/* =========================================================================
 * Donation statistics page — /statistics (page-donation.php)
 * Brand-red, dignified. main.css carries the ranking/podium + progress-bar
 * base styles reused here; this sheet adds the page layout and the hero look.
 * Scoped to body.y70-stats-page / main.y70-stats.
 * ========================================================================= */

.y70-stats{ background: var(--bg); }

/* The inner header is sticky/in-flow (it sits over the light strip ABOVE the
   hero, not over the red hero), so it keeps its normal dark-on-light treatment
   at the top and the global maroon bar when scrolled — no overrides needed. */

/* ============================== HERO ============================== */
.y70-stats-hero{
  position: relative;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(135deg, #6c0019 0%, #7E001D 46%, #A72D33 100%);
  padding: clamp(54px, 8vw, 96px) 0 clamp(74px, 9vw, 108px);
}
.y70-stats-hero::before{ /* gold hairline along the very top */
  content: "";
  position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, transparent, #f0b323, #ffd76a, #f0b323, transparent);
  z-index: 3;
}
.y70-stats-hero__bg{ position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.y70-stats-hero__bg::before{ /* soft light + vignette */
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(58% 78% at 86% 16%, rgba(255,255,255,.12), transparent 60%),
    radial-gradient(46% 64% at 6% 104%, rgba(0,0,0,.30), transparent 70%);
}
.y70-stats-hero__bg::after{ /* faint concentric medallion (engineering seal feel) */
  content: ""; position: absolute; right: -130px; top: 50%; transform: translateY(-50%);
  width: 540px; height: 540px; border-radius: 50%; opacity: .85;
  background:
    radial-gradient(circle, transparent 0 37%, rgba(255,255,255,.07) 37% 38%, transparent 38%),
    radial-gradient(circle, transparent 0 47%, rgba(255,255,255,.06) 47% 48%, transparent 48%),
    radial-gradient(circle, transparent 0 57%, rgba(240,179,35,.12) 57% 58.4%, transparent 58.4%);
}
.y70-stats-hero__inner{
  position: relative; z-index: 2;
  max-width: 780px; text-align: center;
}
.y70-stats-eyebrow{
  margin: 0 0 14px; font-size: 13px; font-weight: 800;
  letter-spacing: .14em; color: #ffd76a;
}
.y70-stats-title{
  margin: 0 0 14px; line-height: 1.08; font-weight: 800;
  font-size: clamp(30px, 5vw, 52px);
}
.y70-stats-lead{
  margin: 0 auto; max-width: 640px;
  font-size: clamp(15px, 1.7vw, 18px); line-height: 1.62;
  color: rgba(255,255,255,.86);
}

.y70-stats-totalwrap{ margin-top: clamp(26px, 4vw, 40px); }
.y70-stats-total{
  display: flex; align-items: flex-start; justify-content: center; gap: 10px;
}
.y70-stats-total .y70-total-amount{
  font-weight: 800; line-height: .98; letter-spacing: -.012em; color: #fff;
  font-size: clamp(42px, 8.4vw, 88px);
  text-shadow: 0 6px 30px rgba(0,0,0,.30);
}
.y70-stats-total .y70-total-dec{ font-size: .42em; font-weight: 700; color: rgba(255,255,255,.72); }
.y70-stats-total__unit{ margin-top: .7em; font-size: clamp(15px, 1.6vw, 21px); font-weight: 700; color: rgba(255,255,255,.85); }
.y70-stats-goalline{ margin-top: 10px; font-size: 15px; color: rgba(255,255,255,.82); }
.y70-stats-goalline strong{ color: #ffd76a; font-weight: 800; }

.y70-stats-progress{ max-width: 560px; margin: clamp(26px, 4vw, 38px) auto 0; }
.y70-stats-hero .y70-progress-track{
  height: 22px; border-radius: 999px;
  background: rgba(255,255,255,.16);
  box-shadow: inset 0 1px 3px rgba(0,0,0,.28);
}
.y70-stats-hero .y70-progress-fill{
  border-radius: 999px; padding-right: 12px;
  background: linear-gradient(90deg, #f0b323, #ffd76a);
  box-shadow: 0 0 18px rgba(240,179,35,.5);
}
.y70-stats-hero .y70-progress-fill::after{ opacity: .45; }
.y70-stats-hero .y70-progress-label{ font-size: 12px; font-weight: 800; }
.y70-stats-hero .y70-progress-label--current{ color: #5a3a00; }
.y70-stats-hero .y70-progress-label--target{ right: 12px; color: rgba(255,255,255,.82); }
.y70-stats-progress__meta{ display: flex; align-items: baseline; justify-content: center; gap: 10px; margin-top: 12px; }
.y70-stats-pct{ font-size: 22px; font-weight: 800; color: #ffd76a; }
.y70-stats-progress__caption{ font-size: 13.5px; color: rgba(255,255,255,.72); }

.y70-stats-updated{
  display: inline-flex; align-items: center; gap: 8px;
  margin: 22px 0 0; font-size: 13px; color: rgba(255,255,255,.72);
}
.y70-stats-dot{ width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 4px rgba(61,220,132,.18); }

/* ============================== KPIs ============================== */
.y70-stats-kpis{
  position: relative; z-index: 3;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-top: clamp(-56px, -6vw, -44px);
}
.y70-stats-kpi{
  background: var(--card); border: 1px solid var(--border); border-top: 3px solid var(--primary);
  border-radius: 16px; padding: 20px 18px;
  box-shadow: 0 18px 44px rgba(126,0,29,.10);
  display: flex; flex-direction: column; gap: 6px;
}
.y70-stats-kpi__icon{
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px; margin-bottom: 4px;
  background: color-mix(in srgb, var(--primary) 9%, var(--card));
  color: var(--primary);
}
.y70-stats-kpi__icon svg{ width: 22px; height: 22px; display: block; }
.y70-stats-kpi__value{ font-size: clamp(25px, 3.2vw, 36px); font-weight: 800; color: var(--primary); line-height: 1; }
.y70-stats-kpi__value small{ font-size: .5em; font-weight: 700; }
.y70-stats-kpi__label{ font-size: 13.5px; font-weight: 600; color: var(--muted); }

.y70-stats-kpis.y70-stats-kpis--3{ grid-template-columns: repeat(3, 1fr); }

.y70-stats-kpis-note{
  margin: 10px auto 0; text-align: center;
  font-size: 12.5px; color: var(--muted);
}
.y70-stats-kpis-note strong{ color: var(--primary); font-weight: 700; }

/* countdown — its own full-width card (was one of 4 cramped KPI tiles) so the
   days + running clock actually have room to breathe. Gold accent keeps it
   visually distinct from the red metric cards above. */
.y70-stats-countdown{
  display: flex; align-items: center; gap: 20px;
  background: var(--card); border: 1px solid var(--border); border-top: 3px solid #f0b323;
  border-radius: 16px; padding: 22px 26px;
  box-shadow: 0 18px 44px rgba(126,0,29,.10);
  margin-top: 18px;
}
.y70-stats-countdown__icon{
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: 14px;
  background: color-mix(in srgb, #f0b323 18%, var(--card)); color: #b9810a;
}
.y70-stats-countdown__icon svg{ width: 28px; height: 28px; display: block; }
.y70-stats-countdown__body{ display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.y70-stats-countdown__label{ font-size: 13.5px; font-weight: 600; color: var(--muted); order: 2; }
.y70-stats-countdown__value{
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; order: 1;
}
.y70-cd-days{ font-size: clamp(28px, 4vw, 40px); font-weight: 800; color: var(--primary); line-height: 1; }
.y70-stats-countdown__value > small{ font-size: 15px; font-weight: 700; color: var(--primary); }
.y70-cd-hms{
  font-weight: 700; font-size: clamp(14px, 1.6vw, 17px); color: #b9810a;
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
}

@media (max-width: 560px){
  .y70-stats-countdown{ flex-direction: column; align-items: flex-start; gap: 12px; padding: 18px; }
}

/* ============================ BLOCKS ============================= */
.y70-stats-block{ padding-top: clamp(44px, 6vw, 72px); }
.y70-stats-blockhead{ max-width: 720px; margin: 0 auto clamp(24px, 4vw, 40px); text-align: center; }
.y70-stats-h2{
  position: relative; display: inline-block; margin: 0;
  font-size: clamp(22px, 2.6vw, 30px); font-weight: 800; color: var(--dark);
}
.y70-stats-h2::after{
  content: ""; display: block; width: 54px; height: 3px; margin: 12px auto 0; border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-600));
}
.y70-stats-blocksub{ margin: 14px 0 0; font-size: 15px; color: var(--muted); }
.y70-stats-empty{ text-align: center; color: var(--muted); padding: 28px 0; }

/* --------------------------- by purpose -------------------------- */
.y70-stats-purposes{
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  padding: clamp(22px, 3vw, 34px);
  box-shadow: 0 20px 50px rgba(42,44,47,.07);
  display: grid; gap: 20px;
}
.y70-stats-purpose__top{ display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 9px; }
.y70-stats-purpose__name{ font-weight: 700; font-size: 16px; color: var(--dark); }
.y70-stats-purpose__amt{ white-space: nowrap; font-weight: 800; font-size: 16px; color: var(--primary); }
.y70-stats-purpose__amt small{ font-size: .74em; font-weight: 600; color: var(--muted); }
.y70-stats-purpose__bar{
  height: 12px; border-radius: 999px; overflow: hidden;
  background: color-mix(in srgb, var(--primary) 8%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--primary) 12%, var(--border));
}
.y70-stats-purpose__fill{
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--primary-600));
  box-shadow: 0 1px 8px rgba(126,0,29,.30);
}
.y70-stats-purpose__pct{ display: block; margin-top: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); }

/* ----------------------- department ranking ---------------------- */
.y70-stats-rank .y70-podium-board{ margin-bottom: 22px; }

/* ------------------------- per-year breakdown -------------------- */
.y70-stats-years{
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  margin-bottom: 22px; padding-bottom: 20px;
  border-bottom: 1px dashed color-mix(in srgb, var(--primary) 18%, var(--border));
}
.y70-stats-yearchip{
  display: inline-flex; align-items: baseline; gap: 8px;
  padding: 8px 16px; border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 6%, var(--card));
  border: 1px solid color-mix(in srgb, var(--primary) 16%, var(--border));
}
.y70-stats-yearchip__yr{ font-weight: 800; font-size: 13px; color: var(--primary); }
.y70-stats-yearchip__amt{ font-weight: 700; font-size: 14px; color: var(--dark); }
.y70-stats-yearchip__amt small{ font-size: .78em; font-weight: 600; color: var(--muted); }

/* --------------------- monthly trend (interactive) --------------- */
.y70-stats-trend{
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  padding: clamp(24px, 3vw, 34px) clamp(14px, 2.2vw, 26px);
  box-shadow: 0 20px 50px rgba(42,44,47,.07);
}
.y70-stats-trend__bar{
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.y70-stats-trend__toggle{
  display: inline-flex; padding: 4px; gap: 4px; border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 7%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--primary) 14%, var(--border));
}
.y70-stats-trend__toggle button{
  -webkit-appearance: none; appearance: none; cursor: pointer;
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 18px; border-radius: 999px; font: inherit; font-weight: 700; font-size: 13.5px;
  transition: background .2s ease, color .2s ease, box-shadow .2s ease;
}
.y70-stats-trend__toggle button.is-active{
  background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(126,0,29,.28);
}
.y70-stats-trend__hint{ font-size: 12.5px; color: var(--muted); }

.y70-stats-trend__plot{ position: relative; padding-top: 82px; }
.y70-stats-trend__chart{
  display: flex; align-items: flex-end; gap: clamp(10px, 2vw, 26px);
  height: 300px; width: 100%;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.y70-stats-col{
  -webkit-appearance: none; appearance: none; background: transparent; border: 0; margin: 0; padding: 0;
  font: inherit; color: inherit; cursor: pointer; text-align: center;
  flex: 1 1 0; min-width: 48px; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px;
  transition: opacity .2s ease;
}
.y70-stats-col__val{ flex: 0 0 auto; font-size: 12px; font-weight: 800; color: var(--primary); transition: color .2s ease; }
.y70-stats-col__bar{
  flex: 0 0 auto; width: clamp(26px, 4vw, 54px); min-height: 4px; max-height: calc(100% - 50px);
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, var(--primary-600), var(--primary));
  box-shadow: 0 6px 16px rgba(126,0,29,.22);
  transition: height .5s cubic-bezier(.2,.7,.2,1), filter .2s ease, transform .2s ease;
}
.y70-stats-col__label{ flex: 0 0 auto; font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; transition: color .2s ease; }
.y70-stats-col:hover .y70-stats-col__bar,
.y70-stats-col:focus-visible .y70-stats-col__bar,
.y70-stats-col.is-active .y70-stats-col__bar{ filter: brightness(1.12) saturate(1.05); transform: translateY(-2px); }
.y70-stats-col.is-active .y70-stats-col__label{ color: var(--primary); font-weight: 800; }
.y70-stats-col.is-dim{ opacity: .42; }
.y70-stats-col:focus-visible{ outline: none; }

/* hover/tap tooltip */
.y70-stats-tip{
  position: absolute; z-index: 5; left: 0; top: 0;
  transform: translate(-50%, calc(-100% - 12px));
  min-width: 132px; padding: 10px 14px; border-radius: 12px; pointer-events: none;
  display: flex; flex-direction: column; gap: 2px; text-align: center;
  background: var(--primary); color: #fff;
  box-shadow: 0 14px 30px rgba(126,0,29,.34);
}
.y70-stats-tip::after{
  content: ""; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%) rotate(45deg);
  width: 12px; height: 12px; background: var(--primary); border-radius: 0 0 3px 0;
}
.y70-stats-tip[hidden]{ display: none; }
.y70-stats-tip__title{ font-size: 12px; font-weight: 700; color: #ffd76a; }
.y70-stats-tip__val{ font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.y70-stats-tip__sub{ font-size: 11.5px; color: rgba(255,255,255,.8); }

/* ============================ CTA band =========================== */
.y70-stats-ctaband{
  position: relative; margin-top: clamp(48px, 7vw, 82px); color: #fff;
  background: linear-gradient(135deg, #7E001D, #A72D33);
}
/* the CTA band is the page's last block and flows straight into the footer —
   drop the footer's usual top gap so there's no empty strip below it */
body.y70-stats-page .y70-foot{ margin-top: 0; }
.y70-stats-ctaband::before{
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, transparent, #f0b323, #ffd76a, #f0b323, transparent);
}
.y70-stats-ctaband__inner{
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  padding: clamp(32px, 5vw, 54px) 0;
}
.y70-stats-ctaband__text h2{ margin: 0 0 6px; font-size: clamp(22px, 2.8vw, 30px); font-weight: 800; }
.y70-stats-ctaband__text p{ margin: 0; color: rgba(255,255,255,.82); }
.y70-stats-ctaband__actions{ display: flex; gap: 12px; flex-wrap: wrap; }
.y70-stats-btn{
  display: inline-flex; align-items: center; justify-content: center;
  padding: 13px 26px; border-radius: 999px; font-weight: 800; font-size: 15px;
  transition: transform .15s ease, box-shadow .15s ease, background .2s ease;
}
.y70-stats-btn--solid{ background: #fff; color: var(--primary); box-shadow: 0 10px 24px rgba(0,0,0,.18); }
.y70-stats-btn--solid:hover{ transform: translateY(-2px); color: var(--primary); }
.y70-stats-btn--ghost{ background: rgba(255,255,255,.12); color: #fff; border: 1.5px solid rgba(255,255,255,.55); }
.y70-stats-btn--ghost:hover{ transform: translateY(-2px); background: rgba(255,255,255,.2); color: #fff; }

.y70-stats-note{
  margin: clamp(26px, 4vw, 40px) auto clamp(40px, 6vw, 64px);
  font-size: 12.5px; line-height: 1.6; color: var(--muted); text-align: center; max-width: 880px;
}

/* ============================ responsive ========================= */
@media (max-width: 900px){
  /* .y70-stats-kpis--3 repeats the container class (specificity 0,2,0), same
     as its own base rule at .y70-stats-kpis.y70-stats-kpis--3 above — needed
     because a bare `.y70-stats-kpis{...}` here (0,1,0) can never beat that
     rule regardless of source order, so the 3-card row was stuck at 3 columns
     (never dropping to 2) all the way down to phone widths. */
  .y70-stats-kpis,
  .y70-stats-kpis.y70-stats-kpis--3{ grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px){
  .y70-stats-kpis{ gap: 12px; margin-top: -36px; }
  .y70-stats-hero__bg::after{ display: none; }
  .y70-stats-ctaband__inner{ flex-direction: column; align-items: center; text-align: center; }
  .y70-stats-purpose__top{ flex-direction: column; gap: 2px; }
  .y70-stats-trend__chart{ height: 250px; }
}
@media (max-width: 480px){
  /* Phone-width stack (e.g. iPhone SE 375px): 2 columns is still cramped for
     3-4 cards with an icon + a 2-3 digit value each, so fall all the way to
     a single column here instead. */
  .y70-stats-kpis,
  .y70-stats-kpis.y70-stats-kpis--3{ grid-template-columns: 1fr; }

  /* Monthly-trend bar chart: on an iPhone SE (375px) the 6 columns' natural
     width (6 × 48px min-width + 5 × 10px gap ≈ 338px) is wider than the
     card's own content box (~317px after page + card padding) — it used to
     spill past the card edge instead of scrolling internally (the chart had
     `min-width:max-content`, which fights its own `overflow-x:auto` by
     refusing to ever be narrower than its content — fixed above, all
     widths). Tightened here on top of that fix so 6 months fit with room to
     spare and don't need horizontal scrolling on a phone at all: narrower
     gap/columns/bars, and the month label wraps to 2 lines ("พ.ย." / "68")
     instead of forcing extra column width to stay on one line. */
  .y70-stats-trend__chart{ gap: 6px; }
  .y70-stats-col{ min-width: 34px; }
  .y70-stats-col__bar{ width: clamp(16px, 5.5vw, 40px); }
  .y70-stats-col__val{ font-size: 10.5px; }
  .y70-stats-col__label{ white-space: normal; max-width: 34px; font-size: 10px; line-height: 1.15; }
}

@media (prefers-reduced-motion: reduce){
  .y70-stats-hero .y70-progress-fill::after{ animation: none; display: none; }
  .y70-stats-btn:hover, .y70-stats-col:hover .y70-stats-col__bar{ transform: none; filter: none; }
  .y70-stats-col__bar{ transition: filter .2s ease; }
}
