/* ==========================================================================
   DICTION DOJO — sumi-ink & vermilion training-poster aesthetic.
   Light washi-paper home · dark ink focus-mode for drills.
   ========================================================================== */

:root {
  --paper: #F3EBDA;
  --paper-deep: #EAE0C9;
  --ink: #1A1714;
  --ink-soft: #4A443C;
  --vermilion: #C93A26;
  --vermilion-deep: #A82C1B;
  --gold: #C9962B;
  --font-display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --font-body: "Schibsted Grotesk", Georgia, sans-serif;
  --font-mono: "Sometype Mono", "Courier New", monospace;
  --shadow-hard: 5px 5px 0 var(--ink);
  --border: 2px solid var(--ink);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at 85% -5%, rgba(201, 58, 38, 0.12) 0%, transparent 42%),
    radial-gradient(circle at -10% 100%, rgba(201, 150, 43, 0.10) 0%, transparent 35%),
    var(--paper);
  min-height: 100vh;
  line-height: 1.5;
}
/* paper grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}
body.no-scroll { overflow: hidden; }

#app {
  position: relative;
  z-index: 2;
  max-width: 1060px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.mono { font-family: var(--font-mono); }

/* ==========================================================================
   MASTHEAD
   ========================================================================== */
.masthead {
  position: relative;
  padding: 12px 0 30px;
  border-bottom: 3px solid var(--ink);
  margin-bottom: 34px;
  animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.masthead-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: var(--border);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.masthead-kicker {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.sound-toggle {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: 5px 12px;
  cursor: pointer;
}
.sound-toggle:hover { background: var(--vermilion); }

.masthead-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(4.2rem, 15vw, 10.5rem);
  line-height: 0.82;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}
.masthead-title .line { display: block; }
.masthead-title .line-accent {
  color: var(--vermilion);
  -webkit-text-stroke: 2px var(--vermilion);
  margin-left: clamp(2rem, 12vw, 9rem);
}

.seal {
  position: absolute;
  right: 6px;
  bottom: 34px;
  width: clamp(88px, 13vw, 132px);
  animation: spin 24s linear infinite;
}
.seal svg { width: 100%; height: auto; display: block; }
.seal-ring { fill: none; stroke: var(--vermilion); stroke-width: 3; }
.seal-core { fill: var(--vermilion); }
.seal-text {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  fill: var(--vermilion);
}
.seal-dd {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 34px;
  fill: var(--paper);
  text-anchor: middle;
}

.masthead-strap {
  margin-top: 16px;
  font-size: 1.02rem;
  max-width: 46ch;
  color: var(--ink-soft);
}
.masthead-strap em { color: var(--vermilion); font-weight: 700; font-style: normal; }

/* ==========================================================================
   SCOREBOARD
   ========================================================================== */
.scoreboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 44px;
}

.score-card {
  border: var(--border);
  background: var(--paper);
  box-shadow: var(--shadow-hard);
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.score-card:nth-child(2) { animation-delay: 0.06s; }
.score-card:nth-child(3) { animation-delay: 0.12s; }
.score-card:nth-child(4) { animation-delay: 0.18s; }

.score-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.score-big {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2.6rem;
  line-height: 1;
  text-transform: uppercase;
}
.score-big .unit {
  font-size: 1rem;
  margin-left: 6px;
  color: var(--ink-soft);
  text-transform: lowercase;
}

.score-sub { font-size: 0.8rem; color: var(--ink-soft); }

.belt-band {
  height: 14px;
  border: var(--border);
  background: #EDE7DA;
}
.belt-band-light { box-shadow: inset 0 0 0 2px var(--paper); }

.xp-track {
  height: 14px;
  border: var(--border);
  background: var(--paper-deep);
  overflow: hidden;
}
.xp-fill {
  height: 100%;
  background: repeating-linear-gradient(-45deg, var(--vermilion) 0 8px, var(--vermilion-deep) 8px 16px);
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.goal-pips { display: flex; gap: 8px; padding: 8px 0 2px; }
.pip {
  width: 26px; height: 26px;
  border: var(--border);
  border-radius: 50%;
  background: var(--paper-deep);
}
.pip-done {
  background: var(--vermilion);
  box-shadow: inset 0 0 0 3px var(--paper);
}

/* ==========================================================================
   SECTIONS
   ========================================================================== */
.section { margin-bottom: 52px; }

.section-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.9rem, 4.5vw, 2.7rem);
  text-transform: uppercase;
  letter-spacing: 0.01em;
  border-bottom: var(--border);
  padding-bottom: 8px;
  margin-bottom: 18px;
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.section-num {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--vermilion);
  font-weight: 700;
}

.section-note {
  margin: -6px 0 18px;
  color: var(--ink-soft);
  font-size: 0.95rem;
  max-width: 62ch;
}

/* ==========================================================================
   DRILL CARDS
   ========================================================================== */
.drill-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.drill-card {
  border: var(--border);
  background: var(--paper);
  box-shadow: var(--shadow-hard);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.drill-card:hover {
  transform: translate(-3px, -3px);
  box-shadow: 8px 8px 0 var(--ink);
}

.drill-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }

.drill-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.7rem;
  text-transform: uppercase;
}

.drill-xp {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--paper);
  background: var(--vermilion);
  padding: 3px 8px;
  white-space: nowrap;
}

.drill-desc { font-size: 0.93rem; color: var(--ink-soft); flex: 1; }

.drill-foot { display: flex; justify-content: space-between; align-items: center; }
.drill-time { font-size: 0.78rem; color: var(--ink-soft); }

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: var(--border);
  padding: 8px 22px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn-primary {
  background: var(--vermilion);
  color: var(--paper);
  border-color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}
.btn-primary:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); background: var(--vermilion-deep); }
.btn-primary:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.btn-big { font-size: 1.3rem; padding: 12px 34px; }

.btn-ghost {
  background: transparent;
  color: inherit;
  border-color: currentColor;
}
.btn-ghost:hover { background: rgba(128, 128, 128, 0.15); }

.link-btn {
  background: none;
  border: none;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
  text-decoration: underline;
  cursor: pointer;
}
.link-btn:hover { color: var(--vermilion); }

/* ==========================================================================
   TWISTERS
   ========================================================================== */
.twister-group { margin-bottom: 26px; }

.twister-level {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  text-transform: uppercase;
  color: var(--vermilion);
  margin-bottom: 10px;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.twister-level .mono { font-size: 0.7rem; color: var(--ink-soft); }

.twister-list { display: flex; flex-direction: column; gap: 8px; }

.twister-row {
  display: grid;
  grid-template-columns: 74px 1fr auto auto;
  gap: 14px;
  align-items: center;
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.95rem;
  border: var(--border);
  background: var(--paper);
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.twister-row:hover {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--ink);
}

.twister-focus {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--vermilion);
  border: 1px solid var(--vermilion);
  padding: 3px 6px;
  text-align: center;
  white-space: nowrap;
}

.twister-text { color: var(--ink); }

.twister-tempos { display: flex; gap: 5px; }
.tempo-dot {
  width: 11px; height: 11px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: var(--paper-deep);
}
.tempo-done { background: var(--vermilion); border-color: var(--vermilion-deep); }

.twister-mastered { background: var(--paper-deep); }
.twister-seal {
  font-size: 1.15rem;
  color: var(--paper);
  background: var(--vermilion);
  border-radius: 50%;
  width: 30px; height: 30px;
  display: grid;
  place-items: center;
  transform: rotate(-8deg);
}

/* ==========================================================================
   RECORD BOOK
   ========================================================================== */
.record-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.record-card {
  border: var(--border);
  background: var(--paper);
  box-shadow: var(--shadow-hard);
  padding: 16px 18px;
}
.record-card-wide { grid-column: 1 / -1; }

.record-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  text-transform: uppercase;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 6px;
}

.week-dots { display: flex; justify-content: space-between; gap: 6px; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.week-dot {
  width: 38px; height: 38px;
  border: var(--border);
  border-radius: 50%;
  background: var(--paper-deep);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
}
.week-dot-hit { background: var(--vermilion); color: var(--paper); }
.week-dot-today { outline: 2px dashed var(--vermilion); outline-offset: 3px; }
.week-name { font-size: 0.65rem; color: var(--ink-soft); }

.bests { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.bests li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.92rem;
  border-bottom: 1px dotted var(--ink-soft);
  padding-bottom: 6px;
}
.bests strong { font-size: 1.1rem; }

.badge-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.badge {
  border: 2px dashed var(--ink-soft);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  opacity: 0.55;
}
.badge-won {
  border: var(--border);
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--ink);
  opacity: 1;
}
.badge-mark {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  background: var(--paper-deep);
  color: var(--ink-soft);
  transform: rotate(-6deg);
}
.badge-won .badge-mark { background: var(--vermilion); color: var(--paper); }
.badge-name {
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 1rem;
}
.badge-how { font-size: 0.72rem; color: var(--ink-soft); }

/* ==========================================================================
   FOOTER
   ========================================================================== */
.footer {
  border-top: 3px solid var(--ink);
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  font-size: 0.82rem;
  color: var(--ink-soft);
  flex-wrap: wrap;
}

/* ==========================================================================
   RUNNER — dark focus mode
   ========================================================================== */
.runner {
  position: fixed;
  inset: 0;
  z-index: 50;
  background:
    radial-gradient(circle at 50% 120%, rgba(201, 58, 38, 0.22) 0%, transparent 55%),
    #141110;
  color: var(--paper);
  display: flex;
  flex-direction: column;
  animation: fade-in 0.25s ease both;
}
.runner[hidden] { display: none; }

.runner-chrome {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
}

.runner-exit {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  background: none;
  color: var(--paper);
  border: 1px solid rgba(243, 235, 218, 0.4);
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.runner-exit:hover { border-color: var(--vermilion); color: var(--vermilion); }

.runner-progress {
  flex: 1;
  height: 8px;
  border: 1px solid rgba(243, 235, 218, 0.35);
  overflow: hidden;
}
.runner-progress-fill {
  height: 100%;
  width: 0;
  background: var(--vermilion);
  transition: width 0.3s ease;
}

.runner-step {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: rgba(243, 235, 218, 0.7);
  white-space: nowrap;
}

.runner-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px;
  text-align: center;
}

.stage-kicker {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}

.stage-giant {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(6rem, 24vw, 15rem);
  line-height: 0.9;
  text-transform: uppercase;
  color: var(--paper);
}
.stage-giant-sm { font-size: clamp(2.6rem, 9vw, 5.5rem); }

.stage-say { font-size: 1.4rem; color: var(--vermilion); letter-spacing: 0.1em; }

.stage-hint {
  font-size: 1rem;
  color: rgba(243, 235, 218, 0.75);
  max-width: 46ch;
}
.stage-hint-wide { max-width: 58ch; font-size: 1.1rem; }

.stage-xp {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
}

.stage-clock {
  font-size: 1.6rem;
  color: rgba(243, 235, 218, 0.6);
}

/* expanding breath/vowel ring */
.stage-ring {
  position: relative;
  width: min(60vw, 340px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.stage-ring::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px solid var(--vermilion);
  border-radius: 50%;
  animation: ring-grow var(--hold, 6000ms) ease-in-out both;
}
.stage-ring::after {
  content: "";
  position: absolute;
  inset: 12%;
  border: 1px solid rgba(201, 58, 38, 0.4);
  border-radius: 50%;
}

/* beat pulse */
.pulse { animation: pulse 0.28s ease-out; }
.stage-beat { color: var(--vermilion); }

/* breath drum */
.drum {
  width: min(70vw, 320px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 4px solid var(--vermilion);
  background: radial-gradient(circle at 50% 38%, rgba(201, 58, 38, 0.35), rgba(201, 58, 38, 0.08) 70%);
  color: var(--paper);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.drum:active { border-color: var(--gold); }
.drum .stage-giant { font-size: clamp(4rem, 18vw, 9rem); }

/* twister display */
.stage-twister {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: clamp(1.3rem, 3.4vw, 2rem);
  max-width: 26ch;
  line-height: 1.35;
}
.stage-twister-big { font-size: clamp(1.7rem, 5vw, 3rem); max-width: 24ch; }

.pacer {
  width: min(80vw, 520px);
  height: 12px;
  border: 1px solid rgba(243, 235, 218, 0.4);
  overflow: hidden;
}
.pacer-fill {
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(-45deg, var(--vermilion) 0 8px, var(--vermilion-deep) 8px 16px);
  animation: pacer var(--pass, 5000ms) linear both;
}

.tempo-picker { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.tempo-btn {
  font-family: var(--font-body);
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  background: none;
  border: 1px solid rgba(243, 235, 218, 0.4);
  color: var(--paper);
  padding: 12px 20px;
  cursor: pointer;
  min-width: 130px;
}
.tempo-btn strong { font-family: var(--font-display); text-transform: uppercase; font-size: 1.15rem; }
.tempo-btn .mono { font-size: 0.68rem; color: rgba(243, 235, 218, 0.6); }
.tempo-btn em { font-size: 0.68rem; color: var(--gold); font-style: normal; }
.tempo-btn:hover { border-color: var(--paper); }
.tempo-btn-active { border: 2px solid var(--vermilion); background: rgba(201, 58, 38, 0.15); }
.tempo-btn-done { opacity: 0.75; }

.judge-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

/* runner buttons sit on dark bg — hard shadows read differently there */
.runner .btn-primary { box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.6); border-color: var(--vermilion-deep); }
.runner .btn-ghost { color: var(--paper); }

/* ==========================================================================
   TOASTS & CONFETTI
   ========================================================================== */
.toast-root {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--paper);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.35);
  padding: 10px 20px;
  font-size: 0.92rem;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-gold { border-color: var(--gold); color: var(--gold); }
.toast-belt { background: var(--vermilion); color: var(--paper); border-color: var(--paper); }

.confetti-root { position: fixed; inset: 0; z-index: 95; pointer-events: none; overflow: hidden; }
.confetti-bit {
  position: absolute;
  top: -12px;
  width: 10px;
  height: 14px;
  animation: confetti-fall 2.2s cubic-bezier(0.25, 0.4, 0.6, 1) both;
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */
@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0% { transform: scale(1); }
  35% { transform: scale(1.07); }
  100% { transform: scale(1); }
}
@keyframes ring-grow {
  from { transform: scale(0.55); opacity: 0.4; }
  to   { transform: scale(1); opacity: 1; }
}
@keyframes pacer { from { width: 0; } to { width: 100%; } }
@keyframes confetti-fall {
  from { transform: translate(0, 0) rotate(0); opacity: 1; }
  to   { transform: translate(var(--dx, 0), 105vh) rotate(var(--rot, 360deg)); opacity: 0.9; }
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 860px) {
  .scoreboard { grid-template-columns: 1fr 1fr; }
  .seal { bottom: auto; top: 64px; }
}

@media (max-width: 620px) {
  #app { padding: 18px 14px 60px; }
  .drill-grid { grid-template-columns: 1fr; }
  .record-grid { grid-template-columns: 1fr; }
  .twister-row { grid-template-columns: 1fr auto; }
  .twister-focus { display: none; }
  .twister-text { grid-column: 1; }
  .seal { width: 74px; top: 52px; }
  .week-dot { width: 32px; height: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  /* keep functional timing animations (pacer/ring) readable as static fills */
  .pacer-fill { width: 100%; animation: none; }
  .stage-ring::before { transform: none; animation: none; }
}
