/*
 * Wedding invitation + guest guide (EPIC-10).
 *
 * One invitation tied with a ribbon; under it, a stack of cards the guest
 * takes off one by one with a vertical swipe. Tokens are the photo app's
 * "Wedding Paper" palette (frontend/src/index.css), plus the ribbon, which
 * is sampled from the real chiffon on the printed invitations. Single
 * deliberate look, like the paper it imitates: no dark variant.
 */
@font-face { font-family: 'Arsenal SC'; src: url('/fonts/ArsenalSC-Regular.woff2') format('woff2'); font-weight: 400; font-display: block; }
@font-face { font-family: 'Arsenal SC'; src: url('/fonts/ArsenalSC-Bold.woff2') format('woff2'); font-weight: 700; font-display: block; }
@font-face { font-family: 'Modelista Signature'; src: url('/fonts/Modelista-Signature.woff2') format('woff2'); font-display: block; }

:root {
  color-scheme: light;
  --ground: #f5ebe0;
  --ground-deep: #ecd8c3;
  --card: #fcf8f3;
  --burgundy: #640d14;
  --burgundy-soft: #8a2630;
  --burgundy-mute: #93333c;
  --burgundy-hair: rgb(100 13 20 / 0.22);
  --burgundy-edge: #a36758;
  --ink: #2a1d19;
  --ribbon: #7c1431;
  --ribbon-lit: #9b2148;
  --ribbon-dark: #4f0a1d;
  --on-burgundy: #f5ebe0;

  --f-script: 'Modelista Signature', 'Snell Roundhand', cursive;
  --f-text: 'Arsenal SC', 'Palatino', Georgia, serif;

  /* The card is the whole phone screen; on a wider screen, a phone-width column. */
  --cw: min(100vw, 520px);
  --ch: 100vh;
  --hint-bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  --paper-tex: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35  0 0 0 0 .25  0 0 0 0 .2  0 0 0 .085 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

@supports (height: 100dvh) { :root { --ch: 100dvh; } }

html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 20%, #f9f2ec 0%, var(--ground) 55%, var(--ground-deep) 100%);
  color: var(--ink);
  font-family: var(--f-text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---------- cards ---------- */
.card {
  position: absolute;
  left: 50%; top: 50%;
  width: var(--cw); height: var(--ch);
  margin-left: calc(var(--cw) / -2);
  margin-top: calc(var(--ch) / -2);
  box-sizing: border-box;
  background: var(--paper-tex), linear-gradient(170deg, #fffdfa 0%, var(--card) 60%, #f6efe6 100%);
  box-shadow:
    0 1px 1px rgb(60 20 15 / 0.08),
    0 10px 30px -12px rgb(60 20 15 / 0.35),
    0 30px 60px -30px rgb(60 20 15 / 0.25);
  transform-origin: 50% 60%;
  transition: transform .62s cubic-bezier(.2,.75,.2,1), opacity .4s ease;
  will-change: transform;
  overflow: hidden;
  container-type: inline-size;
}
.card-inner {
  height: 100%; box-sizing: border-box;
  /* clear the notch, the home bar + swipe hint, and the dots on the right */
  padding-top: calc(env(safe-area-inset-top, 0px) + 28px);
  padding-bottom: calc(var(--hint-bottom) + 56px);
  padding-left: max(28px, calc(env(safe-area-inset-left, 0px) + 16px));
  padding-right: max(36px, calc(env(safe-area-inset-right, 0px) + 24px));
  display: flex; flex-direction: column; justify-content: center;
  gap: 14px;
  color: var(--burgundy);
}

/* ---------- type ---------- */
.eyebrow {
  margin: 0;
  font-size: 0.82rem; letter-spacing: 0.16em;
  color: var(--burgundy-mute);
}
.script {
  margin: 0;
  font-family: var(--f-script); font-weight: 400;
  font-size: clamp(2.7rem, 13vw, 3.7rem);
  line-height: 1.05;
  color: var(--burgundy);
  padding: 0.12em 0 0.18em;
}
/* landing.js shrinks a heading to fit one line; these two are long enough
   to read better on two, as the photo app's "You make / memories." does */
.script.two-lines { line-height: 1.2; font-size: clamp(2.4rem, 13cqw, 3.4rem); }
.lead { margin: 0; font-size: 1.06rem; line-height: 1.45; color: var(--ink); text-wrap: pretty; }
.small { margin: 0; font-size: 0.92rem; line-height: 1.45; color: var(--burgundy-soft); text-wrap: pretty; }

.todo {
  display: inline-block;
  padding: 1px 7px;
  border: 1px dashed var(--burgundy-edge);
  border-radius: 4px;
  font-size: 0.78rem; letter-spacing: 0.08em;
  color: var(--burgundy-mute);
  background: rgb(100 13 20 / 0.04);
}

/* reveal sequence on the card that is on top */
.card .reveal > * { opacity: 0; transform: translateY(8px); transition: opacity .5s ease, transform .6s cubic-bezier(.2,.75,.2,1); }
.card.is-current .reveal > * { opacity: 1; transform: none; }
.card.is-current .reveal > *:nth-child(1) { transition-delay: .15s }
.card.is-current .reveal > *:nth-child(2) { transition-delay: .25s }
.card.is-current .reveal > *:nth-child(3) { transition-delay: 1.0s }
.card.is-current .reveal > *:nth-child(4) { transition-delay: 1.1s }
.card.is-current .reveal > *:nth-child(5) { transition-delay: 1.2s }
.card.is-current .reveal > *:nth-child(6) { transition-delay: 1.3s }
.card.is-current .reveal > *:nth-child(n+7) { transition-delay: 1.4s }

/* the heading writes itself: a wipe that follows the pen, left to right */
.card .script.write { clip-path: inset(-40% 100% -40% -10%); }
.card.is-current .script.write { animation: write 1.25s .3s cubic-bezier(.55,.1,.35,1) forwards; }
@keyframes write { to { clip-path: inset(-40% -10% -40% -10%); } }

/* ---------- cover + ribbon ---------- */
.cover { z-index: 500; touch-action: none; cursor: grab; }
.cover:active { cursor: grabbing; }
.cover .card-inner { justify-content: flex-start; align-items: center; text-align: center; padding-top: calc(env(safe-area-inset-top, 0px) + 16vh); gap: 18px; }
/* Sized to the card, not the screen: one name per line, the second set in
   like the invitation's own swash. */
.cover .names-script { font-size: 13cqw; line-height: .95; text-align: left; width: 100%; }
.cover .names-script span { display: block; }
.cover .names-script span + span { padding-left: 22%; }
.cover .date { margin: 0; font-size: 1.35rem; letter-spacing: 0.12em; color: var(--ink); font-variant-numeric: tabular-nums; }
.cover.gone { transform: translate3d(0, -118vh, 0) rotate(-8deg) !important; transition: transform .9s cubic-bezier(.55,0,.3,1); }

.band {
  position: absolute; top: 62%; height: 40px; margin-top: -20px;
  width: 54%;
  background:
    repeating-linear-gradient(90deg, rgb(255 255 255 / 0.03) 0 2px, transparent 2px 5px),
    linear-gradient(180deg, var(--ribbon-dark) 0%, var(--ribbon) 18%, var(--ribbon-lit) 46%, var(--ribbon) 70%, var(--ribbon-dark) 100%);
  opacity: 0.93;
  box-shadow: 0 2px 6px rgb(60 10 20 / 0.25);
  will-change: transform;
}
.band::before, .band::after {
  content: ""; position: absolute; left: 0; right: 0; height: 3px;
  background: repeating-linear-gradient(90deg, var(--ribbon) 0 1px, transparent 1px 3px);
  opacity: .7;
}
.band::before { top: -2px; } .band::after { bottom: -2px; }
.band-l { left: -4%; transform-origin: 0 50%; }
.band-r { right: -4%; transform-origin: 100% 50%; }

.bow {
  position: absolute; left: 50%; top: 62%;
  width: 52%; aspect-ratio: 220 / 250;
  transform: translate(-50%, -36%);
  overflow: visible; pointer-events: none;
}
.tug { animation: tug 3.2s 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: 0 0; }
.cover.touched .tug { animation: none; }
@keyframes tug {
  0%, 72%, 100% { transform: none; }
  80% { transform: translate(6px, 7px) rotate(-4deg); }
  88% { transform: translate(2px, 2px); }
}

.pull-hint {
  position: absolute; bottom: var(--hint-bottom); left: 0; right: 0;
  display: flex; justify-content: center; align-items: center; gap: 8px;
  font-size: 0.84rem; letter-spacing: 0.16em; color: var(--burgundy-mute);
  transition: opacity .3s;
}
.cover.touched .pull-hint { opacity: 0; }
.pull-hint svg { animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translate(3px, 3px); } }

/* ---------- countdown ---------- */
.count { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-block: 6px; }
.count div { display: flex; flex-direction: column; align-items: center; gap: 2px; padding-block: 10px; border-top: 1px solid var(--burgundy-hair); border-bottom: 1px solid var(--burgundy-hair); }
.count b { font-weight: 400; font-size: clamp(2rem, 10vw, 2.7rem); line-height: 1; font-variant-numeric: tabular-nums; color: var(--burgundy); }
.count span { font-size: 0.74rem; letter-spacing: 0.16em; color: var(--burgundy-mute); }
.state-now, .state-after { display: none; font-size: 1.5rem; }
[data-state="now"] .count, [data-state="after"] .count { display: none; }
[data-state="now"] .state-now, [data-state="after"] .state-after { display: block; }

/* ---------- ceremony ---------- */
.time { margin: 0; font-size: clamp(2.2rem, 11vw, 2.9rem); line-height: 1; color: var(--burgundy); font-variant-numeric: tabular-nums; }
.place { margin: 0; font-size: 1.22rem; line-height: 1.3; font-weight: 700; color: var(--burgundy); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 42px; padding: 0 16px; box-sizing: border-box;
  border-radius: 999px;
  font: inherit; font-size: 0.9rem; letter-spacing: 0.08em;
  text-decoration: none; cursor: pointer;
  border: 1px solid var(--burgundy-edge); color: var(--burgundy); background: transparent;
}
.btn.primary { background: var(--burgundy); border-color: var(--burgundy); color: var(--on-burgundy); }
.btn:focus-visible { outline: 2px solid var(--burgundy); outline-offset: 3px; }

.names { margin: 0; font-size: 1.12rem; font-weight: 700; letter-spacing: .04em; color: var(--burgundy); }
.invite .card-inner { gap: 12px; }
.toc { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.toc li { border-bottom: 1px solid var(--burgundy-hair); }
.toc li:first-child { border-top: 1px solid var(--burgundy-hair); }
.toc button { width: 100%; min-height: 46px; padding: 0; border: 0; background: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font: inherit; font-size: 1.02rem; color: var(--burgundy); text-align: left; }
.toc button::after { content: "↓"; color: var(--burgundy-mute); }
.toc button:focus-visible { outline: 2px solid var(--burgundy); outline-offset: 2px; }

.tight { gap: 10px; }
.tight .script { font-size: clamp(2.4rem, 11vw, 3.2rem); }
.map {
  position: relative; display: block;
  height: min(calc(var(--cw) * 0.6), 30dvh);
  border-radius: 3px; overflow: hidden;
  background: #fbf6f1;
  box-shadow: inset 0 0 0 1px var(--burgundy-hair), inset 0 0 18px rgb(100 13 20 / 0.06);
}
.map svg { width: 100%; height: 100%; display: block; }
.map:focus-visible { outline: 2px solid var(--burgundy); outline-offset: 3px; }
.m-park { fill: var(--burgundy); fill-opacity: .06; }
.m-water { fill: var(--burgundy); fill-opacity: .13; }
.m-bld { fill: var(--burgundy); fill-opacity: .09; }
.m-minor { fill: none; stroke: var(--burgundy); stroke-opacity: .16; stroke-width: .7; }
.m-major { fill: none; stroke: var(--burgundy); stroke-opacity: .5; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.m-label { font-family: var(--f-text); font-size: 10px; letter-spacing: .08em; fill: var(--burgundy-mute); }
.m-park-label { font-size: 9px; fill-opacity: .8; }
.m-venue { font-family: var(--f-text); font-weight: 700; font-size: 12px; letter-spacing: .06em; fill: var(--burgundy); paint-order: stroke; stroke: #fcf8f3; stroke-width: 3px; }
.m-pin path { fill: var(--burgundy); }
.m-pin-eye { fill: #fcf8f3; }
.m-pulse { fill: var(--burgundy); opacity: 0; transform-box: fill-box; transform-origin: center; }
.card.is-current .m-pulse { animation: pulse 2.4s 1.4s ease-out infinite; }
@keyframes pulse { 0% { opacity: .22; transform: scale(.4); } 100% { opacity: 0; transform: scale(2.6); } }
/* ODbL attribution for the street data; keep it on the map */
.map-credit {
  position: absolute; left: 6px; bottom: 5px;
  font-size: 0.6rem; letter-spacing: .04em; color: var(--burgundy-mute);
  background: rgb(252 248 243 / 0.8); padding: 0 3px; border-radius: 2px;
}

/* ---------- lists ---------- */
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rows li { display: grid; grid-template-columns: 4.4em 1fr; gap: 12px; align-items: baseline; padding-block: 9px; border-bottom: 1px solid var(--burgundy-hair); }
.rows li:first-child { border-top: 1px solid var(--burgundy-hair); }
.rows .k { font-size: 0.95rem; color: var(--burgundy); font-variant-numeric: tabular-nums; }
.rows .v { font-size: 0.98rem; line-height: 1.35; color: var(--ink); min-width: 0; }
.rows.info li { grid-template-columns: 1fr; gap: 3px; }
.rows.info .k { font-size: 0.78rem; letter-spacing: 0.16em; color: var(--burgundy-mute); }

/* ---------- chrome ---------- */
.dots {
  position: fixed; z-index: 900;
  right: max(10px, env(safe-area-inset-right, 0px)); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 6px;
  transition: opacity .4s;
}
.dots button { width: 18px; height: 18px; padding: 0; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.dots button::before { content: ""; width: 5px; height: 5px; border-radius: 3px; background: var(--burgundy-edge); opacity: .55; transition: height .35s, background .35s, opacity .35s; }
.dots button.section-start { margin-top: 10px; }
.dots button[aria-current="true"]::before { height: 16px; background: var(--burgundy); opacity: 1; }
.dots button:focus-visible { outline: 2px solid var(--burgundy); border-radius: 4px; }
.locked .dots { opacity: 0; pointer-events: none; }

/* Added to every card by landing.js; the last card gets "back to start". */
.swipe-hint {
  position: absolute; left: 0; right: 0; bottom: var(--hint-bottom);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 0.74rem; letter-spacing: 0.18em; color: var(--burgundy-mute);
  opacity: 0; transition: opacity .5s 1.4s;
}
.card.is-current .swipe-hint { opacity: 1; }
button.swipe-hint {
  margin-inline: auto; width: max-content; padding: 8px 14px;
  border: 0; background: none; font: inherit; cursor: pointer;
}
button.swipe-hint:focus-visible { outline: 2px solid var(--burgundy); border-radius: 4px; }
.swipe-hint svg { animation: up 1.8s ease-in-out infinite; }
@keyframes up { 50% { transform: translateY(-5px); } }

/* programmatic focus after the cover opens; nothing to outline */
.card:focus { outline: none; }

@media (prefers-reduced-motion: reduce) {
  .card { transition: opacity .3s ease; }
  .card .script.write, .card.is-current .script.write { clip-path: none; animation: none; }
  .swipe-hint { transition: none; }
  .card .reveal > * { transition: none; opacity: 1; transform: none; }
  .tug, .pull-hint svg, .swipe-hint svg { animation: none; }
  .cover.gone { transform: none !important; opacity: 0; transition: opacity .5s; }
}
