/* ============================================================
   First Solve
   Built from the cube's own materials: a black plastic body and
   rounded stickers. The home screen is one face of the cube,
   eight step stickers around a live centre. Colour comes from
   the six cube faces; everything else is plastic and paper.
   Rubik for the voice, Atkinson Hyperlegible for instructions
   read in a glance between turns.
   ============================================================ */

:root {
  color-scheme: light dark;

  --ground: #e9eaee;
  --surface: #f8f8fa;
  --surface-2: #dcdee4;
  --plastic: #141519;
  --plastic-2: #2a2c33;
  --plastic-3: #4a4d57;

  --ink: #131418;
  --ink-2: #474b55;
  --ink-3: #6c707a;
  --line: #d3d6dc;

  --btn-bg: #141519;
  --btn-fg: #ffffff;
  --focus: #2f6de0;
  --danger: #b8291a;

  /* cube faces */
  --c-white: #f4f4f0;
  --c-yellow: #ffd500;
  --c-red: #e0402f;
  --c-orange: #ff8c1a;
  --c-blue: #2f6de0;
  --c-green: #2bb673;

  --font-display: "Rubik", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, sans-serif;

  --r-lg: 28px;
  --r-md: 18px;
  --r-sm: 12px;
  --ease: cubic-bezier(0.2, 0.8, 0.25, 1);
  --topbar-h: 68px;
  --dock-h: 84px;
}

/* Dark tokens apply for an explicit choice (data-theme="dark") and, with no
   choice made, when the system is dark. Keep the two blocks identical. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0f1013;
  --surface: #18191d;
  --surface-2: #25272d;
  --plastic: #050506;
  --plastic-2: #25272d;
  --plastic-3: #454852;

  --ink: #edeef1;
  --ink-2: #b4b7bf;
  --ink-3: #8a8e98;
  --line: #2b2d34;

  --btn-bg: #edeef1;
  --btn-fg: #0f1013;
  --focus: #7aa5ff;
  --danger: #8e2418;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0f1013;
    --surface: #18191d;
    --surface-2: #25272d;
    --plastic: #050506;
    --plastic-2: #25272d;
    --plastic-3: #454852;

    --ink: #edeef1;
    --ink-2: #b4b7bf;
    --ink-3: #8a8e98;
    --line: #2b2d34;

    --btn-bg: #edeef1;
    --btn-fg: #0f1013;
    --focus: #7aa5ff;
    --danger: #8e2418;
  }
}

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

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: -0.015em; }
p { margin: 0; }
a { color: inherit; }
b { font-weight: 700; }
svg { flex: none; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 6px;
}

.hidden { display: none !important; }


.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border-radius: var(--r-sm);
  font-family: var(--font-display);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  color: var(--ink);
  background: var(--surface);
  transition: transform 160ms var(--ease), background-color 160ms var(--ease), opacity 160ms;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: default; transform: none; }
.btn-primary { background: var(--btn-bg); color: var(--btn-fg); }
.btn-primary svg { transition: transform 200ms var(--ease); }
.btn-primary:hover svg { transform: translateX(3px); }
.btn-ghost { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-ghost:not(:disabled):hover { background: var(--surface); }

/* ---------- top bar ---------- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(16px, 3vw, 36px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
  flex: 1 1 auto;
}
.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 8px);
  gap: 2px;
  padding: 3px;
  background: var(--plastic);
  border-radius: 7px;
  flex: none;
}
.brand-mark i { width: 8px; height: 8px; border-radius: 2px; }
.brand-mark i:nth-child(1) { background: var(--c-red); }
.brand-mark i:nth-child(2) { background: var(--c-yellow); }
.brand-mark i:nth-child(3) { background: var(--c-blue); }
.brand-mark i:nth-child(4) { background: var(--c-green); }
.brand-mark i:nth-child(5) { background: var(--c-white); }
.brand-mark i:nth-child(6) { background: var(--c-orange); }
.brand-mark i:nth-child(7) { background: var(--c-yellow); }
.brand-mark i:nth-child(8) { background: var(--c-green); }
.brand-mark i:nth-child(9) { background: var(--c-red); }
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.02rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body[data-view="home"] .brand-name { visibility: hidden; }

.topbar-nav { display: flex; align-items: center; gap: 8px; flex: none; }
.nav-link {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 999px;
  transition: background-color 160ms;
  white-space: nowrap;
}
.nav-link:hover { background: var(--surface); }
.nav-link[aria-current="page"] { background: var(--surface); }

.lang-switch {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  background: var(--surface-2);
  border-radius: 999px;
}
.lang-switch button {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  min-width: 42px;
  height: 34px;
  border-radius: 999px;
  cursor: pointer;
}
.lang-switch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); }

.theme-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}
.theme-btn:hover { background: var(--surface); }

/* Grow the touch area to 44px without changing how the controls look. */
.lang-switch button,
.speed button,
.strip-sticker,
.theme-btn { position: relative; }
.lang-switch button::after,
.speed button::after,
.strip-sticker::after,
.theme-btn::after {
  content: "";
  position: absolute;
  inset: 0;
}
.lang-switch button::after { inset: -5px -1px; }
.speed button::after { inset: -6px -1px; }
.strip-sticker::after { inset: -7px -1px; }
.theme-btn::after { inset: -2px; }

/* ---------- banner ---------- */
.banner {
  margin: 0 clamp(16px, 3vw, 36px) 16px;
  padding: 12px 12px 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--danger);
  color: #fff;
  border-radius: var(--r-md);
  font-weight: 600;
}
.banner .btn { flex: none; white-space: nowrap; min-height: 44px; }

/* ============================================================
   home — one face of the cube
   ============================================================ */
.home {
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 40px) clamp(16px, 3vw, 36px) 64px;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  grid-template-areas: "intro face" "link face";
  grid-template-rows: auto auto;
  column-gap: clamp(32px, 5vw, 80px);
  row-gap: 44px;
  align-content: center;
  align-items: center;
  min-height: calc(100dvh - var(--topbar-h));
}
.home-intro { grid-area: intro; align-self: end; }
.home-face-wrap { grid-area: face; }
.side-link { grid-area: link; align-self: start; }

.home-intro { display: flex; flex-direction: column; align-items: flex-start; }
.home-title {
  font-size: clamp(2.8rem, 6.2vw, 5.4rem);
  font-weight: 700;
  line-height: 0.96;
  letter-spacing: -0.035em;
  max-width: 9ch;
}
.home-lead {
  margin-top: 22px;
  font-size: clamp(1.08rem, 1.5vw, 1.25rem);
  color: var(--ink-2);
  max-width: 34ch;
}

.cta {
  margin-top: 36px;
  display: inline-flex;
  align-items: center;
  gap: 28px;
  padding: 14px 14px 14px 28px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border-radius: 999px;
  text-decoration: none;
  transition: transform 160ms var(--ease);
}
.cta:active { transform: scale(0.98); }
.cta-text { display: flex; flex-direction: column; line-height: 1.2; }
.cta-label { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; }
.cta-sub { font-size: 0.92rem; opacity: 0.72; }
.cta-go {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--c-yellow);
  color: #131418;
  transition: transform 220ms var(--ease);
}
.cta:hover .cta-go { transform: translateX(4px); }

.home-progress {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
  color: var(--ink-2);
}
.home-progress b { color: var(--ink); font-variant-numeric: tabular-nums; }
.home-progress-bar { display: flex; gap: 3px; }
.home-progress-bar i {
  width: 14px;
  height: 8px;
  border-radius: 3px;
  background: var(--surface-2);
}
.home-progress-bar i.on { background: var(--accent); }

.side-link {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  width: 100%;
  max-width: 440px;
  border-radius: var(--r-md);
  background: var(--surface);
  text-decoration: none;
  transition: transform 160ms var(--ease);
}
.side-link:hover { transform: translateY(-2px); }
.side-link-text { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.side-link-text b { font-family: var(--font-display); font-weight: 600; }
.side-link-text span { font-size: 0.9rem; color: var(--ink-2); }
.side-link-go { margin-left: auto; color: var(--ink-3); }

.app-footer {
  position: absolute;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid;
  justify-content: center;
  gap: 3px;
  width: min(calc(100% - 32px), 440px);
  max-width: 440px;
  padding: 8px 14px 9px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-family: var(--font-body);
  font-size: 0.78rem;
  line-height: 1.35;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.app-footer-credit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-variant-numeric: normal;
}
.app-footer-credit a {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: inherit;
  text-underline-offset: 3px;
}
.app-footer-credit img {
  width: 14px;
  height: 14px;
  object-fit: contain;
  flex: none;
}
.app-footer-credit a:hover,
.app-footer-credit a:focus-visible { color: var(--ink); }

.mini-stickers {
  display: grid;
  grid-template-columns: repeat(3, 12px);
  gap: 3px;
  padding: 4px;
  border-radius: 8px;
  background: var(--plastic);
  flex: none;
}
.mini-stickers i { height: 12px; border-radius: 3px; }
.mini-stickers i:nth-child(1) { background: var(--c-white); }
.mini-stickers i:nth-child(2) { background: var(--c-yellow); }
.mini-stickers i:nth-child(3) { background: var(--c-green); }
.mini-stickers i:nth-child(4) { background: var(--c-blue); }
.mini-stickers i:nth-child(5) { background: var(--c-red); }
.mini-stickers i:nth-child(6) { background: var(--c-orange); }

/* the face: eight steps clockwise around a live centre */
.home-face-wrap { display: flex; flex-direction: column; align-items: center; }
.home-face {
  --gap: clamp(6px, 1.1vw, 12px);
  width: min(100%, 600px);
  aspect-ratio: 1;
  display: grid;
  grid-template: repeat(3, minmax(0, 1fr)) / repeat(3, minmax(0, 1fr));
  gap: var(--gap);
  padding: var(--gap);
  background: var(--plastic);
  border-radius: clamp(18px, 3vw, 34px);
}
:root[data-theme="dark"] .home-face { box-shadow: inset 0 0 0 1px var(--line); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .home-face { box-shadow: inset 0 0 0 1px var(--line); }
}

.sticker {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(10px, 1.4vw, 16px);
  border-radius: clamp(10px, 1.8vw, 20px);
  text-decoration: none;
  background: var(--accent);
  color: #fff;
  overflow: hidden;
  animation: sticker-in 480ms var(--ease) both;
  animation-delay: calc(var(--i) * 45ms);
  transition: transform 200ms var(--ease), filter 200ms;
}
.sticker[data-tone="light"] { color: #131418; }
.sticker:hover { transform: scale(1.03); }
.sticker:focus-visible { outline-color: #fff; outline-offset: -5px; border-radius: 16px; }

/* not reached yet: an unlit sticker, still recognisably its colour */
.sticker.is-todo {
  background: #24262c;
  color: rgba(255, 255, 255, 0.86);
}
.sticker.is-todo .sticker-num { color: var(--accent); }
.sticker.is-todo:hover { background: #2e3037; }

.sticker.is-next {
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.9), inset 0 0 0 6px rgba(0, 0, 0, 0.25);
}

.sticker-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.sticker-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.4rem, 3.2vw, 2.6rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.sticker-badge {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.18);
}
.sticker[data-tone="dark"] .sticker-badge { background: rgba(255, 255, 255, 0.22); }
.sticker-here {
  width: auto;
  height: auto;
  padding: 4px 9px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.72rem;
  line-height: 1.2;
  white-space: nowrap;
  background: #fff !important;
  color: #131418;
}
.sticker-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(0.8rem, 1.35vw, 1.08rem);
  line-height: 1.15;
  hyphens: auto;
}

.face-center {
  position: relative;
  border-radius: clamp(10px, 1.8vw, 20px);
  background: var(--plastic-2);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.face-center twisty-player { position: absolute; inset: 0; width: 100%; height: 100%; }

.home-face-caption {
  margin-top: 14px;
  font-size: 0.9rem;
  color: var(--ink-3);
}

@keyframes sticker-in {
  from { opacity: 0; transform: scale(0.86); }
  to { opacity: 1; transform: none; }
}

/* ============================================================
   lesson
   ============================================================ */
.lesson {
  padding: 0 clamp(16px, 3vw, 36px) calc(var(--dock-h) + 24px);
  max-width: 1400px;
  margin: 0 auto;
}

.lesson-top {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 4px 0 18px;
}
.strip {
  display: flex;
  gap: 4px;
  padding: 5px;
  background: var(--plastic);
  border-radius: 14px;
  flex: none;
}
.strip-sticker {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
  background: #24262c;
  color: var(--accent);
  transition: transform 160ms var(--ease), background-color 160ms;
}
.strip-sticker:hover { transform: translateY(-2px); }
.strip-sticker.is-done,
.strip-sticker.is-current { background: var(--accent); color: #fff; }
.strip-sticker.is-done[data-tone="light"],
.strip-sticker.is-current[data-tone="light"] { color: #131418; }
.strip-sticker.is-current {
  width: 48px;
  box-shadow: inset 0 0 0 2.5px rgba(255, 255, 255, 0.95);
}
.strip-sticker:focus-visible { outline-offset: 2px; }

.lesson-where { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.lesson-where-count { font-size: 0.85rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.lesson-where-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-body {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: clamp(24px, 3.5vw, 56px);
  align-items: stretch;
}

.stage {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-top: 30px;
}
/* twisty-player lays itself out from its width, so size it by width at
   a fixed 6:5 ratio, capped so the whole cube fits above the dock */
.stage twisty-player {
  width: min(100%, calc((100dvh - var(--topbar-h) - var(--dock-h) - 150px) * 1.2));
  min-width: min(100%, 420px);
  height: auto;
  aspect-ratio: 6 / 5;
}

.speed {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 4px 4px 12px;
  background: var(--ground);
  border-radius: 999px;
  z-index: 2;
}
.speed-label { font-size: 0.8rem; color: var(--ink-3); margin-right: 6px; }
.speed button {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  min-width: 44px;
  height: 34px;
  border-radius: 999px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.speed button[aria-pressed="true"] { background: var(--btn-bg); color: var(--btn-fg); }

.lesson-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px 0;
  min-width: 0;
}
.slide { max-width: 40ch; }
.lesson-text[data-dir="fwd"] .slide { animation: slide-fwd 380ms var(--ease) both; }
.lesson-text[data-dir="back"] .slide { animation: slide-back 380ms var(--ease) both; }
@keyframes slide-fwd { from { opacity: 0; transform: translateX(18px); } }
@keyframes slide-back { from { opacity: 0; transform: translateX(-18px); } }

.slide-title {
  font-size: clamp(1.9rem, 3.2vw, 2.9rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.028em;
  text-wrap: balance;
}
.slide-body {
  margin-top: 18px;
  font-size: clamp(1.08rem, 1.35vw, 1.22rem);
  line-height: 1.62;
  color: var(--ink-2);
  text-wrap: pretty;
}
.slide-body b { color: var(--ink); }

/* notation stickers */
.chips { margin-top: 26px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-grid;
  place-items: center;
  min-width: 46px;
  height: 46px;
  padding: 0 8px;
  border-radius: 11px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1;
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}
.chip-white { background: var(--c-white); color: #131418; box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.16); }
.chip-yellow { background: var(--c-yellow); color: #131418; }
.chip-orange { background: var(--c-orange); color: #131418; }
.chip-green { background: var(--c-green); color: #131418; }
.chip-red { background: var(--c-red); }
.chip-blue { background: var(--c-blue); }
.chip-neutral { background: var(--plastic-2); }
.chips-count {
  display: block;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* completion */
.done-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}
.done-badge > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 9px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
}
.done-badge[data-tone="light"] > span { color: #131418; }

.next-card {
  margin-top: 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px 14px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  text-decoration: none;
  transition: transform 160ms var(--ease);
}
.next-card:hover { transform: translateY(-2px); }
.next-card-mark { display: flex; }
.next-card-mark.mini-stickers { display: grid; }
.next-card-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.next-card-eyebrow { font-size: 0.85rem; color: var(--ink-3); }
.next-card-name { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; }
.next-card-meta { font-size: 0.85rem; color: var(--ink-3); }
.next-card-go { margin-left: auto; color: var(--ink-3); }

/* the dock: back, where you are in the step, next */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 0 clamp(12px, 3vw, 36px) max(12px, env(safe-area-inset-bottom));
  pointer-events: none;
}
.dock-inner {
  pointer-events: auto;
  max-width: 1400px;
  margin: 0 auto;
  height: 72px;
  display: flex;
  align-items: center;
  gap: clamp(10px, 2vw, 24px);
  padding: 0 10px;
  background: var(--surface);
  border-radius: 999px;
  box-shadow: 0 0 0 1px var(--line), 0 12px 32px -18px rgba(0, 0, 0, 0.35);
}
.dock-back { flex: none; }
.dock-next { flex: none; min-width: 150px; }
.dock-progress {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.segs { flex: 1; display: flex; min-width: 0; }
.seg {
  flex: 1;
  height: 44px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.seg span {
  display: block;
  width: 100%;
  height: 8px;
  border-radius: 99px;
  background: var(--surface-2);
  transition: background-color 200ms, height 200ms var(--ease);
}
.seg:hover span { height: 12px; }
.seg.is-past span { background: var(--ink); }
.seg.is-current span { background: var(--accent); height: 12px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.seg-end { flex: 0 0 26px; }
.seg-end span { width: 12px; height: 12px; margin: 0 auto; border-radius: 4px; }
.seg-end.is-current span { width: 16px; height: 16px; }
.seg:focus-visible { outline-offset: -2px; }
.dock-count {
  flex: none;
  min-width: 52px;
  text-align: right;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   cheat sheet
   ============================================================ */
.cheat {
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(8px, 2vw, 28px) clamp(16px, 3vw, 36px) 80px;
}
.cheat-head { max-width: 720px; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: -12px;
  padding: 8px 12px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  color: var(--ink-2);
}
.back-link:hover { background: var(--surface); color: var(--ink); }
.cheat-title {
  margin-top: 18px;
  font-size: clamp(2.3rem, 5vw, 4rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.035em;
}
.cheat-lead { margin-top: 16px; font-size: 1.12rem; color: var(--ink-2); max-width: 52ch; }

.key-box {
  margin-top: 40px;
  padding: clamp(18px, 2.5vw, 28px);
  background: var(--surface);
  border-radius: var(--r-lg);
}
.key-box-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.key-box-head h2 { font-size: 1.35rem; font-weight: 700; }
.key-box-head span { color: var(--ink-3); font-size: 0.95rem; }
.key-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px 20px;
}
.key-item { display: flex; align-items: center; gap: 12px; }
.key-text { display: flex; flex-direction: column; line-height: 1.25; }
.key-word { font-family: var(--font-display); font-weight: 600; }
.key-sub { font-size: 0.88rem; color: var(--ink-3); }
.key-notes {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  color: var(--ink-2);
}
.key-notes span { display: inline-flex; align-items: center; gap: 10px; }
.key-notes .chip { min-width: 40px; height: 36px; font-size: 1rem; }

.cheat-group { margin-top: 48px; }
.cheat-group-head {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  border-radius: var(--r-sm);
}
.cheat-group-head:hover h2 { text-decoration: underline; text-underline-offset: 4px; }
.cheat-group-text { display: flex; flex-direction: column; line-height: 1.15; }
.cheat-group-step { font-size: 0.85rem; color: var(--ink-3); }
.cheat-group-head h2 { font-size: 1.5rem; font-weight: 700; }

.cheat-cards {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}
.cheat-card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: var(--surface);
  border-radius: var(--r-lg);
}
.cheat-name { font-size: 1.2rem; font-weight: 600; }
.cheat-card .chips { margin-top: 14px; }
.cheat-card .chip { min-width: 38px; height: 38px; font-size: 1.02rem; border-radius: 9px; }
.cheat-card .chip-row { gap: 5px; }
.cheat-cube {
  margin-top: auto;
  padding-top: 14px;
  width: 100%;
  aspect-ratio: 5 / 4;
}
.cheat-cube twisty-player { width: 100%; height: 100%; }

/* ---------- confetti ---------- */
#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 50;
}

/* ============================================================
   smaller screens
   ============================================================ */
@media (max-width: 960px) {
  .home {
    grid-template-columns: 1fr;
    grid-template-areas: "intro" "face" "link";
    row-gap: 36px;
    min-height: 0;
  }
  .home-title { max-width: 12ch; }
  .side-link { max-width: none; }
  .app-footer {
    position: static;
    transform: none;
    grid-area: auto;
    margin: 0 auto;
    max-width: none;
  }

  .lesson-body { grid-template-columns: 1fr; gap: 20px; }
  .stage { padding-top: 44px; }
  .stage twisty-player { width: min(100%, 620px); min-width: 0; }
  .slide { max-width: 62ch; }
  .lesson-text { padding: 0; }
}

@media (max-width: 620px) {
  :root { --topbar-h: 60px; --dock-h: 76px; }
  body { font-size: 16px; }
  .nav-link { padding: 10px 12px; }
  .brand-name { display: none; } /* the mark alone: no room beside the theme button */

  .home { gap: 28px; padding-bottom: 40px; }
  .cta { width: 100%; justify-content: space-between; gap: 12px; padding-left: 22px; }
  .cta-label { font-size: 1.15rem; }
  .sticker-here {
    width: 14px;
    height: 14px;
    padding: 0;
    font-size: 0;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.2);
  }
  .sticker-badge { width: 20px; height: 20px; }
  .sticker-badge svg { width: 11px; height: 11px; }

  .lesson-top { gap: 12px; padding-bottom: 12px; }
  .strip { gap: 3px; padding: 4px; border-radius: 11px; }
  .strip-sticker { width: 26px; height: 30px; border-radius: 7px; font-size: 0.75rem; }
  .strip-sticker.is-current { width: 34px; }
  .strip-sticker svg { width: 10px; height: 10px; }
  .lesson-where-count { font-size: 0.75rem; }
  .lesson-where-name { font-size: 0.95rem; }
  .stage { border-radius: 22px; padding-top: 40px; }
  .stage twisty-player { width: 100%; }
  .speed { top: 10px; right: 10px; }
  .speed-label { display: none; }
  .speed { padding-left: 4px; }
  .speed button { min-width: 40px; height: 32px; }

  .chip { min-width: 42px; height: 42px; font-size: 1.1rem; }

  .dock { padding-left: 8px; padding-right: 8px; }
  .dock-inner { height: 64px; gap: 8px; padding: 0 6px; }
  .dock-back { width: 52px; padding: 0; }
  .dock-back span { display: none; }
  .dock-next { min-width: 0; padding: 0 18px; }
  .dock-count { display: none; }
}

@media (max-width: 380px) {
  .strip-sticker { width: 24px; }
  .strip-sticker.is-current { width: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
