/* Sanad — donation screen. Tokens first; everything else uses them. */
:root {
  --ink: #1d2639;          /* 14.9:1 on surface */
  --ink-2: #4c566a;        /* 7.1:1 on surface */
  --ink-3: #6a6458;        /* 5.4:1 on surface (small meta text) */
  --surface: #fffcf7;
  --surface-2: #f6efe4;
  --line: #e9dfd0;
  --ctl-line: #8a7c6b;     /* 3.9:1 control boundary on surface (non-text ≥ 3:1) */
  --accent: #b5481f;       /* CTA — white text 5.3:1 */
  --accent-hover: #9c3c17;
  --accent-soft: #fbe6dc;
  --ok: #2f6b55;           /* reached-item tick — 6.2:1 */
  --focus: #1f5fbf;        /* focus ring — 5.6:1 on surface, 4.4:1 on the wall */
  --stage: #ead9c0;

  --font-display: "Beiruti", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --font-body: "IBM Plex Sans Arabic", system-ui, sans-serif;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;
  --r-sm: 12px; --r-md: 16px; --r-lg: 28px;
  --shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 2px 6px rgba(60,40,20,.06), 0 18px 48px -12px rgba(60,40,20,.22);
  --ease-out: cubic-bezier(.22,1,.36,1);
  --t-fast: 160ms; --t-med: 260ms;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--stage); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.6; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
.sr, [data-state] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── stage (3D canvas, full-bleed) ── */
.stage { position: fixed; inset: 0; z-index: 0; background: var(--stage); }
.stage canvas, .stage img#scene, .scene-fallback { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: cover; }
.vignette { position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 95% at var(--vx, 34%) 48%, rgba(0,0,0,0) 50%, rgba(70,45,25,.2) 100%); }
.scene-caption { display: none; }

/* ── layout ── */
.layout { position: relative; z-index: 1; min-height: 100%; display: grid; grid-template-rows: auto 1fr; padding: var(--s6) var(--s10) var(--s10); pointer-events: none; }
.layout > * { pointer-events: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); }
.brand { display: flex; align-items: center; gap: var(--s3); background: rgba(255,252,247,.92); padding: 8px 16px 8px 18px; border-radius: 999px; box-shadow: 0 1px 2px rgba(60,40,20,.08); }
.brand-mark { width: 28px; height: 28px; }
.brand-name { font-family: var(--font-display); font-weight: 900; font-size: 24px; letter-spacing: 0; }
.brand-tag { color: var(--ink-2); font-size: 14px; border-inline-start: 1px solid var(--line); padding-inline-start: var(--s3); }

.motion-toggle { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 18px 8px 14px; border-radius: 999px; border: 1px solid var(--ctl-line); background: var(--surface); cursor: pointer; font-weight: 500; font-size: 15px; box-shadow: 0 1px 2px rgba(60,40,20,.08); }
.motion-toggle .switch { width: 36px; height: 22px; border-radius: 999px; background: #d8cfc2; border: 1px solid var(--ctl-line); position: relative; transition: background var(--t-fast); flex: none; }
.motion-toggle .knob { position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform var(--t-fast) var(--ease-out); }
.motion-toggle[aria-pressed="true"] .switch { background: var(--ink); border-color: var(--ink); }
.motion-toggle[aria-pressed="true"] .knob { transform: translateX(-14px); }

.panel { align-self: center; justify-self: start; width: 452px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: var(--s6) var(--s8); display: flex; flex-direction: column; gap: var(--s4); }
.panel-col { display: flex; flex-direction: column; gap: var(--s5); }

.eyebrow { margin: 0; font-size: 14px; font-weight: 600; color: var(--accent); }
h1 { margin: 2px 0 0; font-family: var(--font-display); font-weight: 800; font-size: 38px; line-height: 1.15; letter-spacing: 0; text-wrap: balance; }
.lede { margin: -10px 0 0; color: var(--ink-2); font-size: 15.5px; line-height: 1.7; text-wrap: pretty; }
.label { display: block; margin: 0 0 var(--s2); font-size: 14px; font-weight: 600; color: var(--ink-2); }

/* stepper */
.stepper { display: flex; align-items: center; gap: var(--s3); }
.step { flex: none; width: 56px; height: 56px; border-radius: 50%; border: 1.5px solid var(--ctl-line); background: var(--surface); display: grid; place-items: center; cursor: pointer; transition: background var(--t-fast), transform var(--t-fast) var(--ease-out); }
.step svg { width: 22px; height: 22px; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; fill: none; }
.step:hover { background: var(--surface-2); }
.step:active { transform: scale(.94); }
.step[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.field { flex: 1; min-width: 0; height: 76px; display: flex; align-items: baseline; justify-content: center; gap: var(--s2); border-radius: var(--r-md); background: var(--surface-2); border: 1.5px solid transparent; padding: 0 var(--s4); cursor: text; transition: border-color var(--t-fast); }
.field:focus-within { border-color: var(--ctl-line); }
.field input { width: 3ch; min-width: 3ch; border: 0; background: transparent; padding: 0; text-align: center; font-family: var(--font-display); font-weight: 900; font-size: 60px; line-height: 72px; height: 72px; direction: ltr; font-variant-numeric: tabular-nums; outline: none; }
.field input.tick { animation: tick var(--t-med) var(--ease-out); }
@keyframes tick { 0% { transform: translateY(6px); opacity: .4; } 100% { transform: none; opacity: 1; } }
.unit { font-family: var(--font-display); font-weight: 700; font-size: 20px; color: var(--ink-2); min-width: 4.4em; }
.hint { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; font-size: 13px; color: var(--ink-3); }
.hint.warn { position: static; width: auto; height: auto; clip: auto; margin: var(--s2) 0 0; color: var(--accent); font-weight: 600; }

.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); margin-top: var(--s4); }
.chip { min-height: 44px; border-radius: 999px; border: 1.5px solid var(--ctl-line); background: var(--surface); cursor: pointer; font-family: var(--font-display); font-weight: 800; font-size: 18px; padding: 6px 8px; transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast); white-space: nowrap; }
.chip span { font-family: var(--font-body); font-weight: 500; font-size: 13px; }
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hover); box-shadow: inset 0 0 0 1px var(--accent); }

/* impact */
.impact { border-top: 1px solid var(--line); padding-top: var(--s5); }
.impact .label { margin-bottom: var(--s1); }
.impact-line { margin: 0 0 var(--s3); font-size: 16px; font-weight: 500; line-height: 1.6; min-height: 3.2em; } /* two lines reserved: no layout jump between levels */
.checklist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--s5); row-gap: 0; }
.checklist li { display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: var(--s3); padding: 4px 0; color: var(--ink-3); transition: color var(--t-med); }
.checklist .glyph { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--ctl-line); color: var(--ink-3); transition: background var(--t-med) var(--ease-out), color var(--t-med), border-color var(--t-med), transform var(--t-med) var(--ease-out); }
.checklist .glyph svg { width: 18px; height: 18px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.checklist li.on .glyph { background: var(--ok); border-color: var(--ok); color: #fff; box-shadow: inset 0 1.5px 0 rgba(255,255,255,.25), inset 0 -2px 0 rgba(0,0,0,.18); }
.checklist li.on .name { font-weight: 600; }
.checklist .tick { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--ctl-line); display: grid; place-items: center; transition: background var(--t-med) var(--ease-out), border-color var(--t-med); }
.checklist .tick svg { width: 12px; height: 12px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 14; stroke-dashoffset: 14; transition: stroke-dashoffset var(--t-med) var(--ease-out) 60ms; }
.checklist .name { font-size: 15px; font-weight: 500; white-space: nowrap; }
.checklist li.on { color: var(--ink); }
.checklist li.on .tick { background: var(--ok); border-color: var(--ok); }
.checklist li.on .tick svg { stroke-dashoffset: 0; }
.next { margin: var(--s3) 0 0; font-size: 14px; color: var(--ink-2); min-height: 1.6em; }
.next b { font-weight: 600; color: var(--ink); }

.donate { width: 100%; min-height: 58px; border: 0; border-radius: var(--r-md); background: var(--accent); color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 21px; cursor: pointer; transition: background var(--t-fast), transform var(--t-fast) var(--ease-out); box-shadow: 0 10px 24px -10px rgba(181,72,31,.7); }
.donate:hover { background: var(--accent-hover); }
.donate:active { transform: scale(.985); }
.donate[aria-disabled="true"] { background: #e7ddd0; color: #5d564b; box-shadow: none; cursor: not-allowed; }
.donate.small { width: auto; min-width: 140px; min-height: 48px; padding: 0 var(--s8); }

/* focus — visible everywhere */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 12px; }
.step:focus-visible, .chip:focus-visible, .motion-toggle:focus-visible { border-radius: 999px; }
.field input:focus-visible { outline: none; }
.field:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }

/* confirmation */
.thanks { border: 0; border-radius: var(--r-lg); padding: var(--s10) var(--s8) var(--s8); width: min(420px, calc(100vw - 32px)); text-align: center; color: var(--ink); background: var(--surface); box-shadow: 0 30px 80px -20px rgba(40,25,10,.4); }
.thanks::backdrop { background: rgba(40,30,20,.22); }
@media (min-width: 901px) { .thanks { margin: auto 56px auto auto; } } /* over the panel, so the student's little celebration stays visible */
.thanks[open] { animation: rise var(--t-med) var(--ease-out); }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.thanks-mark svg { width: 56px; height: 56px; }
.thanks-mark circle { fill: var(--ok); }
.thanks-mark path { fill: none; stroke: #fff; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.thanks h2 { font-family: var(--font-display); font-size: 26px; margin: var(--s4) 0 var(--s2); }
.thanks p { margin: 0 0 var(--s3); color: var(--ink-2); }
.thanks .thanks-note { font-size: 14px; color: var(--ink-3); margin-bottom: var(--s6); }
.noscript { position: fixed; inset: auto 16px 16px; background: #fff; padding: 16px; border-radius: 12px; z-index: 5; }

/* ── compact desktop heights (1366×768, 1280×720) ── */
@media (min-width: 901px) and (max-height: 820px) {
  .layout { padding: var(--s3) var(--s8) var(--s4); }
  .panel { padding: var(--s5) var(--s6); gap: var(--s3); width: 452px; }
  .panel-col { gap: var(--s3); }
  .eyebrow { display: none; }
  h1 { font-size: 32px; }
  .lede { font-size: 15px; line-height: 1.6; }
  .field { height: 64px; } .field input { font-size: 50px; height: 62px; line-height: 62px; }
  .step { width: 52px; height: 52px; }
  .chips { margin-top: var(--s3); }
  .impact { padding-top: var(--s4); }
  .checklist li { padding: 3px 0; }
}

/* ── tablet / narrow: panel docks at the bottom, two columns ── */
@media (max-width: 900px) {
  .layout { padding: var(--s5) var(--s6) var(--s6); }
  .brand-tag { display: none; }
  .panel { align-self: end; justify-self: stretch; width: auto; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: var(--s6); padding: var(--s6) var(--s6) var(--s6); }
  .checklist { grid-template-columns: 1fr; }
  .checklist li { padding: 3px 0; }
  .impact { border-top: 0; padding-top: 0; }
  h1 { font-size: 32px; }
  .lede { font-size: 15px; }
  .panel-impact { justify-content: space-between; }
  .panel { padding: var(--s5) var(--s6); gap: var(--s5); }
  h1 { font-size: 30px; }
}
.hero-spacer, .donate-shelf { display: none; }
/* ── phone (portrait): the student is the hero on top, a sheet of controls below, a sticky donate bar ── */
@media (max-width: 600px) {
  .layout { display: block; padding: 0; min-height: 0; }
  .topbar { position: sticky; top: 0; z-index: 3; padding: max(10px, env(safe-area-inset-top)) var(--s4) 10px; }
  .brand { padding: 6px 12px 6px 14px; } .brand-name { font-size: 22px; }
  .motion-toggle { min-height: 44px; padding: 6px 14px 6px 12px; font-size: 15px; }
  .hero-spacer { display: block; height: calc(var(--hero-h, 58svh) - 64px); }
  .panel { display: flex; flex-direction: column; width: auto; border-radius: 28px 28px 0 0; padding: var(--s6) var(--s5) calc(96px + env(safe-area-inset-bottom)); gap: var(--s5);
    box-shadow: 0 -1px 0 rgba(255,255,255,.7) inset, 0 -16px 40px -18px rgba(60,40,20,.35); }
  .panel::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 3px; background: #d8cdbd; margin: -10px auto 0; }
  .panel-col { gap: var(--s4); }
  h1 { font-size: 28px; }
  .lede { font-size: 16px; order: 3; margin-top: 0; }
  .panel-main .amount { order: 2; }
  .eyebrow { display: none; }
  .label { font-size: 15px; }
  .step { width: 56px; height: 56px; }
  .field { height: 68px; } .field input { font-size: 52px; height: 64px; line-height: 64px; width: 2.8ch; }
  .chips { gap: 8px; } .chip { min-height: 48px; font-size: 18px; } .chip span { font-size: 14px; }
  .impact { border-top: 1px solid var(--line); padding-top: var(--s4); }
  .impact-line, .checklist .name { font-size: 16px; }
  .checklist { grid-template-columns: 1fr 1fr; column-gap: var(--s3); }
  .checklist li { min-height: 44px; }
  .next { font-size: 16px; }
  /* sticky donate bar, always under the thumb */
  #donate { position: fixed; z-index: 4; left: var(--s4); right: var(--s4); bottom: max(12px, env(safe-area-inset-bottom)); width: auto; min-height: 58px; font-size: 20px; }
  .donate-shelf { display: block; position: fixed; z-index: 3; left: 0; right: 0; bottom: 0; height: calc(84px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--surface) 62%, rgba(255,252,247,0)); pointer-events: none; }
  .vignette { background: radial-gradient(120% 70% at 50% 30%, rgba(0,0,0,0) 55%, rgba(70,45,25,.18) 100%); }
}
@media (hover: none) { .step:hover, .chip:hover { background: var(--surface); } .donate:hover { background: var(--accent); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}
html.motion-off *, html.motion-off *::before, html.motion-off *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }

/* ── clay bevel: controls borrow the soft extruded look of the 3D plaque ── */
.step, .chip, .motion-toggle { box-shadow: inset 0 1.5px 0 rgba(255,255,255,.95), inset 0 -2.5px 0 rgba(110,80,50,.12), 0 2px 5px -1px rgba(90,60,30,.18); }
.step:active, .chip:active { box-shadow: inset 0 2px 3px rgba(110,80,50,.18); }
.chip[aria-pressed="true"] { box-shadow: inset 0 1.5px 0 rgba(255,255,255,.7), inset 0 -2.5px 0 rgba(156,60,23,.18), inset 0 0 0 1px var(--accent), 0 2px 5px -1px rgba(156,60,23,.25); }
.field { box-shadow: inset 0 2px 4px rgba(110,80,50,.14), inset 0 -1px 0 rgba(255,255,255,.8); }
.donate { box-shadow: inset 0 1.5px 0 rgba(255,255,255,.28), inset 0 -4px 0 rgba(70,20,5,.22), 0 12px 24px -12px rgba(181,72,31,.75); }
.donate[aria-disabled="true"] { box-shadow: inset 0 1.5px 0 rgba(255,255,255,.7), inset 0 -3px 0 rgba(110,80,50,.12); }
.brand { box-shadow: inset 0 1.5px 0 rgba(255,255,255,.9), inset 0 -2px 0 rgba(110,80,50,.1), 0 2px 5px -1px rgba(90,60,30,.15); }
.next[hidden] { display: none !important; }

/* short laptop screens (1280×720): tighter rhythm so donate stays above the fold */
@media (min-width: 901px) and (max-height: 760px) {
  .layout { padding: 12px var(--s8) var(--s4); }
  .panel { padding: var(--s5) var(--s6); gap: var(--s3); }
  .panel-col { gap: var(--s3); }
  h1 { font-size: 28px; }
  .lede { font-size: 14px; margin-top: -6px; }
  .field { height: 56px; } .field input { font-size: 44px; height: 54px; line-height: 54px; }
  .step { width: 48px; height: 48px; }
  .chips { margin-top: var(--s2); } .chip { min-height: 40px; }
  .impact { padding-top: var(--s3); } .impact-line { margin-bottom: var(--s2); }
  .checklist li { padding: 2px 0; }
  .next { margin-top: var(--s2); }
  .donate { min-height: 52px; }
}
/* zoomed / very short viewports (e.g. 720×450 at 200%): let the page scroll, keep the number whole */
/* short / 200 %-zoomed screens: like phones — she stays on top, the controls scroll over her */
html.short .layout { display: block; padding: 0 var(--s4) var(--s4); }
html.short .topbar { padding: var(--s2) 0; }
html.short .hero-spacer { display: block; height: calc(var(--hero-h, 60vh) - 60px); }
html.short .panel { width: min(640px, 100%); margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: var(--s5); }
@media (max-height: 420px) { .field input { font-size: 40px; } .field { height: 58px; } }

/* ── round 3 ── */
.xfade { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; }
.xfade.fading, html.motion-off .xfade.fading { transition: opacity 200ms linear !important; }
@media (prefers-reduced-motion: reduce) { .xfade.fading { transition: opacity 200ms linear !important; } }
.checklist li.flash { background: #fdf0d8; box-shadow: 0 0 0 4px #fdf0d8; border-radius: 10px; }
.honesty { margin: calc(-1 * var(--s2)) 0 var(--s3); font-size: 13px; color: var(--ink-3); line-height: 1.5; }
.chip { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; gap: 1px; padding: 5px 4px; }
.chip .chip-amt { font-size: 17px; font-weight: 800; } .chip .chip-amt span { font-size: 12.5px; font-weight: 600; }
.chip small { font-family: var(--font-body); font-weight: 500; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.chip[aria-pressed="true"] small { color: var(--accent-hover); }
@media (min-width: 601px) and (max-width: 900px) { .chip small { white-space: normal; text-align: center; } }
.thanks h2 { margin-top: 0; }
.summary { text-align: start; background: var(--surface-2); border-radius: var(--r-md); padding: var(--s4) var(--s5); margin: var(--s2) 0 var(--s4); box-shadow: inset 0 1.5px 0 rgba(255,255,255,.9), inset 0 -2px 0 rgba(110,80,50,.1); }
.summary p { margin: 0; }
.summary-amt { font-family: var(--font-display); color: var(--ink) !important; } .summary-amt b { font-size: 34px; font-weight: 900; }
.summary-title { font-size: 14px; font-weight: 600; margin-top: var(--s1) !important; }
.summary-items { list-style: none; margin: var(--s2) 0 var(--s3); padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.summary-items li { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border-radius: 999px; padding: 4px 10px 4px 8px; font-size: 14px; font-weight: 500; color: var(--ink); }
.summary-items svg { width: 18px; height: 18px; fill: none; stroke: var(--ok); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.summary-fund { font-size: 13px; color: var(--ink-2) !important; line-height: 1.6; }
@media (max-width: 600px) { .honesty { font-size: 15px; } .chip small { font-size: 13px; } .chip { min-height: 56px; } }

/* skip link (first tab stop) */
.skip { position: absolute; z-index: 10; top: 8px; inset-inline-start: 50%; transform: translate(50%, -160%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 600; text-decoration: none; }
.skip:focus { transform: translate(50%, 0); }
@media (max-width: 600px) { .chips { grid-template-columns: 1fr 1fr; } .chip { flex-direction: row; gap: 8px; min-height: 52px; } }
@media (max-width: 600px) and (max-height: 820px) {
  .panel { gap: var(--s3); padding-top: var(--s5); } .panel-col { gap: var(--s3); }
  h1 { font-size: 25px; }
  .step { width: 50px; height: 50px; } .field { height: 60px; } .field input { font-size: 46px; height: 58px; line-height: 58px; }
  .chip { min-height: 46px; } .chips { gap: 6px; margin-top: var(--s3); }
}
