/* ==========================================================================
   Tokens
   ========================================================================== */

:root {
  /* Color — all colors verified WCAG AA against cream bg */
  --bg: #F4EEE4;
  --text: #12283A;                        /* ~13:1 on cream — AAA */
  --text-muted: #44586A;                  /*  ~5.5:1 on cream — AA body */
  --accent: #6CDDEA;
  --line: rgba(18, 40, 58, 0.10);
  --line-medium: rgba(18, 40, 58, 0.28);  /* visible idle border for form fields */
  --line-strong: rgba(18, 40, 58, 0.55);  /* ~3.0:1 — passes 1.4.11 */
  --line-decor: rgba(18, 40, 58, 0.18);   /* decorative dashes, not UI */
  --bg-sunk: rgba(18, 40, 58, 0.04);
  --bg-lift: rgba(255, 252, 246, 0.55);   /* warm paper-tab fill for cards */
  --error: #B5463C;                       /* warm red on cream */

  /* Type */
  --font-serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --font-sans:  "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;

  /* Space */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --s-20: 80px;
  --s-24: 96px;
  --s-32: 128px;

  /* Type scale */
  --t-xs: 14px;
  --t-sm: 16px;
  --t-base: 18px;
  --t-lg: 22px;
  --t-xl: 28px;
  --t-2xl: 36px;
  --display-sm: 42px;
  --display: 54px;
  --display-lg: 72px;
}

@media (min-width: 420px) {
  :root {
    --t-base: 19px;
    --display: 58px;
  }
}

@media (min-width: 768px) {
  :root {
    --t-base: 20px;
    --t-lg: 24px;
    --t-xl: 32px;
    --t-2xl: 44px;
    --display-sm: 58px;
    --display: 80px;
    --display-lg: 108px;
  }
}

/* ==========================================================================
   Base
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  font-family: var(--font-sans);
  font-size: var(--t-base);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  position: relative;
  isolation: isolate;
  font-feature-settings: "kern", "liga", "calt";
  font-optical-sizing: auto;
}

/* No-flash render: body hidden until app.js applies i18n (safety timeout in head script) */
body[data-ready="false"] { opacity: 0; }
body[data-ready="true"]  { opacity: 1; transition: opacity 0.22s ease-out; }

/* Film grain — subtle paper texture over cream, excluded from photos via isolation */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.06;
  mix-blend-mode: multiply;
  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.9' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.07 0 0 0 0 0.15 0 0 0 0 0.23 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

::selection {
  background: rgba(127, 165, 184, 0.38);
  color: var(--text);
}

/* ==========================================================================
   Skip link (keyboard-only)
   ========================================================================== */

.skip-link {
  position: absolute;
  left: var(--s-4);
  top: var(--s-4);
  padding: var(--s-2) var(--s-4);
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: var(--t-sm);
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform 0.15s;
  z-index: 100;
}
.skip-link:focus { transform: translateY(0); }

/* ==========================================================================
   Language switcher
   ========================================================================== */

.lang-switch {
  position: absolute;
  top: var(--s-5);
  right: max(var(--s-6), env(safe-area-inset-right));
  display: flex;
  gap: var(--s-2);
  align-items: center;
  font-family: var(--font-sans);
  font-size: var(--t-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  z-index: 10;
  color: var(--text-muted);
}

.lang-switch a {
  color: var(--text-muted);
  text-decoration: none;
  padding: var(--s-1) var(--s-2);
  transition: color 0.15s;
}
.lang-switch a:hover { color: var(--text); }
.lang-switch a[aria-current="true"] { color: var(--text); font-weight: 500; }
.lang-switch a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ==========================================================================
   Ampersand — editorial serif italic treatment
   ========================================================================== */

.amp {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.12em;
  letter-spacing: 0.02em;
  margin-inline: 0.06em;
}

/* ==========================================================================
   Layout
   ========================================================================== */

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--s-16) var(--s-6) var(--s-24);
  padding-top: max(var(--s-16), env(safe-area-inset-top));
  padding-bottom: max(var(--s-24), env(safe-area-inset-bottom));
}

.section {
  padding-block: var(--s-16);
  border-top: 1px solid var(--line);
}

@media (min-width: 768px) {
  .section { padding-block: var(--s-20); }
}

/* ==========================================================================
   Hero
   Order: greeting → display → video → sign → CTA
   ========================================================================== */

.hero {
  padding-block: var(--s-8) var(--s-16);
}

.hero__greeting {
  font-family: var(--font-serif);
  font-size: var(--t-xl);
  font-style: italic;
  color: var(--text-muted);
  letter-spacing: -0.01em;
  margin-bottom: var(--s-6);
  font-feature-settings: "kern", "liga", "calt", "salt";
  hanging-punctuation: allow-end;
}

.hero__greeting-name {
  display: inline-block;
}

.hero__display {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: var(--display);
  line-height: 1.02;
  letter-spacing: -0.025em;
  margin-bottom: var(--s-10);
  text-wrap: balance;
  hyphens: manual;
  font-feature-settings: "kern", "liga", "dlig", "salt", "ss01";
  hanging-punctuation: first last;
}

.hero__sign {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--t-lg);
  color: var(--text-muted);
  margin-top: var(--s-10);
  font-feature-settings: "kern", "liga", "calt";
}

.hero__sign .amp {
  color: var(--accent);
  font-size: 1.22em;
}

/* ==========================================================================
   Hero image — portrait, contained on desktop, full-bleed on mobile
   ========================================================================== */

.hero-image {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--bg-sunk);
  margin-bottom: var(--s-4);
  isolation: isolate;   /* exclude from body grain — photo already has its own */
  z-index: 2;
}

/* Full-bleed on mobile only */
@media (max-width: 767px) {
  .hero-image {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    aspect-ratio: 4 / 5;
  }
}

/* Soft paper-drop shadow — desktop only, mobile full-bleed would clip */
@media (min-width: 768px) {
  .hero-image {
    filter: drop-shadow(0 24px 40px rgba(18, 40, 58, 0.14));
  }
}

.hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 35%;
  display: block;
}

/* ==========================================================================
   Glance (compact date/place)
   ========================================================================== */

.glance {
  padding-block: var(--s-12) var(--s-16);
  border-top: 1px solid var(--line);
}

.glance__list {
  display: grid;
  gap: var(--s-8);
  margin-bottom: var(--s-6);
}

.glance__row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: var(--s-4);
  align-items: baseline;
}

@media (max-width: 420px) {
  .glance__row { grid-template-columns: 88px 1fr; }
}

.glance__row dt {
  font-family: var(--font-sans);
  font-size: var(--t-sm);
  color: var(--text-muted);
  text-transform: lowercase;
  letter-spacing: 0.01em;
}

.glance__row dd {
  font-family: var(--font-serif);
  font-size: var(--t-xl);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   Section typography
   ========================================================================== */

.section__title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: var(--t-2xl);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: var(--s-8);
  text-wrap: balance;
}

.section p {
  font-size: var(--t-base);
  line-height: 1.6;
  margin-bottom: var(--s-4);
  max-width: 56ch;
}
.section p:last-child { margin-bottom: 0; }

.section__note {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--text-muted);
  font-size: var(--t-base);
  margin-top: var(--s-6) !important;
}

/* ==========================================================================
   Key-value blocks
   ========================================================================== */

.kv, .faq {
  display: grid;
  gap: var(--s-6);
}

.kv__row, .faq__item {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--s-4);
  align-items: baseline;
}

@media (max-width: 600px) {
  .kv__row, .faq__item {
    grid-template-columns: 1fr;
    gap: var(--s-1);
  }
}

.kv dt, .faq dt {
  font-family: var(--font-sans);
  font-size: var(--t-sm);
  color: var(--text-muted);
  line-height: 1.5;
}

.kv dd, .faq dd {
  font-size: var(--t-base);
  line-height: 1.55;
}

/* ==========================================================================
   Program
   ========================================================================== */

.program {
  list-style: none;
  display: grid;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}

.program li {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: var(--s-4);
  align-items: baseline;
  font-size: var(--t-lg);
  font-family: var(--font-serif);
  line-height: 1.35;
}

.program__time {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Mumi gallery — one hero + pair below
   ========================================================================== */

.mumi-gallery {
  display: grid;
  gap: var(--s-3);
  margin-top: var(--s-8);
}

.mumi-gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: var(--bg-sunk);
}

.mumi-gallery__hero {
  aspect-ratio: 3 / 2;
}

.mumi-gallery__pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
}

.mumi-gallery__pair img {
  aspect-ratio: 1 / 1;
}

@media (max-width: 400px) {
  .mumi-gallery__pair { grid-template-columns: 1fr; }
  .mumi-gallery__pair img { aspect-ratio: 3 / 2; }
}

/* ==========================================================================
   Link
   ========================================================================== */

.link {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 1px;
  transition: border-color 0.15s;
  cursor: pointer;
}
.link:hover { border-color: var(--accent); }
.link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}

/* Map link in glance — serif italic, hover-only underline (editorial, not utility) */
.glance .link {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--t-lg);
  color: var(--text-muted);
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: border-color 0.2s, color 0.2s;
  cursor: pointer;
}
.glance .link:hover {
  color: var(--text);
  border-bottom-color: var(--line-strong);
}

/* ==========================================================================
   RSVP
   ========================================================================== */

.rsvp__deadline {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--t-sm);
  color: var(--text-muted);
  margin-top: var(--s-6);
  text-align: left;
}

/* ==========================================================================
   Form
   ========================================================================== */

.form {
  display: grid;
  gap: var(--s-8);
}

@media (min-width: 768px) {
  .form { gap: var(--s-10); }
}

.form__group {
  border: none;
  display: grid;
  gap: var(--s-3);
}

.form__legend {
  font-family: var(--font-sans);
  font-size: var(--t-sm);
  color: var(--text-muted);
  margin-bottom: var(--s-3);
}

.form__error {
  font-family: var(--font-sans);
  font-size: var(--t-sm);
  color: var(--error);
  margin-top: var(--s-2);
}

/* Radio field spacing — SDS radio-group inherits. Wedding wants more breathing. */
.radio-group {
  gap: var(--s-3);
}
.radio-field {
  padding: var(--s-2) 0;
  cursor: pointer;
}

/* Text field label + textarea wrapper (SDS text-area handles the input styling) */
.form__field {
  display: grid;
  gap: var(--s-2);
}

.form__label {
  font-family: var(--font-sans);
  font-size: var(--t-sm);
  color: var(--text-muted);
}

/* Ensure SDS textarea uses wedding 16px on mobile to prevent iOS zoom */
@media (max-width: 767px) {
  .text-area { font-size: 16px !important; }
}

/* Checkbox field wrapper — subtle tap area */
.checkbox-field {
  padding: var(--s-2) 0;
  cursor: pointer;
}

/* Party composition block */
.form__party {
  display: grid;
  gap: var(--s-6);
}
.form__party[hidden] { display: none; }

/* Prevent iOS zoom on SDS input/textarea focus */
@media (max-width: 767px) {
  .text-area,
  .input { font-size: 16px !important; }
}

/* Conditional group */
.form__if-yes {
  display: grid;
  gap: var(--s-8);
}
.form__if-yes[hidden] { display: none; }

/* Transfer info panel — appears when "need transfer" is checked */
.transfer-info {
  padding: var(--s-5);
  background: var(--bg-sunk);
  border-left: 3px solid var(--accent);
  display: grid;
  gap: var(--s-2);
  margin-top: calc(var(--s-8) * -1 + var(--s-3));
}
.transfer-info[hidden] { display: none; }

.transfer-info__lead {
  font-family: var(--font-sans);
  font-size: var(--t-sm);
  color: var(--text-muted);
  line-height: 1.5;
}

.transfer-info__cta {
  font-family: var(--font-sans);
  font-size: var(--t-base);
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 1px;
  justify-self: start;
  transition: border-color 0.15s;
}
.transfer-info__cta:hover { border-color: var(--accent); }
.transfer-info__cta:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* SDS button alignment in wedding form */
.form > .button {
  justify-self: stretch;
}
@media (min-width: 600px) {
  .form > .button {
    justify-self: start;
    min-width: 200px;
  }
}

/* Thanks state */
.rsvp__thanks { padding-block: var(--s-6); }
.rsvp__thanks[hidden] { display: none; }

.rsvp__thanks-title {
  font-family: var(--font-serif);
  font-size: var(--t-2xl);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-bottom: var(--s-3) !important;
  outline: none;
}

.rsvp__thanks p { max-width: 56ch; }

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  padding-top: var(--s-16);
  border-top: 1px solid var(--line);
  font-size: var(--t-sm);
  color: var(--text-muted);
  display: grid;
  gap: var(--s-6);
}

.footer p { line-height: 1.7; margin: 0; }
.footer .link { color: var(--text-muted); }

.footer__colophon {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--t-base);
  letter-spacing: 0.02em;
  color: var(--text-muted);
}
.footer__colophon .amp {
  color: var(--accent);
  font-size: 1.15em;
}
.footer__colophon .footer__dot {
  margin-inline: 0.3em;
  opacity: 0.6;
}

/* ==========================================================================
   Entrance animations
   ========================================================================== */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

@keyframes widthIn {
  from { width: 0; }
  to   { width: 72px; }
}

/* Hero stagger: 0 → 600ms, tight like an exhale */
body[data-ready="true"] .hero__greeting         { animation: fadeUp 0.5s 0.05s ease-out both; }
body[data-ready="true"] .hero__greeting-name    { animation: fadeUp 0.45s 0.30s ease-out both; }
body[data-ready="true"] .hero__display          { animation: fadeUp 0.6s 0.18s ease-out both; }
body[data-ready="true"] .hero-image             { animation: fadeUp 0.7s 0.32s ease-out both; }
body[data-ready="true"] .hero__sign             { animation: fadeUp 0.5s 0.48s ease-out both; }

/* Scroll reveal — only applied where .reveal class exists */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.7s ease-out, transform 0.7s ease-out;
  will-change: opacity, transform;
}
.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Mumi gallery: slow photographic develop (blur → sharp) */
.mumi-gallery img {
  filter: blur(10px);
  opacity: 0;
  transition: filter 0.8s ease-out, opacity 0.6s ease-out;
}
.mumi-gallery img.is-loaded {
  filter: blur(0);
  opacity: 1;
}

/* RSVP success: two-beat reveal with hairline under name (like guestbook signature) */
.rsvp__thanks:not([hidden]) .rsvp__thanks-title {
  animation: fadeUp 0.5s 0s ease-out both;
  position: relative;
}
.rsvp__thanks:not([hidden]) .rsvp__thanks-title::after {
  content: "";
  display: block;
  width: 0;
  height: 1px;
  background: var(--line-strong);
  margin-top: var(--s-3);
  animation: widthIn 0.8s 0.5s ease-out both;
}
.rsvp__thanks:not([hidden]) > p:not(.rsvp__thanks-title) {
  animation: fadeUp 0.6s 1.0s ease-out both;
}
.rsvp__thanks:not([hidden]) > .section__note {
  animation: fadeUp 0.6s 1.15s ease-out both;
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .hero__greeting, .hero__greeting-name, .hero__display, .hero-image, .hero__sign,
  .reveal,
  .mumi-gallery img,
  .rsvp__thanks-title, .rsvp__thanks > p {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
  .rsvp__thanks-title::after { width: 72px !important; }
}
