/* The bedtime-pilot story pages (.lamplit), loaded alongside base.css.
 * Browse state: the same storybook library as every other page (walnut
 * header, a leather book around an aged paper page, a framed picture plate),
 * built from base.css's tokens, so it follows the system theme with them.
 * The night reader: a full-screen overlay that is always night, in its own
 * fixed palette:
 *   Inkwell #1C2340   Quilt #121729   Lamplight #F0B45A
 *   Moonpaper #EFE6CF Dusk #53669E    Puppet #0A0D1A
 * Contrast: Moonpaper/Quilt 14.31:1, Lamplight/Quilt 9.64:1, ribbon ink
 * #FBF1DC on crimson 8.0:1 and on moss 9.0:1. Silhouettes never sit straight
 * on Quilt (1.09:1), always on the Dusk backdrop layer. */

.lamplit {
  --lp-inkwell: #1c2340;
  --lp-quilt: #121729;
  --lp-lamplight: #f0b45a;
  --lp-moonpaper: #efe6cf;
  --lp-dusk: #53669e;
  --lp-puppet: #0a0d1a;
  --f-display: var(--display);
  --f-read: var(--serif);
  --f-ui: var(--serif);
  font-family: var(--f-ui);
  color: var(--ink);
}
.lamplit .lp-main a { color: var(--link); }
.lamplit .lp-main .volume-nav a { color: #2a1b10; }
.lamplit .skip-link { color: #fbf1dc; }
.lamplit .lp-main .fine { color: var(--ink-faint); }

/* the reader's focus ring: Lamplight, 9.64:1 on Quilt */
.lamplit .lp-reader a:focus-visible,
.lamplit .lp-reader button:focus-visible {
  outline-color: var(--lp-lamplight);
}

.lp-main { max-width: 760px; margin: 0 auto; padding: 0 1rem 1rem; }
.lp-book { margin-top: 1rem; }

/* ---------- the picture plate: the cover art, framed and tipped in ---------- */
.lp-cover {
  position: relative; overflow: hidden; background: var(--lp-dusk); aspect-ratio: 16 / 9;
}
.lp-cover svg { display: block; width: 100%; height: 100%; }
.lp-plate {
  margin: 0.2rem 0 1rem; border-radius: 2px;
  border: 3px double var(--gilt);
  box-shadow: 0 0 0 4px var(--card), 0 0 0 5px var(--line), 0 4px 10px rgba(40, 20, 5, 0.3);
}

.lp-title {
  font-family: var(--f-display); font-weight: 400; font-size: clamp(1.6rem, 5vw, 2.3rem); line-height: 1.18;
  margin: 1rem 0 0.4rem; color: var(--ink); text-align: center;
}
.lp-book .lp-title::after {
  content: ""; display: block; width: 8rem; height: 12px; margin: 0.35rem auto 0;
  background:
    radial-gradient(circle, var(--crimson) 0 3px, transparent 3.5px) center / 12px 12px no-repeat,
    linear-gradient(90deg, transparent, var(--ink-faint) 30%, var(--ink-faint) 70%, transparent) center / 100% 1px no-repeat;
}
/* the chips: three paper library tags */
.lp-chiprow { display: flex; gap: 0.45rem; flex-wrap: wrap; justify-content: center; margin: 0.5rem 0 0.9rem; }
.lp-chip {
  font-family: var(--f-ui); font-size: 0.8rem; font-style: italic; font-weight: 600; line-height: 1.2;
  padding: 0.25rem 0.7rem 0.25rem 1.35rem; border-radius: 3px; color: var(--ink);
  border: 1px solid var(--ink-faint); box-shadow: 0 1px 2px rgba(40, 20, 5, 0.18);
  background: radial-gradient(circle at 0.6rem 50%, var(--paper) 0 3px, var(--ink-faint) 3.5px 4.5px, transparent 5px), var(--card);
}

/* starring: the bookplate */
.lp-starring {
  display: flex; align-items: center; justify-content: center; gap: 0.4rem 0.8rem; flex-wrap: wrap; text-align: center;
  margin: 0 0 0.9rem; padding: 0.4rem 0.7rem; font-size: 0.98rem;
  background: var(--card); border: 1.5px solid var(--ink-soft); border-radius: 3px;
  box-shadow: inset 0 0 0 3px var(--card), inset 0 0 0 4px var(--line);
}
.lp-starring b { font-family: var(--f-display); font-weight: 400; font-size: 1.08rem; }
.lp-personalize-btn {
  font-family: var(--f-ui); font-weight: 600; font-style: italic; font-size: 0.9rem; color: var(--link);
  background: none; border: 0; border-bottom: 1.5px solid currentColor; border-radius: 0; padding: 0.3rem 0.1rem;
  cursor: pointer; min-height: 44px;
}
.lp-personalize-btn:hover { border-bottom-width: 3px; }

.lp-personalize {
  background: var(--card); border: 1px solid var(--line); border-radius: 3px;
  padding: 1rem 1.1rem; margin: 0 0 1.1rem; display: grid; gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  box-shadow: 0 2px 6px rgba(40, 20, 5, 0.15);
}
.lp-personalize .lp-field { display: flex; flex-direction: column; gap: 0.3rem; }
.lp-personalize label { font-family: var(--f-display); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.lp-personalize input, .lp-personalize select {
  font: inherit; font-size: 1rem; padding: 0.5rem 0.6rem; border-radius: 3px;
  border: 1px solid var(--ink-faint); background: var(--paper); color: var(--ink); min-height: 44px;
}
.lp-personalize .lp-actions { grid-column: 1 / -1; display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* buttons: the leather spine label and the paper tag, as base.css's .btn */
.lp-actions-row { display: flex; gap: 0.7rem; flex-wrap: wrap; justify-content: center; margin: 0 0 1.2rem; }
.lp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 44px; cursor: pointer;
  font-family: var(--f-display); font-weight: 400; font-size: 1.02rem; line-height: 1.2;
  padding: 0.65rem 1.4rem; border-radius: 4px; border: 1px solid transparent;
}
.lp-btn-begin {
  min-width: 9rem; color: var(--gilt-text); border-color: var(--gilt);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(0, 0, 0, 0.22)), var(--crimson);
  box-shadow: inset 0 0 0 3px var(--crimson), inset 0 0 0 4px rgba(242, 213, 140, 0.55), 0 2px 4px rgba(40, 20, 5, 0.35);
}
.lp-btn-begin:hover { filter: brightness(1.12); }
.lp-btn-outline {
  color: var(--ink); border: 1.5px solid var(--ink-soft); padding-left: 1.8rem; box-shadow: 0 1px 2px rgba(40, 20, 5, 0.2);
  background: radial-gradient(circle at 0.85rem 50%, var(--paper) 0 4px, var(--ink-faint) 4.5px 5.5px, transparent 6px), var(--card);
}
.lp-btn-outline:hover { background-color: var(--paper-edge); }
.lp-btn[hidden] { display: none; }

.lp-prose { font-family: var(--f-read); font-size: 1.1rem; line-height: 1.72; color: var(--ink); }
.lp-prose p { margin: 0 0 1.05rem; max-width: none; }
.lp-prose h2 { font-family: var(--f-display); font-weight: 400; font-size: 1.3rem; margin: 1.6rem 0 0.6rem; }
@media (max-width: 480px) { .lp-prose { font-size: 1.04rem; line-height: 1.66; } }
/* the illuminated capital, as on the home page */
.lp-book .lp-prose > p:first-child::first-letter {
  float: left; font-family: var(--display); font-weight: 400; font-size: 3.15em; line-height: 0.92;
  margin: 0.1em 0.16em 0 0; padding: 0.14em 0.16em 0.1em;
  color: var(--gilt-text); text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
  background:
    radial-gradient(circle at 18% 18%, rgba(242, 213, 140, 0.55) 0 2px, transparent 2.5px),
    radial-gradient(circle at 82% 82%, rgba(242, 213, 140, 0.55) 0 2px, transparent 2.5px),
    linear-gradient(135deg, #a32a3a, #6a1420);
  border: 3px double var(--gilt); border-radius: 3px;
}
/* a wax seal under the last line */
.lp-book .lp-prose > p:last-child::after {
  content: ""; display: block; width: 52px; height: 52px; margin: 1.3rem auto 0.2rem; border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 14px, rgba(0, 0, 0, 0.22) 14.5px 16px, transparent 16.5px),
    radial-gradient(circle at 36% 32%, #c9404c, #8c1d2c 55%, #5c0f18);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35), 3px -2px 0 -1px #8c1d2c, -3px 3px 0 -1px #7a1824;
}
.lp-foot-link { margin: 1.4rem auto 0; }

/* ---------- the night reader ---------- */
.lp-reader {
  position: fixed; inset: 0; z-index: 500; background: var(--lp-quilt); color: var(--lp-moonpaper);
  display: flex; flex-direction: column;
}
.lp-reader[hidden] { display: none; }
.lp-reader.lp-big .lp-reader-text { font-size: 1.5em; }
.lp-reader.lp-dim { filter: brightness(0.78); }
.lp-reader-stars {
  display: flex; gap: 0.3rem; justify-content: center; padding: calc(env(safe-area-inset-top, 0px) + 0.5rem) 1rem 0.3rem;
  font-size: 0.9rem;
}
.lp-star { opacity: 0.25; color: var(--lp-moonpaper); }
.lp-star.lit { opacity: 1; color: var(--lp-lamplight); }
.lp-reader-scene { position: relative; flex: 0 0 38vh; min-height: 9rem; background: var(--lp-dusk); overflow: hidden; display: flex; justify-content: center; }
/* The art is a fixed 16:9 (viewBox 400x225, silhouettes.js). The scene band
   is 16:9 itself only near phone width; at 768-1280 it widens to as much as
   ~4.2:1 (a fixed-vh band under a full-viewport-width reader), and width:
   100%/height: 100% stretched the art to fill that, so the <svg>'s own
   preserveAspectRatio="xMidYMax slice" cropped the whole excess off the TOP
   -- on the moon story's reader, that was the moon itself. Sizing the <svg>
   to its own 16:9 and centering it in the (wider) band leaves slice nothing
   to crop at any width this reader ships at; the Dusk background (above)
   shows at the sides instead of the art being cropped. */
.lp-reader-scene svg { display: block; height: 100%; width: auto; max-width: 100%; aspect-ratio: 16 / 9; }
.lp-reader-body { flex: 1 1 auto; overflow-y: auto; padding: 1.1rem 1.3rem 1.4rem; }
.lp-reader-text { font-family: var(--f-read); font-size: 1.32rem; line-height: 1.58; max-width: 36ch; margin: 0 auto; }
.lp-reader-text p { margin: 0 0 1em; }
.lp-reader-fork-prompt { font-family: var(--f-display); font-weight: 400; font-size: 1.25rem; text-align: center; margin: 0 auto 1rem; max-width: 30ch; }
.lp-doors { display: flex; gap: 0.8rem; max-width: 34rem; margin: 0 auto; flex-wrap: wrap; }
/* the two doors: silk ribbon bookmarks, as the home page's choices */
.lp-door {
  --rib: var(--crimson);
  flex: 1 1 10rem; font-family: var(--f-ui); font-weight: 600; font-size: 1.02rem; line-height: 1.35; color: #fbf1dc;
  border: 0; border-radius: 2px; padding: 1.1rem 1rem; min-height: 72px; cursor: pointer; text-align: center;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(0, 0, 0, 0.2)),
    var(--rib);
  box-shadow: inset 0 5px 0 -4px rgba(251, 241, 220, 0.42), inset 0 -5px 0 -4px rgba(251, 241, 220, 0.42), 0 4px 10px rgba(0, 0, 0, 0.45);
}
.lp-door + .lp-door { --rib: var(--moss); }
.lp-door:hover, .lp-door:focus-visible { filter: brightness(1.15); }
.lp-reader-end { text-align: center; }
.lp-reader-end .lp-caption { font-family: var(--f-display); font-weight: 400; font-size: 1.15rem; max-width: 30ch; margin: 0.8rem auto 1.2rem; color: var(--lp-moonpaper); }
.lp-end-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; margin-top: 1.2rem; }
.lp-end-actions .lp-btn-outline { border-color: var(--lp-moonpaper); color: var(--lp-moonpaper); }
.lp-end-actions .lp-btn-outline:hover { background: var(--lp-moonpaper); color: var(--lp-quilt); }

.lp-thumb {
  display: flex; align-items: center; justify-content: space-between; gap: 0.3rem;
  padding: 0.5rem 0.7rem calc(env(safe-area-inset-bottom, 0px) + 0.5rem);
  background: rgba(10, 13, 26, 0.55); border-top: 1px solid rgba(239, 230, 207, 0.12);
  backdrop-filter: blur(6px);
}
.lp-thumb button {
  font-family: var(--f-ui); font-weight: 700; font-size: 0.82rem; color: var(--lp-moonpaper);
  background: none; border: 0; border-radius: 10px; padding: 0.5rem 0.6rem; min-width: 44px; min-height: 44px;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
}
.lp-thumb button:hover, .lp-thumb button:focus-visible { background: rgba(239, 230, 207, 0.12); }
.lp-thumb button[disabled] { opacity: 0.3; cursor: default; }
.lp-thumb button[aria-pressed="true"] { color: var(--lp-lamplight); }
.lp-thumb .lp-thumb-icon { font-size: 1.1rem; line-height: 1; }
.lp-close {
  position: absolute; top: calc(env(safe-area-inset-top, 0px) + 0.4rem); right: 0.6rem;
  font-family: var(--f-ui); font-weight: 700; font-size: 0.85rem; color: var(--lp-moonpaper);
  background: rgba(10, 13, 26, 0.5); border: 0; border-radius: 999px; padding: 0.45rem 0.8rem; min-height: 44px; cursor: pointer;
}

/* ---------- the stories hub: six picture books on a walnut shelf ---------- */
.lp-main.lp-hub { max-width: 1060px; }
.lp-hub .hero { text-align: center; }
.lp-hub .hero h1, .lp-hub .hero .sub { margin-left: auto; margin-right: auto; }
.lp-hub .lp-title { margin-top: 0; }
.lp-grid.bookcase { grid-template-columns: 1fr; gap: 1.6rem 0; padding: 1.1rem 0.6rem 0; }
@media (min-width: 560px) { .lp-grid.bookcase { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .lp-grid.bookcase { grid-template-columns: repeat(3, 1fr); padding: 1.6rem 0.6rem 0; gap: 2rem 0; } }
.lp-card {
  --leather: #6b1d27;
  display: flex; flex-direction: column; margin: 0 0.45rem; text-decoration: none; color: var(--ink);
  padding: 8px 9px 0 14px; border-radius: 3px 8px 0 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.45), rgba(255, 255, 255, 0.12) 7px, transparent 12px),
    repeating-radial-gradient(circle at 20% 30%, rgba(0, 0, 0, 0.07) 0 1px, transparent 1px 4px),
    var(--leather);
  border-bottom: 14px solid #7a5030;
  box-shadow: 0 7px 6px -3px rgba(0, 0, 0, 0.55), inset 0 -2px 0 #9a6a40;
  transition: transform 0.3s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.lp-book-0 { --leather: #1d4a52; }
.lp-book-1 { --leather: #5a3420; }
.lp-book-2 { --leather: #34406e; }
.lp-book-3 { --leather: #24452c; }
.lp-book-4 { --leather: #5c2238; }
.lp-book-5 { --leather: #1c4b6b; }
.lp-card:hover, .lp-card:focus-visible { text-decoration: none; transform: translateY(-6px); }
.lp-card:focus-visible { outline-color: #f2d58c; }
.lp-card .lp-cover { margin: 0; border: 2px solid rgba(242, 213, 140, 0.75); border-radius: 2px; }
/* the paper label pasted on the cover */
.lp-card-body {
  position: relative; margin: -1.2rem 0.5rem 0.6rem; padding: 0.6rem 0.75rem 0.7rem; text-align: center;
  background: #f5ecd6; color: #2a1b10; border-radius: 2px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
}
.lp-card h2 { font-family: var(--f-display); font-weight: 400; font-size: 1.12rem; line-height: 1.25; margin: 0 0 0.25rem; color: #2a1b10; }
.lp-card .lp-chiprow { margin: 0 0 0.35rem; gap: 0.35rem; }
.lp-card .lp-chip { font-size: 0.74rem; padding: 0.18rem 0.55rem 0.18rem 1.2rem; }
.lp-card .lp-chip { color: #2a1b10; background-color: #fffbf2; border-color: #6b5442; }
.lamplit .lp-card .fine { color: #4e3a2a; font-style: italic; margin: 0; }

@media (prefers-reduced-motion: no-preference) {
  .lp-reader-scene svg .lp-glow { transition: opacity 0.6s ease; }
}
