/* MBusinoLibPy Web Decoder - no framework, no build step. */

:root {
  --bg: #f6f7f9;
  --card-bg: #ffffff;
  --text: #1a1d21;
  --muted: #5b6470;
  --border: #d9dee5;
  --accent: #1454c7;
  --accent-contrast: #ffffff;
  --focus: #0b57d0;
  --ok-bg: #e7f6ec;
  --ok-border: #86cf9b;
  --ok-text: #14532d;
  --err-bg: #fdecec;
  --err-border: #eaa5a5;
  --err-text: #7f1d1d;
  --warn-bg: #fff3e0;
  --warn-border: #f0a94a;
  --warn-text: #8a4b00;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --card-bg: #1d2126;
    --text: #e8eaed;
    --muted: #9aa4b1;
    --border: #333a42;
    --accent: #6ea8ff;
    --accent-contrast: #10131a;
    --focus: #8ab4ff;
    --ok-bg: #12301d;
    --ok-border: #2f6b45;
    --ok-text: #b9f0cb;
    --err-bg: #351515;
    --err-border: #7d3b3b;
    --err-text: #ffc9c9;
    --warn-bg: #3a2a12;
    --warn-border: #b8781f;
    --warn-text: #ffd9a0;
  }
}

* {
  box-sizing: border-box;
}

/* Author display rules would otherwise override the UA style for [hidden]. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
}

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

a {
  color: var(--accent);
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ */
/* Header                                                              */
/* ------------------------------------------------------------------ */

.site-header {
  padding: 2.5rem 0 1rem;
}

.site-header h1 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.5rem, 4vw, 2rem);
  letter-spacing: -0.01em;
}

.tagline {
  margin: 0 0 1rem;
  color: var(--muted);
}

.runtime-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  font-size: 0.9rem;
  color: var(--muted);
}

.runtime-status .dot {
  width: 0.6em;
  height: 0.6em;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.runtime-status.is-loading .dot {
  background: #d99a00;
  animation: pulse 1.2s ease-in-out infinite;
}

.runtime-status.is-ready .dot {
  background: #2fae60;
}

.runtime-status.is-error .dot {
  background: #d24b4b;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

/* ------------------------------------------------------------------ */
/* Cards and layout                                                    */
/* ------------------------------------------------------------------ */

main {
  padding-bottom: 2.5rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-top: 1.5rem;
}

.card h2,
.card h3,
.card h4 {
  margin-top: 0;
  font-size: 1.1rem;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.muted {
  color: var(--muted);
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: color-mix(in srgb, var(--border) 35%, transparent);
  padding: 0.05em 0.3em;
  border-radius: 4px;
}

/* ------------------------------------------------------------------ */
/* Input                                                               */
/* ------------------------------------------------------------------ */

textarea {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  resize: vertical;
}

textarea::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.shortcut-hint {
  margin-left: auto;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.examples-label {
  font-size: 0.9rem;
  color: var(--muted);
  margin-right: 0.25rem;
}

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */

.btn {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.45rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-small {
  font-size: 0.85rem;
  padding: 0.25rem 0.75rem;
}

.btn-example {
  font-size: 0.875rem;
  padding: 0.3rem 0.75rem;
}

/* ------------------------------------------------------------------ */
/* Banners                                                             */
/* ------------------------------------------------------------------ */

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-top: 1.5rem;
  background: var(--card-bg);
}

.banner-error {
  margin-top: 1rem;
}

.banner-ok {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-text);
}

.banner-fail {
  background: var(--err-bg);
  border-color: var(--err-border);
  color: var(--err-text);
}

.banner .banner-title {
  font-weight: 700;
}

/* ------------------------------------------------------------------ */
/* Results: two engines side by side                                   */
/* ------------------------------------------------------------------ */

.panels {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr;
  margin-top: 1.5rem;
}

/* Let grid children shrink so wide tables scroll instead of squeezing a
   sibling panel. */
.panel {
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.panel-head h3 {
  margin: 0;
  font-size: 1.15rem;
}

.tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.tag-cpp {
  border-color: var(--accent);
  color: var(--accent);
}

.tag-rust {
  border-color: #c1440e;
  color: #c1440e;
}

.panel-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-repo {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-decoration: none;
  color: var(--muted);
  border-bottom: 1px dotted currentColor;
}

.panel-repo:hover {
  color: var(--accent);
  border-bottom-color: currentColor;
}

/* Inside a panel the banner/cards carry no extra top margin. */
.panel .banner {
  margin-top: 0;
}

.panel .card {
  margin-top: 1rem;
}

/* ------------------------------------------------------------------ */
/* Result: header grid + records table                                 */
/* ------------------------------------------------------------------ */

/* Fixed data header: one pair per row - label left, value right.
   A fixed two-column layout (instead of auto-fill) keeps each <dt> on the
   same row as its <dd>: with auto-fill, dt and dd were separate grid items
   and a multi-column layout pushed a value onto the next row. */
.kv-grid {
  display: grid;
  grid-template-columns: minmax(5rem, 10rem) minmax(0, 1fr);
  gap: 0.5rem 1.25rem;
  margin: 0;
  align-items: baseline;
}

.kv-grid dt {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.kv-grid dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

/* "No fixed data header" message spans the full width. */
.kv-grid > .muted {
  grid-column: 1 / -1;
}

.table-scroll {
  overflow-x: auto;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.records-table th,
.records-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.records-table thead th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.records-table tbody tr:last-child td {
  border-bottom: none;
}

.records-table td:not(:nth-child(2)) {
  font-family: var(--mono);
}

.records-table td:nth-child(1) {
  color: var(--muted);
}

.note-follow {
  margin: 0.75rem 0 0;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--warn-border);
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 0.9rem;
}

/* ------------------------------------------------------------------ */
/* Footer                                                              */
/* ------------------------------------------------------------------ */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0 2.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 0.25rem 0;
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */

@media (max-width: 600px) {
  .card {
    padding: 1rem;
  }

  .shortcut-hint {
    margin-left: 0;
    flex-basis: 100%;
  }
}
