/* Kata — dojo minimalism. Ink, paper, one red seal. Dark only, phone only. */

:root {
  --ink: #0e0e0e;
  --ink-2: #181818;
  --ink-3: #202020;
  --paper: #f2efe9;
  --paper-2: #b5b2ab;
  --mute: #6f6d68;
  --seal: #c8102e;
  --line: #2a2a2a;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  padding: var(--safe-top) 16px calc(var(--safe-bottom) + 12px);
  /* Phone-first: stays phone-shaped on a desktop so QA sees what the phone sees. */
  max-width: 480px;
  margin: 0 auto;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:active { transform: scale(0.98); }

/* Author `display` rules outrank the UA's [hidden] rule — restore it explicitly. */
[hidden] { display: none !important; }

/* ---------- screen switching ---------- */
.screen { display: none; flex: 1; flex-direction: column; min-height: 0; }
body[data-screen="home"]   #screen-home   { display: flex; }
body[data-screen="player"] #screen-player { display: flex; }
body[data-screen="done"]   #screen-done   { display: flex; }

/* ---------- shared ---------- */
.label {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0 6px;
  min-height: 44px;
}
.topbar .spacer { flex: 1; }

.iconbtn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  color: var(--paper-2);
}
.iconbtn[aria-pressed="false"] { color: var(--mute); }

.version { font-size: 12px; color: var(--mute); font-variant-numeric: tabular-nums; }

/* ---------- home ---------- */
.brand {
  font-size: 15px;
  letter-spacing: 0.3em;
  color: var(--paper-2);
  text-transform: uppercase;
}
.brand .glyph { color: var(--seal); font-size: 17px; letter-spacing: 0; }

.card {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-top: 18px;
}
.card h1 { font-size: 30px; line-height: 1.15; margin: 0 0 10px; font-weight: 700; }
.card .meta { font-size: 17px; color: var(--paper-2); font-variant-numeric: tabular-nums; }
.card .lastdone { font-size: 15px; color: var(--mute); margin-top: 14px; }

.dots { display: flex; gap: 7px; margin-top: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.dot.on { background: var(--paper-2); }

.home-foot { margin-top: auto; padding-top: 20px; }

.primary {
  width: 100%;
  min-height: 92px;
  border-radius: var(--radius);
  background: var(--seal);
  color: var(--paper);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: 0.18em;
}
.secondary {
  width: 100%;
  min-height: 60px;
  border-radius: var(--radius);
  background: var(--ink-2);
  border: 1px solid var(--line);
  color: var(--paper);
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 10px;
}

.pill {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--ink-3);
  border: 1px solid var(--line);
  color: var(--paper-2);
  font-size: 15px;
}

.footnote { margin-top: 14px; text-align: center; font-size: 12px; color: var(--mute); }

/* ---------- player ---------- */
.progress {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  flex: 1;
}
.progress span { display: block; height: 100%; background: var(--paper-2); width: 0%; }
.counter { font-size: 13px; color: var(--mute); font-variant-numeric: tabular-nums; min-width: 46px; }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  min-height: 0;
  padding: 4px 0;
}

.frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 30vh;
  border-radius: var(--radius);
  background: var(--ink-2);
  border: 1px solid var(--line);
  overflow: hidden;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.frame img { width: 100%; height: 100%; object-fit: cover; display: none; }
.frame img.on { display: block; }
.frame .placeholder { font-size: 74px; color: var(--line); font-weight: 700; }

.titlerow { display: flex; align-items: baseline; gap: 10px; }
.movename { font-size: 32px; font-weight: 700; line-height: 1.1; flex: 1; }
.side {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--ink-3);
  color: var(--paper-2);
}
.side.hidden { display: none; }
.gaplabel { color: var(--seal); font-weight: 700; letter-spacing: 0.14em; font-size: 14px; }
.cue { font-size: 19px; color: var(--paper-2); line-height: 1.3; }
.note { font-size: 16px; color: var(--mute); }
.sampletag {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--mute);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 5px;
  margin-left: 8px;
  vertical-align: middle;
}

/* The ring is absolutely positioned, so the wrapper must reserve its height
   or it draws over the cue and look-ahead lines. */
.countwrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 184px;
  flex-shrink: 0;
}
.countwrap svg { position: absolute; width: 176px; height: 176px; transform: rotate(-90deg); }
.countwrap circle { fill: none; stroke-width: 5; }
.countwrap .track { stroke: var(--line); }
.countwrap .arc { stroke: var(--paper); transition: stroke-dashoffset 0.2s linear; }
.count {
  font-size: 88px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.02em;
}
@media (min-height: 800px) { .count { font-size: 104px; } }

.lookahead { font-size: 16px; color: var(--mute); min-height: 22px; }
.lookahead b { color: var(--paper-2); font-weight: 600; }

.controls { display: flex; gap: 10px; margin-top: 10px; }
.controls button {
  min-height: 76px;
  border-radius: var(--radius);
  background: var(--ink-2);
  border: 1px solid var(--line);
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.controls .w25 { flex: 0 0 25%; }
.controls .w50 { flex: 0 0 calc(50% - 20px); font-size: 30px; }
.controls .w50.act { background: var(--seal); border-color: var(--seal); font-size: 22px; letter-spacing: 0.1em; }

.navrow { display: flex; gap: 10px; margin-top: 10px; }
.navrow button {
  flex: 1;
  min-height: 58px;
  border-radius: var(--radius);
  background: transparent;
  border: 1px solid var(--line);
  color: var(--paper-2);
  font-size: 16px;
}

/* paused veil */
.veil {
  position: fixed;
  inset: 0;
  background: rgba(14, 14, 14, 0.82);
  display: none;
  place-items: center;
  z-index: 20;
}
body.paused .veil { display: grid; }
.veil .word { font-size: 26px; letter-spacing: 0.3em; color: var(--paper-2); }
.veil .hint { font-size: 15px; color: var(--mute); margin-top: 10px; text-align: center; }

/* edge flash — the silent cue */
.flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  box-shadow: inset 0 0 0 0 transparent;
}
.flash.go { animation: flash-paper 260ms ease-out; }
.flash.gap { animation: flash-seal 260ms ease-out; }
@keyframes flash-paper {
  from { box-shadow: inset 0 0 0 9px var(--paper); }
  to   { box-shadow: inset 0 0 0 9px transparent; }
}
@keyframes flash-seal {
  from { box-shadow: inset 0 0 0 9px var(--seal); }
  to   { box-shadow: inset 0 0 0 9px transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .flash.go, .flash.gap { animation-duration: 120ms; }
}

/* ---------- done ---------- */
.done-hero { margin-top: 14vh; text-align: center; }
.done-hero .mark { font-size: 64px; color: var(--seal); font-weight: 700; }
.done-hero h1 { font-size: 34px; margin: 12px 0 6px; }
.done-hero .stat { font-size: 19px; color: var(--paper-2); font-variant-numeric: tabular-nums; }
.done-hero .sub { font-size: 15px; color: var(--mute); margin-top: 8px; }
.done-foot { margin-top: auto; }
.chain { margin-top: 22px; }
.chain a {
  display: block;
  text-align: center;
  min-height: 60px;
  line-height: 60px;
  border-radius: var(--radius);
  background: var(--ink-2);
  border: 1px solid var(--line);
  color: var(--paper);
  font-size: 17px;
  font-weight: 600;
  text-decoration: none;
  margin-bottom: 10px;
}

/* ---------- settings sheet ---------- */
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--ink-2);
  border-top: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(var(--safe-bottom) + 20px);
  transform: translateY(110%);
  transition: transform 0.22s ease-out;
  z-index: 40;
}
body.sheet-open .sheet { transform: translateY(0); }
.sheet h2 { font-size: 19px; margin: 0 0 16px; }
.row { display: flex; align-items: center; justify-content: space-between; padding: 13px 0; border-bottom: 1px solid var(--line); }
.row:last-of-type { border-bottom: 0; }
.row span { font-size: 17px; }
.row input[type="range"] { width: 150px; accent-color: var(--seal); }
.switch { min-width: 64px; text-align: right; font-size: 17px; font-weight: 600; color: var(--seal); }
.switch[aria-pressed="false"] { color: var(--mute); }
.sheet .secondary { margin-top: 16px; }
