@font-face {
  font-family: "OpenDyslexic";
  src: url("assets/fonts/OpenDyslexic-Regular.otf") format("opentype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "OpenDyslexic";
  src: url("assets/fonts/OpenDyslexic-Bold.otf") format("opentype");
  font-weight: 700;
  font-display: swap;
}

/* Garden (light) version. Same structure as prototype-dark, different palette and scenes. */
:root {
  --ink: #23303d;                       /* text */
  --muted: rgba(35, 48, 61, 0.72);
  --unread: rgba(35, 48, 61, 0.5);      /* words not read yet */
  --cream: #fffaf0;
  --panel: rgba(255, 250, 240, 0.93);   /* cards: tale text, captions */
  --sky-top: #bfe0f7;
  --sky-low: #eef8ff;
  --hero-top: #a9d6f5;
  --lawn: #8fcf6a;
  --lawn-dark: #6fb24c;
  --hill: #b9e2a4;
  --soil-1: #d4a373;
  --soil-2: #b9875a;
  --soil-3: #9a6a43;
  --tunnel: #5a3a22;
  --pipe: #c9d6e0;
  --pipe-edge: #7d8e9c;
  --accent: #237a5b;                    /* read words, title: the tale's green, darkened for contrast */
  --accent-light: #43aa8b;              /* the tale's colour in the app */
  --sun: #ffd45c;
  --orange: #f2793a;
  --mistake: #d43a3a;
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
h1, h2 { font-family: "Love Ya Like A Sister", "Nunito", cursive; font-weight: 400; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
}
/* Light overlay behind the bar, fading out below, so content scrolling underneath doesn't clash. */
.topbar::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: calc(100% + 48px); z-index: -1; pointer-events: none;
  background: linear-gradient(to bottom, rgba(255, 250, 240, 0.9) 0%, rgba(255, 250, 240, 0.65) 50%, rgba(255, 250, 240, 0) 100%);
}

.btn {
  display: inline-block; font-weight: 800; text-decoration: none; text-align: center;
  background: var(--orange); color: #fff; border: 0; border-radius: 999px;
  padding: 14px 24px; font-size: 1rem; cursor: pointer;
}
/* Apple's badge: keep its proportions, never smaller than 40px tall (Apple's guideline). */
.appstore-badge { display: inline-block; line-height: 0; border-radius: 9px; }
.appstore-badge img { height: 100%; width: auto; }
.appstore-badge-small { height: 40px; }
.appstore-badge-large { height: 56px; }
.appstore-badge:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn-ghost { background: transparent; border: 2px solid var(--accent); color: var(--accent); font-family: inherit; }

/* ---------- title screen (normal scroll) ---------- */
.hero {
  position: relative; height: 75vh; height: 75svh; overflow: hidden;
  display: grid; place-items: center; text-align: center; padding: 10vh 16px 0; padding-top: 10svh;
  background: linear-gradient(to bottom, var(--hero-top) 0%, var(--sky-top) 100%); /* ends where the story's sky starts */
}
.hero-content { position: relative; }
.hero-title-pin h1.is-placeholder { visibility: hidden; }
.floating-title {
  position: fixed; left: 50%; top: 0; z-index: 60; pointer-events: none; white-space: nowrap;
  font-family: "Love Ya Like A Sister", "Nunito", cursive; font-size: clamp(3.5rem, 15vw, 8rem); line-height: 1.15;
  color: var(--accent); text-shadow: 0 2px 0 rgba(255, 255, 255, 0.7); transform-origin: 50% 50%; will-change: transform;
}
.topbar-title { position: absolute; left: 50%; transform: translateX(-50%); color: var(--accent); font-family: "Love Ya Like A Sister", cursive; font-size: 1.6rem; }
.hero h1 { font-size: clamp(3.5rem, 15vw, 8rem); margin: 0; color: var(--accent); line-height: 1.15; }
.hero .tagline { margin: 18px auto 0; max-width: 34ch; text-wrap: balance; font-size: clamp(1.15rem, 4vw, 1.6rem); color: var(--ink); }
.hero .scroll-hint { position: absolute; bottom: 28px; left: 0; right: 0; margin: 0; }
.scroll-hint { color: var(--muted); font-size: 0.9rem; animation: bob 1.8s ease-in-out infinite; }
.scroll-hint::after { content: " ↓"; }
@keyframes bob { 50% { transform: translateY(6px); } }
/* two clouds on the title screen (the sun is in the garden below) */
.cloud { position: absolute; width: 140px; height: 44px; border-radius: 44px; background: rgba(255, 255, 255, 0.9); }
.cloud::before, .cloud::after { content: ""; position: absolute; background: inherit; border-radius: 50%; }
.cloud::before { width: 60px; height: 60px; left: 24px; top: -30px; }
.cloud::after { width: 46px; height: 46px; left: 72px; top: -20px; }
.cloud-1 { left: 8%; top: 22%; }
.cloud-2 { left: 58%; top: 64%; transform: scale(0.7); opacity: 0.8; }

/* ---------- story stage ---------- */
#story { position: relative; height: 900vh; }
.stage {
  /* dvh = the real visible height, which changes as Safari's toolbars shrink and grow (iPhone). */
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  /* Clip sideways, but let the ground spill below the stage (iPhone, see .land). */
  overflow: hidden; overflow-x: clip; overflow-y: visible;
}
.sky { position: absolute; inset: 0 0 -100% 0; background: var(--sky-top); }

/* ---------- SURFACE: the garden in perspective (horizon at 52%) ---------- */
.surface { position: absolute; inset: 0; } /* no will-change: keeps pictures sharp when the camera zooms in */
.land { position: absolute; left: 0; top: 0; width: 100%; height: 150%; } /* 1500 units = 150%: also fills under Safari's bar */
.land .pipe-line { opacity: 0; }
.sun { position: absolute; right: 10%; top: 10%; width: min(13vw, 100px); aspect-ratio: 1; border-radius: 50%; background: var(--sun); box-shadow: 0 0 50px 14px rgba(255, 212, 92, 0.45); }
.cloud-a { left: 9%; top: 17%; }

/* Actors: positioned in % of the stage, anchored at their bottom centre. */
.actor { position: absolute; width: var(--w); margin-left: calc(var(--w) / -2); margin-top: calc(var(--w) * -1); transform-origin: 50% 100%; }
.actor-img { width: 100%; transform-origin: 50% 50%; }
.flowerbed { --w: min(9vw, 72px);   left: 50%; top: 53%; }               /* far away, at the end of the path */
.marigold  { --w: min(20vw, 150px); left: 12%; top: 73%; }               /* foreground */
.violet    { --w: min(17vw, 130px); left: 28%; top: 77%; }
.veg       { --w: min(24vw, 180px); left: 86%; top: 74%; }
.farmer    { --w: min(26vw, 200px); left: 70%; top: 75%; opacity: 0; }
.shovel    { --w: min(32vw, 240px); left: 60%; top: 74%; opacity: 0; transform-origin: 50% 100%; }
.stake     { opacity: 0; }
.stake-1   { --w: min(3.2vw, 26px); left: 40%; top: 60%; }
.stake-2   { --w: min(5vw, 40px);   left: 63%; top: 65%; }
.stake-3   { --w: min(7vw, 56px);   left: 33%; top: 69%; }
.rings { position: absolute; left: 50%; top: 10%; width: 0; height: 0; }
.rings i { position: absolute; left: -40px; top: -40px; width: 80px; height: 80px; border: 3px solid var(--orange); border-radius: 50%; opacity: 0; animation: ring 1.2s ease-out infinite; }
.rings i:nth-child(2) { animation-delay: 0.4s; }
.rings i:nth-child(3) { animation-delay: 0.8s; }
@keyframes ring { 0% { transform: scale(0.3); opacity: 0.9; } 100% { transform: scale(1.8); opacity: 0; } }

/* Alberta's hole in the foreground, and Alberta popping out of it (the box clips her below the rim). */
.hole { position: absolute; left: 50%; top: 74%; width: min(40vw, 300px); aspect-ratio: 4 / 1; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(ellipse at 50% 40%, #3a2414 0%, #5a3a22 70%, #7a5232 100%); }
.mole { --w: min(28vw, 210px); position: absolute; left: 50%; top: 74%; width: var(--w); height: calc(var(--w) * 1.5); margin-left: calc(var(--w) / -2); margin-top: calc(var(--w) * -1.5); overflow: hidden; }
.mole-body { position: absolute; left: 0; right: 0; bottom: 0; }
.headphones { position: absolute; width: 92%; left: 4%; top: -16%; opacity: 0; }
.mound { position: absolute; left: 50%; top: 74%; width: min(44vw, 330px); height: min(16vw, 120px); transform: translate(-50%, -78%); border-radius: 50% 50% 12% 12% / 100% 100% 12% 12%; background: #b9875a; box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.08); opacity: 0; transform-origin: 50% 100%; }

/* ---------- TUNNEL: inside, in perspective (vanishing point at 50% 45%) ---------- */
.tunnel { position: absolute; inset: 0 0 -40% 0; overflow: hidden; opacity: 0; visibility: hidden;
  background: radial-gradient(ellipse at 50% 32%, #fff3cf 0%, #f3cf9c 14%, #d7a06c 36%, #a8724a 70%, #8a5a37 100%); }
.daylight { position: absolute; left: 50%; top: 32%; width: 34vmin; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0%, #fffbea 45%, rgba(255, 251, 234, 0) 72%); }
.rings-3d i { position: absolute; left: 50%; top: 32%; width: 150vmin; height: 120vmin; margin-left: -75vmin; margin-top: -60vmin;
  border-radius: 50%; border: 5vmin solid rgba(122, 78, 44, 0.55); box-shadow: inset 0 0 0 1.5vmin rgba(90, 55, 30, 0.22); will-change: transform, opacity; }

/* captions (feature explanations): dark ink on a cream card, readable over sky or soil */
.captions { position: absolute; left: 50%; top: 80px; transform: translateX(-50%); width: min(calc(100vw - 32px), 900px); height: 5em; }
.caption {
  position: absolute; left: 0; right: 0; top: 0; margin: 0 auto; width: fit-content; max-width: 100%;
  text-align: center; opacity: 0; visibility: hidden;
  font-size: clamp(1.4rem, 5.2vw, 2.4rem); line-height: 1.2; font-weight: 800; color: var(--ink);
  text-wrap: balance; background: var(--panel); padding: 0.3em 0.7em; border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(35, 48, 61, 0.12);
}

/* tale text at the bottom, like a page of the app */
.reader {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(calc(100vw - 32px), 760px); min-height: 8.5em;
}
.sentence {
  position: absolute; inset: auto 0 0 0; opacity: 0; visibility: hidden;
  background: var(--panel); border-radius: var(--radius); padding: 16px 20px;
  box-shadow: 0 8px 28px rgba(35, 48, 61, 0.15);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.tale-text { font-family: "OpenDyslexic", "Nunito", sans-serif; font-size: clamp(1rem, 3.3vw, 1.35rem); line-height: 1.75; margin: 0; }
.w { color: var(--unread); transition: none; }
.caption .sound-word { cursor: pointer; text-decoration: underline wavy var(--orange); text-underline-offset: 8px; text-decoration-thickness: 2px; }
.w.sound-word { cursor: pointer; text-decoration: underline wavy var(--orange); text-underline-offset: 6px; pointer-events: auto; }
.w.hard { display: inline-block; }
.reader, .reader * { pointer-events: none; }
.reader .sound-word { pointer-events: auto; }

/* syllables overlay */
.syllables {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%);
  display: flex; gap: 0.08em; opacity: 0; pointer-events: none; white-space: nowrap; max-width: calc(100vw - 32px);
  font-family: "OpenDyslexic", sans-serif; font-weight: 700; font-size: clamp(1.3rem, 5.8vw, 4.5rem);
  background: #fff; color: var(--ink); padding: 0.2em 0.5em; border-radius: 22px;
  box-shadow: 0 10px 40px rgba(35, 48, 61, 0.25);
}
.syllables span:nth-child(odd) { color: #1d6fd8; }
.syllables span:nth-child(even) { color: #d8431d; }

/* ---------- demo ---------- */
.finale { position: relative; z-index: 1; background: var(--cream); min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 104px 0 32px; }
.demo { padding: 0 16px; width: 100%; max-width: 760px; margin: 0 auto; text-align: center; }
.demo h2 { font-size: clamp(2.2rem, 8vw, 3.5rem); color: var(--accent); margin: 0; }
.demo-intro { color: var(--muted); margin: 8px 0 88px; }
.demo-card { background: #fff; border: 1px solid rgba(35, 48, 61, 0.1); border-radius: var(--radius); padding: 24px 20px; position: relative; box-shadow: 0 10px 30px rgba(35, 48, 61, 0.08); }
.demo-hedgehog { width: 110px; margin: -84px auto 8px; }
.demo-sentence { font-size: clamp(1.15rem, 4.2vw, 1.6rem); }
.demo-sentence .w { cursor: pointer; transition: color 0.2s, transform 0.2s; display: inline-block; }
.demo-sentence .w.read { color: var(--accent); }
.demo-sentence .w.next { color: var(--ink); }
.demo-sentence .w.hint { color: var(--ink); transform: scale(1.25); }
.demo-sentence .w.wrong { color: var(--mistake); }
.demo-syllables[hidden] { display: none; }
.demo-syllables { margin: 18px auto 0; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.demo-syllables-word { font-family: "OpenDyslexic", sans-serif; font-weight: 700; font-size: clamp(1.8rem, 8vw, 3rem); background: var(--cream); border-radius: 16px; padding: 0.1em 0.5em; }
.demo-syllables-word span:nth-child(odd) { color: #1d6fd8; }
.demo-syllables-word span:nth-child(even) { color: #d8431d; }
.demo-controls { margin-top: 22px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.mic {
  display: inline-flex; align-items: center; gap: 10px; font: inherit; font-weight: 800; font-size: 1.05rem;
  background: var(--orange); color: #fff; border: 0; border-radius: 999px; padding: 14px 26px; cursor: pointer;
}
.mic svg { width: 24px; height: 24px; fill: currentColor; }
.mic[aria-pressed="true"] { background: var(--mistake); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 12px rgba(212, 58, 58, 0.2); } }
.demo-status { min-height: 1.5em; color: var(--muted); margin: 0; }
.demo-debug { font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; color: var(--accent); margin: 0; word-break: break-word; }
.demo-privacy { color: var(--muted); font-size: 0.85rem; margin-top: 16px; }
.end { text-align: center; padding: 36px 16px 0; }

/* ---------- reduced motion: a static page, no scroll animation ---------- */
body.reduced #story { height: auto; }
body.reduced .stage { display: none; }
.static-story { display: none; }
body.reduced .static-story { display: block; padding: 96px 16px 0; max-width: 760px; margin: 0 auto; }
.static-scene { background: #fff; border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: 0 6px 20px rgba(35, 48, 61, 0.08); }
.static-scene img { width: 96px; margin-bottom: 8px; }
.static-scene .w { color: var(--ink); }
.static-scene .caption-static { color: var(--accent); font-weight: 800; margin: 12px 0 0; }
