/* ════════════════════════════════════════════════════════════════════════
   backwaiter.com: the landing page.
   The page is one afternoon: each chapter carries its own light (--sky-top →
   --sky-bottom), and neighbouring chapters share an edge colour, so scrolling
   moves from sunlit paper to golden hour to night without a seam.
   Brand gold + burgundy are read straight off the logo (site/img/favicon.png).
   ════════════════════════════════════════════════════════════════════════ */

:root {
  /* ── brand (from the logo) ─────────────────────────────────────── */
  --burgundy:   #59011A;
  --gold:       #F1C763;

  /* ── the light, top of page → bottom ───────────────────────────── */
  --afternoon:  #FBF1DE;   /* 2:30, sun through the window     */
  --late:       #F7E3C1;
  --amber:      #F2CF97;   /* 3:05, the light turns              */
  --golden:     #EDB680;   /* 3:30, golden hour                  */
  --sunset:     #E39C78;
  --wine-dusk:  #7A1A2E;
  --night:      #24080F;   /* 4:45 on, candles lit               */
  --late-night: #160509;

  /* ── ink ───────────────────────────────────────────────────────── */
  --ink-day:    #2A0D15;
  --ink-night:  #F6E7C8;   /* candlelight                        */
  --ruby:       #A8102C;   /* backlit wine, on paper             */
  --ruby-glow:  #F2576F;   /* backlit wine, after dark           */

  /* ── type ──────────────────────────────────────────────────────── */
  --font-display: "Fraunces", Georgia, serif;
  --font-body:    "Hanken Grotesk", "Segoe UI", system-ui, sans-serif;

  --maxw: 1240px;
  --gutter: clamp(16px, 4vw, 48px);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--afternoon);
  color: var(--ink-day);
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, p, figure { margin: 0; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
.sprite { position: absolute; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
:focus-visible { outline: 3px solid var(--ruby); outline-offset: 3px; border-radius: 4px; }
.chapter--preshift :focus-visible, .chapter--doors :focus-visible, .foot :focus-visible { outline-color: var(--gold); }

/* ── wordmark ──────────────────────────────────────────────────────── */
.wordmark {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}
.br { color: var(--ruby); font-weight: 400; }

/* ── header ────────────────────────────────────────────────────────── */
.top {
  position: absolute; inset: 0 0 auto 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  max-width: var(--maxw); margin: 0 auto;
  padding: 20px var(--gutter);
}
.top .wordmark { font-size: 1.35rem; }

/* ── buttons ───────────────────────────────────────────────────────── */
.btn {
  font: 700 1.05rem/1 var(--font-body);
  color: #FFF8EC;
  background: var(--burgundy);
  border: 0; border-radius: 999px;
  padding: 1rem 1.7rem;
  cursor: pointer;
  box-shadow: 0 1px 0 rgb(255 255 255 / .18) inset, 0 6px 18px -8px rgb(89 1 26 / .6);
  transition: transform .15s ease, background-color .15s ease;
}
.btn:hover { background: #6E0A26; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn--small { font-size: .92rem; padding: .7rem 1.15rem; }
.btn--glow {
  color: var(--burgundy);
  background: var(--gold);
  box-shadow: 0 0 0 1px rgb(241 199 99 / .4), 0 0 40px -6px rgb(241 199 99 / .55);
}
.btn--glow:hover { background: #F6D47F; }
.quiet-link { font-weight: 600; text-underline-offset: .25em; text-decoration-thickness: 1px; }

/* ════════════════════════════════════════════════════════════════════
   CHAPTERS
   ════════════════════════════════════════════════════════════════════ */
.chapter {
  --ink: var(--ink-day);
  --accent: var(--ruby);
  background: linear-gradient(to bottom, var(--sky-top), var(--sky-bottom));
  color: var(--ink);
}
.chapter--hero     { --sky-top: var(--afternoon); --sky-bottom: var(--late); }
.chapter--homework { --sky-top: var(--late);      --sky-bottom: var(--amber); }
.chapter--snap     { --sky-top: var(--amber);     --sky-bottom: var(--golden); }
.chapter--reading  { --sky-top: var(--golden);    --sky-bottom: var(--golden); }
.chapter--decide   { --sky-top: var(--golden);    --sky-bottom: var(--sunset); }
.chapter--preshift { --sky-top: var(--night);     --sky-bottom: var(--night); }
.chapter--doors    { --sky-top: var(--night);     --sky-bottom: var(--late-night); }
.chapter--preshift, .chapter--doors { --ink: var(--ink-night); --accent: var(--ruby-glow); --hl: var(--gold); }

/* the sun going down between family meal and preshift: no words, just light */
.dusk {
  height: clamp(220px, 40vh, 420px);
  background: linear-gradient(to bottom, var(--sunset), var(--wine-dusk) 55%, var(--night));
}

.chapter__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(72px, 11vh, 132px) var(--gutter);
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 36rem) minmax(0, 1fr);
  column-gap: clamp(24px, 4vw, 64px);
  row-gap: clamp(40px, 7vh, 72px);
  align-items: start;
}

/* The clock: the page's timeline, pinned in the left margin while you read. */
.clock {
  grid-column: 1; grid-row: 1 / span 3;
  position: sticky; top: 28px;
  display: flex; flex-direction: column; gap: .2rem;
  padding-top: .6rem;
  border-top: 1px solid color-mix(in srgb, var(--ink) 30%, transparent);
}
.clock__time {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.6rem;
  font-weight: 400;
  line-height: 1.1;
  font-variant-numeric: lining-nums;
}
.clock__what { font-size: .88rem; line-height: 1.35; color: color-mix(in srgb, var(--ink) 68%, transparent); }

.chapter__text { grid-column: 2; display: grid; gap: 1.1rem; }
.chapter__text p { max-width: 34em; }

h2 {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 6vw, 4.6rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.025em;
  font-variation-settings: "opsz" 144;
  margin-bottom: .5rem;
  text-wrap: balance;
}

/* A line said out loud: the big sentence each chapter turns on. */
.say {
  grid-column: 2;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(2rem, 4.8vw, 3.9rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  max-width: 18ch;
  font-variation-settings: "opsz" 144;
  text-wrap: balance;
}

.aside {
  font-size: 1rem;
  padding-left: 1rem;
  border-left: 2px solid var(--accent);
  color: color-mix(in srgb, var(--ink) 80%, transparent);
}

/* The phrases the glass will point at later. For now: a wash of wine underneath. */
/* The key lines. The underline draws itself in when the line reaches the middle of the screen
   (main.js adds .is-drawn); on wide screens the glass floats over just before it does. */
mark.hl {
  color: inherit;
  background-color: transparent;
  background-image: linear-gradient(var(--hl, color-mix(in srgb, var(--ruby) 75%, transparent)), var(--hl, color-mix(in srgb, var(--ruby) 75%, transparent)));
  background-repeat: no-repeat;
  background-position: 0 92%;
  background-size: 0% .14em;
  padding: 0 .04em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  transition: background-size 1.1s cubic-bezier(.65, 0, .35, 1) .35s;
}
mark.hl.is-drawn { background-size: 100% .14em; }

/* The homework, crossed off one line at a time. */
.chores {
  list-style: none; margin: .2rem 0 .4rem; padding: 0;
  display: grid; gap: .3rem;
  font-family: var(--font-display); font-style: italic; font-weight: 400;
  font-size: clamp(1.35rem, 2.3vw, 1.7rem); line-height: 1.25;
}
.chores li { position: relative; width: fit-content; transition: color .4s ease; }
.chores li::after {
  content: ""; position: absolute; left: -.12em; right: -.12em; top: 56%;
  height: .085em; border-radius: 2px;
  background: var(--ruby);
  transform: scaleX(0) rotate(-1.4deg); transform-origin: left center;
  transition: transform .5s cubic-bezier(.65, 0, .35, 1);
}
.chores.is-drawn li { color: color-mix(in srgb, var(--ink) 50%, transparent); }
.chores.is-drawn li::after { transform: scaleX(1) rotate(-1.4deg); }
.chores li:nth-child(2), .chores li:nth-child(2)::after { transition-delay: .3s; }
.chores li:nth-child(3), .chores li:nth-child(3)::after { transition-delay: .6s; }
.chores li:nth-child(4), .chores li:nth-child(4)::after { transition-delay: .9s; }
.chores li:nth-child(5), .chores li:nth-child(5)::after { transition-delay: 1.2s; }

q { quotes: "“" "”"; font-style: italic; }

/* ── hero ──────────────────────────────────────────────────────────── */
.chapter--hero .chapter__inner {
  min-height: 100svh;
  align-content: center;
  padding-top: clamp(110px, 18vh, 200px);
  row-gap: 2.2rem;
}
.hero__title {
  font-family: var(--font-display);
  font-size: clamp(3.2rem, 8.6vw, 7.4rem);
  font-weight: 650;
  line-height: .93;
  letter-spacing: -0.035em;
  font-variation-settings: "opsz" 144;
  grid-column: 2 / -1; grid-row: 1;
}
.chapter--hero .chapter__text { grid-row: 2; }
.lead { font-size: clamp(1.15rem, 1.6vw, 1.3rem); max-width: 30em; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 1rem 1.6rem; margin-top: 1.4rem; }

.chapter--hero .hero__glass { grid-column: 3; grid-row: 2; justify-self: center; align-self: start; margin-top: -1.5rem; }
.mark { display: block; width: clamp(180px, 22vw, 300px); height: auto; overflow: visible; }
.mark__half { fill: var(--gold); }
.chapter--hero .mark__half { fill: #D9A93F; } /* gold reads a touch deeper on paper */
.hero__glass .mark { filter: drop-shadow(0 30px 40px rgb(168 16 44 / .18)); }

/* ── screenshots ───────────────────────────────────────────────────── */
.chapter__figure { grid-column: 3; grid-row: 1 / span 3; }
.chapter__figure--wide { grid-column: 2 / -1; grid-row: auto; }
.shot figcaption {
  margin-top: .8rem;
  font-family: var(--font-display);
  font-style: italic;
  font-size: .98rem;
  color: color-mix(in srgb, var(--ink) 72%, transparent);
}

.frame {
  overflow: hidden;
  background: #FFFDF8;
  box-shadow: 0 1px 0 rgb(255 255 255 / .6) inset, 0 30px 60px -30px rgb(60 10 20 / .45), 0 0 0 1px rgb(42 13 21 / .08);
}
.frame--browser { border-radius: 14px; padding-top: 26px; position: relative; }
.frame--browser::after {    /* the bar the dots sit on, kept above a zoomed image */
  content: ""; position: absolute; inset: 0 0 auto 0; height: 26px;
  background: #FFFDF8; z-index: 1;
  border-bottom: 1px solid rgb(42 13 21 / .08);
}
.frame--browser::before {   /* three dots: it's a real app in a real browser */
  content: ""; position: absolute; top: 9px; left: 12px; z-index: 2;
  width: 8px; height: 8px; border-radius: 50%;
  background: #D9C9B5;
  box-shadow: 13px 0 0 #D9C9B5, 26px 0 0 #D9C9B5;
}
.frame--browser img { border-top: 1px solid rgb(42 13 21 / .08); }

/* scroll zoom: main.js sets --zoom (1 → data-zoom) as the frame crosses the screen */
.zoom img {
  transform-origin: var(--fx, 50%) var(--fy, 50%);
  transform: scale(var(--zoom, 1));
}

.frame--phone {
  width: min(300px, 78vw, 100%);
  border-radius: 38px;
  padding: 10px;
  background: #120408;
  box-shadow: 0 0 0 1px rgb(241 199 99 / .25), 0 40px 80px -30px rgb(0 0 0 / .8), 0 0 90px -20px rgb(242 87 111 / .25);
}
.frame--phone img { border-radius: 29px; }
.shot--phone { justify-self: stretch; display: flex; flex-direction: column; align-items: center; }

/* ── ending ────────────────────────────────────────────────────────── */
.chapter--doors .chapter__inner { min-height: 100svh; align-content: center; }
.ending {
  grid-column: 2 / -1;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 1.1rem;
}
.ending h2 { color: var(--gold); margin-bottom: 0; }
.ending__line { font-size: 1.2rem; max-width: 26em; }

/* The ending: the empty glass }{ swings open, each half flipping into a bracket of { backwaiter }. */
.reveal {
  display: flex; align-items: center; justify-content: center;
  height: clamp(130px, 16vw, 180px);
  margin-bottom: .8rem;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 7vw, 5rem);
  line-height: 1;
  perspective: 700px;
}
.reveal__half {
  height: clamp(130px, 16vw, 180px); width: auto; aspect-ratio: 346.5 / 868;
  overflow: visible;
  transition: transform 1s cubic-bezier(.65, 0, .35, 1), height .9s cubic-bezier(.65, 0, .35, 1) .55s;
}
.reveal__half .mark__half { fill: var(--gold); }
.reveal__word {
  max-width: 0; opacity: 0; overflow: hidden; white-space: nowrap;
  color: var(--ink-night); font-weight: 500; letter-spacing: -0.01em;
  transition: max-width 1s cubic-bezier(.65, 0, .35, 1) .7s, margin .9s ease .7s, opacity .7s ease 1.05s;
}
.reveal.is-open .reveal__half { transform: rotateY(180deg); height: 1.25em; }
.reveal.is-open .reveal__word { max-width: 6.4em; opacity: 1; margin: 0 .16em; }
.ending__pilot { font-size: 1.15rem; max-width: 26em; margin-bottom: .6rem; }
.ending__byline {
  margin-top: 1.2rem;
  font-family: var(--font-display); font-style: italic;
  font-size: 1rem;
  color: color-mix(in srgb, var(--ink) 72%, transparent);
}

.foot {
  background: var(--late-night);
  color: color-mix(in srgb, var(--ink-night) 70%, transparent);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem 2rem;
  padding: 28px var(--gutter);
  font-size: .92rem;
}
.foot a { text-decoration: none; }
.foot a:hover, .motion-toggle:hover { color: var(--gold); }
.motion-toggle {
  border: 0; background: none; padding: 0; cursor: pointer;
  font: inherit; color: inherit;
}

/* ── the companion glass ───────────────────────────────────────────── */
.companion {
  position: fixed; left: 0; top: 0; z-index: 4;
  width: 52px;
  pointer-events: none;
  opacity: 0;
  transform: translate(var(--x, 24px), var(--y, 50vh));
  transition: opacity .45s ease, transform 1s cubic-bezier(.33, 1, .68, 1);
}
.companion.is-on { opacity: 1; }
.companion .mark { width: 100%; filter: drop-shadow(0 8px 14px rgb(60 10 20 / .25)); }
.companion .mark__half { fill: #D9A93F; transition: fill .6s ease; }
.companion.is-night .mark__half { fill: var(--gold); }
.mark__wine { transition: transform .9s cubic-bezier(.45, 0, .25, 1); }

@media (max-width: 1100px) {   /* no room to drift: it sits in the corner and just drinks */
  .companion { width: 34px; transform: none; left: auto; top: auto; right: 14px; bottom: 14px; }
}

/* Motion off (the footer switch, or the phone/computer's reduce-motion setting): everything sits still. */
.no-motion .companion { display: none; }
.no-motion mark.hl { background-size: 100% .14em; transition: none; }
.no-motion .chores li, .no-motion .chores li::after, .no-motion .reveal *, .no-motion .mark__wine { transition: none !important; }

/* ════════════════════════════════════════════════════════════════════
   REQUEST INFO
   ════════════════════════════════════════════════════════════════════ */
.request {
  border: 0; padding: 0; margin: auto;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100svh - 24px);
  border-radius: 22px;
  background: var(--afternoon);
  color: var(--ink-day);
  box-shadow: 0 40px 100px -30px rgb(22 5 9 / .7);
}
.request::backdrop { background: rgb(22 5 9 / .55); backdrop-filter: blur(3px); }
.request__panel { position: relative; padding: clamp(22px, 5vw, 36px); }
.request__close {
  position: absolute; top: 10px; right: 12px;
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: transparent; color: inherit; font-size: 1.7rem; line-height: 1; cursor: pointer;
}
.request__close:hover { background: rgb(42 13 21 / .07); }
.request h2 { font-size: clamp(1.9rem, 6vw, 2.4rem); margin-bottom: .4rem; padding-right: 2rem; }
.request__intro { color: color-mix(in srgb, var(--ink-day) 75%, transparent); margin-bottom: 1.2rem; }
.request__form { display: grid; gap: 1rem; }

.field { display: grid; gap: .3rem; font-weight: 600; font-size: .95rem; }
.field input, .field textarea {
  font: 400 1rem/1.4 var(--font-body);
  color: inherit;
  background: #FFFDF8;
  border: 1px solid rgb(42 13 21 / .2);
  border-radius: 12px;
  padding: .75rem .9rem;
  width: 100%;
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--ruby); outline-offset: 1px; border-color: transparent; }

.chips { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .45rem; }
.chips legend { font-weight: 600; font-size: .95rem; margin-bottom: .45rem; padding: 0; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chips span {
  display: inline-block;
  padding: .55rem .95rem;
  border: 1px solid rgb(42 13 21 / .22);
  border-radius: 999px;
  background: #FFFDF8;
  font-size: .95rem; font-weight: 500;
  transition: background-color .12s ease, color .12s ease, border-color .12s ease;
}
.chips label:hover span { border-color: var(--burgundy); }
.chips input:checked + span { background: var(--burgundy); border-color: var(--burgundy); color: #FFF8EC; }
.chips input:focus-visible + span { outline: 3px solid var(--ruby); outline-offset: 2px; }
.chips.is-missing legend { color: var(--ruby); }
.chips.is-missing legend::after { content: " (pick one)"; font-weight: 500; }

.note summary { cursor: pointer; font-weight: 600; font-size: .95rem; color: var(--burgundy); width: max-content; }
.note .field { margin-top: .6rem; }
.request__submit { justify-self: start; margin-top: .3rem; }
.request__status { min-height: 1.4em; font-size: .95rem; }
.request__done { display: grid; gap: 1rem; justify-items: start; }

/* ════════════════════════════════════════════════════════════════════
   NARROWER SCREENS
   ════════════════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .chapter__inner { grid-template-columns: minmax(0, 1fr); }
  .chapter__inner > * { grid-column: 1 !important; grid-row: auto !important; }
  .clock {
    position: static;
    flex-direction: row; align-items: baseline; gap: .8rem;
    border-top: 0; padding-top: 0;
  }
  .chapter__figure { max-width: 720px; }
  .chapter--hero .hero__glass { order: -1; justify-self: start; }
  .chapter--hero .mark { width: clamp(96px, 22vw, 150px); }
  .chapter--hero .chapter__inner { row-gap: 28px; align-content: start; }
  .chapter--hero .hero__glass { margin-top: 0; }
  .ending { align-items: center; }
}

@media (max-width: 520px) {
  body { font-size: 1.06rem; }
  .chapter__inner { padding-top: 84px; padding-bottom: 84px; }
  .top { padding-top: 14px; }
  .top .wordmark { font-size: 1.15rem; }
  .clock__time { font-size: 1.3rem; }
}
