/* ==========================================================================
   global.css — REDF Annual Report 2025
   Tokens, reset, type system, layout primitives, navbar, footer.
   ========================================================================== */

/* ------ Tokens (from DESIGN.md "Visionary Trust") ------------------------- */
:root {
  /* Brand */
  --c-primary:            #008375;
  --c-primary-dark:       #00685c;
  --c-primary-fixed:      #91f4e3;
  --c-primary-fixed-dim:  #74d7c7;
  --c-primary-container:  #008375;
  --c-on-primary:         #ffffff;

  --c-secondary-container:#bce9e1;
  --c-tertiary-container: #d4e6e3;
  --c-divider-teal:       #86bdb7;

  /* Neutrals */
  --c-bg:                 #f6faf8;
  --c-surface:            #ffffff;
  --c-surface-low:        #f0f5f2;
  --c-surface-high:       #e5e9e7;
  --c-on-surface:         #181d1b;
  --c-on-surface-variant: #3e4946;
  --c-outline:            #6e7a76;
  --c-outline-variant:    #bdc9c5;
  --c-inverse-surface:    #2c3130;
  --c-inverse-on-surface: #edf2ef;

  /* Functional / status */
  --c-on-track:        #3aa776;
  --c-behind:          #e89f3a;
  --c-significantly:   #d8453d;
  --c-completed:       #39a3c9;
  --c-error:           #ba1a1a;

  /* Typography */
  --ff-sans: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
             Roboto, "Helvetica Neue", Arial, sans-serif;

  --fs-xs:     0.75rem;   /* 12 */
  --fs-sm:     0.875rem;  /* 14 */
  --fs-base:   1rem;      /* 16 */
  --fs-lg:     1.125rem;  /* 18 */
  --fs-xl:     1.375rem;  /* 22 */
  --fs-2xl:    1.75rem;   /* 28 */
  --fs-3xl:    2.5rem;    /* 40 */
  --fs-4xl:    3.5rem;    /* 56 */
  --fs-5xl:    5rem;      /* 80 */
  --fs-display:7rem;      /* 112 — chapter numerals */

  --lh-tight:  1.1;
  --lh-snug:   1.25;
  --lh-base:   1.55;
  --lh-loose:  1.7;

  --fw-regular: 400;
  --fw-medium:  500;
  --fw-semi:    600;
  --fw-bold:    700;
  --fw-display: 800;

  /* Spacing — 8px scale */
  --s-1:  4px;
  --s-2:  8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  24px;
  --s-6:  32px;
  --s-7:  48px;
  --s-8:  64px;
  --s-9:  96px;
  --s-10: 128px;

  /* Layout */
  --container-max: 1280px;
  --container-pad: clamp(20px, 4vw, 48px);
  --header-h:      72px;

  /* Sharp corners only — DESIGN.md rule */
  --radius:        0;
  --radius-pill:   9999px;   /* status dots only */

  /* Motion */
  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
  --ease-inout: cubic-bezier(0.83, 0, 0.17, 1);
  --d-fast:     180ms;
  --d-base:     320ms;
  --d-slow:     560ms;
}

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

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

body {
  font-family: var(--ff-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--c-on-surface);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg, video { display: block; max-width: 100%; height: auto; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

a { color: var(--c-primary); text-decoration: none; transition: color var(--d-fast) var(--ease-out); }
a:hover { color: var(--c-primary-dark); }

ul, ol { list-style: none; }

table { border-collapse: collapse; width: 100%; }

input, textarea, select { font: inherit; color: inherit; }

::selection { background: var(--c-primary); color: var(--c-on-primary); }

/* Skip link for keyboard users */
.skip-link {
  position: absolute;
  inset-inline-start: var(--s-4);
  top: -100px;
  padding: var(--s-3) var(--s-4);
  background: var(--c-primary);
  color: var(--c-on-primary);
  z-index: 1000;
  font-weight: var(--fw-semi);
}
.skip-link:focus { top: var(--s-4); }

/* ------ Type system ------------------------------------------------------- */
.eyebrow {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-primary);
}

.h-display {
  font-size: clamp(2.5rem, 1.6rem + 4.5vw, var(--fs-5xl));
  line-height: var(--lh-tight);
  font-weight: var(--fw-display);
  letter-spacing: -0.02em;
  color: var(--c-on-surface);
}

.h-1 { font-size: clamp(2rem, 1.4rem + 2.4vw, var(--fs-3xl)); line-height: var(--lh-snug); font-weight: var(--fw-bold); letter-spacing: -0.01em; }
.h-2 { font-size: var(--fs-2xl); line-height: var(--lh-snug); font-weight: var(--fw-bold); }
.h-3 { font-size: var(--fs-xl); line-height: var(--lh-snug); font-weight: var(--fw-semi); }

.lead { font-size: var(--fs-lg); line-height: var(--lh-loose); color: var(--c-on-surface-variant); }

.muted { color: var(--c-on-surface-variant); }

/* Chapter indicator — signature wayfinding from DESIGN.md */
.chapter-indicator {
  display: inline-flex;
  align-items: baseline;
  gap: var(--s-3);
  color: var(--c-primary);
  font-weight: var(--fw-bold);
}
.chapter-indicator .ci-num {
  font-size: clamp(3rem, 2rem + 4vw, var(--fs-5xl));
  font-weight: var(--fw-display);
  letter-spacing: -0.04em;
}
.chapter-indicator .ci-divider { color: var(--c-divider-teal); font-weight: var(--fw-medium); }
.chapter-indicator .ci-title { font-size: var(--fs-2xl); font-weight: var(--fw-semi); color: var(--c-primary-dark); }

/* ------ Layout primitives ------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

.section {
  padding-block: clamp(56px, 8vw, 128px);
}

.section--tight { padding-block: clamp(40px, 6vw, 96px); }

@media (max-width: 520px) {
  .section { padding-block: clamp(48px, 12vw, 72px); }
  .section--tight { padding-block: clamp(32px, 9vw, 56px); }
  .section-header { margin-bottom: var(--s-5); }
}

.section-header {
  max-width: 720px;
  margin-bottom: var(--s-7);
}
.section-header > .eyebrow { margin-bottom: var(--s-3); }
.section-header > .h-1     { margin-bottom: var(--s-4); }

.grid { display: grid; gap: var(--s-5); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 960px) { .grid--3, .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; } }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: var(--s-2); }
.gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); }
.gap-6 { gap: var(--s-6); }

/* ------ Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-width: 160px;
  padding: 14px 24px;
  border-radius: var(--radius);
  font-size: var(--fs-base);
  font-weight: var(--fw-semi);
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--d-fast) var(--ease-out),
              color      var(--d-fast) var(--ease-out),
              border     var(--d-fast) var(--ease-out),
              transform  var(--d-fast) var(--ease-out),
              box-shadow var(--d-fast) var(--ease-out);
}
.btn:focus-visible { outline: 2px solid var(--c-primary-dark); outline-offset: 2px; }

.btn--primary {
  background: var(--c-primary);
  color: var(--c-on-primary);
  border: 1.5px solid var(--c-primary);
}
.btn--primary:hover {
  background: var(--c-primary-dark);
  border-color: var(--c-primary-dark);
  color: var(--c-on-primary);
  box-shadow: 0 8px 24px rgba(0, 131, 117, 0.18);
}
.btn--primary:active { transform: translateY(1px); box-shadow: none; }

.btn--secondary {
  background: transparent;
  color: var(--c-primary);
  border: 1.5px solid var(--c-primary);
}
.btn--secondary:hover {
  background: var(--c-primary);
  color: var(--c-on-primary);
}

.btn--ghost {
  background: transparent;
  color: var(--c-on-surface);
  border: 1.5px solid var(--c-outline-variant);
}
.btn--ghost:hover { border-color: var(--c-primary); color: var(--c-primary); }

.btn--inverse {
  background: var(--c-on-primary);
  color: var(--c-primary);
  border: 1.5px solid var(--c-on-primary);
}
.btn--inverse:hover { background: transparent; color: var(--c-on-primary); }

.btn--lg { padding: 18px 32px; font-size: var(--fs-lg); }
.btn--sm { padding: 10px 18px; min-width: auto; font-size: var(--fs-sm); }

/* On narrow viewports, drop button min-width so stacked groups don't
   feel oversized; let the parent flex track decide width. */
@media (max-width: 520px) {
  .btn { min-width: 0; padding: 13px 20px; }
  .btn--lg { padding: 15px 24px; font-size: var(--fs-base); }
  /* When two btns are in a flex row, let them grow side-by-side; when
     they wrap to a column they'll fill the row naturally. */
  .hero__actions .btn,
  .cta-strip__actions .btn { flex: 1 1 auto; }
}

/* ------ Saudi Riyal glyph (DESIGN.md currency rule) ---------------------- */
.riyal {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  vertical-align: baseline;
  margin-inline-end: 0.25em;
  fill: currentColor;
  transform: translateY(0.04em);
}
.h-display .riyal,
.stat__value .riyal { width: 0.95em; height: 0.95em; }

/* ------ Status dot (only round shape in the system) --------------------- */
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--c-on-track);
}
.dot--behind        { background: var(--c-behind); }
.dot--significantly { background: var(--c-significantly); }
.dot--completed     { background: var(--c-completed); }

/* ------ Banner header (rectilinear, primary teal) ----------------------- */
.banner {
  background: var(--c-primary);
  color: var(--c-on-primary);
  padding: var(--s-5) var(--s-6);
  font-weight: var(--fw-semi);
  font-size: var(--fs-lg);
}

/* ------ Site header / navbar -------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(246, 250, 248, 0.85);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid transparent;
  transition: background var(--d-fast) var(--ease-out),
              border-color var(--d-fast) var(--ease-out),
              box-shadow var(--d-fast) var(--ease-out);
}
.site-header.is-scrolled {
  background: var(--c-surface);
  border-bottom-color: var(--c-outline-variant);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  gap: var(--s-5);
}

.nav__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--c-on-surface);
  font-weight: var(--fw-bold);
  font-size: var(--fs-base);
  letter-spacing: 0.02em;
}
.nav__brand img { height: 32px; width: auto; }
.nav__brand span { line-height: 1.1; }
.nav__brand small { display: block; font-size: 11px; font-weight: var(--fw-regular); color: var(--c-on-surface-variant); letter-spacing: 0.06em; }

.nav__list {
  display: flex;
  align-items: center;
  gap: var(--s-6);
}
.nav__link {
  position: relative;
  color: var(--c-on-surface);
  font-weight: var(--fw-medium);
  font-size: var(--fs-sm);
  padding-block: var(--s-2);
}
.nav__link::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  bottom: -2px;
  width: 0;
  height: 2px;
  background: var(--c-primary);
  transition: width var(--d-base) var(--ease-out);
}
.nav__link:hover { color: var(--c-primary); }
.nav__link:hover::after,
.nav__link[aria-current="page"]::after { width: 100%; }
.nav__link[aria-current="page"] { color: var(--c-primary); }

.nav__cta { display: flex; gap: var(--s-3); align-items: center; }

.nav__lang {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  letter-spacing: 0.08em;
  color: var(--c-on-surface-variant);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--c-outline-variant);
}
.nav__lang:hover { color: var(--c-primary); border-color: var(--c-primary); }

/* The legacy hamburger toggle is removed by main.js (initStaggeredMenu)
   in favor of the staggered overlay menu, so we don't render any drawer here. */

@media (max-width: 880px) {
  /* Inline links collapse — staggered overlay carries navigation. */
  .nav__list { display: none; }
  /* Keep only the menu trigger visible in the CTA cluster. */
  .nav__cta .nav__lang,
  .nav__cta .btn { display: none; }
  .nav__cta { gap: 0; }
}

@media (max-width: 420px) {
  .nav__brand small { display: none; }
  .nav__brand img { height: 28px; }
  .nav { gap: var(--s-3); }
}

/* ------ Reveal on scroll utility ---------------------------------------- */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity var(--d-slow) var(--ease-out),
              transform var(--d-slow) var(--ease-out);
  will-change: opacity, transform;
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* GSAP utility classes (ANIMATIONS.md §2). Initial state mirrors .reveal so
   the page never paints with content visibly missing if the script fails. */
.anim-fadeinup { opacity: 0; transform: translateY(60px); will-change: opacity, transform; }
.anim-zoomin   { opacity: 0; transform: scale(1.12); will-change: opacity, transform; }

/* When GSAP boots it sets html.is-anim-ready and assumes ownership of these.
   Until then keep the CSS-based reveal as a graceful fallback. */
html.is-anim-ready .reveal,
html.is-anim-ready .anim-fadeinup,
html.is-anim-ready .anim-zoomin {
  transition: none;
}

/* ------ Page-enter curtain ---------------------------------------------- */
.page-curtain {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--c-primary);
  transform-origin: top center;
  pointer-events: none;
}
html.is-anim-ready .page-curtain { will-change: transform; }
.page-curtain.is-done { display: none; }

/* ------ Lenis smooth-scroll plumbing ------------------------------------ */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }
.lenis.lenis-scrolling iframe { pointer-events: none; }

/* Image scrub-parallax wrapper -------------------------------------------- */
.parallax {
  overflow: hidden;
  position: relative;
}
.parallax > img,
.parallax > picture > img {
  width: 100%;
  height: 115%;
  object-fit: cover;
  will-change: transform;
}

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

/* ------ Footer ---------------------------------------------------------- */
.site-footer {
  background: var(--c-primary);
  color: var(--c-on-primary);
  padding-block: var(--s-9) var(--s-6);
  margin-top: var(--s-10);
}
.site-footer a { color: var(--c-on-primary); }
.site-footer a:hover { color: var(--c-primary-fixed); }

/* Header row — wordmark + tagline + eyebrow */
.footer__head {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: var(--s-7);
  align-items: end;
  margin-bottom: var(--s-7);
}
@media (max-width: 720px) { .footer__head { grid-template-columns: 1fr; } }

.footer__brand { display: flex; flex-direction: column; gap: var(--s-3); max-width: 460px; }
.footer__brand strong { font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: -0.01em; }
.footer__brand p { font-size: var(--fs-sm); line-height: var(--lh-loose); opacity: 0.85; }

.footer__eyebrow {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.7;
  text-align: end;
}

/* Report index — divider list */
.footer__index {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
}
.footer__index li { border-bottom: 1px solid rgba(255, 255, 255, 0.22); }
.footer__index a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding-block: var(--s-4);
  padding-inline: 0;
  font-size: var(--fs-lg);
  font-weight: var(--fw-semi);
  letter-spacing: -0.005em;
  color: var(--c-on-primary);
  line-height: var(--lh-snug);
  transition: padding-inline var(--d-fast) var(--ease-out),
              background var(--d-fast) var(--ease-out),
              color var(--d-fast) var(--ease-out);
}
.footer__index a > span:first-child {
  min-width: 0;
  flex: 1 1 auto;
}
.footer__index a:hover {
  padding-inline: var(--s-4);
  background: rgba(255, 255, 255, 0.05);
  color: var(--c-on-primary);
}
.footer__index .pdf-tag {
  font-size: var(--fs-sm);
  font-weight: var(--fw-regular);
  letter-spacing: 0.04em;
  opacity: 0.7;
  margin-inline-start: var(--s-2);
}
.footer__index .icon-arrow {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.55;
  transition: opacity var(--d-fast) var(--ease-out), transform var(--d-fast) var(--ease-out);
}
.footer__index a:hover .icon-arrow { opacity: 1; transform: translateX(4px); }
[dir="rtl"] .footer__index a:hover .icon-arrow { transform: translateX(-4px); }
[dir="rtl"] .footer__index .icon-arrow { transform: scaleX(-1); }
[dir="rtl"] .footer__index a:hover .icon-arrow { transform: scaleX(-1) translateX(4px); }

@media (max-width: 720px) {
  .footer__index a { font-size: var(--fs-base); padding-block: var(--s-3); }
}

/* Bottom — copyright + social */
.footer__bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-4);
  margin-top: var(--s-7);
  padding-top: var(--s-5);
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  opacity: 0.9;
}
.footer__social { display: flex; gap: var(--s-3); }
.footer__social a {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: background var(--d-fast) var(--ease-out), border-color var(--d-fast) var(--ease-out);
}
.footer__social a:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--c-on-primary); }
.footer__social svg { width: 16px; height: 16px; fill: currentColor; }
