/* V3 round 2, lane H: What Happens Next as a storybook inside a phone (group whnbook; see v4/r2/lane-h.js).
   a Phone story, b Phone flipbook, c Phone + chapters, d hands the section back to lane D's ldbook.
   The phone is never taller than the viewport (dvh with a vh fallback). Transforms and opacity only.
   html.glz-static: no phone, no motion, all four pages as a plain readable sequence. Styles stop at #how-it-works. */

/* Who shows: the phone (a to c) or lane D's book (d). Only once lane H has set its group, so nothing hides early. */
.whn { display: none; }
html[data-v-whnbook]:not([data-v-whnbook="d"]) .whn { display: grid; }
html[data-v-whnbook]:not([data-v-whnbook="d"]) #how-it-works :is(.guide-binding, .guide-controls, .ld-reel) { display: none !important; }
html[data-v-whnbook]:not([data-v-whnbook="d"]) #how-it-works > .glzv[aria-label="Preview variants: Storybook"] { display: none; }
html[data-v-whnbook="d"] #how-it-works > .glzv[aria-label="Preview variants: Phone storybook"] { top: 48px; }

.whn {
  --whn-w: min(21.5rem, calc(100vw - 2.5rem), calc((100vh - 11rem) * .48));
  position: relative; justify-items: center; gap: 1.1rem; max-width: 64rem; margin: 0 auto; padding: .5rem 0 0;
  background: radial-gradient(closest-side at 50% 46%, rgba(212, 168, 67, .2), transparent 78%);
}
@supports (height: 100dvh) { .whn { --whn-w: min(21.5rem, calc(100vw - 2.5rem), calc((100dvh - 11rem) * .48)); } }
.whn-device { display: grid; justify-items: center; gap: 1rem; min-width: 0; max-width: 100%; }

/* The phone */
.whn-phone {
  position: relative; display: grid; width: var(--whn-w); max-width: 100%; aspect-ratio: 9 / 18.4;
  padding: calc(var(--whn-w) * .034); border-radius: calc(var(--whn-w) * .15);
  background: linear-gradient(150deg, #3D2636, #1C1018 70%);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .09), 0 0 0 1px rgba(45, 25, 40, .35), 0 2.2rem 3rem -1.6rem rgba(45, 25, 40, .6);
  touch-action: pan-y; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.whn-phone:focus-visible { outline: 3px solid var(--honey-gold-dark, #B8902D); outline-offset: 5px; }
.whn-island { position: absolute; z-index: 6; top: calc(var(--whn-w) * .06); left: 50%; width: 27%; height: calc(var(--whn-w) * .068); border-radius: 999px; background: #0E080C; transform: translateX(-50%); }
.whn-bars { position: absolute; z-index: 6; top: calc(var(--whn-w) * .155); left: calc(var(--whn-w) * .085); right: calc(var(--whn-w) * .085); display: flex; gap: 4px; pointer-events: none; }
.whn-bars span { flex: 1; height: 3px; border-radius: 3px; overflow: hidden; background: rgba(253, 248, 240, .5); box-shadow: 0 0 0 .5px rgba(45, 25, 40, .22); }
.whn-bars i { display: block; height: 100%; background: #D4A843; transform: scaleX(0); transform-origin: left; }
.whn-bars :is(.is-on, .is-done) i { transform: scaleX(1); }
html:not(.glz-static) .whn-bars i { transition: transform .6s ease-out; }
.whn-screen { position: relative; min-height: 0; overflow: hidden; border-radius: calc(var(--whn-w) * .118); background: var(--cream, #FDF8F0); isolation: isolate; }

/* Pages */
.whn-page { position: absolute; inset: 0; container-type: inline-size; display: grid; grid-template-rows: 56% minmax(0, 1fr); background: var(--cream, #FDF8F0); opacity: 0; visibility: hidden; }
.whn-page.is-on { z-index: 2; opacity: 1; visibility: visible; }
html:not(.glz-static) .whn-page { transition: opacity .55s ease-out, transform .7s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .7s; will-change: transform, opacity; }
html:not(.glz-static) .whn-page.is-on { transition-delay: 0s; }
.whn-art { position: relative; margin: 0; overflow: hidden; background: #2A1A24; user-select: none; }
.whn-art :is(img, video) { display: block; width: 100%; height: 100%; object-fit: cover; }
.whn-art picture { display: block; width: 100%; height: 100%; }
.whn-art-map { background: #F4EAD8; }
.whn-map-svg { display: block; width: 100%; height: 100%; }
.whn-map-area, .whn-map-ring { transform-box: fill-box; transform-origin: center; }
.whn-map-label { position: absolute; left: 50%; bottom: 6cqi; z-index: 2; display: grid; justify-items: center; gap: .1rem; margin: 0; padding: 2cqi 4.5cqi; border-radius: 999px; background: rgba(253, 248, 240, .94); box-shadow: 0 .4rem 1rem -.6rem rgba(45, 25, 40, .5); color: var(--text-muted, #5A4D44); font: 500 clamp(.6rem, 3.1cqi, .72rem)/1.25 'DM Sans', sans-serif; white-space: nowrap; transform: translateX(-50%); }
.whn-map-label strong { color: var(--plum, #4A1942); font-size: clamp(.72rem, 3.9cqi, .9rem); }
.whn-chip { position: absolute; left: 5cqi; bottom: 5cqi; z-index: 2; display: inline-flex; align-items: center; gap: 2cqi; padding: 2cqi 3.6cqi; border-radius: 999px; background: rgba(253, 248, 240, .95); color: var(--ink, #2D1928); font: 700 clamp(.62rem, 3.4cqi, .8rem)/1 'DM Sans', sans-serif; box-shadow: 0 .4rem 1rem -.5rem rgba(0, 0, 0, .5); }
.whn-chip b { display: inline-grid; place-items: center; width: 4.6cqi; height: 4.6cqi; border-radius: 50%; background: #3F7A4A; color: #fff; font-size: .8em; }
.whn-chip-here { left: auto; right: 5cqi; background: var(--plum, #4A1942); color: #FDF8F0; }
.whn-clock { position: relative; display: inline-block; width: 4.8cqi; height: 4.8cqi; border: 1.5px solid currentColor; border-radius: 50%; }
.whn-clock i { position: absolute; left: 50%; bottom: 50%; width: 1.5px; height: 40%; margin-left: -.75px; background: #B8902D; transform-origin: 50% 100%; }
.whn-bubble { position: absolute; top: 18cqi; left: 6cqi; right: 6cqi; z-index: 3; display: grid; gap: .15rem; padding: 3cqi 4cqi; border-radius: 4.5cqi; background: rgba(253, 248, 240, .97); color: var(--ink, #2D1928); font: 500 clamp(.66rem, 3.6cqi, .84rem)/1.35 'DM Sans', sans-serif; box-shadow: 0 .6rem 1.4rem -.8rem rgba(45, 25, 40, .6); }
.whn-bubble b { color: var(--gold-text, #8A6514); font-size: .82em; letter-spacing: .1em; text-transform: uppercase; }
.whn-copy { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; padding: 5cqi 7cqi 6cqi; text-align: left; cursor: auto; }
.whn-copy::-webkit-scrollbar { display: none; }
.whn-kicker { margin: 0 0 2.6cqi !important; color: var(--gold-text, #8A6514) !important; font: 700 clamp(.58rem, 3.1cqi, .72rem)/1.4 'DM Sans', sans-serif !important; letter-spacing: .14em; text-transform: uppercase; }
.whn-copy h3 { margin: 0 0 3cqi; color: var(--ink, #2D1928); font: 400 clamp(1.05rem, 8.2cqi, 1.85rem)/1.06 'Glaze Display', Georgia, serif; font-variant-ligatures: none; }
.whn-copy p { margin: 0 0 2.6cqi; color: var(--text-muted, #5A4D44); font-size: clamp(.74rem, 4.25cqi, .98rem); line-height: 1.5; }
.whn-copy strong { color: var(--ink, #2D1928); }
.whn-copy .whn-note { padding-top: 2.4cqi; border-top: 1px solid color-mix(in srgb, var(--honey-gold-dark, #B8902D) 30%, transparent); font-size: clamp(.7rem, 3.8cqi, .88rem); }
.whn-copy .whn-ready { padding-left: 3cqi; border-left: 3px solid #D4A843; color: var(--plum, #4A1942); font-weight: 600; }
.whn-link { display: inline-flex; align-items: center; gap: .5rem; min-height: 2.75rem; color: var(--ink, #2D1928); font-size: clamp(.74rem, 4cqi, .9rem); font-weight: 700; text-decoration: none; border-bottom: 1px solid var(--honey-gold-dark, #B8902D); }
.whn-link:focus-visible { outline: 2px solid var(--honey-gold-dark, #B8902D); outline-offset: 3px; }

/* Arrows, count and the clip toggle */
.whn-nav { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .7rem; }
.whn-count { min-width: 10rem; margin: 0; color: var(--text-muted, #5A4D44); font-size: .78rem; text-align: center; }
.whn-nav button { min-width: 2.9rem; height: 2.9rem; padding: 0 .9rem; border: 1px solid var(--linen, #EADFCB); border-radius: 999px; background: var(--cream, #FDF8F0); color: var(--ink, #2D1928); font: 600 .8rem/1 'DM Sans', sans-serif; cursor: pointer; }
.whn-nav :is(.whn-prev, .whn-next) { padding: 0; font-size: 1.15rem; }
.whn-nav button:disabled { opacity: .3; cursor: default; }
.whn-nav button:focus-visible, .whn-chapters button:focus-visible { outline: 2px solid var(--honey-gold-dark, #B8902D); outline-offset: 3px; }
html:not(.glz-static) .whn-nav button { transition: transform .18s ease-out; }
.whn-nav button:hover:not(:disabled) { background: var(--white, #fff); transform: translateY(-1px); }
.whn-nav button:active:not(:disabled) { transform: scale(.94); }

/* Chapter list (variant c only) */
.whn-chapters { display: none; margin: 0; padding: 0; list-style: none; }
.whn-chapters button { display: flex; align-items: baseline; gap: .6rem; width: 100%; min-height: 2.75rem; padding: .55rem 1rem; border: 1px solid var(--linen, #EADFCB); border-radius: 999px; background: var(--cream, #FDF8F0); color: var(--ink, #2D1928); font: 600 .86rem/1.2 'DM Sans', sans-serif; text-align: left; cursor: pointer; }
.whn-chapters button span { color: var(--gold-text, #8A6514); font-size: .72rem; letter-spacing: .1em; }
.whn-chapters button[aria-current] { border-color: var(--plum, #4A1942); background: var(--plum, #4A1942); color: #FDF8F0; }
.whn-chapters button[aria-current] span { color: #E9C978; }
html:not(.glz-static) .whn-chapters button { transition: transform .18s ease-out; }
.whn-chapters button:active { transform: scale(.97); }
html[data-v-whnbook="c"] .whn-chapters { display: flex; flex-wrap: wrap; justify-content: center; gap: .45rem; order: 2; max-width: 100%; }
html[data-v-whnbook="c"] .whn-chapters button { width: auto; padding: .45rem .85rem; font-size: .78rem; }
@media (min-width: 900px) {
  html[data-v-whnbook="c"] .whn { grid-template-columns: minmax(0, 17rem) auto; justify-content: center; align-items: center; column-gap: clamp(2rem, 5vw, 4.5rem); background: none; }
  html[data-v-whnbook="c"] .whn-chapters { order: 0; display: grid; gap: .6rem; }
  html[data-v-whnbook="c"] .whn-chapters button { width: 100%; padding: .7rem 1.1rem; font-size: .9rem; }
}

/* A: Phone story. Pages slide like stories. */
html:not(.glz-static)[data-v-whnbook="a"] .whn-page.is-before { transform: translate3d(-24%, 0, 0); }
html:not(.glz-static)[data-v-whnbook="a"] .whn-page.is-after { transform: translate3d(24%, 0, 0); }

/* B: Phone flipbook. The page swings away from its left edge; the next one waits underneath. */
html[data-v-whnbook="b"] .whn-screen { background: #EFE3CD; }
html[data-v-whnbook="b"] .whn-page { transform-origin: left center; }
html[data-v-whnbook="b"] .whn-page.is-before { z-index: 3; }
html:not(.glz-static)[data-v-whnbook="b"] .whn-page.is-before { transform: perspective(1100px) rotateY(-82deg); }
html:not(.glz-static)[data-v-whnbook="b"] .whn-page.is-after { transform: scale(.94); }
html:not(.glz-static)[data-v-whnbook="b"] .whn-page { transition: opacity .7s ease-in, transform .8s cubic-bezier(.45, .05, .25, 1), visibility 0s linear .8s; }
html:not(.glz-static)[data-v-whnbook="b"] .whn-page.is-on { transition: opacity .45s ease-out, transform .8s cubic-bezier(.45, .05, .25, 1), visibility 0s; }
html[data-v-whnbook="b"] .whn-page::after { content: ''; position: absolute; inset: 0 auto 0 0; width: 9%; background: linear-gradient(90deg, rgba(45, 25, 40, .16), transparent); pointer-events: none; }
html[data-v-whnbook="b"] .whn-kicker::before { content: 'Page '; }

/* C: Phone + chapters. Pages settle in place. */
html:not(.glz-static)[data-v-whnbook="c"] .whn-page:is(.is-before, .is-after) { transform: translate3d(0, 4%, 0) scale(.97); }

/* One entrance per page, played when the page opens (never looped). */
@keyframes whn-rise { from { opacity: 0; transform: translate3d(0, 10px, 0); } to { opacity: 1; transform: none; } }
@keyframes whn-pop { from { opacity: 0; transform: translate3d(0, 8px, 0) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes whn-drop { from { opacity: 0; transform: translate3d(0, -14px, 0); } to { opacity: 1; transform: none; } }
@keyframes whn-zoom { from { transform: scale(1); } to { transform: scale(1.06); } }
@keyframes whn-sweep { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes whn-area { from { opacity: 0; transform: scale(.72); } to { opacity: 1; transform: none; } }
@keyframes whn-fade { from { opacity: 0; } to { opacity: .7; } }
html:not(.glz-static) .whn.is-awake .whn-page.is-on .whn-copy > * { animation: whn-rise .75s ease-out both; }
html:not(.glz-static) .whn.is-awake .whn-page.is-on .whn-copy > :nth-child(2) { animation-delay: .08s; }
html:not(.glz-static) .whn.is-awake .whn-page.is-on .whn-copy > :nth-child(3) { animation-delay: .16s; }
html:not(.glz-static) .whn.is-awake .whn-page.is-on .whn-copy > :nth-child(n+4) { animation-delay: .24s; }
html:not(.glz-static) .whn.is-awake .whn-page.is-on .whn-art-photo img { animation: whn-zoom 18s ease-out forwards; }
html:not(.glz-static) .whn.is-awake .whn-page.is-on :is(.whn-chip, .whn-map-label) { animation: whn-pop .6s ease-out .5s both; }
html:not(.glz-static) .whn.is-awake .whn-page.is-on .whn-bubble { animation: whn-drop .7s ease-out .9s both; }
html:not(.glz-static) .whn.is-awake .whn-page.is-on .whn-clock i { animation: whn-sweep 2.4s ease-in-out .5s both; }
html:not(.glz-static) .whn.is-awake .whn-page.is-on .whn-map-area { animation: whn-area 1.1s ease-out .1s both; }
html:not(.glz-static) .whn.is-awake .whn-page.is-on .whn-map-ring { animation: whn-fade .8s ease-out .5s both; }

/* Static (reduced motion or Save-Data): no phone, every page in order, nothing moves. */
html.glz-static .whn { background: none; }
html.glz-static :is(.whn-island, .whn-bars, .whn-nav, .whn-chapters) { display: none !important; }
html.glz-static .whn-device { width: 100%; }
html.glz-static .whn-phone { width: 100%; max-width: 64rem; aspect-ratio: auto; padding: 0; border-radius: 0; background: none; box-shadow: none; cursor: auto; }
html.glz-static .whn-screen { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: 1rem; overflow: visible; border-radius: 0; background: none; }
html.glz-static .whn-page { position: relative; inset: auto; grid-template-rows: auto auto; opacity: 1; visibility: visible; transform: none; overflow: hidden; border: 1px solid var(--linen, #EADFCB); border-radius: 22px; }
html.glz-static .whn-art { aspect-ratio: 4 / 3; }
html.glz-static .whn-copy { overflow: visible; }
html.glz-static .whn-page::after { display: none; }
