/* ==========================================================================
   Keyboard Tester
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg: #141517;
  --bg-hi: #26272b;
  --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;
}

/* Segmented Mac / PC switch */
.seg {
  position: relative;
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
}

.seg button {
  position: relative;
  z-index: 1;
  width: 74px;
  padding: 9px 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.25s ease;
}

.seg button:hover,
.seg button[aria-checked="true"] { color: var(--text); }

.seg-thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: 999px;
  background: linear-gradient(180deg, #313238, #27282d);
  box-shadow: inset 0 0 0 1px var(--line-hi), 0 6px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.4s var(--ease-spring);
}

.seg[data-active="pc"] .seg-thumb { transform: translateX(100%); }

/* Numpad switch (Mac only) — folds away behind the Mac / PC control on PC */
.layout-controls {
  display: flex;
  align-items: center;
  justify-content: center;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  max-width: 140px;
  margin-left: 10px;
  padding: 0 14px 0 10px;
  overflow: hidden;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition:
    color 0.2s ease,
    border-color 0.2s ease,
    background-color 0.2s ease,
    opacity 0.3s ease,
    max-width 0.45s var(--ease-out),
    margin 0.45s var(--ease-out),
    padding 0.45s var(--ease-out),
    border-width 0.45s var(--ease-out);
}

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

.switch[aria-checked="true"] { color: var(--text); }

.switch-track {
  position: relative;
  flex: none;
  width: 28px;
  height: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--legend);
  transition: transform 0.35s var(--ease-spring), background-color 0.25s ease;
}

.switch[aria-checked="true"] .switch-track {
  background: var(--green);
  box-shadow: 0 0 12px rgba(62, 224, 143, 0.35);
}

.switch[aria-checked="true"] .switch-knob {
  transform: translateX(12px);
  background: #ffffff;
}

/* PC size picker — folds away on Mac, like the Numpad switch on PC */
.sizes {
  display: inline-flex;
  gap: 2px;
  max-width: 260px;
  margin-left: 10px;
  padding: 4px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  transition:
    opacity 0.3s ease,
    max-width 0.45s var(--ease-out),
    margin 0.45s var(--ease-out),
    padding 0.45s var(--ease-out),
    border-width 0.45s var(--ease-out);
}

.sizes button {
  padding: 7px 11px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

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

.sizes button[aria-checked="true"] {
  color: var(--text);
  background: linear-gradient(180deg, #313238, #27282d);
  box-shadow: inset 0 0 0 1px var(--line-hi);
}

.layout-controls[data-active="mac"] .sizes {
  max-width: 0;
  margin-left: 0;
  padding-left: 0;
  padding-right: 0;
  border-width: 0;
  opacity: 0;
  pointer-events: none;
}

.layout-controls[data-active="pc"] .switch {
  max-width: 0;
  margin-left: 0;
  padding-left: 0;
  padding-right: 0;
  border-width: 0;
  opacity: 0;
  pointer-events: none;
}

.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 { display: none; }
.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;
  --u: 48px;
}

.readout,
.case { width: var(--kb-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-key  { min-width: 112px; }
.chip-code { min-width: 172px; }
.chip-num  { min-width: 96px; }
.chip-held { min-width: 72px; }

.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-code.missing dt em { opacity: 1; }

.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; }

/* ---------- Keyboard ------------------------------------------------- */

.case {
  position: relative;
  padding: calc(var(--u) * 0.38);
  border-radius: calc(var(--u) * 0.42);
  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;
}

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

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

.keyboard {
  position: relative;
  width: calc(var(--W) * var(--u));
  height: calc(var(--H) * var(--u));
  --gap: calc(var(--u) * 0.11);
  --bw: max(1.5px, calc(var(--u) * 0.032));
}

.key {
  position: absolute;
  left: calc(var(--x) * var(--u) + var(--gap) / 2);
  top: calc(var(--y) * var(--u) + var(--gap) / 2);
  width: calc(var(--w) * var(--u) - var(--gap));
  height: calc(var(--h) * var(--u) - var(--gap));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
  padding: calc(var(--u) * 0.1 + var(--bw)) calc(var(--u) * 0.15 + var(--bw));
  border-radius: calc(var(--u) * 0.14);
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.04));
  box-shadow:
    0 calc(var(--u) * 0.05) 0 var(--key-edge),
    0 calc(var(--u) * 0.1) calc(var(--u) * 0.18) rgba(0, 0, 0, 0.35);
  color: var(--legend);
  font-size: calc(var(--u) * 0.3);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition:
    translate 0.09s ease,
    box-shadow 0.25s ease,
    color 0.3s ease,
    filter 0.15s ease;
}

/* The key face, inset by the rim width */
.key::after {
  content: "";
  position: absolute;
  inset: var(--bw);
  z-index: -1;
  border-radius: calc(var(--u) * 0.14 - var(--bw));
  background: linear-gradient(180deg, var(--key-top), var(--key-bot));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.key:hover { filter: brightness(1.15); }

/* Legend variants */
.key .t {
  font-size: 0.72em;
  color: var(--dim);
  transition: color 0.3s ease;
}

.key.dual { font-size: calc(var(--u) * 0.25); gap: 0.32em; }
.key.f    { font-size: calc(var(--u) * 0.2); }
.key.sm   { font-size: calc(var(--u) * 0.17); }
.key.xs   { font-size: calc(var(--u) * 0.15); }

.key.mod {
  font-size: calc(var(--u) * 0.16);
  align-items: flex-start;
  justify-content: flex-end;
  padding: calc(var(--u) * 0.13 + var(--bw)) calc(var(--u) * 0.15 + var(--bw));
}

.key.mod.r { align-items: flex-end; }

.key .sym {
  position: absolute;
  top: calc(var(--u) * 0.12 + var(--bw));
  right: calc(var(--u) * 0.14 + var(--bw));
  font-size: 1.35em;
}

.key.mod.r .sym { right: auto; left: calc(var(--u) * 0.14 + var(--bw)); }

.key .sym svg,
.key .m svg {
  display: block;
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.key .led {
  position: absolute;
  top: calc(var(--u) * 0.14 + var(--bw));
  left: calc(var(--u) * 0.15 + var(--bw));
  width: max(4px, calc(var(--u) * 0.08));
  height: max(4px, calc(var(--u) * 0.08));
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.key.lock-on .led {
  background: var(--green);
  box-shadow: 0 0 calc(var(--u) * 0.15) var(--green);
}

.key.optional { opacity: 0.5; }
.key.wrap { white-space: normal; text-align: center; line-height: 1.15; }
.key.optional.tested { opacity: 1; }

/* Held down */
.key.down {
  translate: 0 calc(var(--u) * 0.04);
  filter: brightness(1.35);
  box-shadow:
    0 calc(var(--u) * 0.01) 0 var(--key-edge),
    0 calc(var(--u) * 0.04) calc(var(--u) * 0.08) rgba(0, 0, 0, 0.35);
}

/* Tested: an RGB rim. A conic gradient sits between the rim and the face and is
   spun with transform only, so the GPU rotates it without repainting anything.
   Each key is phase-shifted so the colour ripples across the board. */
.key.tested {
  color: var(--text);
  box-shadow:
    0 calc(var(--u) * 0.05) 0 var(--key-edge),
    0 0 calc(var(--u) * 0.32) calc(var(--u) * -0.06)
      hsl(calc(var(--x) / var(--W) * 38deg) 100% 55% / 0.4);
}

.key.tested::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: -2;
  width: calc(var(--d) * var(--u));
  height: calc(var(--d) * var(--u));
  translate: -50% -50%;
  background: conic-gradient(var(--rgb));
  animation: spin 2.6s linear infinite;
  animation-delay: calc((var(--x) + var(--y) * 0.6) * -0.13s);
}

.key.tested::after {
  background: linear-gradient(180deg, #2f2926, #221e1c);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.key.tested .t { color: var(--legend); }

.key.tested.down {
  translate: 0 calc(var(--u) * 0.04);
  box-shadow:
    0 calc(var(--u) * 0.01) 0 var(--key-edge),
    0 0 calc(var(--u) * 0.45) calc(var(--u) * -0.02)
      hsl(calc(var(--x) / var(--W) * 38deg) 100% 55% / 0.6);
}

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

/* ---------- 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 keyboard */

.seo {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  width: var(--kb-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 {
  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-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; }

/* Keyboard sizes */
.sizes-list {
  display: grid;
  gap: 12px;
  margin: 4px 0 0;
}

.sizes-list > div {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 14px;
  align-items: baseline;
}

.sizes-list dt {
  padding: 3px 0;
  border: 1px solid rgba(255, 106, 31, 0.35);
  border-radius: 7px;
  background: linear-gradient(135deg, rgba(255, 42, 42, 0.22), rgba(255, 122, 26, 0.22));
  font: 500 12.5px/1.4 var(--mono);
  text-align: center;
  color: #fff;
}

.sizes-list dd {
  margin: 0;
  font-size: 14.5px;
}

/* 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-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;
  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: 720px) {
  .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-key, .chip-code, .chip-num, .chip-held { min-width: 0; }
  .progress { align-items: flex-start; }
  .progress-done { right: auto; left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .key.tested::before,
  .stage.complete .case::after,
  body.menu-open .menu-links li { animation: none; }
}

/* ---------- 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; }
}

