/* ==========================================================================
   Isometric diorama — donation screen (Team D)
   Tokens first; every colour/size used below comes from here.
   ========================================================================== */
:root {
  /* colour — warm limestone paper, one strong accent (pomegranate clay) */
  --bg: #F4EFE7;
  --bg-glow: #FBF8F3;
  --surface: #FFFFFF;
  --surface-2: #F7F2EA;
  --ink: #1E2833;          /* 14.6:1 on --bg */
  --ink-2: #4F5A66;        /* 6.4:1 on --bg, 7.2:1 on white */
  --line: #E4DACB;
  --line-2: #958670;      /* control borders: ≥3:1 on white and on --bg */
  --track-off: #7D705E;   /* switch track when off: white knob 4.9:1 */
  --accent: #B4432E;       /* white text on it: 5.6:1 */
  --accent-hover: #9C3825;
  --accent-soft: #F8E6DF;
  --accent-ink: #8A3222;   /* 7.0:1 on --accent-soft */
  --muted-btn: #E9E1D5;
  --muted-btn-ink: #5E574C; /* 5.5:1 on --muted-btn */
  --focus: #1F4E8C;

  /* type — Alexandria (display, numbers) + IBM Plex Sans Arabic (UI/body) */
  --font-display: 'Alexandria', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans Arabic', 'Alexandria', system-ui, sans-serif;
  --fs-eyebrow: 14px;
  --fs-h1: 34px;
  --fs-lede: 17px;
  --fs-body: 15px;
  --fs-small: 13px;
  --fs-amount: 30px;

  /* space — 4-pt scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 32px; --s8: 40px;
  --r-sm: 10px; --r-md: 14px; --r-lg: 22px; --r-pill: 999px;

  --shadow-bar: 0 1px 0 rgba(90, 70, 48, 0.04), 0 18px 40px -24px rgba(90, 70, 48, 0.35);

  /* motion tokens (CSS side; the item choreography lives in app.js MOTION → motion-spec.json) */
  --dur-ui: 160ms;
  --ease-ui: cubic-bezier(0.2, 0, 0, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(56% 52% at 50% 48%, var(--bg-glow) 0%, rgba(251, 248, 243, 0) 72%);
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; inset-inline-start: var(--s4); top: -60px; z-index: 10; background: var(--ink); color: #fff; padding: var(--s2) var(--s4); border-radius: var(--r-sm); text-decoration: none; }
.skip:focus { top: var(--s3); }

/* ---------------------------------------------------------------- top bar */
.topbar {
  width: 100%; max-width: 1360px; margin-inline: auto;
  height: 56px; padding-inline: var(--s8);
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: var(--s2); }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.motion-toggle {
  display: inline-flex; align-items: center; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s3) 0 var(--s4);
  border: 1px solid var(--line-2); border-radius: var(--r-pill);
  background: var(--surface); font-size: 14px; font-weight: 500; color: var(--ink);
  transition: background-color var(--dur-ui) var(--ease-ui), border-color var(--dur-ui) var(--ease-ui);
}
.motion-toggle:hover { background: var(--surface-2); }
.switch { position: relative; width: 34px; height: 20px; border-radius: var(--r-pill); background: var(--track-off); transition: background-color var(--dur-ui) var(--ease-ui); flex: none; }
.knob { position: absolute; top: 3px; inset-inline-start: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); transition: transform var(--dur-ui) var(--ease-ui); }
.motion-toggle[aria-checked="true"] .switch { background: var(--ink); }
.motion-toggle[aria-checked="true"] .knob { transform: translateX(-14px); }

/* ---------------------------------------------------------------- page */
.page {
  flex: 1; width: 100%;
  display: grid; grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "intro" "stage" "panel" "bar";
  justify-items: center; align-content: start; row-gap: var(--s3);
  padding: 0 var(--s8) var(--s5);
}
.intro { grid-area: intro; text-align: center; max-width: 760px; }
.eyebrow { margin: 0; font-size: var(--fs-eyebrow); font-weight: 600; color: var(--accent-ink); display: inline-flex; align-items: center; gap: var(--s2); }
.eyebrow-mark { width: 8px; height: 8px; border-radius: 2px; background: var(--accent); transform: rotate(45deg); flex: none; }
h1 { margin: var(--s2) 0 var(--s1); font-family: var(--font-display); font-weight: 600; font-size: var(--fs-h1); line-height: 1.3; letter-spacing: 0; text-wrap: balance; }
.lede { margin: 0; font-size: var(--fs-lede); line-height: 1.6; color: var(--ink-2); text-wrap: balance; }

/* ---------------------------------------------------------------- stage */
.stage { grid-area: stage; margin: 0; display: flex; justify-content: center; min-width: 0; }
.scene { display: block; height: clamp(280px, calc(100svh - 412px), 640px); width: auto; max-width: 100%; overflow: visible; }

/* ---------------------------------------------------------------- impact panel (live text + what is in the scene) */
.panel { grid-area: panel; width: min(1180px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title items-title" "impact items" "next items"; column-gap: var(--s7); align-items: start; }
.panel-title, .items-title { margin: 0 0 var(--s1); font-size: 14px; font-weight: 600; color: var(--ink-2); }
.panel-title { grid-area: title; }
.items-title { grid-area: items-title; }
.impact-main { grid-area: impact; margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 18px; line-height: 1.5; color: var(--ink); text-wrap: balance; }
.impact-next { grid-area: next; margin: var(--s1) 0 0; font-size: 16px; line-height: 1.5; color: var(--ink-2); display: flex; align-items: center; gap: var(--s2); }
.next-dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--ink-2); flex: none; }
.impact-next.is-complete .next-dot { background: var(--ink-2); }
.items { grid-area: items; list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); max-width: 420px; }
.items li { display: flex; align-items: center; gap: var(--s2); font-size: 16px; line-height: 1.4; color: var(--ink-2); }
.tick { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--line-2); display: grid; place-items: center; color: transparent; flex: none; transition: background-color var(--dur-ui) var(--ease-ui), border-color var(--dur-ui) var(--ease-ui); }
.items li[data-on="true"] { color: var(--ink); font-weight: 500; }
.items li[data-on="true"] .tick { background: var(--ink); border-color: var(--ink); color: #fff; }

/* animation hooks on SVG layers (transform-box so origins are local to each layer) */
.scene .item, .scene #clothes-everyday, .scene #sneakers, .scene .book, .scene .part { transform-box: fill-box; }
.scene #bag { transform-origin: 50% 100%; }
.scene #eyes { transform-box: fill-box; transform-origin: 50% 50%; }
.scene .breathe { transform-box: fill-box; transform-origin: 50% 100%; }
.scene #head { transform-box: fill-box; transform-origin: 45% 92%; }
.scene .arm-l, .scene .hand-l { transform-box: fill-box; }

/* ---------------------------------------------------------------- control bar */
.bar {
  grid-area: bar;
  width: min(1180px, 100%);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3) var(--s5);
  padding: var(--s3) var(--s4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-bar);
}
.amount { display: flex; align-items: center; gap: var(--s3); flex: none; }
.amount-label { font-size: var(--fs-small); font-weight: 600; color: var(--ink-2); }
.stepper { display: flex; align-items: center; gap: var(--s2); }
.step {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%; border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink);
  transition: background-color var(--dur-ui) var(--ease-ui), transform var(--dur-ui) var(--ease-ui), opacity var(--dur-ui) var(--ease-ui);
}
.step:hover { background: var(--surface-2); }
.step:active { transform: scale(0.94); }
.step[aria-disabled="true"] { opacity: 0.38; cursor: not-allowed; }
.step[aria-disabled="true"]:active { transform: none; }
.field {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 132px; height: 52px; padding: 0 var(--s3);
  background: var(--surface-2); border: 1.5px solid var(--line-2); border-radius: var(--r-md);
  transition: border-color var(--dur-ui) var(--ease-ui);
}
.field:focus-within { border-color: var(--focus); outline: 3px solid var(--focus); outline-offset: 3px; }
.field input {
  width: 3.2ch; border: 0; background: transparent; padding: 0; margin: 0;
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-amount); line-height: 52px; height: 52px;
  text-align: center; font-variant-numeric: tabular-nums; direction: ltr; color: var(--ink);
}
.field input:focus-visible { outline: none; }
.unit { font-size: 14px; line-height: 1; color: var(--ink-2); white-space: nowrap; padding-top: 4px; }

.chips { display: flex; gap: var(--s2); flex: none; }
.chip {
  height: 44px; padding: 0 14px;
  border-radius: var(--r-pill); border: 1.5px solid var(--line-2); background: var(--surface);
  font-weight: 600; font-size: var(--fs-body); white-space: nowrap;
  transition: background-color var(--dur-ui) var(--ease-ui), border-color var(--dur-ui) var(--ease-ui), color var(--dur-ui) var(--ease-ui);
}
.chip-n { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.chip-u { font-weight: 400; font-size: var(--fs-small); color: var(--ink-2); }
.chip:hover { background: var(--surface-2); }
@media (hover: none) { .step:hover, .chip:hover { background: var(--surface); } }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.chip[aria-pressed="true"] .chip-u { color: var(--accent-ink); }


.donate {
  flex: 1 1 220px; max-width: 300px; min-width: 200px; height: 56px; padding: 0 var(--s6);
  border: 0; border-radius: var(--r-md);
  background: var(--accent); color: #fff;
  font-family: var(--font-display); font-weight: 600; font-size: 17px; white-space: nowrap;
  transition: background-color var(--dur-ui) var(--ease-ui), transform var(--dur-ui) var(--ease-ui);
}
.donate:hover { background: var(--accent-hover); }
.donate:active { transform: scale(0.98); }
.donate[aria-disabled="true"] { background: var(--muted-btn); color: var(--muted-btn-ink); cursor: not-allowed; }
.donate[aria-disabled="true"]:active { transform: none; }

/* ---------------------------------------------------------------- dialog */
.dialog {
  width: min(440px, calc(100vw - 32px)); padding: var(--s7) var(--s7) var(--s6);
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: var(--ink);
  text-align: center; box-shadow: 0 30px 80px -30px rgba(40, 30, 20, 0.45);
}
.dialog::backdrop { background: rgba(30, 40, 51, 0.38); }
.dialog h2 { margin: var(--s3) 0 var(--s2); font-family: var(--font-display); font-weight: 600; font-size: 24px; }
.dialog p { margin: 0 0 var(--s2); line-height: 1.7; }
.dialog-note { font-size: var(--fs-small); color: var(--ink-2); }
.dialog-close { margin-top: var(--s4); height: 48px; min-width: 140px; border: 0; border-radius: var(--r-md); background: var(--ink); color: #fff; font-weight: 600; }
.dialog[open] { animation: dialog-in 280ms cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- wide desktop: scene on one side, headline + impact panel on the other, controls underneath both */
@media (min-width: 1301px) {
  .page {
    grid-template-columns: minmax(340px, 400px) auto;
    grid-template-rows: auto 1fr auto;
    grid-template-areas: "intro stage" "panel stage" "bar bar";
    justify-content: center; justify-items: stretch; column-gap: 64px; row-gap: 0;
  }
  .intro { text-align: start; max-width: none; align-self: end; padding-bottom: var(--s6); }
  .intro h1 { font-size: 36px; }
  .stage { justify-content: center; }
  .scene { height: clamp(420px, calc(100svh - 204px), 780px); }
  .panel {
    width: auto; align-self: start;
    grid-template-columns: 1fr; grid-template-areas: "title" "impact" "next" "items-title" "items";
    padding: var(--s5) var(--s6); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-bar);
  }
  .impact-main { font-size: 20px; }
  .items-title { margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--line); }
  .items { flex-direction: column; gap: var(--s2); }
  .bar { width: 100%; margin-top: var(--s4); }
}
@media (min-width: 1301px) and (min-height: 850px) {
  .scene { height: clamp(420px, calc(100svh - 186px), 780px); }
  .bar { margin-top: var(--s2); }
}

/* ---------------------------------------------------------------- tablet & narrow desktop: stacked, panel + bar under the scene */
@media (max-width: 1300px) {
  .bar { padding: var(--s3) var(--s4); }
}
@media (max-width: 900px) {
  :root { --fs-h1: 28px; --fs-lede: 16px; }
  .topbar { padding-inline: var(--s6); }
  .page { padding: 0 var(--s6) var(--s5); }
  .scene { height: clamp(300px, calc(100svh - 480px), 640px); }
  .panel { grid-template-columns: 1fr; grid-template-areas: "title" "impact" "next" "items"; }
  .items-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .items { margin-top: var(--s2); max-width: none; gap: var(--s2) var(--s4); }
  .items li { font-size: 15px; }
  .amount-label { display: none; }
  .chip { padding: 0 var(--s3); }
  .donate { max-width: none; flex-basis: 100%; }
}
@media (max-width: 640px) {
  .chips { justify-content: center; flex-wrap: wrap; }
  .amount { justify-content: center; width: 100%; }
  .topbar { padding-inline: var(--s4); }
  .page { padding: 0 var(--s4) var(--s4); }
  .scene { height: auto; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
