/* thock: audition screen. Shares the mwlabs.be palette (cool paper,
   deep ink, amber accent) with lab.html's styles.css. */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --line: #dbe0ea;
  --line-2: #c5cdda;
  --ink: #0b1220;
  --ink-dim: #475569;
  --ink-mute: #64708a;
  --accent: #b45309;
  --accent-ink: #ffffff;
  --accent-soft: rgba(217, 119, 6, 0.14);
  --focus: #b45309;

  /* Atlas prototype, after images/atlas-render.png: walnut housing,
     yellow cover and caps, red trackpoint. */
  --case: #7a4f33;
  --case-top: #946342;
  --cover: #e3a21a;
  --cap: #f7c548;
  --cap-side: #c98a12;
  --legend: #5b3a08;
  --nub: #c8352a;

  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #131c30;
    --line: #273349;
    --line-2: #36445d;
    --ink: #e8edf5;
    --ink-dim: #a3afc2;
    --ink-mute: #8692a6;
    --accent: #f59e0b;
    --accent-ink: #0b1220;
    --accent-soft: rgba(245, 158, 11, 0.16);
    --focus: #fbbf24;

    --case: #5c3b26;
    --case-top: #734c33;
    --cover: #c98b12;
    --cap: #e8b53e;
    --cap-side: #a8730e;
    --legend: #4a2f06;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
html.is-play, html.is-play body { overflow: hidden; overscroll-behavior: none; }

a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
a:hover { color: var(--accent); text-decoration-color: currentColor; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap;
}

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

/* ----------------------------- shared ---------------------------- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 0 max(20px, env(safe-area-inset-left)) 0 max(20px, env(safe-area-inset-right));
}

/* Wordmark: set like the mwlabs.be mark (Plex Mono 600, tight
   tracking), one amber square standing in for the full stop. */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
  line-height: 1;
}
.brand a { text-decoration: none; }
.brand-word {
  position: relative;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.03em;
  color: var(--ink);
  padding-right: 7px;
  font-feature-settings: "zero" on;
}
.brand-word::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0.14em;
  width: 4px;
  height: 4px;
  border-radius: 1px;
  background: var(--accent);
}
.brand-word:hover { color: var(--ink); opacity: 0.7; }
.brand-rule { width: 1px; height: 14px; background: var(--line-2); }
.brand-by {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
}
.brand-by:hover { color: var(--ink); }

.btn {
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 10px 20px;
  min-height: 44px;
  cursor: pointer;
  transition: background-color 120ms, border-color 120ms, color 120ms;
}
.btn:hover:not(:disabled) { border-color: var(--ink-dim); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.primary:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.ghost { background: transparent; }
.btn.small { font-size: 13px; padding: 6px 14px; min-height: 36px; color: var(--ink-dim); }

.link-btn {
  font: inherit;
  font-size: 13px;
  color: var(--ink-dim);
  background: none;
  border: 0;
  padding: 8px 4px;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--line-2);
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--accent); }

/* --------------------------- pick screen ------------------------- */

.pick { min-height: 100dvh; display: flex; flex-direction: column; }

.pick-inner {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 20px 32px;
  flex: 1;
}

.pick h1 {
  font-size: clamp(26px, 4.4vw, 38px);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 8px 0 10px;
}
.lede { margin: 0 0 28px; color: var(--ink-dim); max-width: 36em; }

.pick-group { margin-bottom: 28px; }
.pick-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.pick-group h2 {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 0;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 40px 12px 12px;
  min-height: 64px;
  cursor: pointer;
  transition: border-color 120ms, box-shadow 120ms, background-color 120ms;
  -webkit-tap-highlight-color: transparent;
}
.card:hover { border-color: var(--line-2); }
.card[aria-pressed="true"] {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.stem {
  flex: none;
  width: 34px; height: 34px;
  padding: 6px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--c) 14%, var(--surface));
  fill: var(--c);
}
.card-text { display: flex; flex-direction: column; min-width: 0; }
.card-name { font-weight: 500; line-height: 1.25; }
.card-type { font-size: 13px; color: var(--ink-dim); line-height: 1.3; }
.card-spec { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-mute); line-height: 1.4; }
.card-check {
  position: absolute;
  right: 12px; top: 50%;
  width: 20px; height: 20px;
  margin-top: -10px;
  border-radius: 50%;
  border: 1.5px solid var(--line-2);
}
.card[aria-pressed="true"] .card-check {
  background: var(--ink);
  border-color: var(--ink);
}
.card[aria-pressed="true"] .card-check::after {
  content: "";
  position: absolute;
  left: 5.5px; top: 2.5px;
  width: 5px; height: 9px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.pick-bar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 10px 20px calc(10px + env(safe-area-inset-bottom));
}
.pick-bar-inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.pick-count { font-family: var(--font-mono); font-size: 13px; color: var(--ink-dim); }

.foot {
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 20px 24px;
  font-size: 13px;
  color: var(--ink-mute);
}

/* --------------------------- play screen ------------------------- */

.play {
  height: var(--app-h, 100dvh);
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  padding-bottom: env(safe-area-inset-bottom);
}

.bar-actions { display: flex; align-items: center; gap: 6px; }

.room select {
  font: inherit;
  font-size: 13px;
  color: var(--ink-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 10px;
  min-height: 36px;
  max-width: 44vw;
  cursor: pointer;
}
.room select:hover { border-color: var(--line-2); }

.switchbar { padding: 4px 20px 0; text-align: center; }

.switches {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 14px;
  color: var(--ink-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px 7px 10px;
  min-height: 40px;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 120ms, color 120ms, background-color 120ms;
}
.pill:hover { border-color: var(--line-2); color: var(--ink); }
.pill[aria-checked="true"] {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.pill-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.pill-tag { font-family: var(--font-mono); font-size: 11px; color: var(--ink-mute); }
.pill-bar {
  position: absolute;
  left: 0; bottom: 0;
  height: 2px;
  width: calc(var(--p, 0) * 100%);
  background: var(--c);
  opacity: 0;
  transition: width 120ms linear, opacity 200ms;
}
.pill.loading .pill-bar { opacity: 1; }
.pill.loading .pill-name { opacity: 0.6; }
.pill.failed .pill-name { text-decoration: line-through; }

.switch-info {
  margin: 8px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-mute);
  min-height: 1.5em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Atlas */

.board {
  --press: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 5vw, 72px);
  min-height: 0;
  padding: 12px 20px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.half {
  flex: 1 1 0;
  min-width: 0;
  max-width: 540px;
  height: 100%;
  max-height: 460px;
  overflow: visible;
}

.case-shadow { fill: rgba(11, 18, 32, 0.14); }
.cover { fill: var(--cover); }
.case { fill: var(--case); }
.case-top { fill: var(--case-top); }

.key { cursor: pointer; }
.hit { fill: transparent; }
.cap-side { fill: var(--cap-side); }
.cap-top { fill: var(--cap); }
.cap-glow { fill: var(--press); opacity: 0; transition: opacity 120ms ease-out; }
.cap { transition: transform 90ms cubic-bezier(.2, .7, .3, 1); }
.legend {
  font-family: var(--font-mono);
  font-size: 4.6px;
  font-weight: 500;
  fill: var(--legend);
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
.legend.small { font-size: 3.1px; letter-spacing: 0.02em; }
.legend.hold { font-size: 2.5px; fill: var(--legend); opacity: 0.6; }

.key.down .cap { transform: translateY(1.1px); transition-duration: 0ms; }
.key.down .cap-glow { opacity: 0.85; transition-duration: 0ms; }
.key.down .cap-top { stroke: rgba(0, 0, 0, 0.25); stroke-width: 0.3; }
.key.latched .cap-glow { opacity: 0.3; }

.nub-ring { fill: rgba(0, 0, 0, 0.28); }
.nub { fill: var(--nub); }

/* typed text */

.pad {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 4px 20px 16px;
}
#typed {
  display: block;
  width: 100%;
  resize: none;
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  height: calc(3 * 1.5em + 24px + 2px);
  caret-color: var(--accent);
}
#typed::placeholder { color: var(--ink-mute); }
#typed:focus { outline: none; border-color: var(--ink-dim); }
#typed:focus-visible { outline: none; }
.pad-actions { display: flex; justify-content: flex-end; gap: 4px; margin-top: 4px; }
.touch-only { display: none; }
.touch .touch-only { display: inline-block; }

/* Phones in portrait: stack the halves and let them fill the width. */
@media (max-width: 720px) and (orientation: portrait) {
  .bar { min-height: 48px; padding: 0 14px; }
  .switchbar { padding: 0; }
  .switches {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 2px 14px;
    scroll-padding: 0 14px;
  }
  .switches::-webkit-scrollbar { display: none; }
  .pill { flex: none; }
  .switch-info { padding: 0 14px; margin-top: 6px; font-size: 11px; }
  .board { flex-direction: column; gap: 8px; padding: 8px 8px; }
  .half { width: 100%; max-width: none; max-height: none; flex: 1 1 0; min-height: 0; }
  .pad { padding: 0 12px 8px; }
  #typed { font-size: 16px; height: calc(2 * 1.5em + 20px + 2px); padding: 10px 12px; }
  .pad-actions { margin-top: 2px; }
  .brand-word { font-size: 18px; }
  .pick-inner { padding-top: 12px; }
  .lede { margin-bottom: 20px; }
  .cards { gap: 8px; }
  .card { min-height: 0; padding: 10px 40px 10px 10px; }
}

/* Short landscape windows (phones on their side). */
@media (max-height: 500px) and (orientation: landscape) {
  .bar { min-height: 44px; }
  .switch-info { display: none; }
  .board { padding: 6px 20px; }
  #typed { height: calc(1.5em + 20px + 2px); padding: 10px 12px; font-size: 16px; }
  .pad { padding-bottom: 6px; }
  .pad-actions { display: none; }
}

@media (max-height: 720px) and (orientation: portrait) {
  .switch-info { display: none; }
  .pad-actions .btn.small { min-height: 30px; padding: 4px 12px; }
}

@media (max-width: 400px) {
  .brand-rule, .brand-by { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cap, .cap-glow, .pill-bar { transition: none; }
}
