/* =========================================================================
 * Storytime Theater · the scrolling stories  (assets/css/kids-story-scroll.css)
 * includes/views/kids-story.php · data & art: includes/kids-story-scroll.php · camera: assets/js/kids-story-scroll.js
 *
 * An always-dark page in both themes (it sets its own Temple Dark tokens: ivory #FCFBF7 and gold on deep night glass,
 * far above AA), like the Storytime Theater's stage band.
 *   - .kss-stage: sticky, one viewport tall (100svh), pulled up under the story by a negative margin, clipped
 *     (overflow: clip), so the 4:1 world (.kss-world, height 100%, width 400% of the height: about 500 phone widths)
 *     never widens the page. The world is moved only by transform (translate3d + scale from its top-left corner);
 *     will-change is set by the script only while the camera moves, so the art re-rasterises sharp when it settles.
 *     Without JavaScript a CSS transform frames Act 1's focus (x 1035 of 6000 = 69% of the stage height).
 *   - Ambient light (.kss-ov: the lamp, the three doorways, the presence under the banyan, the dawn, a lit window,
 *     fireflies) is HTML laid over the world at the same world coordinates (left / top in % of the world), so its gentle
 *     motion is composited and never repaints the big SVG. It moves only when the script marks the page .is-alive
 *     (motion welcome and "Keep the stage still" not pressed) and never under prefers-reduced-motion.
 *   - The traveller (.kss-hero) stands on a dark ridge in the foreground; it bobs (@keyframes kss-float) and leans with
 *     the camera's speed; under reduced motion it stands still.
 *   - The story (.kss-track) scrolls over the stage: one panel per card, at least one viewport tall, its card on dark
 *     glass (right-hand column from 900px, full width on phones), body text 18px+ for reading aloud.
 * Phones first: no horizontal scroll at 320px (.kss is overflow-x: clip), every control at least 44px, buttons
 * position: relative.
 * ========================================================================= */

.kss {
  --ink: #FCFBF7; --muted: #DCCFBE; --gold: #F2B54C; --gold-hi: #FFE7A0; --focus: #FCD34D;
  --glass: rgba(11, 10, 24, 0.84); --glass-line: rgba(242, 181, 76, 0.32);
  position: relative; isolation: isolate; color: var(--ink); color-scheme: dark; background: #07091A;
  overflow-x: hidden; overflow-x: clip; padding: 0;
}
.kss :where(h1, h2, h3) { color: var(--ink); }

/* ---------------------------------------------------------------- the stage */
.kss-stage {
  position: sticky; top: 0; z-index: 0; height: 100vh; height: 100svh; margin-bottom: -100vh; margin-bottom: -100svh;
  overflow: hidden; overflow: clip; pointer-events: none; contain: strict; width: 100%;
  background: linear-gradient(180deg, #0B0C26 0%, #15132A 58%, #0C0B12 100%);
}
.kss-world { position: absolute; left: 0; top: 0; height: 100%; aspect-ratio: 4 / 1; width: auto; transform-origin: 0 0;
  transform: translate3d(min(0px, calc(40vw - 69svh)), 0, 0); }
.kss-world.is-moving { will-change: transform; }
.kss-world__svg { display: block; width: 100%; height: 100%; }
.kss-vignette { position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(5, 6, 16, 0.55) 0%, transparent 22%, transparent 70%, rgba(5, 6, 14, 0.45) 100%),
              radial-gradient(130% 90% at 50% 45%, transparent 55%, rgba(4, 4, 12, 0.55) 100%); }
/* the foreground ridge the traveller stands on */
.kss-fore { position: absolute; left: -10%; right: -10%; bottom: 0; height: 15svh;
  background:
    radial-gradient(60% 120% at 22% 120%, #06050A 62%, transparent 63%),
    radial-gradient(70% 110% at 78% 135%, #08070D 60%, transparent 61%),
    linear-gradient(180deg, transparent 55%, #050409 100%); }

/* ---------------------------------------------------------------- ambient light over the world (world coordinates) */
.kss-ov { position: absolute; border-radius: 50%; aspect-ratio: 1; pointer-events: none; }
.kss-ov--lamp { left: calc(865 / 6000 * 100%); top: calc(810 / 1500 * 100%); width: calc(340 / 6000 * 100%);
  background: radial-gradient(closest-side, rgba(255, 226, 150, 0.55), rgba(245, 158, 11, 0.18) 55%, transparent); }
.kss-ov--soot { left: calc(960 / 6000 * 100%); top: calc(790 / 1500 * 100%); width: calc(220 / 6000 * 100%);
  background: conic-gradient(from 0deg, rgba(60, 56, 70, 0.0), rgba(90, 84, 98, 0.42), rgba(60, 56, 70, 0.0) 35%, rgba(90, 84, 98, 0.36) 60%, rgba(60, 56, 70, 0) 80%);
  -webkit-mask: radial-gradient(closest-side, #000 55%, transparent); mask: radial-gradient(closest-side, #000 55%, transparent); }
.kss-ov--door { top: calc(690 / 1500 * 100%); width: calc(480 / 6000 * 100%); opacity: 0.55; transition: opacity 0.6s ease, transform 0.6s ease; }
.kss-ov--satya { left: calc(1960 / 6000 * 100%); background: radial-gradient(closest-side, rgba(255, 231, 160, 0.7), rgba(246, 195, 91, 0.2) 60%, transparent); }
.kss-ov--dharma { left: calc(2260 / 6000 * 100%); background: radial-gradient(closest-side, rgba(255, 208, 176, 0.7), rgba(240, 138, 93, 0.2) 60%, transparent); }
.kss-ov--shanti { left: calc(2560 / 6000 * 100%); background: radial-gradient(closest-side, rgba(201, 240, 255, 0.7), rgba(111, 198, 232, 0.2) 60%, transparent); }
.kss[data-door] .kss-ov--door { opacity: 0.25; }
.kss[data-door="satya"] .kss-ov--satya, .kss[data-door="dharma"] .kss-ov--dharma, .kss[data-door="shanti"] .kss-ov--shanti { opacity: 1; transform: scale(1.18); }
.kss-ov--presence { left: calc(3550 / 6000 * 100%); top: calc(760 / 1500 * 100%); width: calc(520 / 6000 * 100%);
  background: radial-gradient(closest-side, rgba(255, 250, 235, 0.85), rgba(255, 231, 176, 0.4) 40%, rgba(246, 195, 91, 0.1) 70%, transparent); }
.kss-ov--sun { left: calc(4020 / 6000 * 100%); top: calc(405 / 1500 * 100%); width: calc(1000 / 6000 * 100%);
  background: radial-gradient(closest-side, rgba(255, 236, 180, 0.45), rgba(247, 166, 90, 0.14) 55%, transparent); }
/* schema patch 39.09: the Guru's presence as light over its pillar (Makhan Shah: the simple room at Bakala; King Janak: the dawn terrace) */
.kss-ov--divine { width: calc(560 / 6000 * 100%); background: radial-gradient(closest-side, rgba(255, 248, 230, 0.75), rgba(255, 217, 138, 0.32) 45%, rgba(246, 195, 91, 0.08) 75%, transparent); }
.kss-ov--divine-makhan-shah { left: calc(3570 / 6000 * 100%); top: calc(560 / 1500 * 100%); }
.kss-ov--divine-touchstone-truth { left: calc(4020 / 6000 * 100%); top: calc(600 / 1500 * 100%); }
.kss-ov--home { left: calc(5070 / 6000 * 100%); top: calc(770 / 1500 * 100%); width: calc(320 / 6000 * 100%);
  background: radial-gradient(closest-side, rgba(255, 218, 140, 0.4), transparent); }
.kss-ov--fly { width: calc(16 / 6000 * 100%); min-width: 4px; background: radial-gradient(closest-side, #FFF3C4, rgba(255, 231, 160, 0.5) 50%, transparent); }
.kss-ov--f1 { left: calc(180 / 6000 * 100%); top: calc(880 / 1500 * 100%); }
.kss-ov--f2 { left: calc(520 / 6000 * 100%); top: calc(950 / 1500 * 100%); }
.kss-ov--f3 { left: calc(1400 / 6000 * 100%); top: calc(900 / 1500 * 100%); }
.kss-ov--f4 { left: calc(5000 / 6000 * 100%); top: calc(960 / 1500 * 100%); }
.kss-ov--f5 { left: calc(5560 / 6000 * 100%); top: calc(890 / 1500 * 100%); }
.kss-ov--f6 { left: calc(5820 / 6000 * 100%); top: calc(1000 / 1500 * 100%); }

@media (prefers-reduced-motion: no-preference) {
  .kss.is-alive .kss-ov--lamp { animation: kss-flicker 2.8s ease-in-out infinite alternate; }
  .kss.is-alive .kss-ov--soot { animation: kss-swirl 16s linear infinite; }
  .kss.is-alive .kss-ov--presence, .kss.is-alive .kss-ov--divine { animation: kss-breathe 6s ease-in-out infinite; }
  .kss.is-alive .kss-ov--sun { animation: kss-breathe 9s ease-in-out infinite; }
  .kss.is-alive .kss-ov--home { animation: kss-flicker 4s ease-in-out infinite alternate; }
  .kss.is-alive .kss-ov--fly { animation: kss-drift 7s ease-in-out infinite alternate; }
  .kss.is-alive .kss-ov--f2, .kss.is-alive .kss-ov--f5 { animation-duration: 9s; animation-delay: -3s; }
  .kss.is-alive .kss-ov--f3, .kss.is-alive .kss-ov--f6 { animation-duration: 11s; animation-delay: -6s; }
  .kss.is-alive .kss-hero__bob { animation: kss-float 3.8s ease-in-out infinite; }
  .kss.is-alive .kss-hero__shadow { animation: kss-shadow 3.8s ease-in-out infinite; }
}
@keyframes kss-flicker { 0% { opacity: 0.75; transform: scale(0.97); } 40% { opacity: 1; transform: scale(1.03); } 100% { opacity: 0.85; transform: scale(1); } }
@keyframes kss-swirl { to { transform: rotate(360deg); } }
@keyframes kss-breathe { 0%, 100% { opacity: 0.7; transform: scale(0.94); } 50% { opacity: 1; transform: scale(1.06); } }
@keyframes kss-drift { 0% { transform: translate(0, 0); opacity: 0.3; } 50% { opacity: 1; } 100% { transform: translate(260%, -320%); opacity: 0.5; } }
@keyframes kss-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7%); } }
@keyframes kss-shadow { 0%, 100% { transform: scaleX(1); opacity: 0.55; } 50% { transform: scaleX(0.82); opacity: 0.35; } }

/* ---------------------------------------------------------------- the traveller */
.kss-hero { position: absolute; z-index: 2; left: clamp(10px, 8vw, 180px); bottom: 4.5svh; width: clamp(64px, 12.5svh, 168px); }
.kss-hero__lean { transform-origin: 50% 100%; }
.kss-hero__svg { display: block; width: 100%; height: auto; overflow: visible; filter: drop-shadow(0 0 18px rgba(255, 214, 140, 0.18)); }
.kss-hero--deer, .kss-hero--pot { width: clamp(72px, 14svh, 170px); }
.kss-hero--king { width: clamp(84px, 16svh, 200px); } /* seated: wider than tall (viewBox 220 × 210) */
.kss-hero--deer .kss-hero__svg { transform: scaleX(-1); }
.kss-hero__shadow { position: absolute; left: 18%; right: 18%; bottom: -4px; height: 10px; border-radius: 50%; background: rgba(0, 0, 0, 0.6); filter: blur(3px); opacity: 0.55; z-index: -1; }

/* ---------------------------------------------------------------- the story panels */
.kss-track { position: relative; z-index: 1; }
.kss-panel { position: relative; display: flex; align-items: center; min-height: 100vh; min-height: 100svh;
  padding: calc(var(--header-h, 72px) + 20px) max(var(--gutter, 16px), 16px) 22svh; }
.kss-panel + .kss-panel, .kss-act + .kss-panel { margin-top: -6svh; }
.kss-act { display: block; }
.kss-card {
  position: relative; width: 100%; max-width: 34rem; padding: clamp(20px, 3vw, 32px) clamp(18px, 3vw, 34px);
  border-radius: 22px; border: 1px solid var(--glass-line); background: var(--glass);
  box-shadow: 0 1px 0 rgba(255, 241, 191, 0.07) inset, 0 30px 60px -30px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(0, 0, 0, 0.25);
}
@media (min-width: 900px) {
  .kss-panel { justify-content: flex-end; padding-right: max(5vw, var(--gutter, 24px)); padding-bottom: 12svh; }
  .kss-panel--intro { justify-content: flex-start; padding-left: max(5vw, var(--gutter, 24px)); }
  .kss-card--intro { max-width: 40rem; }
  .kss-panel--intro .kss-card { margin-left: max(0px, calc(15vw - 60px)); }
}
@media (min-width: 600px) and (max-width: 899.98px) { .kss-panel { justify-content: center; } }
@media (max-width: 899.98px) {
  .kss-panel { align-items: flex-end; padding-bottom: 19svh; }
  .kss-panel--intro { align-items: center; padding-bottom: 26svh; }
}

/* the cards fade in as they arrive (only once the script runs: without it everything is simply shown) */
.kss.is-ready .kss-card { opacity: 0; transform: translateY(26px); transition: opacity 0.7s ease, transform 0.7s cubic-bezier(.2, .7, .2, 1); }
.kss.is-ready .kss-panel.is-in .kss-card { opacity: 1; transform: none; }

.kss-crumbs ol { display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 0 0 14px; padding: 0; list-style: none; font-size: 0.9rem; color: var(--muted); }
.kss-crumbs li + li::before { content: "/"; margin-right: 8px; opacity: 0.6; }
.kss-crumbs a { color: var(--muted); text-underline-offset: 0.2em; display: inline-block; padding-block: 10px; margin-block: -10px; }
.kss-crumbs [aria-current] { color: var(--ink); }
.kss-eyebrow { margin: 0 0 8px; font: 700 0.8rem/1.4 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
.kss-title { margin: 0 0 10px; font-family: var(--serif); font-weight: 600; font-size: clamp(2.2rem, 1.5rem + 3.2vw, 3.6rem); line-height: 1.04; letter-spacing: -0.01em; text-wrap: balance;
  background: linear-gradient(180deg, #FFF8E1 10%, #F6D27A 60%, #E8A93A 95%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
@media (forced-colors: active) { .kss-title { -webkit-text-fill-color: CanvasText; background: none; } }
.kss-value { margin: 0 0 12px; font: 600 1rem/1.4 var(--sans); color: var(--gold-hi); }
.kss-term { color: var(--muted); font-weight: 500; }
.kss-lead { margin: 0 0 14px; font-family: var(--serif); font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem); line-height: 1.45; }
.kss-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 10px; font-size: 0.95rem; color: var(--muted); }
.kss-time { font-weight: 700; color: var(--ink); font-variant-numeric: lining-nums tabular-nums; }
.kss-how { margin: 0 0 16px; font-size: 1rem; line-height: 1.55; color: var(--muted); }
.kss-act__title { margin: 0 0 12px; font-family: var(--serif); font-weight: 600; font-size: clamp(1.7rem, 1.35rem + 1.6vw, 2.4rem); line-height: 1.1; text-wrap: balance; }
.kss-count { margin: 0 0 8px; font: 600 0.82rem/1.3 var(--sans); color: var(--muted); font-variant-numeric: lining-nums tabular-nums; }
.kss-text { margin: 0; font-size: clamp(1.125rem, 1.06rem + 0.3vw, 1.25rem); line-height: 1.7; color: var(--ink); text-wrap: pretty; }
.kss-card--apply { border-color: rgba(147, 170, 255, 0.4); background: rgba(9, 12, 34, 0.86); }
.kss-card--apply .kss-eyebrow { color: #C9D4FF; }
.kss-card--moral { text-align: center; }
.kss-moral { margin: 0 0 14px; font-family: var(--serif); font-size: clamp(1.45rem, 1.2rem + 1.1vw, 1.95rem); line-height: 1.4; color: var(--gold-hi); text-wrap: balance; }
.kss-source { margin: 0; font-size: 0.9rem; color: var(--muted); }
.kss-note { margin: 18px 0 0; font-size: 0.92rem; line-height: 1.55; color: var(--muted); }

/* buttons and links: at least 44px, position: relative (the app gives buttons a ::after touch target) */
.kss-actions { display: flex; flex-wrap: wrap; gap: 10px 12px; margin-top: 6px; }
.kss-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 0.45em; min-height: 48px; padding: 0 20px;
  border-radius: 999px; border: 1px solid rgba(242, 181, 76, 0.5); background: rgba(26, 18, 20, 0.7); color: var(--ink);
  font: 700 1rem/1.1 var(--sans); text-decoration: none; cursor: pointer;
}
.kss-btn--gold { color: #2A0A14; border-color: transparent; background: linear-gradient(135deg, #F8D888 0%, #E7AE45 52%, #C98A22 100%); }
.kss-btn--quiet { font-weight: 600; font-size: 0.92rem; }
.kss-btn[aria-pressed="true"] { border-color: var(--gold); background: rgba(120, 18, 43, 0.7); }
.kss-btn[hidden] { display: none; }
.kss-btn:focus-visible, .kss-choice__btn:focus-visible, .kss a:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
  .kss-btn:hover { border-color: var(--gold); }
  .kss-btn--gold:hover { filter: brightness(1.06); }
}
.kss-more { display: grid; gap: 4px; margin: 16px 0 0; padding: 0; list-style: none; }
.kss-more a { display: inline-flex; align-items: center; gap: 0.4em; min-height: 44px; color: var(--gold); font-weight: 600; text-underline-offset: 0.2em; }

/* ---------------------------------------------------------------- the crossroads */
.kss-question { margin: 0 0 8px; font-family: var(--serif); font-weight: 600; font-size: clamp(1.5rem, 1.25rem + 1.2vw, 2.05rem); line-height: 1.2; text-wrap: balance; }
.kss-hint { margin: 0 0 14px; font-size: 1rem; line-height: 1.5; color: var(--muted); }
.kss-choices { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.kss-choice { --c: #F6C35B; border-radius: 16px; border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); background: color-mix(in srgb, var(--c) 9%, rgba(11, 10, 24, 0.6)); }
.kss-choice--dharma { --c: #F08A5D; }
.kss-choice--shanti { --c: #6FC6E8; }
.kss-choice__btn {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 16px; border: 0; border-radius: 16px;
  background: none; color: var(--ink); font: 700 1.08rem/1.3 var(--sans); text-align: left; cursor: pointer;
}
.kss-choice__icon { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; background: color-mix(in srgb, var(--c) 22%, transparent); font-size: 1.1rem; }
.kss-choice__label { flex: 1 1 auto; }
.kss-choice__chev { flex: none; width: 12px; height: 12px; border-right: 2.5px solid var(--c); border-bottom: 2.5px solid var(--c); transform: rotate(45deg) translate(-3px, -3px); transition: transform 0.25s ease; }
.kss-choice__btn[aria-expanded="true"] .kss-choice__chev { transform: rotate(-135deg) translate(-2px, -2px); }
.kss-choice__cons { padding: 0 16px 16px 64px; }
.kss-choice__cons[hidden] { display: none; }
.kss-choice__cons .kss-text { font-size: clamp(1.125rem, 1.06rem + 0.25vw, 1.2rem); }
@media (max-width: 479.98px) { .kss-choice__cons { padding-left: 16px; } }
@media (hover: hover) and (pointer: fine) { .kss-choice__btn:hover { background: color-mix(in srgb, var(--c) 12%, transparent); } }

/* "Keep the stage still": no fades either */
.kss.is-still .kss-card { transition: none; }

@media (prefers-reduced-motion: reduce) {
  .kss .kss-ov, .kss .kss-hero__bob, .kss .kss-hero__shadow { animation: none !important; }
  .kss.is-ready .kss-card { transform: none; transition: opacity 0.01s; }
  .kss-ov--door, .kss-choice__chev { transition: none; }
}
