/* Book-E-Kids public site. Tokens mirror docs/production/DESIGN-DIRECTION.md
   and apple/BookEKids/UI/Theme.swift: Meadow by day, Night after dark. */

:root {
  color-scheme: light dark;

  --bg: #FFF8EC;
  --raised: #FFFFFF;
  --soft: #F1F7E8;
  --ink: #17362B;
  --ink-2: #4F625A;
  --ink-3: #657068;
  --accent: #236B4E;
  --accent-press: #184A37;
  --on-accent: #FFFFFF;
  --border: #C7D2C9;
  --focus: #7544B8;

  /* Diorama: Meadow */
  --sky-top: #DDF1FF;
  --sky-bottom: #F6FBFF;
  --hills: #CFE8C3;
  --hills-near: #BEDDAF;
  --ground: #F1F7E8;
  --detail: #F6C445;
  --oak: #2F8F5B;
  --pine: #1F6B56;
  --willow: #6FA050;
  --trunk: #7A4B2A;
  --blossom: #F4A6C1;
  --fruit: #E85D4A;
  --shadow-alpha: 0.08;

  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 18px;
  --gutter: clamp(1rem, 4vw, 2rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101512;
    --raised: #1A231E;
    --soft: #1E2B23;
    --ink: #F4FFF8;
    --ink-2: #D1E3D8;
    --ink-3: #B4C4BB;
    --accent: #78D6A8;
    --accent-press: #A2E8C4;
    --on-accent: #102018;
    --border: #718078;
    --focus: #D5B3FF;

    /* Diorama: Night */
    --sky-top: #16213E;
    --sky-bottom: #0F1C33;
    --hills: #1E3A34;
    --hills-near: #18302B;
    --ground: #101512;
    --detail: #FFF3B0;
    --oak: #5FB47F;
    --pine: #4E9C88;
    --willow: #A2CB7E;
    --shadow-alpha: 0.25;
  }
}

/* Base */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1 0 auto; }

h1, h2, h3 {
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
  text-wrap: balance;
}

h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 2.75rem); }
h2 { font-size: clamp(1.4rem, 1.15rem + 1vw, 1.75rem); margin-top: 2.5rem; }
h3 { font-size: 1.2rem; margin-top: 1.75rem; }

p, ul, ol { margin: 0 0 1rem; }
ul, ol { padding-left: 1.4rem; }
li { margin-bottom: 0.4rem; }
li::marker { color: var(--accent); }
strong { font-weight: 700; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}
a:hover { color: var(--accent-press); }

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

.wrap {
  width: 100%;
  max-width: 44rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  background: var(--raised);
  color: var(--ink);
  padding: 0.6rem 1rem;
  border-radius: 999px;
  z-index: 10;
}
.skip:focus { top: 0.75rem; }

/* Header */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
}
.brand svg { width: 30px; height: 30px; flex: none; }

.top nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.top nav li { margin: 0; }
.top nav a {
  color: var(--ink-2);
  text-decoration: none;
  padding: 0.35rem 0;
}
.top nav a:hover, .top nav a[aria-current="page"] {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

/* Hero (the one centered element on the site) */

.hero {
  text-align: center;
  padding-bottom: 1.5rem;
}

.diorama {
  display: block;
  width: 100%;
  height: clamp(220px, 42vw, 480px);
}
.diorama .sky-top { stop-color: var(--sky-top); }
.diorama .sky-bottom { stop-color: var(--sky-bottom); }
.diorama .hill-far { fill: var(--hills); }
.diorama .hill-near { fill: var(--hills-near); }
.diorama .ground { fill: var(--ground); }
.diorama .d-sun, .diorama .d-leaves, .diorama .d-stars, .diorama .d-flakes { fill: var(--detail); }
.diorama .d-leaves, .diorama .d-stars, .diorama .d-flakes { display: none; }
/* Tree fills live on the SVG elements themselves (see index.html); only the species colour is set here. */
.diorama .sp-oak { color: var(--oak); }
.diorama .sp-pine { color: var(--pine); }
.diorama .sp-willow { color: var(--willow); }

/* Picking a look swaps only the scene, exactly like the app. */
.hero:has(#look-meadow:checked) .diorama {
  --sky-top: #DDF1FF; --sky-bottom: #F6FBFF; --hills: #CFE8C3; --hills-near: #BEDDAF;
  --ground: #F1F7E8; --detail: #F6C445; --oak: #2F8F5B; --pine: #1F6B56; --willow: #6FA050; --shadow-alpha: 0.08;
}
.hero:has(#look-autumn:checked) .diorama {
  --sky-top: #FFE9D6; --sky-bottom: #FFF6EC; --hills: #E8C9A0; --hills-near: #DDB98A;
  --ground: #F8EAD6; --detail: #E39A3B; --oak: #2F8F5B; --pine: #1F6B56; --willow: #6FA050; --shadow-alpha: 0.08;
}
.hero:has(#look-night:checked) .diorama {
  --sky-top: #16213E; --sky-bottom: #0F1C33; --hills: #1E3A34; --hills-near: #18302B;
  --ground: #101512; --detail: #FFF3B0; --oak: #5FB47F; --pine: #4E9C88; --willow: #A2CB7E; --shadow-alpha: 0.25;
}
.hero:has(#look-snow:checked) .diorama {
  --sky-top: #E6F0FA; --sky-bottom: #F7FAFD; --hills: #D9E6F2; --hills-near: #C8DAEA;
  --ground: #F4F8FC; --detail: #FFFFFF; --oak: #2F8F5B; --pine: #1F6B56; --willow: #6FA050; --shadow-alpha: 0.08;
}
.hero:has(#look-meadow:checked) .diorama .d-sun,
.hero:has(#look-autumn:checked) .diorama .d-leaves,
.hero:has(#look-night:checked) .diorama .d-stars,
.hero:has(#look-snow:checked) .diorama .d-flakes { display: block; }
.hero:has(#look-autumn:checked) .diorama .d-sun,
.hero:has(#look-night:checked) .diorama .d-sun,
.hero:has(#look-snow:checked) .diorama .d-sun { display: none; }
@media (prefers-color-scheme: dark) {
  .diorama .d-sun { display: none; }
  .diorama .d-stars { display: block; }
  .hero:has(#look-meadow:checked) .diorama .d-sun { display: block; }
  .hero:has(#look-meadow:checked) .diorama .d-stars,
  .hero:has(#look-autumn:checked) .diorama .d-stars,
  .hero:has(#look-snow:checked) .diorama .d-stars { display: none; }
}

.looks {
  border: 0;
  margin: 1.25rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}
.looks legend {
  float: left;
  width: 100%;
  color: var(--ink-2);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}
.look {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.9rem 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--raised);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.95rem;
  min-height: 44px;
  position: relative;
}
.look .swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  flex: none;
  background: linear-gradient(to bottom, var(--s1) 0 55%, var(--s2) 55%);
}
.look-meadow { --s1: #DDF1FF; --s2: #CFE8C3; }
.look-autumn { --s1: #FFE9D6; --s2: #E8C9A0; }
.look-night { --s1: #16213E; --s2: #1E3A34; }
.look-snow { --s1: #E6F0FA; --s2: #D9E6F2; }
.look:has(:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.look:has(:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.look input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }

.hero h1 { margin-top: 2rem; }
.hero .lead {
  max-width: 36rem;
  margin: 0 auto 1.5rem;
  color: var(--ink-2);
  font-size: 1.15rem;
  text-wrap: pretty;
}

.stores {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
}
.stores li { margin: 0; }
.badge {
  display: inline-block;
  border-radius: 12px;
  line-height: 0;
}
.badge svg { width: 176px; height: 56px; display: block; }
.badge .badge-bg { fill: var(--ink); }
.badge .badge-edge { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.badge text {
  font-family: var(--font);
  fill: var(--bg);
}
.badge .badge-small { font-size: 11px; }
.badge .badge-big { font-size: 18px; font-weight: 700; }
.badge .badge-glyph { fill: var(--bg); }
.badge:hover .badge-bg { fill: var(--accent-press); }
.stores-note {
  color: var(--ink-2);
  font-size: 0.95rem;
  margin-bottom: 0;
}

/* Home page pillars: an editorial two-column, not a card grid */

.pillars {
  padding-block: 1.5rem 3rem;
  text-align: left;
}
.pillar {
  padding-block: 2rem;
  border-top: 1px solid var(--border);
}
.pillar h2 { margin-top: 0; }
.pillar ul { margin-bottom: 0; }
.pillar p:last-child { margin-bottom: 0; }
.pillar .glyph {
  width: 40px;
  height: 40px;
  display: block;
  margin-bottom: 0.75rem;
}
.pillar .glyph .trunk { fill: var(--trunk); }
.pillar .glyph .canopy { fill: var(--oak); }
.pillar .glyph .canopy-shade { fill: #000; opacity: 0.18; }
.pillar .glyph .blossom { fill: var(--blossom); }
.pillar .glyph .blossom-dot { fill: #fff; opacity: 0.9; }
.pillar .glyph .fruit { fill: var(--fruit); }
.pillar .glyph .moon { fill: var(--ink-2); }

@media (min-width: 48rem) {
  .pillars .wrap { max-width: 56rem; }
  .pillar {
    display: grid;
    grid-template-columns: minmax(12rem, 16rem) 1fr;
    gap: 2rem 3rem;
    align-items: start;
  }
}

/* Document pages (privacy, support, terms) */

.doc { padding-block: 1.5rem 4rem; }
.doc h1 { margin-top: 1rem; }
.doc .meta {
  color: var(--ink-2);
  font-size: 0.95rem;
  margin-bottom: 1.75rem;
}
.doc h2 { color: var(--accent); }
.doc p, .doc li { text-wrap: pretty; }
.doc .aside {
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
}
.doc .aside p:last-child { margin-bottom: 0; }

/* 404 */

.lost { padding-block: 3rem 4rem; }
.lost .glyph { width: 96px; height: 96px; display: block; margin-bottom: 1rem; }
.lost .glyph .trunk { fill: var(--trunk); }
.lost .glyph .canopy { fill: var(--oak); }
.lost .glyph .shadow { fill: #000; opacity: var(--shadow-alpha); }

/* Footer */

.foot {
  border-top: 1px solid var(--border);
  padding-block: 1.5rem 2.5rem;
  color: var(--ink-2);
  font-size: 0.95rem;
}
.foot .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
}
.foot ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.foot li { margin: 0; }
.foot a { color: var(--ink-2); }
.foot a:hover { color: var(--ink); }
.foot p { margin: 0; }

/* Motion: only short press feedback, and only when allowed. */
@media (prefers-reduced-motion: no-preference) {
  .badge .badge-bg, .look, a { transition: fill 160ms ease, border-color 160ms ease, color 160ms ease; }
}
