/* Poetic Prompts — THE ASCENT (results)
   A pigeon carries the sealed poem up through six paintings, stacked into one
   continuous climb. Each band fades into the one above under a cloud bank.
   Bands are spaced 1.4 screens apart, so a camera resting ON a painting
   (alt = 0,1,…,5) sees only that painting; scores in between show the fade.
   --alt (0…5) is the camera altitude in paintings. */

.ascent {
  --D: 100svh;                  /* one screen */
  --P: calc(var(--D) * 1.4);    /* distance between painting centres */
  --F: calc(var(--D) * 0.4);    /* crossfade zone between paintings */
  --alt: 0;
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow: hidden;
  background: #2a1a10;
  color: #f4e9d2;
}
.ascent[hidden] { display: none; }
.ascent.entering { animation: ascent-in 0.9s ease both; }
@keyframes ascent-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- the stacked sky ---------- */
.sky {
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  height: calc(var(--P) * 6);
  transform: translate3d(0, calc((var(--alt) - 5) * var(--P)), 0);
  will-change: transform;
}
.band {
  position: absolute;
  left: 0; width: 100%;
  height: calc(var(--P) + var(--F));   /* its own span + the fade into the band above */
  z-index: 1;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 calc(var(--F)));
          mask-image: linear-gradient(to bottom, transparent 0, #000 calc(var(--F)));
}
.b6 { top: 0; height: var(--P); -webkit-mask-image: none; mask-image: none; }
.b5 { top: calc(var(--P) * 1 - var(--F)); }
.b4 { top: calc(var(--P) * 2 - var(--F)); }
.b3 { top: calc(var(--P) * 3 - var(--F)); }
.b2 { top: calc(var(--P) * 4 - var(--F)); }
.b1 { top: calc(var(--P) * 5 - var(--F)); }

.band-art {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.9) sepia(0.1) contrast(1.02);   /* one shared varnish */
}
.b1 .band-art { object-position: 50% 62%; }
.b2 .band-art { object-position: 50% 55%; }
.b3 .band-art { object-position: 50% 30%; }
.b4 .band-art { object-position: 50% 50%; }
.b5 .band-art { object-position: 50% 50%; }

/* cloud banks straddling each seam (seam k sits between band k and k+1) */
.seam {
  position: absolute;
  z-index: 2;
  left: -25%; width: 150%;
  height: calc(var(--D) * 0.62);
  pointer-events: none;
  opacity: 0.92;
}
/* centred on each crossfade zone, which sits just below a painting's view */
.seam-5 { top: calc(var(--P) * 1 - var(--F) / 2 - var(--D) * 0.31); }
.seam-4 { top: calc(var(--P) * 2 - var(--F) / 2 - var(--D) * 0.31); transform: scaleX(-1); }
.seam-3 { top: calc(var(--P) * 3 - var(--F) / 2 - var(--D) * 0.31); }
.seam-2 { top: calc(var(--P) * 4 - var(--F) / 2 - var(--D) * 0.31); transform: scaleX(-1); }
.seam-1 { top: calc(var(--P) * 5 - var(--F) / 2 - var(--D) * 0.31); }

.band-label {
  position: absolute;
  z-index: 3;
  left: clamp(16px, 3vw, 40px);
  bottom: calc(var(--P) * (var(--k) - 1) + var(--F) + var(--D) * 0.1);
  margin: 0;
  max-width: 70vw;
  font: 600 clamp(15px, 1.5vw, 19px)/1.25 "Cinzel", serif;
  letter-spacing: 0.12em;
  color: #fbf1dc;
  text-shadow: 0 1px 2px rgba(20, 10, 4, 0.8), 0 0 18px rgba(20, 10, 4, 0.55);
}
.band-label i { font-style: normal; color: #f2c46d; margin-right: 0.4em; }
.band-label span {
  display: block;
  margin-top: 4px;
  font: italic 500 13px/1.3 "Cormorant Garamond", serif;
  letter-spacing: 0.02em;
  opacity: 0.85;
}
.band-label span i { font-style: italic; color: inherit; margin: 0; }

/* ---------- the summit ---------- */
.sun-glow {
  position: absolute; inset: 0; z-index: 1;
  background: radial-gradient(circle at 50% 20%, rgba(255, 252, 230, 0.95) 0 4%, rgba(255, 236, 170, 0.5) 9%, transparent 30%);
  animation: sun-breathe 5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sun-breathe { 50% { opacity: 0.75; transform: scale(1.04); } }
.icarus {
  position: absolute; z-index: 2;
  width: min(44vw, 520px);
  left: 9%; top: 24%;
  filter: sepia(0.35) drop-shadow(0 12px 18px rgba(90, 50, 10, 0.35));
  animation: icarus-hang 9s ease-in-out infinite;
}
@keyframes icarus-hang { 50% { transform: translateY(-10px) rotate(-1.5deg); } }
.feathers { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.feather {
  position: absolute;
  width: 34px;
  opacity: 0;
  animation: feather-drift linear infinite;
}
@keyframes feather-drift {
  0%   { opacity: 0; transform: translate(0, 0) rotate(var(--r0)); }
  10%  { opacity: 0.9; }
  100% { opacity: 0; transform: translate(var(--dx), 70vh) rotate(var(--r1)); }
}

.ascent-vignette {
  position: absolute; inset: 0; z-index: 4; pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(25, 14, 6, 0.55) 100%);
}

/* ---------- the pigeon and its letter ---------- */
.flyer {
  position: absolute; z-index: 6;
  left: 50%; top: 58%;
  width: clamp(150px, 17vw, 230px);
  translate: -50% -50%;
  transition: translate 1.6s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.flyer.offstage { translate: -50vw 30vh; }
.ascent.done .flyer { left: 36%; }               /* make room for the verdict */
.flyer-tilt {
  position: relative;
  rotate: -4deg;
  animation: bob 1.1s ease-in-out infinite;
  transition: rotate 1.2s ease;
}
@keyframes bob { 50% { transform: translateY(-8px); } }

/* the pigeon: a pixel-art sprite sheet (11 frames of 48x40), Krillion-style.
   frames 0-3 fly · 4-7 idle (hover, blink) · 8 glide · 9-10 summit sparkle */
.flyer { --px: 4; --fw: 52px; --fh: 44px;   /* one sprite frame (see tools/make_pigeon_sprite.py) */ width: calc(var(--fw) * var(--px)); }
.sprite {
  width: calc(var(--fw) * var(--px)); height: calc(var(--fh) * var(--px));
  background: url("assets/ascent/pigeon-sprite.png") 0 0 / calc(11 * var(--fw) * var(--px)) 100% no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 10px rgba(255, 232, 170, 0.45)) drop-shadow(0 6px 6px rgba(30, 15, 5, 0.35));
  animation: pg-idle 0.9s steps(4) infinite;
}
@keyframes pg-idle { from { background-position-x: calc(-4 * var(--fw) * var(--px)); } to { background-position-x: calc(-8 * var(--fw) * var(--px)); } }
@keyframes pg-fly  { from { background-position-x: 0; } to { background-position-x: calc(-4 * var(--fw) * var(--px)); } }
@keyframes pg-summit { from { background-position-x: calc(-9 * var(--fw) * var(--px)); } to { background-position-x: calc(-11 * var(--fw) * var(--px)); } }
.ascent.climbing .sprite { animation: pg-fly 0.36s steps(4) infinite; }
/* skins: the same 11-frame rig, drawn by tools/make_pigeon_sprite.py */
/* (each skin's sheet is set by ascent.js; these two glow) */
.flyer[data-skin="gold"] .sprite { filter: drop-shadow(0 0 14px rgba(255, 214, 110, 0.85)) drop-shadow(0 6px 6px rgba(30, 15, 5, 0.35)); }
.flyer[data-skin="phoenix"] .sprite { filter: drop-shadow(0 0 16px rgba(255, 140, 50, 0.8)) drop-shadow(0 6px 6px rgba(30, 15, 5, 0.35)); }
.v-board .gold-won { color: #8a6410; font-weight: 700; }
.ascent.climbing .flyer-tilt { rotate: -12deg; }
.ascent.at-summit .sprite { animation: pg-summit 0.7s steps(2) infinite; }
.ascent.at-summit .flyer-tilt { rotate: -6deg; }
.ascent.done.at-summit .flyer { left: 44%; top: 22%; }   /* up beside the sun, clear of Icarus */

/* ---------- the score builds up ---------- */
.tally {
  position: absolute; z-index: 7;
  left: 50%; top: 9%;
  translate: -50% 0;
  width: min(400px, 88vw);
  padding: 30px 38px 24px;
  color: #2a2119;
  background: url("assets/paper-wide.webp") center / 100% 100% no-repeat;
  filter: drop-shadow(0 12px 20px rgba(20, 10, 4, 0.5));
  animation: tally-in 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.tally[hidden] { display: none; }
.tally.leaving { animation: tally-out 0.45s ease-in both; }
@keyframes tally-in { from { opacity: 0; transform: translateY(14px) rotate(-1.5deg); } }
@keyframes tally-out { to { opacity: 0; transform: translateY(-24px) scale(0.96); } }
.tally-k { margin: 0 0 10px; text-align: center; font: 600 13px "Cormorant SC", serif; letter-spacing: 0.16em; color: #a6321f; }
.tally-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.tally-rows li { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; opacity: 0.28; transition: opacity 0.3s; }
.tally-rows li.on { opacity: 1; }
.tally-rows b { font: 600 14px "Cormorant SC", serif; letter-spacing: 0.08em; }
.tally-rows em { font: 600 16px "Cormorant Garamond", serif; font-style: normal; color: #6b5440; font-variant-numeric: tabular-nums; }
.tally-rows .bar { grid-column: 1 / -1; height: 3px; background: rgba(42, 33, 25, 0.12); border-radius: 2px; overflow: hidden; }
.tally-rows .bar i { display: block; height: 100%; width: 0; background: #26437e; transition: width 0.65s cubic-bezier(0.2, 0.8, 0.2, 1); }
.tally-total {
  margin: 16px 0 0; padding-top: 10px;
  border-top: 1px dotted rgba(42, 33, 25, 0.3);
  text-align: center;
  font: 700 58px/1 "Cormorant Garamond", serif; color: #a6321f;
  font-variant-numeric: tabular-nums;
}
.tally-total span { font-size: 20px; font-weight: 500; color: #6b5440; margin-left: 6px; }
.tally-total.landed b { display: inline-block; animation: landed 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes landed { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }

/* while climbing: the pigeon leans into it and the world streaks past */
.ascent.climbing .sky { filter: blur(0.6px); }
.feather img { width: 100%; display: block; filter: sepia(0.25) drop-shadow(0 3px 4px rgba(90, 50, 10, 0.25)); }

.judge-reading {
  position: absolute; z-index: 7;
  left: 50%; top: 22%; translate: -50% 0;
  margin: 0;
  padding: 10px 22px;
  font: italic 500 22px "Cormorant Garamond", serif;
  color: #fbf1dc;
  text-shadow: 0 1px 3px rgba(20, 10, 4, 0.9);
  animation: reading 1.4s ease-in-out infinite;
}
@keyframes reading { 50% { opacity: 0.55; } }

.skip {
  position: absolute; z-index: 8; right: 18px; bottom: 16px;
  min-height: 44px; padding: 0 16px;
  border: 0; background: none; cursor: pointer;
  font: italic 500 20px "Cormorant Garamond", serif; color: #fbf1dc;
  text-shadow: 0 1px 3px rgba(20, 10, 4, 0.9);
}
.skip[hidden] { display: none; }

/* ---------- the verdict ----------
   Readability pass: upright body text >=16px, ink on paper for 4.5:1+ contrast,
   right-aligned tabular scores, thicker bars tinted by strength (the number is
   always shown too, so colour isn't the only signal), tip set off as a callout,
   and no inner scrollbar on desktop. */
.verdict {
  --v-ink: #241b13;          /* body text on parchment */
  --v-muted: #5a4634;        /* secondary text, still >= 4.5:1 on the paper */
  --v-red: #9c2c1a;
  position: absolute; z-index: 9;
  right: clamp(16px, 4vw, 56px); top: 50%;
  translate: 0 -50%;
  width: min(540px, 92vw);   /* wide enough that real reasons stay on one line and the card never scrolls (verify: seal-flow) */
  max-height: 94svh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(60, 40, 25, 0.35) transparent;
  padding: 30px 46px 26px;
  color: var(--v-ink);
  background: url("assets/paper-tall.webp") center / 100% 100% no-repeat;
  filter: drop-shadow(0 18px 28px rgba(20, 10, 4, 0.55));
  animation: verdict-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.verdict[hidden] { display: none; }
@keyframes verdict-in { from { opacity: 0; transform: translateX(28px) rotate(1.2deg); } }

/* header: where it rose to, the score, how far to the next level */
.v-kicker { margin: 0; font: italic 500 19px/1.2 "Cormorant Garamond", serif; color: var(--v-muted); }
.v-level { margin: 4px 0 0; font: 600 26px/1.15 "Cinzel", serif; letter-spacing: 0.05em; padding-right: 40px; }
.v-level i { font-style: normal; color: var(--v-red); margin-right: 0.35em; }
.v-scoreline { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin: 8px 0 0; }
.v-score { margin: 0; font: 700 60px/0.9 "Cormorant Garamond", serif; color: var(--v-red); font-variant-numeric: lining-nums tabular-nums; }
.v-score span { font-size: 24px; font-weight: 500; color: var(--v-muted); margin-left: 6px; }
.v-next { margin: 0; font: italic 500 18px/1.3 "Cormorant Garamond", serif; color: var(--v-muted); }
.v-est[hidden] { display: none; }
.v-est {
  margin-left: auto; align-self: center;
  padding: 3px 8px; border: 1px solid rgba(36, 27, 19, 0.35); border-radius: 2px;
  font: 600 10.5px/1 "Cinzel", serif; letter-spacing: 0.12em; text-transform: uppercase; color: var(--v-muted);
  cursor: help;
}
.v-next b { font-style: normal; font-weight: 700; color: var(--v-ink); }

/* the marks */
.v-rubric {
  list-style: none; margin: 16px 0 0; padding: 14px 0 0;
  border-top: 1.5px solid rgba(36, 27, 19, 0.18);
  display: grid; gap: 8px;
}
.v-row { display: grid; grid-template-columns: 9.2em 1fr auto; align-items: center; gap: 12px; margin-bottom: 3px; }
.v-label { font: 600 13px/1 "Cinzel", serif; letter-spacing: 0.12em; text-transform: uppercase; color: var(--v-ink); }
.v-pts { font: 500 17px/1 "Cormorant Garamond", serif; color: var(--v-muted); font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
.v-pts b { font-size: 24px; font-weight: 700; color: var(--v-ink); }
.v-rubric .bar { display: block; height: 7px; margin: 0; background: rgba(36, 27, 19, 0.1); border-radius: 4px; overflow: hidden; box-shadow: inset 0 1px 1px rgba(36, 27, 19, 0.12); }
.v-rubric .bar i { display: block; height: 100%; width: 0; border-radius: 4px; background: #2f4f86; transition: width 0.9s cubic-bezier(0.2, 0.8, 0.2, 1); }
.v-rubric .bar[data-tier="low"] i { background: #a8432c; }
.v-rubric .bar[data-tier="mid"] i { background: #b8862e; }
.v-rubric p { margin: 0; font: 500 16.5px/1.35 "Cormorant Garamond", serif; color: var(--v-ink); }
/* desktop: one line per reason and two for the tip, so any judge's text fits the card
   (the full text is in the tooltip and in My Poems); phones wrap freely and scroll */
@media (min-width: 721px) {
  .v-rubric p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .v-tip p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}
/* short laptop screens: a little tighter, so a two-line tip and the leaderboard line still fit without scrolling */
@media (min-width: 721px) and (max-height: 820px) {
  .verdict { padding: 24px 42px 20px; }
  .v-score { font-size: 54px; }
  .v-rubric { gap: 5px; margin-top: 12px; padding-top: 10px; }
  .v-tip { margin-top: 10px; padding: 8px 12px 9px 14px; }
  .v-actions { margin-top: 10px; }
}

/* where it landed on today's leaderboard (or the sign-in invitation) */
.v-board { margin: 10px 0 0; font: 500 17px/1.4 "Cormorant Garamond", serif; color: var(--v-ink); }
.v-board b { font-weight: 700; color: var(--v-red); font-variant-numeric: lining-nums; }
.v-board a, .v-board .linklike { color: var(--v-red); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.v-extra { margin: 3px 0 0; font: 500 16px/1.4 "Cormorant Garamond", serif; color: var(--v-muted); }
.v-extra b { color: var(--v-ink); font-weight: 700; }

/* one concrete tip, set off as a margin note */
.v-tip {
  margin: 16px 0 0; padding: 11px 14px 12px 16px;
  border-left: 3px solid var(--v-red);
  background: rgba(156, 44, 26, 0.06);
  border-radius: 0 3px 3px 0;
}
.v-tip-k { display: block; margin-bottom: 4px; font: 600 12px/1 "Cinzel", serif; letter-spacing: 0.14em; text-transform: uppercase; color: var(--v-red); }
.v-tip p { margin: 0; font: 500 18px/1.4 "Cormorant Garamond", serif; color: var(--v-ink); }

.v-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.v-actions button {
  min-height: 46px; padding: 0 20px;
  border: 1.5px solid var(--v-ink); border-radius: 2px;
  background: var(--v-ink); color: #f4e9d2;
  font: italic 600 19px "Cormorant Garamond", serif; cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.v-actions button:hover { background: #3a2c20; }
.v-actions button:active { transform: scale(0.97); }
.v-actions button.ghost { background: transparent; color: var(--v-ink); }
.v-actions button.ghost:hover { background: rgba(36, 27, 19, 0.07); }
.v-actions button:focus-visible, .v-close:focus-visible { outline: 2px solid var(--v-red); outline-offset: 3px; }
.v-poem {
  margin: 16px 0 0; padding: 14px 16px; white-space: pre-wrap;
  font: 17px/1.65 "IM Fell English", serif; color: var(--v-ink);
  background: rgba(36, 27, 19, 0.04); border-radius: 3px;
}
.v-note { margin: 12px 0 0; font: italic 500 14.5px/1.4 "Cormorant Garamond", serif; color: var(--v-muted); }
.v-close {
  position: absolute; top: 20px; right: 24px;
  width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; cursor: pointer;
  font: 400 34px/1 "Cormorant Garamond", serif; color: var(--v-ink);
}
.v-close:hover { background: rgba(36, 27, 19, 0.07); }

.see-ascent { position: relative; z-index: 1; text-align: center; margin: 10px 0 0; }
.see-ascent[hidden] { display: none; }
.see-ascent button {
  min-height: 46px; padding: 0 22px;
  border: 1.5px solid #f2d9a8; border-radius: 2px; background: rgba(30, 18, 10, 0.4);
  color: #fbf1dc; font: italic 600 20px "Cormorant Garamond", serif; cursor: pointer;
}

/* the page folding into a letter as the pigeon takes it */
.stage.sending .sheet { animation: fold-away 0.9s cubic-bezier(0.5, 0, 0.75, 0) forwards; }
.stage.sending .arm-adam { animation: withdraw-left 0.9s ease-in forwards; }
.stage.sending .arm-god { animation: withdraw-right 0.9s ease-in forwards; }
/* desktop: the tally is read from further away, so it's bigger and the counting rows stronger */
@media (min-width: 721px) {
  .tally { top: 4%; width: min(500px, 88vw); padding: 34px 46px 26px; }
  .tally-k { margin-bottom: 14px; font-size: 16px; }
  .tally-rows { gap: 12px; }
  .tally-rows li { opacity: 0.4; }
  .tally-rows b { font-size: 19px; }
  .tally-rows em { font-size: 22px; color: #5a4634; }
  .tally-rows .bar { height: 5px; }
  .tally-total { margin-top: 18px; padding-top: 12px; font-size: 78px; }
  .tally-total span { font-size: 26px; }
  /* the pigeon waits below the bigger tally, then takes off into its flight position */
  .flyer { transition: translate 1.6s cubic-bezier(0.25, 0.8, 0.25, 1), top 0.9s cubic-bezier(0.3, 0.7, 0.3, 1); }
  .ascent:not(.climbing):not(.done) .flyer { top: 77%; }   /* clear of the tally even while it drops in (14 px lower) */
}
@keyframes fold-away { to { transform: scale(0.12, 0.08) translateY(-200px) rotate(-8deg); opacity: 0; } }
@keyframes withdraw-left { to { transform: translateX(-40%); opacity: 0; } }
@keyframes withdraw-right { to { transform: translateX(40%); opacity: 0; } }

/* ---------- phones ---------- */
@media (max-width: 720px) {
  .flyer { top: 62%; --px: 3; }
  .ascent.done .flyer { left: 50%; top: 27%; transition: top 1s ease, translate 1.6s; }
  .tally { top: 7%; padding: 26px 28px 20px; }
  .tally-total { font-size: 48px; }
  /* the results sheet covers the lower ~60%: Icarus and the pigeon share the sky above it */
  .icarus { width: min(50vw, 30svh); left: 3%; top: 4%; }
  .ascent.at-summit.done .flyer { left: 74%; top: 19%; }
  .band-label { bottom: calc(var(--P) * (var(--k) - 1) + var(--F) + var(--D) * 0.36); }
  .verdict {
    left: 0; right: 0; top: auto; bottom: 0;
    translate: none;
    width: auto; max-height: 62svh;
    padding: 40px 26px 26px;
    background-image: url("assets/paper-wide.webp");
  }
  @keyframes verdict-in { from { opacity: 0; transform: translateY(40px); } }
  .v-score { font-size: 56px; }
  .v-row { grid-template-columns: 7.4em 1fr auto; gap: 10px; }
  .v-label { font-size: 12px; letter-spacing: 0.08em; }
  .v-level { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .flyer { transition: none; }
  .sprite, .flyer-tilt { animation: none; }
}
