/* THE BIG DAY — First Light. Everything visual is a photograph (Flow); code adds only text and light grading.
   Self-hosted fonts only; no third-party requests. */

@font-face {
  font-family: 'Instrument Serif';
  src: url('fonts/instrument-serif-latin-400-normal.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Instrument Serif';
  src: url('fonts/instrument-serif-latin-400-italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Archivo';
  src: url('fonts/archivo-latin-wdth-normal.woff2') format('woff2');
  font-weight: 100 900; font-stretch: 62% 125%; font-style: normal; font-display: swap;
}

/* ---------- Themes (colour variants a customer can pick) ---------- */
:root, [data-theme='obsidian'] {
  --bg: #0c0907; --ink: #f4ede1; --muted: rgba(244, 237, 225, 0.66);
  --gold: #d6b46c; --gold-hi: #f4dfa6; --on-gold: #17120a;
  --card: rgba(255, 255, 255, 0.035); --line: rgba(214, 180, 108, 0.22);
  --tone: saturate(1); /* extra grade on the photo for this theme */
  --serif: 'Instrument Serif', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --sans: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
[data-theme='midnight'] {
  --bg: #070a12; --ink: #eef1f8; --muted: rgba(238, 241, 248, 0.66);
  --gold: #cfb37b; --gold-hi: #f1e3bd; --on-gold: #0d1120;
  --card: rgba(255, 255, 255, 0.04); --line: rgba(207, 179, 123, 0.22);
  --tone: hue-rotate(-14deg) saturate(0.8);
}
[data-theme='ivory'] {
  --bg: #f3eee5; --ink: #1d1813; --muted: rgba(29, 24, 19, 0.7);
  --gold: #8d6a2c; --gold-hi: #b98e45; --on-gold: #fffaf0;
  --card: rgba(255, 255, 255, 0.55); --line: rgba(141, 106, 44, 0.28);
  --tone: sepia(0.08) brightness(1.04);
  color-scheme: light;
}

/* ---------- Light that changes as the day approaches: a grade on the photo + a tint in the room ---------- */
[data-mood='night']   { --sun: #6e85c8; --sun-a: 0.12; --grade: brightness(0.74) saturate(0.72) contrast(1.06); }
[data-mood='dawn']    { --sun: #c98ba2; --sun-a: 0.16; --grade: brightness(0.84) saturate(0.84) contrast(1.04); }
[data-mood='sunrise'] { --sun: #e69a50; --sun-a: 0.2;  --grade: brightness(0.93) saturate(0.95) contrast(1); }
[data-mood='golden']  { --sun: #f1b955; --sun-a: 0.26; --grade: brightness(1) saturate(1.06) contrast(1); }
[data-mood='noon']    { --sun: #ffe2a2; --sun-a: 0.32; --grade: brightness(1.07) saturate(1.12) contrast(1); }
[data-mood='dusk']    { --sun: #b8644a; --sun-a: 0.18; --grade: brightness(0.8) saturate(0.82) contrast(1.02); }

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100svh; background: var(--bg); color: var(--ink);
  font: 400 1rem/1.55 var(--sans); overflow-x: hidden;
}
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 4px; border-radius: 2px; }

.sky {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(110% 70% at 50% 18%, color-mix(in srgb, var(--sun) calc(var(--sun-a) * 100%), transparent), transparent 65%);
  transition: background 2.4s ease;
}

/* ---------- Hero ---------- */
.stage { position: relative; z-index: 1; }
.hero {
  min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); text-align: center;
}

/* The photo: full frame (wall, slab, sundial) in the intro; cropped to the sundial once revealed. */
.photo-area {
  --pw: min(100vw, 55svh, 560px);
  --px: 0; --py: 0;
  position: relative; width: var(--pw); height: calc(var(--pw) * 2000 / 1116);
  transition: height 1.5s cubic-bezier(0.6, 0, 0.2, 1);
}
.revealed-ready .photo-area { height: calc(var(--pw) * 1180 / 1116); }
.photo {
  position: absolute; inset: 0; overflow: hidden;
  /* The frame's edges dissolve into the page, so the photo sits in the room instead of in a box. */
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 9%, #000 91%, transparent), linear-gradient(to right, transparent, #000 4%, #000 96%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to bottom, transparent, #000 9%, #000 91%, transparent), linear-gradient(to right, transparent, #000 4%, #000 96%, transparent);
  mask-composite: intersect;
  filter: var(--grade) var(--tone);
  transition: filter 2.6s ease;
}
/* On wide screens the photo is a column in a dark room: soften its sides more. */
@media (min-width: 700px) {
  .photo {
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 9%, #000 91%, transparent), linear-gradient(to right, transparent, #000 14%, #000 86%, transparent);
    mask-image: linear-gradient(to bottom, transparent, #000 9%, #000 91%, transparent), linear-gradient(to right, transparent, #000 14%, #000 86%, transparent);
  }
}
[data-theme='ivory'] .photo { -webkit-mask-image: none; mask-image: none; border-radius: 3px; }
/* Before the reveal the room is dark: only a trace of light on the stone. Same filter functions as the mood
   grades, so the browser can fade smoothly from one to the other. */
[data-stage='intro'] .photo { filter: brightness(0.36) saturate(0.55) contrast(1.15) var(--tone); }
[data-instant] *, [data-instant] *::after { transition: none !important; animation-duration: 0s !important; animation-delay: 0s !important; }
/* Returning visitor: the photo starts a little dim, then the light lifts while the shadow catches up with today. */
[data-catchup] .photo { filter: brightness(0.5) saturate(0.65) contrast(1.1) var(--tone); transition: none; }
/* While counting down the light lives a little: now and then it dims softly, as if a cloud passes the sun. It is a
   grade on the photograph (a dark veil whose opacity changes), nothing is drawn. On the big day it shimmers warm. */
.photo::after { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: #000; opacity: 0; }
[data-stage='revealed'] .photo::after { animation: clouds 26s ease-in-out 3s infinite; }
@keyframes clouds {
  0%, 100% { opacity: 0; } 14% { opacity: 0.16; } 22% { opacity: 0.07; } 30% { opacity: 0.13; } 44% { opacity: 0; }
  68% { opacity: 0; } 76% { opacity: 0.1; } 86% { opacity: 0.02; }
}
[data-phase='live'] [data-stage='revealed'] .photo::after { background: #ffd9a0; mix-blend-mode: soft-light; animation: shimmer 5s ease-in-out infinite; }
@keyframes shimmer { 50% { opacity: 0.4; } }
.layer {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 50.5%;
  opacity: 0; transition: opacity 1s ease;
  transform: translate3d(calc(var(--px) * 7px), calc(var(--py) * 5px), 0) scale(1.03);
}
.layer.is-on { opacity: 1; }

.hero-top { position: absolute; top: 4.5%; left: 0; right: 0; padding: 0 1rem; display: grid; gap: 0.6rem; z-index: 2; transition: opacity 0.8s ease; }
.kicker {
  margin: 0; font: 500 0.72rem/1 var(--sans); font-stretch: 112%; letter-spacing: 0.42em; text-transform: uppercase;
  color: var(--gold); padding-left: 0.42em;
}
.intro-line { margin: 0; font: 400 clamp(1.7rem, 7.4vw, 2.7rem)/1.1 var(--serif); text-wrap: balance; color: #f4ede1; }
.hero-top .kicker { color: #d6b46c; }

.dial-button {
  position: absolute; left: 6%; right: 6%; top: 25%; bottom: 22%; border: 0; border-radius: 50%;
  background: transparent; cursor: pointer; z-index: 2; -webkit-tap-highlight-color: transparent;
}
.dial-button:focus-visible { outline-offset: -6px; }
.hero-bottom { position: absolute; bottom: 4%; left: 0; right: 0; display: grid; justify-items: center; z-index: 2; transition: opacity 0.6s ease; }
.hint {
  margin: 0; font: 500 0.7rem/1 var(--sans); letter-spacing: 0.32em; text-transform: uppercase; color: rgba(244, 237, 225, 0.72);
  animation: pulse 2.8s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.45; } }
.skip-intro {
  margin-top: 0.4rem; background: none; border: 0; color: rgba(244, 237, 225, 0.66); font: 400 0.8rem/1 var(--sans);
  text-decoration: underline; text-underline-offset: 4px; padding: 0.8rem; cursor: pointer; min-height: 44px;
}

/* ---------- Stages ---------- */
[data-stage='revealing'] .hero-top, [data-stage='revealed'] .hero-top,
[data-stage='revealing'] .hero-bottom, [data-stage='revealed'] .hero-bottom { opacity: 0; pointer-events: none; }
[data-stage='revealing'] .dial-button, [data-stage='revealed'] .dial-button { display: none; }

.revealed { display: grid; grid-template-rows: 0fr; width: 100%; transition: grid-template-rows 1.3s cubic-bezier(0.6, 0, 0.2, 1); }
.revealed-inner { overflow: hidden; min-height: 0; opacity: 0; transform: translateY(12px); transition: opacity 1s ease 0.4s, transform 1.2s ease 0.4s; padding: 0 1rem; }
.revealed-ready .revealed { grid-template-rows: 1fr; }
.revealed-ready .revealed-inner { opacity: 1; transform: none; }

.kicker-revealed { margin-top: clamp(0.4rem, 1.5svh, 1rem); }
.event-title {
  margin: 0.6rem auto 0.5rem; max-width: 18ch;
  font: 400 clamp(2rem, 8.5vw, 3.6rem)/1.04 var(--serif); text-wrap: balance;
}
.event-title:focus { outline: none; }
.event-date {
  margin: 0 0 clamp(1rem, 3svh, 2rem); font: 500 0.74rem/1.6 var(--sans); letter-spacing: 0.24em;
  text-transform: uppercase; color: var(--gold);
}
.event-date .sep { margin: 0 0.4em; }

.countdown {
  --gap: clamp(1rem, 4.5vw, 2.8rem);
  display: grid; grid-template-columns: repeat(4, auto); justify-content: center; column-gap: var(--gap);
}
.unit { position: relative; display: flex; flex-direction: column; align-items: center; --u: 0; }
.unit[data-unit='hours'] { --u: 1; } .unit[data-unit='minutes'] { --u: 2; } .unit[data-unit='seconds'] { --u: 3; }
.unit + .unit::before {
  content: ''; position: absolute; left: calc(var(--gap) / -2); top: 12%; height: 52%; width: 1px;
  background: linear-gradient(transparent, var(--line), transparent);
}
.num { display: flex; font: 400 clamp(2.7rem, 12.5vw, 6.4rem)/1 var(--serif); font-variant-numeric: lining-nums; }
.digit { display: inline-block; width: 0.55em; text-align: center; }
.digit.in { animation: digit-in 0.55s cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes digit-in { from { opacity: 0; transform: translateY(0.3em); filter: blur(4px); } }
.label { margin-top: 0.55rem; font: 500 0.62rem/1 var(--sans); letter-spacing: 0.26em; text-transform: uppercase; color: var(--muted); padding-left: 0.26em; }

.big-day { margin: 0.2rem 0 0; font: italic 400 clamp(2.2rem, 10vw, 4.4rem)/1.05 var(--serif); color: var(--gold-hi); text-wrap: balance; }
[data-theme='ivory'] .big-day { color: var(--gold); }
.mood-line { margin: clamp(0.9rem, 2.6svh, 1.6rem) 0 0; font: italic 400 1.2rem/1.3 var(--serif); color: var(--muted); }
.scroll-cue { display: inline-block; margin-top: clamp(0.8rem, 3svh, 2.2rem); padding: 0.8rem; }
.scroll-cue span { display: block; width: 1px; height: 2.6rem; background: linear-gradient(var(--gold), transparent); animation: cue 2.4s ease-in-out infinite; }
@keyframes cue { 0% { transform: scaleY(0); transform-origin: top; } 50% { transform: scaleY(1); transform-origin: top; } 51% { transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }

/* ---------- Details ---------- */
.details { position: relative; z-index: 1; width: min(100% - 2rem, 34rem); margin: 0 auto; padding: 2rem 0 4rem; display: grid; gap: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); padding: 1.4rem 1.3rem; border-radius: 3px; }
.message { margin: 0 0 1rem; font: 400 1.35rem/1.4 var(--serif); white-space: pre-line; }
.host { margin: 0; color: var(--muted); }
.label-sm { margin: 0 0 0.6rem; font: 500 0.68rem/1 var(--sans); letter-spacing: 0.28em; text-transform: uppercase; color: var(--gold); }
.host .label-sm { margin-right: 0.4rem; }
.detail-strong { margin: 0; font: 400 1.4rem/1.3 var(--serif); }
.detail { margin: 0.2rem 0 0; white-space: pre-line; }
.muted { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0.7rem 1.1rem;
  border: 1px solid var(--gold); border-radius: 2px; background: transparent; color: var(--ink); cursor: pointer;
  font: 500 0.72rem/1 var(--sans); letter-spacing: 0.18em; text-transform: uppercase; text-decoration: none;
  transition: background 0.25s ease, color 0.25s ease;
}
.btn:hover { background: color-mix(in srgb, var(--gold) 16%, transparent); }
.btn-primary { background: var(--gold); color: var(--on-gold); }
.btn-primary:hover { background: var(--gold-hi); }
.btn-quiet { border-color: transparent; color: var(--muted); }
.status { margin: 0.6rem 0 0; min-height: 1.2em; font-size: 0.85rem; color: var(--muted); }
.foot { text-align: center; padding-top: 1rem; font-size: 0.8rem; }
.foot p { margin: 0.3rem 0; }
.made-by { letter-spacing: 0.24em; text-transform: uppercase; font-size: 0.62rem; color: var(--gold); }

.noscript { text-align: center; padding: 2rem 1rem; }
.error-screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 2rem; text-align: center; z-index: 5; background: var(--bg); font: 400 1.5rem/1.3 var(--serif); }

@media (min-width: 900px) {
  .details { grid-template-columns: 1fr 1fr; width: min(100% - 4rem, 56rem); }
  .details .message-card, .details .foot, .details .card:last-of-type { grid-column: 1 / -1; }
}

/* ---------- Film grain: one static noise tile over everything, like the grain of the photograph ---------- */
body::after {
  content: ''; position: fixed; inset: 0; z-index: 4; pointer-events: none; opacity: 0.06; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme='ivory'] body::after { opacity: 0.04; mix-blend-mode: multiply; }

/* ---------- Choreography ---------- */
/* Until app.js has chosen between intro and countdown, show nothing (no flash of the intro for returning
   visitors). Without JavaScript the page still appears after a moment. */
html:not([data-ready]) .stage { opacity: 0; animation: appear 0.6s ease 1.5s forwards; }
@keyframes appear { to { opacity: 1; } }

/* First visit: the scene comes out of the dark one piece at a time. */
[data-entrance] .photo-area { animation: photo-in 2.4s cubic-bezier(0.2, 0.7, 0.2, 1) 0.1s both; }
[data-entrance] .hero-top .kicker { animation: rise-in 1.2s cubic-bezier(0.2, 0.7, 0.2, 1) 0.5s both; }
[data-entrance] .intro-line { animation: rise-in 1.4s cubic-bezier(0.2, 0.7, 0.2, 1) 0.85s both; }
[data-entrance] .hero-bottom { animation: fade-in 1s ease 2s both; }
@keyframes photo-in { from { opacity: 0; transform: scale(0.985); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); filter: blur(6px); } }
@keyframes fade-in { from { opacity: 0; } }

/* The reveal: words of the title, then the date tightening, then the four units one after another. */
.event-title .w { display: inline-block; }
.revealed-ready .kicker-revealed { animation: fade-in 1s ease 0.3s both; }
.revealed-ready .event-title .w { animation: word-in 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: calc(0.45s + var(--i) * 0.09s); }
@keyframes word-in { from { opacity: 0; transform: translateY(0.35em); filter: blur(8px); } }
.revealed-ready .event-date { animation: track-in 1.6s cubic-bezier(0.2, 0.7, 0.2, 1) 0.8s both; }
@keyframes track-in { from { opacity: 0; letter-spacing: 0.6em; } }
.revealed-ready .unit { animation: rise-in 1s cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: calc(1.05s + var(--u) * 0.11s); }
.revealed-ready .mood-line { animation: fade-in 1.2s ease 1.7s both; }
.revealed-ready .big-day { animation: rise-in 1.4s cubic-bezier(0.2, 0.7, 0.2, 1) 0.9s both; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  [data-entrance] *, .revealed-ready *, .hint, .scroll-cue span, .photo::after { animation: none !important; }
  .digit.in { animation: none; }
  .layer { transform: none; transition-duration: 0.3s; }
  .photo { transition-duration: 0.3s; }
  .photo-area, .revealed, .revealed-inner { transition-duration: 0.01s; transition-delay: 0s; }
}

/* Webshop display correction: leave space for mobile scrollbars and screen edges. */
.photo-area { --pw: min(calc(100vw - 2rem), 55svh, 560px); }
