/* ============================================================================
   style.css — the reader: home map, chapter title page, page view.
   Loads AFTER den.css, which supplies the reset, the palette and the game look.

   Two surfaces on purpose: the map keeps the Den's night sky (same world), the
   book itself is warm parchment with dark ink, because that is what is
   comfortable to actually read on for ten minutes.
   ========================================================================== */

html, body{ height:100%; }
body{
  margin:0;
  font-family:'Nunito', ui-rounded, 'Comic Sans MS', sans-serif;
  background:var(--sky-deep);
  color:var(--cloud);
  touch-action:manipulation;
  overflow-x:hidden;
  -webkit-text-size-adjust:100%;
}
body.no-scroll{ overflow:hidden; }
#app{ min-height:100%; }

/* Everything tappable clears 44px and shows where the keyboard is. */
button{ font-family:inherit; }
button:focus-visible,
a:focus-visible{ outline:3px solid var(--flame); outline-offset:2px; border-radius:10px; }

.sr-only{
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0;
}

/* ==========================================================================
   HOME — the ten lands as a winding map path
   ========================================================================== */
.map-screen{
  position:relative; min-height:100vh; min-height:100dvh;
  background:radial-gradient(1200px 600px at 50% -10%, #4A3F8C 0%, var(--sky) 45%, var(--sky-deep) 100%);
  padding:0 0 34px;
  overflow:hidden;
}
.map-head{
  position:relative; z-index:2;
  /* WRAP. This was nowrap, and it was fine with two links in it. The day a
     third and fourth went in, the row became 725px wide inside a 375px phone
     and everything after the XP badge sat off the right edge with no
     scrollbar to hint at it - so Les sons, Le loup rouge and the Hebrew book
     shipped completely invisible on the device they are read on. */
  display:flex; flex-wrap:wrap; align-items:center; gap:10px;
  padding:14px 16px 6px; max-width:760px; margin:0 auto;
}
/* The title keeps the first row to itself so the links below it line up. */
.map-head h1{ flex:1 0 100%; }
.map-head h1{
  flex:1; margin:0;
  font-family:'Baloo 2', ui-rounded, sans-serif; font-weight:800;
  font-size:clamp(22px, 5vw, 30px); line-height:1.1;
  color:#FFE9B8; text-shadow:0 3px 0 rgba(0,0,0,.25);
}
.gear{
  flex:0 0 auto; width:48px; height:48px; border-radius:16px; border:none; cursor:pointer;
  background:rgba(255,255,255,.12); color:#FFF; font-size:24px; line-height:1;
  -webkit-touch-callout:none; user-select:none; -webkit-user-select:none;
}

/* The French page needs a way in that a seven-year-old can find. The footer
   link sits 2,325px down the map, past all sixteen chapters - over two screens
   of scrolling on an iPad. This one is beside the gear, always on screen.

   It is a word, not a flag. Windows draws the regional-indicator pair as the
   letters "FR" while iOS draws the French tricolour, so the same button looked
   like two different things on the two devices this app runs on - and France's
   flag is the wrong country for a child learning French in Ontario. */
.head-link{
  flex:0 0 auto; min-height:48px; padding:0 14px; border-radius:16px; cursor:pointer;
  display:flex; align-items:center; background:rgba(255,255,255,.12);
  color:#FFE9B8; text-decoration:none; white-space:nowrap;
  font-family:'Baloo 2', ui-rounded, sans-serif; font-weight:800; font-size:16px;
  -webkit-touch-callout:none; user-select:none; -webkit-user-select:none;
}
.head-link:active{ transform:translateY(2px); }
.gear:active{ transform:scale(.94); }
.map-sub{
  position:relative; z-index:2; text-align:center; margin:0 auto 6px;
  font-size:15px; font-weight:700; color:#BFB6EA; max-width:760px; padding:0 16px;
}

.map-wrap{ position:relative; z-index:1; max-width:760px; margin:0 auto; }
.map-svg{ position:absolute; inset:0; width:100%; height:100%; pointer-events:none; }
.map-trail{
  fill:none; stroke:rgba(255,255,255,.26); stroke-width:9;
  stroke-linecap:round; stroke-dasharray:1 24;
  vector-effect:non-scaling-stroke;
}

.land{
  position:absolute; transform:translate(-50%, -50%);
  display:flex; flex-direction:column; align-items:center; gap:5px;
  width:132px; padding:8px 4px; border:none; background:none; cursor:pointer;
  color:var(--cloud); font-family:'Nunito', sans-serif;
  border-radius:20px;
}
.land:active{ transform:translate(-50%, -50%) scale(.95); }
.land .egg{ width:64px; height:80px; }
.land .egg .team-tag{ font-size:19px; }
.land .dragon-face{ font-size:52px; }
.land-name{
  font-family:'Baloo 2', sans-serif; font-weight:800; font-size:14px; line-height:1.15;
  color:#FFF; text-shadow:0 2px 4px rgba(0,0,0,.55);
}
.land-sub{ font-size:12px; font-weight:700; color:#BFB6EA; min-height:14px; }
.land-stars{ font-size:12px; letter-spacing:1px; color:#FFD46A; min-height:14px; }
.land.is-locked .egg{ filter:grayscale(.85) brightness(.55); box-shadow:none; }
.land.is-locked .land-name{ color:#9C95C9; }
.land.is-soon .egg{ filter:saturate(.55) brightness(.8); }
.land.is-open .egg{ box-shadow:inset -10px -12px 0 rgba(0,0,0,.14), 0 0 34px var(--glow, #FFF); }
.land-lock{
  position:absolute; top:16px; left:50%; transform:translateX(-50%);
  font-size:26px; filter:drop-shadow(0 2px 3px rgba(0,0,0,.6));
}
.land-go{
  font-family:'Baloo 2', sans-serif; font-weight:800; font-size:13px;
  background:var(--flame); color:#4A2404; border-radius:999px; padding:2px 12px;
}

.map-foot{ position:relative; z-index:2; text-align:center; margin-top:26px; }
.den-link{
  display:inline-block; text-decoration:none;
  font-family:'Baloo 2', sans-serif; font-weight:800; font-size:20px;
  background:rgba(255,255,255,.14); color:#FFF; box-shadow:0 6px 0 rgba(0,0,0,.25);
  border-radius:20px; padding:14px 28px; min-height:52px;
}
.den-link:active{ transform:translateY(3px); box-shadow:0 3px 0 rgba(0,0,0,.25); }

/* ==========================================================================
   THE BOOK — title page and page view (parchment)
   ========================================================================== */
.book{
  display:flex; flex-direction:column;
  min-height:100vh; min-height:100dvh;
  background:linear-gradient(180deg, #FFFDF6 0%, var(--parchment) 100%);
  color:var(--ink);
}
/* the page view is a fixed pane: art, text, arrows — never a scrolling page */
.book-page{ height:100vh; height:100dvh; min-height:0; overflow:hidden; }
.book-bar{
  flex:0 0 auto; display:flex; align-items:center; gap:10px;
  padding:8px 12px; padding-top:max(8px, env(safe-area-inset-top));
}
.icon-btn{
  width:48px; height:48px; border-radius:16px; border:none; cursor:pointer;
  background:rgba(51,37,91,.09); color:var(--ink); font-size:22px; line-height:1;
}
.icon-btn:active{ transform:scale(.94); }
.book-count{
  flex:1; text-align:center; font-weight:800; font-size:15px; color:var(--ink-soft);
  font-variant-numeric:tabular-nums;
}

/* ---------- title page ---------- */
.title-page{
  flex:1 1 auto; display:flex; flex-direction:column; align-items:center;
  gap:14px; padding:0 18px 26px; max-width:720px; margin:0 auto; width:100%;
  overflow-y:auto;
}
.cover-frame{
  width:100%; max-width:520px; aspect-ratio:3 / 2;
  border-radius:22px; overflow:hidden; background:#E7DCC2;
  box-shadow:0 8px 0 rgba(51,37,91,.14);
}
.cover-frame img{ width:100%; height:100%; object-fit:cover; display:block; }
.chapter-kicker{
  font-weight:800; font-size:15px; letter-spacing:1px; text-transform:uppercase;
  color:var(--ink-soft); margin:2px 0 -6px;
}
.chapter-title{
  font-family:'Baloo 2', sans-serif; font-weight:800; text-align:center; margin:0;
  font-size:clamp(28px, 6.4vw, 42px); line-height:1.1; color:var(--ink);
}
.story-words{
  width:100%; max-width:560px;
  background:#FFFDF6; border:3px solid var(--parchment-edge); border-radius:22px;
  padding:14px 14px 16px; text-align:center;
  box-shadow:0 6px 0 rgba(51,37,91,.10);
}
.story-words h2{
  margin:0 0 10px; font-family:'Baloo 2', sans-serif; font-weight:800;
  font-size:17px; color:var(--ink-soft); letter-spacing:.3px;
}
.chips{ display:flex; flex-wrap:wrap; justify-content:center; gap:10px; }
.chip{
  border:none; cursor:pointer; border-radius:16px; padding:10px 18px; min-height:48px;
  background:#FFF; color:var(--ink); box-shadow:0 5px 0 rgba(51,37,91,.18);
  font-family:'Baloo 2', sans-serif; font-weight:800; font-size:clamp(20px, 4.6vw, 28px);
}
.chip:active{ transform:translateY(3px); box-shadow:0 2px 0 rgba(51,37,91,.18); }
.tap-hint{ font-size:14px; font-weight:700; color:var(--ink-soft); margin:0; text-align:center; }
.start-btn{
  border:none; cursor:pointer; border-radius:22px; padding:16px 40px; min-height:60px;
  font-family:'Baloo 2', sans-serif; font-weight:800; font-size:24px;
  background:var(--flame); color:#4A2404; box-shadow:0 7px 0 #C4701C;
}
.start-btn:active{ transform:translateY(4px); box-shadow:0 3px 0 #C4701C; }

/* ---------- page view ---------- */
.page{
  flex:1 1 auto; display:flex; flex-direction:column; min-height:0;
  padding:0 14px 10px; padding-bottom:max(10px, env(safe-area-inset-bottom));
  max-width:900px; margin:0 auto; width:100%;
}
.page-art{
  flex:0 0 auto; height:46vh; width:100%;
  border-radius:22px; overflow:hidden; background:#E7DCC2;
  box-shadow:0 7px 0 rgba(51,37,91,.13);
}
.page-art img{ width:100%; height:100%; object-fit:cover; display:block; }
@media (orientation:portrait) and (max-width:560px){ .page-art{ height:34vh; } }
@media (orientation:landscape){ .page-art{ height:50vh; } }
/* a phone held sideways: the art gives up room so the lines still fit on screen */
@media (orientation:landscape) and (max-height:520px){
  .book-bar{ padding:4px 12px; }
  .icon-btn{ width:44px; height:44px; font-size:19px; }
  .page-art{ height:30vh; }
  .page-nav{ padding-top:2px; }
}

.page-text{
  flex:1 1 auto; min-height:0; overflow-y:auto;
  display:flex; flex-direction:column; justify-content:flex-start; gap:.35em;
  padding:14px 4px 4px;
  font-family:'Baloo 2', ui-rounded, sans-serif; font-weight:700;
  font-size:clamp(23px, 3.6vw + 12px, 40px); line-height:1.5;
  color:var(--ink); text-align:left;
}
.page-line{ margin:0; }

/* the whole point: every word is a button.
   inline-flex + min-height keeps every word at or over the 44px tap floor even
   at the smallest clamped font size; the line box grows to fit, so the pill
   backgrounds never collide between wrapped lines. */
.w{
  display:inline-flex; align-items:center; justify-content:center;
  min-height:44px; border:none; background:none; cursor:pointer;
  font:inherit; color:inherit; letter-spacing:inherit; line-height:1.2;
  padding:0 4px; margin:0 -2px; border-radius:10px;
  -webkit-tap-highlight-color:transparent;
}
.w:active{ background:rgba(78,203,160,.20); }
.w.speaking{ background:rgba(78,203,160,.28); animation:wordPulse .45s ease; }
@keyframes wordPulse{ 0%{transform:scale(1);} 40%{transform:scale(1.16);} 100%{transform:scale(1);} }
.chip.speaking{ background:rgba(78,203,160,.30); animation:wordPulse .45s ease; }

/* the chapter's team grapheme, and earlier teams as a quiet underline */
.g{ color:var(--g, var(--good)); font-weight:800; }
.g-old{
  text-decoration:underline; text-decoration-color:var(--g, var(--ink-soft));
  text-decoration-thickness:3px; text-underline-offset:5px;
}
.teaser-word{ color:var(--g, #4FA3E8); font-weight:800; }

.page-nav{
  flex:0 0 auto; display:flex; align-items:center; gap:12px; padding-top:6px;
}
.nav-btn{
  border:none; cursor:pointer; border-radius:22px;
  min-width:74px; min-height:62px; padding:0 18px;
  font-family:'Baloo 2', sans-serif; font-weight:800; font-size:30px; line-height:1;
  background:#FFF; color:var(--ink); box-shadow:0 6px 0 rgba(51,37,91,.2);
}
.nav-btn:active{ transform:translateY(3px); box-shadow:0 3px 0 rgba(51,37,91,.2); }
.nav-btn[disabled]{ opacity:.32; cursor:default; box-shadow:0 6px 0 rgba(51,37,91,.12); }
.nav-btn.next{ margin-left:auto; }
.nav-btn.hunt{
  background:var(--flame); color:#4A2404; box-shadow:0 6px 0 #C4701C;
  font-size:22px; padding:0 24px;
}
.nav-btn.hunt:active{ box-shadow:0 3px 0 #C4701C; }
@media (orientation:landscape) and (max-height:520px){
  .page-text{ font-size:clamp(19px, 2.2vw + 6px, 26px); padding:8px 4px 2px; }
  .nav-btn{ min-height:52px; font-size:26px; }
  .nav-btn.hunt{ font-size:19px; }
}

/* ---------- the story-language switch: EN | FR | HE ----------
   Three 44px buttons in the top bar, between the page count and the title
   button. At 380px wide the bar has about 230px between its two icon buttons;
   the switch takes 146 and the count keeps the rest. */
.lang-slot{ flex:0 0 auto; display:flex; }
.lang-toggle{
  display:flex; gap:4px; padding:3px; border-radius:16px;
  background:rgba(51,37,91,.09);
}
.lang-btn{
  min-width:44px; min-height:44px; padding:0 6px; border:none; cursor:pointer;
  border-radius:13px; background:transparent; color:var(--ink-soft);
  font-family:'Baloo 2', sans-serif; font-weight:800; font-size:16px; line-height:1;
  -webkit-tap-highlight-color:transparent;
}
.lang-btn[aria-pressed="true"]{
  background:#FFF; color:var(--ink); box-shadow:0 3px 0 rgba(51,37,91,.18);
}
.lang-btn:active{ transform:translateY(2px); }

/* ---------- a translated page ----------
   Nunito and Baloo 2 carry no Hebrew at all, so Hebrew names its own faces.
   The size bump is the same one the Hebrew book makes: a nikud dot at the
   Latin reading size is too small for a seven-year-old to see. */
.tr-stanza{ display:flex; flex-direction:column; }
.tw{ white-space:nowrap; }      /* a word and its punctuation never part */
.page-text .tr-he{
  font-family:'David Libre', 'Noto Sans Hebrew', 'Arial Hebrew', 'Times New Roman', serif;
  font-weight:500; font-size:1.15em; line-height:1.75; text-align:right;
}
.tr-translit{
  margin:0 0 .15em; font-family:'Nunito', sans-serif; font-style:italic;
  font-weight:700; font-size:max(15px, .48em); line-height:1.35;
  color:var(--ink-soft); text-align:left;
}
.tr-note{
  margin:.5em 0 0; font-family:'Nunito', sans-serif; font-weight:700;
  font-size:14px; line-height:1.4; color:var(--ink-soft);
}
/* A translated page still too long at its smallest size scrolls. iPad Safari
   hides the scrollbar, so the bottom edge fades while there is more below;
   app.js drops the class once the last line is in view. The mask only
   changes how it looks: every word under the fade still taps. */
.page-text.more-below{
  -webkit-mask-image:linear-gradient(to bottom, #000 calc(100% - 2.2em), rgba(0,0,0,.18));
          mask-image:linear-gradient(to bottom, #000 calc(100% - 2.2em), rgba(0,0,0,.18));
}

/* ==========================================================================
   WORD HUNT (den surface inside the reader)
   ========================================================================== */
.hunt-screen{ min-height:100vh; min-height:100dvh; }
.hunt-lead{
  font-size:17px; font-weight:700; color:#CFC8F2; max-width:320px; text-align:center;
}
.hunt-team{
  font-family:'Baloo 2', sans-serif; font-weight:800; font-size:64px; letter-spacing:3px;
  color:var(--good); text-shadow:0 3px 0 rgba(0,0,0,.25);
}

/* ==========================================================================
   OVERLAY (grown-ups panel, gentle "not yet" messages)
   ========================================================================== */
.overlay{
  position:fixed; inset:0; z-index:60; display:flex; align-items:center; justify-content:center;
  background:rgba(20,16,48,.72); padding:20px;
}
/* display:flex above beats the [hidden] attribute's UA display:none, which
   left the backdrop covering the page and eating every tap. Keep this rule. */
.overlay[hidden]{ display:none; }
.sheet{
  width:100%; max-width:400px; max-height:86vh; overflow-y:auto;
  background:linear-gradient(180deg, #FFFBF0, var(--parchment));
  color:var(--ink); border:3px solid var(--parchment-edge); border-radius:26px;
  padding:22px 20px; text-align:center; box-shadow:0 12px 0 rgba(0,0,0,.28);
}
.sheet h2{
  margin:0 0 8px; font-family:'Baloo 2', sans-serif; font-weight:800;
  font-size:26px; line-height:1.15;
}
.sheet p{ margin:0 0 14px; font-size:16px; font-weight:700; color:var(--ink-soft); line-height:1.45; }
.sheet .sheet-emoji{ font-size:54px; line-height:1; display:block; margin-bottom:6px; }
.sheet-actions{ display:flex; flex-direction:column; gap:10px; margin-top:6px; }
.sheet-btn{
  border:none; cursor:pointer; border-radius:18px; padding:14px 18px; min-height:54px;
  font-family:'Baloo 2', sans-serif; font-weight:800; font-size:19px;
  background:var(--flame); color:#4A2404; box-shadow:0 6px 0 #C4701C;
}
.sheet-btn:active{ transform:translateY(3px); box-shadow:0 3px 0 #C4701C; }
.sheet-btn.quiet{ background:#FFF; color:var(--ink); box-shadow:0 6px 0 rgba(51,37,91,.2); }
.sheet-btn.quiet:active{ box-shadow:0 3px 0 rgba(51,37,91,.2); }
.sheet-note{ font-size:13px; font-weight:700; color:var(--ink-soft); margin:14px 0 0; }
.code-box{
  width:100%; margin:0 0 14px; padding:10px 12px;
  font-family:ui-monospace, 'Cascadia Mono', Menlo, Consolas, monospace;
  font-size:12px; line-height:1.5; color:var(--ink); background:#FFF;
  border:2px solid var(--parchment-edge); border-radius:14px;
  resize:vertical; word-break:break-all;
}
.code-box:focus-visible{ outline:3px solid var(--flame); outline-offset:2px; }

.toast{
  position:fixed; left:50%; bottom:26px; transform:translateX(-50%); z-index:70;
  background:rgba(20,16,48,.94); color:#FFE9B8; border-radius:999px;
  padding:12px 22px; font-weight:800; font-size:16px; pointer-events:none;
  max-width:88vw; text-align:center;
}

@media (prefers-reduced-motion: reduce){
  .w.speaking, .chip.speaking{ animation:none; }
  .land:active, .gear:active, .icon-btn:active{ transform:none; }
}

/* XP earned, shown on the chapter win screen under the dragon. */
.hatch-xp{
  font-family:'Baloo 2', ui-rounded, sans-serif; font-weight:800;
  font-size:20px; color:#FFD98A; margin-top:4px;
}
/* The map header badge sits with .head-link and .gear, so it needs the same
   box but its own inner layout. */
.head-link.xp-badge{ border-radius:16px; }
