/* Scroll Stories engine styles. Layout variables flip between phone and desktop at 720px. */
:root {
  --paper: rgba(250, 246, 238, 0.9);
  --ink: #2b2825;
  --cream: #f6efe3;
  --floor: 0px;          /* how far above the screen bottom a bottom-anchored figure stands */
  --fig-h: 74vh;         /* bottom-anchored figure height */
  --fig-x: 6vw;          /* inset from the side for bottom-left / bottom-right figures */
  --obj-h: 34vh;         /* center-anchored object height */
  --text-w: min(34vw, 500px);
}
@media (max-width: 720px) {
  :root { --floor: 31vh; --fig-h: 42vh; --fig-x: 1vw; --obj-h: 22vh; }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: #14151a; }
body { font-family: Literata, Georgia, serif; color: var(--ink); -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
#runway { position: relative; width: 1px; pointer-events: none; }

#stage { position: fixed; inset: 0; overflow: hidden; background: #14151a; }
.scene { position: absolute; inset: 0; opacity: 0; will-change: opacity, transform; transform-origin: 50% 50%; }
.scene.off { display: none; }

.bg { position: absolute; inset: 0; will-change: transform; transform-origin: var(--focus, 50% 50%); }
.bg img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: var(--focus, 50% 50%); }
.bg img.alt { opacity: 0; }

.layer { position: absolute; will-change: transform, opacity; transform-origin: 50% 100%; }
.layer img { display: block; height: 100%; width: auto; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.layer.flip img { transform: scaleX(-1); }
.layer[data-anchor="bottom-left"]  { left: var(--fig-x); bottom: var(--floor); height: var(--fig-h); }
.layer[data-anchor="bottom-right"] { right: var(--fig-x); bottom: var(--floor); height: var(--fig-h); }
.layer[data-anchor="center"] { left: 50%; top: 46%; height: var(--obj-h); translate: -50% -50%; transform-origin: 50% 50%; }
.layer[data-anchor="panel"] { left: 50%; top: 44%; width: min(54vw, 52vh); height: auto; translate: -50% -50%; transform-origin: 50% 50%; z-index: 0;
  border-radius: 14px; overflow: hidden; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45); }
.layer[data-anchor="panel"] img { width: 100%; height: auto; }
.layer .glow { position: absolute; width: 22vmin; height: 22vmin; translate: -50% -50%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 196, 96, 0.55) 0%, rgba(255, 176, 64, 0.22) 35%, rgba(255, 160, 40, 0) 70%);
  opacity: 0; mix-blend-mode: screen; }
.layer .glow.on { animation: glow-pulse 4.5s ease-in-out infinite; }
@keyframes glow-pulse { 0%, 100% { opacity: 0.45; transform: scale(0.9); } 50% { opacity: 1; transform: scale(1.1); } }
.layer .frost { position: absolute; inset: -4%; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at 50% 50%, rgba(255, 255, 255, 0) 30%, rgba(240, 248, 255, 0.85) 75%, #fff 100%); }
.layer .display { position: absolute; display: grid; place-items: center; font: 600 1em "Courier New", monospace; letter-spacing: 0.04em;
  color: #9bffc0; background: #1f2a24; border-radius: 6% / 20%; font-size: 1em; transition: background 0.4s, color 0.4s, box-shadow 0.4s; }
.layer .display.idle { color: #3a5a48; text-shadow: none; }
.layer .display.on { text-shadow: 0 0 8px rgba(120, 255, 170, 0.9), 0 0 22px rgba(80, 220, 140, 0.6); box-shadow: 0 0 18px rgba(90, 240, 150, 0.35); }
.layer .display.flare { color: #eafff0; text-shadow: 0 0 14px #b8ffd2, 0 0 40px rgba(120, 255, 170, 0.9); box-shadow: 0 0 60px rgba(120, 255, 170, 0.9); background: #35604a; }
.layer .display.dark { background: #101512; color: transparent; text-shadow: none; box-shadow: none; }

/* the bg-level glow for backgrounds (a lit window) */
.bg .glow { position: absolute; width: 18vmin; height: 18vmin; translate: -50% -50%; border-radius: 50%; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, rgba(255, 200, 110, 0.7) 0%, rgba(255, 180, 70, 0.25) 40%, rgba(255, 160, 40, 0) 70%); mix-blend-mode: screen; }
.bg .glow.on { animation: glow-pulse 5s ease-in-out infinite; }

/* text */
.text { position: absolute; display: grid; z-index: 5; pointer-events: none; }
.text > .beat { grid-area: 1 / 1; opacity: 0; will-change: opacity, transform; pointer-events: none; }
.text > .beat.active { pointer-events: auto; }
.beat { background: var(--paper); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: 16px;
  padding: clamp(16px, 2.4vw, 28px) clamp(18px, 2.6vw, 32px); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22); }
.beat p { margin: 0; font-size: clamp(1.05rem, 0.9vw + 0.75rem, 1.4rem); line-height: 1.5; font-weight: 400; text-wrap: pretty; }
.beat.kind-verse p { font-style: italic; font-size: clamp(1.1rem, 1vw + 0.8rem, 1.5rem); }
.beat .cite { display: block; margin-top: 0.8em; font-size: 0.8em; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.7; font-style: normal; }
.beat.effect-page { background: #f4ead6; box-shadow: inset 0 0 60px rgba(120, 90, 40, 0.15), 0 18px 50px rgba(0, 0, 0, 0.3); }
@media (min-width: 721px) {
  .text { top: 50%; translate: 0 -50%; width: var(--text-w); left: 6vw; }
  .text[data-side="right"] { left: auto; right: 6vw; }
  .text[data-side="center"] { left: 50%; translate: -50% -50%; width: min(52vw, 640px); }
}
@media (max-width: 720px) {
  .text { left: 4vw; right: 4vw; bottom: max(3.5vh, env(safe-area-inset-bottom)); align-items: end; }
  .text > .beat { align-self: end; }
}

/* title */
/* no transform here on purpose: a transformed ancestor would trap the fixed-position scroll hint */
.text.has-title { top: auto; bottom: 12%; left: 5vw; right: 5vw; width: auto; max-width: 900px; margin: 0 auto; translate: none; text-align: center; align-items: start; }   /* desktop: the title sits on the lawn under the house */
@media (max-width: 720px) { .text.has-title { top: 7%; bottom: auto; } }   /* phone: the sky is free above the house */
.beat.effect-title { background: none; backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; }
.beat.effect-title h1 { margin: 0; font-family: Fraunces, Georgia, serif; font-style: italic; font-weight: 500; letter-spacing: -0.01em;
  font-size: clamp(2.3rem, 6.2vw, 4.8rem); line-height: 1.05; color: var(--cream); text-shadow: 0 2px 30px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.5); text-wrap: balance; }
.beat.effect-title .subtitle { display: block; margin-top: 1em; font-size: clamp(0.95rem, 1vw + 0.5rem, 1.2rem); letter-spacing: 0.22em; text-transform: uppercase; color: var(--cream); opacity: 0.85; text-shadow: 0 1px 12px rgba(0, 0, 0, 0.6); }

/* hint: sits at the foot of the screen, outside the card */
.beat.kind-hint { position: fixed; left: 50%; bottom: max(4vh, env(safe-area-inset-bottom)); translate: -50% 0; background: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none;
  color: var(--cream); text-shadow: 0 1px 10px rgba(0, 0, 0, 0.7); text-align: center; padding: 0; width: 90vw; }
.beat.kind-hint p { font-size: clamp(0.9rem, 0.5vw + 0.7rem, 1.05rem); letter-spacing: 0.02em; }
.beat.kind-hint p::after { content: ""; display: block; width: 12px; height: 12px; margin: 14px auto 0; border-right: 2px solid var(--cream); border-bottom: 2px solid var(--cream); transform: rotate(45deg); animation: bob 1.8s ease-in-out infinite; }
@keyframes bob { 0%, 100% { translate: 0 0; opacity: 0.5; } 50% { translate: 0 8px; opacity: 1; } }

/* share card */
.beat.effect-share { text-align: center; }
.beat.effect-share p { font-family: Fraunces, Georgia, serif; font-style: italic; font-size: clamp(1.5rem, 2vw + 0.6rem, 2.3rem); }
.share-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
.share-row a, .share-row button { font: inherit; font-size: 0.95rem; padding: 10px 18px; border-radius: 999px; border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  text-decoration: none; cursor: pointer; transition: background 0.2s, color 0.2s; }
.share-row a:hover, .share-row button:hover { background: var(--ink); color: var(--cream); }
.share-row [data-action="share"] { display: none; }
body.can-share .share-row [data-action="share"] { display: inline-block; }
body.can-share .share-row [data-action="sms"], body.can-share .share-row [data-action="email"] { display: none; }
.share-again { display: block; margin-top: 16px; font-size: 0.85rem; opacity: 0.7; cursor: pointer; background: none; border: 0; font: inherit; color: var(--ink); text-decoration: underline; }

/* html layers (the contest poster) */
.layer.html-poster { left: 50%; top: 44%; translate: -50% -50%; width: min(48vw, 46vh); height: auto; transform-origin: 50% 50%; }
.poster { background: #efe3c8; color: #2b2825; padding: 6% 7%; border-radius: 3px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); text-align: center; font-family: Fraunces, Georgia, serif; }
.poster .k { font-size: clamp(1.4rem, 3.4vw, 3rem); font-weight: 700; letter-spacing: 0.1em; }
.poster .b { font-size: clamp(0.8rem, 1.4vw, 1.2rem); margin-top: 0.8em; line-height: 1.4; }

/* chrome */
#veil { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: #000; z-index: 8; }
#progress { position: fixed; top: 0; left: 0; width: 100%; height: 3px; background: var(--cream); transform-origin: 0 50%; transform: scaleX(0); z-index: 20; opacity: 0.85; }
#next { position: fixed; right: 22px; bottom: 22px; width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid rgba(246, 239, 227, 0.7); background: rgba(20, 21, 26, 0.35); cursor: pointer; z-index: 20; display: none; }
#next::after { content: ""; position: absolute; left: 50%; top: 42%; width: 10px; height: 10px; border-right: 2px solid var(--cream); border-bottom: 2px solid var(--cream); transform: translate(-50%, -50%) rotate(45deg); }
@media (hover: hover) and (min-width: 721px) { #next { display: block; } body.at-end #next { display: none; } }
body:not(.ready) #stage { opacity: 0; }
body.ready #stage { opacity: 1; transition: opacity 0.6s ease; }
