/* Al-Rahmah Foundation — site theme
   Palette taken from the foundation's own material:
   ink = night teal behind the logo, gold = the calligraphy, water = the filter tanks */
:root {
  --ink: #0f2a2e;
  --ink-2: #16383d;
  --gold: #c9a24d;
  --gold-soft: #e7d3a2;
  --water: #2f7fb8;
  --paper: #f4f6f3;
  --white: #ffffff;
  --text: #1c2b2d;
  --muted: #5b6b6c;
  --line: #d9e0dc;

  --f-sans: "Bricolage Grotesque", system-ui, sans-serif;
  --f-urdu: "Noto Nastaliq Urdu", serif;

  --wrap: 1180px;
  --r-lg: 22px;
  --r-sm: 10px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--f-sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 4px; }
.wrap { width: min(var(--wrap), 100% - 2.5rem); margin-inline: auto; }
.skip { position: absolute; left: -999px; top: 0; background: var(--gold); color: var(--ink); padding: .6rem 1rem; z-index: 99; }
.skip:focus { left: 1rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .55rem;
  font: 600 1rem/1 var(--f-sans);
  padding: .95rem 1.4rem; border-radius: 999px;
  text-decoration: none; border: 2px solid transparent;
  transition: background .2s, color .2s, border-color .2s, transform .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-gold:hover { background: var(--gold-soft); }
.btn-line { border-color: currentColor; color: inherit; }
.btn-line:hover { background: rgba(255,255,255,.08); }
.btn-ink { background: var(--ink); color: var(--white); }
.btn-ink:hover { background: var(--ink-2); }

/* ---------- Top bar + nav ---------- */
.topbar { background: var(--ink); color: #b9c8c6; font-size: .875rem; }
.topbar .wrap { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; flex-wrap: wrap; }
.topbar a { text-decoration: none; }
.topbar a:hover { color: var(--gold); }
.topbar .contact { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.topbar .social { display: flex; gap: 1rem; }
.topbar svg { width: 15px; height: 15px; vertical-align: -2px; margin-right: .35rem; fill: currentColor; }

.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(15, 42, 46, .96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(201, 162, 77, .25);
}
.nav .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding: .7rem 0; }
.brand { display: flex; align-items: center; gap: .8rem; text-decoration: none; color: var(--white); }
.brand img { width: 54px; height: 54px; border-radius: 50%; background: #000; }
.brand b { display: block; font-size: 1.15rem; letter-spacing: -.01em; line-height: 1.1; }
.brand small { display: block; color: var(--gold); font-size: .8rem; }
.menu { display: flex; align-items: center; gap: .3rem; list-style: none; margin: 0; padding: 0; }
.menu a { display: block; padding: .55rem .85rem; color: #dbe5e3; text-decoration: none; border-radius: 999px; font-weight: 500; }
.menu a:hover, .menu a[aria-current="page"] { color: var(--white); background: rgba(255,255,255,.08); }
.menu a[aria-current="page"] { color: var(--gold); }
.menu .btn { margin-left: .6rem; padding: .75rem 1.2rem; color: var(--ink); }
.menu .btn:hover { background: var(--gold-soft); color: var(--ink); }

.has-sub { position: relative; }
.has-sub > button {
  font: inherit; font-weight: 500; color: #dbe5e3; background: none; border: 0; cursor: pointer;
  padding: .55rem .85rem; border-radius: 999px; display: flex; align-items: center; gap: .3rem;
}
.has-sub > button:hover { background: rgba(255,255,255,.08); color: var(--white); }
.has-sub > button svg { width: 12px; transition: transform .2s; }
.has-sub[data-open] > button svg { transform: rotate(180deg); }
.has-sub .sub {
  position: absolute; top: calc(100% + .5rem); left: 0; min-width: 250px;
  background: var(--white); border-radius: var(--r-sm); padding: .5rem;
  box-shadow: 0 18px 40px -12px rgba(15,42,46,.35);
  list-style: none; margin: 0; display: none;
}
.has-sub[data-open] .sub { display: block; }
.has-sub .sub a { color: var(--text); border-radius: 6px; padding: .55rem .8rem; }
.has-sub .sub a:hover { background: var(--paper); color: var(--ink); }
.has-sub .sub span { display: block; font-size: .8rem; color: var(--muted); padding: .55rem .8rem .15rem; }

.burger { display: none; background: none; border: 0; color: var(--white); padding: .4rem; cursor: pointer; }
.burger svg { width: 28px; height: 28px; }

@media (max-width: 980px) {
  .burger { display: block; }
  .menu {
    position: absolute; inset: 100% 0 auto 0; flex-direction: column; align-items: stretch;
    background: var(--ink); padding: 1rem 1.25rem 1.5rem; gap: .2rem;
    display: none; border-bottom: 1px solid rgba(201,162,77,.25);
  }
  .nav[data-open] .menu { display: flex; }
  .menu .btn { margin: .6rem 0 0; justify-content: center; }
  .has-sub .sub { position: static; box-shadow: none; background: rgba(255,255,255,.05); }
  .has-sub .sub a { color: #dbe5e3; }
  .has-sub .sub a:hover { background: rgba(255,255,255,.08); color: var(--white); }
  .has-sub .sub span { color: #8fa3a1; }
  .topbar .social { display: none; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background: var(--ink); color: var(--white);
  padding: clamp(3rem, 7vw, 6rem) 0 clamp(4rem, 8vw, 7rem);
}
/* faint calligraphic arc echoing the logo ring */
.hero::before {
  content: ""; position: absolute; transform-origin: 50% 50%; width: 900px; height: 900px; right: -320px; top: -260px;
  border: 1.5px solid rgba(201,162,77,.22); border-right-color: transparent; border-bottom-color: rgba(201,162,77,.05); border-radius: 50%;
}
.hero::after {
  content: ""; position: absolute; width: 620px; height: 620px; right: -170px; top: -110px;
  border: 1px solid rgba(201,162,77,.12); border-radius: 50%;
}
.hero .wrap { position: relative; z-index: 1; display: grid; grid-template-columns: 1.05fr 1fr; gap: clamp(2rem, 5vw, 4.5rem); align-items: center; }
.urdu {
  font-family: var(--f-urdu); color: var(--gold);
  font-size: clamp(1.5rem, 3vw, 2rem); line-height: 2; margin: 0 0 .5rem; direction: rtl; text-align: left;
}
.hero h1 {
  font-size: clamp(2.5rem, 5.6vw, 4.6rem);
  line-height: 1.02; letter-spacing: -.035em; font-weight: 700;
  margin: 0 0 1.4rem; max-width: 13ch;
}
.hero .lead { font-size: clamp(1.05rem, 1.6vw, 1.25rem); color: #c5d3d1; max-width: 46ch; margin: 0 0 2.2rem; }
.hero .actions { display: flex; flex-wrap: wrap; gap: .8rem; }
.hero .place { margin-top: 2.6rem; display: flex; align-items: center; gap: .7rem; color: #9fb3b0; font-size: .95rem; }
.hero .place svg { width: 18px; fill: var(--gold); flex: none; }

/* photo collage — the real work, shown first */
.proof { position: relative; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 14px; aspect-ratio: 1 / 1.02; }
.proof figure { margin: 0; position: relative; overflow: hidden; border-radius: var(--r-lg); background: var(--ink-2); }
.proof figure img { width: 100%; height: 100%; object-fit: cover; }
.proof .p1 { grid-row: 1 / 3; }
.proof figcaption {
  position: absolute; left: .7rem; bottom: .7rem; right: .7rem;
  background: rgba(15,42,46,.82); backdrop-filter: blur(6px);
  color: var(--white); font-size: .85rem; line-height: 1.35; padding: .55rem .8rem; border-radius: 10px;
}
.proof figcaption b { color: var(--gold); font-weight: 600; display: block; }
.proof .seal {
  position: absolute; z-index: 2; width: 116px; height: 116px; left: -40px; bottom: 18%;
  border-radius: 50%; background: #000; box-shadow: 0 0 0 6px var(--ink), 0 20px 40px rgba(0,0,0,.4);
}

/* single orchestrated load moment */
@media (prefers-reduced-motion: no-preference) {
  .proof figure { animation: settle .9s cubic-bezier(.2,.7,.2,1) both; }
  .proof .p2 { animation-delay: .12s; }
  .proof .p3 { animation-delay: .24s; }
  .proof .seal { animation: settle 1s .4s cubic-bezier(.2,.7,.2,1) both; }
  @keyframes settle { from { opacity: 0; transform: translateY(22px) scale(.97); } to { opacity: 1; transform: none; } }
}

@media (max-width: 900px) {
  .hero .wrap { grid-template-columns: 1fr; }
  .proof { aspect-ratio: 4 / 3.4; }
  .proof .seal { width: 84px; height: 84px; left: auto; right: 12px; bottom: auto; top: -30px; }
}

/* ---------- Sections ---------- */
section { padding: clamp(4rem, 8vw, 6.5rem) 0; }
.head { max-width: 640px; margin-bottom: clamp(2.2rem, 4vw, 3.5rem); }
.head h2 { font-size: clamp(2rem, 3.8vw, 3rem); line-height: 1.08; letter-spacing: -.03em; margin: 0 0 .9rem; }
.head p { color: var(--muted); margin: 0; font-size: 1.1rem; }

/* ---------- Services ---------- */
.feature {
  display: grid; grid-template-columns: 1.1fr 1fr; gap: clamp(1.5rem, 4vw, 3.5rem); align-items: center;
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}
.feature.flip { grid-template-columns: 1fr 1.1fr; }
.feature.flip .media { order: 2; }
.feature .media { position: relative; }
.feature .media img { border-radius: var(--r-lg); width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.feature .media .inset {
  position: absolute; width: 38%; right: -18px; bottom: -26px; aspect-ratio: 3/4;
  border: 6px solid var(--paper); border-radius: 16px;
}
.feature.flip .media .inset { right: auto; left: -18px; aspect-ratio: 3 / 2; }
.feature h3 { font-size: clamp(1.6rem, 2.8vw, 2.2rem); letter-spacing: -.02em; line-height: 1.1; margin: .6rem 0 .8rem; }
.feature p { color: var(--muted); margin: 0 0 1.2rem; max-width: 48ch; }
.icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; }
.icon svg { width: 26px; height: 26px; }
.icon.water { background: #e2eff8; color: var(--water); }
.icon.health { background: #f4ecda; color: #9a7425; }
.ticks { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.ticks li { display: flex; gap: .6rem; align-items: baseline; }
.ticks li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--water); flex: none; transform: translateY(-2px); }

.more { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); margin-top: 1rem; }
.more div { padding: 1.8rem 1.6rem 0 0; }
.more div + div { padding-left: 1.6rem; border-left: 1px solid var(--line); }
.more svg { width: 28px; height: 28px; color: var(--ink); margin-bottom: .8rem; }
.more h4 { font-size: 1.15rem; margin: 0 0 .4rem; letter-spacing: -.01em; }
.more p { margin: 0; color: var(--muted); font-size: .97rem; }
.more-link { margin-top: 2.5rem; }
@media (max-width: 900px) {
  .feature, .feature.flip { grid-template-columns: 1fr; }
  .feature.flip .media { order: 0; }
  .more { grid-template-columns: 1fr 1fr; }
  .more div, .more div + div { padding: 1.6rem 1rem 1.2rem 0; border-left: 0; }
}
@media (max-width: 520px) { .more { grid-template-columns: 1fr; } }

/* ---------- About (tabs) ---------- */
.about { background: var(--white); }
.about .wrap { display: grid; grid-template-columns: .85fr 1.15fr; gap: clamp(2rem, 6vw, 5rem); align-items: start; }
.creed {
  position: sticky; top: 110px;
  background: var(--ink); color: var(--white); border-radius: var(--r-lg);
  padding: 2.4rem 2.2rem; overflow: hidden;
}
.creed img { width: 120px; height: 120px; border-radius: 50%; margin-bottom: 1.6rem; background: #000; }
.creed blockquote { margin: 0; font-size: clamp(1.5rem, 2.4vw, 1.9rem); line-height: 1.2; letter-spacing: -.02em; font-weight: 600; }
.creed p { color: #a9bbb9; margin: 1rem 0 0; font-size: .95rem; }
.tabs [role="tablist"] { display: inline-flex; background: var(--paper); border-radius: 999px; padding: 5px; margin-bottom: 2rem; }
.tabs [role="tab"] {
  font: 600 1rem var(--f-sans); border: 0; background: none; color: var(--muted);
  padding: .7rem 1.4rem; border-radius: 999px; cursor: pointer;
}
.tabs [role="tab"][aria-selected="true"] { background: var(--ink); color: var(--white); }
.tabs [role="tabpanel"] p { margin: 0 0 1.1rem; color: var(--text); max-width: 62ch; }
.tabs [role="tabpanel"] p:first-child { font-size: 1.22rem; line-height: 1.5; letter-spacing: -.01em; }
.tabs .btn { margin-top: .8rem; }
@media (max-width: 900px) { .about .wrap { grid-template-columns: 1fr; } .creed { position: static; } }

/* ---------- Give band ---------- */
.give { background: var(--gold); color: var(--ink); padding: clamp(3.5rem, 7vw, 5.5rem) 0; position: relative; overflow: hidden; }
.give::after {
  content: ""; position: absolute; width: 520px; height: 520px; right: -140px; top: -200px;
  border-radius: 50%; border: 2px solid rgba(15,42,46,.18);
}
.give .wrap { position: relative; z-index: 1; display: grid; grid-template-columns: 1.4fr 1fr; gap: 2.5rem; align-items: center; }
.give h2 { font-size: clamp(2rem, 4.2vw, 3.3rem); line-height: 1.04; letter-spacing: -.035em; margin: 0 0 1rem; }
.give p { margin: 0; font-size: 1.12rem; max-width: 50ch; }
.give .actions { display: flex; flex-direction: column; gap: .8rem; align-items: flex-start; }
.give .call { font-weight: 600; text-decoration: none; display: flex; gap: .5rem; align-items: center; padding-top: .4rem; }
.give .call svg { width: 18px; fill: currentColor; }
@media (max-width: 800px) { .give .wrap { grid-template-columns: 1fr; } }

/* ---------- Team ---------- */
.team-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(1rem, 2.5vw, 2rem); }
.person img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: top; border-radius: var(--r-lg); background: var(--line); }
.person h3 { margin: 1.1rem 0 .15rem; font-size: 1.3rem; letter-spacing: -.01em; }
.person p { margin: 0; color: var(--muted); }
.person a { display: inline-block; margin-top: .6rem; font-weight: 600; color: var(--water); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.person:first-child img { object-position: 50% 15%; }
@media (max-width: 800px) { .team-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .team-grid { grid-template-columns: 1fr; } }

/* ---------- Footer ---------- */
footer { background: var(--ink); color: #b9c8c6; padding: 4.5rem 0 2rem; }
footer .cols { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 2.5rem; }
footer h4 { color: var(--white); font-size: 1rem; margin: 0 0 1rem; }
footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .55rem; }
footer a { text-decoration: none; }
footer a:hover { color: var(--gold); }
footer .brand { margin-bottom: 1.2rem; }
footer .tag { max-width: 34ch; margin: 0; }
footer .social { display: flex; gap: .6rem; margin-top: 1.4rem; }
footer .social a { width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,.18); display: grid; place-items: center; }
footer .social a:hover { border-color: var(--gold); }
footer .social svg { width: 17px; height: 17px; fill: currentColor; }
footer .base { margin-top: 3.5rem; padding-top: 1.5rem; border-top: 1px solid rgba(255,255,255,.1); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem; font-size: .9rem; color: #8ea2a0; }
@media (max-width: 900px) { footer .cols { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { footer .cols { grid-template-columns: 1fr; } }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  .topbar { display: none; }
  .brand small { display: none; }
  .brand img { width: 46px; height: 46px; }
  .proof figcaption { font-size: .78rem; padding: .45rem .6rem; left: .5rem; right: .5rem; bottom: .5rem; }
  .proof .p2 figcaption { display: none; }
  .feature .media .inset, .feature.flip .media .inset { right: 10px; left: auto; bottom: -18px; width: 34%; border-width: 4px; }
  .feature .media { margin-bottom: 1.2rem; }
}

/* =====================================================================
   MOTION LAYER — scroll effects. Everything here is opt-in via
   html.js (set by rahmah.js) and is switched off for reduced motion.
   ===================================================================== */

/* Scroll progress bar */
.progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 100; pointer-events: none; }
.progress span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--water), var(--gold)); transform-origin: 0 50%; transform: scaleX(var(--scroll, 0)); }

/* Nav: compact after scrolling, hides on scroll down, returns on scroll up */
.nav { transition: transform .35s cubic-bezier(.2,.7,.2,1), background .3s, box-shadow .3s; }
.nav .wrap { transition: padding .3s; }
.nav.is-compact { box-shadow: 0 10px 30px -18px rgba(0,0,0,.6); }
.nav.is-compact .wrap { padding: .35rem 0; }
.nav.is-compact .brand img { width: 44px; height: 44px; }
.nav.is-hidden { transform: translateY(-100%); }
.nav .brand img { transition: width .3s, height .3s; }

/* Back to top with progress ring */
.to-top {
  position: fixed; right: 1.2rem; bottom: 1.2rem; z-index: 60;
  width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--ink); color: var(--gold); display: grid; place-items: center;
  box-shadow: 0 12px 30px -10px rgba(15,42,46,.6);
  opacity: 0; transform: translateY(16px) scale(.9); pointer-events: none;
  transition: opacity .3s, transform .3s;
}
.to-top.is-on { opacity: 1; transform: none; pointer-events: auto; }
.to-top svg.ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.to-top svg.ring circle { fill: none; stroke: var(--gold); stroke-width: 3; stroke-dasharray: 151; stroke-dashoffset: calc(151 - 151 * var(--scroll, 0)); }
.to-top svg.arrow { width: 20px; height: 20px; }

/* Ribbon marquee */
.ribbon { background: var(--ink); color: var(--white); overflow: hidden; padding: 1.3rem 0; border-block: 1px solid rgba(201,162,77,.25); }
.ribbon .track { display: flex; width: max-content; gap: 0; }
.ribbon span { font-size: clamp(1.3rem, 2.6vw, 2.1rem); font-weight: 600; letter-spacing: -.02em; white-space: nowrap; display: flex; align-items: center; }
.ribbon span::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--gold); margin: 0 2.2rem; }
.ribbon span:nth-child(3n+2) { color: var(--gold-soft); }

/* Page hero for inner pages */
.page-hero { position: relative; overflow: hidden; background: var(--ink); color: var(--white); padding: clamp(3.5rem, 8vw, 6.5rem) 0 clamp(3rem, 7vw, 5.5rem); }
.page-hero::before, .page-hero::after { content: ""; position: absolute; border-radius: 50%; border: 1.5px solid rgba(201,162,77,.2); }
.page-hero::before { border-right-color: transparent !important; width: 760px; height: 760px; right: -260px; top: -380px; transform: rotate(calc(var(--hero-p, 0) * 40deg)); }
.page-hero::after { width: 480px; height: 480px; right: -60px; top: -180px; border-color: rgba(201,162,77,.1); }
.page-hero .wrap { position: relative; z-index: 1; }
.crumbs { display: flex; gap: .5rem; list-style: none; padding: 0; margin: 0 0 1.6rem; font-size: .9rem; color: #9fb3b0; flex-wrap: wrap; }
.crumbs a { color: #c5d3d1; text-decoration: none; }
.crumbs a:hover { color: var(--gold); }
.crumbs li + li::before { content: "/"; margin-right: .5rem; color: rgba(201,162,77,.6); }
.page-hero h1 { font-size: clamp(2.4rem, 6vw, 4.8rem); line-height: 1; letter-spacing: -.04em; margin: 0 0 1.2rem; max-width: 16ch; }
.page-hero .lead { font-size: clamp(1.05rem, 1.6vw, 1.25rem); color: #c5d3d1; max-width: 56ch; margin: 0; }
.page-hero .actions { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: 2rem; }
.page-hero.has-img .wrap { display: grid; grid-template-columns: 1.2fr 1fr; gap: 3rem; align-items: center; }
.page-hero .hero-img { border-radius: var(--r-lg); overflow: hidden; aspect-ratio: 4/3; box-shadow: 0 30px 60px -30px rgba(0,0,0,.7); }
.page-hero .hero-img img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.12) translateY(calc(var(--hero-p, 0) * 40px)); }
@media (max-width: 860px) { .page-hero.has-img .wrap { grid-template-columns: 1fr; } }

/* Word-split headings */
.split .w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .08em; margin-bottom: -.08em; }
.split .w > span { display: inline-block; }

/* Prose for long-form text */
.prose { max-width: 70ch; }
.prose h2 { font-size: clamp(1.6rem, 2.6vw, 2.1rem); letter-spacing: -.025em; line-height: 1.15; margin: 2.8rem 0 1rem; scroll-margin-top: 110px; }
.prose h3 { font-size: 1.3rem; letter-spacing: -.015em; margin: 2rem 0 .7rem; scroll-margin-top: 110px; }
.prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose p, .prose li { color: #304244; }
.prose p { margin: 0 0 1.1rem; }
.prose ul, .prose ol { padding-left: 1.2rem; margin: 0 0 1.4rem; display: grid; gap: .55rem; }
.prose li::marker { color: var(--water); }
.prose strong { color: var(--ink); }
.prose a { color: var(--water); }
.prose table { width: 100%; border-collapse: collapse; margin: 1rem 0 2rem; font-size: .97rem; background: var(--white); border-radius: var(--r-sm); overflow: hidden; }
.prose th, .prose td { text-align: left; padding: .75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose thead th { background: var(--ink); color: var(--white); font-weight: 600; }
.prose tfoot td { color: var(--muted); }
.table-scroll { overflow-x: auto; }

/* Doc layout: content + sticky side */
.doc { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: clamp(2rem, 5vw, 4.5rem); align-items: start; }
.doc aside { position: sticky; top: 100px; display: grid; gap: 1.2rem; }
.toc { background: var(--white); border-radius: var(--r-lg); padding: 1.4rem 1.4rem 1.2rem; }
.toc b { display: block; font-size: .95rem; margin-bottom: .7rem; }
.toc ol { list-style: none; padding: 0; margin: 0; display: grid; gap: .15rem; max-height: 50vh; overflow: auto; }
.toc a { display: block; padding: .4rem .7rem; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: .92rem; line-height: 1.35; border-left: 2px solid transparent; }
.toc a:hover { color: var(--ink); background: var(--paper); }
.toc a.is-active { color: var(--ink); border-left-color: var(--gold); background: var(--paper); font-weight: 600; }
.cover-card { background: var(--ink); color: var(--white); border-radius: var(--r-lg); padding: 1.2rem; }
.cover-card img { border-radius: 12px; margin-bottom: 1rem; }
.cover-card p { margin: 0 0 1rem; color: #b9c8c6; font-size: .95rem; }
.cover-card .btn { width: 100%; justify-content: center; }
@media (max-width: 960px) { .doc { grid-template-columns: 1fr; } .doc aside { position: static; } .toc { display: none; } }

/* Generic grids and blocks */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(1rem, 2.4vw, 1.8rem); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: clamp(1rem, 2.4vw, 1.8rem); }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }
.tile { background: var(--white); border-radius: var(--r-lg); padding: 1.8rem; position: relative; overflow: hidden; }
.tile h3 { margin: .9rem 0 .5rem; font-size: 1.25rem; letter-spacing: -.015em; }
.tile p { margin: 0; color: var(--muted); }
.tile .ic { width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center; background: var(--paper); color: var(--ink); }
.tile .ic svg { width: 24px; height: 24px; }
.tile::after { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--gold); transform: scaleX(0); transform-origin: left; transition: transform .5s cubic-bezier(.2,.7,.2,1); }
.tile:hover::after { transform: scaleX(1); }
.band { background: var(--white); }
.band-ink { background: var(--ink); color: var(--white); }
.band-ink .head p { color: #b9c8c6; }

/* Big statement quote */
.statement { font-size: clamp(1.8rem, 4.2vw, 3.4rem); line-height: 1.1; letter-spacing: -.035em; font-weight: 600; max-width: 22ch; margin: 0; }
.statement-sub { color: var(--muted); margin-top: 1.2rem; max-width: 52ch; }

/* Stacking cards (objectives) */
.stack { display: grid; gap: 1.6rem; }
.stack-card {
  position: sticky; top: calc(110px + var(--i, 0) * 22px);
  background: var(--white); border-radius: 28px; padding: clamp(1.8rem, 4vw, 3rem);
  box-shadow: 0 -18px 40px -28px rgba(15,42,46,.45);
  display: grid; grid-template-columns: 260px 1fr; gap: 2.5rem;
  transform-origin: 50% 0;
}
.stack-card:nth-child(2) { background: #eef4f8; }
.stack-card:nth-child(3) { background: #f7f0df; }
.stack-card:nth-child(4) { background: var(--ink); color: var(--white); }
.stack-card:nth-child(4) li { color: #d3dfdd; }
.stack-card h3 { font-size: clamp(1.6rem, 2.6vw, 2.2rem); letter-spacing: -.03em; line-height: 1.05; margin: 1rem 0 0; }
.stack-card .ic { width: 58px; height: 58px; border-radius: 16px; background: rgba(201,162,77,.18); color: #9a7425; display: grid; place-items: center; }
.stack-card:nth-child(4) .ic { color: var(--gold); }
.stack-card .ic svg { width: 28px; height: 28px; }
.stack-card ul { margin: 0; padding-left: 1.1rem; display: grid; gap: .6rem; }
.stack-card li::marker { color: var(--gold); }
@media (max-width: 800px) { .stack-card { grid-template-columns: 1fr; gap: 1.2rem; position: static; } }

/* Forms */
.form { display: grid; gap: 1.1rem; }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
@media (max-width: 600px) { .form .row2 { grid-template-columns: 1fr; } }
.field label, .field .label { display: block; font-weight: 600; font-size: .95rem; margin-bottom: .4rem; }
.field small { color: var(--muted); display: block; margin-top: .3rem; font-size: .85rem; }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--white); border: 1.5px solid var(--line); border-radius: 12px;
  padding: .85rem 1rem; transition: border-color .2s, box-shadow .2s;
}
.field textarea { min-height: 140px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--water); box-shadow: 0 0 0 4px rgba(47,127,184,.15); }
.field input[type="file"] { padding: .7rem; background: var(--paper); border-style: dashed; }
.check { display: flex; gap: .7rem; align-items: flex-start; }
.check input { width: 20px; height: 20px; margin-top: .2rem; accent-color: var(--ink); flex: none; }
.chips { display: flex; gap: .6rem; flex-wrap: wrap; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; }
.chips span { display: inline-block; padding: .7rem 1.2rem; border-radius: 999px; border: 1.5px solid var(--line); background: var(--white); cursor: pointer; font-weight: 600; transition: all .2s; }
.chips input:checked + span { background: var(--ink); color: var(--white); border-color: var(--ink); }
.chips input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }
.panel { background: var(--white); border-radius: var(--r-lg); padding: clamp(1.5rem, 4vw, 2.5rem); box-shadow: 0 30px 60px -40px rgba(15,42,46,.35); }
.notice { border-radius: 12px; padding: 1rem 1.2rem; margin-bottom: 1.4rem; font-weight: 500; }
.notice.ok { background: #e3f3e8; color: #1d5b33; }
.notice.err { background: #fbe6e4; color: #8a2a1f; }

/* Split section (text + panel) */
.split-2 { display: grid; grid-template-columns: 1fr 1.15fr; gap: clamp(2rem, 6vw, 5rem); align-items: start; }
@media (max-width: 900px) { .split-2 { grid-template-columns: 1fr; } }
.info-list { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: 1rem; }
.info-list li { display: flex; gap: 1rem; align-items: flex-start; }
.info-list .ic { width: 46px; height: 46px; border-radius: 12px; background: var(--white); display: grid; place-items: center; flex: none; color: var(--water); }
.info-list .ic svg { width: 22px; height: 22px; }
.info-list b { display: block; }
.info-list a, .info-list span { color: var(--muted); text-decoration: none; }
.info-list a:hover { color: var(--water); }
.map { border: 0; width: 100%; height: 360px; border-radius: var(--r-lg); filter: grayscale(.3) contrast(1.05); }

/* Cause cards */
.cause { background: var(--white); border-radius: var(--r-lg); overflow: hidden; display: flex; flex-direction: column; }
.cause .img { aspect-ratio: 16/10; overflow: hidden; background: var(--ink-2); }
.cause .img img { width: 100%; height: 100%; object-fit: cover; transition: transform .8s cubic-bezier(.2,.7,.2,1); }
.cause:hover .img img { transform: scale(1.06); }
.cause .body { padding: 1.5rem; display: flex; flex-direction: column; gap: .6rem; flex: 1; }
.cause h3 { margin: 0; font-size: 1.25rem; letter-spacing: -.015em; }
.cause p { margin: 0; color: var(--muted); flex: 1; }
.cause .btn { align-self: flex-start; margin-top: .6rem; padding: .75rem 1.1rem; }
.cause .img.icon-only { display: grid; place-items: center; color: var(--gold); }
.cause .img.icon-only svg { width: 64px; height: 64px; }

/* Journal */
.jbar { background: var(--white); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
.jbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.jnav { display: flex; gap: .2rem; overflow-x: auto; scrollbar-width: none; padding: .55rem 0; }
.jnav::-webkit-scrollbar { display: none; }
.jnav a { white-space: nowrap; padding: .5rem .85rem; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: .95rem; }
.jnav a:hover { background: var(--paper); color: var(--ink); }
.jnav a[aria-current="page"] { background: var(--ink); color: var(--white); }
.jauth { display: flex; gap: .5rem; align-items: center; flex: none; font-size: .9rem; color: var(--muted); }
.jauth .btn { padding: .55rem 1rem; font-size: .92rem; }
@media (max-width: 760px) { .jauth .who { display: none; } }
.jhero .wrap { display: grid; grid-template-columns: 1.3fr .7fr; gap: 3rem; align-items: center; }
.jhero .cover { transform: rotate(calc(-4deg + var(--hero-p, 0) * 6deg)); border-radius: 14px; box-shadow: 0 40px 70px -30px rgba(0,0,0,.8); max-width: 330px; justify-self: end; }
.badge { display: inline-flex; align-items: center; gap: .5rem; background: rgba(201,162,77,.16); color: var(--gold-soft); padding: .45rem .9rem; border-radius: 999px; font-weight: 600; font-size: .9rem; margin-bottom: 1.3rem; }
.badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 0 rgba(201,162,77,.7); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(201,162,77,0); } 100% { box-shadow: 0 0 0 0 rgba(201,162,77,0); } }
@media (max-width: 860px) { .jhero .wrap { grid-template-columns: 1fr; } .jhero .cover { justify-self: start; max-width: 220px; } }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid rgba(255,255,255,.12); margin-top: 3rem; }
.stats div { padding: 1.6rem 1.5rem 0 0; }
.stats div + div { padding-left: 1.5rem; border-left: 1px solid rgba(255,255,255,.12); }
.stats b { display: block; font-size: clamp(2.2rem, 4.5vw, 3.4rem); letter-spacing: -.04em; line-height: 1; color: var(--gold); font-variant-numeric: tabular-nums; }
.stats span { color: #b9c8c6; font-size: .95rem; }
.articles { display: grid; gap: 1rem; }
.article { background: var(--white); border-radius: var(--r-lg); padding: 1.6rem 1.8rem; display: grid; grid-template-columns: 1fr auto; gap: 1.5rem; align-items: center; border: 1px solid transparent; transition: border-color .3s, transform .3s; }
.article:hover { border-color: var(--gold); transform: translateX(4px); }
.article .meta { color: var(--water); font-weight: 600; font-size: .9rem; margin-bottom: .4rem; }
.article h3 { margin: 0 0 .4rem; font-size: 1.2rem; line-height: 1.3; letter-spacing: -.01em; }
.article p { margin: 0; color: var(--muted); }
.article .btn { padding: .7rem 1.1rem; }
@media (max-width: 640px) { .article { grid-template-columns: 1fr; } .article .btn { justify-self: start; } }
.empty { background: var(--white); border-radius: var(--r-lg); padding: 3rem 2rem; text-align: center; color: var(--muted); }
.empty h3 { color: var(--text); margin: 0 0 .5rem; }
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 1.5rem 0 2.5rem; }
.board div { background: var(--white); border-radius: 16px; padding: 1.2rem 1.3rem; }
.board b { display: block; line-height: 1.3; }
.board span { color: var(--muted); font-size: .92rem; }
@media (max-width: 900px) { .board { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .board { grid-template-columns: 1fr; } }
.chief { display: flex; gap: 1.5rem; align-items: center; background: var(--ink); color: var(--white); border-radius: var(--r-lg); padding: 1.5rem; margin-bottom: 1rem; }
.chief img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; object-position: top; }
.chief span { color: var(--gold); font-weight: 600; font-size: .9rem; }
.chief h3 { margin: .2rem 0 0; font-size: 1.5rem; }

/* Modal (login / sign up) */
dialog.modal { border: 0; padding: 0; border-radius: 24px; width: min(440px, 100% - 2rem); box-shadow: 0 40px 80px -20px rgba(0,0,0,.5); }
dialog.modal::backdrop { background: rgba(15,42,46,.65); backdrop-filter: blur(4px); }
dialog.modal .in { padding: 2rem; }
dialog.modal h2 { margin: 0 0 .3rem; letter-spacing: -.02em; }
dialog.modal p.sub { margin: 0 0 1.5rem; color: var(--muted); }
dialog.modal .x { position: absolute; top: 1rem; right: 1rem; width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--paper); cursor: pointer; font-size: 1.3rem; line-height: 1; }
dialog.modal .switch { margin: 1.2rem 0 0; color: var(--muted); font-size: .95rem; }
dialog.modal .switch button { background: none; border: 0; color: var(--water); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
@media (prefers-reduced-motion: no-preference) {
  dialog.modal[open] { animation: pop .35s cubic-bezier(.2,.7,.2,1); }
  @keyframes pop { from { opacity: 0; transform: translateY(20px) scale(.97); } }
}

/* Author dashboard */
.dash { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.dash-side { background: var(--ink); color: var(--white); padding: 1.5rem 1.2rem; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2rem; }
.dash-side nav { display: grid; gap: .3rem; }
.dash-side nav a { display: flex; gap: .7rem; align-items: center; padding: .75rem .9rem; border-radius: 12px; color: #c5d3d1; text-decoration: none; font-weight: 500; }
.dash-side nav a svg { width: 20px; height: 20px; }
.dash-side nav a:hover { background: rgba(255,255,255,.07); color: var(--white); }
.dash-side nav a[aria-current="page"] { background: var(--gold); color: var(--ink); }
.dash-side .bottom { margin-top: auto; font-size: .9rem; color: #9fb3b0; display: grid; gap: .8rem; word-break: break-all; }
.dash-main { padding: clamp(1.5rem, 4vw, 3rem); max-width: 1000px; width: 100%; }
.dash-main h1 { font-size: clamp(1.8rem, 3.4vw, 2.6rem); letter-spacing: -.03em; margin: 0 0 .5rem; }
.dash-main > p.lead { color: var(--muted); margin: 0 0 2rem; }
@media (max-width: 860px) {
  .dash { grid-template-columns: 1fr; }
  .dash-side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 1rem; }
  .dash-side nav { display: flex; flex-wrap: wrap; }
  .dash-side .bottom { margin: 0 0 0 auto; }
}
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: 0 0 2rem; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; padding: .9rem 1rem; border-radius: 14px; background: var(--white); color: var(--muted); font-weight: 600; font-size: .95rem; display: flex; gap: .6rem; align-items: center; }
.steps li::before { content: counter(s); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--paper); font-size: .85rem; flex: none; }
.steps li.done { color: var(--ink); }
.steps li.done::before { content: "✓"; background: #d7ecdf; color: #1d5b33; }
.steps li.now { background: var(--ink); color: var(--white); }
.steps li.now::before { background: var(--gold); color: var(--ink); }
@media (max-width: 700px) { .steps { grid-template-columns: 1fr 1fr; } }
.seg { display: inline-flex; background: var(--white); border-radius: 999px; padding: 5px; margin-bottom: 1.5rem; }
.seg a { padding: .6rem 1.3rem; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; }
.seg a[aria-current="page"] { background: var(--ink); color: var(--white); }
.list-table { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--r-lg); overflow: hidden; }
.list-table th, .list-table td { text-align: left; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.list-table th { font-size: .88rem; color: var(--muted); font-weight: 600; background: #fafbf9; }
.pill { display: inline-block; padding: .3rem .7rem; border-radius: 999px; font-size: .82rem; font-weight: 600; background: #e2eff8; color: var(--water); }
.pill.arch { background: #efeadf; color: #7a5d1d; }
.done-card { text-align: center; padding: 3.5rem 2rem; }
.done-card .tick { width: 84px; height: 84px; border-radius: 50%; background: #d7ecdf; color: #1d5b33; display: grid; place-items: center; margin: 0 auto 1.5rem; }
.done-card .tick svg { width: 40px; height: 40px; }
@media (prefers-reduced-motion: no-preference) {
  .done-card .tick svg path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .7s .3s forwards; }
  @keyframes draw { to { stroke-dashoffset: 0; } }
}

/* ---------- Reveal states (only with JS + motion allowed) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .js [data-reveal] { opacity: 0; transform: translateY(36px); transition: opacity .9s cubic-bezier(.2,.7,.2,1), transform .9s cubic-bezier(.2,.7,.2,1); transition-delay: var(--d, 0s); }
  .js [data-reveal="left"] { transform: translateX(-46px); }
  .js [data-reveal="right"] { transform: translateX(46px); }
  .js [data-reveal="zoom"] { transform: scale(.92); }
  .js [data-reveal].is-in { opacity: 1; transform: none; }

  .js [data-wipe] { clip-path: inset(0 0 100% 0 round var(--r-lg)); transition: clip-path 1.2s cubic-bezier(.7,0,.2,1); transition-delay: var(--d, 0s); }
  .js [data-wipe] img { transform: scale(1.25); transition: transform 1.6s cubic-bezier(.2,.7,.2,1); transition-delay: var(--d, 0s); }
  .js [data-wipe].is-in { clip-path: inset(0 0 0 0 round var(--r-lg)); }
  .js [data-wipe].is-in img { transform: scale(1); }

  .js .split .w > span { transform: translateY(110%); transition: transform .9s cubic-bezier(.2,.7,.2,1); transition-delay: calc(var(--wi) * 60ms + var(--d, 0s)); }
  .js .split.is-in .w > span { transform: none; }

  .ribbon .track { animation: marquee 38s linear infinite; }
  .ribbon:hover .track { animation-play-state: paused; }
  @keyframes marquee { to { transform: translateX(-50%); } }

  .js .hero .proof { transform: translateY(calc(var(--hero-p, 0) * -60px)); }
  .js .hero .proof .p1 img { transform: scale(1.1) translateY(calc(var(--hero-p, 0) * 50px)); }
  .js .hero::before { transform: rotate(calc(var(--hero-p, 0) * 50deg)); }
  .js .hero .copy { transform: translateY(calc(var(--hero-p, 0) * 80px)); opacity: calc(1 - var(--hero-p, 0) * 1.2); }
  .js .parallax { transform: translateY(calc(var(--pp, 0) * 1px)); will-change: transform; }
}

/* Fixes after review */
.band .tile { background: var(--paper); }
footer { border-top: 1px solid rgba(201,162,77,.22); }
@media (max-width: 760px) {
  .jbar .wrap { flex-wrap: wrap; gap: 0; padding-top: .5rem; }
  .jauth { width: 100%; justify-content: flex-end; }
  .jnav { order: 2; width: 100%; }
  .stats div { padding-right: .8rem; }
  .stats div + div { padding-left: .8rem; }
  .stats span { font-size: .82rem; }
}
