/* ==========================================================================
   Typing Test
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg: #141517;
  --line: rgba(255, 255, 255, 0.08);
  --line-hi: rgba(255, 255, 255, 0.16);
  --text: #f2f2f3;
  --muted: #8b8d95;
  --dim: #5d6068;

  --key-top: #26272c;
  --key-bot: #1c1d21;
  --key-edge: #0a0a0c;
  --legend: #a3a5ac;

  --orange: #ff6a1f;
  --green: #3ee08f;
  --rgb: #ff2a2a, #ff4d1f, #ff7a1a, #ffa31a, #ff7a1a, #ff4d1f, #ff2a2a; /* red → orange → red, loops seamlessly */

  --ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.45, 0.5, 1);
}

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

html { background: var(--bg); }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 520px at 50% -8%, rgba(72, 74, 84, 0.35), transparent 65%),
    radial-gradient(900px 500px at 50% 115%, rgba(40, 41, 47, 0.45), transparent 70%),
    linear-gradient(180deg, #18191c 0%, #0e0f11 100%);
  background-attachment: fixed;
}

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

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

/* ---------- Header ---------------------------------------------------- */

.bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 22px clamp(16px, 3vw, 36px);
}

.brand {
  display: flex;
  align-items: center;
  color: var(--text);
  justify-self: start; /* the link hugs the logo, not the whole header column */
  border-radius: 8px;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

a.brand:hover { opacity: 0.85; }
a.brand:focus-visible { outline: 2px solid #ffa31a; outline-offset: 4px; }

.brand-logo {
  display: block;
  width: 100%;
  max-width: 190px;
  height: auto;
  aspect-ratio: 1166 / 277.89;
  min-width: 0;
}

.layout-controls {
  display: flex;
  align-items: center;
  justify-content: center;
}

.actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.icon-btn,
.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.icon-btn { width: 36px; }
.pill-btn { padding: 0 14px 0 12px; }

.icon-btn:hover,
.pill-btn:hover {
  color: var(--text);
  border-color: var(--line-hi);
  background: rgba(255, 255, 255, 0.05);
}

.icon-btn svg,
.pill-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn .i-collapse,
.icon-btn .i-done { display: none; }
.icon-btn.done { color: var(--green); border-color: rgba(62, 224, 143, 0.45); }
.icon-btn.done .i-main { display: none; }
.icon-btn.done .i-done { display: block; }
.icon-btn.busy { opacity: 0.5; pointer-events: none; }
.icon-btn:disabled { opacity: 0.35; }
.icon-btn:disabled:hover { color: var(--muted); border-color: var(--line); background: rgba(255, 255, 255, 0.025); }
.icon-btn.on .i-expand { display: none; }
.icon-btn.on .i-collapse { display: block; }

/* ---------- Stage ----------------------------------------------------- */

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 2.2vh, 24px);
  padding: 4px 0 8px;
}

:root { --case-w: min(80vw, 1500px); }

.readout,
.case { width: var(--case-w, 80vw); }

/* Readout */
.readout {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}

.chip {
  padding: 10px 14px 11px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.022);
  border: 1px solid var(--line);
}

.chip-wpm  { min-width: 96px; }
.chip-acc  { min-width: 112px; }
.chip-left { min-width: 112px; }
.chip-best { min-width: 136px; }

.chip dt {
  margin-bottom: 7px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
}

.chip dt em {
  font-style: normal;
  letter-spacing: 0.06em;
  color: var(--orange);
  opacity: 0;
  transition: opacity 0.2s ease;
}


.chip dd {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(13px, 0.95vw, 17px);
  font-weight: 500;
  line-height: 1;
  color: var(--text);
  white-space: nowrap;
}

/* Progress */
.progress {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 9px;
  padding-bottom: 2px;
}

.progress-label {
  position: relative;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.progress-done {
  position: absolute;
  right: 0;
  top: 0;
  color: var(--green);
  opacity: 0;
  translate: 0 4px;
  transition: opacity 0.4s ease, translate 0.4s var(--ease-out);
}

.track {
  width: clamp(140px, 14vw, 240px);
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rgb));
  background-size: 240px 100%;
  transition: width 0.45s var(--ease-out);
}

.stage.complete #r-count { opacity: 0; }
.stage.complete .progress-done { opacity: 1; translate: 0 0; }

/* ---------- Settings bar --------------------------------------------- */

.config {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
}

.amounts { display: inline-flex; gap: 2px; }

.opt {
  padding: 8px 13px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.opt:hover { color: var(--text); }

.opt[aria-pressed="true"] {
  color: var(--text);
  background: linear-gradient(180deg, #313238, #27282d);
  box-shadow: inset 0 0 0 1px var(--line-hi), 0 4px 14px rgba(0, 0, 0, 0.3);
}

.opt[data-toggle][aria-pressed="true"] { color: #ff8a4d; }

.divider {
  width: 1px;
  height: 18px;
  margin: 0 6px;
  background: var(--line-hi);
}

/* Focus mode: chrome fades away while typing */
.bar,
.hint { transition: opacity 0.5s ease; }

body.typing .bar,
body.typing .hint { opacity: 0.12; }

body.typing .cursor { opacity: 0 !important; }

/* ---------- Case ----------------------------------------------------- */

.case {
  position: relative;
  padding: clamp(20px, 2.6vw, 40px) clamp(20px, 3vw, 48px);
  border-radius: clamp(16px, 1.6vw, 24px);
  background: linear-gradient(180deg, rgba(44, 45, 51, 0.55), rgba(20, 21, 24, 0.65));
  border: 1px solid var(--line);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.045),
    0 40px 90px -30px rgba(0, 0, 0, 0.75),
    0 0 0 1px rgba(0, 0, 0, 0.25);
}

.case::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(from 200deg, var(--rgb));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0;
  transition: opacity 1s ease;
  pointer-events: none;
}

.case.done::after {
  opacity: 0.9;
  animation: breathe 3.2s ease-in-out infinite alternate;
}

@keyframes breathe {
  from { opacity: 0.95; }
  to   { opacity: 0.45; }
}

/* ---------- Test ----------------------------------------------------- */

.test { --fs: clamp(22px, 2.4vw, 44px); }

.test-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  min-height: calc(var(--fs) * 1.3);
  margin-bottom: calc(var(--fs) * 0.5);
}

.counter {
  font-family: var(--mono);
  font-size: calc(var(--fs) * 1.15);
  font-weight: 500;
  line-height: 1;
  color: var(--orange);
  opacity: 0.35;
  transition: opacity 0.3s ease;
}

.test.running .counter { opacity: 1; }

.caps {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 106, 31, 0.5);
  background: rgba(255, 106, 31, 0.1);
  color: var(--orange);
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  translate: 0 4px;
  transition: opacity 0.25s ease, translate 0.25s var(--ease-out);
}

.caps.on { opacity: 1; translate: 0 0; }

/* One line that slides left as you type; soft fade at both edges */
.words-wrap {
  position: relative;
  height: calc(var(--fs) * 2.4);
  overflow: hidden;
  cursor: text;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 12%, #000 88%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 12%, #000 88%, transparent 100%);
}

.words {
  position: absolute;
  left: 0;
  top: 50%;
  margin-top: calc(var(--fs) * -0.85);
  display: flex;
  flex-wrap: nowrap;
  width: max-content;
  font-family: var(--mono);
  font-size: var(--fs);
  line-height: 1.7;
  color: #62656e;
  transition: transform 0.12s ease-out, filter 0.3s ease, opacity 0.3s ease;
  will-change: transform;
}

.word {
  position: relative;
  flex: none;
  margin-right: 0.62em;
  white-space: pre;
}

.letter.ok { color: var(--text); }
.letter.bad { color: #ff5c7a; }
.letter.extra { color: #b8364f; }

.word.correct .letter { color: var(--green); }
.word.incorrect .letter { color: #ff5c7a; }
.word.incorrect .letter.ok { color: rgba(255, 92, 122, 0.65); }

.word.incorrect::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.18em;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 92, 122, 0.55);
}

/* The caret stays still; the words move under it */
.caret {
  position: absolute;
  left: 28%;
  top: 50%;
  width: max(2px, calc(var(--fs) * 0.09));
  height: calc(var(--fs) * 1.2);
  translate: -1px -50%;
  border-radius: 2px;
  background: var(--orange);
  box-shadow: 0 0 10px rgba(255, 106, 31, 0.6);
  pointer-events: none;
}

.caret.idle { animation: blink 1s steps(1) infinite; }

@keyframes blink {
  50% { opacity: 0; }
}

.ghost {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px;
  pointer-events: none;
}

.focus-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.words-wrap.blurred .words { filter: blur(5px); opacity: 0.45; }
.words-wrap.blurred .caret { opacity: 0; }
.words-wrap.blurred .focus-hint { opacity: 1; }

/* ---------- Results -------------------------------------------------- */

.results { animation: rise 0.6s var(--ease-out); }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.res-main {
  display: grid;
  grid-template-columns: minmax(150px, auto) minmax(0, 1fr);
  gap: clamp(20px, 3vw, 48px);
  align-items: stretch;
}

.res-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

.res-wpm,
.res-acc {
  font-family: var(--mono);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text);
}

.res-wpm {
  justify-self: start;
  width: fit-content;
  margin: 6px 0 18px;
  font-size: clamp(56px, 6.4vw, 110px);
  background: linear-gradient(90deg, #ff2a2a, #ff6a1f 55%, #ffa31a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.res-acc {
  margin-top: 6px;
  font-size: clamp(30px, 3vw, 52px);
}

.res-pb {
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
}

.res-pb.new { color: var(--green); font-weight: 500; }

.res-graph {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Fixed CSS height: the drawing buffer is sized from it, so it must not depend on the buffer */
.res-graph canvas {
  display: block;
  width: 100%;
  height: clamp(170px, 24vh, 250px);
}

.legend {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}

.legend span::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 3px;
  margin-right: 6px;
  vertical-align: middle;
  border-radius: 2px;
}

.legend .l-wpm::before { background: linear-gradient(90deg, var(--rgb)); }
.legend .l-raw::before { background: rgba(170, 172, 180, 0.5); }
.legend .l-err::before { width: 6px; height: 6px; border-radius: 50%; background: #ff5c7a; }

.res-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: clamp(20px, 2.4vw, 32px) 0 0;
}

.res-stats > div {
  padding: 12px 14px 13px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.022);
  border: 1px solid var(--line);
  min-width: 0;
}

.res-stats dt {
  margin-bottom: 8px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

.res-stats dd {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(14px, 1.2vw, 20px);
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.res-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px 32px;
  margin-top: clamp(20px, 2.4vw, 32px);
}

/* Missed-key heatmap: a tiny keyboard */
.heat {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 10px;
  --k: clamp(24px, 2.1vw, 34px);
}

.heat-row { display: flex; gap: 5px; }
.heat-row.r2 { padding-left: calc(var(--k) * 0.35); }
.heat-row.r3 { padding-left: calc(var(--k) * 0.85); }

.hk {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--k);
  height: var(--k);
  overflow: hidden;
  isolation: isolate;
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.04));
  font-family: var(--mono);
  font-size: calc(var(--k) * 0.4);
  color: var(--dim);
}

.hk::after {
  content: "";
  position: absolute;
  inset: 1.5px;
  z-index: -1;
  border-radius: 6px;
  background:
    linear-gradient(rgba(255, 92, 122, var(--heat, 0)), rgba(255, 92, 122, var(--heat, 0))),
    linear-gradient(170deg, var(--key-top), var(--key-bot));
}

.hk.hit { color: var(--text); }

.hk .n {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: calc(var(--k) * 0.26);
  color: rgba(255, 255, 255, 0.75);
}

/* Flawless: every key gets the rainbow rim (rotated with transform only) */
.hk.flawless { color: var(--text); }

.hk.flawless::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: -2;
  width: 150%;
  height: 150%;
  translate: -50% -50%;
  background: conic-gradient(var(--rgb));
  animation: spin 2.6s linear infinite;
  animation-delay: calc(var(--i) * -0.12s);
}

@keyframes spin {
  to { transform: rotate(1turn); }
}

.heat-note {
  margin-top: 10px;
  font-size: 13px;
  color: var(--green);
}

.res-actions { display: flex; gap: 8px; }

.pill-btn.primary {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(90deg, #ff2a2a, #ff6a1f);
  box-shadow: 0 10px 28px -10px rgba(255, 74, 26, 0.6);
}

.pill-btn.primary:hover {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(90deg, #ff3a2a, #ff7a2a);
}

.pill-btn.primary kbd { color: rgba(255, 255, 255, 0.85); border-color: rgba(255, 255, 255, 0.35); }

.pill-btn kbd {
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--line-hi);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .res-main { grid-template-columns: 1fr; }
  .res-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .res-stats > div:last-child { grid-column: 1 / -1; }
}

/* ---------- Footer hint ---------------------------------------------- */

.hint {
  padding: 4px 16px 26px;
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  color: var(--dim);
  letter-spacing: 0.01em;
}

.hint b {
  font-weight: 500;
  color: var(--muted);
}

.hint .sep {
  display: inline-block;
  margin: 0 10px;
  opacity: 0.6;
}

/* ---------- "About" link in the hint -------------------------------- */

.hint a.more {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--line-hi);
  transition: color 0.2s ease, border-color 0.2s ease;
}

.hint a.more:hover { color: var(--text); border-color: var(--orange); }

/* ---------- SEO article: cards on a 12-column grid, as wide as the typing test */

.seo {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  width: var(--case-w, 80vw);
  max-width: calc(100vw - 32px);
  margin: 0 auto;
  padding: clamp(56px, 8vw, 110px) 0 64px;
  color: #b7b9c0;
  font-size: 16px;
  line-height: 1.68;
  user-select: text;
  -webkit-user-select: text;
}

.seo .card {
  display: block; /* not the tester's flex cards */
  grid-column: span 12;
  min-width: 0;
  padding: clamp(22px, 2.4vw, 34px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.012));
}

.seo .card > :last-child { margin-bottom: 0; }

.seo .span-4  { grid-column: span 4; }
.seo .span-5  { grid-column: span 5; }
.seo .span-6  { grid-column: span 6; }
.seo .span-7  { grid-column: span 7; }
.seo .span-12 { grid-column: span 12; }

.seo .intro {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: 18px 44px;
  align-items: start;
  overflow: hidden;
  background:
    radial-gradient(700px 260px at 0% 0%, rgba(255, 77, 31, 0.10), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.012));
}

.intro::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, #ff2a2a, #ff7a1a, #ffa31a, transparent 80%);
}

.seo h1 {
  margin: 0;
  font-size: clamp(30px, 3.4vw, 46px);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--text);
}

.seo .lead {
  grid-column: 1;
  margin: 0;
  font-size: clamp(16.5px, 1.3vw, 19px);
  color: #cfd0d5;
}

.facts {
  grid-column: 2;
  grid-row: 1 / span 2;
  padding: 20px 22px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.2);
}

.seo .facts-title {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}

.facts li { margin-bottom: 8px; color: #d6d7dc; }

.seo h2 {
  margin: 0 0 14px;
  font-size: clamp(19px, 1.55vw, 23px);
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
}

.seo p { margin: 0 0 14px; }
.seo strong { font-weight: 500; color: var(--text); }

.seo ol,
.seo ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.seo ol { counter-reset: step; }

.seo li {
  position: relative;
  margin-bottom: 12px;
  padding-left: 34px;
}

.seo li:last-child { margin-bottom: 0; }

.seo ol li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.2em;
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff2a2a, #ff7a1a);
  color: #fff;
  font: 500 12px/1 var(--mono);
}

.seo ul li::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 0.68em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff2a2a, #ffa31a);
}

.two-col {
  columns: 2;
  column-gap: 48px;
}

.two-col li { break-inside: avoid; }

/* FAQ: question cards in two columns */
.faq-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

.faq details {
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.16);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.faq details[open] {
  background: rgba(255, 255, 255, 0.035);
  border-color: var(--line-hi);
}

.faq summary {
  position: relative;
  padding: 17px 32px 17px 0;
  list-style: none;
  font-weight: 500;
  color: var(--text);
}

.faq summary::-webkit-details-marker { display: none; }

.faq summary::after {
  content: "+";
  position: absolute;
  right: 0;
  top: 50%;
  translate: 0 -50%;
  font-size: 22px;
  font-weight: 300;
  color: var(--orange);
  transition: rotate 0.25s var(--ease-out);
}

.faq details[open] summary::after { rotate: 45deg; }
.faq details p { margin: -4px 0 18px; }

@media (max-width: 980px) {
  .seo .span-4, .seo .span-5, .seo .span-6, .seo .span-7 { grid-column: span 12; }
  .seo .intro { grid-template-columns: 1fr; }
  .facts { grid-column: 1; grid-row: auto; }
  .two-col { columns: 1; }
  .faq-grid { grid-template-columns: 1fr; }
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 28px 16px 44px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--dim);
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.site-footer a:hover { color: var(--text); }
.site-footer .sep { opacity: 0.6; }

/* ---------- Menu ----------------------------------------------------- */

.burger {
  position: relative;
  display: block;
  width: 16px;
  height: 12px;
}

.burger i {
  position: absolute;
  left: 0;
  right: 0;
  height: 1.8px;
  border-radius: 2px;
  background: currentColor;
  transition: top 0.35s var(--ease-out), transform 0.35s var(--ease-out), opacity 0.2s ease;
}

.burger i:nth-child(1) { top: 0; }
.burger i:nth-child(2) { top: 5px; right: 4px; }
.burger i:nth-child(3) { top: 10px; }

.menu-btn:hover .burger i:nth-child(2) { right: 0; }

body.menu-open .burger i:nth-child(1) { top: 5px; transform: rotate(45deg); }
body.menu-open .burger i:nth-child(2) { opacity: 0; }
body.menu-open .burger i:nth-child(3) { top: 5px; transform: rotate(-45deg); }

.menu-scrim {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(6, 6, 8, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}

body.menu-open .menu-scrim {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s ease;
}

.menu {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  width: min(400px, 90vw);
  padding: 22px 22px 28px;
  background: linear-gradient(180deg, #1e1f23, #151619);
  border-left: 1px solid var(--line);
  box-shadow: -30px 0 80px rgba(0, 0, 0, 0.5);
  transform: translateX(102%);
  transition: transform 0.45s var(--ease-out);
}

.menu::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, #ff2a2a, #ff7a1a, #ffa31a, transparent);
}

body.menu-open .menu { transform: none; }

.menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
}

.menu-title {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}

.menu-links {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

body.menu-open .menu-links li { animation: menu-in 0.5s var(--ease-out) backwards; }
body.menu-open .menu-links li:nth-child(2) { animation-delay: 0.04s; }
body.menu-open .menu-links li:nth-child(3) { animation-delay: 0.08s; }
body.menu-open .menu-links li:nth-child(4) { animation-delay: 0.12s; }
body.menu-open .menu-links li:nth-child(5) { animation-delay: 0.16s; }
body.menu-open .menu-links li:nth-child(6) { animation-delay: 0.2s; }
body.menu-open .menu-links li:nth-child(7) { animation-delay: 0.24s; }

@keyframes menu-in {
  from { opacity: 0; transform: translateX(18px); }
}

.menu-links a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 12px;
  padding: 15px 18px 16px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--text);
  text-decoration: none;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.menu-links a:hover,
.menu-links a:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
}

.menu-links a[aria-current="page"] {
  background: linear-gradient(90deg, rgba(255, 77, 31, 0.14), rgba(255, 77, 31, 0) 85%);
  border-color: rgba(255, 106, 31, 0.28);
}

.m-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.menu-links a[aria-current="page"] .m-name::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 10px var(--orange);
}

.m-desc {
  grid-column: 1;
  margin-top: 3px;
  font-size: 13px;
  color: var(--muted);
}

.m-arrow {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--dim);
  transition: transform 0.25s var(--ease-out), color 0.2s ease;
}

.menu-links a:hover .m-arrow,
.menu-links a:focus-visible .m-arrow {
  transform: translateX(4px);
  color: var(--orange);
}

.menu-foot {
  margin: auto 0 0;
  padding-top: 24px;
  font-size: 12px;
  color: var(--dim);
}

/* ---------- Sparks + cursor ------------------------------------------ */

.sparks {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.sparks { z-index: 50; }

.cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  will-change: transform;
}

.cursor.visible { opacity: 1; }

.cursor-dot {
  width: 10px;
  height: 10px;
  translate: -50% -50%;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 14px rgba(255, 106, 31, 0.6);
  transition:
    width 0.35s var(--ease-spring),
    height 0.35s var(--ease-spring),
    background-color 0.25s ease,
    box-shadow 0.25s ease,
    scale 0.15s ease;
}

.cursor.hover .cursor-dot {
  width: 30px;
  height: 30px;
  background: rgba(62, 224, 143, 0.32);
  box-shadow:
    inset 0 0 0 1.5px var(--green),
    0 0 20px rgba(62, 224, 143, 0.45);
}

.cursor.press .cursor-dot { scale: 0.8; }

/* The system pointer hides only once app.js has the custom cursor running
   (it adds .has-cursor), so if the script ever fails the pointer stays */
@media (hover: hover) and (pointer: fine) {
  html.has-cursor,
  html.has-cursor * { cursor: none !important; }
}

@media (hover: none), (pointer: coarse) {
  .cursor { display: none; }
}

/* ---------- Small screens -------------------------------------------- */

@media (max-width: 980px) {
  .bar {
    grid-template-columns: 1fr auto;
    grid-template-areas: "brand actions" "controls controls";
    gap: 14px 10px;
  }
  .brand { grid-area: brand; }
  .actions { grid-area: actions; }
  .layout-controls { grid-area: controls; }
  .brand-logo { max-width: 130px; }
  .pill-btn span { display: none; }
  .pill-btn { width: 36px; padding: 0; }
  .chip { padding: 8px 10px 9px; }
  .chip-wpm, .chip-acc, .chip-left, .chip-best { min-width: 0; }
  .progress { align-items: flex-start; }
  .progress-done { right: auto; left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hk.flawless::before,
  .case.done::after,
  .caret.idle,
  .results,
  body.menu-open .menu-links li { animation: none; }
}

@media (max-width: 720px) {
  :root { --case-w: 92vw; }
  .config { flex-wrap: wrap; justify-content: center; border-radius: 18px; }
}

/* ---------- Charts & stats in the article ---------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.seo figure { margin: 0; }

.viz-sub {
  margin: -8px 0 20px !important;
  font-size: 14px;
  color: var(--muted);
}

.viz figcaption {
  margin-top: 18px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.example-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 8px;
  border: 1px solid var(--line-hi);
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  vertical-align: middle;
  color: var(--muted);
}

/* Stat tiles */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.012));
  overflow: hidden;
}

.seo .kpis { padding: 0; }
.seo .card.kpis { display: grid; } /* beats the article's card reset */

.stat {
  padding: clamp(20px, 2.2vw, 30px);
  border-left: 1px solid var(--line);
}

.stat:first-child { border-left: 0; }

.stat::before {
  content: "";
  display: block;
  width: 28px;
  height: 3px;
  margin-bottom: 16px;
  border-radius: 3px;
  background: linear-gradient(90deg, #ff2a2a, #ffa31a);
}

.stat-value {
  display: block;
  font-family: var(--ui);
  font-size: clamp(30px, 3vw, 44px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text);
}

.stat-label {
  display: block;
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

/* Horizontal bars: <= 24px thick, rounded data end, square at the baseline */
.hbars {
  display: grid;
  gap: 14px;
}

.hbar {
  display: grid;
  grid-template-columns: minmax(64px, 112px) minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  outline: none;
}

.hbar-label {
  font-size: 14px;
  text-align: right;
  color: var(--text);
}

.hbar-plot {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 28px;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
}

.hbar-fill {
  flex: none;
  width: max(4px, calc(var(--v) * (100% - 64px)));
  height: 18px;
  border-radius: 0 4px 4px 0;
  background: var(--c, #f0601a);
  transition: filter 0.15s ease;
}

.hbar-value {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text);
}

.hbar:hover .hbar-fill,
.hbar:focus-visible .hbar-fill { filter: brightness(1.2); }
.hbar:focus-visible .hbar-label { text-decoration: underline; }

/* Status scale (drift) */
.scale {
  position: relative;
  margin-top: 40px;
}

.scale-bar {
  display: flex;
  gap: 2px;
  height: 18px;
}

.scale-zone {
  flex: var(--w) 1 0;
  background: var(--c);
  outline: none;
  transition: filter 0.15s ease;
}

.scale-zone:first-child { border-radius: 4px 0 0 4px; }
.scale-zone:last-child { border-radius: 0 4px 4px 0; }
.scale-zone:hover,
.scale-zone:focus-visible { filter: brightness(1.2); }

/* The label sits above the bar and reads rightwards from its pointer line */
.scale-marker {
  position: absolute;
  left: var(--at);
  top: -34px;
  padding-left: 8px;
  translate: -1px 0;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--text);
}

.scale-marker::after {
  content: "";
  position: absolute;
  left: 0;
  top: 2px;
  width: 2px;
  height: 50px;
  border-radius: 2px;
  background: var(--text);
}

.scale-ticks {
  position: relative;
  height: 20px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.scale-ticks span {
  position: absolute;
  left: var(--at);
  translate: -50% 0;
}

.scale-ticks span:first-child { translate: 0 0; }
.scale-ticks span:last-child { translate: -100% 0; }

.seo .scale-legend {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.seo .scale-legend li {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 0;
  font-size: 14.5px;
}

.seo .scale-legend li::before { content: none; }

.badge {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--c);
  color: #141517;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

/* Circularity examples */
.circ-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.circ { text-align: center; }

.circ svg {
  display: block;
  width: 100%;
  max-width: 210px;
  height: auto;
  margin: 0 auto;
}

.circ-name {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text);
}

.circ-val {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
}

/* Line chart */
.line-chart {
  position: relative;
  width: 100%;
  height: 220px;
}

.line-chart svg { display: block; overflow: visible; }

.viz-grid {
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.viz-axis {
  fill: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.viz-end {
  fill: var(--text);
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 600;
}

.viz-ring {
  stroke: #1c1d21;
  stroke-width: 2;
}

.viz-hair {
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 1;
  opacity: 0;
}

.viz-hover-dot { opacity: 0; }
.hovering .viz-hair,
.hovering .viz-hover-dot { opacity: 1; }
.line-chart rect:focus { outline: none; }

/* Tooltip */
.viz-tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 95;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border: 1px solid var(--line-hi);
  border-radius: 10px;
  background: rgba(24, 25, 28, 0.96);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.viz-tip.show { opacity: 1; }

.viz-tip strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* Footer "Cookie settings" */
.site-footer .cookie-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--muted);
  transition: color 0.2s ease;
}

.site-footer .cookie-link:hover { color: var(--text); }

@media (max-width: 980px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

@media (max-width: 520px) {
  .circ-pair { grid-template-columns: 1fr; }
}

