/* ============================================================================
   donations.css — /donations (Rozliczenie wsparcia). Built from the kit
   (components.css: .page-header, .stats/.stat (Shared/Stat), .meter,
   .notice (Shared/Notice), .card, .chip, .avatar, .table (--hover, --inset,
   --stack, __rank, [data-paginate]), .btn, .pagination, .empty-state,
   .split, .card--lift, .spotlight, .cta-band (Shared/CtaBand), .horizon;
   layout.css: .page-top); this file lays the page out. Tokens only.
   Prefix: don-.

   Motion: the coverage meter is the kit .meter--grow --sheen; the podium
   has ambient loops (edge light, avatar halo, first-place sparkles). All of
   it animates opacity / background-position / clip-path only — no
   transform on text, no blur filter, no will-change — and stops under
   prefers-reduced-motion (§5). No scroll reveal (subpage).

   Contents
     1. Totals          .don-stats, .don-stat (page header row)
     2. Intro           .don-notes, .don-why (kit .split), .don-reason
     3. Donors          .don-podium, .don-place (+ podium light),
                        .don-donor-table
     4. Expenses        .don-expense-table (kit .table--stack on phones)
     5. Lists           .don-table__amount; reduced motion
   .don-list (around a table and its pager) is the scroll target of the kit
   paging (data-paginate-scroll), no styles.
   ========================================================================== */


/* ── 1. Totals (kit .stats hairline row in the page header's toolbar slot) ──
   Three Shared/Stat side by side from 768px (a 2 × 2 grid on phones), the
   first one flush with the header text. Amounts keep to one line; a chip
   in each stat's foot; in the coverage stat the foot holds the kit meter
   (15rem) over the chip.
   The meter's --meter (0–1) is rendered inline by the template, so the fill
   is right without JS; .meter--grow grows it in once (300ms delay, 1.2s,
   ease-out-cubic — the LS.countUp of donations.js uses the same numbers),
   .meter--sheen sweeps a soft light over the filled part. */
.don-stat .stat__value { white-space: nowrap; }
.don-stat--coverage .stat__foot {
  flex-direction: column;
  align-items: flex-start;
  row-gap: var(--space-3);
  margin-top: var(--space-1);
}
.don-stat--coverage .meter { --meter-w: 15rem; }
@media (min-width: 768px) {
  .don-stats > .stat:first-child { padding-left: 0; }
  .don-stats > .stat:last-child { padding-right: 0; }
}
/* Phones (owner, 2026-10-15: three tall stacked rows looked bare): still
   the kit hairline row, laid out as a 2 × 2 grid —
     Zebrano  │ Wydano
     ─────────┴─────────
     % · status chip (right)
     label
     meter across the full width
   (the coverage foot is display: contents, so its meter and chip are
   placed in the stat's grid). Amounts scale with the screen so they stay
   on one line down to 320px; the two chips sit on the bottom edge of
   their cells, level. */
@media (max-width: 767px) {
  .don-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .don-stats > .stat { padding: var(--space-5) 0; }
  .don-stats > .stat + .stat { border-top: 0; }
  .don-stats > .stat:first-child { padding-right: var(--space-4); }
  .don-stats > .stat:nth-child(2) {
    padding-left: var(--space-4);
    border-left: 1px solid var(--line);
  }
  .don-stat .stat__value { font-size: clamp(1.375rem, 6.4vw, 1.75rem); }
  .don-stats > .stat:not(.don-stat--coverage) .stat__foot {
    margin-top: auto;
    padding-top: var(--space-2);
  }
  .don-stats > .don-stat--coverage {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "value foot"
      "label label"
      "meter meter";
    align-items: center;
    column-gap: var(--space-4);
    row-gap: 0.25rem;
    border-top: 1px solid var(--line);
  }
  .don-stat--coverage .stat__value { grid-area: value; }
  .don-stat--coverage .stat__label { grid-area: label; }
  .don-stat--coverage .stat__foot { display: contents; }
  .don-stat--coverage .meter {
    --meter-w: none;
    grid-area: meter;
    margin-top: var(--space-2);
  }
  .don-stat--coverage .chip { grid-area: foot; justify-self: end; }
}


/* ── 2. Intro: notes + why ──────────────────────────────────────────────── */
.don-notes { margin-bottom: var(--space-16); }
.don-notes .notice { height: 100%; }

.don-why__list {
  display: grid;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}
.don-reason {
  flex-direction: row;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-6);
}
.don-reason__text {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: var(--text-strong);
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}
.don-reason__index {
  align-self: flex-start;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
}
@media (hover: hover) and (pointer: fine) {   /* a card hover: mouse only */
  .don-reason:hover .don-reason__index { color: var(--accent-text); }
}
@media (min-width: 1024px) {
  .don-reason { padding: var(--space-6) var(--space-8); }
}
@media (max-width: 767px) {
  .don-notes { margin-bottom: var(--space-12); }
  .don-reason { gap: var(--space-4); padding: var(--space-5); }
  .don-reason__text { font-size: 1.0625rem; }
}


/* ── 3. Donors ──────────────────────────────────────────────────────────── */
.don-podium {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--grid-gap);
  margin: 0 0 var(--space-12);
  padding: 0;
  list-style: none;
}
.don-podium__item { display: flex; min-width: 0; }
.don-podium__item > .don-place { flex: 1 1 auto; }

.don-place {
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-6) var(--space-6);
  text-align: center;
}
.don-place__num {
  position: absolute;
  top: var(--space-3);
  right: var(--space-5);
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-size: 4rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.06em;
  opacity: 0.05;
  pointer-events: none;
}
.don-place__rank { margin-bottom: var(--space-2); }
/* The avatar sits in a badge that also holds its halo (and the sparks). */
.don-place__badge {
  position: relative;
  display: inline-grid;
  place-items: center;
  margin-bottom: var(--space-1);
}
.don-place__avatar { position: relative; z-index: 1; }
.don-place__name {
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--text-strong);
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.don-place__amount {
  margin: 0;
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-size: 1.625rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.don-place__unit { color: var(--text-2); font-size: 0.6em; font-weight: 500; letter-spacing: 0; }
.don-place__coffee { margin-top: var(--space-1); }
.don-place__coffee svg { color: var(--warning-text); }

/* Place tones: violet for the first, blue / orange (the avatar tones of
   Donors.html.twig _places) for the second and third. They feed the ring
   around the avatar and the podium light below. */
.don-place--1 {
  --place-tone: var(--accent-300);
  --place-glow: var(--ambient-violet);
  --place-edge: var(--ambient-violet-soft);
  --place-ring: var(--accent-line);
}
.don-place--2 {
  --place-tone: var(--cat-blue);
  --place-glow: var(--cat-blue-soft);
  --place-edge: var(--cat-blue-soft);
  --place-ring: var(--cat-blue-line);
}
.don-place--3 {
  --place-tone: var(--cat-orange);
  --place-glow: var(--cat-orange-soft);
  --place-edge: var(--cat-orange-soft);
  --place-ring: var(--cat-orange-line);
}

/* First place: raised surface, accent edge, violet underlight, a ring
   around the avatar. Second and third: a thin ring in their tone. */
.don-place--1 {
  background: var(--sheen), var(--surface-2);
  border-color: var(--accent-line);
  box-shadow: var(--highlight-top-strong), var(--shadow-xl), var(--underlight);
}
.don-place--1 .don-place__avatar {
  box-shadow: 0 0 0 4px var(--surface-2), 0 0 0 5px var(--place-ring), var(--underlight-sm);
}
.don-place--2 .don-place__avatar,
.don-place--3 .don-place__avatar {
  box-shadow: 0 0 0 3px var(--surface-1), 0 0 0 4px var(--place-ring);
}
.don-place--1 .don-place__amount { font-size: 2.125rem; }
.don-place--1 .don-place__num { opacity: 0.08; }

/* Podium light — ambient loops, only while the podium is on screen
   ([data-loop] → .is-visible from main.js), never on a ghost card.
   Cheap properties only: background-position on a thin strip at the top
   edge, opacity on the small halo and sparks; nothing translates, no blur
   filter, no will-change. Hover keeps the kit .spotlight only (no lift).
   - Edge light: a short band of the place tone (1px line + a soft falloff
     under it) crosses the top edge, then rests off the card. First place
     every 6s at full strength; second / third slower (9s / 10.5s), dimmer,
     offset so the three never cross together.
   - Halo: a radial glow behind the avatar breathes (opacity); first place
     4s and brighter, second / third 6s / 7s and fainter.
   - Sparks (first place only): three tiny four-point stars next to the
     avatar twinkle in turn (opacity).
   At rest (offscreen, no JS, reduced motion) the band is parked off the
   card, the halo sits at its low point and the sparks are faint and still. */
.don-place--1 { --sweep-dur: 6s;    --sweep-delay: 0.6s; --sweep-opacity: 1;    --sweep-h: 3rem; --halo-min: 0.55; --halo-max: 1;    --halo-dur: 4s; }
.don-place--2 { --sweep-dur: 9s;    --sweep-delay: 2.4s; --sweep-opacity: 0.55; --sweep-h: 2rem; --halo-min: 0.35; --halo-max: 0.75; --halo-dur: 6s; }
.don-place--3 { --sweep-dur: 10.5s; --sweep-delay: 4.8s; --sweep-opacity: 0.55; --sweep-h: 2rem; --halo-min: 0.35; --halo-max: 0.75; --halo-dur: 7s; }

/* Under the content, above the card fill (.spotlight isolates the card). */
.don-place:not(.don-place--ghost)::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: -1;
  height: var(--sweep-h);
  background:
    linear-gradient(90deg, transparent, var(--place-tone), transparent) no-repeat,
    radial-gradient(50% 100% at 50% 0%, var(--place-edge), transparent) no-repeat;
  background-size: 45% 1px, 45% 100%;
  background-position: -100% 0, -100% 0;   /* parked left of the card */
  opacity: var(--sweep-opacity);
  pointer-events: none;
}
.don-podium.is-visible .don-place:not(.don-place--ghost)::after {
  animation: don-edge-sweep var(--sweep-dur) var(--ease-in-out) var(--sweep-delay) infinite;
}
@keyframes don-edge-sweep {
  0%   { background-position: -100% 0, -100% 0; }
  40%  { background-position: 200% 0, 200% 0; }
  100% { background-position: 200% 0, 200% 0; }
}

/* z-index -1: under the chip and name it reaches, over the card fill. */
.don-place__halo {
  position: absolute;
  inset: -45%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--place-glow), transparent);
  opacity: var(--halo-min);
  pointer-events: none;
}
.don-podium.is-visible .don-place__halo {
  animation: don-halo var(--halo-dur) var(--ease-in-out) infinite alternate;
}
@keyframes don-halo {
  from { opacity: var(--halo-min); }
  to   { opacity: var(--halo-max); }
}

.don-place__spark {
  position: absolute;
  z-index: 2;
  width: 0.625rem;
  height: 0.625rem;
  background-color: var(--accent-300);
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
  opacity: 0.4;
  pointer-events: none;
}
.don-place__spark--a { top: -2%; right: -10%; }
.don-place__spark--b { top: 20%; left: -20%; width: 0.4375rem; height: 0.4375rem; }
.don-place__spark--c { bottom: 8%; right: -22%; width: 0.375rem; height: 0.375rem; }
.don-podium.is-visible .don-place__spark {
  animation: don-twinkle 3.6s var(--ease-in-out) infinite;
}
/* Negative delays: the three start at different points of the loop. */
.don-podium.is-visible .don-place__spark--b { animation-delay: -1.2s; }
.don-podium.is-visible .don-place__spark--c { animation-delay: -2.4s; }
@keyframes don-twinkle {
  0%, 100% { opacity: 0; }
  18%      { opacity: 0.9; }
  40%      { opacity: 0; }
}

/* An empty podium step. */
.don-place--ghost {
  background-color: transparent;
  border-style: dashed;
  border-color: var(--line-strong);
  box-shadow: none;
}
.don-place__ghost {
  display: grid;
  place-items: center;
  width: 4.5rem;
  height: 4.5rem;
  margin-bottom: var(--space-1);
  color: var(--text-3);
  border: 1px dashed var(--line-strong);
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 1.5rem;
}
.don-place--ghost .don-place__name { color: var(--text-2); }
.don-place__hint { margin: 0; color: var(--text-3); font-size: var(--fs-sm); }

/* Phones: first place across the full width, second and third side by side. */
@media (max-width: 767px) {
  .don-podium { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
  .don-podium__item--1 { grid-column: 1 / -1; }
  .don-place { padding: var(--space-6) var(--space-3) var(--space-5); gap: var(--space-2); }
  .don-place:not(.don-place--1) .don-place__amount { font-size: 1.25rem; }
  .don-place:not(.don-place--1) .don-place__num { font-size: 2.75rem; right: var(--space-3); }
  .don-place__name { font-size: 1rem; }
}
@media (min-width: 768px) {
  .don-podium {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
  }
  .don-podium__item--1 { order: 2; }
  .don-podium__item--2 { order: 1; }
  .don-podium__item--3 { order: 3; }
  .don-place--1 { padding-block: var(--space-12) var(--space-8); }
}
@media (min-width: 1024px) {
  .don-podium { gap: var(--space-8); max-width: 62rem; margin-inline: auto; }
}

/* The rest: a kit table (.table--hover --inset, .table__rank). */
.don-donor { display: inline-flex; align-items: center; gap: var(--space-3); min-width: 0; }
.don-donor__name { color: var(--text-strong); font-weight: 500; }
.don-coffee {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.don-coffee svg { color: var(--warning-text); }

/* Steady columns while paging: the kit paging (main.js [data-paginate])
   shows one page of rows at a time, and an auto table re-measures its
   columns from the rows on screen — a long name or amount on page 2 moved
   every column. From 768px both tables (donors and expenses, §4) use a fixed
   layout: set widths for #, coffees, category, date and amount (from the
   header cells), the name takes the rest. Phones keep the auto table (the
   expenses are row-cards there anyway). */
@media (min-width: 768px) {
  .don-donor-table,
  .don-expense-table { table-layout: fixed; }
  .don-donor-table .table__rank,
  .don-expense-table .table__rank { width: 4rem; }
  .don-donor-table .don-table__coffee { width: 8rem; }
  .don-donor-table th.is-num,
  .don-expense-table th.is-num { width: 9rem; }
  .don-expense-table .don-expense__cat { width: 11rem; }   /* "Bezpieczeństwo" chip */
  .don-expense-table .don-expense__date { width: 7.5rem; }
  .don-donor__name { overflow-wrap: anywhere; }
}
@media (min-width: 1024px) {
  .don-donor-table .table__rank,
  .don-expense-table .table__rank { width: 4.5rem; }
  .don-donor-table th.is-num,
  .don-expense-table th.is-num { width: 10rem; }
  .don-expense-table .don-expense__date { width: 9rem; }
}

/* Phones: a tighter table without the avatars (the narrow-phone version
   for the whole phone range). */
@media (max-width: 767px) {
  .don-donor-table th,
  .don-donor-table td { padding: 0.75rem 0.5rem; }
  .don-donor-table .table__rank { width: 2rem; }
  .don-donor-table .don-donor .avatar { display: none; }
  .don-donor__name { overflow-wrap: anywhere; }
}


/* ── 4. Expenses ────────────────────────────────────────────────────────────
   The same list as the donors (§3 rules apply to both tables): a category
   disc + name + description, then category, date, amount. Phones: the kit
   .table--stack makes every expense a row-card of its own (disc · name,
   description and a quiet "date · category" line · amount top right); the
   # column and the category / date columns go. */
.don-expense { align-items: flex-start; }
.don-expense .avatar { flex: none; margin-top: 0.125rem; }
.don-expense .avatar svg { width: 0.875rem; height: 0.875rem; }
.don-expense__text { display: flex; flex-direction: column; gap: 0.125rem; min-width: 0; }
.don-expense__desc { color: var(--text-2); font-size: var(--fs-sm); line-height: 1.5; }
.don-expense__when {
  display: none;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}
.don-expense__date {
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 767px) {
  .don-expense-table tbody tr { gap: var(--space-4); }
  .don-expense-table .table__rank,
  .don-expense-table .don-expense__cat,
  .don-expense-table .don-expense__date { display: none; }
  .don-expense-table .don-donor { display: flex; gap: var(--space-3); }
  .don-expense__text { gap: 0.25rem; }
  .don-expense .don-donor__name { line-height: 1.35; }
  .don-expense__when { display: block; margin-top: 0.125rem; color: var(--text-3); }
  .don-expense-table .don-table__amount { padding-top: 0.0625rem; }
}


/* ── 5. Lists, reduced motion ───────────────────────────────────────────────
   Donors and expenses are one system: a card with a kit .table (row hover,
   edge padding: --hover, --inset), then the kit pagination under it (same
   as the library and news). Every row is in the HTML; the kit paging
   (main.js, table[data-paginate]: components.css section 22 — the page
   switch, .is-page-end, .is-entering) shows 15 per page and fills the
   [data-pager]. Without JS — or with a single page — the pager stays
   hidden and every row shows. */
.don-table__amount { color: var(--text-strong); font-weight: 500; white-space: nowrap; }

/* Reduced motion: the podium shows its resting light (the kit meter stands
   at its value, LS.countUp does not run, the kit switches table pages
   without a fade). */
@media (prefers-reduced-motion: reduce) {
  .don-podium.is-visible .don-place:not(.don-place--ghost)::after,
  .don-podium.is-visible .don-place__halo,
  .don-podium.is-visible .don-place__spark { animation: none; }
}
