* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --ink: #2b2620;
  --paper: #ece2cb;
  --accent: #b8432c;
  --serif: "Iowan Old Style", Palatino, Georgia, serif;
}
html { scroll-behavior: auto; }
body { background: var(--paper); color: var(--ink); font-family: var(--serif); }

/* ---------- the scrolling story ---------- */
#track { position: relative; }
#stage { position: sticky; top: 0; height: 100vh; overflow: hidden; }
#bg { position: absolute; inset: 0; background: var(--paper); transition: none; }

/* sparse drawn space: a horizon line and a few floor strokes, nothing more */
#linework { position: absolute; inset: 0; opacity: .5; pointer-events: none; }

.chapter { position: absolute; inset: 0; }
.layer { position: absolute; left: 0; top: 0; will-change: transform, opacity; }
.layer img { height: 100%; width: auto; display: block; }

.layer.missing {
  width: 14vw; border: 2px dashed rgba(43, 38, 32, .32); border-radius: 6px;
  background: rgba(43, 38, 32, .05);
}
.layer.missing::after {
  content: attr(data-name); position: absolute; inset: auto 0 6px; text-align: center;
  font: 12px/1.3 var(--serif); letter-spacing: .4px; color: rgba(43, 38, 32, .5);
}

/* ---------- the couple, pinned ---------- */
#couple {
  position: absolute; left: 0; top: 0; z-index: 60;
  display: flex; align-items: flex-end; gap: 1.2vw;
  animation: breathe 7s ease-in-out infinite;
}
/* faint contact shadow so the cutouts stand on the drawn floor instead of hovering */
#couple::after {
  content: ''; position: absolute; left: 50%; bottom: -1.1%; width: 118%; height: 5%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(43, 38, 32, .22), rgba(43, 38, 32, 0) 70%);
}
.figure { height: 100%; position: relative; }
.figure img { height: 100%; width: auto; display: block; }
.groom { animation: swayA 9s ease-in-out infinite; transform-origin: 50% 100%; }
.bride { animation: swayB 11s ease-in-out infinite; transform-origin: 50% 100%; }
.figure.missing {
  width: 9vh; border: 2px dashed rgba(43, 38, 32, .4); border-radius: 8px;
  background: rgba(43, 38, 32, .06);
}
.figure.missing::after {
  content: attr(data-name); position: absolute; inset: auto 0 8px; text-align: center;
  font: 12px var(--serif); color: rgba(43, 38, 32, .55);
}
@keyframes breathe { 0%,100% { scale: 1 1; } 50% { scale: 1.004 1.008; } }
@keyframes swayA { 0%,100% { rotate: -.5deg; } 50% { rotate: .5deg; } }
@keyframes swayB { 0%,100% { rotate: .6deg; } 50% { rotate: -.4deg; } }

/* ---------- caption ---------- */
#caption {
  position: absolute; left: 50%; top: 9vh; transform: translateX(-50%);
  width: min(620px, 78vw); text-align: center; z-index: 70; pointer-events: none;
}
#caption h2 { font-size: clamp(28px, 4.4vw, 54px); font-weight: 400; letter-spacing: .4px; }
#caption p { margin-top: 10px; font-size: clamp(14px, 1.5vw, 19px); opacity: .7; line-height: 1.5; }

/* ---------- the ordinary pages at the end ---------- */
#pages { position: relative; z-index: 2; background: var(--paper); padding: 8vh 6vw 14vh; }
#outro { text-align: center; margin-bottom: 9vh; }
#outro h2 { font-size: clamp(30px, 5vw, 60px); font-weight: 400; }
#outro p { opacity: .7; margin-top: 10px; }
.cards { display: grid; gap: 28px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); max-width: 1120px; margin: 0 auto; }
.card { border: 1px solid rgba(43, 38, 32, .18); padding: 26px 24px; background: rgba(255, 255, 255, .34); }
.card h3 { font-weight: 400; font-size: 22px; margin-bottom: 10px; }
.card p, .card li { font-size: 15px; line-height: 1.6; opacity: .82; }
.card ul { margin: 8px 0 0 18px; }
form { display: grid; gap: 10px; margin-top: 14px; }
input, select, textarea {
  font: 15px var(--serif); padding: 10px 12px; border: 1px solid rgba(43, 38, 32, .28);
  background: rgba(255, 255, 255, .6); color: var(--ink);
}
button {
  font: 16px var(--serif); padding: 11px 18px; border: 0; background: var(--accent); color: #fdf6e6;
  cursor: pointer; letter-spacing: .4px;
}

/* ---------- art-direction panel ---------- */
#panel {
  position: fixed; right: 14px; bottom: 14px; z-index: 200; display: flex; align-items: center; gap: 10px;
  background: rgba(43, 38, 32, .84); color: #f2ead8; padding: 9px 12px; border-radius: 8px;
  font: 12px/1 var(--serif); letter-spacing: .3px;
}
#panel input[type=color] { width: 28px; height: 22px; border: 0; background: none; padding: 0; }
#hud { position: fixed; left: 14px; bottom: 14px; z-index: 200; display: none;
  background: rgba(43, 38, 32, .84); color: #f2ead8; padding: 8px 11px; border-radius: 8px; font: 12px var(--serif); }
body.debug #hud { display: block; }
body.debug .layer { outline: 1px solid rgba(184, 67, 44, .5); }
body.debug .layer::before {
  content: attr(data-name); position: absolute; left: 0; top: -15px;
  font: 11px var(--serif); color: var(--accent);
}

/* ---------- speech bubbles ----------
   The box only holds the text; the paper sticker around it is an SVG drawn by setBubble() in
   app.js to fit. Its tail tip hangs var(--drop) below the box. */
.bubble {
  position: absolute; left: 50%; bottom: 100%; margin-bottom: calc(var(--drop, 20px) + .3vh);
  transform: translateX(-50%); transform-origin: 50% 120%;
  color: var(--ink); padding: .55em 1.05em .6em; width: max-content; max-width: 10em; text-align: center;
  font: clamp(14px, 1.5vw, 20px)/1.3 var(--serif); letter-spacing: .3px;
  opacity: 0; pointer-events: none;
}
.bubble:empty { display: none; }
.bubble > span { position: relative; }
.bubble-bg {
  position: absolute; left: 0; top: 0; overflow: visible; z-index: -1;
  filter: drop-shadow(1px 3px 3px rgba(40, 32, 22, .26));
}

/* ---------- edit mode ---------- */
body.editing #stage { cursor: crosshair; }
body.editing #hud { display: block; max-width: 92vw; line-height: 1.5; }
body.editing .layer { outline: 1px dashed rgba(43, 38, 32, .25); }
body.editing .layer.sel, body.editing #couple.sel { outline: 2px solid var(--accent); }
body.editing #caption { opacity: .25 !important; }
#dump {
  display: none; position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(900px, 90vw); height: 60vh; z-index: 300; font: 12px/1.45 ui-monospace, monospace;
  background: #1d1b16; color: #f2ead8; border: 1px solid #4a4436; padding: 14px;
}

/* ---------- live attribute badge, edit mode only ---------- */
.tag { display: none; }
body.editing .tag {
  display: block; position: absolute; left: 0; bottom: 100%; margin-bottom: 4px;
  white-space: nowrap; padding: 3px 7px; border-radius: 4px;
  background: rgba(43, 38, 32, .78); color: #f2ead8;
  font: 11px/1.25 ui-monospace, SFMono-Regular, monospace; letter-spacing: .2px;
}
body.editing .sel > .tag { background: var(--accent); color: #fff6e6; }
body.editing #couple > .tag { left: 50%; transform: translateX(-50%); }
/* couple badge sits below the feet, clear of the speech bubbles */
body.editing #couple > .tag { bottom: auto; top: 100%; margin: 6px 0 0; }

/* ---------- the intro photo, in pieces ---------- */
#intro { position: absolute; inset: 0; z-index: 40; }
.ipart { position: absolute; left: 0; top: 0; will-change: transform, opacity; }
.ipart img { width: 100%; height: auto; display: block; }
.intro-bubble { position: absolute; left: 0; top: 0; bottom: auto; margin: 0; z-index: 90; }
#scenes { position: absolute; inset: 0; }

/* ---------- the intro polaroid ---------- */
#intro { position: absolute; inset: 0; z-index: 40; }
#card { position: absolute; left: 0; top: 0; transform-origin: 50% 50%; }
#card .paper {
  position: absolute; inset: 0; background: #fffdf6; border-radius: 3px;
  box-shadow: 0 2px 3px rgba(40, 32, 22, .16), 0 18px 34px rgba(40, 32, 22, .22);
}
.ipart { position: absolute; left: 0; top: 0; will-change: transform, opacity, filter; }
.ipart img { width: 100%; height: auto; display: block; }
.ipart img.lit { position: absolute; left: 0; top: 0; opacity: 0; }
.intro-bubble { position: absolute; left: 0; top: 0; bottom: auto; margin: 0; z-index: 90; }

/* title and the nudge to scroll, over the polaroid */
#introhead {
  position: absolute; left: 50%; top: 4.5vh; transform: translateX(-50%);
  text-align: center; z-index: 95; pointer-events: none; width: min(760px, 88vw);
}
#introhead h1 { font-size: clamp(30px, 4.6vw, 58px); font-weight: 400; letter-spacing: .5px; }
#introhead .hint {
  margin-top: 8px; font-size: clamp(13px, 1.4vw, 17px); opacity: .62; letter-spacing: 1.6px;
  text-transform: lowercase;
}
#introhead .cue { display: inline-block; animation: nudge 1.9s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }

/* the couple as one drawn picture */
.figure.art { height: 100%; position: relative; }
.figure.art img { height: 100%; width: auto; display: block; }
.figure.art .bubble { left: 50%; }

/* ---------- chapter captions: the rolling year and the nudge to keep going ---------- */
#caption h2:empty { display: none; }
#caption .hint {
  margin-top: 14px; font-size: clamp(12px, 1.2vw, 15px); opacity: .55; letter-spacing: 1.6px;
  text-transform: lowercase;
}
#caption .cue { display: inline-block; animation: nudge 1.9s ease-in-out infinite; }

/* ---------- CZ / EN ---------- */
#lang { position: fixed; top: 14px; right: 14px; z-index: 210; display: flex; gap: 2px; }
#lang button {
  font: 12px/1 var(--serif); letter-spacing: 1px; padding: 6px 9px; border-radius: 4px;
  background: transparent; color: var(--ink); opacity: .5;
}
#lang button.on { opacity: 1; background: rgba(43, 38, 32, .08); }
#lang button:hover { opacity: .85; }

/* ---------- GIF frames and photo drops ---------- */
.layer { overflow: visible; }
.layer img.frame { position: absolute; left: 0; top: 0; }
.layer img.drop { position: absolute; height: auto; transform-origin: 50% 80%; opacity: 0; will-change: transform; }

/* ---------- a photo group's own speech bubble ---------- */
.layer .layer-bubble { bottom: auto; margin: 0; z-index: 5; }

/* ---------- bilingual static pages: both languages in the markup, html[lang] picks one ---------- */
html[lang="cs"] [lang="en"], html[lang="en"] [lang="cs"] { display: none !important; }
html[lang="cs"] [lang="cs"], html[lang="en"] [lang="en"] { display: inline; }

/* ---------- RSVP form ---------- */
#rsvp-form label { display: grid; gap: 5px; font-size: 14px; }
#rsvp-form label > span { opacity: .8; }
#rsvp-form small { font-size: 12px; opacity: .6; }
#rsvp-form .count { justify-self: end; }
#rsvp-form .count.full { color: var(--accent); opacity: 1; }
#rsvp-form button:disabled { opacity: .6; cursor: wait; }
.form-msg:empty { display: none; }
.form-msg { font-size: 15px; line-height: 1.5; }
.form-msg.err { color: var(--accent); }
.card-rsvp.sent form > :not(.form-msg) { display: none; }
.card .links a { color: var(--accent); }
.card .soon { font-style: italic; opacity: .6; }

/* ---------- phones ----------
   Everything below is phone-only (narrow portrait, plus touch screens for the form), so the
   desktop layout above stays exactly as arranged. Chapter placement on phones lives in app.js
   (`place()` and the per-layer `m` overrides in story.js). */
@media (max-width: 760px) and (orientation: portrait) {
  #introhead { top: 8vh; }
  #caption { top: 9vh; width: calc(100vw - 32px); }
  #caption h2 { font-size: clamp(26px, 7.6vw, 34px); line-height: 1.15; }
  #caption p { font-size: 15px; margin-top: 6px; }
  #caption .hint { font-size: 13px; }
  #lang { top: 4px; right: 4px; gap: 0; }
  #lang button { min-width: 44px; min-height: 44px; padding: 0 8px; font-size: 13px; }
  #panel { display: none; }        /* the colour picker is a desktop tool; e / d still work */
  .bubble { font-size: 15px; }
}
@media (max-width: 760px) {
  #pages { padding: 7vh 16px 12vh; }
  #outro { margin-bottom: 6vh; }
  .cards { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .card { padding: 22px 18px; }
}
/* touch: no iOS zoom-on-focus (inputs >= 16px), thumb-sized targets */
@media (max-width: 760px), (pointer: coarse) {
  input, select, textarea { font-size: 16px; padding: 12px; min-height: 46px; }
  #rsvp-form label { font-size: 15px; }
  .card .links a { display: inline-block; padding: 10px 0; }
  button { min-height: 48px; }
  #lang button { min-height: 44px; min-width: 44px; }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
}
@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
  #couple, .groom, .bride, .cue { animation: none !important; }
}
