/* =============================================================================
   Lamsa Dawa – Smart Events | Guest invitation page
   Ivory + gold + navy. RTL-first, mobile-first.
   ============================================================================= */

:root {
  --navy-950: #070E1C;
  --navy-900: #0B1426;
  --navy-800: #15254A;
  --navy-700: #1F3360;
  --gold-700: #8A6A22;
  --gold-600: #A8842F;
  --gold-500: #C9A24A;
  --gold-400: #D9B968;
  --gold-300: #E9D49F;
  --gold-200: #F3E7C6;
  --ivory-50: #FFFDF7;
  --ivory-100: #FBF6EA;
  --ivory-200: #F4ECDA;
  --ivory-300: #E9DCC0;
  --ink-900: #1A2440;
  --ink-700: #3F465A;
  --ink-500: #75705F;
  --line: rgba(168, 132, 47, .28);
  --green-700: #1D6B47;
  --green-600: #2B8A5E;
  --green-100: #E3F2E9;
  --rose-700: #8E3A3A;
  --rose-100: #F7E6E3;

  --font-body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --font-display: "Amiri", "IBM Plex Sans Arabic", serif;
  --font-script: "Aref Ruqaa", "Amiri", serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --radius: 26px;
  --shadow-card: 0 30px 60px -30px rgba(11, 20, 38, .35), 0 8px 20px -12px rgba(11, 20, 38, .18);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink-900);
  background: radial-gradient(120% 70% at 50% 0%, #FFFCF3 0%, var(--ivory-100) 55%, var(--ivory-200) 100%);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, a { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
p { margin: 0; }
h1, h2, h3 { margin: 0; font-weight: 700; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 3px; border-radius: 10px; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.noscript { padding: 24px; text-align: center; color: var(--rose-700); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Background geometric pattern (8-point stars) ---------- */
.bg-pattern {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='%23C9A24A' stroke-opacity='.16' stroke-width='1'%3E%3Cpath d='M48 20l8.5 19.5L76 48l-19.5 8.5L48 76l-8.5-19.5L20 48l19.5-8.5z'/%3E%3Cpath d='M28.2 28.2h39.6v39.6H28.2z' transform='rotate(45 48 48)'/%3E%3Ccircle cx='48' cy='48' r='5'/%3E%3Cpath d='M0 0l12 12M96 0L84 12M0 96l12-12M96 96L84 84'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 96px 96px;
  -webkit-mask-image: radial-gradient(90% 70% at 50% 30%, #000 30%, transparent 85%);
  mask-image: radial-gradient(90% 70% at 50% 30%, #000 30%, transparent 85%);
}

.app { width: 100%; max-width: 520px; margin: 0 auto; padding: calc(20px + var(--safe-t)) 16px calc(32px + var(--safe-b)); }

/* ---------- Seal (loading + cover) ---------- */
.seal {
  width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center; position: relative;
  background: radial-gradient(circle at 35% 30%, #E6C477, var(--gold-500) 45%, var(--gold-700) 100%);
  box-shadow: inset 0 2px 6px rgba(255,255,255,.4), inset 0 -6px 12px rgba(0,0,0,.25), 0 12px 30px -10px rgba(138,106,34,.7);
  color: var(--navy-900);
}
.seal::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; border: 1.5px dashed rgba(11,20,38,.35); }
.seal span { font-family: var(--font-script); font-size: 40px; line-height: 1; transform: translateY(-3px); }
.seal--pulse { animation: sealPulse 1.6s ease-in-out infinite; }
@keyframes sealPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }

/* ---------- Generic states (loading / error) ---------- */
.state {
  min-height: calc(100dvh - 80px); display: grid; place-content: center; justify-items: center; gap: 18px; text-align: center; padding: 24px 8px;
  animation: rise .5s var(--ease);
}
.state-title { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--navy-800); line-height: 1.4; }
.state-text { color: var(--ink-500); max-width: 340px; }
.state-icon { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; background: var(--ivory-50); border: 1px solid var(--line); color: var(--gold-600); box-shadow: 0 12px 30px -16px rgba(11,20,38,.3); }
.state-icon svg { width: 38px; height: 38px; }
.state-icon--rose { color: var(--rose-700); background: var(--rose-100); border-color: rgba(142,58,58,.2); }
.state .brand-foot { margin-top: 18px; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 54px; padding: 0 22px;
  border-radius: 16px; border: 1px solid transparent; font-weight: 600; font-size: 16px; text-decoration: none; white-space: nowrap;
  transition: transform .12s var(--ease), box-shadow .2s, background .2s, border-color .2s; user-select: none;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn[disabled] { opacity: .6; pointer-events: none; }
.btn--block { width: 100%; }
.btn--primary { background: linear-gradient(180deg, var(--navy-700), var(--navy-900)); color: var(--gold-300); box-shadow: 0 14px 28px -16px rgba(11,20,38,.8); }
.btn--primary:hover { box-shadow: 0 16px 32px -14px rgba(11,20,38,.85); }
.btn--gold { background: linear-gradient(180deg, var(--gold-400), var(--gold-500)); color: var(--navy-900); border-color: var(--gold-600); box-shadow: 0 14px 28px -16px rgba(138,106,34,.8); }
.btn--outline { background: var(--ivory-50); border-color: var(--line); color: var(--ink-900); }
.btn--outline:hover { border-color: var(--gold-500); }
.btn--ghost { background: transparent; color: var(--ink-500); min-height: 44px; font-weight: 500; font-size: 14.5px; text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--line); }
.btn .spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cover (sealed envelope) ---------- */
.cover {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 28px 20px calc(28px + var(--safe-b));
  background:
    radial-gradient(100% 60% at 50% 0%, rgba(201,162,74,.22), transparent 60%),
    radial-gradient(80% 60% at 50% 100%, rgba(31,51,96,.9), transparent 70%),
    var(--navy-900);
  color: var(--ivory-100); text-align: center; overflow: hidden;
  transition: opacity .7s var(--ease), transform .8s var(--ease);
}
.cover::before {
  content: ""; position: absolute; inset: 0; opacity: .45;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='%23C9A24A' stroke-opacity='.18' stroke-width='1'%3E%3Cpath d='M48 20l8.5 19.5L76 48l-19.5 8.5L48 76l-8.5-19.5L20 48l19.5-8.5z'/%3E%3Cpath d='M28.2 28.2h39.6v39.6H28.2z' transform='rotate(45 48 48)'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 96px 96px;
}
.cover-frame { position: absolute; inset: calc(14px + var(--safe-t)) 14px calc(14px + var(--safe-b)); border: 1px solid rgba(201,162,74,.4); border-radius: 22px; pointer-events: none; }
.cover-frame::after { content: ""; position: absolute; inset: 6px; border: 1px solid rgba(201,162,74,.18); border-radius: 17px; }
.cover-inner { position: relative; z-index: 1; display: grid; justify-items: center; gap: 14px; max-width: 420px; animation: rise .8s var(--ease); }
.cover-brand { font-family: var(--font-display); font-size: 15px; color: var(--gold-300); letter-spacing: .08em; }
.cover-to { font-size: 14px; color: rgba(251,246,234,.65); margin-top: 18px; }
.cover-name { font-family: var(--font-display); font-size: clamp(30px, 9vw, 42px); font-weight: 700; line-height: 1.35; color: var(--ivory-50); overflow-wrap: anywhere; }
.cover-sub { font-family: var(--font-display); font-size: 18px; color: var(--gold-300); }
.cover-open { margin-top: 26px; background: none; border: 0; padding: 0; display: grid; justify-items: center; gap: 14px; color: var(--gold-300); }
.cover-open .seal { width: 108px; height: 108px; transition: transform .3s var(--ease); }
.cover-open .seal span { font-size: 46px; }
.cover-open:hover .seal { transform: scale(1.05) rotate(-4deg); }
.cover-open-label { font-size: 15px; font-weight: 600; letter-spacing: .02em; display: inline-flex; align-items: center; gap: 8px; }
.cover-open-label::before, .cover-open-label::after { content: ""; width: 26px; height: 1px; background: var(--gold-500); opacity: .6; }
.cover.is-opening { opacity: 0; transform: translateY(-4%) scale(1.02); pointer-events: none; }
.cover.is-opening .seal { transform: scale(1.25) rotate(-12deg); opacity: 0; transition: transform .5s var(--ease), opacity .4s; }

/* ---------- Invitation card ---------- */
.invite { display: grid; gap: 18px; }
.invite.is-revealed { animation: rise .8s var(--ease); }
.card {
  position: relative; background: linear-gradient(180deg, #FFFEFA, var(--ivory-50) 40%, #FCF6E8);
  border-radius: var(--radius); box-shadow: var(--shadow-card); border: 1px solid var(--line); overflow: hidden;
}
.card::before { content: ""; position: absolute; inset: 9px; border: 1px solid rgba(201,162,74,.45); border-radius: calc(var(--radius) - 8px); pointer-events: none; }
.card::after { content: ""; position: absolute; inset: 14px; border: 1px dashed rgba(201,162,74,.25); border-radius: calc(var(--radius) - 12px); pointer-events: none; }

.hero { padding: 26px 26px 30px; text-align: center; display: grid; justify-items: center; gap: 6px; }
.corner { position: absolute; width: 64px; height: 64px; color: var(--gold-500); opacity: .85; pointer-events: none; z-index: 1; }
.corner--tr { top: 4px; right: 4px; }
.corner--tl { top: 4px; left: 4px; transform: scaleX(-1); }
.corner--br { bottom: 4px; right: 4px; transform: scaleY(-1); }
.corner--bl { bottom: 4px; left: 4px; transform: scale(-1, -1); }
.arch { width: 132px; height: 70px; color: var(--gold-500); margin-top: 6px; }
.brand-mini { font-family: var(--font-display); font-size: 13px; letter-spacing: .1em; color: var(--gold-700); }
.kicker { font-size: 14px; color: var(--ink-500); margin-top: 10px; }
.guest-name { font-family: var(--font-display); font-weight: 700; font-size: clamp(32px, 10vw, 44px); line-height: 1.3; color: var(--navy-800); overflow-wrap: anywhere; padding-inline: 8px; }
.guest-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 6px; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 5px 13px; border-radius: 999px; font-size: 13.5px; font-weight: 600; background: var(--ivory-200); color: var(--ink-700); border: 1px solid var(--line); }
.tag svg { width: 15px; height: 15px; color: var(--gold-600); }
.tag--vip { background: linear-gradient(180deg, var(--gold-300), var(--gold-400)); color: var(--navy-900); border-color: var(--gold-500); }
.tag--vip svg { color: var(--navy-800); }
.invite-line { font-family: var(--font-display); font-size: 18px; color: var(--ink-700); margin-top: 16px; }
.event-name { font-family: var(--font-script); font-size: clamp(30px, 9vw, 40px); line-height: 1.45; color: var(--gold-700); padding-inline: 10px; overflow-wrap: anywhere; }
.divider { width: 220px; max-width: 70%; height: 22px; color: var(--gold-500); margin: 10px auto 4px; }

.details { display: grid; gap: 4px; padding: 0 22px 8px; }
.detail { display: flex; align-items: flex-start; gap: 14px; padding: 14px 4px; border-top: 1px solid rgba(201,162,74,.22); }
.detail:first-child { border-top: 0; }
.detail-icon { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; flex: none; background: var(--ivory-200); color: var(--gold-700); border: 1px solid var(--line); }
.detail-icon svg { width: 20px; height: 20px; }
.detail-label { font-size: 12.5px; color: var(--ink-500); }
.detail-value { font-weight: 600; font-size: 16.5px; line-height: 1.5; }
.detail-sub { font-size: 13.5px; color: var(--ink-500); }

/* Countdown */
.countdown { margin: 8px 18px 22px; padding: 18px 14px 16px; border-radius: 20px; text-align: center; color: var(--ivory-100); position: relative; overflow: hidden;
  background: radial-gradient(100% 120% at 50% 0%, rgba(201,162,74,.25), transparent 60%), linear-gradient(160deg, var(--navy-800), var(--navy-900)); }
.countdown::after { content: ""; position: absolute; inset: 6px; border: 1px solid rgba(201,162,74,.28); border-radius: 15px; pointer-events: none; }
.countdown-title { font-size: 13.5px; color: var(--gold-300); margin-bottom: 10px; letter-spacing: .02em; }
.countdown-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; direction: rtl; }
.cd-unit { padding: 10px 4px 8px; border-radius: 14px; background: rgba(255,255,255,.06); border: 1px solid rgba(201,162,74,.18); }
.cd-num { display: block; font-family: var(--font-display); font-size: 32px; font-weight: 700; line-height: 1.1; color: var(--ivory-50); font-variant-numeric: tabular-nums; }
.cd-label { display: block; font-size: 12px; color: rgba(251,246,234,.7); }
.countdown-msg { font-family: var(--font-display); font-size: 22px; color: var(--gold-300); padding: 6px 0; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 18px 24px; }
.actions .btn { min-height: 50px; font-size: 15px; padding: 0 12px; }
.actions .btn:only-child { grid-column: 1 / -1; }

/* ---------- RSVP ---------- */
.rsvp { padding: 26px 22px 24px; text-align: center; display: grid; gap: 14px; justify-items: center; }
.section-kicker { font-size: 13px; letter-spacing: .06em; color: var(--gold-700); display: inline-flex; align-items: center; gap: 10px; }
.section-kicker::before, .section-kicker::after { content: ""; width: 22px; height: 1px; background: var(--gold-500); opacity: .7; }
.rsvp-q { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--navy-800); line-height: 1.4; }
.rsvp-hint { color: var(--ink-500); font-size: 14.5px; max-width: 360px; }
.rsvp-buttons { display: grid; gap: 10px; width: 100%; margin-top: 4px; }
.rsvp-status { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600; }
.rsvp-status svg { width: 16px; height: 16px; }
.rsvp-status--pending { background: var(--gold-200); color: var(--gold-700); }
.rsvp-status--confirmed { background: var(--green-100); color: var(--green-700); }
.rsvp-status--declined { background: var(--rose-100); color: var(--rose-700); }
.rsvp-done { display: grid; gap: 10px; justify-items: center; animation: rise .5s var(--ease); }
.rsvp-done-icon { width: 78px; height: 78px; border-radius: 50%; display: grid; place-items: center; }
.rsvp-done-icon svg { width: 38px; height: 38px; }
.rsvp-done--confirmed .rsvp-done-icon { background: radial-gradient(circle at 35% 30%, #4DB384, var(--green-600) 55%, var(--green-700)); color: #fff; box-shadow: 0 14px 30px -14px rgba(29,107,71,.8); }
.rsvp-done--declined .rsvp-done-icon { background: var(--rose-100); color: var(--rose-700); border: 1px solid rgba(142,58,58,.2); }
.rsvp-done h3 { font-family: var(--font-display); font-size: 26px; color: var(--navy-800); line-height: 1.4; }
.rsvp-note { padding: 12px 16px; border-radius: 14px; background: var(--ivory-200); color: var(--ink-700); font-size: 14px; border: 1px solid var(--line); }

/* ---------- Entry pass ---------- */
.pass { padding: 26px 22px 24px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.pass-title { font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--navy-800); }
.pass-text { color: var(--ink-500); font-size: 14.5px; max-width: 340px; }
.qr-box { width: 220px; height: 220px; padding: 14px; background: #fff; border-radius: 20px; border: 1px solid var(--line); box-shadow: 0 16px 34px -20px rgba(11,20,38,.45); display: grid; place-items: center; position: relative; }
.qr-box::before { content: ""; position: absolute; inset: -7px; border: 1px solid rgba(201,162,74,.45); border-radius: 25px; pointer-events: none; }
.qr-box svg { width: 100%; height: 100%; }
.qr-fallback { font-size: 13px; color: var(--ink-500); }
.pass-token { font-family: var(--font-mono); font-size: 13px; color: var(--ink-500); direction: ltr; letter-spacing: .04em; overflow-wrap: anywhere; }
.pass-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.pass-gate { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 14px; font-weight: 600; font-size: 14.5px; background: var(--navy-800); color: var(--gold-300); }
.pass-gate svg { width: 18px; height: 18px; }

/* ---------- Footer ---------- */
.brand-foot { display: grid; justify-items: center; gap: 4px; padding: 10px 0 4px; color: var(--ink-500); font-size: 12.5px; text-align: center; }
.brand-foot strong { font-family: var(--font-display); font-size: 16px; color: var(--gold-700); font-weight: 700; }

/* ---------- Bottom sheet (decline confirm) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(7,14,28,.5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); display: grid; align-items: end; justify-items: center; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-width: 520px; background: var(--ivory-50); border-radius: 26px 26px 0 0; padding: 12px 22px calc(22px + var(--safe-b)); display: grid; gap: 14px; text-align: center; animation: sheetUp .35s var(--ease); border-top: 1px solid var(--line); }
.sheet-handle { width: 44px; height: 5px; border-radius: 3px; background: var(--ivory-300); margin: 0 auto 6px; }
.sheet h3 { font-family: var(--font-display); font-size: 24px; color: var(--navy-800); }
.sheet p { color: var(--ink-500); }
.sheet-actions { display: grid; gap: 10px; margin-top: 6px; }
@keyframes sheetUp { from { transform: translateY(40px); opacity: .4; } }
@media (min-width: 560px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 26px; border: 1px solid var(--line); } }

/* ---------- Toast ---------- */
.toast { position: fixed; z-index: 90; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%); width: calc(100% - 32px); max-width: 440px; padding: 14px 18px; border-radius: 16px; background: var(--navy-900); color: var(--ivory-100); font-size: 14.5px; text-align: center; box-shadow: 0 20px 40px -18px rgba(7,14,28,.6); animation: rise .3s var(--ease); }
.toast--error { background: #6E2B2B; }

@media (min-width: 560px) {
  .app { padding-top: 40px; }
  .hero { padding: 34px 40px 34px; }
}
@media print {
  .bg-pattern, .actions, .rsvp-buttons, .btn--ghost, .toast, #sheet-root { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* Cover button focus: glow the seal instead of drawing a box */
.cover-open:focus-visible { outline: none; }
.cover-open:focus-visible .seal { box-shadow: inset 0 2px 6px rgba(255,255,255,.4), inset 0 -6px 12px rgba(0,0,0,.25), 0 0 0 4px rgba(233,212,159,.35), 0 12px 30px -10px rgba(138,106,34,.7); }
