/* =========================================================
   معصومه نخلی — Design System : Base
   Editorial / Paper & Gold Foil / RTL-first
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&family=Amiri:ital,wght@0,400;0,700;1,400&family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400&display=swap');

/* ---------- Tokens ---------- */
:root {
  /* Paper & ink */
  --paper:        #F7F3EC;
  --paper-2:      #FFFDF8;
  --paper-3:      #EFE8DC;
  --ink:          #14110D;
  --ink-2:        #3B352C;
  --ink-3:        #6B6257;
  --ink-4:        #9A9186;

  /* Brand */
  --gold:         #C79A3E;
  --gold-soft:    #E2C57E;
  --gold-deep:    #8C6420;
  --sage:         #CBD9D0;
  --sage-deep:    #7E9A8B;
  --clay:         #8C4A2F;

  /* Dark surfaces */
  --night:        #0E0C0A;
  --night-2:      #17140F;
  --night-3:      #241F18;

  --danger:       #B3261E;
  --success:      #2F6B4F;

  /* Semantic */
  --bg:           var(--paper);
  --surface:      var(--paper-2);
  --surface-alt:  var(--paper-3);
  --fg:           var(--ink);
  --fg-muted:     var(--ink-3);
  --border:       #E2D9C9;
  --border-soft:  #EDE5D7;
  --ring:         var(--gold);

  /* Foil gradient */
  --foil: linear-gradient(135deg, #EBD9A6 0%, #C79A3E 28%, #F2E4B9 46%, #A97C2A 62%, #E8D19B 82%, #C79A3E 100%);
  --foil-text: linear-gradient(100deg, #A97C2A 0%, #D9B65C 35%, #F4E7BE 50%, #C79A3E 68%, #8C6420 100%);

  /* Type */
  --font-body:    'Vazirmatn', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Amiri', 'Vazirmatn', Georgia, serif;
  --font-latin:   'Cormorant Garamond', Georgia, serif;
  --font-latin-ui:'Vazirmatn', system-ui, sans-serif;

  /* Spacing scale (density 4/10 — standard, slightly airy) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;
  --space-10:128px;

  /* Radius */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-xl: 32px;
  --r-pill: 999px;

  /* Elevation */
  --e-1: 0 1px 2px rgba(20,17,13,.05), 0 1px 3px rgba(20,17,13,.04);
  --e-2: 0 4px 10px rgba(20,17,13,.06), 0 2px 4px rgba(20,17,13,.04);
  --e-3: 0 14px 34px rgba(20,17,13,.10), 0 4px 10px rgba(20,17,13,.05);
  --e-4: 0 30px 70px rgba(20,17,13,.16), 0 10px 24px rgba(20,17,13,.07);

  /* Motion */
  --dur-1: 150ms;
  --dur-2: 240ms;
  --dur-3: 380ms;
  --dur-4: 620ms;
  --ease:      cubic-bezier(.22,.61,.36,1);
  --ease-out:  cubic-bezier(.16,1,.3,1);
  --ease-in:   cubic-bezier(.55,.06,.68,.19);
  --spring:    cubic-bezier(.34,1.56,.64,1);

  /* Layers */
  --z-base: 0;
  --z-deco: 1;
  --z-content: 10;
  --z-sticky: 40;
  --z-nav: 60;
  --z-overlay: 90;
  --z-modal: 100;
  --z-toast: 120;

  --container: 1240px;
  --nav-h: 76px;
}

/* ---------- Dark theme ---------- */
[data-theme="dark"] {
  --bg:          var(--night);
  --surface:     var(--night-2);
  --surface-alt: var(--night-3);
  --fg:          #F3EDE2;
  --fg-muted:    #A9A093;
  --border:      #2E2820;
  --border-soft: #241F19;
  --paper-2:     #17140F;
  --paper-3:     #241F18;
  --ink:         #F3EDE2;
  --ink-2:       #D9D0C2;
  --ink-3:       #A9A093;
  --ink-4:       #776F63;
  --e-1: 0 1px 2px rgba(0,0,0,.5);
  --e-2: 0 4px 12px rgba(0,0,0,.45);
  --e-3: 0 16px 38px rgba(0,0,0,.5);
  --e-4: 0 30px 70px rgba(0,0,0,.6);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.75;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100dvh;
  transition: background-color var(--dur-3) var(--ease), color var(--dur-3) var(--ease);
}

img, svg, video, canvas { display: block; max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
table { border-collapse: collapse; }
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}
::selection { background: var(--gold); color: #fff; }

/* Scrollbar */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--surface-alt); }
::-webkit-scrollbar-thumb {
  background: var(--ink-4);
  border-radius: var(--r-pill);
  border: 3px solid var(--surface-alt);
}
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: -0.01em;
  color: var(--fg);
}
:lang(en) h1, :lang(en) h2, :lang(en) h3,
.lat, .en h1, .en h2, .en h3 { font-family: var(--font-latin); }

h1 { font-size: clamp(2.4rem, 6.4vw, 4.6rem); line-height: 1.14; }
h2 { font-size: clamp(1.9rem, 4vw, 3.1rem); line-height: 1.2; }
h3 { font-size: clamp(1.35rem, 2.2vw, 1.85rem); }
h4 { font-size: 1.2rem; font-family: var(--font-body); font-weight: 700; }
h5 { font-size: 1rem;  font-family: var(--font-body); font-weight: 600; }

p { max-width: 68ch; }
strong { font-weight: 700; }

.display {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.015em;
}
.serif-lat { font-family: var(--font-latin); }

.lead {
  font-size: clamp(1.02rem, 1.4vw, 1.16rem);
  color: var(--fg-muted);
  line-height: 1.95;
  max-width: 60ch;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .18em;
  color: var(--gold-deep);
  text-transform: uppercase;
  font-family: var(--font-body);
}
.eyebrow::before {
  content: '';
  width: 28px; height: 1px;
  background: var(--gold);
  flex: none;
}
[data-theme="dark"] .eyebrow { color: var(--gold-soft); }

.foil-text {
  background: var(--foil-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.muted { color: var(--fg-muted); }
.small { font-size: .875rem; }
.tabular { font-variant-numeric: tabular-nums; }

/* Persian numerals helper */
.fa-num { font-feature-settings: 'ss01'; }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--space-5);
}
.container-narrow { max-width: 860px; }
.container-wide   { max-width: 1440px; }

.section { padding-block: clamp(56px, 9vw, 118px); position: relative; }
.section-sm { padding-block: clamp(40px, 6vw, 72px); }

.grid { display: grid; gap: var(--space-5); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.flex { display: flex; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-baseline { align-items: baseline; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }
.wrap { flex-wrap: wrap; }
.center { text-align: center; }
.mx-auto { margin-inline: auto; }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mt-7 { margin-top: var(--space-7); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.relative { position: relative; }
.hidden { display: none !important; }

/* Section header */
.sec-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-5);
  margin-bottom: var(--space-7);
  flex-wrap: wrap;
}
.sec-head .t { max-width: 62ch; }
.sec-head h2 { margin-top: var(--space-3); }
.sec-head p { margin-top: var(--space-3); }

/* ---------- Decorative ---------- */
.grain::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  opacity: .32;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
}
[data-theme="dark"] .grain::after { mix-blend-mode: screen; opacity: .18; }

.blob {
  position: absolute;
  border-radius: 50%;
  z-index: var(--z-deco);
  pointer-events: none;
}
.blob-ink {
  background: var(--night);
  border-radius: 48% 52% 56% 44% / 50% 46% 54% 50%;
}
.blob-sage { background: var(--sage); opacity: .75; }
.blob-gold {
  background: var(--foil);
  box-shadow: inset 0 -8px 24px rgba(140,100,32,.5), 0 12px 32px rgba(199,154,62,.28);
}
.blob-gold::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23g)' opacity='.5'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  opacity: .55;
}

.rule {
  height: 1px;
  background: linear-gradient(to left, transparent, var(--border), transparent);
  border: 0;
}

.ornament {
  display: block;
  width: 116px;
  margin-inline: auto;
  color: var(--gold);
  opacity: .85;
}

/* ---------- Motion ---------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(22px);
  transition:
    opacity var(--dur-4) var(--ease-out),
    transform var(--dur-4) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}
[data-reveal].is-in { opacity: 1; transform: none; }
[data-reveal="fade"] { transform: none; }
[data-reveal="right"] { transform: translateX(28px); }
[data-reveal="left"]  { transform: translateX(-28px); }
[data-reveal="zoom"]  { transform: scale(.94); }

@keyframes float-y {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-14px); }
}
@keyframes spin-slow { to { transform: rotate(360deg); } }
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(199,154,62,.45); }
  70%  { box-shadow: 0 0 0 16px rgba(199,154,62,0); }
  100% { box-shadow: 0 0 0 0 rgba(199,154,62,0); }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.float { animation: float-y 7s var(--ease) infinite; }
.float-slow { animation: float-y 11s var(--ease) infinite; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  [data-reveal] { opacity: 1 !important; transform: none !important; }
}

/* ---------- A11y ---------- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  inset-inline-start: var(--space-4);
  top: -100px;
  z-index: var(--z-toast);
  background: var(--ink);
  color: var(--paper);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--r-pill);
  font-weight: 600;
  transition: top var(--dur-2) var(--ease);
}
.skip-link:focus { top: var(--space-4); }

/* ---------- Responsive base ---------- */
@media (max-width: 1024px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  :root { --nav-h: 64px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .container { padding-inline: var(--space-4); }
  .sec-head { margin-bottom: var(--space-6); }
}
