/* ============================================================
   Khalil Al-Rahman Academy — base.css
   Tokens, reset, typography, themes (light/dark), RTL-ready
   ============================================================ */

:root {
  /* Palette — KAA navy & gold */
  --bg: #f4f6fa;
  --bg-2: #e9edf4;
  --bg-3: #dbe2ed;
  --surface: #ffffff;
  --ink: #17233c;
  --ink-2: #56627a;
  --ink-3: #8a93a6;
  --line: rgba(23, 35, 60, 0.14);
  --line-soft: rgba(23, 35, 60, 0.08);

  --terra: #1d3f78;
  --terra-deep: #14305d;
  --terra-tint: #d7e1f1;
  --green: #2c6e66;
  --green-deep: #1f4f49;
  --green-tint: #d4e6e3;
  --gold: #c39a36;
  --gold-tint: #f0e6c8;

  --hero-grad-a: #e9eff7;
  --hero-grad-b: #f4f6fa;

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(23, 35, 60, 0.07), 0 4px 14px rgba(23, 35, 60, 0.07);
  --shadow-2: 0 2px 6px rgba(23, 35, 60, 0.09), 0 16px 40px rgba(23, 35, 60, 0.13);
  --shadow-3: 0 8px 24px rgba(23, 35, 60, 0.15), 0 32px 80px rgba(23, 35, 60, 0.2);

  /* Radii */
  --r-s: 10px;
  --r-m: 18px;
  --r-l: 28px;
  --r-arch: 999px 999px 18px 18px;

  /* Type */
  --font-display: "Instrument Serif", "Amiri", serif;
  --font-body: "Public Sans", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --track-caps: 0.18em;

  /* Layout */
  --container: 1240px;
  --gutter: clamp(20px, 4vw, 48px);
  --sec-pad: clamp(72px, 9vw, 130px);
  --nav-h: 76px;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.44, 1);

  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0f1521;
  --bg-2: #161d2c;
  --bg-3: #1f2838;
  --surface: #161d2c;
  --ink: #e9eef7;
  --ink-2: #a3afc4;
  --ink-3: #74809a;
  --line: rgba(233, 238, 247, 0.16);
  --line-soft: rgba(233, 238, 247, 0.08);

  --terra: #6f9be0;
  --terra-deep: #8fb4ea;
  --terra-tint: #16243c;
  --green: #5fa79c;
  --green-deep: #82c3b8;
  --green-tint: #16302c;
  --gold: #d6b257;
  --gold-tint: #2f2710;

  --hero-grad-a: #141c2b;
  --hero-grad-b: #0f1521;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.35), 0 16px 40px rgba(0, 0, 0, 0.4);
  --shadow-3: 0 8px 24px rgba(0, 0, 0, 0.4), 0 32px 80px rgba(0, 0, 0, 0.5);

  color-scheme: dark;
}

/* Arabic typography swap */
html[lang="ar"] {
  --font-display: "Amiri", "Instrument Serif", serif;
  --font-body: "IBM Plex Sans Arabic", "Public Sans", system-ui, sans-serif;
  --track-caps: 0.02em;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background-color 0.45s ease, color 0.45s ease;
}

img, svg, canvas, video, iframe { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { padding: 0; list-style: none; }

::selection { background: var(--terra); color: #fff8f2; }

:focus-visible {
  outline: 2px solid var(--terra);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- Typography ---------- */
.display, .h1, .h2, .h3 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.06;
  text-wrap: balance;
  letter-spacing: -0.01em;
}
html[lang="ar"] .display,
html[lang="ar"] .h1,
html[lang="ar"] .h2,
html[lang="ar"] .h3 {
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0;
}

.display { font-size: clamp(3rem, 7.4vw, 6.2rem); }
.h1 { font-size: clamp(2.6rem, 5.4vw, 4.4rem); }
.h2 { font-size: clamp(2rem, 3.8vw, 3.1rem); }
.h3 { font-size: clamp(1.4rem, 2.2vw, 1.85rem); }

.display em, .h1 em, .h2 em {
  font-style: italic;
  color: var(--terra);
}
html[lang="ar"] .display em,
html[lang="ar"] .h1 em,
html[lang="ar"] .h2 em { font-style: normal; }

.lead {
  font-size: clamp(1.05rem, 1.5vw, 1.25rem);
  color: var(--ink-2);
  line-height: 1.7;
  text-wrap: pretty;
  max-width: 62ch;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: var(--terra);
}
.eyebrow::before {
  content: "";
  width: 26px;
  height: 2px;
  background: var(--terra);
  border-radius: 2px;
}

p { text-wrap: pretty; }

/* ---------- Layout ---------- */
.container {
  width: min(var(--container), 100% - var(--gutter) * 2);
  margin-inline: auto;
}

.section { padding-block: var(--sec-pad); }
.section-tint { background: var(--bg-2); }
.section-deep {
  background: var(--green-deep);
  color: #f0f5f0;
}
html[data-theme="dark"] .section-deep { background: #15211c; }

.sec-head {
  display: grid;
  gap: 16px;
  max-width: 760px;
  margin-bottom: clamp(40px, 5vw, 64px);
}
.sec-head.center { margin-inline: auto; text-align: center; justify-items: center; }

/* ---------- Reveal-on-scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
  transition-delay: var(--d, 0s);
}
.reveal.in { opacity: 1; transform: none; }

.reveal-scale {
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
  transition-delay: var(--d, 0s);
}
.reveal-scale.in { opacity: 1; transform: none; }

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

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 28px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  background: var(--terra);
  color: #fff8f2;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.35s var(--ease-spring), box-shadow 0.35s ease, background 0.3s ease;
}
.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px color-mix(in oklab, var(--terra) 40%, transparent);
  background: var(--terra-deep);
}
.btn:active { transform: translateY(0) scale(0.98); }

.btn .arr { transition: transform 0.3s var(--ease-out); display: inline-block; }
.btn:hover .arr { transform: translateX(4px); }
html[dir="rtl"] .btn .arr { transform: scaleX(-1); }
html[dir="rtl"] .btn:hover .arr { transform: scaleX(-1) translateX(4px); }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn-ghost:hover {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
  box-shadow: var(--shadow-1);
}

.btn-light {
  background: #fff8f2;
  color: #261f16;
}
.btn-light:hover { background: #fff; box-shadow: 0 10px 26px rgba(0,0,0,0.25); }

.btn-green { background: var(--green); }
.btn-green:hover { background: var(--green-deep); box-shadow: 0 10px 26px color-mix(in oklab, var(--green) 40%, transparent); }

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--terra);
  font-size: 0.95rem;
}
.link-arrow .arr { transition: transform 0.3s var(--ease-out); }
.link-arrow:hover .arr { transform: translateX(5px); }
html[dir="rtl"] .link-arrow .arr { transform: scaleX(-1); }
html[dir="rtl"] .link-arrow:hover .arr { transform: scaleX(-1) translateX(5px); }

/* ---------- Image placeholders (striped) ---------- */
.ph {
  position: relative;
  overflow: hidden;
  background:
    repeating-linear-gradient(45deg,
      color-mix(in oklab, var(--bg-3) 78%, transparent) 0 14px,
      transparent 14px 28px),
    linear-gradient(160deg, var(--bg-2), var(--bg-3));
  border: 1px solid var(--line-soft);
  min-height: 120px;
}
.ph::after {
  content: attr(data-label);
  position: absolute;
  inset-block-end: 12px;
  inset-inline-start: 14px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  background: color-mix(in oklab, var(--surface) 85%, transparent);
  border: 1px solid var(--line-soft);
  padding: 4px 10px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}
.ph-arch { border-radius: var(--r-arch); }
.ph-round { border-radius: var(--r-m); }
.ph-circle { border-radius: 50%; aspect-ratio: 1; }

/* Real photographs replace the striped placeholder */
.ph.has-img {
  background-image: none;
  background-size: cover !important;
  background-position: center;
  background-repeat: no-repeat;
  border-color: var(--line-soft);
}
.ph.has-img::after { display: none; }
.ph.no-cap::after { display: none; }

/* Tinted variants so grids feel alive */
.ph.t-terra { background:
  repeating-linear-gradient(45deg, color-mix(in oklab, var(--terra) 12%, transparent) 0 14px, transparent 14px 28px),
  linear-gradient(160deg, var(--terra-tint), var(--bg-2)); }
.ph.t-green { background:
  repeating-linear-gradient(45deg, color-mix(in oklab, var(--green) 12%, transparent) 0 14px, transparent 14px 28px),
  linear-gradient(160deg, var(--green-tint), var(--bg-2)); }
.ph.t-gold { background:
  repeating-linear-gradient(45deg, color-mix(in oklab, var(--gold) 14%, transparent) 0 14px, transparent 14px 28px),
  linear-gradient(160deg, var(--gold-tint), var(--bg-2)); }

/* ---------- Decorative arches ---------- */
.arch-deco {
  position: absolute;
  border: 1.5px solid var(--line);
  border-radius: 999px 999px 0 0;
  border-bottom: none;
  pointer-events: none;
}

/* ---------- Misc utilities ---------- */
.grid { display: grid; gap: clamp(18px, 2.4vw, 30px); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 980px) {
  .g3, .g4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.25s ease;
}
.chip:hover { border-color: var(--terra); color: var(--terra); }
.chip.on {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.num-display {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 4.6vw, 4rem);
  line-height: 1;
  color: var(--terra);
}
html[lang="ar"] .num-display { font-weight: 700; }

/* Scrollbar (subtle) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--ink-3); border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
