/* A Chanchin: an editorial page over the 3D sky */
body.story { display: block; padding: 0; }
.story-main, .story-footer { position: relative; }
.story-main { display: block; max-width: none; }

.story-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 4;
  padding: max(12px, env(safe-area-inset-top)) 16px 32px;
  background: linear-gradient(rgba(250,244,234,.92), rgba(250,244,234,0));
}
.back {
  display: inline-flex; align-items: center; min-height: 44px; padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--hair); background: var(--glass); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font: 600 1.05rem/1 var(--display); letter-spacing: .03em; color: var(--ink); text-decoration: none;
  transition: background .4s, translate .5s cubic-bezier(.2,.8,.2,1);
}
.back:hover { background: rgba(255,255,255,.85); }
.back:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 3px; }

/* hero */
.hero { min-height: 100svh; display: grid; place-content: center; text-align: center; padding: 110px 20px 70px; }
.kicker-line { margin: 0 0 18px; font: 600 .85rem/1 var(--display); letter-spacing: .5em; text-indent: .5em; text-transform: uppercase; color: #7a5a30; }
.hero .name {
  margin: 0; font: 400 clamp(3.4rem, 15vw, 8.5rem)/1.15 var(--script);
  background: linear-gradient(100deg, #b8862f 20%, #f7e3a8 40%, #c99a45 55%, #b8862f 80%) 0 0 / 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 12px rgba(255,255,255,.85));
  animation: shimmer 5s ease-in-out infinite;
}
.hero .dates { margin: 18px 0 0; font: 500 clamp(1rem, 3.4vw, 1.35rem)/1 var(--display); letter-spacing: .28em; color: #6d5130; }
.hero .dates span { margin: 0 .4em; color: var(--gold-deep); }
.cue { position: relative; display: block; width: 1px; height: 72px; margin: 52px auto 0; background: var(--hair); overflow: hidden; }
.cue::after { content: ''; position: absolute; left: 0; top: -40%; width: 1px; height: 40%; background: var(--gold-deep); animation: cue 2.2s ease-in-out infinite; }
@keyframes cue { to { top: 100%; } }

/* timeline: four years on a golden thread */
.timeline { position: relative; max-width: 1000px; margin: 0 auto; padding: 30px 20px 110px; display: grid; gap: clamp(64px, 12vw, 130px); }
.timeline::before { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: linear-gradient(transparent, var(--gold-deep) 12%, var(--gold-deep) 88%, transparent); opacity: .55; }
.timeline article { position: relative; width: 50%; padding: 0 clamp(24px, 5vw, 64px); }
.timeline article:nth-child(odd) { justify-self: start; text-align: right; }
.timeline article:nth-child(even) { justify-self: end; }
.timeline article::after {
  content: ''; position: absolute; top: clamp(1.6rem, 5vw, 3rem); width: 11px; height: 11px; border-radius: 50%;
  background: #fff; border: 2px solid var(--gold-deep); box-shadow: 0 0 0 6px rgba(242,202,122,.35), 0 0 24px rgba(242,202,122,.9);
}
.timeline article:nth-child(odd)::after { right: -6.5px; }
.timeline article:nth-child(even)::after { left: -6.5px; }
.year {
  margin: 0; font: 300 clamp(3.6rem, 12vw, 7rem)/1 var(--display); letter-spacing: .02em;
  background: linear-gradient(180deg, #e9c983 0%, #c3923d 55%, #9c7027 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 14px rgba(255,255,255,.9));
}
.moment { margin: 12px 0 0; font: italic 500 clamp(1.15rem, 3.6vw, 1.5rem)/1.5 var(--display); color: var(--ink); text-shadow: 0 0 14px rgba(255,255,255,.95), 0 0 2px #fff; text-wrap: balance; }
.moment-link { display: inline-block; margin-top: 14px; font: 600 .95rem/1 var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--gold-deep); text-decoration: none; border-bottom: 1px solid var(--hair); padding-bottom: 4px; }
@media (max-width: 720px) {
  .timeline::before { left: 30px; }
  .timeline article, .timeline article:nth-child(odd), .timeline article:nth-child(even) { width: auto; justify-self: stretch; text-align: left; padding: 0 0 0 48px; }
  .timeline article:nth-child(odd)::after, .timeline article:nth-child(even)::after { left: 4.5px; right: auto; }
}

/* chapters: frosted parchment panels */
.chapter { max-width: 780px; margin: 0 auto clamp(56px, 10vw, 110px); padding: 0 16px; }
.chapter.wide { max-width: 1080px; }
.panel {
  position: relative; padding: clamp(30px, 6vw, 64px) clamp(22px, 6vw, 64px);
  background: rgba(255, 251, 245, .8); -webkit-backdrop-filter: blur(18px) saturate(1.1); backdrop-filter: blur(18px) saturate(1.1);
  border: 1px solid rgba(184, 138, 58, .28); border-radius: 28px;
  box-shadow: 0 30px 80px rgba(110, 80, 35, .16), inset 0 1px 0 rgba(255,255,255,.85);
}
.chapter.wide .panel { max-width: 780px; margin: 0 auto; }
.ornament { margin: 0 0 8px; text-align: center; color: var(--gold-deep); font-size: 1.1rem; }
.panel h2 { margin: 0 0 30px; text-align: center; font: 600 clamp(1.9rem, 6vw, 2.9rem)/1.15 var(--display); color: #4f3a22; }
.panel h2::after { content: ''; display: block; width: 72px; height: 1px; margin: 22px auto 0; background: linear-gradient(90deg, transparent, var(--gold-deep), transparent); }
.panel p { margin: 0 0 1.25em; font-size: clamp(1.02rem, 2.6vw, 1.12rem); line-height: 1.9; }
.panel p:last-child { margin-bottom: 0; }
.lead::first-letter { float: left; margin: .1em .12em 0 0; font: 600 4.2em/.78 var(--display); color: var(--gold-deep); }
.quiet { background: rgba(255, 251, 245, .66); }
.quiet p { color: #5b4a38; }

.siblings { list-style: none; counter-reset: s; margin: 1.8em 0 2.2em; padding: 0; display: grid; gap: 10px; }
.siblings li {
  counter-increment: s; display: flex; align-items: baseline; gap: 16px; padding: 13px 18px; border-radius: 14px;
  background: rgba(255,255,255,.55); border: 1px solid rgba(184,138,58,.18); font: 500 1.18rem/1.35 var(--display);
}
.siblings li::before { content: counter(s, decimal-leading-zero); font: 300 1.45rem/1 var(--display); color: var(--gold-deep); }
.siblings .her { background: linear-gradient(90deg, rgba(242,202,122,.42), rgba(255,255,255,.65)); border-color: var(--gold-deep); font-weight: 600; }

.pull { margin: 1.7em 0; text-align: center; font: italic 500 clamp(1.5rem, 5vw, 2.2rem)/1.35 var(--display); color: var(--gold-deep); }
.pull::before { content: '“'; }
.pull::after { content: '”'; }

.chips { list-style: none; margin: 1.6em 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chips li { padding: 9px 15px; border-radius: 999px; border: 1px solid var(--hair); background: rgba(255,255,255,.55); font: 500 1rem/1.2 var(--display); color: #5a4128; }

.programme { margin: 0; }
.programme div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; align-items: baseline; padding: 15px 0; border-bottom: 1px solid rgba(184,138,58,.22); }
.programme div:last-child { border-bottom: 0; }
.programme dt { font: 600 .8rem/1.4 var(--display); letter-spacing: .18em; text-transform: uppercase; color: #8a6a3a; }
.programme dd { margin: 0; font: 500 1.25rem/1.4 var(--display); }
@media (max-width: 520px) { .programme div { grid-template-columns: 1fr; gap: 4px; } }

/* the printed programme as a booklet you can open */
.booklet { margin: clamp(48px, 9vw, 90px) auto 0; max-width: 980px; }
.book { position: relative; width: 100%; aspect-ratio: 4 / 3; perspective: 2400px; cursor: pointer; touch-action: pan-y; transition: transform 1.1s cubic-bezier(.6,.05,.25,1); }
.book[data-state="0"] { transform: translateX(-25%); }
.book[data-state="2"] { transform: translateX(25%); }
.book::after { /* the fold */
  content: ''; position: absolute; z-index: 20; top: 0; bottom: 0; left: calc(50% - 30px); width: 60px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(60,40,10,.16) 50%, transparent); opacity: 0; transition: opacity .6s;
}
.book[data-state="1"]::after { opacity: 1; }
.leaf { position: absolute; top: 0; left: 50%; width: 50%; height: 100%; transform-origin: left center; transform-style: preserve-3d; transition: transform 1.2s cubic-bezier(.6,.05,.25,1); }
.leaf.turned { transform: rotateY(-180deg); }
.face {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #fff;
  -webkit-backface-visibility: hidden; backface-visibility: hidden; box-shadow: 0 24px 60px rgba(80, 55, 20, .28);
}
.face.verso { transform: rotateY(180deg); } /* the reverse side of a leaf */
.leaf.moving .face { animation: shade 1.2s ease-in-out; }
@keyframes shade { 50% { filter: brightness(.82); } }
.book-controls { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 28px; }
.book-controls button, .viewer button {
  width: 48px; height: 48px; border-radius: 50%; cursor: pointer; border: 1px solid var(--hair);
  background: var(--glass); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font: 500 1.25rem/1 var(--display); color: var(--ink);
}
.book-controls button:disabled { opacity: .35; cursor: default; }
.book-page { min-width: 84px; text-align: center; font: 600 .9rem/1 var(--display); letter-spacing: .2em; color: #7a5a30; }

.viewer { width: 100vw; height: 100svh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(28, 21, 12, .94); }
.viewer::backdrop { background: rgba(28, 21, 12, .6); }
.viewer img { display: block; width: 100%; height: 100%; object-fit: contain; padding: 64px 12px 72px; }
.viewer button { position: absolute; background: rgba(255,255,255,.88); }
.viewer .close { top: max(14px, env(safe-area-inset-top)); right: 14px; font-size: 1.6rem; }
.viewer .prev { left: 14px; top: 50%; translate: 0 -50%; }
.viewer .next { right: 14px; top: 50%; translate: 0 -50%; }
.viewer .count { position: absolute; left: 0; right: 0; bottom: max(22px, env(safe-area-inset-bottom)); text-align: center; font: 600 .9rem/1 var(--display); letter-spacing: .25em; color: #f1e2c4; }

/* hymn */
.hymn { text-align: center; }
.hymn-number { margin: -6px 0 6px; font: 300 clamp(3.6rem, 12vw, 5.6rem)/1 var(--display); background: linear-gradient(180deg, #e9c983, #c3923d 55%, #9c7027); -webkit-background-clip: text; background-clip: text; color: transparent; }
.panel .hymn-meta { margin-bottom: 2.4em; font: italic 500 1.25rem/1.5 var(--display); color: #5a4128; }
.hymn-meta span { font-style: normal; font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: #8a6a3a; }
.hymn .song { margin: 0 0 2.8em; }
.stanzas { list-style: none; counter-reset: v; margin: 0; padding: 0; display: grid; gap: 2.4em; }
.stanzas li { counter-increment: v; }
.stanzas li::before { content: counter(v); display: block; margin-bottom: .7em; font: 600 .95rem/1 var(--display); letter-spacing: .2em; color: var(--gold-deep); }
.panel .stanzas p { margin: 0; font: 500 clamp(1.2rem, 3.8vw, 1.45rem)/1.7 var(--display); }
.panel .stanzas .refrain { margin-top: 1.4em; padding: 1.2em .5em; border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); font-style: italic; color: #6d5130; }

.thanks p { text-align: center; font: italic 500 clamp(1.25rem, 3.8vw, 1.6rem)/1.7 var(--display); color: #4f3a22; }

/* footer */
.story-footer { text-align: center; padding: 30px 16px max(52px, env(safe-area-inset-bottom)); }
.story-footer img { width: 128px; height: auto; }
.story-footer .name { margin: 6px 0 0; font: 400 clamp(2.4rem, 9vw, 3.6rem)/1.1 var(--script); color: var(--gold); text-shadow: 0 0 6px #fff, 0 0 18px rgba(255,255,255,.9), 0 1px 3px rgba(120,80,20,.6); }
.story-footer .dates { margin: 8px 0 30px; font: 500 1rem/1 var(--display); letter-spacing: .3em; color: #7a5a30; }
.story-footer nav { max-width: 660px; margin: 0 auto; }

/* reveal on scroll (only once story.js is running, so nothing hides if it fails) */
.reveal [data-reveal] { opacity: 0; transform: translateY(48px); transition: opacity 1.2s ease, transform 1.4s cubic-bezier(.2,.8,.2,1); }
.reveal [data-reveal].in { opacity: 1; transform: none; }

/* arrive out of white; leave into it */
.story .veil { opacity: 1; animation: dawn 1.6s ease-out forwards; }
.leaving .story .veil { animation: dusk .9s ease-in forwards; }
@keyframes dawn { to { opacity: 0; } }
@keyframes dusk { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .hero .name, .cue::after { animation: none; }
  .reveal [data-reveal] { transform: none; transition: opacity .6s; }
  .book, .leaf { transition-duration: .01s; }
  .story .veil { animation: none; opacity: 0; }
}
