/* =========================================================
   «ختم النور» — design tokens, base, shell, shared components
   Owned by the orchestrator. Module CSS lives in cover.css,
   sections-a.css, sections-b.css, guestbook.css.
   ========================================================= */
:root {
  /* MIDNIGHT */
  --night-950: #05070F;
  --night-900: #0B1020;
  --night-800: #131A33;
  --night-700: #1C2547;
  --night-grad: radial-gradient(120% 90% at 50% 42%, #18214A 0%, #0B1020 55%, #05070F 100%);

  /* IVORY */
  --ivory: #FBF6EF;
  --paper: #FFFDF8;
  --parchment: #F3EADB;
  --sand: #E6D8C1;

  /* CHAMPAGNE GOLD */
  --gold: #C9A46A;        /* ornaments/strokes/button fill; as TEXT only on midnight */
  --gold-light: #E8D3A6;  /* text on midnight */
  --gold-glint: #F8EBC9;
  --gold-deep: #9C7A43;   /* display text >= 24px on ivory */
  --gold-ink: #7A5A2A;    /* ALL small gold text on ivory */

  /* WAX */
  --wax-hi: #F1D592; --wax: #C69A4E; --wax-mid: #A87C36; --wax-low: #6E4E1E; --wax-shadow: #4A3312;
  --wax-grad: radial-gradient(circle at 36% 30%, #F1D592 0%, #C69A4E 38%, #A87C36 68%, #6E4E1E 100%);

  /* INK */
  --ink: #2A2118;
  --ink-soft: #5C4C3B;
  --ink-mute: #7C6C59;

  /* COUPLE ACCENTS */
  --blush: #EAD5CB;
  --rose: #A8705A;
  --rose-ink: #8E5A43;
  --olive: #4F6B3F;
  --error: #A3473A;

  /* LIGHT */
  --glow: #FFE6B3; --flame: #FFD98E; --ember: #F2B66B;
  --flood: radial-gradient(closest-side, #FFFFFF 0%, #FBF6EF 62%, rgba(251, 246, 239, 0) 100%);
  --pool: radial-gradient(closest-side, rgba(255, 231, 184, .55), rgba(255, 231, 184, 0));

  /* FOIL (use with background-clip:text; background-size:250% 100%) */
  --foil-ivory: linear-gradient(115deg, #7A5A2A 0%, #9C7A43 28%, #C9A46A 44%, #F3E2B8 50%, #C9A46A 56%, #9C7A43 72%, #7A5A2A 100%);
  --foil-night: linear-gradient(115deg, #9C7A43 0%, #C9A46A 25%, #F8EBC9 45%, #E8D3A6 55%, #C9A46A 75%, #9C7A43 100%);
  --btn-gold: linear-gradient(180deg, #D8B77E 0%, #C9A46A 55%, #B48E52 100%);

  /* UTILITY */
  --rule-gold: rgba(201, 164, 106, .35);
  --shadow-card: inset 0 1px 0 rgba(255, 255, 255, .7), 0 10px 30px -14px rgba(90, 64, 28, .25);
  --shadow-photo: 0 30px 50px -30px rgba(0, 0, 0, .6);
  --focus-ivory: #7A5A2A;
  --focus-night: #E8D3A6;

  /* TYPE */
  --f-names: 'Gulzar', 'Noto Nastaliq Urdu', 'Aref Ruqaa', serif;
  --f-head: 'Alyamama', 'Markazi Text', serif;
  --f-verse: 'Amiri Quran', 'Scheherazade New', 'Amiri', serif;
  --f-body: 'Alexandria', 'Readex Pro', system-ui, sans-serif;
  --f-num: 'Markazi Text', 'Amiri', serif;
  --f-letter: 'Markazi Text', 'Amiri', serif;

  /* MOTION */
  --e-expo: cubic-bezier(.16, 1, .3, 1);
  --e-cine: cubic-bezier(.65, 0, .35, 1);
  --e-fall: cubic-bezier(.55, 0, 1, .45);
  --e-spring: cubic-bezier(.34, 1.56, .64, 1);
  --e-write: cubic-bezier(.45, .05, .25, 1);
  --e-flood: cubic-bezier(.55, 0, .1, 1);

  /* LAYOUT */
  --col: 440px;
  --gutter: 20px;
  --sec-pad: 80px;

  /* Khatam lattice tile (O9), stroke #C9A46A — use as background-image with an opacity layer */
  --lattice: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cg fill='none' stroke='%23C9A46A' stroke-width='.75'%3E%3Crect x='15.5' y='15.5' width='17' height='17'/%3E%3Crect x='15.5' y='15.5' width='17' height='17' transform='rotate(45 24 24)'/%3E%3Cpath d='M24 0V7M24 41V48M0 24H7M41 24H48'/%3E%3Cpath d='M0 -4L4 0L0 4L-4 0Z M48 -4L52 0L48 4L44 0Z M0 44L4 48L0 52L-4 48Z M48 44L52 48L48 52L44 48Z'/%3E%3C/g%3E%3C/svg%3E");
  /* Paper grain (O17), pre-rendered static tile */
  --grain: 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='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .31 0 0 0 0 .16 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: auto; }
body {
  margin: 0;
  min-height: 100svh;
  background: var(--night-950);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
html.is-sealed, html.is-sealed body { overflow: hidden; height: 100%; }
img, svg, video, canvas { display: block; max-width: 100%; }
svg { overflow: visible; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }
h1, h2, h3, h4, p, figure, blockquote, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus-ivory); outline-offset: 4px; border-radius: 6px; }
.on-night :focus-visible, .on-night:focus-visible { outline-color: var(--focus-night); }

/* ---------- page shell ---------- */
main {
  position: relative;
  width: 100%;
  max-width: var(--col);
  margin-inline: auto;
  background: var(--ivory);
  overflow-x: clip;
}
html.is-sealed main { visibility: hidden; }

.sec {
  position: relative;
  padding: var(--sec-pad) var(--gutter);
  text-align: center;
  isolation: isolate;
}
.sec.paper::before {             /* paper grain on ivory sections */
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: var(--grain); background-size: 180px 180px;
}
.sec.tint { background: color-mix(in srgb, var(--parchment) 40%, var(--ivory)); }
.band-night { background: var(--night-900); color: var(--gold-light); }
.lattice-layer {                   /* add as an empty child: <div class="lattice-layer" aria-hidden="true"></div> */
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: var(--lattice); background-size: 48px 48px; opacity: .05;
}
.sec-late { content-visibility: auto; contain-intrinsic-size: auto 900px; }

@media (min-width: 768px) {
  body {
    background:
      radial-gradient(520px 520px at 15% 25%, rgba(201, 164, 106, .16), transparent 70%),
      radial-gradient(520px 520px at 85% 75%, rgba(201, 164, 106, .12), transparent 70%),
      var(--night-950);
    background-attachment: fixed;
  }
  body::before {
    content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
    background-image: var(--lattice); background-size: 48px 48px; opacity: .04;
  }
  main {
    z-index: 1;
    box-shadow: 0 40px 120px rgba(0, 0, 0, .55);
    border-inline: 1px solid rgba(201, 164, 106, .35);
  }
}

/* ---------- typography ---------- */
.names {
  font-family: var(--f-names);
  font-weight: 400;
  line-height: 1.75;
  padding: .25em .2em;
  letter-spacing: 0;
}
.foil-ivory, .foil-night {
  background-size: 250% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.foil-ivory { background-image: var(--foil-ivory); }
.foil-night { background-image: var(--foil-night); }
.foil-ivory.glint, .foil-night.glint { animation: foil-glint 1.6s var(--e-cine) 1; }
@keyframes foil-glint { from { background-position: 100% 0; } to { background-position: 0 0; } }

.num { font-family: var(--f-num); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Section header: <header class="sec-head"> kicker, h2, divider */
.sec-head { display: grid; justify-items: center; gap: 6px; margin-block-end: 36px; }
.kicker {
  display: inline-flex; align-items: center; gap: 10px;
  font: 500 13px/1.6 var(--f-body); color: var(--gold-ink); word-spacing: .2em;
}
.kicker::before, .kicker::after {
  content: ''; width: 20px; height: 1px;
  background: linear-gradient(to var(--kicker-dir, left), currentColor, transparent);
}
.kicker::after { --kicker-dir: right; }
.band-night .kicker, .on-night .kicker { color: var(--gold); }
.sec-title {
  font: 700 clamp(28px, 8vw, 36px)/1.5 var(--f-head);
  color: var(--ink);
}
.band-night .sec-title, .on-night .sec-title { color: var(--gold-light); }
.divider { width: 220px; height: 18px; color: var(--gold); margin-inline: auto; }
.divider--sm { width: 160px; height: 14px; }
.band-night .divider .dv-star, .on-night .divider .dv-star { color: var(--gold-light); }
.lead { font: 300 clamp(17px, 4.6vw, 19px)/2 var(--f-body); color: var(--ink-soft); }
.meta { font: 400 12.5px/1.6 var(--f-body); color: var(--ink-mute); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 24px; border-radius: 14px;
  font: 600 17px/1 var(--f-body); text-decoration: none;
  transition: transform .15s ease, opacity .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:active { transform: translateY(1px); }
.btn-gold { background: var(--btn-gold); color: var(--night-900); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 8px 20px -10px rgba(122, 90, 42, .55); }
.btn-ghost { border: 1px solid var(--gold); color: var(--gold-ink); background: transparent; }
.band-night .btn-ghost, .on-night .btn-ghost { color: var(--gold-light); }
.btn-text { min-height: 44px; padding: 0 8px; font-weight: 500; font-size: 15px; color: var(--gold-ink); text-decoration: underline; text-underline-offset: 5px; text-decoration-color: var(--rule-gold); }
.btn-block { width: 100%; }

/* ---------- corner brackets (O5) ----------
   <div class="cornered"> … <svg class="corner tl"><use href="#corner"/></svg> ×4 (tl,tr,bl,br) */
.cornered { position: relative; }
.corner { position: absolute; width: 22px; height: 22px; color: var(--gold); pointer-events: none; }
.corner.tr { top: 8px; inset-inline-start: 8px; }              /* RTL: start = right */
.corner.tl { top: 8px; inset-inline-end: 8px; transform: scaleX(-1); }
.corner.br { bottom: 8px; inset-inline-start: 8px; transform: scaleY(-1); }
.corner.bl { bottom: 8px; inset-inline-end: 8px; transform: scale(-1, -1); }

/* ---------- reveal primitives (paused until html.is-open) ---------- */
.rv-rise { opacity: 0; transform: translateY(14px); transition: opacity .7s var(--e-expo), transform .7s var(--e-expo); transition-delay: calc(var(--i, 0) * 90ms + var(--d, 0ms)); }
.rv-rise.is-in { opacity: 1; transform: none; }

.rv-pop { opacity: 0; transform: scale(.6); transition: opacity .5s var(--e-spring), transform .5s var(--e-spring); transition-delay: calc(var(--i, 0) * 90ms + var(--d, 0ms)); }
.rv-pop.is-in { opacity: 1; transform: none; }

/* ink sweep: writes right-to-left like a pen */
.rv-ink {
  -webkit-mask-image: linear-gradient(to left, #000 40%, transparent 60%);
          mask-image: linear-gradient(to left, #000 40%, transparent 60%);
  -webkit-mask-size: 300% 100%; mask-size: 300% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: 0 0; mask-position: 0 0;
}
.rv-ink.is-in { animation: ink-sweep var(--ink-dur, 1100ms) var(--e-write) var(--d, 0ms) both; }
@keyframes ink-sweep {
  from { -webkit-mask-position: 0 0; mask-position: 0 0; }
  to   { -webkit-mask-position: 100% 0; mask-position: 100% 0; }
}
.rv-ink.ink-done { -webkit-mask-image: none; mask-image: none; animation: none; }

/* stroke draw: put pathLength="1" on the paths */
.rv-draw path, .rv-draw line, .rv-draw polyline, .rv-draw circle, .rv-draw rect { stroke-dasharray: 1; stroke-dashoffset: 1; }
.rv-draw.is-in path, .rv-draw.is-in line, .rv-draw.is-in polyline, .rv-draw.is-in circle, .rv-draw.is-in rect {
  transition: stroke-dashoffset var(--draw-dur, 1200ms) var(--e-cine) var(--d, 0ms); stroke-dashoffset: 0;
}

/* Nothing animates in until the envelope is opened */
html:not(.is-open) .rv-rise, html:not(.is-open) .rv-pop { transition: none; }

/* infinite loops get paused off-screen by JS with .is-off */
.is-off, .is-off * { animation-play-state: paused !important; }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 120; inset-inline: 0; bottom: calc(84px + env(safe-area-inset-bottom));
  margin-inline: auto; width: max-content; max-width: calc(100vw - 32px);
  padding: 10px 18px; border-radius: 999px;
  background: var(--night-900); color: var(--gold-light);
  font: 500 14px/1.5 var(--f-body);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5);
  opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity .3s var(--e-expo), transform .3s var(--e-expo);
}
.toast.is-show { opacity: 1; transform: none; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
html.is-reduced .rv-rise, html.is-reduced .rv-pop { transform: none; transition: opacity .3s ease; }
html.is-reduced .rv-ink { -webkit-mask-image: none; mask-image: none; animation: none; }
html.is-reduced .rv-draw path, html.is-reduced .rv-draw line, html.is-reduced .rv-draw polyline,
html.is-reduced .rv-draw circle, html.is-reduced .rv-draw rect { stroke-dashoffset: 0; transition: none; }

/* ===== desktop ===== */
/* Wide layout >= 1024px: main goes full width, sections stay full-bleed (backgrounds,
   grain, lattice span the viewport) and their content is held to --wide via inline padding.
   Below 1024px nothing here applies — the phone column is untouched. */
@media (min-width: 1024px) {
  :root {
    --wide: 1280px;
    --gutter: 48px;
    --sec-pad: 120px;
    --sec-x: max(var(--gutter), calc((100% - var(--wide)) / 2));
    --doorw: min(880px, 70vw);   /* arched doorway width used by gallery + footer */
  }
  body::before { content: none; }
  main {
    max-width: none;
    box-shadow: none;
    border-inline: 0;
  }
  .sec { padding-inline: var(--sec-x); }

  .sec-head { gap: 8px; margin-block-end: 56px; }
  .kicker { font-size: 15px; }
  .kicker::before, .kicker::after { width: 32px; }
  .sec-title { font-size: clamp(40px, 3.6vw, 52px); }
  .divider { width: 280px; height: 23px; }
  .lead { font-size: 21px; }

  /* toast sits beside the music button in the bottom-left (inline-end in RTL) corner */
  .toast {
    inset-inline: auto 92px;
    bottom: calc(31px + env(safe-area-inset-bottom));
    margin-inline: 0;
    max-width: min(420px, calc(100vw - 140px));
  }
}
@media (min-width: 1440px) {
  :root { --gutter: 64px; --sec-pad: 136px; }
  .sec-title { font-size: 56px; }
  .toast { inset-inline-end: 100px; bottom: calc(39px + env(safe-area-inset-bottom)); }
}
