/* Colour tokens here are a first-paint fallback: src/theme.js is the source of
   truth and overwrites them on the root element as soon as the module runs. */
:root {
  --bg: #070b10; --bg2: #0c1219; --ink: #d7e6e2; --muted: #8fa3b0; --accent: #35e0a0; --cool: #48b6ff;
  --blue: #3d7bff; --danger: #ff8080; --dim: #1a2530;
  --line: rgba(120,224,190,0.16); --panel: rgba(7,11,16,0.78); --panel-blur: 14px;
  --fs-xs: 10.5px; --fs-sm: 11px; --fs-md: 12px;
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
:root[data-theme="light"] {
  --bg: #eef4f2; --bg2: #e2ebe8; --ink: #0d1b1a; --muted: #4a5c5b; --accent: #0d9e6d; --cool: #0e7490;
  --blue: #2563eb; --danger: #b42318; --dim: #cddbd6;
  --line: rgba(13,27,26,0.16); --panel: rgba(238,244,242,0.85);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--mono); font-size: 13px; line-height: 1.5;
  overflow: hidden; -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease; /* canvases repaint on their own schedule; ease the shell to meet them */
}
:where(button, a[href], input, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#stage { position: fixed; inset: 0; z-index: 0; }
#stage canvas.stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* hiding the UI must also take it out of the tab order, not just fade it */
.ui { position: fixed; z-index: 2; transition: opacity .35s ease, transform .35s ease, visibility 0s; }
body.ui-hidden .ui {
  opacity: 0; pointer-events: none; transform: translateY(6px); visibility: hidden;
  transition: opacity .35s ease, transform .35s ease, visibility 0s linear .35s;
}
.ui-hint {
  position: fixed; right: 14px; bottom: 12px; z-index: 3; appearance: none; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  font-family: var(--mono); font-size: var(--fs-sm); padding: 5px 10px; border-radius: 2px;
  opacity: 0; visibility: hidden; transition: opacity .4s ease, visibility 0s linear .4s;
}
body.ui-hidden .ui-hint { opacity: .75; visibility: visible; transition: opacity .4s ease, visibility 0s; }
body.ui-hidden .ui-hint:hover, body.ui-hidden .ui-hint:focus-visible { opacity: 1; border-color: var(--accent); color: var(--ink); }

/* brand */
.brand { top: 22px; left: 26px; display: flex; gap: 14px; align-items: flex-start; }
.mark { font-family: var(--serif); font-weight: 600; font-size: 28px; letter-spacing: -0.02em; line-height: 1; padding-top: 2px; }
.mark span { color: var(--accent); font-style: italic; font-weight: 300; margin: 0 1px; }
.brand-text .t1 { font-family: var(--serif); font-size: 20px; font-weight: 300; font-style: italic; line-height: 1.1; }
.brand-text .t2 { color: var(--muted); font-size: var(--fs-sm); margin-top: 5px; max-width: 46ch; }

/* tabs: specimen tags */
.tabs { left: 26px; bottom: 70px; display: flex; flex-direction: column; gap: 4px; }
.tab {
  appearance: none; background: var(--panel); backdrop-filter: blur(var(--panel-blur)); -webkit-backdrop-filter: blur(var(--panel-blur));
  color: var(--ink); border: 1px solid var(--line); border-left: 3px solid transparent; border-radius: 2px;
  padding: 7px 12px 7px 10px; text-align: left; cursor: pointer; font-family: var(--mono); font-size: var(--fs-md);
  display: grid; grid-template-columns: 2.2em 1fr auto; gap: 10px; align-items: baseline; min-width: 230px;
  transition: border-color .2s, background .2s, transform .2s;
}
.tab:hover { transform: translateX(2px); border-color: var(--accent); }
.tab[aria-selected="true"] { border-left-color: var(--accent); background: color-mix(in srgb, var(--panel) 70%, var(--accent) 12%); }
.tab .num { color: var(--accent); font-weight: 500; }
.tab .name { font-family: var(--serif); font-size: 15px; font-weight: 500; letter-spacing: -0.01em; }
.tab .engine { color: var(--muted); font-size: var(--fs-xs); }

/* card */
.card-wrap { top: 22px; right: 22px; width: min(360px, calc(100vw - 44px)); max-height: calc(100vh - 110px); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.card-toggle { appearance: none; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-family: var(--mono); font-size: var(--fs-sm); padding: 4px 9px; border-radius: 2px; cursor: pointer; }
.card-toggle:hover { border-color: var(--accent); color: var(--ink); }
.card {
  width: 100%; overflow: auto; background: var(--panel); backdrop-filter: blur(var(--panel-blur)); -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--line); border-top: 2px solid var(--accent); border-radius: 2px; padding: 16px 18px 14px;
  scrollbar-width: thin; animation: rise .45s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
body.card-collapsed .card { display: none; }
/* collapsed is the mobile default, so this line is where most visitors learn the background reacts to them */
.card-brief { display: none; }
body.card-collapsed .card-brief {
  display: block; width: 100%; text-align: right; background: var(--panel);
  backdrop-filter: blur(var(--panel-blur)); -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--line); border-right: 2px solid var(--accent); border-radius: 2px; padding: 8px 10px;
}
.card-brief .tagline { margin: 0; }
.card-brief .brief-interact { margin: 4px 0 0; color: var(--ink); font-size: var(--fs-sm); }
.card-head { display: flex; align-items: baseline; gap: 10px; }
.card-head .num { color: var(--accent); font-weight: 500; }
.card-head h1 { font-family: var(--serif); font-weight: 300; font-size: 30px; letter-spacing: -0.02em; margin: 0; line-height: 1; }
.card-head .engine { margin-left: auto; color: var(--muted); font-size: var(--fs-sm); }
.tagline { margin: 8px 0 12px; color: var(--muted); font-size: var(--fs-sm); letter-spacing: .02em; }
.error { color: var(--danger); border: 1px dashed var(--danger); padding: 8px 10px; border-radius: 2px; }
.spec { margin: 0; display: grid; grid-template-columns: 6em 1fr; gap: 8px 12px; }
.spec dt { color: var(--accent); font-size: var(--fs-sm); padding-top: 3px; }
.spec dd { margin: 0; font-family: var(--serif); font-size: 14px; line-height: 1.55; font-weight: 300; }
.spec dd::first-letter { font-weight: 500; }
.target { display: block; width: 96px; height: 96px; image-rendering: pixelated; margin: 12px 0 0; border: 1px solid var(--line); background: var(--bg2); }
.opts { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.opt { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.opt .lbl { color: var(--muted); font-size: var(--fs-sm); min-width: 5em; }
.chip { appearance: none; border: 1px solid var(--line); background: transparent; color: var(--ink); font-family: var(--mono); font-size: var(--fs-sm); padding: 3px 8px; border-radius: 999px; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.refs { margin: 14px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); list-style: none; color: var(--muted); font-size: var(--fs-xs); line-height: 1.5; }
.refs li::before { content: "— "; }
.stats { margin-top: 10px; color: var(--muted); font-size: var(--fs-xs); letter-spacing: .02em; }

/* toolbar */
.toolbar { left: 26px; bottom: 18px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar button, .toolbar .speed {
  border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(var(--panel-blur)); -webkit-backdrop-filter: blur(var(--panel-blur));
  color: var(--ink); font-family: var(--mono); font-size: var(--fs-sm); padding: 5px 10px; border-radius: 2px; cursor: pointer;
}
.toolbar button:hover { border-color: var(--accent); }
.toolbar .speed { display: flex; align-items: center; gap: 8px; cursor: default; }
.toolbar .speed span { color: var(--muted); }
.toolbar input[type=range] { width: 110px; accent-color: var(--accent); }
.toolbar output { min-width: 4.5em; }
.toolbar .keys { color: var(--muted); font-size: var(--fs-xs); margin-left: 6px; }
#motion[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

@media (max-width: 760px) {
  .brand { top: 12px; left: 12px; }
  .brand-text .t2, .toolbar .keys { display: none; }
  /* tabs become one horizontal, scrollable row directly above the toolbar */
  .tabs { left: 12px; right: 12px; bottom: 62px; flex-direction: row; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .tab { min-width: 0; flex: 0 0 auto; grid-template-columns: auto auto; padding: 6px 10px; }
  .tab .engine { display: none; }
  .tab .name { font-size: 13px; }
  .toolbar { left: 12px; right: 12px; bottom: 10px; gap: 6px; }
  .toolbar input[type=range] { width: 70px; }
  /* card floats at the top and starts collapsed (main.js adds .card-collapsed on small screens) */
  .card-wrap { top: 56px; right: 12px; left: 12px; width: auto; max-height: calc(100vh - 190px); }
  .card { padding: 12px 14px; }
  .card-head h1 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { body, .ui, .card { transition: none; animation: none; } }
