/* =====================================================================
   Bidaya Foundation — style.css
   tokens -> base -> utilities -> header -> hero -> story -> programmes
   -> gallery -> involve -> footer -> sticky bar -> reveal -> media queries
   Fonts are loaded via <link rel="preconnect"> + <link> in index.html.
   ===================================================================== */

/* ---------- :root tokens ---------- */
:root {
  /* Core — dark green & white per brief */
  --forest:        #033F23;
  --forest-deep:   #022917;
  --forest-soft:   #0E5A34;
  --white:         #FFFFFF;

  /* Ground */
  --cream:         #F6EFE0;
  --cream-deep:    #EDE2CC;
  --ink:           #17140F;
  --ink-soft:      #4B453A;

  /* Textile accents — seams and small marks only */
  --ochre:         #E0A32E;
  --henna:         #A33B26;
  --indigo:        #1F3A5F;

  /* Utility */
  --focus:         #E0A32E;
  --shadow:        0 2px 24px rgba(3, 63, 35, 0.10);

  /* Fonts */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body:    "Karla", -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-arabic:  "IBM Plex Sans Arabic", "Noto Sans Arabic", sans-serif;

  /* Type scale (fluid) */
  --step--1: clamp(0.875rem, 0.85rem + 0.15vw, 0.95rem);
  --step-0:  clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  --step-1:  clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);
  --step-2:  clamp(1.6rem, 1.4rem + 1vw, 2.25rem);
  --step-3:  clamp(2.25rem, 1.8rem + 2.2vw, 3.5rem);
  --step-4:  clamp(2.75rem, 2rem + 4.5vw, 5.5rem);

  /* Layout */
  --container: 1180px;
  --pad-x: clamp(20px, 5vw, 64px);
  --section-y: clamp(72px, 10vw, 140px);
  --header-h: 72px;
}

/* ---------- base ---------- */
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.65;
  color: var(--ink);
  background: var(--cream);
  overflow-x: hidden; /* guard; layout should not need it */
}

h1, h2, h3 { font-family: var(--font-display); line-height: 1.05; font-weight: 600; }
h2 { font-size: var(--step-2); color: var(--forest); }

p { max-width: 62ch; }

a { text-decoration: none; }

/* Growing underline on text links (not buttons / cards) */
.link-underline {
  background-image: linear-gradient(var(--forest-soft), var(--forest-soft));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1.5px;
  transition: background-size 180ms ease;
}
.link-underline:hover,
.link-underline:focus-visible { background-size: 100% 1.5px; }

/* Focus */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  z-index: 100;
  background: var(--white);
  color: var(--forest);
  padding: 10px 16px;
  border-radius: 4px;
  font-weight: 700;
  transition: top 160ms ease;
}
.skip-link:focus { top: 12px; }

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

/* ---------- utilities ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--pad-x);
}
.section { padding-block: var(--section-y); }
.section--tight { padding-block: clamp(48px, 6vw, 84px); }

.eyebrow {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--step--1);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--forest-soft);
  margin-bottom: 0.9rem;
  display: block;
}
.on-forest .eyebrow { color: var(--ochre); }

/* Woven seam — used exactly four times; threads drift slowly like a live weave */
.seam {
  height: 6px;
  border: 0;
  margin: 0;
  background:
    repeating-linear-gradient(90deg,
      var(--forest-soft) 0 18px,
      var(--white)       18px 35px,
      var(--henna)       35px 52px);
  background-size: 52px 6px;
  animation: seam-weave 9s linear infinite;
}
@keyframes seam-weave { to { background-position: 52px 0; } }
@keyframes seam-weave-sm { to { background-position: 39px 0; } }

/* Sudanese / Nubian textile motifs — subtle concentric lozenges that drift */
.motifs {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.motif {
  position: absolute;
  width: var(--s, 40px);
  height: var(--s, 40px);
  border: 1.5px solid currentColor;
  opacity: 0.09;
  transform: rotate(45deg);
  animation: motif-float var(--t, 20s) ease-in-out var(--d, 0s) infinite;
}
.motif::before {
  content: "";
  position: absolute;
  inset: 22%;
  border: 1.5px solid currentColor;
}
.motif--ochre  { color: var(--ochre); }
.motif--henna  { color: var(--henna); }
.motif--indigo { color: var(--indigo); opacity: 0.13; }
.motif--cream  { color: var(--cream); opacity: 0.08; }
@keyframes motif-float {
  0%, 100% { transform: rotate(45deg) translate(0, 0); }
  50%      { transform: rotate(45deg) translate(0, -16px); }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 24px;
  border-radius: 4px;
  font-weight: 700;
  font-size: var(--step-0);
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}
.btn--primary { background: var(--ochre); color: var(--forest-deep); }
.btn--primary:hover { background: #cf9422; }
.btn--primary:focus-visible { outline-color: var(--forest-deep); }
.btn--ghost { border: 1px solid var(--white); color: var(--white); }
.btn--ghost:hover { background: var(--white); color: var(--forest); }

/* ---------- header ---------- */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background-color 220ms ease, border-color 220ms ease;
}
.site-header.is-scrolled {
  background: var(--forest);
  border-bottom-color: var(--forest-soft);
}
.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--header-h);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--white); }
.brand__mark { width: 40px; height: 40px; color: var(--white); }
.brand__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}
.header__nav { display: flex; align-items: center; gap: 28px; }
.header__nav a { color: var(--white); font-weight: 500; }
.header__nav .btn--primary { color: var(--forest-deep); }

/* ---------- hero ---------- */
.hero { position: relative; background: var(--forest); color: var(--white); overflow: hidden; }
.hero__inner {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 44%);
  gap: 48px;
  align-items: center;
  min-height: min(88vh, 780px);
  padding-block: clamp(96px, 12vw, 150px) var(--section-y);
}
.hero__content { max-width: 620px; }
.hero__sprout { width: 90px; height: 90px; color: var(--white); margin-bottom: 24px; }
.hero h1 {
  font-size: var(--step-4);
  color: var(--white);
  max-width: 18ch;
  letter-spacing: -0.02em;
  font-variation-settings: "SOFT" 60, "WONK" 1, "opsz" 144;
}
.hero__lead {
  color: var(--cream);
  font-size: var(--step-1);
  max-width: 48ch;
  margin-top: 20px;
}
.hero__actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 32px; }

.hero__media {
  position: absolute;
  inset: 0 0 0 auto;
  width: 46%;
  z-index: 1;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px clamp(20px, 4vw, 56px);
}
.hero__video {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border-radius: 6px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.38);
  background: var(--forest-deep);
}
.hero__video iframe { width: 100%; height: 100%; border: 0; display: block; }
/* seam flush to hero bottom */
.hero .seam { position: relative; z-index: 3; }

/* ---------- story ---------- */
.story__grid {
  display: grid;
  grid-template-columns: 8fr 4fr;
  gap: clamp(32px, 5vw, 72px);
  align-items: start;
}
.story__lead { font-size: var(--step-1); }
.story__body > * + * { margin-top: 1.1rem; }
.story__aside {
  font-family: var(--font-arabic);
  color: var(--ink-soft);
  font-size: var(--step-0);
  margin-top: 1rem;
}
.story__aside [lang="ar"] { font-weight: 600; }

.framed { position: relative; }
.framed::before {
  content: "";
  position: absolute;
  inset: 12px -12px -12px 12px;
  background: var(--cream-deep);
  z-index: 0;
}
.framed img { position: relative; z-index: 1; width: 100%; }
.figure-caption { color: var(--ink-soft); font-size: var(--step--1); margin-top: 20px; }

.pullout {
  margin-top: clamp(48px, 6vw, 80px);
  padding-top: clamp(28px, 4vw, 40px);
  border-top: 1px solid rgba(14, 90, 52, 0.35);
}
.pullout p {
  font-family: var(--font-display);
  font-size: var(--step-2);
  color: var(--forest);
  max-width: 30ch;
  line-height: 1.2;
}

/* ---------- programmes (what we fund) ---------- */
.fund { background: var(--cream-deep); }
.fund__head { max-width: 46ch; margin-bottom: clamp(36px, 5vw, 56px); }
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
.card {
  background: var(--cream);
  border: 1px solid rgba(14, 90, 52, 0.20);
  border-radius: 4px;
  padding: 32px;
}
.card__icon { width: 40px; height: 40px; color: var(--forest); margin-bottom: 20px; }
.card h3 { font-family: var(--font-display); font-size: var(--step-2); color: var(--forest); }
.card__desc { margin-top: 10px; color: var(--ink); }
.card ul { list-style: none; padding: 0; margin-top: 18px; display: grid; gap: 10px; }
.card li { position: relative; padding-left: 20px; }
.card li::before {
  content: "";
  position: absolute; left: 0; top: 0.62em;
  width: 5px; height: 5px;
  background: var(--ochre);
}

/* ---------- gallery (in the field) ---------- */
.field { background: var(--forest); color: var(--white); position: relative; overflow: hidden; }
.field > .container { position: relative; z-index: 1; }
.field h2 { color: var(--white); }
.field__intro { color: var(--cream); max-width: 52ch; margin-top: 12px; }
.mosaic {
  margin-top: clamp(36px, 5vw, 56px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  align-items: start;
}
.mosaic figure { margin: 0; }
.mosaic .shot { overflow: hidden; }
.mosaic .shot img {
  width: 100%; height: 100%; object-fit: cover;
  aspect-ratio: 3 / 4;
  transition: transform 600ms cubic-bezier(.2,.7,.3,1);
}
.mosaic .shot:hover img { transform: scale(1.03); }
.mosaic figcaption { color: rgba(246, 239, 224, 0.8); font-size: var(--step--1); margin-top: 12px; }
.mosaic .m-tall { margin-top: 40px; }
.mosaic .m-wide { grid-column: 1 / -1; margin-top: 8px; }
.mosaic .m-wide .shot img { aspect-ratio: 1280 / 591; }

/* ---------- involve (get involved) ---------- */
.involve__grid {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: clamp(32px, 5vw, 64px);
  align-items: start;
}
.qr-card {
  background: var(--white);
  border-radius: 4px;
  padding: 40px;
  box-shadow: var(--shadow);
  text-align: center;
}
.qr-card h3 { font-family: var(--font-display); font-size: var(--step-2); color: var(--forest); }
.qr-card .qr-img {
  width: 240px; height: 240px;
  margin: 24px auto 20px;
  background: var(--white);
}
.qr-card p { max-width: none; }
.qr-card .qr-note { color: var(--ink-soft); }
.qr-card .qr-link { display: inline-block; margin-top: 14px; font-weight: 700; color: var(--forest-soft); }

.action-rows { display: grid; }
.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  padding-block: clamp(22px, 3vw, 30px);
  border-top: 1px solid rgba(14, 90, 52, 0.28);
}
.action-row:first-child { border-top: 0; padding-top: 0; }
.action-row__text { max-width: 46ch; }
.action-row__text strong { font-family: var(--font-display); font-weight: 600; font-size: var(--step-1); color: var(--forest); display: block; margin-bottom: 4px; }
.action-row__cta { display: inline-flex; align-items: center; gap: 8px; }
.action-row a.link-underline { color: var(--forest-soft); font-weight: 700; }
.ig-glyph, .wa-glyph { width: 20px; height: 20px; }

/* ---------- instagram strip (auto-scrolling marquee) ---------- */
.ig-strip { background: var(--cream-deep); overflow: hidden; }
.ig-strip__head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 12px 24px; margin-bottom: clamp(24px, 3vw, 40px);
}
.ig-strip__title { max-width: 20ch; }
.ig-strip__cta { display: inline-flex; align-items: center; gap: 8px; color: var(--forest-soft); font-weight: 700; }

.marquee {
  position: relative;
  overflow-x: auto;              /* no-JS: a plain scrollable row */
}
.marquee.is-looping { overflow: hidden; }
.marquee__track {
  display: flex;
  width: max-content;
}
.marquee.is-looping .marquee__track {
  animation: marquee var(--marquee-duration, 60s) linear infinite;
}
.marquee:hover .marquee__track,
.marquee:focus-within .marquee__track { animation-play-state: paused; }
/* main.js builds the track as two identical halves, so -50% loops seamlessly */
@keyframes marquee { to { transform: translateX(-50%); } }

/* Card widths are a fraction of the viewport, so whole cards span the page edge to edge */
.ig-card { flex: 0 0 auto; width: calc(100vw / 2.2 - 16px); margin-right: 16px; }
@media (min-width: 700px)  { .ig-card { width: calc(100vw / 3.5 - 16px); } }
@media (min-width: 1100px) { .ig-card { width: calc(100vw / 5 - 16px); } }
@media (min-width: 1600px) { .ig-card { width: calc(100vw / 6 - 16px); } }
.ig-card__link { display: block; color: var(--ink); }
.ig-card__media {
  display: block;
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 4px;
  background: var(--forest);
  box-shadow: var(--shadow);
}
.ig-card__media img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 600ms cubic-bezier(.2,.7,.3,1);
}
.ig-card__link:hover .ig-card__media img { transform: scale(1.04); }
.ig-card__glyph {
  position: absolute; top: 10px; right: 10px; width: 22px; height: 22px;
  color: #fff; opacity: .92; filter: drop-shadow(0 1px 2px rgba(0,0,0,.45));
}
.ig-card__meta { display: block; margin-top: 10px; font-size: var(--step--1); color: var(--ink-soft); }
@media (prefers-reduced-motion: reduce) {
  .marquee.is-looping { overflow-x: auto; }
  .marquee.is-looping .marquee__track { animation: none; }
}

/* ---------- footer ---------- */
.site-footer { background: var(--forest-deep); color: var(--cream); }
.footer__top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 20px;
  padding-bottom: 28px;
}
.footer__lockup { display: inline-flex; align-items: center; gap: 16px; }
.footer__lockup .brand__mark { width: 56px; height: 56px; }
.footer__rule { width: 1px; height: 44px; background: var(--forest-soft); }
.footer__arabic { font-family: var(--font-arabic); font-size: 1.9rem; color: var(--white); font-weight: 600; }
.footer__line { color: var(--cream); }
.footer__links { display: flex; flex-wrap: wrap; gap: 22px; padding-block: 24px; border-top: 1px solid var(--forest-soft); }
.footer__links a { color: var(--white); font-weight: 500; }
.footer__bottom {
  display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between;
  padding-top: 20px; border-top: 1px solid var(--forest-soft);
  color: rgba(246, 239, 224, 0.6); font-size: var(--step--1);
}

/* ---------- sticky donate bar (mobile) ---------- */
.sticky-bar {
  display: none;
  position: fixed;
  inset: auto 0 0 0;
  z-index: 40;
  background: var(--forest);
  border-top: 1px solid var(--forest-soft);
  padding: 12px var(--pad-x);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
}
.sticky-bar__inner { display: flex; gap: 12px; }
.sticky-bar .btn { flex: 1; }

/* ---------- reveal (progressive; visible without JS) ---------- */
html.reveal-ready .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 500ms cubic-bezier(.2,.7,.3,1),
              transform 500ms cubic-bezier(.2,.7,.3,1);
}
html.reveal-ready .reveal.is-visible { opacity: 1; transform: none; }

/* Sprout draw */
html.reveal-ready .hero__sprout path {
  stroke-dasharray: var(--len);
  stroke-dashoffset: var(--len);
}
.hero__sprout.is-drawn path {
  animation: draw 1.4s cubic-bezier(.6,.05,.3,1) forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

/* =====================================================================
   Media queries — one block per breakpoint
   ===================================================================== */

@media (max-width: 1179px) {
  .hero__media { width: 42%; }
}

@media (max-width: 1023px) {
  .story__grid { grid-template-columns: 1fr; }
  .framed { max-width: 460px; }
  .framed::before { inset: 10px -10px -10px 10px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .card:last-child { grid-column: 1 / -1; }
  .involve__grid { grid-template-columns: 1fr; }
}

@media (max-width: 759px) {
  :root { --header-h: 64px; }
  body { padding-bottom: 76px; } /* room for sticky bar */

  .header__nav a:not(.btn) { display: none; }

  .hero__inner {
    grid-template-columns: 1fr;
    min-height: 0;
    padding-block: 96px 0;
    gap: 28px;
  }
  .hero__media {
    position: relative;
    width: 100%;
    margin: 0;
    padding: 0 0 8px;
    height: auto;
  }
  .hero__video { max-width: 280px; }

  .seam { background-size: 39px 6px; animation-name: seam-weave-sm; } /* ~25% smaller pattern */

  .cards { grid-template-columns: 1fr; }
  .card:last-child { grid-column: auto; }

  /* gallery -> horizontal snap carousel */
  .mosaic {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  .mosaic::-webkit-scrollbar { display: none; }
  .mosaic figure { flex: 0 0 78%; scroll-snap-align: start; }
  .mosaic .m-tall { margin-top: 0; }
  .mosaic .m-wide { grid-column: auto; flex: 0 0 92%; }
  .mosaic .shot img { aspect-ratio: 3 / 4; }
  .mosaic .m-wide .shot img { aspect-ratio: 16 / 9; }

  .sticky-bar { display: block; }

}

@media (max-width: 379px) {
  .hero h1 { font-size: var(--step-3); }
  .hero__actions { flex-direction: column; align-items: stretch; }
  .hero__actions .btn { width: 100%; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  html.reveal-ready .hero__sprout path { stroke-dashoffset: 0; }
}
