/* ==========================================================================
   Components
   Each block uses semantic or tone tokens only. No raw colours here,
   except inside illustrations.
   ========================================================================== */

/* ---------- Button ---------- */
.btn {
  --btn-bg: var(--color-brand);
  --btn-fg: var(--color-text-on-brand);
  --btn-bg-hover: var(--color-brand-strong);
  --btn-border: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--button-height);
  padding: 0 var(--space-6);
  border: 2px solid var(--btn-border);
  border-radius: var(--radius-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  text-align: center;
  text-wrap: balance;
  max-width: 100%;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}
.btn:hover { background: var(--btn-bg-hover); color: var(--btn-fg); text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn svg { width: 1.25em; height: 1.25em; flex: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

.btn--secondary { --btn-bg: var(--color-ink); --btn-fg: var(--color-on-ink); --btn-bg-hover: var(--color-ink-strong); }
.btn--outline   { --btn-bg: transparent; --btn-fg: var(--color-ink); --btn-bg-hover: var(--color-bg-muted); --btn-border: var(--color-ink); }
.btn--ghost     { --btn-bg: transparent; --btn-fg: var(--color-ink); --btn-bg-hover: var(--color-bg-muted); padding-inline: var(--space-4); }
.btn--on-dark   { --btn-bg: var(--white); --btn-fg: var(--navy-700); --btn-bg-hover: var(--yellow-100); }
.btn--sm { min-height: var(--button-height-sm); padding-inline: var(--space-4); }
.btn--lg { min-height: var(--button-height-lg); padding-inline: var(--space-8); font-size: var(--text-base); }
.btn--block { width: 100%; }

/* ---------- Tag / pill ---------- */
.tag {
  display: inline-flex;
  align-self: flex-start;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--tone-bg, var(--color-bg-muted));
  color: var(--tone-text, var(--color-text));
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.tag::before {
  content: "";
  width: 0.5rem; height: 0.5rem;
  border-radius: 50%;
  background: var(--tone-accent, var(--color-brand));
}

/* ---------- Announcement bar ---------- */
.announce {
  margin: 0;
  background: var(--color-bg-inverse);
  color: var(--color-text-inverse);
  font-size: var(--text-sm);
  text-align: center;
  padding: var(--space-3) var(--gutter);
}
.announce a { color: var(--yellow-300); font-weight: var(--weight-bold); }
.announce a:hover { color: var(--yellow-200); }

/* ---------- Header / navigation ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--color-bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--duration-base);
}
.site-header.is-scrolled { border-bottom-color: var(--color-border); }
.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-6);
  min-height: 4.5rem;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  text-decoration: none;
}
.logo:hover { color: var(--color-ink); text-decoration: none; }
.logo svg { width: 2.5rem; height: 2.5rem; }
.nav__links {
  display: flex;
  gap: var(--space-1);
  margin-left: auto;
  list-style: none;
  padding: 0;
}
.nav__links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-target);
  padding: 0 var(--space-4);
  border-radius: var(--radius-pill);
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
}
.nav__links a:hover { background: var(--color-bg-muted); }
.nav__actions { display: flex; align-items: center; gap: var(--space-2); }
.nav__toggle {
  display: none;
  flex: none;
  margin-left: auto;
  width: var(--button-height);
  height: var(--button-height);
  border: 2px solid var(--color-ink);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.nav__toggle span,
.nav__toggle span::before,
.nav__toggle span::after {
  display: block;
  width: 1.25rem; height: 2px;
  margin: auto;
  background: var(--color-ink);
  border-radius: 2px;
  position: relative;
  transition: transform var(--duration-base) var(--ease-out);
}
.nav__toggle span::before, .nav__toggle span::after { content: ""; position: absolute; left: 0; }
.nav__toggle span::before { top: -6px; }
.nav__toggle span::after { top: 6px; }
.nav__toggle[aria-expanded="true"] span { background: transparent; }
.nav__toggle[aria-expanded="true"] span::before { transform: translateY(6px) rotate(45deg); }
.nav__toggle[aria-expanded="true"] span::after { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 60rem) {
  .nav__toggle { display: block; }
  .nav__menu {
    display: none;
    position: absolute;
    inset: 100% 0 auto 0;
    padding: var(--space-4) var(--gutter) var(--space-8);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
  }
  .nav__menu.is-open { display: block; }
  .nav__links { flex-direction: column; margin: 0 0 var(--space-4); }
  .nav__links a { font-size: var(--text-lg); width: 100%; }
  .nav__actions .btn { width: 100%; }
}
@media (min-width: 60.01rem) {
  .nav__menu { display: contents; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding-block: clamp(2.5rem, 2rem + 4vw, 6rem) clamp(3rem, 2rem + 5vw, 7rem);
  overflow: hidden;
}
.hero__title { font-size: var(--text-4xl); font-weight: var(--weight-bold); }
.hero__lead { font-size: var(--text-xl); line-height: var(--leading-snug); color: var(--color-text-muted); max-width: 32ch; }
.hero__note { font-size: var(--text-sm); color: var(--color-text-muted); }
.hero__art { position: relative; }

/* ---------- Curved section edge (signature shape) ---------- */
.curve {
  display: block;
  width: 100%;
  height: clamp(2rem, 6vw, 5rem);
  color: var(--tone-bg);
}
.curve--top { margin-bottom: -1px; }
.curve--bottom { margin-top: -1px; transform: scaleY(-1); }

/* ---------- Card ---------- */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--card-pad, var(--space-8));
  border-radius: var(--radius-lg);
  background: var(--tone-bg, var(--color-bg-soft));
  color: var(--tone-text, var(--color-text));
}
.card--outline { background: var(--color-bg); border: 2px solid var(--color-border); }
.card--raised { background: var(--color-bg); box-shadow: var(--shadow-md); }
.card__title { font-size: var(--text-xl); font-weight: var(--weight-semibold); }
.card__art { margin-bottom: var(--space-2); }

/* Link card: whole card is the link target */
.card--link { transition: transform var(--duration-base) var(--ease-bounce); }
.card--link:hover { transform: translateY(-4px); }
.card--link a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.card--link a { color: inherit; text-decoration: none; }
.card--link:focus-within { outline: 3px solid var(--color-focus); outline-offset: 3px; }
.card--link a:focus-visible { outline: none; box-shadow: none; }

/* ---------- Tile (big colourful category card) ---------- */
.tile {
  min-height: 17rem;
  justify-content: flex-end;
  overflow: hidden;
  --card-pad: var(--space-6);
}
.tile .card__art {
  position: absolute;
  top: var(--space-5);
  right: var(--space-5);
  width: 6.5rem;
  transition: transform var(--duration-slow) var(--ease-bounce);
}
.tile:hover .card__art { transform: rotate(-6deg) scale(1.06); }
.tile__arrow {
  display: inline-grid;
  place-items: center;
  width: 2.5rem; height: 2.5rem;
  border-radius: 50%;
  background: var(--color-bg);
  color: var(--color-ink);
  margin-top: var(--space-2);
}

/* ---------- Steps (real sequence) ---------- */
.steps { counter-reset: step; }
.step { counter-increment: step; }
.step__num {
  display: grid;
  place-items: center;
  width: 3rem; height: 3rem;
  border-radius: 50%;
  background: var(--tone-accent, var(--color-brand));
  color: var(--navy-800);
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: var(--text-lg);
}

/* ---------- Feature (media + text) ---------- */
.feature__media {
  border-radius: var(--radius-xl);
  background: var(--tone-bg);
  aspect-ratio: 5 / 4;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: var(--space-8);
}
.feature__media svg { width: 100%; max-width: 26rem; height: auto; }
.feature__list { display: grid; gap: var(--space-3); padding: 0; list-style: none; }
.feature__list li { display: flex; gap: var(--space-3); align-items: flex-start; }
.feature__list li::before {
  content: "";
  flex: none;
  width: 1.5rem; height: 1.5rem;
  margin-top: 0.15em;
  border-radius: 50%;
  background: var(--color-brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23111842' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E") center / 70% no-repeat;
}

/* ---------- Stat ---------- */
.stat { display: flex; flex-direction: column; gap: var(--space-2); }
.stat__value {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  line-height: 1;
  color: var(--tone-accent, var(--color-brand));
}
.stat__label { font-size: var(--text-lg); line-height: var(--leading-snug); }

/* ---------- Quote / moment card (horizontal scroller) ---------- */
.scroller {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(17rem, 22rem);
  gap: var(--space-5);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: var(--space-2) var(--gutter) var(--space-6);
  margin-inline: calc(var(--gutter) * -1);
  scrollbar-width: thin;
}
.scroller > * { scroll-snap-align: start; }
.scroller__controls { display: flex; gap: var(--space-2); }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--button-height);
  height: var(--button-height);
  border-radius: 50%;
  border: 2px solid var(--color-ink);
  background: var(--color-bg);
  color: var(--color-ink);
  cursor: pointer;
}
.icon-btn:hover { background: var(--color-bg-muted); }
.icon-btn svg { width: 1.25rem; height: 1.25rem; }

.quote { justify-content: space-between; min-height: 15rem; }
.quote__text {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
}
.quote__meta { display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-sm); }
.quote__avatar {
  width: 2.75rem; height: 2.75rem; border-radius: 50%;
  background: var(--tone-accent);
  color: var(--navy-800);
  display: grid; place-items: center;
  flex: none;
}
.quote__avatar svg { width: 1.4rem; height: 1.4rem; }

/* ---------- Accordion (uses <details>) ---------- */
.accordion { border-top: 2px solid var(--color-border); }
.accordion details { border-bottom: 2px solid var(--color-border); }
.accordion summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: var(--tap-target);
  padding: var(--space-5) 0;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  list-style: none;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary::after {
  content: "";
  flex: none;
  width: 2.25rem; height: 2.25rem;
  border-radius: 50%;
  color: var(--color-ink);
  /* A plus sign drawn in currentColor, so it follows the theme */
  background:
    linear-gradient(currentColor, currentColor) center / 50% 3px no-repeat,
    linear-gradient(currentColor, currentColor) center / 3px 50% no-repeat,
    var(--color-bg);
  border: 2px solid var(--color-border-strong);
  transition: transform var(--duration-base) var(--ease-out);
}
.accordion details[open] summary::after { transform: rotate(45deg); color: var(--navy-800); background-color: var(--color-brand); border-color: var(--color-brand); }
.accordion summary:hover { text-decoration: underline; text-underline-offset: 0.2em; }
/* Smooth open and close where supported */
.accordion details::details-content {
  block-size: 0;
  overflow: clip;
  transition: block-size var(--duration-base) var(--ease-out), content-visibility var(--duration-base) allow-discrete;
}
.accordion details[open]::details-content { block-size: auto; }
.accordion__body { padding: 0 0 var(--space-6); color: var(--color-text-muted); }

/* ---------- Form fields ---------- */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.label { font-family: var(--font-display); font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.hint { font-size: var(--text-sm); color: var(--color-text-muted); }
.input {
  min-height: var(--button-height);
  padding: 0 var(--space-5);
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  background: var(--color-bg);
  color: var(--color-text);
}
.input:focus-visible { border-color: var(--color-focus); }
.input::placeholder { color: var(--color-text-muted); opacity: 1; }
.inline-form { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.inline-form .input { flex: 1 1 min(16rem, 100%); min-width: 0; }
.inline-form > * { min-width: 0; }
.form-status { font-weight: var(--weight-bold); min-height: 1.6em; }

/* ---------- Callout band ---------- */
.band {
  position: relative;
  border-radius: var(--radius-xl);
  padding: clamp(2rem, 1rem + 5vw, 5rem);
  background: var(--tone-bg);
  color: var(--tone-text);
  overflow: hidden;
}

/* ---------- Store badge (generic, not an official store mark) ---------- */
.store-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--button-height);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-md);
  background: var(--navy-900);
  color: var(--white);
  text-decoration: none;
  font-family: var(--font-display);
  line-height: 1.15;
  border: 1px solid rgb(255 255 255 / 0.35);
}
.store-badge small { display: block; font-size: 0.7rem; opacity: 0.8; }
.store-badge strong { font-size: var(--text-sm); }
.store-badge svg { width: 1.5rem; height: 1.5rem; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--tone-bg);
  color: var(--tone-text);
  padding-block: var(--space-16) var(--space-10);
}
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; color: var(--yellow-300); }
.footer__grid {
  display: grid;
  gap: var(--space-10);
  grid-template-columns: repeat(auto-fit, minmax(min(11rem, 100%), 1fr));
}
.footer__brand { grid-column: 1 / -1; }
@media (min-width: 56rem) {
  .footer__grid { grid-template-columns: 2fr repeat(3, 1fr); }
  .footer__brand { grid-column: auto; }
}
.footer__heading { font-size: var(--text-sm); font-family: var(--font-display); color: var(--yellow-300); margin-bottom: var(--space-4); }
.footer__links { display: grid; gap: var(--space-2); list-style: none; padding: 0; }
.footer__links { gap: 0; }
.footer__links a { display: inline-flex; align-items: center; min-height: var(--tap-target); text-decoration: underline; text-decoration-color: rgb(255 255 255 / 0.35); }
.site-footer a:hover { text-decoration-color: currentColor; }
.footer__legal {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-4);
  margin-top: var(--space-16);
  padding-top: var(--space-6);
  border-top: 1px solid rgb(255 255 255 / 0.2);
  font-size: var(--text-sm);
  opacity: 0.85;
}

/* ---------- Illustration helpers ---------- */
.buddy .pupil { transition: transform var(--duration-base) var(--ease-out); }
.float { animation: float 6s ease-in-out infinite; }
.float--slow { animation-duration: 9s; }
.float--delay { animation-delay: -3s; }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.wave { animation: wave 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: left center; }
.wave--2 { animation-delay: 0.3s; }
@keyframes wave {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(1.08); }
}
.blink { animation: blink 5s infinite; transform-box: fill-box; transform-origin: center; }
@keyframes blink {
  0%, 94%, 100% { transform: scaleY(1); }
  97% { transform: scaleY(0.1); }
}

/* ---------- Reading options panel ----------
   A popover opened from the header "Reading options" button.
   Every choice is a native radio or button, so it works with any
   screen reader, switch or keyboard. */
.reading-btn svg { width: 1.4em; height: 1.4em; }
.reading-panel {
  position: fixed;
  inset: 5rem var(--gutter) auto auto;
  width: min(25rem, calc(100vw - var(--gutter) * 2));
  max-height: calc(100dvh - 6rem);
  overflow: auto;
  margin: 0;
  padding: var(--space-6);
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
}
.reading-panel:not(:popover-open):not(.is-open) { display: none; }
.reading-panel::backdrop { background: rgb(11 16 44 / 0.25); }
.reading-panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.reading-panel h2 { font-size: var(--text-xl); }
.reading-panel fieldset { border: 0; padding: 0; margin: 0 0 var(--space-5); }
.reading-panel legend { font-family: var(--font-display); font-weight: var(--weight-semibold); margin-bottom: var(--space-2); padding: 0; }

/* Segmented choice built from real radio buttons */
.segmented { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.segmented label {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-target);
  min-width: var(--tap-target);
  padding: 0 var(--space-4);
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  cursor: pointer;
}
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented label:has(input:checked) { background: var(--color-ink); border-color: var(--color-ink); color: var(--color-on-ink); font-weight: var(--weight-semibold); }
.segmented label:has(input:checked)::before { content: "✓"; margin-right: var(--space-2); }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--color-focus); outline-offset: 3px; box-shadow: 0 0 0 7px var(--color-focus-halo); }
.segmented label:hover { border-color: var(--color-ink); }

.listen { border-top: 2px solid var(--color-border); padding-top: var(--space-5); }
.listen__status { font-size: var(--text-sm); color: var(--color-text-muted); min-height: 1.6em; }

/* ---------- Phone frame (real app screenshots) ---------- */
.phone {
  width: min(100%, 18rem);
  margin-inline: auto;
  padding: 0.6rem;
  border-radius: 2.4rem;
  background: var(--navy-900);
  box-shadow: var(--shadow-lg);
}
.phone img { border-radius: 1.9rem; width: 100%; height: auto; }
.screens { display: grid; gap: var(--space-10); grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr)); align-items: start; }
.screens figure { display: flex; flex-direction: column; gap: var(--space-4); }
.screens figcaption { text-align: center; max-width: 22rem; margin-inline: auto; }

/* ---------- Prose (long-form pages such as Privacy) ---------- */
.prose { display: flex; flex-direction: column; gap: var(--space-5); }
.prose h2 { font-size: var(--text-2xl); margin-top: var(--space-8); }
.prose h3 { font-size: var(--text-xl); margin-top: var(--space-4); }
.prose ul { padding-left: 1.25em; display: grid; gap: var(--space-2); }
.prose li { max-width: 65ch; }
.note {
  padding: var(--space-5) var(--space-6);
  border-radius: var(--radius-md);
  border-left: 0.4rem solid var(--tone-accent);
  background: var(--tone-bg);
  color: var(--tone-text);
}

/* ---------- Forced colours (Windows High Contrast) ---------- */
@media (forced-colors: active) {
  .btn, .tag, .card, .band, .icon-btn, .store-badge, .feature__media, .reading-panel { border: 2px solid CanvasText; }
  .btn:hover { border-color: Highlight; }
  .segmented label:has(input:checked) { border-color: Highlight; outline: 2px solid Highlight; }
  .accordion summary::after { content: "+"; display: grid; place-items: center; }
  .accordion details[open] summary::after { content: "\2212"; transform: none; }
  .feature__list li::before { background: CanvasText; forced-color-adjust: none; }
  .curve { display: none; }
}
.field .input { width: 100%; }
