/* Nightcap, the story. One evening told in six scenes as you scroll: line
   drawings in candlelight cream on a plum night, ending on morning paper.
   Every scene is a tall section with a sticky stage; story.js turns the scroll
   position inside it into 0..1 and draws, fills and fades from that. */

@font-face { font-family: Gloock; src: url(/fonts/Gloock-Regular.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: Newsreader; src: url(/fonts/Newsreader.woff2) format("woff2"); font-weight: 400 600; font-display: swap; }
@font-face { font-family: Newsreader; src: url(/fonts/Newsreader-Italic.woff2) format("woff2"); font-weight: 400 600; font-style: italic; font-display: swap; }

:root {
  --night: #1a0c1b;
  --cream: #f1e4cc;
  --paper: #f4ecdc;
  --ink: #4a1419;
  --rose: #d9a3a0;
  --gold: #f0c27a;
  --wine: #9b2d40;
  --display: Gloock, "Didot", "Bodoni 72", Georgia, serif;
  --text: Newsreader, Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { background: var(--night); -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--cream); font: 400 1.125rem/1.55 var(--text); overflow-x: clip; }
body::after {
  /* film grain over everything, generated inline so nothing is fetched */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 20; opacity: .5;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .95 0 0 0 0 .9 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .18em; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
::selection { background: var(--gold); color: var(--night); }
.defs { position: absolute; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--cream); color: var(--night); padding: 8px 14px; z-index: 30; }
.skip:focus { left: 12px; }

/* header floats over every scene; difference keeps it legible on night and paper */
.top {
  position: fixed; inset: 0 0 auto; z-index: 10; display: flex; justify-content: space-between; align-items: baseline;
  padding: max(18px, env(safe-area-inset-top)) clamp(18px, 4vw, 48px) 0; color: #fff; mix-blend-mode: difference;
}
.mark { font-family: var(--display); font-size: 1.35rem; text-decoration: none; letter-spacing: .01em; }
.top nav a { font-style: italic; text-decoration: none; }
.top nav a:hover { text-decoration: underline; }
.top nav { display: flex; gap: 18px; align-items: baseline; }
.top nav a.lang { font-style: normal; font-size: .78rem; letter-spacing: .12em; border: 1px solid currentColor; border-radius: 99px; padding: 1px 9px 0; align-self: center; }
.top nav a.lang:hover { text-decoration: none; }
.bar { position: fixed; inset: 0 0 auto; height: 2px; z-index: 11; }
.bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--wine), var(--gold)); transform-origin: 0 50%; transform: scaleX(0); }

/* scenes */
.scene { position: relative; height: 260vh; background: var(--bg, var(--night)); color: var(--fg, var(--cream)); }
.s-night { height: 230vh; }
.s-yes { height: 320vh; }
.s-jar { height: 300vh; }
.s-menu { height: 280vh; }
.s-morning { height: 260vh; }
.stage {
  position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: center;
  gap: clamp(16px, 4vw, 64px); padding: 72px clamp(20px, 6vw, 96px) 40px; max-width: 1360px; margin: 0 auto;
}
.art { display: grid; place-items: center; min-height: 0; height: 100%; }
.art > svg { width: 100%; height: 100%; max-height: 82vh; max-height: 82svh; overflow: visible; }

/* type */
.kicker { margin: 0 0 14px; font-style: italic; color: var(--rose); letter-spacing: .04em; font-size: 1.05rem; }
.display { font-family: var(--display); font-weight: 400; letter-spacing: -.02em; line-height: .95; margin: 0; font-size: clamp(2.7rem, 6.4vw, 5.6rem); text-wrap: balance; }
.display em { font-style: normal; color: var(--gold); }
h1.display { font-size: clamp(2.9rem, 7vw, 6.2rem); }
.lede { margin: 22px 0 0; font-size: clamp(1.15rem, 1.7vw, 1.4rem); line-height: 1.45; max-width: 30ch; color: color-mix(in srgb, currentColor 82%, transparent); }
.copy { position: relative; }
.swap { display: grid; }
.swap > * { grid-area: 1 / 1; }
.cue { margin-top: 48px; font-style: italic; color: var(--rose); font-size: 1rem; }
.cue::after { content: ""; display: block; width: 1px; height: 44px; margin-top: 10px; background: linear-gradient(var(--rose), transparent); animation: cue 2.2s ease-in-out infinite; transform-origin: top; }
@keyframes cue { 0% { transform: scaleY(0); } 55% { transform: scaleY(1); } 100% { transform: scaleY(1); opacity: 0; } }
.count { margin: 28px 0 0; font-style: italic; color: var(--rose); font-size: 1.2rem; }
.count b { font-family: var(--display); font-weight: 400; font-style: normal; font-size: clamp(3.4rem, 7vw, 5.4rem); color: var(--gold); font-variant-numeric: tabular-nums; margin-right: 8px; vertical-align: -0.12em; }
.bal { display: block; margin-top: 6px; font-family: var(--display); color: var(--gold); font-size: 1.6rem; }

/* drawing */
.ln, .ln use { fill: none; stroke: var(--line, var(--cream)); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.ln.gold { stroke: var(--gold); }
.ln.faint { opacity: .55; }
.ln .shine { opacity: .45; }
.winefill { fill: url(#wine); }
.jarfill { fill: url(#coins); }
.stream { fill: var(--wine); }
.moonfill { fill: var(--cream); opacity: .9; }
.stars circle, .stars .spark { fill: var(--cream); animation: twinkle 3.4s ease-in-out infinite; }
.stars :nth-child(2n) { animation-delay: -1.2s; } .stars :nth-child(3n) { animation-delay: -2.3s; animation-duration: 4.2s; }
@keyframes twinkle { 0%, 100% { opacity: .9; } 50% { opacity: .25; } }
.flame { fill: var(--gold); transform-box: fill-box; transform-origin: 50% 100%; animation: flicker 1.6s ease-in-out infinite; }
@keyframes flicker { 0%, 100% { transform: scale(1, 1) rotate(0); } 30% { transform: scale(.94, 1.06) rotate(-2deg); } 60% { transform: scale(1.04, .96) rotate(2deg); } }
.candleglow { animation: breathe 2.6s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .75; } }
.shadefill { fill: var(--gold); opacity: 0; }
.tiefill { fill: var(--wine); }
.lips { fill: none; stroke: #c94a5c; stroke-width: 7; stroke-linecap: round; }
.moonlight { fill: var(--cream); opacity: 0; }
.plus text, .tagtext { font-family: var(--text); font-style: italic; }
.plus text { fill: var(--gold); font-size: 22px; text-anchor: middle; }
.tag { fill: var(--paper); }
.tagtext { fill: var(--ink); font-size: 19px; text-anchor: middle; }
.sun { fill: #ffcf86; }
.steam path { fill: none; stroke: var(--line, var(--cream)); stroke-width: 1.6; stroke-linecap: round; opacity: .55; animation: steam 3s ease-in-out infinite; vector-effect: non-scaling-stroke; }
.steam path:nth-child(2) { animation-delay: -1.4s; }
@keyframes steam { 0% { transform: translateY(6px); opacity: 0; } 40% { opacity: .6; } 100% { transform: translateY(-14px); opacity: 0; } }

/* the hero copy arrives on its own, the rest waits for the scroll */
.intro { animation: arrive 1.4s cubic-bezier(.2, .7, .2, 1) both; }
h1.intro { animation-delay: .15s; }
.lede.intro { animation-delay: .35s; }
.cue.intro { animation-delay: 1.2s; }
@keyframes arrive { from { opacity: 0; transform: translateY(18px); } }

/* the menu card */
.card {
  position: relative; width: min(100%, 470px); background: var(--paper); color: var(--ink);
  border: 1.5px solid var(--ink); outline: 1px solid var(--ink); outline-offset: -9px;
  padding: clamp(26px, 4vw, 44px) clamp(24px, 4vw, 44px) 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
  will-change: transform;
}
.card-k { margin: 0; text-align: center; font-style: italic; color: #6e4a40; }
.card-h { margin: 4px 0 18px; text-align: center; font-family: var(--display); font-size: clamp(1.7rem, 3vw, 2.2rem); border-bottom: 1px solid var(--ink); padding-bottom: 14px; }
.items { list-style: none; margin: 0; padding: 0; }
.items li { position: relative; display: flex; align-items: baseline; gap: 10px; padding: 9px 0; }
.items li span { flex: 1; display: flex; flex-direction: column; font-weight: 600; font-size: 1.12rem; line-height: 1.2; }
.items li span::after { content: none; }
.items li i { font-weight: 400; font-size: .95rem; color: #6e4a40; }
.items li b { font-family: var(--display); font-weight: 400; font-size: 1.35rem; }
.loop { position: absolute; inset: -6px -18px -6px -16px; width: calc(100% + 34px); height: calc(100% + 12px); overflow: visible; pointer-events: none; }
.loop path { fill: none; stroke: var(--wine); stroke-width: 2.4; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.card-f { margin: 18px 0 0; padding-top: 12px; border-top: 1px solid var(--ink); text-align: center; font-style: italic; font-size: .92rem; color: #6e4a40; }

/* the end, on morning paper */
.end { background: var(--paper); color: var(--ink); text-align: center; padding: 18vh 22px 40px; --line: var(--ink); }
.endglass { width: 74px; height: auto; margin-bottom: 18px; overflow: visible; }
.end .display { font-size: clamp(3.4rem, 10vw, 7.5rem); }
.sub { margin: 8px 0 34px; font-style: italic; font-size: clamp(1.3rem, 2.4vw, 1.7rem); color: #6e4a40; }
.stores { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.stores span { display: inline-flex; flex-direction: column; align-items: flex-start; padding: 10px 22px; border-radius: 12px; background: var(--ink); color: var(--paper); font-size: .8rem; line-height: 1.2; min-width: 172px; }
.stores b { font-size: 1.15rem; font-weight: 600; }
.soon { margin: 14px 0 64px; font-style: italic; color: #6e4a40; }
.fine { max-width: 34rem; margin: 10px auto; color: #6e4a40; }
.foot { margin: 14vh auto 0; max-width: 1080px; border-top: 1px solid var(--ink); padding-top: 14px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px; font-size: .98rem; }
.foot small { flex-basis: 100%; color: #6e4a40; font-size: .9rem; }

/* phones: drawing on top, words underneath */
@media (max-width: 820px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; align-items: stretch; padding: 64px 22px 34px; gap: 10px; }
  .art { order: -1; }
  .art > svg { max-height: 54svh; }
  .copy { align-self: end; min-height: 13.5rem; }
  .display { font-size: clamp(2.5rem, 11vw, 3.4rem); }
  h1.display { font-size: clamp(2.6rem, 12vw, 3.6rem); }
  .lede { margin-top: 12px; font-size: 1.12rem; }
  .cue { margin-top: 18px; }
  .count { margin-top: 10px; }
  .count b { font-size: 3rem; }
  .s-menu .copy { min-height: 11rem; }
  .card { width: min(100%, 360px); padding: 22px 22px 18px; }
  .items li { padding: 5px 0; }
  .items li span { font-size: 1rem; }
  .items li i { font-size: .85rem; }
  .card-h { margin-bottom: 8px; padding-bottom: 8px; }
  .card-f { display: none; }
}

/* no motion: every scene shows its finished picture, one screen each */
@media (prefers-reduced-motion: reduce) {
  .scene { height: auto !important; }
  .stage { position: relative; height: auto; min-height: 100svh; }
  .stars *, .flame, .candleglow, .steam path, .cue::after { animation: none; }
}
