/* ============================================================
   Keybending · styles
   Palette and type borrowed from marisolcornejo.com
   ============================================================ */

/* OpenDyslexic, self-hosted. SIL Open Font License — see fonts/OFL.txt.
   Only downloaded when the reading font is set to it. */
/* Every face is self-hosted (the Latin files Google Fonts serves), so her pages call no other
   company. All SIL Open Font License: see fonts/LICENSES.txt. */
@font-face { font-family: 'Atkinson Hyperlegible Mono'; src: url('../fonts/AtkinsonHyperlegibleMono-latin.woff2') format('woff2'); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Atkinson Hyperlegible Next'; src: url('../fonts/AtkinsonHyperlegibleNext-latin.woff2') format('woff2'); font-weight: 300 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'OpenDyslexic'; src: url('../fonts/OpenDyslexic-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'OpenDyslexic'; src: url('../fonts/OpenDyslexic-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'OpenDyslexic'; src: url('../fonts/OpenDyslexic-Italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'OpenDyslexic'; src: url('../fonts/OpenDyslexic-Bold-Italic.woff2') format('woff2'); font-weight: 700; font-style: italic; font-display: swap; }

:root {
  --clay:   #A0522D;
  --rust:   #8B3A2A;
  --gold:   #C9973A;
  --gold-soft: #E7C77F;
  --sage:   #7A9E7E;
  --sage-deep: #4F7454;
  --cream:  #FAF5EC;
  --sand:   #E8D5B0;
  --sand-soft: #F1E6CF;
  --indigo: #2B2D42;
  --indigo-soft: #4A4D6B;
  --text:   #1C1A17;
  --muted:  #6B645A;
  --paper:  #FFFDF8;

  --water: #3E5C8A;
  --water-soft: #DCE5F2;
  --earth: #5E7F5E;
  --earth-soft: #DFE9DA;
  --fire:  #A0522D;
  --fire-soft: #F3DCCF;
  --air:   #C9973A;
  --air-soft: #F6E9CC;

  /* Type is a setting, not a constant. These are the "Easy read" values, the default;
     the [data-font] blocks below restate them and swap in OpenDyslexic. */
  --serif-display: 'Atkinson Hyperlegible Next', 'Atkinson Hyperlegible', Verdana, sans-serif;
  --serif-body: 'Atkinson Hyperlegible Next', 'Atkinson Hyperlegible', Verdana, sans-serif;
  --mono: 'Atkinson Hyperlegible Mono', Menlo, monospace;
  --head-scale: .92;
  --drill-scale: 1;
  --body-leading: 1.62;
  --body-tracking: .01em;
  --body-words: .06em;
  --drill-tracking: .05em;

  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px -14px rgba(28, 26, 23, .28);
  --shadow-soft: 0 4px 14px -8px rgba(28, 26, 23, .25);
  --ease: cubic-bezier(.22, .61, .36, 1);
  --header-h: 64px;
}

/* ---------- reading font ----------
   Marisol is dyslexic, so the default is a face built for that, not the
   pretty one. An inline script in index.html stamps data-font on <html>
   before first paint, so switching never flashes the wrong type. */
:root[data-font="easy"] {
  --serif-display: 'Atkinson Hyperlegible Next', 'Atkinson Hyperlegible', Verdana, sans-serif;
  --serif-body: 'Atkinson Hyperlegible Next', 'Atkinson Hyperlegible', Verdana, sans-serif;
  --mono: 'Atkinson Hyperlegible Mono', Menlo, monospace;
  --head-scale: .92;
  --body-leading: 1.62;
  --body-tracking: .01em;
  --body-words: .06em;
  --drill-tracking: .05em;
}

:root[data-font="dyslexic"] {
  --serif-display: 'OpenDyslexic', 'Atkinson Hyperlegible Next', Verdana, sans-serif;
  --serif-body: 'OpenDyslexic', 'Atkinson Hyperlegible Next', Verdana, sans-serif;
  --mono: 'OpenDyslexic', 'Atkinson Hyperlegible Mono', Menlo, monospace;
  --head-scale: .8;
  --drill-scale: .88;
  --body-leading: 1.7;
  --body-tracking: .01em;
  --body-words: .09em;
  --drill-tracking: .05em;
}

/* Italics smear for a lot of dyslexic readers, so every slanted accent
   stands back up. Colour and weight carry it instead.
   Keep this list in step with the `font-style: italic` rules below. */
:root :is(
  em, i, cite,
  .eyebrow, .tip, .book-tagline, .bonus-note, .sync-status, .login-msg,
  .stage-note, .sticker.locked .nm, .cheer-line
) { font-style: normal; }
/* Pseudo-elements are not allowed inside :is(), so this one stands alone. */
:root .text.waiting::after { font-style: normal; }
:root .eyebrow { font-weight: 600; }
:root .tip { color: var(--clay); }

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(201, 151, 58, .12), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(122, 158, 126, .12), transparent 55%),
    var(--cream);
  font-family: var(--serif-body);
  font-size: 19px;
  line-height: var(--body-leading);
  letter-spacing: var(--body-tracking);
  word-spacing: var(--body-words);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: var(--serif-display); font-weight: 400; line-height: 1.12; margin: 0; letter-spacing: -.005em; }
h1 { font-size: calc(clamp(2.4rem, 4.5vw, 3.6rem) * var(--head-scale)); }
h2 { font-size: calc(clamp(1.6rem, 2.6vw, 2.2rem) * var(--head-scale)); }
h3 { font-size: calc(1.35rem * var(--head-scale)); }
p { margin: 0 0 .8em; }
a { color: var(--clay); }
small, .small { font-size: .9rem; }
.muted { color: var(--muted); }
.eyebrow { font-family: var(--serif-body); font-style: italic; color: var(--clay); letter-spacing: .02em; font-size: 1rem; }
.center { text-align: center; }
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }

button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---------- background flourishes ---------- */
.particles { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.particles span {
  position: absolute;
  bottom: -20px;
  width: var(--s, 6px); height: var(--s, 6px);
  border-radius: 50%;
  background: var(--c, var(--gold));
  opacity: 0;
  animation: float var(--d, 14s) linear var(--delay, 0s) infinite;
}
@keyframes float {
  0%   { transform: translate(0, 0) scale(.8); opacity: 0; }
  10%  { opacity: .55; }
  90%  { opacity: .35; }
  100% { transform: translate(var(--x, 20px), -110vh) scale(1.1); opacity: 0; }
}
.scroll-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: linear-gradient(90deg, var(--gold), var(--clay)); z-index: 60; transition: width .12s linear; }

/* ---------- header / footer ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(16px, 4vw, 40px);
  background: rgba(250, 245, 236, .82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(201, 151, 58, .25);
  transition: transform .35s var(--ease), opacity .35s var(--ease);
}
body.focus .site-header { transform: translateY(-110%); opacity: 0; pointer-events: none; }
body.focus .site-footer, body.focus .particles { opacity: 0; transition: opacity .3s; }
.brand { font-family: var(--serif-display); font-size: 1.5rem; color: var(--indigo); text-decoration: none; display: inline-flex; align-items: center; gap: .45rem; }
.brand-glyph { font-size: 1.25rem; }
.site-nav { display: flex; align-items: center; gap: .25rem; }
.site-nav a {
  text-decoration: none; color: var(--indigo); padding: .45rem .8rem; border-radius: 999px;
  font-size: 1.02rem; transition: background .2s;
}
.site-nav a:hover, .site-nav a.active { background: rgba(201, 151, 58, .18); }
.site-nav a.nav-home { border: 1px solid rgba(201, 151, 58, .45); margin-left: .3rem; }
.icon-btn {
  background: transparent; border: 0; cursor: pointer; padding: .5rem; border-radius: 50%;
  display: inline-grid; place-items: center; color: var(--indigo); transition: background .2s, transform .2s;
}
.icon-btn:hover { background: rgba(201, 151, 58, .18); transform: rotate(12deg); }
.site-footer { text-align: center; color: var(--muted); font-size: .95rem; padding: 2.5rem 1rem 3rem; position: relative; z-index: 1; }

/* ---------- layout ---------- */
.app { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; padding: clamp(20px, 4vw, 44px) clamp(16px, 4vw, 40px) 20px; }
.stack { display: grid; gap: 1.25rem; }
.card {
  background: var(--paper);
  border: 1px solid rgba(201, 151, 58, .35);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: clamp(18px, 2.6vw, 30px);
}
.row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.divider { height: 1px; background: linear-gradient(90deg, transparent, rgba(201, 151, 58, .55), transparent); margin: 2rem 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border: 2px solid var(--clay); background: var(--clay); color: var(--cream);
  padding: .7rem 1.35rem; border-radius: 999px; font-size: 1.08rem; cursor: pointer;
  text-decoration: none; transition: transform .15s var(--ease), box-shadow .2s, background .2s;
  box-shadow: 0 8px 18px -12px rgba(160, 82, 45, .7);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 12px 24px -12px rgba(160, 82, 45, .75); }
.btn:active { transform: translateY(0); }
.btn.big { font-size: 1.3rem; padding: 1rem 1.9rem; }
.btn.ghost { background: transparent; color: var(--clay); box-shadow: none; }
.btn.ghost:hover { background: rgba(160, 82, 45, .08); }
.btn.sage { background: var(--sage-deep); border-color: var(--sage-deep); box-shadow: 0 8px 18px -12px rgba(79, 116, 84, .7); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--indigo); }
.btn.small { font-size: .95rem; padding: .45rem .95rem; }
.btn kbd { font-family: var(--mono); font-size: .72em; background: rgba(255, 255, 255, .22); padding: .1rem .4rem; border-radius: 6px; margin-left: .15rem; }
.btn.ghost kbd { background: rgba(160, 82, 45, .12); }
.actions { display: flex; gap: .8rem; flex-wrap: wrap; align-items: center; margin-top: 1.4rem; }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: 1.3fr .9fr; gap: 2rem; align-items: center; }
.hero-copy .greeting { margin-bottom: .4rem; }
.hero-copy .lede { font-size: 1.25rem; color: var(--muted); max-width: 34ch; }
.continue-card {
  margin-top: 1.4rem; padding: 1.2rem 1.4rem; border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(201, 151, 58, .18), rgba(122, 158, 126, .14));
  border: 1px solid rgba(201, 151, 58, .4);
  display: grid; gap: .6rem;
}
.continue-card .where { font-size: 1.05rem; color: var(--indigo); }
.continue-card .where strong { font-family: var(--serif-display); font-weight: 400; font-size: 1.35rem; display: block; }
.sunflower-wrap { display: grid; place-items: center; text-align: center; gap: .5rem; }
.sunflower-wrap svg { width: min(100%, 260px); height: auto; filter: drop-shadow(0 12px 18px rgba(28, 26, 23, .15)); }
.sunflower-wrap .stage-note { font-style: italic; color: var(--muted); font-size: 1rem; max-width: 26ch; }

.week { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1.5rem; }
.week-dots { display: flex; gap: .45rem; }
.week-dots span {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--sand);
  background: transparent; display: grid; place-items: center; font-size: .6rem; color: var(--muted);
  position: relative;
}
.week-dots span.on { background: var(--sage); border-color: var(--sage); }
.week-dots span.today { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201, 151, 58, .25); }
.week-dots span::after { content: attr(data-d); position: absolute; top: 22px; font-size: .7rem; color: var(--muted); }
.week-text { color: var(--muted); }
.xp-chip { margin-left: auto; font-family: var(--mono); font-size: .85rem; background: var(--indigo); color: var(--cream); padding: .25rem .7rem; border-radius: 999px; }

.books { display: grid; gap: 1.4rem; margin-top: 2.2rem; }
.book { position: relative; overflow: hidden; }
.book::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; background: var(--book-color, var(--gold)); }
.book-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.book-head .glyph { font-size: 2rem; line-height: 1; margin-right: .5rem; }
.book-title { display: flex; align-items: center; gap: .6rem; }
.book-title h2 { color: var(--book-color, var(--indigo)); }
.book-tagline { font-style: italic; color: var(--muted); margin: .2rem 0 0; }
.book-progress { font-family: var(--mono); font-size: .8rem; color: var(--muted); white-space: nowrap; margin-top: .4rem; }
.book.locked { opacity: .72; }
.lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .6rem; }
.lesson-row {
  display: grid; grid-template-columns: 40px 1fr auto; gap: .7rem; align-items: center;
  text-align: left; padding: .65rem .85rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: rgba(232, 213, 176, .25); cursor: pointer;
  transition: transform .15s var(--ease), background .2s, border-color .2s;
}
.lesson-row:hover:not(:disabled) { background: rgba(232, 213, 176, .5); transform: translateX(3px); }
.lesson-row:disabled { cursor: not-allowed; color: var(--muted); }
.lesson-row .num {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--sand); color: var(--indigo); font-family: var(--mono); font-size: .85rem;
}
.lesson-row.done .num { background: var(--sage); color: var(--cream); }
.lesson-row.next .num { background: var(--gold); color: var(--indigo); animation: pulse 2.2s ease-in-out infinite; }
.lesson-row.next { border-color: rgba(201, 151, 58, .6); background: rgba(201, 151, 58, .14); }
.lesson-row .title { font-size: 1.08rem; line-height: 1.2; }
.lesson-row .sub { color: var(--muted); font-size: .9rem; }
.lesson-row .stars { font-size: .85rem; letter-spacing: .05em; color: var(--gold); white-space: nowrap; }
.lesson-row .lock { color: var(--muted); font-size: .9rem; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(201, 151, 58, .55); } 50% { box-shadow: 0 0 0 8px rgba(201, 151, 58, 0); } }

.practice-teaser { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ---------- lesson intro ---------- */
.intro { max-width: 760px; margin: 0 auto; }
.intro .key-callouts { display: flex; gap: 1rem; flex-wrap: wrap; margin: 1.2rem 0; }
.callout {
  display: grid; grid-template-columns: auto 1fr; gap: .9rem; align-items: center;
  padding: .8rem 1rem; border-radius: var(--radius-sm); background: var(--sand-soft);
  border: 1px solid rgba(201, 151, 58, .35); min-width: 240px; flex: 1;
}
.keycap {
  font-family: var(--mono); font-size: 1.5rem; width: 56px; height: 56px; border-radius: 12px;
  display: grid; place-items: center; background: var(--paper); color: var(--indigo);
  border: 1px solid var(--sand); box-shadow: 0 3px 0 var(--sand), 0 6px 12px -8px rgba(0, 0, 0, .3);
}
.callout .finger { font-size: 1rem; }
.callout .finger strong { color: var(--clay); }
.intro .plan { display: flex; gap: .6rem; flex-wrap: wrap; margin: .5rem 0 1.2rem; }
.intro .plan span { font-size: .9rem; padding: .3rem .7rem; border-radius: 999px; background: rgba(43, 45, 66, .08); color: var(--indigo); }
.posture { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: center; padding: 1rem; border-radius: var(--radius-sm); background: rgba(122, 158, 126, .12); margin-top: 1rem; }
.posture .emoji { font-size: 2rem; }

/* ---------- round ---------- */
.round { max-width: 980px; margin: 0 auto; display: grid; gap: 1.1rem; padding-top: .5rem; }
.round-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.round-top h2 { font-size: 1.6rem; }
.round-dots { display: flex; gap: .4rem; align-items: center; }
.round-dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--sand); }
.round-dots span.done { background: var(--sage); }
.round-dots span.cur { background: var(--gold); transform: scale(1.25); }
.round-timer { font-family: var(--mono); font-size: 1.1rem; color: var(--indigo); background: var(--sand-soft); padding: .25rem .7rem; border-radius: 999px; }
.round-timer.low { color: var(--rust); }
.tip { color: var(--muted); font-style: italic; text-align: center; min-height: 1.5em; }
.tip.caps { color: var(--rust); font-weight: 700; }

.text {
  font-family: var(--mono); font-size: calc(clamp(1.5rem, 2.6vw, 2.05rem) * var(--drill-scale)); line-height: 1.85;
  padding: 1.4rem 1.8rem; border-radius: var(--radius);
  background: var(--paper); border: 1px solid rgba(201, 151, 58, .35); box-shadow: var(--shadow-soft);
  white-space: pre-wrap; word-break: break-word; letter-spacing: var(--drill-tracking); word-spacing: normal; user-select: none;
  position: relative; cursor: default;
}
.text.long { font-size: calc(clamp(1.2rem, 2vw, 1.55rem) * var(--drill-scale)); line-height: 1.75; padding: 1.1rem 1.4rem; }
.text.waiting::after {
  content: 'start typing whenever you\'re ready';
  position: absolute; right: 1rem; bottom: .4rem; font-family: var(--serif-body); font-style: italic;
  font-size: .95rem; color: var(--muted); letter-spacing: 0;
}
.ch { color: rgba(28, 26, 23, .42); position: relative; border-radius: 4px; transition: color .12s; }
.ch.sp { display: inline-block; min-width: .55em; }
.ch.done { color: var(--sage-deep); }
.ch.done.slip { color: var(--clay); text-decoration: underline dotted rgba(160, 82, 45, .6); text-underline-offset: .2em; }
.ch.cur { color: var(--indigo); background: rgba(201, 151, 58, .22); }
.ch.cur::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -.1em; height: 3px; border-radius: 2px;
  background: var(--gold); animation: caret 1s ease-in-out infinite;
}
.ch.cur.sp::after { left: .1em; right: .1em; }
.ch.miss { animation: shake .3s var(--ease); background: rgba(160, 82, 45, .22); }
@keyframes caret { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@keyframes shake { 0% { transform: translateX(0); } 25% { transform: translateX(-3px); } 50% { transform: translateX(3px); } 75% { transform: translateX(-2px); } 100% { transform: translateX(0); } }

.round-hint { text-align: center; color: var(--muted); font-size: .9rem; }
.round-hint kbd { font-family: var(--mono); font-size: .8em; background: var(--sand-soft); padding: .1rem .4rem; border-radius: 5px; }

/* ---------- keyboard + hands ---------- */
.kb-wrap { display: grid; gap: .6rem; justify-items: center; }
.kb {
  --u: clamp(34px, 4.1vw, 52px);
  display: grid; gap: 5px; padding: 12px; border-radius: 16px;
  background: linear-gradient(180deg, #E9E1D2, #DDD3C0);
  border: 1px solid rgba(28, 26, 23, .12); box-shadow: var(--shadow);
  width: max-content; max-width: 100%;
}
.kb-row { display: flex; gap: 5px; }
.key {
  --w: 1;
  width: calc(var(--u) * var(--w) + 5px * (var(--w) - 1));
  height: calc(var(--u) * .86);
  border-radius: 8px; background: var(--paper); color: var(--indigo);
  display: grid; place-items: center; font-family: var(--mono); font-size: calc(var(--u) * .3);
  box-shadow: 0 2px 0 rgba(28, 26, 23, .15), inset 0 -2px 0 rgba(28, 26, 23, .04);
  position: relative; transition: background .12s, transform .12s, color .12s;
  user-select: none;
}
.key.mod { font-size: calc(var(--u) * .24); color: var(--muted); }
.key.home::after { content: ''; position: absolute; bottom: 6px; width: 32%; height: 3px; border-radius: 2px; background: rgba(43, 45, 66, .35); }
.key.hi { background: var(--gold); color: var(--indigo); transform: translateY(1px); box-shadow: 0 0 0 3px rgba(201, 151, 58, .35), 0 1px 0 rgba(28, 26, 23, .2); }
.key.hi-shift { background: var(--gold-soft); }
.key.pop { animation: keypop .28s var(--ease); }
@keyframes keypop { 0% { transform: translateY(2px) scale(.96); background: var(--sand); } 100% { transform: translateY(0) scale(1); } }
.key.oops { animation: oops .45s ease; }
@keyframes oops { 0%, 100% { box-shadow: 0 2px 0 rgba(28, 26, 23, .15); } 50% { box-shadow: 0 0 0 5px rgba(160, 82, 45, .5); } }

.hands { display: flex; gap: clamp(20px, 6vw, 80px); justify-content: center; align-items: flex-end; }
.hand { width: clamp(110px, 14vw, 160px); height: auto; }
.hand .palm, .hand .finger { fill: #F0DEC6; stroke: rgba(139, 58, 42, .28); stroke-width: 2; transition: fill .15s; }
.hand .finger.hi { fill: var(--gold); stroke: var(--clay); }
.hand .finger.hi-shift { fill: var(--gold-soft); }
.hand-label { font-size: .8rem; color: var(--muted); text-align: center; margin-top: .2rem; }

/* ---------- companion ---------- */
.companion {
  position: fixed; right: clamp(12px, 2.5vw, 36px); bottom: clamp(12px, 2.5vw, 30px); z-index: 20;
  display: flex; align-items: center; gap: .7rem; max-width: 320px;
  background: var(--paper); border: 1px solid rgba(201, 151, 58, .45); border-radius: 999px;
  padding: .45rem .9rem .45rem .5rem; box-shadow: var(--shadow); font-size: .95rem;
  transform: translateY(0); transition: transform .35s var(--ease), opacity .3s;
}
.companion.hide { transform: translateY(140%); opacity: 0; }
.companion .face { font-size: 1.6rem; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--sand-soft); }
.companion .say { color: var(--indigo); line-height: 1.25; }

/* ---------- interstitial + results ---------- */
.interstitial {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  background: rgba(250, 245, 236, .72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: fadein .25s var(--ease);
}
.interstitial .card { width: min(520px, 92vw); text-align: center; animation: rise .35s var(--ease); }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.stat-row { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin: 1rem 0; }
.stat { min-width: 120px; padding: .8rem 1rem; border-radius: var(--radius-sm); background: var(--sand-soft); }
.stat .v { font-family: var(--serif-display); font-size: 2.2rem; color: var(--indigo); line-height: 1; }
.stat .v.hero { font-size: 3rem; color: var(--clay); }
.stat .l { color: var(--muted); font-size: .9rem; margin-top: .3rem; }
/* Between rounds the kind words lead and the numbers sit back. */
.stat-row.quiet { gap: .6rem; margin: .6rem 0 1rem; }
.stat-row.quiet .stat { min-width: 0; padding: .4rem .8rem; background: none; display: flex; align-items: baseline; gap: .4rem; }
.stat-row.quiet .stat .v { font-size: 1.15rem; color: var(--muted); }
.stat-row.quiet .stat .l { margin: 0; }
.interstitial .cheer-line { font-size: 1.2rem; color: var(--indigo); margin: .4rem 0 0; }

.results { max-width: 720px; margin: 0 auto; text-align: center; }
.results h1 { margin-bottom: .3rem; }
.sparkles { font-size: 2.2rem; letter-spacing: .3rem; margin: .3rem 0; }
.sparkles .off { opacity: .25; filter: grayscale(1); }
.sticker-reveal { margin: 1.5rem auto; display: grid; place-items: center; perspective: 900px; }
.sticker {
  width: 150px; height: 170px; border-radius: 16px; background: var(--paper);
  border: 3px solid var(--gold); box-shadow: 0 12px 24px -14px rgba(28, 26, 23, .4), inset 0 0 0 4px var(--cream);
  display: grid; place-items: center; align-content: center; gap: .4rem; padding: .6rem;
  transform-style: preserve-3d; position: relative;
}
.sticker .em { font-size: 3.4rem; line-height: 1; }
.sticker .nm { font-family: var(--serif-display); font-size: 1.02rem; color: var(--indigo); text-align: center; line-height: 1.15; }
.sticker .dt { font-family: var(--mono); font-size: .68rem; color: var(--muted); }
.sticker.flip { animation: flip .9s var(--ease); }
@keyframes flip { 0% { transform: rotateY(180deg) scale(.7); opacity: 0; } 60% { transform: rotateY(-15deg) scale(1.05); opacity: 1; } 100% { transform: rotateY(0) scale(1); } }
.sticker.rare { border-color: var(--clay); background: linear-gradient(160deg, var(--paper), var(--air-soft)); }
.sticker.rare::before { content: 'rare'; position: absolute; top: -10px; right: -8px; background: var(--clay); color: var(--cream); font-family: var(--mono); font-size: .62rem; padding: .15rem .45rem; border-radius: 999px; transform: rotate(8deg); }
.sticker.locked { border-style: dashed; border-color: var(--sand); background: transparent; box-shadow: none; }
.sticker.locked .em { opacity: .35; filter: grayscale(1) blur(1px); }
.sticker.locked .nm { color: var(--muted); font-style: italic; font-family: var(--serif-body); font-size: .9rem; }
.bonus-note { color: var(--sage-deep); font-style: italic; }
.cheer-line { font-style: italic; color: var(--muted); }

/* ---------- practice ---------- */
.packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .9rem; margin-top: 1rem; }
.pack {
  text-align: left; padding: 1rem 1.1rem; border-radius: var(--radius); cursor: pointer;
  background: var(--paper); border: 1px solid rgba(201, 151, 58, .35); box-shadow: var(--shadow-soft);
  display: grid; gap: .3rem; transition: transform .15s var(--ease), box-shadow .2s;
}
.pack:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.pack .em { font-size: 1.9rem; }
.pack h3 { font-size: 1.25rem; }
.pack p { color: var(--muted); font-size: .95rem; margin: 0; }
.pack.test { background: linear-gradient(135deg, var(--indigo), var(--indigo-soft)); color: var(--cream); border-color: transparent; }
.pack.test p, .pack.test h3 { color: var(--cream); }
.custom-box { display: grid; gap: .6rem; }
textarea, input[type=text] {
  font: inherit; width: 100%; padding: .7rem .9rem; border-radius: var(--radius-sm);
  border: 1px solid rgba(201, 151, 58, .5); background: var(--paper); color: var(--text); resize: vertical;
}
textarea { font-family: var(--mono); font-size: 1rem; }

/* ---------- scrapbook ---------- */
.scrap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; justify-items: center; margin-top: 1.2rem; }
.scrap-grid .sticker:nth-child(3n) { transform: rotate(-2deg); }
.scrap-grid .sticker:nth-child(3n+1) { transform: rotate(1.5deg); }
.scrap-grid .sticker:hover { transform: rotate(0) scale(1.04); transition: transform .2s var(--ease); }
.scrap-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ---------- letter + certificate ---------- */
.letter { max-width: 680px; margin: 0 auto; }
.letter .paper {
  background: var(--paper); border: 1px solid rgba(201, 151, 58, .4); border-radius: 6px; padding: clamp(24px, 4vw, 48px);
  box-shadow: var(--shadow); font-size: 1.2rem; line-height: 1.7; white-space: pre-wrap; min-height: 200px;
  background-image: repeating-linear-gradient(transparent, transparent 1.68em, rgba(201, 151, 58, .12) 1.68em, rgba(201, 151, 58, .12) calc(1.68em + 1px));
}
.letter .paper .cursor { display: inline-block; width: .6ch; border-bottom: 2px solid var(--clay); animation: caret 1s infinite; }
.certificate {
  max-width: 760px; margin: 0 auto; text-align: center; padding: clamp(28px, 5vw, 56px);
  background: var(--paper); border: 6px double var(--gold); border-radius: 8px; box-shadow: var(--shadow);
  position: relative;
}
.certificate::before { content: '🌻'; position: absolute; top: 18px; left: 22px; font-size: 1.6rem; }
.certificate::after { content: '🌻'; position: absolute; bottom: 18px; right: 22px; font-size: 1.6rem; }
.certificate h1 { color: var(--clay); }
.certificate .name { font-family: var(--serif-display); font-size: clamp(2.6rem, 6vw, 4rem); color: var(--indigo); margin: .5rem 0; }
.certificate .seal { display: inline-block; margin-top: 1.2rem; padding: .6rem 1.2rem; border-radius: 999px; background: var(--indigo); color: var(--cream); font-family: var(--mono); font-size: .85rem; }

/* ---------- locked door ---------- */
.sync-status { font-size: .85rem; color: var(--muted); font-style: italic; margin: 0 .4rem; transition: opacity .3s; }
.sync-status[data-state="error"] { color: var(--rust); }
body.locked .site-nav a, body.locked .site-footer, body.locked .sync-status { display: none; }
.login { max-width: 600px; margin: 3vh auto 0; text-align: center; display: grid; gap: .5rem; justify-items: center; }
.login .sunflower-wrap svg { width: 170px; }
.login h1 { margin-top: .2rem; }
.login-form { display: flex; gap: .6rem; width: 100%; max-width: 480px; margin-top: .6rem; }
.login-form input { flex: 1; font-size: 1.15rem; text-align: center; letter-spacing: .06em; }
.login-form.shake { animation: shake .35s var(--ease); }
.login-msg { min-height: 1.5em; color: var(--rust); font-style: italic; margin: .2rem 0 0; }

/* ---------- settings ---------- */
.settings { border: 0; border-radius: var(--radius); padding: 0; width: min(560px, 94vw); background: var(--paper); box-shadow: 0 30px 60px -30px rgba(28, 26, 23, .6); }
.settings::backdrop { background: rgba(43, 45, 66, .45); backdrop-filter: blur(3px); }
.settings-form { padding: 1.4rem 1.6rem 1.6rem; display: grid; gap: 1rem; }
.settings-head { display: flex; align-items: center; justify-content: space-between; }
.toggle { display: grid; grid-template-columns: 48px 1fr; gap: .9rem; align-items: center; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track { width: 48px; height: 28px; border-radius: 999px; background: var(--sand); position: relative; transition: background .2s; }
.toggle-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--paper); transition: transform .2s var(--ease); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.toggle input:checked + .toggle-track { background: var(--sage); }
.toggle input:checked + .toggle-track::after { transform: translateX(20px); }
.toggle input:focus-visible + .toggle-track { outline: 3px solid var(--gold); outline-offset: 2px; }
.toggle-text { display: grid; }
.toggle-text small { color: var(--muted); }
.field { display: grid; gap: .4rem; }
.field-label { font-weight: 600; }
.companion-pick { display: flex; gap: .6rem; flex-wrap: wrap; }
.companion-pick button {
  border: 2px solid var(--sand); background: var(--sand-soft); border-radius: 999px; padding: .4rem .9rem .4rem .5rem;
  display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; font-size: 1rem;
}
.companion-pick button.on { border-color: var(--gold); background: rgba(201, 151, 58, .2); }
.font-pick { display: grid; gap: .5rem; }
.font-pick button {
  border: 2px solid var(--sand); background: var(--sand-soft); border-radius: var(--radius-sm);
  padding: .6rem .85rem; cursor: pointer; text-align: left; display: grid; gap: .1rem;
  letter-spacing: normal; word-spacing: normal;
}
.font-pick button.on { border-color: var(--gold); background: rgba(201, 151, 58, .2); }
.font-pick .nm { font-size: 1.15rem; line-height: 1.25; }
.font-pick .why { font-size: .85rem; color: var(--muted); font-family: var(--serif-body); font-style: normal; }
.font-pick .s-easy { font-family: 'Atkinson Hyperlegible Next', 'Atkinson Hyperlegible', Verdana, sans-serif; }
.font-pick .s-dyslexic { font-family: 'OpenDyslexic', Verdana, sans-serif; font-size: 1rem; }
.settings-more summary { cursor: pointer; color: var(--clay); }
.settings-more.danger summary { color: var(--rust); }
.settings-more > *:not(summary) { margin-top: .6rem; }

/* ---------- confetti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti i {
  position: absolute; left: 50%; top: 45%; width: 10px; height: 14px; background: var(--c);
  border-radius: 2px; animation: burst 1.4s var(--ease) forwards; opacity: 0;
}
@keyframes burst {
  0%   { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}

/* ---------- phone gate ---------- */
.phone-gate { display: none; position: fixed; inset: 0; z-index: 100; background: var(--cream); place-items: center; padding: 2rem; text-align: center; }
.phone-card { max-width: 420px; }
.phone-emoji { font-size: 3.5rem; }
@media (max-width: 720px) {
  .phone-gate { display: grid; }
  .site-header, .app, .site-footer, .companion { display: none !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .sunflower-wrap { order: -1; }
  .sunflower-wrap svg { width: 180px; }
}

/* ---------- motion ---------- */
body.calm .particles, body.calm .confetti { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .particles, .confetti { display: none !important; }
}

/* ---------- print (certificate) ---------- */
@media print {
  body { background: #fff; }
  .site-header, .site-footer, .particles, .scroll-progress, .companion, .actions, .no-print { display: none !important; }
  .app { padding: 0; max-width: none; }
  .certificate { box-shadow: none; border-color: var(--gold); }
}

/* ---------- care notes from Javier ---------- */
.care { display: grid; grid-template-columns: auto 1fr; gap: .8rem; align-items: center; text-align: left; max-width: 560px; margin: 1.2rem auto 0; background: linear-gradient(135deg, rgba(122, 158, 126, .16), rgba(62, 92, 138, .08)); border: 1px solid rgba(122, 158, 126, .45); border-radius: var(--radius); padding: .7rem .9rem; }
.care-emoji { font-size: 1.8rem; width: 48px; height: 48px; border-radius: 50%; background: var(--paper); display: grid; place-items: center; }
.care-text { color: var(--indigo); font-size: 1.05rem; line-height: 1.4; }
.care-pet { color: var(--muted); }
.care-from { display: block; font-size: .85rem; color: var(--sage-deep); font-weight: 600; margin-top: .15rem; }
