/* The Kids Friendly Apollo storybook (/kids/apollo): a cover, fifteen
   picture-book pages, an ending and the sources. Builds on facts-kids.css
   (fonts, palette, hero, buttons) and is loaded only on that page. The dark
   theme is kids-apollo-dark.css, linked like facts-kids-dark.css. */

.story {
  --s-card: #fff4cc;
  --s-card-ink: #2a1606;
  --s-card-edge: #f0b400;
  --s-flag: #ff5d73;
  --s-paper: #ffffff;
  --s-paper-ink: #1b2350;
}

/* ---- Pages ---- */
.story-pages {
  list-style: none;
  margin: clamp(22px, 4vw, 44px) 0 0;
  padding: 0;
  display: grid;
  gap: clamp(22px, 4vw, 40px);
}
.story-page {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
  overflow: hidden;
  border-radius: 28px;
  background: var(--f-card);
  box-shadow: 0 0 0 1px var(--f-line), 0 18px 36px -26px var(--f-shadow);
  scroll-margin-top: 16px;
  transition: box-shadow 0.25s;
}
/* Pictures alternate sides, like facing pages. */
.story-page.is-flipped .story-art { order: 2; }
.story-page.is-reading { box-shadow: 0 0 0 4px var(--f-focus), 0 18px 36px -22px var(--f-shadow); }

/* The picture sits framed on a tinted panel as tall as the text beside it. */
.story-art {
  display: grid;
  place-items: center;
  padding: clamp(12px, 2vw, 24px);
  background: linear-gradient(160deg, var(--f-ta), var(--f-tb));
}
.story-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 20px;
  background: #0b1130;
  box-shadow: 0 14px 28px -18px var(--f-shadow);
}
.story-frame > svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

.story-text {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: clamp(18px, 3vw, 32px);
  background: linear-gradient(170deg, var(--f-tb), var(--f-card) 62%);
}
.story-text h2 { font: 600 clamp(1.6rem, 3vw, 2.15rem)/1.1 var(--f-heading); text-wrap: balance; }
.story-words { font-size: clamp(1.05rem, 1.4vw, 1.16rem); line-height: 1.6; }
.story-extras { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px; margin-top: auto; }

/* The fact card: one number worth remembering. */
.story-wow {
  flex: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 128px;
  max-width: 160px;
  padding: 12px 16px 12px 14px;
  border-left: 5px solid var(--s-card-edge);
  border-radius: 6px 14px 14px 6px;
  background: var(--s-card);
  color: var(--s-card-ink);
}
.story-wow-n { font: 600 1.5rem/1.05 var(--f-heading); }
.story-wow-l { margin-top: 4px; font-size: 0.85rem; line-height: 1.25; }

/* A real NASA photo, as a snapshot. */
.story-photo {
  flex: 0 1 180px;
  margin: 0;
  padding: 8px 8px 10px;
  border-radius: 4px;
  background: var(--s-paper);
  box-shadow: 0 12px 24px -14px rgb(0 0 0 / 0.5);
  transform: rotate(1.2deg);
  transition: transform 0.2s;
}
.story-photo:hover { transform: rotate(0deg) scale(1.02); }
.story-photo a { display: block; }
.story-photo img { display: block; width: 100%; height: auto; border-radius: 2px; }
.story-photo figcaption { margin-top: 7px; color: var(--s-paper-ink); text-align: center; font: 600 0.82rem/1.25 var(--f-heading); }

/* The landing sites on the real Moon. */
.story-map .story-frame { background: #03040e; }
.story-disk { position: absolute; top: 4%; left: 15.5%; width: 69%; height: 92%; }
.story-disk img, .story-disk svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.story-flag .story-pole { stroke: #eef0f6; stroke-width: 5; stroke-linecap: round; }
.story-flag rect { fill: var(--s-flag); stroke: #ffffff; stroke-width: 3.5; }
.story-flag text { fill: #ffffff; font-family: var(--f-heading); font-size: 36px; font-weight: 600; }
.story-flag circle { fill: #ffd447; stroke: #1b2350; stroke-width: 2.5; }
.story-sites {
  flex: 1 1 260px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.98rem;
  line-height: 1.3;
}
.story-sites li { display: flex; align-items: center; gap: 8px; }
.story-site-n {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 22px;
  border-radius: 5px;
  background: var(--s-flag);
  color: #ffffff;
  font: 600 0.85rem/1 var(--f-heading);
}

/* Read-aloud button, page number and sources, along the bottom of the page. */
.story-foot {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
  border-top: 2px dashed var(--f-line);
}
.story-read {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px 0 10px;
  border: 0;
  border-radius: 999px;
  background: var(--f-btn);
  color: var(--f-btn-ink);
  box-shadow: 0 3px 0 var(--f-btn-shadow);
  cursor: pointer;
  white-space: nowrap;
  font: 600 0.95rem/1 var(--f-heading);
}
.story-read[hidden] { display: none; }
.story-read:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--f-btn-shadow); }
.story-read[aria-pressed="true"], .story-cover [data-action="read-all"][aria-pressed="true"] { background: #ff5d73; color: #ffffff; box-shadow: 0 3px 0 #c43a50; }
.story-ico { flex: none; width: 20px; height: 20px; }
.story-ico-box { fill: currentColor; }
.story-ico-wave { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.story-num { grid-column: 2; justify-self: center; color: var(--f-text2); font: 600 0.92rem/1 var(--f-heading); white-space: nowrap; }
.story-info {
  grid-column: 3;
  justify-self: end;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--f-line);
  border-radius: 50%;
  background: transparent;
  color: var(--f-text2);
  cursor: pointer;
  font: 600 1rem/1 var(--f-heading);
}
.story-info:hover, .story-info[aria-expanded="true"] { color: var(--text); border-color: var(--f-focus); }

/* The (i) popover: where a page's facts come from. Without script the
   browser centers it; the storybook island anchors it under its button. */
.story-pop {
  width: min(340px, calc(100vw - 24px));
  padding: 14px 16px;
  border: 1px solid var(--f-line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.2);
  font-size: 0.88rem;
  line-height: 1.45;
}
.story-pop.is-anchored { position: fixed; inset: auto; margin: 0; }
.story-pop::backdrop { background: transparent; }
.story-pop-h { color: var(--f-text2); font: 600 0.85rem/1.2 var(--f-heading); }
.story-pop ol { margin: 8px 0 0; padding-left: 1.7em; }
.story-pop li + li { margin-top: 6px; }
.story-pop li::marker { color: var(--muted); }
.story-pop a { color: var(--text); }
.story-pop span { display: block; color: var(--muted); }
.story-pop .story-all { display: inline-block; margin-top: 10px; color: var(--muted); font-size: 0.8rem; }

/* ---- The end, the link to the Moon facts, sources ---- */
.story-end {
  margin-top: clamp(30px, 5vw, 56px);
  padding: clamp(18px, 3vw, 34px) 16px clamp(24px, 4vw, 40px);
  border-radius: 30px;
  background: linear-gradient(180deg, var(--f-sky1), var(--f-sky2) 60%, var(--f-sky3));
  color: var(--f-hero-ink);
  text-align: center;
}
.story-end svg { display: block; width: min(340px, 86%); height: auto; margin: 0 auto; }
.story-end h2 { font: 600 clamp(2.4rem, 6vw, 3.4rem)/1 var(--f-heading); }
.story-end p { margin-top: 8px; font-size: 1.1rem; }
.story-end .facts-cta { margin-top: 18px; }

.story-sources { margin-top: 28px; color: var(--muted); font-size: 0.9rem; }
.story-sources summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; min-height: 44px; padding-top: 10px; cursor: pointer; list-style: none; }
.story-sources summary::-webkit-details-marker { display: none; }
.story-sources summary::before { content: "▸"; color: var(--text); }
.story-sources details[open] summary::before { content: "▾"; }
.story-sources h2 { display: inline; color: var(--text); font: 600 1rem/1.2 var(--f-heading); }
.story-sources ol { display: grid; gap: 6px; margin: 8px 0 0; padding-left: 1.9em; }
.story-sources a { color: var(--text); text-underline-offset: 3px; }
.story-sources p { margin-top: 12px; }

@media (max-width: 760px) {
  .story-page { grid-template-columns: minmax(0, 1fr); border-radius: 24px; }
  .story-page.is-flipped .story-art { order: 0; }
  .story-art { padding: 10px 10px 0; background: var(--f-card); }
  .story-frame { border-radius: 16px; }
  .story-text { background: var(--f-card); }
}
@media (prefers-reduced-motion: reduce) {
  .story-page, .story-photo { transition: none; }
  .story-photo:hover { transform: rotate(1.2deg); }
}
