/* ==========================================================================
   Riyadah — coming soon
   Aesthetic: editorial luxury, warm dark, single typographic centerpiece.
   ========================================================================== */

:root {
  /* Palette: warm ink + parchment + antique gold */
  --bg: #0c0a08;
  --bg-soft: #14110d;
  --fg: #ebe3d0;
  --fg-soft: #b8ad95;
  --fg-mute: #6a604f;
  --gold: #c9a961;
  --gold-bright: #e3c47a;
  --line: #2a241c;

  /* Type */
  --font-display-en: "Fraunces", "Times New Roman", serif;
  --font-display-ar: "El Messiri", "Tajawal", serif;
  --font-body-en: "Geist", "Helvetica Neue", system-ui, sans-serif;
  --font-body-ar: "IBM Plex Sans Arabic", "Tajawal", system-ui, sans-serif;

  --space-1: clamp(0.5rem, 1vw, 0.75rem);
  --space-2: clamp(1rem, 2vw, 1.5rem);
  --space-3: clamp(1.5rem, 3vw, 2.5rem);
  --space-4: clamp(2rem, 5vw, 4rem);
  --space-5: clamp(3rem, 8vw, 7rem);

  --max: 1180px;

  /* Easings */
  --ease-out-soft: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out-soft: cubic-bezier(0.65, 0, 0.35, 1);
}

/* Reset --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body-en);
  font-size: 16px;
  line-height: 1.5;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  position: relative;
}

/* RTL behaviour ------------------------------------------------------- */
html[data-lang="ar"] body { font-family: var(--font-body-ar); }
html[data-lang="ar"] {
  direction: rtl;
}

/* Shared ambient layers ----------------------------------------------- */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.06;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 0.95  0 0 0 0 0.85  0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

.aurora {
  position: fixed;
  inset: -20%;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 60% 40% at 20% 30%, rgba(201, 169, 97, 0.14), transparent 60%),
    radial-gradient(ellipse 50% 35% at 85% 75%, rgba(201, 169, 97, 0.08), transparent 65%),
    radial-gradient(ellipse 80% 60% at 50% 100%, rgba(80, 50, 20, 0.35), transparent 70%);
  filter: blur(40px);
  animation: aurora-drift 24s var(--ease-in-out-soft) infinite alternate;
}
@keyframes aurora-drift {
  0%   { transform: translate3d(-2%, -1%, 0) scale(1); }
  100% { transform: translate3d(3%, 2%, 0) scale(1.05); }
}

/* Layout shell -------------------------------------------------------- */
.site-header,
.stage,
.site-footer {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--space-3);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: clamp(1.25rem, 2.5vw, 1.75rem);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--fg);
  font-family: var(--font-body-en);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  transition: color 0.4s var(--ease-out-soft);
}
.brand-mark:hover { color: var(--gold-bright); }
.brand-mark svg { color: var(--gold); transition: transform 0.6s var(--ease-out-soft); }
.brand-mark:hover svg { transform: rotate(45deg); }
.brand-mark .dot { color: var(--gold); }

/* Force the brand mark to stay LTR even in RTL mode (it's a wordmark) */
html[data-lang="ar"] .brand-mark {
  direction: ltr;
  font-family: var(--font-body-en);
}

/* Language toggle ----------------------------------------------------- */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(20, 17, 13, 0.5);
  backdrop-filter: blur(6px);
}
.lang-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--fg-mute);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: color 0.3s var(--ease-out-soft);
}
.lang-btn[data-set-lang="ar"] { font-family: var(--font-body-ar); font-size: 0.9rem; }
.lang-btn:hover { color: var(--fg-soft); }
.lang-btn.is-active { color: var(--gold-bright); }
.lang-sep { color: var(--fg-mute); font-size: 0.75rem; opacity: 0.6; }

/* Stage --------------------------------------------------------------- */
.stage {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(2rem, 4vw, 3rem);
  padding-block: var(--space-4);
  min-height: 70dvh;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--fg-soft);
  font-family: var(--font-body-en);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}
body.is-revealing .eyebrow {
  opacity: 0;
  animation: fade-up 0.9s 0.1s var(--ease-out-soft) forwards;
}
.eyebrow .dash {
  display: inline-block;
  width: 28px;
  height: 1px;
  background: var(--gold);
  transform-origin: left center;
}
body.is-revealing .eyebrow .dash {
  transform: scaleX(0);
  animation: dash-grow 0.8s 0.05s var(--ease-out-soft) forwards;
}
html[data-lang="ar"] .eyebrow {
  font-family: var(--font-body-ar);
  letter-spacing: 0;
  text-transform: none;
  font-size: 0.85rem;
}
html[data-lang="ar"] .eyebrow .dash { transform-origin: right center; }
@keyframes dash-grow { to { transform: scaleX(1); } }

/* Wordmark — the centerpiece ----------------------------------------- */
.wordmark {
  display: flex;
  flex-direction: column;
  gap: clamp(0.5rem, 1.5vw, 1.25rem);
  font-weight: 400;
  line-height: 1.05; /* roomy enough for italic ascenders/descenders */
  position: relative;
  padding-block: 0.25em; /* headroom for the temporarily-translated reveal state */
}

.wordmark-ar,
.wordmark-en {
  display: inline-flex;
  align-items: baseline;
}

.wordmark-ar {
  font-family: var(--font-display-ar);
  font-size: clamp(5.5rem, 18vw, 16rem);
  letter-spacing: -0.01em;
  color: var(--fg);
  direction: rtl;
  /* Slight optical adjustment so Arabic letters connect smoothly when
     animated character-by-character. */
  gap: 0;
}

.wordmark-en {
  font-family: var(--font-display-en);
  font-variation-settings: "opsz" 144, "SOFT" 30, "wght" 400;
  font-size: clamp(3.5rem, 11vw, 9.5rem);
  letter-spacing: -0.04em;
  color: var(--fg);
  font-style: italic;
  position: relative;
  direction: ltr; /* always LTR, even when the page is RTL */
  padding-bottom: 0.2em; /* explicit room for italic descenders that
                            WebKit clips when relying on line-box alone */
}

/* Character reveal animation — only during the initial reveal phase.
 * Default state is visible; animations only run once on first load.
 * English uses per-character stagger (Latin letters are independent).
 * Arabic must animate as a single word because contextual letter
 * shaping requires all letters to live in one text run. */
.wordmark-en .char {
  display: inline-block;
}
/* Wordmark is static: no entry animation. WebKit clipped italic
   descenders during the reveal regardless of how the animation was
   structured (per-char vs whole-word, with or without transform).
   Other elements (eyebrow, lede, capture) keep their reveals. */

@keyframes char-reveal {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes char-fade {
  to { opacity: 1; }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(0.6em); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  to { opacity: 1; }
}

/* Lede ---------------------------------------------------------------- */
.lede {
  font-family: var(--font-display-en);
  font-variation-settings: "opsz" 14, "SOFT" 0, "wght" 350;
  font-size: clamp(1.05rem, 1.7vw, 1.4rem);
  line-height: 1.45;
  color: var(--fg-soft);
  max-width: 36ch;
}
body.is-revealing .lede {
  opacity: 0;
  animation: fade-up 1s 1.5s var(--ease-out-soft) forwards;
}
.lede span { display: block; }
.lede-em {
  color: var(--fg);
  font-style: italic;
  margin-top: 0.2em;
}
html[data-lang="ar"] .lede {
  font-family: var(--font-display-ar);
  font-size: clamp(1.1rem, 1.8vw, 1.5rem);
  font-weight: 400;
}
html[data-lang="ar"] .lede-em {
  font-style: normal;
  font-weight: 600;
}

/* Capture form -------------------------------------------------------- */
.capture {
  width: 100%;
  max-width: 38rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
body.is-revealing .capture {
  opacity: 0;
  animation: fade-up 1s 1.9s var(--ease-out-soft) forwards;
}
.capture-heading {
  font-family: var(--font-body-en);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-soft);
}
html[data-lang="ar"] .capture-heading {
  font-family: var(--font-body-ar);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.95rem;
}

.signup-field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border-bottom: 1px solid var(--line);
  transition: border-color 0.4s var(--ease-out-soft);
}
.signup-field:focus-within { border-color: var(--gold); }

#email {
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--fg);
  font-family: var(--font-body-en);
  font-size: clamp(1rem, 1.3vw, 1.15rem);
  padding: 1rem 0;
  caret-color: var(--gold);
}
html[data-lang="ar"] #email { font-family: var(--font-body-ar); }
#email::placeholder { color: var(--fg-mute); }

.signup-submit {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: transparent;
  border: 0;
  color: var(--fg);
  font-family: var(--font-body-en);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0.5rem 0.25rem;
  cursor: pointer;
  transition: color 0.3s var(--ease-out-soft);
}
html[data-lang="ar"] .signup-submit {
  font-family: var(--font-body-ar);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.95rem;
}
.signup-submit:hover { color: var(--gold-bright); }
.signup-submit .submit-arrow {
  transition: transform 0.4s var(--ease-out-soft);
}
.signup-submit:hover .submit-arrow { transform: translateX(4px); }
html[data-lang="ar"] .signup-submit .submit-arrow { transform: scaleX(-1); }
html[data-lang="ar"] .signup-submit:hover .submit-arrow { transform: scaleX(-1) translateX(4px); }

.signup-feedback {
  font-size: 0.85rem;
  min-height: 1.2em;
  color: var(--fg-soft);
  transition: color 0.3s ease;
}
.signup-feedback[data-state="success"] { color: var(--gold-bright); }
.signup-feedback[data-state="error"] { color: #d97757; }

.capture-fineprint {
  font-size: 0.78rem;
  color: var(--fg-mute);
  font-style: italic;
}
html[data-lang="ar"] .capture-fineprint { font-style: normal; }

/* Footer -------------------------------------------------------------- */
.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding-block: clamp(1.5rem, 3vw, 2rem);
  font-size: 0.75rem;
  color: var(--fg-mute);
  letter-spacing: 0.05em;
}
html[data-lang="ar"] .site-footer { letter-spacing: 0; font-size: 0.85rem; }
.footer-meta { display: inline-flex; gap: 0.6rem; align-items: center; }
.footer-meta a {
  color: var(--fg-soft);
  text-decoration: none;
  transition: color 0.3s var(--ease-out-soft);
  border-bottom: 1px solid transparent;
}
.footer-meta a:hover { color: var(--gold-bright); border-bottom-color: var(--gold); }

/* Locale visibility --------------------------------------------------- */
/* The JS swaps textContent on [data-i18n] elements in place, so they
 * stay visible at all times — the only thing that needs language-aware
 * hiding is the wordmark (handled below). */

/* Wordmark visibility — show only the script matching the active
   language. Showing both at once visually overlaps and confuses. */
.wordmark-ar { display: none; }
html[data-lang="ar"] .wordmark-ar { display: inline-block; }
html[data-lang="ar"] .wordmark-en { display: none; }

/* Utilities ----------------------------------------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Responsive ---------------------------------------------------------- */
@media (max-width: 640px) {
  .site-header { padding-block: 1.1rem; }
  .stage { padding-block: 2rem 3rem; gap: 2.25rem; min-height: 80dvh; }
  .wordmark { gap: 0.4rem; }
  .signup-field { grid-template-columns: 1fr; gap: 0.5rem; padding-bottom: 0.5rem; }
  .signup-submit { justify-self: start; padding-inline: 0; }
  html[data-lang="ar"] .signup-submit { justify-self: end; }
  .site-footer { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .aurora { animation: none; }
  .wordmark .char { opacity: 1; transform: none; }
}
