/* ============================================================
   Nos fiançailles — subtle Algerian / Palestinian romantic
   Palette notes:
     ivory / sand    → shared Maghrebi-Levantine plaster tones
     deep olive      → Palestinian olive groves (tatreez ground)
     muted teal      → Algerian zellige blues, desaturated
     soft terracotta → tatreez thread red, dialed way down
     antique gold    → accent only, never fill
   ============================================================ */

:root {
  --ivory:      #FBF7F0;
  --sand:       #F2EADD;
  --sand-deep:  #E7DBC9;
  --ink:        #2E2A26;
  --ink-soft:   #6B6155;
  --olive:      #5C6B4E;
  --teal:       #3E6B6B;
  --terracotta: #A8564A;
  --gold:       #B99653;

  --max:        68rem;
  --narrow:     40rem;

  --serif:  "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --sans:   "Jost", system-ui, -apple-system, "Segoe UI", sans-serif;
  --arabic: "Amiri", "Noto Naskh Arabic", "Geeza Pro", serif;

  --step: clamp(3rem, 8vw, 6rem);
  --ease: cubic-bezier(.22, .61, .36, 1);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  font-size: clamp(1rem, .4vw + .92rem, 1.075rem);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;

  /* Whisper-quiet keffiyeh fishnet: diamond lattice + cross-stitch dot at each node */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='34' viewBox='0 0 34 34'%3E%3Cpath d='M0,17 L17,0 L34,17 L17,34 Z' fill='none' stroke='%235C6B4E' stroke-width='.9' opacity='.05'/%3E%3Ccircle cx='17' cy='17' r='1' fill='%23A8564A' opacity='.07'/%3E%3Ccircle cx='0' cy='17' r='1' fill='%23A8564A' opacity='.07'/%3E%3Ccircle cx='34' cy='17' r='1' fill='%23A8564A' opacity='.07'/%3E%3Ccircle cx='17' cy='0' r='1' fill='%23A8564A' opacity='.07'/%3E%3Ccircle cx='17' cy='34' r='1' fill='%23A8564A' opacity='.07'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

/* Arabic mode: RTL + naskh face */
html[lang="ar"] body { font-family: var(--arabic); line-height: 1.95; }
html[lang="ar"] .names,
html[lang="ar"] .hero__title,
html[lang="ar"] .section__title,
html[lang="ar"] .card__title { font-family: var(--arabic); }
html[lang="ar"] .eyebrow {
  letter-spacing: 0;
  text-transform: none;
  font-size: 1rem;
}
html[lang="ar"] .unit__label { letter-spacing: 0; }
/* Arabic joins names with و, which shouldn't be italicised like an ampersand */
html[lang="ar"] .names__amp { font-style: normal; font-size: .4em; }

img, svg, iframe { display: block; max-width: 100%; }

/* ─────────────  language switch  ───────────── */

.lang-switch {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  gap: .25rem;
  padding: .6rem;
  background: color-mix(in srgb, var(--ivory) 86%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--sand-deep);
}

.lang-btn {
  min-width: 2.75rem;
  padding: .3rem .7rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-size: .8rem;
  letter-spacing: .1em;
  cursor: pointer;
  transition: color .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease);
}
.lang-btn:hover { color: var(--ink); }
.lang-btn[aria-current="true"] {
  color: var(--teal);
  border-color: color-mix(in srgb, var(--teal) 35%, transparent);
  background: color-mix(in srgb, var(--teal) 7%, transparent);
}
.lang-btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ─────────────  layout  ───────────── */

main { overflow-x: hidden; }

.section {
  width: min(100% - 2.5rem, var(--max));
  margin-inline: auto;
  padding-block: var(--step);
}
.section--narrow { width: min(100% - 2.5rem, var(--narrow)); }

.section__title {
  margin: 0 0 2rem;
  font-family: var(--serif);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 400;
  font-style: italic;
  text-align: center;
  color: var(--olive);
}

/* ─────────────  hero  ───────────── */

.hero {
  padding: clamp(2.5rem, 7vw, 5rem) 1.25rem clamp(1rem, 4vw, 2rem);
  display: grid;
  place-items: center;
  text-align: center;
}

/* Double hairline frame — echoes an engraved invitation card */
.hero__frame {
  position: relative;
  width: min(100%, 46rem);
  padding: clamp(2.25rem, 6vw, 3.75rem) clamp(1.25rem, 5vw, 3rem);
  border: 1px solid var(--sand-deep);
}
.hero__frame::before {
  content: "";
  position: absolute;
  inset: 7px;
  /* rgba, not color-mix(): html2canvas (used by the save-card export) can't parse color-mix() */
  border: 1px solid rgba(185, 150, 83, .34);
  pointer-events: none;
}

.frame-corners {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  grid-template-rows: 38px 1fr 38px;
  padding: 14px;
  pointer-events: none;
}
.frame-corner {
  width: 38px;
  height: 38px;
  color: var(--olive);
  opacity: .5;
}
.frame-corner--tl { grid-column: 1; grid-row: 1; }
.frame-corner--tr { grid-column: 3; grid-row: 1; }
.frame-corner--bl { grid-column: 1; grid-row: 3; }
.frame-corner--br { grid-column: 3; grid-row: 3; }

.save-card__label {
  margin: 1.75rem 0 0;
  font-size: .72rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
html[lang="ar"] .save-card__label { letter-spacing: 0; text-transform: none; font-size: .95rem; }

.save-card__actions {
  display: flex;
  justify-content: center;
  gap: .6rem;
  margin: .75rem 0 0;
}
.save-card__actions .btn[disabled] { opacity: .55; cursor: progress; }

.save-card__status {
  min-height: 1.4em;
  margin: .6rem 0 0;
  font-size: .85rem;
  color: var(--ink-soft);
}
.save-card__status[data-state="error"] { color: var(--terracotta); }

.eyebrow {
  margin: 0 0 1.75rem;
  font-size: .72rem;
  font-weight: 400;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.names {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .1em;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.6rem, 10vw, 5rem);
  line-height: 1.02;
  color: var(--ink);
}
.names__amp {
  font-style: italic;
  font-size: .48em;
  color: var(--terracotta);
  opacity: .8;
  transform: translate(-.09em, .2em);
}
/* html2canvas (save-card export) lays out the italic ampersand higher
   in its line box than native Chromium does — needs a bigger nudge. */
#save-card.is-exporting .names__amp {
  transform: translate(-.09em, .63em);
}

.hero__title {
  margin: 1.5rem 0 .35rem;
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2.4vw, 1.5rem);
  font-style: italic;
  color: var(--olive);
}

.hero__date {
  margin: 0;
  font-size: .85rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
html[lang="ar"] .hero__date { letter-spacing: 0; text-transform: none; font-size: 1rem; }

.hero__venue {
  margin: .5rem 0 0;
  font-size: .78rem;
  letter-spacing: .06em;
  color: var(--ink-soft);
}
html[lang="ar"] .hero__venue { letter-spacing: 0; font-size: .92rem; }

/* ─────────────  olive branches  ───────────── */

.branch {
  width: min(72%, 17rem);
  height: auto;
  aspect-ratio: 200 / 46;
  margin-inline: auto;
  color: var(--olive);
  opacity: .58;
}
.branch--top    { margin-bottom: 1.5rem; }
.branch--bottom { margin-top: 1.75rem; transform: scaleY(-1); }
.branch--foot   { width: min(50%, 10.5rem); opacity: .4; margin-bottom: 1rem; }

.branch__berries { fill: rgba(168, 86, 74, .8); }
.branch__vein { fill: none; stroke: rgba(46, 42, 38, .22); }

/* ─────────────  tatreez divider  ───────────── */

.tatreez-rule {
  height: 24px;
  color: var(--terracotta);
  opacity: .3;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cg fill='%23A8564A'%3E%3Crect x='8' y='0' width='4' height='4'/%3E%3Crect x='4' y='4' width='4' height='4'/%3E%3Crect x='12' y='4' width='4' height='4'/%3E%3Crect x='0' y='8' width='4' height='4'/%3E%3Crect x='16' y='8' width='4' height='4'/%3E%3Crect x='8' y='8' width='4' height='4' opacity='.55'/%3E%3Crect x='4' y='12' width='4' height='4'/%3E%3Crect x='12' y='12' width='4' height='4'/%3E%3Crect x='8' y='16' width='4' height='4'/%3E%3C/g%3E%3C/svg%3E") repeat-x center;
  /* Fade the stitching out at both edges so it reads as embroidery, not tiling */
  mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent);
}

/* ─────────────  invite text  ───────────── */

.invite { text-align: center; }
.invite__body {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2.2vw, 1.4rem);
  line-height: 1.85;
  color: var(--ink);
  white-space: pre-line;
}
html[lang="ar"] .invite__body { font-family: var(--arabic); font-size: clamp(1.1rem, 2vw, 1.3rem); }

.invite__sign {
  margin: 1.75rem 0 0;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-soft);
}

/* ─────────────  countdown  ───────────── */

.countdown-wrap { text-align: center; }

.countdown {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(.5rem, 2vw, 1.5rem);
  max-width: 34rem;
  margin-inline: auto;
}

.unit {
  padding: 1.25rem .5rem;
  background: var(--sand);
  border: 1px solid var(--sand-deep);
  border-radius: 2px;
  position: relative;
}
/* tiny gold corner ticks */
.unit::before,
.unit::after {
  content: "";
  position: absolute;
  width: 7px; height: 7px;
  border-color: color-mix(in srgb, var(--gold) 55%, transparent);
  border-style: solid;
  border-width: 0;
}
.unit::before { inset-block-start: 4px; inset-inline-start: 4px; border-top-width: 1px; border-inline-start-width: 1px; }
.unit::after  { inset-block-end: 4px;   inset-inline-end: 4px;   border-bottom-width: 1px; border-inline-end-width: 1px; }

.unit__num {
  display: block;
  font-family: var(--serif);
  font-size: clamp(1.9rem, 6vw, 3rem);
  font-weight: 500;
  line-height: 1;
  color: var(--teal);
  font-variant-numeric: tabular-nums;
}
.unit__label {
  display: block;
  margin-top: .5rem;
  font-size: .66rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
html[lang="ar"] .unit__label { font-size: .85rem; text-transform: none; }

.countdown__over {
  margin: 1.5rem 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.25rem;
  color: var(--terracotta);
}

/* ─────────────  detail cards  ───────────── */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.25rem;
}

.card {
  padding: 2rem 1.5rem;
  text-align: center;
  background: color-mix(in srgb, var(--sand) 55%, var(--ivory));
  border: 1px solid var(--sand-deep);
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
}

.card__title {
  margin: 0 0 .5rem;
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--olive);
}
html[lang="ar"] .card__title { font-size: 1rem; letter-spacing: 0; text-transform: none; }

.card__lead {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.3rem;
  line-height: 1.4;
  color: var(--ink);
}
.card__meta {
  margin: 0;
  font-size: .9rem;
  color: var(--ink-soft);
}
.card .btn { margin-top: auto; }

.card__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .6rem;
  margin-top: 1rem;
}
.card__actions .btn { margin-top: 0; }

.card__hint {
  margin: .6rem 0 0;
  font-size: .78rem;
  color: var(--ink-soft);
}

/* ─────────────  buttons  ───────────── */

.btn {
  display: inline-block;
  padding: .7rem 1.4rem;
  font-family: var(--sans);
  font-size: .74rem;
  font-weight: 400;
  letter-spacing: .16em;
  text-transform: uppercase;
  text-decoration: none;
  border: 1px solid var(--olive);
  border-radius: 2px;
  color: var(--olive);
  background: none;
  cursor: pointer;
  transition: background .22s var(--ease), color .22s var(--ease), border-color .22s var(--ease);
}
html[lang="ar"] .btn { font-family: var(--arabic); font-size: .95rem; letter-spacing: 0; text-transform: none; }

.btn:hover { background: var(--olive); color: var(--ivory); }
.btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.btn--ghost { margin-top: 1rem; border-color: var(--sand-deep); color: var(--ink-soft); }
.btn--ghost:hover { background: var(--olive); border-color: var(--olive); color: var(--ivory); }

.btn--solid {
  width: 100%;
  padding: .95rem 1.4rem;
  background: var(--olive);
  color: var(--ivory);
}
.btn--solid:hover { background: color-mix(in srgb, var(--olive) 82%, #000); }
.btn--solid[disabled] { opacity: .55; cursor: progress; }

/* ─────────────  map  ───────────── */

.map {
  border: 1px solid var(--sand-deep);
  padding: 7px;
  background: var(--sand);
}
.map iframe {
  width: 100%;
  height: clamp(16rem, 42vh, 25rem);
  border: 0;
  /* Desaturate the tiles so the map sits inside the palette */
  filter: saturate(.62) contrast(.96) sepia(.08);
}

.map__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .75rem;
  margin: 1.5rem 0 0;
}

/* ─────────────  RSVP form  ───────────── */

.rsvp__intro {
  margin: 0 0 2.25rem;
  text-align: center;
  color: var(--ink-soft);
}

.form { display: grid; gap: 1.4rem; }

.field { display: grid; gap: .45rem; }

.field label,
.field legend {
  font-size: .7rem;
  font-weight: 400;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 0;
}
html[lang="ar"] .field label,
html[lang="ar"] .field legend { font-size: .95rem; letter-spacing: 0; text-transform: none; }

input[type="text"], input[type="email"], input[type="number"], textarea {
  width: 100%;
  padding: .8rem .9rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--ivory);
  border: 1px solid var(--sand-deep);
  border-radius: 2px;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
textarea { resize: vertical; }

input:focus, textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 14%, transparent);
}

/* Only scold after a submit attempt, never while typing */
.form.is-validated input:invalid,
.form.is-validated textarea:invalid { border-color: var(--terracotta); }

.field--choice {
  border: 0;
  margin: 0;
  display: grid;
  gap: .6rem;
}
.field--choice legend { margin-bottom: .45rem; }

.choice {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .7rem .9rem;
  font-size: .98rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  background: var(--ivory);
  border: 1px solid var(--sand-deep);
  border-radius: 2px;
  cursor: pointer;
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.choice:hover { border-color: var(--olive); }
.choice:has(input:checked) {
  border-color: var(--olive);
  background: color-mix(in srgb, var(--olive) 7%, transparent);
}
.choice input { accent-color: var(--olive); width: 1.05rem; height: 1.05rem; }

.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.form__status {
  margin: 0;
  min-height: 1.5em;
  text-align: center;
  font-size: .95rem;
}
.form__status[data-state="ok"]    { color: var(--olive); }
.form__status[data-state="error"] { color: var(--terracotta); }

/* ─────────────  footer  ───────────── */

.footer {
  padding: var(--step) 1.25rem clamp(2rem, 5vw, 3.5rem);
  text-align: center;
  border-top: 1px solid var(--sand-deep);
}
.footer__note {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink-soft);
}

/* ─────────────  entrance animation  ───────────── */

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .9s var(--ease), transform .9s var(--ease);
}
.reveal.is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ─────────────  print: fold it into a real card  ───────────── */

@media print {
  .lang-switch, .map, .map__links, .form, .rsvp__intro, .btn { display: none !important; }
  body { background: #fff; background-image: none; }
  .section { padding-block: 1.5rem; }
}
