/* ============================================================
   MILLER THE FARMER — site shell (css/site.css)
   The book come to life: pale cyan sky, puffy clouds, blue
   mountains, glossy lime hills, a red barn with white X doors,
   picket fences and cream narration boxes in hand-lettered caps.
   Everything sits on css/tokens.css (loaded first). The old
   variable names below are kept as aliases so every other
   stylesheet in the site keeps working unchanged.
   ============================================================ */

:root {
  /* ---- legacy aliases (other builders' CSS uses these) ---- */
  --barn: var(--barn-red);
  --sky: var(--sky-top);
  --sky-dark: var(--link);
  --grass: var(--tractor-green);
  --grass-dark: var(--tractor-green-dark);
  --bark: var(--text);
  --bark-soft: var(--text-2);
  --sun: var(--wheat);

  --surface-base: var(--meadow);
  --surface-primary: var(--surface);
  --surface-secondary: var(--cream);
  --text-primary: var(--text);
  --text-secondary: var(--text-2);
  --text-inverse: #ffffff;

  --space-1: var(--s1); --space-2: var(--s2); --space-3: var(--s3); --space-4: var(--s4);
  --space-5: var(--s5); --space-6: var(--s6); --space-8: var(--s8); --space-10: var(--s10);
  --space-12: var(--s12); --space-16: var(--s16);

  --radius-md: var(--r-md); --radius-lg: var(--r-lg); --radius-xl: var(--r-xl); --radius-pill: var(--r-pill);

  --shadow-lifted-card: var(--shadow-sticker), var(--shadow-1);
  --shadow-lifted: 0 3px 0 rgba(43, 26, 16, .22);
  --shadow-pop: var(--shadow-sticker-sm);

  --transition-fast: var(--t-fast) var(--ease-out);
  --transition-normal: var(--t-med) var(--ease-out);

  /* ---- shared art (SVG data URIs, no requests) ---- */
  --art-fence: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='64' viewBox='0 0 44 64'%3E%3Crect x='-2' y='26' width='48' height='9' fill='%23b5814f' stroke='%237d4a2a' stroke-width='2.4'/%3E%3Crect x='-2' y='46' width='48' height='9' fill='%23b5814f' stroke='%237d4a2a' stroke-width='2.4'/%3E%3Cpath d='M9 66V15L21 4l12 11v51z' fill='%23c98a4f' stroke='%237d4a2a' stroke-width='3' stroke-linejoin='round'/%3E%3Cpath d='M16 18v38M26 22v30' stroke='%23b5814f' stroke-width='2' stroke-linecap='round'/%3E%3Ccircle cx='21' cy='30.5' r='2' fill='%237d4a2a'/%3E%3Ccircle cx='21' cy='50.5' r='2' fill='%237d4a2a'/%3E%3C/svg%3E");
  --mask-hills-back: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 64' preserveAspectRatio='none'%3E%3Cpath d='M0 64V30C160 0 330 4 520 24s360 28 540-2 280-16 380-4v40z'/%3E%3C/svg%3E");
  --mask-hills-front: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 64' preserveAspectRatio='none'%3E%3Cpath d='M0 64V46c220-26 420-22 640-6s420 18 600-6 160-8 200-4v34z'/%3E%3C/svg%3E");
  --mask-clouds: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='44' viewBox='0 0 160 44'%3E%3Ccircle cx='30' cy='44' r='28'/%3E%3Ccircle cx='86' cy='38' r='34'/%3E%3Ccircle cx='140' cy='46' r='26'/%3E%3Crect y='40' width='160' height='4'/%3E%3C/svg%3E");
}

/* ============ base ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 8px); }
body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  color: var(--text);
  background: var(--meadow);
  -webkit-font-smoothing: antialiased;
  line-height: var(--lh-body);
  min-height: 100vh;
  overflow-x: clip; /* clip, not hidden: hidden would break the sticky header */
  padding-bottom: env(safe-area-inset-bottom);
}
img { max-width: 100%; display: block; }
h1, h2, h3, h4, .brand-name, .btn { font-family: var(--font-display); }
h1, h2, h3 { line-height: var(--lh-tight); }
a { color: var(--link); text-underline-offset: 2px; }
.hidden { display: none !important; }
.center { text-align: center; margin-left: auto; margin-right: auto; }
.muted { color: var(--text-2); }
.small { font-size: var(--fs-small); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* accessible focus everywhere: a thick blue ring with a white halo, readable on sky, grass and red */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, .85);
  border-radius: 10px;
}
.skip-link {
  position: absolute; left: 12px; top: -80px; z-index: 200;
  background: var(--surface); color: var(--text); font-family: var(--font-display); font-weight: 600;
  padding: 12px 18px; border-radius: var(--r-md); border: var(--border-cartoon); text-decoration: none;
}
.skip-link:focus { top: 12px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: var(--s6) var(--s5); }
.wrap-narrow { max-width: var(--wrap-narrow); margin: 0 auto; padding: var(--s6) var(--s5); }
.section-title {
  font-size: var(--fs-h2); font-weight: 700; letter-spacing: .2px; color: var(--text);
  text-shadow: 0 2px 0 rgba(255, 255, 255, .7);
}
.section-sub { color: var(--text-2); margin-top: var(--s2); margin-bottom: var(--s5); font-size: 1.05rem; }
.wrap > .section-title { margin-top: var(--s4); }
.kicker {
  font-family: var(--font-display); font-weight: 600; font-size: .82rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--barn-red-text); margin-bottom: 2px;
}

/* ---- the book's narration boxes: cream, rounded, hand-lettered capitals ---- */
.book-box {
  font-family: var(--font-book); text-transform: uppercase; letter-spacing: .035em;
  font-size: clamp(1.08rem, 1rem + .35vw, 1.3rem); line-height: 1.38; color: var(--text);
  background: var(--cream); border: 2px solid var(--cream-edge);
  border-radius: 18px; padding: 12px 20px;
  box-shadow: 0 4px 0 rgba(43, 26, 16, .10);
}
.book-caps { font-family: var(--font-book); text-transform: uppercase; letter-spacing: .05em; }
.book-who { white-space: nowrap; color: var(--barn-red-text); }

/* ============ buttons: chunky, outlined, press-down ============ */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap);
  border: 3px solid var(--outline); cursor: pointer; text-decoration: none;
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 600; font-size: 1.05rem; letter-spacing: .2px; line-height: 1.15;
  padding: 10px 22px; border-radius: var(--r-pill);
  box-shadow: 0 5px 0 var(--outline), inset 0 -4px 0 rgba(0, 0, 0, .14), inset 0 3px 0 rgba(255, 255, 255, .35);
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out), filter var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:hover { filter: brightness(1.05) saturate(1.05); transform: translateY(-2px); box-shadow: 0 7px 0 var(--outline), inset 0 -4px 0 rgba(0, 0, 0, .14), inset 0 3px 0 rgba(255, 255, 255, .35); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--outline), inset 0 -2px 0 rgba(0, 0, 0, .14), inset 0 3px 0 rgba(255, 255, 255, .3); }
.btn:disabled, .btn[aria-disabled="true"] { filter: grayscale(.6); opacity: .7; cursor: default; transform: none; }
.btn-lg { font-size: 1.22rem; padding: 13px 28px; min-height: 58px; }
.btn-sm { font-size: .95rem; padding: 7px 16px; box-shadow: 0 4px 0 var(--outline), inset 0 -3px 0 rgba(0, 0, 0, .12); }
.btn-sm:active { box-shadow: 0 1px 0 var(--outline); }
.btn-barn { --btn-bg: var(--barn-red); --btn-fg: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.btn-hay { --btn-bg: var(--tractor-yellow); --btn-fg: var(--text); }
.btn-grass { --btn-bg: var(--hill-grass); --btn-fg: var(--text); }
.btn-sky { --btn-bg: var(--sky-top); --btn-fg: var(--text); }
.btn-leaf { --btn-bg: var(--tractor-green-dark); --btn-fg: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.btn-ghost { --btn-bg: var(--paper); --btn-fg: var(--text); box-shadow: 0 4px 0 var(--outline); }
.btn-ghost:hover { box-shadow: 0 6px 0 var(--outline); }
.btn-ghost:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--outline); }
.btn-ico { width: 1.25em; height: 1.25em; flex: 0 0 auto; }
.btn-play {
  --btn-bg: var(--hill-grass); --btn-fg: var(--text);
  font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.1rem); font-weight: 700; letter-spacing: .04em;
  padding: 12px 40px 12px 30px; min-height: 72px; border-width: 4px;
  background: linear-gradient(180deg, #d4f27a 0%, var(--hill-lime) 45%, var(--hill-grass) 100%);
  box-shadow: 0 7px 0 var(--outline), inset 0 -6px 0 rgba(0, 0, 0, .12), inset 0 4px 0 rgba(255, 255, 255, .5);
}
.btn-play:hover { box-shadow: 0 9px 0 var(--outline), inset 0 -6px 0 rgba(0, 0, 0, .12), inset 0 4px 0 rgba(255, 255, 255, .5), var(--glow-gold); }
.btn-play:active { box-shadow: 0 1px 0 var(--outline), inset 0 -3px 0 rgba(0, 0, 0, .12); transform: translateY(6px); }
.btn-play .btn-ico { width: 1.1em; height: 1.1em; color: var(--barn-red); filter: drop-shadow(0 2px 0 var(--outline)); }

.chip {
  display: inline-block; font-family: var(--font-display); font-weight: 600; font-size: .9rem;
  padding: 5px 14px; border-radius: var(--r-pill); color: var(--text); border: 2px solid var(--outline);
}
.chip-hay { background: var(--tint-hay); } .chip-leaf { background: var(--tint-grass); }
.chip-barn { background: var(--tint-barn); } .chip-sky { background: var(--tint-sky); }

/* ============ cards: sticker-style, outlined ============ */
.card {
  background: var(--surface);
  border: var(--border-cartoon);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sticker);
  padding: var(--s6);
}
.card-title { font-size: clamp(1.3rem, 1.1rem + .8vw, 1.7rem); font-weight: 700; margin-bottom: var(--s2); }

/* ============ top bar: the book's sky ============ */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: var(--s4);
  min-height: var(--header-h);
  padding: 8px max(var(--s5), env(safe-area-inset-right)) 8px max(var(--s5), env(safe-area-inset-left));
  background: linear-gradient(180deg, var(--sky-top), var(--sky-mid));
  transition: box-shadow var(--t-med);
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 12px; pointer-events: none;
  background: var(--hill-grass);
  -webkit-mask: var(--mask-hills-front) bottom / 100% 100% no-repeat; mask: var(--mask-hills-front) bottom / 100% 100% no-repeat;
  transform: scaleY(-1); opacity: 0; transition: opacity var(--t-med);
}
body.scrolled .topbar { box-shadow: 0 3px 0 var(--outline-soft); }
body.scrolled .topbar::after { opacity: 0; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: 0 0 auto; border-radius: 12px; }
.brand-logo { height: 54px; width: auto; filter: drop-shadow(0 2px 0 rgba(43, 26, 16, .35)); transition: transform var(--t-fast) var(--ease-spring); }
.brand:hover .brand-logo { transform: rotate(-3deg) scale(1.04); }
.brand-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.topnav { display: flex; gap: 8px; margin-left: auto; flex-wrap: nowrap; }
.topnav a, .grownups-pill {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--tap); padding: 4px 14px 4px 6px;
  font-family: var(--font-display); font-weight: 600; font-size: 1rem; white-space: nowrap;
  text-decoration: none; color: var(--text);
  background: var(--paper); border: 3px solid var(--outline); border-radius: var(--r-pill);
  box-shadow: 0 4px 0 var(--outline);
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out), background var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.nav-ico { width: 34px; height: 34px; flex: 0 0 auto; transition: transform var(--t-med) var(--ease-spring); }
.topnav a:hover, .grownups-pill:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--outline); background: #fff; }
.topnav a:hover .nav-ico { transform: rotate(-8deg) scale(1.12); }
.topnav a:active, .grownups-pill:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--outline); }
.topnav a.active, .grownups-pill.active {
  background: var(--tractor-yellow);
  transform: translateY(3px); box-shadow: 0 1px 0 var(--outline), inset 0 3px 0 rgba(0, 0, 0, .12);
}
.grownups-pill { display: none; margin-left: auto; }
#installBtn { margin-left: var(--s2); flex: 0 0 auto; }
@media (max-width: 1240px) and (min-width: 1000px) {
  .topnav { gap: 5px; }
  .topnav a { font-size: .9rem; padding: 3px 10px 3px 4px; }
  .nav-ico { width: 28px; height: 28px; }
  .brand-logo { height: 46px; }
}

/* ============ phone/tablet tab bar ============ */
nav.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: none; justify-content: space-around; gap: 2px;
  overflow: visible;
  background: var(--paper);
  border-top: 3px solid var(--outline);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -6px 18px rgba(43, 26, 16, .12);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
nav.tabbar a {
  flex: 1 1 0; min-width: 0; min-height: 58px; overflow: visible;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  text-decoration: none; font-family: var(--font-display); font-size: 11.5px; font-weight: 600; letter-spacing: .1px;
  color: var(--text); padding: 4px 1px 2px; border-radius: 16px; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--t-fast);
}
nav.tabbar .tb-svg { width: 32px; height: 32px; transition: transform var(--t-med) var(--ease-spring); }
nav.tabbar .tb-label { display: block; max-width: 100%; overflow: hidden; text-overflow: clip; }
nav.tabbar a:active .tb-svg { transform: scale(.9); }
nav.tabbar a.active { background: var(--tractor-yellow); box-shadow: inset 0 0 0 2.5px var(--outline); }
nav.tabbar a.active .tb-svg { transform: translateY(-3px) scale(1.1); }
nav.tabbar .tb-ico { display: none; }

/* ============ page bands, hills and fences ============ */
.band { position: relative; }
.band-meadow { background: var(--meadow); --edge-back: var(--meadow-deep); --edge-front: var(--meadow); }
.band-sky { background: linear-gradient(180deg, var(--sky-low), var(--tint-sky)); --edge-back: var(--sky-low); --edge-front: var(--sky-low); }
.band-cream { background: var(--tint-hay); --edge-back: var(--tint-hay); --edge-front: var(--tint-hay); }
.hills-top { margin-top: 58px; }
.hills-top::before, .hills-top::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 100%; pointer-events: none;
}
.hills-top::before {
  height: 58px; background: var(--edge-back);
  -webkit-mask: var(--mask-hills-back) bottom / 100% 100% no-repeat; mask: var(--mask-hills-back) bottom / 100% 100% no-repeat;
}
.hills-top::after {
  height: 40px; background: var(--edge-front);
  -webkit-mask: var(--mask-hills-front) bottom / 100% 100% no-repeat; mask: var(--mask-hills-front) bottom / 100% 100% no-repeat;
}
.band-sky.hills-top::before { display: none; }
.band-sky.hills-top::after {
  height: 40px; background: var(--sky-low);
  -webkit-mask: var(--mask-clouds) left bottom / 160px 40px repeat-x; mask: var(--mask-clouds) left bottom / 160px 40px repeat-x;
}
.band-head { padding-bottom: 0; }
.band-head .section-sub { margin-bottom: var(--s2); }
.fence-strip {
  height: 64px; position: relative; z-index: 1;
  background:
    var(--art-fence) left bottom 6px / 44px 64px repeat-x,
    linear-gradient(180deg, transparent calc(100% - 12px), var(--hill-grass) calc(100% - 12px), var(--hill-grass) calc(100% - 4px), var(--hill-deep) calc(100% - 4px));
  height: 70px;
  margin-bottom: 0;
  pointer-events: none;
}
.site-foot {
  margin-top: var(--s8);
  height: 110px;
  background: linear-gradient(180deg, transparent 0 46px, var(--hill-deep) 46px);
  position: relative;
}
.site-foot .fence-strip { position: absolute; left: 0; right: 0; top: 0; margin: 0; }
.site-foot::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 58px;
  background: var(--hill-grass);
  -webkit-mask: var(--mask-hills-back) bottom / 100% 100% no-repeat; mask: var(--mask-hills-back) bottom / 100% 100% no-repeat;
}
.cta-row { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s4); justify-content: center; margin-top: var(--s5); }

/* ============ home hero: opening the book ============ */
.hero-book {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--sky-low);
  min-height: clamp(540px, calc(100vh - var(--header-h)), 680px);
  display: flex; flex-direction: column;
}
.hb-scene { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.hb-inner {
  flex: 1 1 auto; width: 100%; max-width: var(--wrap); margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); align-items: end; gap: var(--s4);
  padding: var(--s6) var(--s5) 0;
}
.hb-copy { align-self: center; padding-bottom: 90px; display: flex; flex-direction: column; align-items: flex-start; gap: var(--s3); }
.hb-title { margin: 0; line-height: 0; }
.hb-logo {
  width: clamp(250px, 30vw, 430px); height: auto;
  filter: drop-shadow(0 4px 0 rgba(43, 26, 16, .35)) drop-shadow(0 12px 18px rgba(43, 26, 16, .18));
  transform-origin: 50% 80%;
}
.hb-sub { font-size: 1.15rem; color: var(--text); display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.hb-sub .book-caps { font-size: 1.45rem; background: rgba(255, 255, 255, .7); padding: 0 12px; border-radius: 10px; }
.hb-by { font-family: var(--font-display); font-weight: 600; color: var(--text-2); background: rgba(255, 255, 255, .6); padding: 0 10px; border-radius: 10px; }
.hb-story { max-width: 520px; background: rgba(248, 242, 214, .95); }
.hb-ctas { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s4); margin-top: var(--s2); }
.hb-cast { position: relative; height: 100%; min-height: 380px; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 30px; }
.hb-miller { height: clamp(330px, 52vh, 470px); width: auto; position: relative; z-index: 2; filter: drop-shadow(0 10px 8px rgba(43, 26, 16, .25)); transform-origin: 50% 100%; }
.hb-ven { height: clamp(190px, 30vh, 280px); width: auto; margin-left: -46px; position: relative; z-index: 1; filter: drop-shadow(0 8px 6px rgba(43, 26, 16, .22)); transform-origin: 40% 100%; }
.hero-book > .fence-strip { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; z-index: 3; }

@media (prefers-reduced-motion: no-preference) {
  .hb-cloud { animation: cloud-drift 38s ease-in-out infinite alternate; }
  .hb-c2 { animation-duration: 46s; animation-delay: -12s; }
  .hb-c3 { animation-duration: 54s; animation-delay: -30s; }
  .hb-c4 { animation-duration: 30s; }
  @keyframes cloud-drift { from { transform: translateX(-30px); } to { transform: translateX(40px); } }
  .hb-blades { transform-box: fill-box; transform-origin: center; animation: blades 9s linear infinite; }
  @keyframes blades { to { transform: rotate(360deg); } }
  .hb-logo { animation: logo-in .9s var(--ease-spring) both, logo-bob 5s ease-in-out 1s infinite; }
  @keyframes logo-in { from { opacity: 0; transform: scale(.6) rotate(-6deg); } to { opacity: 1; transform: none; } }
  @keyframes logo-bob { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-5px) rotate(-1deg); } }
  .hb-miller { animation: pop-up .8s var(--ease-spring) .15s both, sway 6s ease-in-out 1.2s infinite; }
  .hb-ven { animation: pop-up .8s var(--ease-spring) .3s both, wag 3.2s ease-in-out 1.4s infinite; }
  @keyframes pop-up { from { opacity: 0; transform: translateY(60px) scale(.9); } to { opacity: 1; transform: none; } }
  @keyframes sway { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(1.4deg); } }
  @keyframes wag { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-2deg) translateY(-2px); } }
  .btn-play { animation: play-pulse 2.4s ease-in-out 1.5s infinite; }
  @keyframes play-pulse { 0%, 100% { scale: 1; } 50% { scale: 1.045; } }
  .btn-play:hover, .btn-play:active { animation: none; }
}

/* ============ page heroes (every tab but Home): a slice of the book's sky ============ */
.page-hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(60px 26px at 12% 30%, #fff 98%, transparent 100%),
    radial-gradient(42px 22px at 16% 22%, #fff 98%, transparent 100%),
    radial-gradient(70px 28px at 70% 22%, #fff 98%, transparent 100%),
    radial-gradient(46px 22px at 75% 14%, #fff 98%, transparent 100%),
    linear-gradient(180deg, var(--sky-top), var(--sky-mid) 55%, var(--sky-low));
  padding-bottom: 54px;
}
.page-hero::before, .page-hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; pointer-events: none; }
.page-hero::before {
  height: 74px; background: var(--hill-grass);
  -webkit-mask: var(--mask-hills-back) bottom / 100% 100% no-repeat; mask: var(--mask-hills-back) bottom / 100% 100% no-repeat;
}
.page-hero::after {
  height: 46px; background: var(--meadow);
  -webkit-mask: var(--mask-hills-front) bottom / 100% 100% no-repeat; mask: var(--mask-hills-front) bottom / 100% 100% no-repeat;
}
.ph-inner {
  position: relative; z-index: 1; max-width: var(--wrap); margin: 0 auto;
  display: flex; align-items: flex-end; gap: var(--s5); padding: var(--s6) var(--s5) 0;
}
.ph-text { flex: 1 1 auto; min-width: 0; padding-bottom: var(--s5); }
.ph-text .section-title { font-size: var(--fs-h1); }
.ph-text .section-sub { max-width: 640px; color: var(--text); margin-bottom: 0; background: rgba(255, 255, 255, .55); display: inline-block; padding: 4px 12px; border-radius: 12px; }
.ph-art { flex: 0 0 auto; width: clamp(110px, 14vw, 170px); height: auto; margin-bottom: -26px; filter: drop-shadow(0 6px 4px rgba(43, 26, 16, .22)); }
@media (prefers-reduced-motion: no-preference) {
  .tab-panel.active .ph-art { animation: pop-up .7s var(--ease-spring) .05s both; }
}

/* ============ home: section bits ============ */
.section-quote { max-width: 760px; margin: var(--s2) 0 var(--s5); }
.grownups-note { margin-top: var(--s6); }
.grownups-note a { display: inline-block; padding: 12px 2px; }

/* ============ audiobook player + trailer ============ */
.listen-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s6); align-items: stretch; padding-top: var(--s10); padding-bottom: var(--s8); }
.audiobook-card, .trailer-card { background: var(--paper); }
.audiobook-head { display: flex; gap: var(--s5); align-items: center; margin-bottom: var(--s5); }
.disc {
  position: relative; flex: 0 0 auto; width: 104px; height: 104px; border-radius: 50%;
  background: repeating-radial-gradient(circle at 50% 50%, #3a2416 0 2px, #4a2f1d 2px 5px);
  border: 3px solid var(--outline); display: grid; place-items: center;
  box-shadow: 0 5px 0 var(--outline);
}
.disc-art { position: absolute; width: 50%; height: 50%; border-radius: 50%; object-fit: cover; border: 3px solid var(--tractor-yellow); }
.disc.spinning { animation: spin 3.2s linear infinite; }
.disc-hole { position: relative; width: 14px; height: 14px; border-radius: 50%; background: var(--cream); border: 2px solid var(--outline); }
@keyframes spin { to { transform: rotate(360deg); } }
.ab-player { display: flex; align-items: center; gap: var(--s3) var(--s4); flex-wrap: wrap; }
.play-btn { min-width: 176px; }
.play-btn .icon-play, .play-btn .icon-pause { width: 24px; height: 24px; fill: currentColor; }
.ab-track { flex: 1 1 220px; }
.ab-times { display: flex; justify-content: space-between; font-size: .85rem; color: var(--text-2); font-weight: 800; }
/* chunky range sliders (audiobook, read-along size) */
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; width: 100%; height: 32px; cursor: pointer; accent-color: var(--barn-red); }
input[type=range]::-webkit-slider-runnable-track { height: 14px; border-radius: 99px; background: linear-gradient(180deg, var(--cream-edge), var(--cream)); border: 2.5px solid var(--outline); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -9.5px; border-radius: 50%; background: var(--barn-red); border: 3px solid var(--outline); box-shadow: 0 3px 0 var(--outline); }
input[type=range]::-moz-range-track { height: 9px; border-radius: 99px; background: var(--cream); border: 2.5px solid var(--outline); }
input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--barn-red); border: 3px solid var(--outline); }
.trailer-card { text-align: left; display: flex; flex-direction: column; }
.tv-frame {
  margin-top: var(--s3); padding: 10px; border-radius: 20px;
  background: var(--barn-red); border: 3px solid var(--outline);
  box-shadow: inset 0 0 0 4px #fff, 0 5px 0 var(--outline);
}
.tv-frame video {
  display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; background: var(--text);
  border: 3px solid var(--outline);
}

/* ============ learning pillars ============ */
.grid { display: grid; gap: var(--s5); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }
.pillar { text-align: left; display: flex; flex-direction: column; background: var(--paper); }
.pillar h3 { font-size: 1.4rem; margin-bottom: 4px; }
.pillar p { flex: 1 1 auto; }
.pillar .btn { margin-top: var(--s4); align-self: flex-start; }
.pillar-icon {
  display: grid; place-items: center; height: 130px; margin: -8px -8px var(--s4);
  border-radius: 16px; border: 2.5px solid var(--outline); overflow: hidden;
  background: linear-gradient(180deg, var(--sky-top), var(--sky-low) 62%, var(--hill-lime) 62%, var(--hill-grass));
}
.pillar-icon svg { width: 140px; height: 112px; filter: drop-shadow(0 4px 0 rgba(43, 26, 16, .2)); }
.pi-sci { background: linear-gradient(180deg, var(--tint-hay), var(--sky-low) 62%, var(--hill-lime) 62%, var(--hill-grass)); }
.pi-farm { background: linear-gradient(180deg, var(--sky-top), var(--sky-low) 62%, var(--wheat) 62%, var(--hay)); }

/* ============ crew ============ */
.grid-crew { grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.char-art {
  position: relative; display: grid; place-items: end center; overflow: hidden;
  background:
    radial-gradient(120% 60% at 50% 118%, var(--hill-grass) 0 60%, transparent 61%),
    radial-gradient(90% 50% at 10% 112%, var(--hill-lime) 0 60%, transparent 61%),
    linear-gradient(180deg, var(--sky-top), var(--sky-low));
}
.char-art img { width: 86%; height: 86%; object-fit: contain; object-position: center bottom; transition: transform var(--t-med) var(--ease-spring); }
.crew-card { text-align: center; position: relative; overflow: hidden; padding: 0 0 var(--s5); display: flex; flex-direction: column; align-items: center; background: var(--paper); }
.crew-card .char-art { width: 100%; aspect-ratio: 5 / 4; border-bottom: 3px solid var(--outline); }
.crew-card:hover .char-art img { transform: translateY(-4px) rotate(-2deg) scale(1.04); }
.crew-card h3 { margin-top: var(--s3); font-size: 1.5rem; padding: 0 var(--s4); }
.crew-role {
  display: inline-block; margin: 6px var(--s3) 0; font-family: var(--font-display); font-size: .92rem; font-weight: 600;
  color: var(--text); background: var(--tint-hay); border: 2px solid var(--outline);
  padding: 3px 12px; border-radius: var(--r-pill);
}
.crew-quote { margin: var(--s3) var(--s4) 0; font-size: 1.02rem; padding: 8px 14px; align-self: stretch; }
.crew-fact { margin: var(--s3) var(--s4) 0; color: var(--text-2); font-size: .98rem; flex: 1 1 auto; }
.hear-btn { margin-top: var(--s4); }
.hear-btn.playing { animation: pulse 1s ease infinite; background: var(--tractor-yellow); }
@keyframes pulse { 50% { transform: scale(1.06); } }

/* home crew strip: character cards that scroll sideways */
.crew-strip {
  display: grid; grid-auto-flow: column; grid-auto-columns: 176px; gap: var(--s4);
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory;
  padding: 6px 4px 18px; margin: 0 -4px;
  scrollbar-width: thin; scrollbar-color: var(--wood) transparent;
}
.crew-mini {
  scroll-snap-align: start;
  display: flex; flex-direction: column; align-items: stretch; text-align: center;
  background: var(--paper); border: 3px solid var(--outline); border-radius: 20px; overflow: hidden;
  box-shadow: 0 5px 0 var(--outline); cursor: pointer; padding: 0 0 12px;
  font-family: var(--font-body); color: var(--text);
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.crew-mini .char-art { aspect-ratio: 1; border-bottom: 3px solid var(--outline); }
.crew-mini:hover { transform: translateY(-4px) rotate(-1deg); box-shadow: 0 9px 0 var(--outline); }
.crew-mini:hover .char-art img { transform: scale(1.08) rotate(-3deg); }
.crew-mini:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--outline); }
.crew-mini-name { display: block; font-family: var(--font-display); font-weight: 700; font-size: 1.12rem; margin-top: 8px; }
.crew-mini-job { display: block; font-family: var(--font-book); text-transform: uppercase; font-size: .9rem; line-height: 1.25; letter-spacing: .03em; color: var(--text-2); padding: 2px 10px 0; }

/* ============ book promo ============ */
.book-promo { display: flex; gap: var(--s8); align-items: center; flex-wrap: wrap; background: var(--paper); }
.book-cover {
  width: 250px; border-radius: 6px 14px 14px 6px; border: 3px solid var(--outline);
  box-shadow: -8px 0 0 -2px var(--barn-dark), 0 8px 0 var(--outline), 0 18px 30px rgba(43, 26, 16, .25);
  transform: rotate(-3deg); transition: transform var(--t-med) var(--ease-spring);
}
.book-promo:hover .book-cover { transform: rotate(0) scale(1.03); }
.book-promo > div { flex: 1 1 300px; }
.book-promo p + p { margin-top: var(--s2); }
.book-promo .btn { margin-top: var(--s5); }

/* ============ reader ============ */
.reader { padding: var(--s5); background: var(--paper); }
.reader-stage { display: flex; align-items: center; gap: var(--s2); }
.reader-img { flex: 1 1 auto; min-width: 0; width: 100%; max-height: 62vh; object-fit: contain; border-radius: 14px; background: var(--cream); border: 3px solid var(--outline); }
.page-arrow {
  flex: 0 0 auto; width: 58px; height: 58px; border-radius: 50%; cursor: pointer;
  background: var(--tractor-yellow); border: 3px solid var(--outline); box-shadow: 0 4px 0 var(--outline);
  display: grid; place-items: center; transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.page-arrow:hover { transform: translateY(-2px) scale(1.06); box-shadow: 0 6px 0 var(--outline); }
.page-arrow:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--outline); }
.page-arrow svg { width: 30px; height: 30px; fill: none; stroke: var(--text); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.reader-text-zone { min-height: 96px; margin-top: var(--s4); }
/* the narration: the book's cream box, hand-lettered capitals */
.reader-text {
  font-family: var(--font-book); text-transform: uppercase; letter-spacing: .03em;
  font-size: 22px; line-height: 1.7; text-align: center; font-weight: 400;
  background: var(--cream); border: 2px solid var(--cream-edge); border-radius: 18px;
  padding: 12px 18px; box-shadow: 0 4px 0 rgba(43, 26, 16, .1);
}
.reader-text:empty { background: linear-gradient(90deg, var(--cream) 0%, #fffbe8 50%, var(--cream) 100%) 0 0 / 200% 100%; min-height: 76px; animation: shimmer 1.4s linear infinite; }
.reader-text .seg { margin: 0 0 6px; display: block; }
.reader-text .w { padding: 1px 4px; border-radius: 6px; transition: background var(--t-fast), color var(--t-fast); }
.reader-text .w.on { background: var(--tractor-yellow); color: var(--text); }
.reader-text .speaker-chip {
  display: inline-flex; align-items: center; gap: 6px; margin-right: 8px; vertical-align: middle;
  font-family: var(--font-display); text-transform: none; letter-spacing: 0;
  font-size: 14px; font-weight: 600; color: var(--text); background: var(--paper);
  border: 2px solid var(--outline); border-radius: var(--r-pill); padding: 1px 10px 1px 2px;
}
.reader-text .speaker-chip img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; vertical-align: middle; border: 2px solid var(--tractor-yellow); background: var(--sky-low); }
.reader-controls { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; justify-content: center; margin-top: var(--s4); }
.toggle { display: inline-flex; gap: 10px; align-items: center; font-weight: 800; color: var(--text); cursor: pointer; min-height: var(--tap); }
.toggle input { accent-color: var(--tractor-green); width: 24px; height: 24px; }
.page-num { font-family: var(--font-display); font-weight: 600; color: var(--text); background: var(--cream); border: 2px solid var(--outline); padding: 4px 12px; border-radius: var(--r-pill); }
.filmstrip { display: flex; gap: 8px; overflow-x: auto; margin-top: var(--s4); padding: 6px 2px var(--s2); scrollbar-width: thin; }
.filmstrip img {
  flex: 0 0 auto; width: 64px; border-radius: 8px; cursor: pointer;
  opacity: .6; border: 3px solid transparent; transition: opacity var(--t-fast), border-color var(--t-fast);
}
.filmstrip img:hover { opacity: 1; }
.filmstrip img.cur { opacity: 1; border-color: var(--barn-red); }

/* ============ games ============ */
.picker-title { font-size: 1.5rem; margin: var(--s2) 0 var(--s3); }
#games.gx-playing .picker-title, .picker-title:has(+ #gamePicker.hidden) { display: none; }
#games > .wrap > h2.w3d-title {
  font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; color: var(--text); text-align: left;
  text-shadow: none; letter-spacing: .2px; margin: var(--s10) 0 0;
}
#games > .wrap > .w3d-title + .section-sub { text-align: left; margin: 2px 0 var(--s3); }
.game-picker .game-card {
  cursor: pointer; text-align: center; font-family: var(--font-body); color: var(--text);
  padding: 0 var(--s3) var(--s4); overflow: hidden; background: var(--paper);
  display: flex; flex-direction: column; align-items: center;
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.game-picker .game-card:hover { transform: translateY(-5px) rotate(-.6deg); box-shadow: 0 11px 0 var(--outline); }
.game-picker .game-card:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--outline); }
.game-picker .game-card h3 { font-size: 1.3rem; margin-top: var(--s3); }
.game-picker .game-card p { font-size: .95rem; }
.gc-art {
  display: grid; place-items: center; align-self: stretch;
  margin: 0 calc(-1 * var(--s3)); height: 132px;
  border-bottom: 3px solid var(--outline);
  background:
    radial-gradient(130% 48% at 30% 112%, var(--hill-grass) 0 62%, transparent 63%),
    radial-gradient(120% 50% at 90% 116%, var(--hill-lime) 0 62%, transparent 63%),
    radial-gradient(34px 14px at 18% 26%, #fff 96%, transparent 100%),
    radial-gradient(26px 11px at 82% 18%, #fff 96%, transparent 100%),
    linear-gradient(180deg, var(--sky-top), var(--sky-low));
}
.gc-art svg { width: 128px; height: 102px; filter: drop-shadow(0 5px 0 rgba(43, 26, 16, .18)); transition: transform var(--t-med) var(--ease-spring); }
.gc-art img { width: 108px; height: 108px; object-fit: contain; border-radius: 50%; background: var(--cream); border: 3px solid var(--outline); transition: transform var(--t-med) var(--ease-spring); }
.game-card:hover .gc-art svg, .game-card:hover .gc-art img { transform: translateY(-6px) rotate(-4deg) scale(1.06); }
.gc-season, .gc-savehay { background:
    radial-gradient(130% 48% at 30% 112%, var(--hill-grass) 0 62%, transparent 63%),
    radial-gradient(120% 50% at 90% 116%, var(--hill-lime) 0 62%, transparent 63%),
    linear-gradient(180deg, var(--tint-hay), var(--sky-low)); }
.gc-challenge, .gc-universe { background:
    radial-gradient(130% 48% at 30% 112%, var(--hay) 0 62%, transparent 63%),
    radial-gradient(120% 50% at 90% 116%, var(--wheat) 0 62%, transparent 63%),
    linear-gradient(180deg, var(--sky-top), var(--sky-low)); }
#games .world3d-card::after {
  top: 10px; right: 10px; font-size: 13px; padding: 2px 10px;
  background: var(--barn-red); color: #fff; border: 2.5px solid var(--outline); box-shadow: 0 3px 0 var(--outline);
}
.stars { margin-top: 8px; font-size: 24px; letter-spacing: 2px; line-height: 1; color: var(--tractor-yellow); }
.stars span { -webkit-text-stroke: 1.6px var(--outline); paint-order: stroke fill; }
.stars .off { color: var(--paper); opacity: .55; }
.game-stage {
  margin-top: var(--s6); background: var(--paper);
  border: var(--border-cartoon); border-radius: var(--r-xl); box-shadow: var(--shadow-sticker);
  padding: var(--s5);
  animation: panel-in var(--t-slow) var(--ease-out);
}
.game-head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); }
.game-head h3 { font-size: 1.7rem; margin-right: auto; }
.score-chip { font-family: var(--font-display); font-weight: 600; background: var(--tractor-yellow); border: 2.5px solid var(--outline); padding: 6px 14px; border-radius: var(--r-pill); }
.game-q { font-size: 1.4rem; font-weight: 800; text-align: center; margin-bottom: var(--s4); }
.field-box {
  min-height: 160px; border: 3px solid var(--outline); border-radius: var(--r-lg);
  background:
    radial-gradient(130% 40% at 40% 112%, var(--hill-grass) 0 62%, transparent 63%),
    linear-gradient(180deg, var(--sky-top) 0, var(--sky-low) 52%, var(--hill-lime) 52%, var(--hill-grass) 100%);
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; padding: var(--s5);
}
.hay-item { width: 58px; height: 52px; border-radius: 50%; background: radial-gradient(circle at 50% 50%, var(--hay-dark) 0 10%, var(--hay) 11% 30%, var(--hay-dark) 31% 36%, var(--wheat) 37% 100%); border: 2.5px solid var(--outline); box-shadow: 0 3px 0 rgba(43, 26, 16, .35); }
.hay-item.pop { animation: pop .3s ease; }
@keyframes pop { 0% { transform: scale(0); } 80% { transform: scale(1.2); } 100% { transform: scale(1); } }
.answers { display: flex; gap: var(--s3); justify-content: center; flex-wrap: wrap; margin-top: var(--s5); }
.answers.vertical { flex-direction: column; align-items: stretch; max-width: 600px; margin-left: auto; margin-right: auto; }
.answer-btn {
  font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; color: var(--text);
  background: var(--surface); border: 3px solid var(--outline);
  border-radius: var(--r-lg); padding: 12px 24px; cursor: pointer; min-height: 56px;
  box-shadow: 0 5px 0 var(--outline);
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast), background var(--t-fast);
  text-align: left; -webkit-tap-highlight-color: transparent;
}
.answers:not(.vertical) .answer-btn { font-size: 1.7rem; text-align: center; min-width: 76px; }
.answer-btn:hover { transform: translateY(-3px); box-shadow: 0 8px 0 var(--outline); background: var(--tint-hay); }
.answer-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--outline); }
.answer-btn.right { background: var(--tint-grass); border-color: var(--tractor-green-dark); }
.answer-btn.wrong { background: var(--tint-barn); border-color: var(--barn-red); }
.game-feedback { min-height: 34px; text-align: center; font-weight: 800; font-size: 1.2rem; margin-top: var(--s4); color: var(--green-text); }
.game-feedback.err { color: var(--barn-red-text); }
.progress-dots { display: flex; gap: 8px; justify-content: center; margin-top: var(--s4); flex-wrap: wrap; }
.progress-dots span { width: 16px; height: 16px; border-radius: 50%; background: var(--paper); border: 2px solid var(--outline); }
.progress-dots span.done { background: var(--hill-grass); }
.progress-dots span.now { background: var(--tractor-yellow); transform: scale(1.2); }
.lvl-switch { display: flex; gap: 8px; flex-wrap: wrap; }
.lvl {
  border: 2.5px solid var(--outline); background: var(--paper); color: var(--text);
  font-family: var(--font-display); font-weight: 600; font-size: .95rem; min-height: 44px;
  padding: 7px 14px; border-radius: var(--r-pill); cursor: pointer; box-shadow: 0 3px 0 var(--outline);
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.lvl:hover { background: var(--tint-hay); }
.lvl:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--outline); }
.lvl.active { background: var(--barn-red); color: #fff; transform: translateY(2px); box-shadow: 0 1px 0 var(--outline); }

/* season sort */
.season-item { text-align: center; font-size: 1.4rem; font-weight: 800; max-width: 500px; margin: 0 auto; background: var(--cream); }
.season-item small { display: block; font-weight: 600; color: var(--text-2); font-size: 1rem; margin-top: 4px; }
.seasons { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s3); max-width: 780px; margin: var(--s5) auto 0; }
.season {
  cursor: pointer; border-radius: var(--r-lg); padding: var(--s4); min-height: 84px;
  border: 3px solid var(--outline); box-shadow: 0 5px 0 var(--outline);
  transition: transform var(--t-fast), box-shadow var(--t-fast); font-family: var(--font-body); color: var(--text);
}
.season:hover { transform: translateY(-3px); box-shadow: 0 8px 0 var(--outline); }
.season:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--outline); }
.season span { display: block; font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; }
.season small { color: var(--text); font-weight: 700; font-family: var(--font-book); text-transform: uppercase; font-size: .95rem; }
.s-spring { background: var(--tint-grass); } .s-summer { background: var(--tint-hay); }
.s-fall { background: var(--tint-orange); } .s-winter { background: var(--tint-sky); }

/* machine match */
.mm-machine { display: grid; place-items: center; }
.mm-machine img { max-height: 210px; object-fit: contain; }
.qz-q { font-size: 1.4rem; font-weight: 800; text-align: center; margin-bottom: var(--s4); }

/* game done */
#gameDone { margin-top: var(--s6); padding: var(--s8) var(--s6); background: var(--cream); animation: panel-in var(--t-slow) var(--ease-spring); }
#gameDone h3 { font-size: 2rem; }
.big-stars { font-size: 52px; letter-spacing: 8px; color: var(--tractor-yellow); margin: var(--s3) 0; }
.big-stars span { -webkit-text-stroke: 2px var(--outline); paint-order: stroke fill; }
.big-stars .off { color: var(--paper); opacity: .5; }
.hero-ctas { display: flex; gap: var(--s3); justify-content: center; flex-wrap: wrap; }
.hero-ctas.center { justify-content: center; }

/* ============ machines ============ */
.machine-card { text-align: center; padding: 0 0 var(--s5); overflow: hidden; background: var(--paper); display: flex; flex-direction: column; align-items: center; }
.machine-art {
  align-self: stretch; height: 170px; display: grid; place-items: center; border-bottom: 3px solid var(--outline);
  background:
    radial-gradient(140% 50% at 40% 120%, var(--hill-grass) 0 62%, transparent 63%),
    radial-gradient(120% 46% at 95% 118%, var(--hill-lime) 0 62%, transparent 63%),
    linear-gradient(180deg, var(--sky-top), var(--sky-low));
}
.machine-art img, .machine-art svg { height: 150px; width: auto; max-width: 86%; object-fit: contain; filter: drop-shadow(0 6px 0 rgba(43, 26, 16, .16)); transition: transform var(--t-med) var(--ease-spring); }
.machine-art svg { width: 180px; }
.machine-card:hover .machine-art img, .machine-card:hover .machine-art svg { transform: translateX(6px) rotate(-2deg); }
.machine-card h3 { font-size: 1.45rem; margin-top: var(--s3); padding: 0 var(--s4); }
.machine-gloss { margin: var(--s3) var(--s4) 0; align-self: stretch; text-align: left; font-size: 1.02rem; padding: 10px 14px; }
.machine-gloss .gloss-label { display: block; font-family: var(--font-display); text-transform: none; letter-spacing: 0; font-size: .8rem; font-weight: 600; color: var(--barn-red-text); margin-bottom: 2px; }
.machine-def { color: var(--text-2); margin: 8px var(--s4) 0; }
.machine-driver { margin-top: var(--s3); font-size: .9rem; font-weight: 800; color: var(--text); background: var(--tint-grass); border: 2px solid var(--outline); border-radius: var(--r-pill); padding: 3px 12px; }
.machine-bonus { margin-top: var(--s2); font-size: .82rem; font-weight: 800; color: var(--text-2); }
.machine-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s2); margin-top: var(--s3); padding: 0 var(--s4); }
.machine-card .ml-play, .machine-card .ml-more { margin: 0; }
.ml-panel {
  margin: var(--s4) var(--s4) 0; padding-top: var(--s3); align-self: stretch;
  border-top: 3px dashed var(--border-strong); text-align: left;
}
.ml-panel[hidden] { display: none; }
.ml-panel:not([hidden]) { animation: ml-open .22s var(--ease-out); }
@keyframes ml-open { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.ml-bands { justify-content: center; margin-bottom: var(--s2); }
.ml-bands .ka-band { padding: 8px 14px; min-height: var(--tap); justify-content: center; -webkit-tap-highlight-color: transparent; }
.ml-bands .ka-band:hover { transform: none; }
.ml-lesson .ka-bandnote { margin: 0 0 4px; }
.ml-line { font-size: 1.1rem; font-weight: 700; margin: 2px 0; color: var(--text); }
.ml-para { margin: 6px 0; color: var(--text); line-height: 1.55; }
.ml-sec { margin-top: var(--s3); }
.ml-sec h4 { font-size: .9rem; font-weight: 600; color: var(--barn-red-text); margin: 0 0 6px; text-transform: uppercase; letter-spacing: .05em; }
.ml-parts, .ml-steps { margin: 0; padding-left: 20px; color: var(--text); }
.ml-parts li, .ml-steps li { margin: 3px 0; line-height: 1.45; font-size: .95rem; }
.ml-parts strong { color: var(--barn-red-text); }
.ml-safety, .ml-fact { border-radius: var(--r-md); padding: 10px 12px; border: 2px solid var(--outline); }
.ml-safety { background: var(--tint-barn); }
.ml-fact { background: var(--tint-hay); }
.ml-safety p, .ml-fact p { margin: 0; font-size: .95rem; line-height: 1.45; color: var(--text); }

/* ============ grown-ups ============ */
.g-card { margin-top: var(--s5); background: var(--paper); }
.g-card h3 { font-size: 1.4rem; margin-bottom: var(--s2); }
.g-card p + p { margin-top: var(--s3); }
.goal-list { margin-left: var(--s5); display: grid; gap: 8px; }
.printables { display: flex; gap: var(--s4); flex-wrap: wrap; margin-top: var(--s3); }
.print-card { flex: 1 1 220px; text-decoration: none; color: var(--text); text-align: center; font-weight: 800; }
.print-card img { border-radius: var(--r-md); border: 3px solid var(--outline); box-shadow: 0 4px 0 var(--outline); transition: transform var(--t-fast); background: #fff; margin-bottom: 6px; }
.print-card:hover img { transform: scale(1.03) rotate(-1deg); }
.credit { margin: var(--s8) 0 var(--s6); color: var(--text-2); font-weight: 700; }

/* ============ confetti (the book's party) ============ */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti-layer i {
  position: absolute; top: -20px; width: 12px; height: 18px; border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ============ tab panels: smooth page turns ============ */
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: panel-in var(--t-slow) var(--ease-out); }
@keyframes panel-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ============ loading skeletons ============ */
@keyframes shimmer { to { background-position: -200% 0; } }
#academy:empty, #crewGrid:empty, #machineGrid:empty, #farmCardMount:empty, #crewStrip:empty, #worldMapWrap:empty {
  min-height: 220px; border-radius: var(--r-lg);
  background: linear-gradient(90deg, rgba(255, 255, 255, .5) 0%, rgba(255, 255, 255, .95) 50%, rgba(255, 255, 255, .5) 100%) 0 0 / 200% 100%;
  border: 3px dashed var(--border-strong);
  animation: shimmer 1.4s linear infinite;
}
#farmCardMount:empty { min-height: 260px; margin: var(--s6) var(--s5); }
.char-art img, .machine-art img, .gc-art img { background-color: transparent; }

/* ============ storybook mode (full-screen overlay) ============ */
.sb-overlay {
  position: fixed; inset: 0; z-index: 100;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(142, 231, 238, .22), transparent 60%),
    linear-gradient(180deg, #23405e 0%, #18304a 100%);
  opacity: 0;
  transition: opacity 220ms ease;
}
.sb-overlay.sb-open { opacity: 1; }
body.sb-lock { overflow: hidden; }
.sb-inner {
  height: 100%; width: min(1080px, 100%); margin: 0 auto;
  display: flex; flex-direction: column; gap: var(--s3);
  padding: calc(env(safe-area-inset-top) + 64px) var(--s5) calc(env(safe-area-inset-bottom) + 14px);
}
.sb-close {
  position: fixed; top: calc(env(safe-area-inset-top) + 12px); right: 14px; z-index: 2;
  width: 54px; height: 54px; border-radius: var(--r-pill); cursor: pointer;
  background: var(--cream); border: 3px solid var(--outline); box-shadow: 0 4px 0 var(--outline);
  display: grid; place-items: center;
  transition: transform var(--t-fast);
}
.sb-close:hover { transform: scale(1.08); }
.sb-close:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--outline); }
.sb-close svg { width: 26px; height: 26px; fill: none; stroke: var(--text); stroke-width: 3.4; stroke-linecap: round; }
.sb-stage { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; gap: var(--s3); perspective: 1600px; }
.sb-page-wrap { flex: 1 1 auto; min-width: 0; height: 100%; display: flex; }
.sb-page { margin: auto; max-width: 100%; max-height: 100%; transform-origin: left center; backface-visibility: hidden; will-change: transform; }
.sb-page img {
  max-height: 62vh; max-width: 100%; object-fit: contain;
  border-radius: 10px 18px 18px 10px; background: var(--surface); border: 3px solid var(--outline);
  box-shadow: -10px 0 0 -3px var(--barn-dark), 0 18px 50px rgba(0, 0, 0, .5);
  user-select: none; -webkit-user-drag: none;
}
.sb-arrow { background: var(--tractor-yellow); }
.sb-arrow svg { stroke: var(--text); }
.sb-page.flip-out-fwd { animation: sbFlipOutFwd .3s ease-in forwards; }
.sb-page.flip-in-fwd  { animation: sbFlipInFwd .3s ease-out forwards; }
.sb-page.flip-out-back, .sb-page.flip-in-back { transform-origin: right center; }
.sb-page.flip-out-back { animation: sbFlipOutBack .3s ease-in forwards; }
.sb-page.flip-in-back  { animation: sbFlipInBack .3s ease-out forwards; }
@keyframes sbFlipOutFwd  { to   { transform: rotateY(-92deg); } }
@keyframes sbFlipInFwd   { from { transform: rotateY(92deg); } to { transform: rotateY(0); } }
@keyframes sbFlipOutBack { to   { transform: rotateY(92deg); } }
@keyframes sbFlipInBack  { from { transform: rotateY(-92deg); } to { transform: rotateY(0); } }
/* karaoke text: the book's cream narration box */
.sb-text-zone {
  flex: 0 0 auto; min-height: 96px; max-height: 24vh; overflow-y: auto;
  background: var(--cream); border: 3px solid var(--outline);
  border-radius: 20px; box-shadow: 0 5px 0 rgba(0, 0, 0, .35);
  padding: var(--s3) var(--s5);
}
.sb-text { font-family: var(--font-book); text-transform: uppercase; letter-spacing: .03em; font-size: 22px; line-height: 1.7; text-align: center; color: var(--text); }
.sb-text .seg { margin: 0 0 6px; display: block; }
.sb-text .w { padding: 1px 4px; border-radius: 6px; transition: background var(--t-fast), color var(--t-fast); }
.sb-text .w.on { background: var(--tractor-yellow); color: var(--text); }
.sb-text .speaker-chip {
  display: inline-flex; align-items: center; gap: 6px; margin-right: 8px;
  font-family: var(--font-display); text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 600;
  color: var(--text); background: var(--paper); border: 2px solid var(--outline);
  border-radius: var(--r-pill); padding: 2px 10px 2px 4px; vertical-align: middle;
}
.sb-text .speaker-chip img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; vertical-align: middle; border: 2px solid var(--tractor-yellow); }
.sb-controls { display: flex; align-items: center; justify-content: center; gap: var(--s5); flex-wrap: wrap; }
.sb-page-num { font-size: 16px; }
.sb-progress { flex: 0 0 auto; height: 12px; border-radius: var(--r-pill); background: rgba(255, 255, 255, .18); border: 2px solid rgba(0, 0, 0, .35); overflow: hidden; }
.sb-progress-fill { height: 100%; width: 0; border-radius: var(--r-pill); background: linear-gradient(90deg, var(--hill-grass), var(--hill-lime)); transition: width var(--t-med); }
@media (max-width: 640px) {
  .sb-inner { padding-inline: var(--s2); gap: var(--s2); }
  .sb-stage { gap: var(--s1); }
  .sb-arrow { width: 48px; height: 48px; }
  .sb-arrow svg { width: 26px; height: 26px; }
  .sb-text-zone { min-height: 76px; max-height: 26vh; padding: var(--s2) var(--s3); }
  .sb-text { font-size: 18px; }
  .sb-controls { gap: var(--s3); }
}

/* ============ responsive ============ */
@media (max-width: 999px) {
  .topnav { display: none; }
  .grownups-pill { display: inline-flex; }
  nav.tabbar { display: flex; }
  body { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .rank-toast { bottom: calc(92px + env(safe-area-inset-bottom)) !important; }
}
@media (max-width: 900px) {
  .listen-grid { grid-template-columns: minmax(0, 1fr); }
  .hb-inner { grid-template-columns: minmax(0, 1fr); grid-template-areas: "logo" "cast" "ctas" "story"; justify-items: center; text-align: center; padding-top: var(--s4); gap: var(--s3); }
  .hb-copy { display: contents; }
  .hb-title { grid-area: logo; }
  .hb-sub { grid-area: logo; align-self: end; justify-content: center; margin-top: 4px; display: block; font-size: 1rem; }
  .hb-story { grid-area: story; margin: 0 var(--s1) 84px; }
  .hb-ctas { grid-area: ctas; justify-content: center; margin-top: 0; gap: var(--s3); }
  .hb-ctas .btn-play { font-size: 1.6rem; min-height: 64px; padding: 8px 28px 8px 22px; }
  .hb-ctas .btn-lg { font-size: 1.05rem; padding: 10px 18px; min-height: 56px; }
  .hb-cast { grid-area: cast; min-height: 0; padding-bottom: 0; margin: -6px 0 -4px; }
  .hb-logo { width: min(300px, 72vw); }
  .hb-miller { height: clamp(210px, 30vh, 280px); }
  .hb-ven { height: clamp(120px, 18vh, 170px); margin-left: -30px; }
  .hero-book { min-height: 0; }
}
@media (max-width: 640px) {
  .wrap, .wrap-narrow { padding: var(--s5) var(--s4); }
  .card { padding: var(--s5) var(--s4); }
  .topbar { padding: 6px var(--s4); min-height: 62px; }
  .brand-logo { height: 46px; }
  .grownups-pill { padding: 3px 12px 3px 4px; font-size: .9rem; }
  .grownups-pill .nav-ico { width: 30px; height: 30px; }
  #installBtn { padding: 6px 10px; font-size: .85rem; }
  .audiobook-head { flex-direction: column; text-align: center; }
  .ab-player { justify-content: center; }
  .ab-player .btn-lg { flex: 1 1 100%; }
  .reader-text { font-size: 19px; padding: 10px 12px; }
  .game-q { font-size: 1.2rem; }
  .answer-btn { font-size: 1.15rem; }
  .ph-inner { padding: var(--s4) var(--s4) 0; gap: var(--s2); }
  .ph-text .section-title { font-size: 1.85rem; }
  .ph-text .section-sub { font-size: .95rem; }
  .ph-art { width: 96px; margin-bottom: -18px; }
  .page-hero { padding-bottom: 44px; }
  .crew-strip { grid-auto-columns: 150px; }
  .book-promo { gap: var(--s5); }
  .book-cover { width: 190px; margin: 0 auto; }
  .gc-art { height: 104px; }
  .gc-art svg { width: 110px; height: 88px; }
  .gc-art img { width: 86px; height: 86px; }
  .game-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
  .game-picker .game-card { padding: 0 var(--s2) var(--s3); }
  .game-picker .game-card h3 { font-size: 1.1rem; }
  .game-picker .game-card p { font-size: .85rem; line-height: 1.3; }
  .gc-art { margin: 0 calc(-1 * var(--s2)); }
  .stars { font-size: 20px; }
  .game-stage { padding: var(--s4) var(--s3); border-radius: var(--r-lg); }
  .hills-top { margin-top: 44px; }
  .hills-top::before { height: 44px; }
  .hills-top::after { height: 30px; }
}
@media (max-width: 380px) {
  .grownups-pill span { display: none; }
  .grownups-pill { padding: 3px 6px; }
}

/* ============ reduced motion ============ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .sb-page { animation: none !important; transition: opacity 240ms ease !important; }
  .sb-page.sb-fade { opacity: .12; }
  .sb-overlay, .sb-progress-fill { transition: none !important; }
}
