/* Shared look for the esp32-emu webdemo. Plain CSS, no build step, no
   frameworks. Palette and type follow the design plan: signal-room
   phosphor-on-ink with oxide-red accents. */

:root {
  --ink: #101418;
  --ink-2: #171d23;
  --panel: #1c232b;
  --panel-2: #222c35;
  --line: #2e3944;
  --text: #e8e4d8;
  --muted: #a7a798;
  --dim: #6f7a86;
  --green: #7ee787;
  --amber: #e8b34b;
  --red: #e4572e;
  --cyan: #6fd3e7;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(126, 231, 135, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(126, 231, 135, 0.025) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, black 30%, transparent 100%);
}

a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: #a5f3ae; }
a:focus-visible, button:focus-visible, select:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* ---- top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(16, 20, 24, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex-shrink: 0; }
.brand > span:last-child { line-height: 1.25; white-space: nowrap; }
.brand-mark {
  width: 30px; height: 30px;
  border: 1px solid var(--green);
  border-radius: 6px;
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--green);
  background: rgba(126, 231, 135, 0.07);
}
.brand b { font-weight: 700; letter-spacing: 0.01em; }
.brand small { color: var(--dim); font-family: var(--mono); font-size: 11px; }
.topbar nav { margin-left: auto; display: flex; gap: 4px; }
.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
}
.topbar nav a:hover { color: var(--text); background: var(--panel); }
.topbar nav a[aria-current="page"] { color: var(--green); background: rgba(126, 231, 135, 0.08); }

/* ---- hero ---- */
.hero { padding: 64px 0 28px; }
.kicker {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--green);
  letter-spacing: 0.02em;
  margin: 0 0 14px;
}
.kicker .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 8px; }
.hero h1 {
  margin: 0 0 16px;
  font-size: clamp(34px, 5.2vw, 58px);
  line-height: 1.04;
  letter-spacing: -0.02em;
  font-weight: 800;
  max-width: 20ch;
}
.hero h1 .accent { color: var(--red); }
.hero p.lede { max-width: 62ch; color: var(--muted); font-size: 17px; margin: 0 0 24px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 36px; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:hover { border-color: var(--dim); background: var(--panel-2); }
.btn.primary { background: var(--green); border-color: var(--green); color: #0c1210; font-weight: 700; }
.btn.primary:hover { background: #93f09c; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn:disabled { opacity: 0.45; cursor: wait; }

/* ---- stat strip ---- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--ink-2);
}
.stat { padding: 18px 20px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat .v { font-family: var(--mono); font-size: 26px; font-weight: 600; color: var(--text); }
.stat .v em { font-style: normal; color: var(--green); }
.stat .l { font-size: 13px; color: var(--dim); margin-top: 2px; }

/* ---- sections ---- */
.section { padding: 40px 0; }
.section h2 { font-size: 24px; letter-spacing: -0.01em; margin: 0 0 8px; }
.section .sub { color: var(--muted); margin: 0 0 20px; max-width: 70ch; }

/* ---- screenshots (indexable <img> with keyword-rich alt text) ---- */
.shot { margin: 28px 0 0; }
.shot img { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 14px; }
.shot figcaption { color: var(--dim); font-size: 13px; margin-top: 8px; }

/* ---- console layout ---- */
.console-grid { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.panel {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}
.panel h3 { margin: 0 0 12px; font-size: 14px; font-family: var(--mono); font-weight: 600; color: var(--muted); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field select, .field input[type="text"] {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
  font-size: 14px;
}
.demo-list { display: flex; flex-direction: column; gap: 6px; max-height: 380px; overflow: auto; }
.demo-item {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 10px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
}
.demo-item .t { display: block; font-weight: 600; }
.demo-item .d { display: block; color: var(--dim); font-size: 12px; font-family: var(--mono); }
.demo-item:hover { background: var(--panel); }
.demo-item[aria-pressed="true"] { border-color: var(--green); background: rgba(126, 231, 135, 0.06); }
.demo-item[aria-pressed="true"] .d { color: var(--green); }
.demo-item .mips { display: block; color: var(--dim); font-size: 11px; font-family: var(--mono); }
.demo-item[aria-pressed="true"] .mips { color: var(--green); }
.demo-item[hidden] { display: none; }
.demo-actions { display: flex; gap: 8px; margin-top: 10px; }
.demo-actions .btn { flex: 1; justify-content: center; padding: 8px 6px; font-size: 13.5px; }
.panel h3 .count { color: var(--dim); font-weight: 400; }
.board-row { display: flex; gap: 8px; }
.board-row .btn { flex: 1; justify-content: center; padding: 8px 6px; font-size: 13.5px; }
.board-row .btn[aria-pressed="true"] { border-color: var(--cyan); color: var(--cyan); }

/* WiFi + OTA preset panel */
.wifi-note { font-size: 12.5px; color: var(--dim); margin: 0 0 10px; }
.wifi-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px;
  font-family: var(--mono); font-size: 12px; }
.wifi-stats[hidden] { display: none; }
.wifi-stats div { background: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 9px; display: flex; justify-content: space-between; gap: 8px; }
.wifi-stats span { color: var(--dim); }
.wifi-stats b { color: var(--green); font-weight: 600; white-space: nowrap; }

.run-row { display: flex; gap: 10px; margin-top: 6px; }
.run-row .btn { flex: 1; justify-content: center; }

/* UART echo input (visible only while an interactive demo runs) */
.echo-row { display: flex; gap: 8px; margin-top: 10px; }
.echo-row[hidden] { display: none; }
.echo-row input {
  flex: 1;
  min-width: 0;
  background: var(--ink);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 10px;
  font-family: var(--mono);
  font-size: 13.5px;
}
.echo-row input:disabled { opacity: 0.45; }

/* Outbound repo link in the top nav */
.topbar nav a[target="_blank"] { border: 1px solid var(--line); }

/* terminal mini buttons */
.screen-bar .term-actions { display: flex; gap: 6px; margin-left: 8px; }
.mini-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 3px 9px;
  cursor: pointer;
}
.mini-btn:hover:not(:disabled) { color: var(--text); border-color: var(--dim); }
.mini-btn:disabled { opacity: 0.4; cursor: default; }

/* per-demo verified MIPS line under the verdict */
.demo-mips {
  border: 1px solid var(--line);
  background: var(--ink-2);
  border-radius: 10px;
  padding: 10px 18px;
  color: var(--muted);
  font-size: 13.5px;
  font-family: var(--mono);
  margin: 12px 0 0;
}
.demo-mips[hidden] { display: none; }
.demo-mips b { color: var(--green); }

/* sketch modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 12, 0.72);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  max-width: 760px;
  width: 100%;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 13px;
}
.modal-bar span { display: flex; gap: 8px; }
.modal pre {
  margin: 0;
  padding: 16px 18px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: #cfd6c9;
  white-space: pre;
}

.screen {
  background: #0a0d10;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.screen-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--dim);
}
.screen-bar .lights { display: flex; gap: 6px; }
.screen-bar .lights i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); display: block; }
.screen-bar .lights i.on { background: var(--green); }
#statusLine { margin-left: auto; }
#statusLine.live { color: var(--green); }
#term {
  height: 420px;
  overflow-y: auto;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  color: #cfd6c9;
}
#term .ok { color: var(--green); }
#term .warn { color: var(--amber); }
#term .err { color: var(--red); }
#term .dim { color: var(--dim); }
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
}
.metric { padding: 12px 16px; border-left: 1px solid var(--line); font-family: var(--mono); }
.metric:first-child { border-left: 0; }
.metric .v { font-size: 18px; color: var(--text); }
.metric .v em { font-style: normal; color: var(--amber); }
.metric .l { font-size: 11.5px; color: var(--dim); }

/* ---- note / callout ---- */
.callout {
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  background: var(--ink-2);
  border-radius: 10px;
  padding: 14px 18px;
  color: var(--muted);
  font-size: 14.5px;
  margin: 20px 0;
}
.callout b { color: var(--text); }

/* ---- docs tables ---- */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table.matrix { border-collapse: collapse; width: 100%; font-size: 14px; background: var(--ink-2); }
table.matrix th, table.matrix td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.matrix td:last-child, table.matrix th:last-child { white-space: nowrap; }
table.matrix thead th { font-family: var(--mono); font-size: 12px; color: var(--muted); background: var(--panel); position: sticky; top: 0; }
table.matrix tbody tr:last-child th, table.matrix tbody tr:last-child td { border-bottom: 0; }
.pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
}
.pill.yes { color: var(--green); border-color: var(--green); background: rgba(126, 231, 135, 0.07); }
.pill.partial { color: var(--amber); border-color: var(--amber); background: rgba(232, 179, 75, 0.07); }
.pill.no { color: var(--dim); border-color: var(--dim); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 12px 0 0; }

/* ---- about ---- */
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.kv { font-family: var(--mono); font-size: 13.5px; }
.kv dt { color: var(--dim); margin-top: 10px; }
.kv dd { margin: 2px 0 0; color: var(--text); }
pre.code {
  background: #0a0d10;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  color: #cfd6c9;
}
pre.code .c { color: var(--dim); }

footer { border-top: 1px solid var(--line); margin-top: 48px; padding: 24px 0 48px; color: var(--dim); font-size: 13.5px; }
footer .wrap { display: flex; gap: 20px; flex-wrap: wrap; }
footer nav { margin-left: auto; display: flex; gap: 16px; }
footer nav a { color: var(--dim); text-decoration: none; }
footer nav a:hover { color: var(--text); }

@media (max-width: 900px) {
  .console-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(3) { border-left: 0; }
  .stat { border-top: 1px solid var(--line); }
  .stat:nth-child(-n+2) { border-top: 0; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(3) { border-left: 0; }
  .metric { border-top: 1px solid var(--line); }
  .metric:nth-child(-n+2) { border-top: 0; }
  .about-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}
