/* home.css — หน้าแรกแบบ landing page
 *
 * ต่อยอดภาษาภาพจาก registry.css: ฉากทุ่งนาที่ทอดไปหาเส้นขอบฟ้าด้วย perspective จริง
 * การ์ดกระจกบนพื้นมืด และแถบข้อมูลที่โตจากซ้ายไปขวา
 *
 * สองข้อที่ต้องถือไว้เหมือนหน้าทะเบียน และห้ามให้ความสวยมากลบ
 *   1. ตัวเลขชุดไหนบวกกันได้ ชุดไหนบวกไม่ได้ ต้องบอกตรง ๆ (.lnote--warn)
 *   2. "ไม่ระบุ" ไม่ใช่ศูนย์ ต้องมองเห็นเสมอ
 *
 * ทุก animation อยู่ใต้ @media (prefers-reduced-motion: no-preference)
 * และเคารพสวิตช์ปิดการเคลื่อนไหวใน a11y toolbar ([data-motion="off"])
 */

.lsec { position: relative; }
.lsec--tint { background: linear-gradient(180deg, var(--color-paper-2), var(--color-paper)); }

.eyebrow {
  display: inline-flex; align-items: center; gap: var(--space-xs);
  font-family: var(--font-mono); font-size: var(--text-2xs); letter-spacing: 0.12em;
  color: var(--color-accent); text-transform: uppercase;
  /* ป้ายลำดับกับหัวเรื่องเคยชนกันพอดี 0px ทุก section — ตัว eyebrow ไม่มี margin-bottom
     และ h2 ไม่มี margin-top ตัวอักษรสองบรรทัดจึงติดกันจนอ่านเหมือนทับ */
  margin-block-end: var(--space-sm);
}
.eyebrow::before { content: ''; inline-size: 2rem; block-size: 2px; background: currentColor; }

/* ปุ่มท้าย section ที่ผู้ดูแลตั้งข้อความและปลายทางเองได้ (เช่น "ดูข่าวทั้งหมด") */
.sec__acts { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-block-start: var(--space-lg); }

.lpill {
  display: inline-flex; align-items: baseline; gap: var(--space-xs);
  margin-block-start: var(--space-md);
  padding: var(--space-2xs) var(--space-md); border-radius: 999px;
  background: var(--color-accent-tint); color: var(--color-accent-deep);
  font-size: var(--text-sm); font-weight: 500;
}
.lpill b { font-family: var(--font-mono); font-size: var(--text-md); }

/* ═══════════════════ ① ฉากหัวเรื่อง ═══════════════════ */

.lhero {
  position: relative; isolation: isolate; overflow: hidden;
  padding-block: clamp(3rem, 7vw, 5.5rem) clamp(2.5rem, 5vw, 4rem);
  color: var(--dm-ink, #eef3ee);
  --lh-deep: oklch(15.5% 0.038 160);
  --lh-mid:  oklch(23% 0.055 152);
  --lh-lit:  oklch(60% 0.120 128);
  --lh-glow: oklch(82% 0.160 140);
  --lh-sun:  oklch(88% 0.130 85);
  --mx: 0; --my: 0;              /* ตำแหน่งเมาส์ — home.js เขียนค่าให้ */
  /* ความสูงของแถบทุ่งข้าวด้านล่าง
     เดิม 11vh ซึ่งบนจอ 900px สูง 99px แต่ใต้การ์ด KPI เหลือที่ว่างแค่ 26px
     ต้นข้าวจึงงอกขึ้นหลังการ์ดใบล่าง การ์ดโปร่งแสงอยู่แล้วจึงอ่านตัวเลขยาก
     หัวเรื่องขยายลงไม่ได้เพราะโหมดเล่าเรื่องตรึงไว้ที่หนึ่งจอพอดี จึงลดความสูงแถบแทน */
  --lh-field-h: clamp(3.5rem, 7vh, 5rem);
}
.lhero__sky {
  position: absolute; inset: 0; z-index: -6;
  background:
    radial-gradient(128% 84% at 50% 112%, var(--lh-lit) 0%, transparent 56%),
    linear-gradient(178deg, var(--lh-deep) 0%, var(--lh-mid) 58%, var(--lh-lit) 100%);
}
.lhero__sun {
  position: absolute; inset-block-start: -8%; inset-inline-start: 62%; z-index: -5;
  inline-size: 38rem; block-size: 38rem; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in oklab, var(--lh-sun) 60%, transparent) 0%, transparent 66%);
  translate: calc(var(--mx) * -34px) calc(var(--my) * -22px);
  transition: translate 0.5s var(--ease-out);
}
/* ระนาบทุ่งที่ทอดไปหาเส้นขอบฟ้า — ลายเส้นอยู่ในลูกเพื่อให้เลื่อนด้วย transform (ไม่ repaint ทั้งผืน) */
.lhero__field {
  position: absolute; inset-inline: -22%; inset-block-end: -14%; block-size: 58%; z-index: -4;
  transform: perspective(340px) rotateX(64deg); transform-origin: 50% 100%;
  mask-image: linear-gradient(to top, #000 16%, transparent 92%);
  overflow: hidden;
  --drift-y: 5rem;
}
.lhero__field > i,
.lstage__grid > i {
  position: absolute; inset-inline: 0;
  inset-block-start: calc(var(--drift-y) * -1);
  block-size: calc(100% + var(--drift-y));
  background-image:
    repeating-linear-gradient(90deg, transparent 0 3.2rem,
      color-mix(in oklab, var(--lh-deep, #000) 46%, transparent) 3.2rem 3.35rem),
    repeating-linear-gradient(0deg, transparent 0 2.4rem,
      color-mix(in oklab, var(--lh-deep, #000) 34%, transparent) 2.4rem 2.5rem);
}

.lhero__motes { position: absolute; inset: 0; z-index: -3; pointer-events: none; }
.lhero__motes i {
  position: absolute; inset-block-end: -4%; inset-inline-start: var(--x);
  inline-size: var(--s); block-size: var(--s); border-radius: 50%; opacity: 0;
  background: color-mix(in oklab, var(--lh-sun) 85%, transparent); filter: blur(0.4px);
}

/* พืชและสัตว์ที่ลอยในฉาก — วางเฉพาะช่องว่างริมซ้าย/ขวา ไม่ทับตัวหนังสือหรือการ์ด */
.flora { position: absolute; inset: 0; z-index: -2; pointer-events: none; perspective: 900px; }
.flora__it {
  position: absolute; inset-inline-start: var(--x); inset-block-start: var(--y);
  inline-size: var(--w); transform-style: preserve-3d;
  translate: calc(var(--mx) * var(--depth) * -1px) calc(var(--my) * var(--depth) * -0.6px);
  transition: translate 0.55s var(--ease-out);
}
.flora__in { display: block; position: relative; will-change: transform; }
/* แสงเรืองหลังตัวภาพ — ใช้ radial-gradient แทน drop-shadow เพราะ Chrome คิดเงา
   ของ animated WebP จากกรอบสี่เหลี่ยมของภาพ ไม่ใช่จากรูปทรงจริง จึงเห็นเป็นกล่อง
   สว่างชัดรอบต้นไม้และสัตว์ ไล่จางเป็นวงรีแบบนี้ไม่มีขอบให้เห็น */
.flora__in::before {
  content: ''; position: absolute; inset: -14%; z-index: 0;
  background: radial-gradient(52% 46% at 50% 52%,
    color-mix(in oklab, var(--lh-glow) 26%, transparent) 0%,
    color-mix(in oklab, var(--lh-glow) 9%, transparent) 46%, transparent 72%);
  filter: blur(16px);
}
.flora__it img {
  display: block; inline-size: 100%; block-size: auto; position: relative; z-index: 1;
  /* ลดความอิ่มตัวและความสว่างให้เข้ากับฉากพลบค่ำ ตัวยิ่งอยู่ไกล (--depth มาก) ยิ่งจาง
     เบลอบางเบา ๆ กันขอบภาพคมกว่าฉากรอบข้างจนดูเป็นภาพตัดแปะ */
  opacity: calc(0.9 - var(--depth, 30) * 0.004);
  filter: saturate(0.72) brightness(0.86) contrast(0.96) blur(0.3px);
  /* โคนต้นและครีบล่างจางลงกลืนไปกับผืนทุ่ง */
  -webkit-mask-image: linear-gradient(to top, transparent 0%, #000 16%);
  mask-image: linear-gradient(to top, transparent 0%, #000 16%);
}

.lhero__inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--space-md); text-align: center; }
.lflag {
  display: inline-flex; align-items: center; gap: var(--space-xs);
  padding: var(--space-2xs) var(--space-md); border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--lh-sun) 52%, transparent);
  background: color-mix(in oklab, var(--lh-sun) 15%, transparent);
  color: color-mix(in oklab, var(--lh-sun) 88%, #fff);
  font-size: var(--text-xs); font-weight: 500;
}
.lflag svg { inline-size: 1.05rem; block-size: 1.05rem; flex: none; }

/* วงล้อตัวเลข — หลักละหนึ่งคอลัมน์ หมุนเข้าที่ตอนเปิดหน้า
   เงาของตัวเลขเป็นแสงฟุ้งหลังทั้งก้อน ไม่ใช่ text-shadow เพราะ text-shadow
   ตกอยู่ในกรอบ overflow:hidden ของแต่ละหลัก ตอนวงล้อหมุน เลขทั้งยี่สิบตัว
   ในหลักเดียวกันทิ้งเงาซ้อนกันจนกรอบนั้นทึบ เห็นเป็นสี่เหลี่ยมมืดรอบตัวเลข
   ระหว่างข้อมูลวิ่ง แล้วค่อยจางตอนหยุด */
.odo {
  position: relative;
  display: flex; align-items: flex-start;
  font-family: var(--font-display); font-weight: 700;
  font-size: var(--text-numeral); line-height: 1; letter-spacing: -0.02em;
}
.odo::before {
  content: ''; position: absolute; inset: -22% -8%; z-index: -1;
  background: radial-gradient(56% 60% at 50% 54%,
    oklch(14% 0.03 150 / 0.5) 0%, oklch(14% 0.03 150 / 0.26) 48%, transparent 76%);
  filter: blur(12px);
}
.odo__d { display: block; block-size: 1em; overflow: hidden; }
.odo__d > i { display: block; font-style: normal; }
.odo__d > i > b { display: block; block-size: 1em; font-weight: inherit; }
.odo__c { opacity: 0.55; }
.odo__unit {
  align-self: flex-end; font-family: var(--font-body); font-weight: 400;
  font-size: var(--text-lg); line-height: 1;
  padding-block-end: 0.6em; margin-inline-start: var(--space-sm);
  color: color-mix(in oklab, var(--dm-ink) 76%, transparent);
}
/* ทางเลือกเมื่อปิดการเคลื่อนไหว — แสดงตัวเลขนิ่ง ๆ แทนวงล้อ */
.lhero__count {
  display: none; font-family: var(--font-display); font-weight: 700;
  font-size: var(--text-numeral); line-height: 1; letter-spacing: -0.02em;
}

.lhero h1 {
  font-size: clamp(1.9rem, 4.4vw, 3.2rem); line-height: 1.12; text-wrap: balance;
  text-shadow: 0 3px 30px oklch(14% 0.03 150 / 0.65);
}
.lhero__lead {
  max-width: 60ch; font-size: var(--text-md);
  color: color-mix(in oklab, var(--dm-ink) 82%, transparent);
}
.lhero__cta { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-sm); margin-block-start: var(--space-2xs); }

.kpis {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-md);
  inline-size: 100%; margin-block-start: var(--space-lg); perspective: 1200px; text-align: start;
}
.kpi {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: var(--space-md); min-block-size: 7rem; border-radius: var(--radius-lg);
  border: 1px solid color-mix(in oklab, #fff 24%, transparent);
  background: linear-gradient(150deg, color-mix(in oklab, #fff 18%, transparent), color-mix(in oklab, #fff 5%, transparent));
  backdrop-filter: blur(12px);
  box-shadow: 0 26px 54px -30px oklch(10% 0.03 150 / 0.95);
}
.kpi__text { flex: 1; min-inline-size: 0; inline-size: 100%; }
.kpi--stack { align-items: flex-start; }
.kpi__label, .kpi__sub { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi__label { font-size: var(--text-2xs); letter-spacing: 0.04em; color: color-mix(in oklab, var(--dm-ink) 72%, transparent); }
/* ตัวเลขหลักต้องอยู่บรรทัดเดียวเสมอ — "9,200,000" ที่ตัดบรรทัดกลางเลขอ่านผิดทันที */
.kpi__value {
  display: block; font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.35rem, 2.4vw, 1.9rem); line-height: 1.15; white-space: nowrap;
}
.kpi__sub { font-size: var(--text-2xs); color: color-mix(in oklab, var(--dm-ink) 62%, transparent); }

/* วงแหวนสัดส่วน — บอก "กี่ %" ได้ในพริบตาโดยไม่ต้องอ่านตัวเลข */
.kpi__ring {
  flex: none; inline-size: 3rem; block-size: 3rem; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--lh-sun) calc(var(--pct) * 1%), color-mix(in oklab, #fff 14%, transparent) 0);
  font-family: var(--font-mono); font-size: var(--text-2xs); font-weight: 600;
}
.kpi__ring::after {
  content: attr(data-pct); font-size: var(--text-3xs);
  inline-size: 2.2rem; block-size: 2.2rem; border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in oklab, var(--lh-deep) 72%, transparent);
}

/* สัดส่วนชาย/หญิง — แถบเดียวอ่านได้เร็วกว่าตัวเลขสองตัว */
.sexbar {
  display: flex; block-size: 0.55rem; border-radius: 3px; overflow: hidden;
  margin-block-start: var(--space-2xs);
  background: color-mix(in oklab, #fff 14%, transparent);
}
.sexbar i { display: block; block-size: 100%; }
.sexbar i.m { background: oklch(72% 0.12 200); }
.sexbar i.f { background: oklch(74% 0.13 20); }
.sexbar i.u { background: color-mix(in oklab, #fff 30%, transparent); }

/* สองคอลัมน์ตายตัว — ปล่อยให้ flex ตัดบรรทัดเองจะดันการ์ดทุกใบในแถวให้สูงตาม */
.sexrow {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.15rem var(--space-sm);
  font-size: var(--text-2xs); margin-block-start: var(--space-2xs);
}
.sexrow span { display: inline-flex; align-items: center; gap: 0.3rem; }
.sexrow i { inline-size: 0.6rem; block-size: 0.6rem; border-radius: 2px; flex: none; }

/* จังหวัดสูงสุด — รายการเล็กในการ์ดเดียว กดไปหน้าทะเบียนของจังหวัดนั้นได้ */
.toplist { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; margin-block-start: 0.3rem; inline-size: 100%; }
.toplist li {
  display: grid; grid-template-columns: 0.9rem 1fr auto; gap: 0.15rem 0.45rem;
  align-items: baseline; font-size: var(--text-2xs);
}
.toplist .rk { font-family: var(--font-mono); opacity: 0.6; color: inherit; text-decoration: none; }
.toplist .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; text-decoration: none; }
.toplist a:hover { color: var(--lh-sun); text-decoration: underline; }
.toplist .vl { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.toplist .pc { font-family: var(--font-mono); font-size: var(--text-3xs); opacity: 0.7; font-weight: 400; }
.toplist .tr {
  grid-column: 2 / -1; block-size: 0.28rem; border-radius: 2px; inline-size: 0;
  background: color-mix(in oklab, var(--lh-sun) 75%, transparent);
}

/* ═══════════════════ ② ภาค + แผนที่ ═══════════════════ */

.regsplit { display: grid; grid-template-columns: 1fr 20rem; gap: clamp(1.5rem, 4vw, 3.25rem); align-items: stretch; }
.regbars { display: flex; flex-direction: column; gap: 2px; }
.rrow {
  display: grid; grid-template-columns: 13rem 1fr 7rem 3.5rem; align-items: center; gap: var(--space-sm);
  padding: var(--space-2xs) var(--space-sm); border-radius: var(--radius-md);
  inline-size: 100%; text-align: start; font: inherit; color: inherit;
  border: 0; background: none; cursor: pointer;
}
.rrow:hover { background: var(--color-paper-2); }
.rrow[aria-pressed="true"] { background: var(--color-accent-tint); }
.rrow:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.rrow__n { display: flex; align-items: baseline; gap: var(--space-2xs); font-weight: 600; font-size: var(--text-sm); }
.rrow__n em { font-family: var(--font-mono); font-style: normal; font-size: var(--text-3xs); color: var(--color-neutral); }
.rrow__track { block-size: 1.15rem; position: relative; }
.rrow__bar {
  position: absolute; inset-block: 0; inset-inline-start: 0; inline-size: 0;
  border-radius: var(--radius-sm);
  box-shadow: inset 0 1px 0 color-mix(in oklab, #fff 32%, transparent);
}
.rrow__v { font-family: var(--font-mono); font-size: var(--text-sm); text-align: end; }
.rrow__p { font-size: var(--text-2xs); text-align: end; color: var(--color-muted); }

.regsum {
  display: flex; flex-direction: column; gap: 3px; margin-block-start: var(--space-md);
  padding: var(--space-md); border-radius: var(--radius-lg);
  border: 1px solid var(--color-rule); background: var(--color-paper);
  box-shadow: var(--shadow-whisper);
}
.regsum__k { font-family: var(--font-mono); font-size: var(--text-3xs); letter-spacing: 0.1em; color: var(--color-accent); text-transform: uppercase; }
.regsum__v { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 700; line-height: 1.05; }
.regsum__n { font-size: var(--text-xs); color: var(--color-muted); }

/* แผนที่ยืดเต็มความสูงของคอลัมน์ซ้าย แล้วย่อ svg ให้พอดี (viewBox + meet ย่อเองอัตโนมัติ)
   จึงไม่ต้องกำหนดความสูงตายตัว และไม่ล้นเมื่อจำนวนภาคเปลี่ยน */
.regmap { display: flex; flex-direction: column; gap: var(--space-sm); align-items: center; justify-content: space-between; }
.regmap__svg { flex: 1 1 auto; min-block-size: 0; inline-size: 100%; max-inline-size: 17rem; block-size: auto; }
.regmap__p {
  stroke: var(--color-paper); stroke-width: 1.6; stroke-linejoin: round; cursor: pointer;
}
.regmap__p:hover { filter: brightness(1.12); }
.regmap__p[data-on="true"] { filter: brightness(1.16) drop-shadow(0 0 12px color-mix(in oklab, var(--color-accent) 60%, transparent)); }
.regmap__scale { display: flex; align-items: center; gap: var(--space-xs); font-size: var(--text-3xs); color: var(--color-muted); }
.regmap__scale i {
  block-size: 0.55rem; inline-size: 8rem; border-radius: 3px;
  background: linear-gradient(90deg, oklch(88% 0.045 145), oklch(34% 0.105 148));
}
.regmap__hint { font-size: var(--text-2xs); color: var(--color-neutral); text-align: center; max-inline-size: 30ch; }

/* ═══════════════════ ③ อายุและเพศ ═══════════════════ */

.agesplit { display: grid; grid-template-columns: 1fr 23rem; gap: clamp(1.5rem, 4vw, 3.25rem); align-items: stretch; }
.pyr { display: flex; flex-direction: column; gap: 3px; }
.pyrkeys { display: flex; flex-wrap: wrap; gap: var(--space-xs) var(--space-lg); margin-block-end: var(--space-md); font-size: var(--text-xs); color: var(--color-muted); }
.pyrkeys span { display: inline-flex; align-items: center; gap: var(--space-2xs); }
.pyrkeys i { inline-size: 0.75rem; block-size: 0.75rem; border-radius: 3px; }
.pyrrow {
  display: grid; grid-template-columns: 1fr 9rem 1fr; align-items: center; gap: var(--space-sm);
  padding-block: 3px; border-radius: var(--radius-sm);
}
.pyrrow:hover { background: var(--color-paper-2); }
.pyrrow--u { background: color-mix(in oklab, var(--color-warn) 10%, var(--color-paper)); }
.pyrside { display: flex; align-items: center; gap: var(--space-2xs); min-inline-size: 0; }
.pyrside--l { justify-content: flex-end; }
.pyrbar {
  block-size: 1.5rem; border-radius: var(--radius-sm); flex: none; inline-size: 0;
  box-shadow: inset 0 1.5px 0 color-mix(in oklab, #fff 30%, transparent);
}
.pyrbar--m { background: linear-gradient(90deg, var(--color-accent-deep), var(--color-accent)); }
.pyrbar--f { background: linear-gradient(270deg, oklch(48% 0.135 22), oklch(63% 0.130 28)); }
.pyrnum { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--color-muted); white-space: nowrap; }
.pyrlb { text-align: center; }
.pyrlb b { display: block; font-size: var(--text-xs); font-weight: 600; }
.pyrlb small { display: block; font-family: var(--font-mono); font-size: var(--text-3xs); color: var(--color-neutral); }

.agecards { display: flex; flex-direction: column; gap: var(--space-md); }
.lnote {
  display: flex; flex-direction: column; gap: var(--space-xs);
  padding: var(--space-lg); border-radius: var(--radius-lg);
  border: 1px solid var(--color-rule); background: var(--color-paper);
  box-shadow: var(--shadow-whisper);
}
.lnote--warn {
  border-color: color-mix(in oklab, var(--color-warn) 55%, transparent);
  border-inline-start-width: 4px;
  background: color-mix(in oklab, var(--color-warn) 8%, var(--color-paper));
}
.lnote h3 { font-size: var(--text-lg); }
.lnote p { font-size: var(--text-sm); color: var(--color-muted); }
.lnote__big { font-family: var(--font-display); font-size: var(--text-3xl); font-weight: 700; line-height: 1.05; color: var(--color-accent-deep); }
.lnote--warn .lnote__big { color: oklch(46% 0.12 62); }

/* ใบเดียวเต็มความสูงของพีระมิดฝั่งซ้าย — เนื้อหากระจายตามแนวตั้งแทนการกองบนสุด */
.donut {
  display: flex; flex-direction: column; justify-content: center; gap: var(--space-lg);
  padding: var(--space-lg); border-radius: var(--radius-lg);
  border: 1px solid var(--color-rule); background: var(--color-paper); box-shadow: var(--shadow-whisper);
}
.donut__h { font-size: var(--text-md); margin-block-end: var(--space-sm); }
.donut__row { display: flex; flex-direction: column; align-items: center; gap: var(--space-lg); }
.donut__svg { inline-size: 11rem; block-size: 11rem; flex: none; transform: rotate(-90deg); }
.donut__track { fill: none; stroke: var(--color-paper-3); stroke-width: 17; }
.donut__arc { fill: none; stroke-width: 17; stroke-linecap: butt; }
.donut__t1, .donut__t2 { transform: rotate(90deg); transform-origin: 70px 70px; text-anchor: middle; fill: var(--color-ink); font-family: var(--font-display); }
.donut__t1 { font-size: 26px; font-weight: 700; }
.donut__t2 { font-size: 11px; font-family: var(--font-body); fill: var(--color-muted); }
.donut__keys { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-sm); inline-size: 100%; min-inline-size: 0; }
.donut__keys li { display: grid; grid-template-columns: 0.7rem 1fr auto; align-items: baseline; gap: 2px var(--space-xs); }
.donut__keys i { inline-size: 0.7rem; block-size: 0.7rem; border-radius: 3px; }
.donut__nm { font-size: var(--text-sm); }
.donut__vl { font-family: var(--font-mono); font-size: var(--text-sm); font-weight: 600; }
.donut__pc { grid-column: 2 / -1; font-family: var(--font-mono); font-size: var(--text-3xs); color: var(--color-muted); }

/* ═══════════════════ ④ เวทีกิจกรรม ═══════════════════ */

.lstage {
  position: relative; isolation: isolate; overflow: hidden;
  color: var(--dm-ink, #eef3ee);
  /* เดิม 4.5rem บน+ล่าง = 144px ในหน้าจอ 900px ของ section ที่สูงเกินจออยู่แล้ว
     ลดลงเพื่อคืนพื้นที่ให้เนื้อหา ไม่ได้ตัดเนื้อหาออก */
  padding-block: clamp(2rem, 4vw, 3rem);
  --lh-deep: oklch(15.5% 0.038 160);
  --lh-lit:  oklch(60% 0.120 128);
  --lh-glow: oklch(82% 0.160 140);
  --lh-sun:  oklch(88% 0.130 85);
  background:
    radial-gradient(90% 60% at 18% 8%, color-mix(in oklab, var(--lh-lit) 22%, transparent) 0%, transparent 62%),
    radial-gradient(80% 66% at 88% 96%, color-mix(in oklab, var(--lh-glow) 16%, transparent) 0%, transparent 60%),
    linear-gradient(165deg, var(--lh-deep) 0%, oklch(23% 0.055 152) 68%, oklch(19% 0.045 156) 100%);
}
.lstage__grid {
  position: absolute; inset-inline: -22%; inset-block-end: -34%; block-size: 78%; z-index: -1;
  transform: perspective(420px) rotateX(70deg); transform-origin: 50% 100%;
  mask-image: linear-gradient(to top, #000 6%, transparent 76%);
  overflow: hidden; --drift-y: 4.6rem;
}
.lstage .sec__head h2 { color: var(--dm-ink); }
.lstage .sec__head p { color: color-mix(in oklab, var(--dm-ink) 76%, transparent); }
.lstage .eyebrow { color: var(--lh-glow); }
.lstage__head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-lg); flex-wrap: wrap; margin-block-end: var(--space-lg); }
.lstage__head .sec__head { margin-bottom: 0; }

.seg {
  display: flex; gap: 4px; padding: 4px; border-radius: 999px; flex: none;
  border: 1px solid color-mix(in oklab, #fff 22%, transparent);
  background: color-mix(in oklab, #fff 8%, transparent);
}
.seg button {
  display: inline-flex; align-items: center; gap: var(--space-2xs);
  min-block-size: 2.75rem; padding-inline: var(--space-md); border-radius: 999px;
  border: 0; background: none; cursor: pointer; font: inherit; font-size: var(--text-sm);
  color: color-mix(in oklab, var(--dm-ink) 74%, transparent);
}
.seg button svg { inline-size: 1.05rem; block-size: 1.05rem; }
.seg button:hover { color: var(--dm-ink); }
.seg button[aria-pressed="true"] { background: var(--lh-glow); color: oklch(22% 0.06 150); font-weight: 600; }
.seg button:focus-visible { outline: 2px solid var(--lh-sun); outline-offset: 2px; }

/* ภาพหมุน 3 มิติ */
/* เวทีตั้งความสูงตายตัวเพราะการ์ดวางซ้อนกันด้วย transform (ไม่มีความสูงตามเนื้อหา)
   เดิม 27rem แต่การ์ดจริงสูง 375px เหลือที่ว่างเปล่า 57px ใต้การ์ด */
.carousel__stage { position: relative; block-size: 24rem; perspective: 1700px; touch-action: pan-y; cursor: grab; user-select: none; }
.carousel__stage:active { cursor: grabbing; }
.slide {
  position: absolute; inset-block-start: 0; inset-inline-start: 50%;
  inline-size: 41rem; margin-inline-start: -20.5rem; block-size: 100%;
  transform-style: preserve-3d;
}
.slide__card {
  block-size: 100%; display: grid; grid-template-columns: 11rem 1fr; gap: var(--space-md); align-items: center;
  padding: var(--space-md) var(--space-lg); border-radius: var(--radius-lg);
  border: 1px solid color-mix(in oklab, #fff 20%, transparent);
  background: linear-gradient(152deg, color-mix(in oklab, #fff 15%, transparent), color-mix(in oklab, #fff 4%, transparent));
  box-shadow: 0 44px 80px -44px oklch(8% 0.03 150 / 0.98);
}
.slide--on .slide__card { border-color: color-mix(in oklab, var(--lh-glow) 46%, transparent); }
.slide__art { position: relative; display: grid; place-items: center; }
.slide__art img {
  display: block; inline-size: 100%; block-size: auto; position: relative; z-index: 1;
  filter: drop-shadow(0 0 32px color-mix(in oklab, var(--lh-glow) 50%, transparent));
}
.slide__halo {
  position: absolute; inset: 4%; border-radius: 50%;
  border: 1.5px solid color-mix(in oklab, var(--lh-glow) 55%, transparent);
  box-shadow: 0 0 34px -6px color-mix(in oklab, var(--lh-glow) 60%, transparent);
}
.slide__ico {
  inline-size: 7rem; block-size: 7rem; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in oklab, var(--lh-glow) 14%, transparent); color: var(--lh-glow);
}
.slide__ico svg { inline-size: 3.5rem; block-size: 3.5rem; }
.slide__body { display: flex; flex-direction: column; gap: var(--space-2xs); min-inline-size: 0; }
.slide__rank { font-family: var(--font-mono); font-size: var(--text-3xs); letter-spacing: 0.12em; color: var(--lh-glow); }
.slide__nm { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 600; line-height: 1.15; }
.slide__vl { font-family: var(--font-display); font-size: var(--text-3xl); font-weight: 700; line-height: 1.05; }
.slide__pc { font-size: var(--text-xs); color: color-mix(in oklab, var(--dm-ink) 74%, transparent); }
.slide__tx { font-size: var(--text-sm); line-height: var(--leading-body); color: color-mix(in oklab, var(--dm-ink) 82%, transparent); }

.carousel__nav { display: flex; align-items: center; justify-content: center; gap: var(--space-lg); margin-block-start: var(--space-lg); }
.navbtn {
  inline-size: 3rem; block-size: 3rem; border-radius: 50%; display: grid; place-items: center; flex: none;
  border: 1px solid color-mix(in oklab, #fff 26%, transparent);
  background: color-mix(in oklab, #fff 9%, transparent); color: var(--dm-ink); cursor: pointer;
}
.navbtn svg { inline-size: 1.25rem; block-size: 1.25rem; }
.navbtn:hover { background: color-mix(in oklab, #fff 18%, transparent); }
.navbtn:disabled { opacity: 0.3; cursor: default; }
.navbtn:focus-visible { outline: 2px solid var(--lh-sun); outline-offset: 2px; }
.dots { display: flex; gap: var(--space-2xs); }
.dot {
  inline-size: 0.7rem; block-size: 0.7rem; border-radius: 50%; padding: 0; border: 0; cursor: pointer;
  background: color-mix(in oklab, #fff 26%, transparent);
}
.dot[aria-current="true"] { inline-size: 2.1rem; border-radius: 999px; background: var(--lh-glow); }
.dot:focus-visible { outline: 2px solid var(--lh-sun); outline-offset: 3px; }
.draghint { display: flex; align-items: center; justify-content: center; gap: var(--space-xs); margin-block-start: var(--space-sm); font-size: var(--text-3xs); color: color-mix(in oklab, var(--dm-ink) 58%, transparent); }
.draghint svg { inline-size: 1rem; block-size: 1rem; }

/* แผงชนิดย่อยที่กางออก */
.detail {
  margin-block-start: var(--space-md); padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in oklab, var(--lh-glow) 30%, transparent);
  background: color-mix(in oklab, #fff 8%, transparent);
}
.detail__h { display: flex; align-items: baseline; gap: var(--space-sm); margin-block-end: var(--space-sm); flex-wrap: wrap; }
.detail__h b { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; }
.detail__h span { font-size: var(--text-xs); color: color-mix(in oklab, var(--dm-ink) 68%, transparent); }
.items { display: flex; flex-direction: column; gap: var(--space-3xs); }
.item { display: grid; grid-template-columns: 2.25rem 13rem 1fr 8rem; align-items: center; gap: var(--space-sm); }
.item__th { inline-size: 2.25rem; block-size: 2.25rem; display: grid; place-items: center; }
.item__th img { inline-size: 100%; block-size: auto; }
.item__th span {
  inline-size: 2rem; block-size: 2rem; border-radius: var(--radius-md); display: grid; place-items: center;
  background: color-mix(in oklab, #fff 12%, transparent); font-family: var(--font-mono); font-size: var(--text-3xs);
}
.item__nm { font-size: var(--text-xs); }
.item__track { block-size: 0.7rem; }
.item__bar {
  display: block; block-size: 100%; inline-size: 0; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, color-mix(in oklab, var(--lh-glow) 55%, transparent), var(--lh-glow));
}
.item__vl { font-family: var(--font-mono); font-size: var(--text-xs); text-align: end; }
/* ถังรวม + ชนิดที่ตกจากอันดับ — บรรทัดสรุปใต้รายการ ไม่ใช่แถวอันดับ */
.detail__rest {
  margin-block-start: var(--space-sm); font-size: var(--text-2xs);
  color: color-mix(in oklab, var(--dm-ink) 62%, transparent);
}

/* มุมมองทุกกิจกรรม + ตารางไขว้ */
.allgrid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-md); margin-block-end: var(--space-xl); }
.acard {
  display: flex; flex-direction: column; gap: var(--space-2xs); align-items: flex-start; position: relative; overflow: hidden;
  padding: var(--space-md); border-radius: var(--radius-lg); text-align: start; cursor: pointer; font: inherit; color: inherit;
  border: 1px solid color-mix(in oklab, #fff 18%, transparent);
  background: linear-gradient(152deg, color-mix(in oklab, #fff 13%, transparent), color-mix(in oklab, #fff 4%, transparent));
}
.acard:hover { border-color: color-mix(in oklab, var(--lh-glow) 50%, transparent); }
.acard:focus-visible { outline: 2px solid var(--lh-sun); outline-offset: 2px; }
.acard__art { inline-size: 4.5rem; block-size: 4.5rem; display: grid; place-items: center; }
.acard__art img { inline-size: 100%; block-size: auto; filter: drop-shadow(0 0 18px color-mix(in oklab, var(--lh-glow) 40%, transparent)); }
.acard__art span { inline-size: 3.5rem; block-size: 3.5rem; border-radius: var(--radius-lg); display: grid; place-items: center; background: color-mix(in oklab, var(--lh-glow) 13%, transparent); color: var(--lh-glow); }
.acard__art svg { inline-size: 1.9rem; block-size: 1.9rem; }
.acard__nm { font-size: var(--text-sm); font-weight: 600; }
.acard__vl { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 600; line-height: 1.1; }
.acard__pc { font-family: var(--font-mono); font-size: var(--text-3xs); color: color-mix(in oklab, var(--dm-ink) 66%, transparent); }
.acard__bar {
  position: absolute; inset-block-end: 0; inset-inline-start: 0; block-size: 4px; inline-size: 0;
  background: linear-gradient(90deg, color-mix(in oklab, var(--lh-glow) 50%, transparent), var(--lh-glow));
}

.xwrap { display: grid; grid-template-columns: 1fr 21rem; gap: var(--space-xl); align-items: start; }
.mxg { overflow-x: auto; }
/* จำนวนคอลัมน์มาจาก --n ที่ home.js เขียนให้ตามจำนวนกิจกรรมที่มีจริง
   ตรึงไว้ที่ 5 ไม่ได้ เพราะผู้ดูแลปรับจำนวนรายการได้ และชุดข้อมูลเองก็เพิ่มกิจกรรมได้ */
.mxg { --n: 5; }
/* ความกว้างตั้งจากการวัด: ชุดเดิมขอ 704px แต่กล่องมีให้ 588px
   คอลัมน์สุดท้าย (นาเกลือ) จึงถูกตัดและต้องเลื่อนแนวนอนถึงจะเห็น
   ลดคอลัมน์ชื่อแถวจาก 13rem เหลือ 8.5rem แล้วตารางลงพอดีโดยไม่ต้องเลื่อน */
.mxg__head, .mxg__body {
  display: grid; gap: 3px;
  grid-template-columns: 8.5rem repeat(var(--n), minmax(4.4rem, 1fr));
  min-inline-size: calc(8.5rem + var(--n) * 4.6rem);
}
.mxg__head { align-items: end; margin-block-end: 3px; }
/* หัวคอลัมน์เคยหมุนตั้ง (vertical-rl) สูง 118px — ภาษาไทยหมุนตั้งอ่านยากกว่าอังกฤษมาก
   เพราะสระบนล่างไปกองอยู่ซ้ายขวาแทน · วางนอนแล้วตัดบรรทัดแทน สูงเหลือราวสองบรรทัด */
.mxg__h {
  display: flex; align-items: flex-end; justify-content: center;
  text-align: center; line-height: 1.24; text-wrap: balance;
  padding-block-end: var(--space-3xs);
  font-size: var(--text-2xs);
  color: color-mix(in oklab, var(--dm-ink) 76%, transparent);
}
.mxg__rh { display: flex; align-items: center; white-space: nowrap; font-size: var(--text-xs); padding-inline-end: var(--space-xs); color: color-mix(in oklab, var(--dm-ink) 82%, transparent); }
/* ชี้ที่ช่องไหน หัวแถวกับหัวคอลัมน์ของช่องนั้นสว่างขึ้น
   ตารางไขว้จะอ่านง่ายก็ต่อเมื่อรู้ว่าช่องที่มองอยู่คือคู่ไหน โดยไม่ต้องไล่สายตาเอง */
.mxg__h[data-on="true"], .mxg__rh[data-on="true"] {
  color: var(--lh-sun);
  font-weight: 600;
}
.mxc {
  inline-size: 100%; min-block-size: 2.9rem; padding: var(--space-2xs) var(--space-xs); border-radius: var(--radius-md);
  border: 0; cursor: pointer; font: inherit;
  font-family: var(--font-mono); font-size: var(--text-2xs); text-align: end;
  background: color-mix(in oklab, var(--lh-glow) calc(var(--heat) * 62%), color-mix(in oklab, #fff 7%, transparent));
  color: color-mix(in oklab, var(--dm-ink) 92%, transparent);
  outline: 2px solid transparent; outline-offset: -2px;
}
.mxc:hover { filter: brightness(1.22); }
.mxc[data-hot="1"] { color: oklch(18% 0.05 150); font-weight: 600; }
.mxc[data-self="1"] { background: color-mix(in oklab, #fff 15%, transparent); font-weight: 600; }
.mxc[aria-pressed="true"] { outline-color: var(--lh-sun); }
.mxc:focus-visible { outline-color: var(--lh-sun); }
.mxscale { display: flex; align-items: center; gap: var(--space-xs); margin-block-start: var(--space-md); font-size: var(--text-2xs); color: color-mix(in oklab, var(--dm-ink) 66%, transparent); }
.mxscale i { block-size: 0.55rem; inline-size: 8rem; border-radius: 3px; background: linear-gradient(90deg, color-mix(in oklab, #fff 7%, transparent), var(--lh-glow)); }

.readout {
  display: flex; flex-direction: column; gap: var(--space-sm); padding: var(--space-lg); border-radius: var(--radius-lg);
  border: 1px solid color-mix(in oklab, var(--lh-glow) 32%, transparent);
  background: color-mix(in oklab, #fff 8%, transparent);
}
.readout__k { font-family: var(--font-mono); font-size: var(--text-3xs); letter-spacing: 0.1em; color: var(--lh-glow); }
.readout__pair { display: flex; align-items: center; gap: var(--space-xs); flex-wrap: wrap; font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; }
.readout__pair svg { inline-size: 1rem; block-size: 1rem; color: color-mix(in oklab, var(--dm-ink) 55%, transparent); }
.readout__vl { font-family: var(--font-display); font-size: var(--text-3xl); font-weight: 700; line-height: 1; }
.readout p { font-size: var(--text-xs); color: color-mix(in oklab, var(--dm-ink) 74%, transparent); }
.readout__warn {
  display: flex; align-items: flex-start; gap: var(--space-2xs); padding-block-start: var(--space-sm); font-size: var(--text-2xs);
  border-block-start: 1px solid color-mix(in oklab, #fff 16%, transparent);
  color: color-mix(in oklab, var(--lh-sun) 88%, #fff);
}
.readout__warn svg { inline-size: 1rem; block-size: 1rem; flex: none; margin-block-start: 2px; }

/* คำเตือนเรื่องการนับซ้ำ — ต้องอ่านเจอก่อนตัวเลขทุกตัวของ section กิจกรรม
   จึงวางไว้บนสุดและใช้สีเหลืองของฉาก ไม่ใช่สีเดียวกับการ์ดข้อมูลรอบข้าง */
/* กล่องนี้เป็นคำเตือน ไม่ใช่เนื้อหาหลัก แต่เดิมสูง 191px ดันตารางกับการ์ดลงไปพ้นจอ
   บีบให้เตี้ยลงโดยยังอ่านครบ — เนื้อความไม่ได้ถูกตัดออกแม้แต่คำเดียว */
.xnote {
  display: flex; align-items: flex-start; gap: var(--space-sm);
  margin-block-end: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in oklab, var(--lh-sun) 46%, transparent);
  border-inline-start-width: 5px;
  background: color-mix(in oklab, var(--lh-sun) 11%, transparent);
  color: var(--dm-ink);
}
.xnote__ico { flex: none; color: var(--lh-sun); }
.xnote__ico svg { inline-size: 1.6rem; block-size: 1.6rem; }
.xnote__tx { display: flex; flex-direction: column; gap: var(--space-2xs); }
.xnote__h {
  font-family: var(--font-display); font-weight: 700;
  font-size: var(--text-lg); line-height: 1.22;
  color: color-mix(in oklab, var(--lh-sun) 82%, #fff);
}
.xnote__b { font-size: var(--text-sm); max-inline-size: 68ch; color: color-mix(in oklab, var(--dm-ink) 88%, transparent); }
.xnote__k {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--space-2xs);
  margin-block-start: 0; font-size: var(--text-xs);
  color: color-mix(in oklab, var(--dm-ink) 74%, transparent);
}
.xnote__k b { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 700; color: var(--dm-ink); }

/* คำเตือนแบบบรรทัดเดียวสำหรับ section บนพื้นสว่าง */
.xhint {
  display: flex; align-items: flex-start; gap: var(--space-2xs);
  margin-block-start: var(--space-md); font-size: var(--text-xs); color: var(--color-muted);
}
.xhint svg { inline-size: 1rem; block-size: 1rem; flex: none; margin-block-start: 2px; color: oklch(58% 0.12 70); }

/* ═══════════════════ ⑤ ชนิดย่อยไขว้ ═══════════════════ */

.spcard {
  display: grid; grid-template-columns: 8.25rem 1fr 25rem; gap: var(--space-lg); align-items: center;
  padding: var(--space-md) var(--space-lg); border-radius: var(--radius-lg); margin-block-end: var(--space-lg);
  border: 1px solid var(--color-rule); background: var(--color-paper); box-shadow: var(--shadow-whisper);
}
.spcard__duo { display: flex; align-items: center; gap: var(--space-2xs); }
.spcard__duo :is(img, .nothumb) { inline-size: 3.25rem; block-size: 3.25rem; object-fit: contain; }
.spcard__duo svg { inline-size: 0.95rem; block-size: 0.95rem; color: var(--color-neutral); flex: none; }
.spcard__txt { display: flex; flex-direction: column; gap: 1px; min-inline-size: 0; }
.spcard__k { font-family: var(--font-mono); font-size: var(--text-3xs); letter-spacing: 0.1em; color: var(--color-accent); text-transform: uppercase; }
.spcard__nm { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; line-height: 1.25; }
.spcard__vl { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 700; line-height: 1.1; color: var(--color-accent-deep); }
.spcard__note { font-size: var(--text-2xs); color: var(--color-muted); }
.spcard__top { display: flex; flex-direction: column; gap: 3px; }
.spcard__topk { font-size: var(--text-2xs); color: var(--color-muted); margin-block-end: 2px; }
.sptop {
  display: grid; grid-template-columns: 1.65rem 7.5rem 1fr 4.75rem; align-items: center; gap: var(--space-xs);
  padding: 2px var(--space-2xs); border-radius: var(--radius-md); inline-size: 100%; text-align: start;
  border: 0; background: none; cursor: pointer; font: inherit; color: inherit;
}
.sptop:hover { background: var(--color-paper-2); }
.sptop[aria-pressed="true"] { background: var(--color-accent-tint); }
.sptop:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.sptop :is(img, .nothumb) { inline-size: 1.65rem; block-size: 1.65rem; object-fit: contain; }
.sptop__nm { font-size: var(--text-2xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sptop__track { block-size: 0.45rem; }
.sptop__bar { display: block; block-size: 100%; inline-size: 0; border-radius: 3px; background: linear-gradient(90deg, var(--color-accent-deep), var(--color-accent)); }
.sptop__vl { font-family: var(--font-mono); font-size: var(--text-3xs); text-align: end; }

.spchips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs); margin-block-end: var(--space-md); }
.spchips__k { font-size: var(--text-2xs); color: var(--color-muted); margin-inline-end: var(--space-2xs); }
.spchip {
  display: inline-flex; align-items: center; gap: var(--space-2xs);
  padding: 3px var(--space-sm) 3px 4px; border-radius: 999px; font-size: var(--text-2xs); cursor: pointer; font-family: inherit;
  border: 1px solid var(--color-rule); background: var(--color-paper); color: var(--color-ink-soft);
}
.spchip :is(img, .nothumb) { inline-size: 1.5rem; block-size: 1.5rem; object-fit: contain; }
.spchip:hover { border-color: var(--color-accent); }
.spchip[aria-pressed="true"] { background: var(--color-accent-tint); border-color: var(--color-accent); color: var(--color-accent-deep); font-weight: 600; }
.spchip:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

.spg { overflow-x: auto; }
.spg { --n: 10; }
.spg__head, .spg__body {
  display: grid; gap: 3px;
  grid-template-columns: 10.5rem repeat(var(--n), minmax(0, 1fr));
  min-inline-size: calc(10.5rem + var(--n) * 4.6rem);
}
.spg__head { align-items: end; margin-block-end: 3px; }
/* วางนอนแล้วตัดบรรทัด ด้วยเหตุผลเดียวกับตารางกิจกรรม (.mxg__h)
   ของเดิมหมุนตั้งสูง 132px ทั้งที่ชื่อชนิดสั้นกว่าชื่อกิจกรรมอีก */
.spg__h {
  display: flex; align-items: flex-end; justify-content: center;
  text-align: center; line-height: 1.24; text-wrap: balance;
  padding-block-end: var(--space-3xs);
  font-size: var(--text-2xs); color: var(--color-muted);
}
.spg__h[data-on="true"] { color: var(--color-accent-deep); font-weight: 600; }
.spg__rh {
  display: flex; align-items: center; gap: var(--space-2xs); white-space: nowrap; overflow: hidden;
  font-size: var(--text-2xs); padding: 2px var(--space-xs) 2px 2px; border-radius: var(--radius-md); color: var(--color-ink-soft);
}
.spg__rh :is(img, .nothumb) { inline-size: 1.65rem; block-size: 1.65rem; object-fit: contain; flex: none; }
/* ชนิดที่ผู้ดูแลยังไม่ได้ผูกภาพ — ต้องกินที่เท่ารูปเพื่อให้แถวไม่เหลื่อม */
.nothumb {
  display: grid; place-items: center; flex: none; border-radius: var(--radius-sm);
  background: color-mix(in oklab, var(--color-ink) 6%, transparent);
  color: var(--color-muted); font-family: var(--font-mono); font-size: var(--text-3xs);
}
.spg__rh[data-on="true"] { background: var(--color-accent-tint); color: var(--color-accent-deep); font-weight: 600; }
.spc {
  inline-size: 100%; min-block-size: 2.6rem; padding: 4px 5px; border-radius: var(--radius-sm);
  border: 0; cursor: pointer; font-family: var(--font-mono); font-size: var(--text-3xs); text-align: end;
  background: color-mix(in oklab, var(--color-accent) calc(var(--heat) * 78%), var(--color-paper-2));
  color: var(--color-ink); outline: 2px solid transparent; outline-offset: -2px;
}
.spc:hover { filter: saturate(1.3) brightness(1.06); }
.spc[data-hot="1"] { color: #fff; }
.spc[data-self="1"] { background: var(--color-paper-3); font-weight: 600; color: var(--color-muted); }
.spc[data-row="false"] { opacity: 0.42; }
.spc[aria-pressed="true"] { outline-color: var(--color-accent-deep); opacity: 1; }
.spc:focus-visible { outline-color: var(--color-focus); }

/* ═══════════════════ ⑥ จังหวัด · ฉากทุ่งกลางคืน ═══════════════════ */

.lprov {
  position: relative; isolation: isolate; overflow: hidden; color: var(--dm-ink, #eef3ee);
  --lh-glow: oklch(82% 0.160 140);
  --lh-sun:  oklch(88% 0.130 85);
  background: linear-gradient(172deg, oklch(13% 0.032 250) 0%, oklch(17% 0.040 200) 46%, oklch(19% 0.048 160) 100%);
}
.lprov .sec__head h2 { color: var(--dm-ink); }
.lprov .sec__head p { color: color-mix(in oklab, var(--dm-ink) 76%, transparent); }
.lprov .eyebrow { color: var(--lh-glow); }

.night { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.night__glow {
  position: absolute; inset-inline: 0; inset-block-end: 0; block-size: 62%;
  background: radial-gradient(64% 92% at 50% 118%, color-mix(in oklab, var(--lh-glow) 34%, transparent) 0%, transparent 68%);
}
.night__stars {
  position: absolute; inset-block-start: 0; inset-inline: 0; block-size: 58%; opacity: 0.55;
  background-image:
    radial-gradient(1.4px 1.4px at 12% 22%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 27% 12%, #fff, transparent),
    radial-gradient(1.6px 1.6px at 41% 30%, #fff, transparent),
    radial-gradient(1.1px 1.1px at 56% 16%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 68% 34%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 79% 20%, #fff, transparent),
    radial-gradient(1.4px 1.4px at 91% 28%, #fff, transparent),
    radial-gradient(1px 1px at 34% 44%, #fff, transparent),
    radial-gradient(1.3px 1.3px at 62% 48%, #fff, transparent),
    radial-gradient(1px 1px at 18% 38%, #fff, transparent);
}
/* ใบหญ้า — รูปเรียวด้วย border-radius แล้วโยกที่โคน ไม่ต้องใช้ไฟล์ภาพ */
.night__blades { position: absolute; inset-inline: 0; inset-block-end: 0; block-size: 100%; }
.night__blades i {
  position: absolute; inset-block-end: -2%; inset-inline-start: var(--l);
  inline-size: var(--w); block-size: var(--h); opacity: var(--o);
  border-radius: 50% 50% 46% 46% / 72% 72% 6% 6%;
  background: linear-gradient(to top, oklch(24% 0.075 150) 0%, oklch(38% 0.105 145) 46%,
              color-mix(in oklab, var(--lh-glow) 82%, transparent) 100%);
  transform-origin: 50% 100%;
  filter: drop-shadow(0 0 9px color-mix(in oklab, var(--lh-glow) 28%, transparent));
}
.night__fire { position: absolute; inset: 0; }
.night__fire b {
  position: absolute; inset-inline-start: var(--x); inset-block-start: var(--y);
  inline-size: var(--s); block-size: var(--s); border-radius: 50%; opacity: 0;
  background: color-mix(in oklab, var(--lh-sun) 88%, transparent);
  box-shadow: 0 0 12px 2px color-mix(in oklab, var(--lh-sun) 55%, transparent);
}
.night__rings { position: absolute; inset: 0; }
.night__rings u {
  position: absolute; inset-inline-start: var(--x); inset-block-start: var(--y);
  inline-size: var(--sz); block-size: var(--sz); border-radius: 50%;
  border: 1.5px solid color-mix(in oklab, var(--lh-glow) 52%, transparent);
  box-shadow: 0 0 22px -4px color-mix(in oklab, var(--lh-glow) 50%, transparent);
}

.podium {
  --n: 3;
  display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  gap: var(--space-lg); align-items: end;
}
.prov {
  display: flex; flex-direction: column; gap: var(--space-xs); position: relative;
  padding: var(--space-lg); border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-sm);
  color: var(--dm-ink); transform-origin: bottom;
  border: 1px solid color-mix(in oklab, #fff 20%, transparent);
  background: linear-gradient(152deg, color-mix(in oklab, #fff 14%, transparent), color-mix(in oklab, #fff 4%, transparent));
  backdrop-filter: blur(10px);
  box-shadow: 0 34px 64px -36px oklch(6% 0.02 200 / 0.98);
}
/* ความสูงลดหลั่นตามอันดับ — คิดจาก --i แทนการเขียนทีละใบ เพราะผู้ดูแลปรับจำนวนอันดับได้
   ตัวที่ 6 เป็นต้นไปสูงเท่ากันหมด ไม่งั้นใบท้าย ๆ จะเตี้ยจนใส่ตัวเลขไม่ลง */
.prov { min-block-size: max(11rem, 18rem - var(--i, 0) * 2.5rem); }
.prov--1 {
  border-color: color-mix(in oklab, var(--lh-glow) 44%, transparent);
  background: linear-gradient(152deg, color-mix(in oklab, var(--lh-glow) 18%, transparent), color-mix(in oklab, #fff 5%, transparent));
}
.prov__rk { font-family: var(--font-display); font-size: var(--text-sm); font-weight: 700; letter-spacing: 0.1em; color: color-mix(in oklab, var(--lh-sun) 88%, #fff); }
.prov__nm { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 600; margin-block-start: auto; }
.prov__vl { font-family: var(--font-mono); font-size: var(--text-xl); }
.prov__pc { font-size: var(--text-2xs); color: color-mix(in oklab, var(--dm-ink) 70%, transparent); }

/* ═══════════════════ การเคลื่อนไหว ═══════════════════ */

@media (prefers-reduced-motion: no-preference) {
  :root:not([data-motion="off"]) .lhero__field > i,
  :root:not([data-motion="off"]) .lstage__grid > i { animation: fieldDrift 26s linear infinite; }
  :root:not([data-motion="off"]) .lhero__sun { animation: sunBreathe 11s ease-in-out infinite; }
  :root:not([data-motion="off"]) .lhero__motes i { animation: moteRise var(--dur) linear var(--delay) infinite; }
  :root:not([data-motion="off"]) .flora__in { animation: drift3d var(--dur, 9s) ease-in-out var(--dly, 0s) infinite; }
    :root:not([data-motion="off"]) .night__rings u { animation: haloPulse var(--hdur, 6s) ease-in-out var(--dly, 0s) infinite; }
  :root:not([data-motion="off"]) .odo__d > i { animation: reel 2.1s var(--ease-out) calc(0.45s + var(--i) * 0.085s) both; }
  :root:not([data-motion="off"]) .kpi { transition: transform 0.35s var(--ease-out), box-shadow 0.35s; }
  :root:not([data-motion="off"]) .kpi:hover { transform: translateY(-5px) rotateX(5deg) rotateY(-4deg); }
  :root:not([data-motion="off"]) .rrow__bar,
  :root:not([data-motion="off"]) .pyrbar,
  :root:not([data-motion="off"]) .item__bar,
  :root:not([data-motion="off"]) .sptop__bar,
  :root:not([data-motion="off"]) .acard__bar,
  :root:not([data-motion="off"]) .sexbar i { transition: inline-size 0.9s var(--ease-out), width 0.9s var(--ease-out); }
  :root:not([data-motion="off"]) .acard,
  :root:not([data-motion="off"]) .regmap__p,
  :root:not([data-motion="off"]) .mxc,
  :root:not([data-motion="off"]) .spc,
  :root:not([data-motion="off"]) .dot,
  :root:not([data-motion="off"]) .navbtn { transition: all 0.25s var(--ease-out); }
  :root:not([data-motion="off"]) .acard:hover { transform: translateY(-6px); }
  :root:not([data-motion="off"]) .mxc:hover,
  :root:not([data-motion="off"]) .spc:hover { transform: scale(1.05); }
  :root:not([data-motion="off"]) .slide { transition: transform 0.72s var(--ease-out), opacity 0.55s var(--ease-out), filter 0.55s; }
  /* .slide--on มาจาก JS ซึ่งไม่ขยับตาม animation — ถ้าใช้ตัวนั้นเบลอ ใบที่อยู่กลางจอ
     จะโดนเบลอตอนเลื่อนเอง จึงแยกเป็นสองกรณี: โหมดคุมเองใช้คลาส ส่วนโหมดเลื่อนเอง
     ใช้ keyframes ที่เดินพร้อมกับ coverflow */
  :root:not([data-motion="off"]) .carousel--manual .slide:not(.slide--on) { filter: blur(2.5px) saturate(0.7); }
  :root:not([data-motion="off"]) .night__blades i { animation: sway var(--sw) ease-in-out var(--d) infinite; }
  :root:not([data-motion="off"]) .night__fire b { animation: fireRise var(--dur) ease-in-out var(--d) infinite; }
  :root:not([data-motion="off"]) .night__stars { animation: twinkle 5.5s ease-in-out infinite; }

  /* เลื่อนภาพหมุนเองด้วย CSS ล้วน — 5 ใบ ใบละ 6 วินาที รวมรอบละ 30 วินาที
     ใบที่อยู่นอกสายตาสลับข้างตอนโปร่งใส จึงไม่เห็นการกระโดด
     พอผู้ใช้ลากหรือกดเอง .carousel--manual จะปิด animation แล้วค่าจาก JS ทำงานแทน */
  /* --rot-total / --rot-step มาจาก home.js ตามค่า "วินาทีต่อการ์ด" ที่ผู้ดูแลตั้งไว้
     ถ้าไม่ได้ตั้ง จะได้ 5 ใบ × 6 วินาที = 30 วินาที เท่ากับพฤติกรรมเดิม */
  :root:not([data-motion="off"]) .carousel__stage:not(.carousel--manual) .slide {
    animation: coverflow var(--rot-total, 30s) cubic-bezier(0.5, 0, 0.2, 1) calc(var(--i) * var(--rot-step, -6s)) infinite,
               coverblur var(--rot-total, 30s) linear calc(var(--i) * var(--rot-step, -6s)) infinite;
  }
  :root:not([data-motion="off"]) .carousel__nav:not(.carousel--manual) .dot {
    animation: dotCycle var(--rot-total, 30s) linear calc(var(--i) * var(--rot-step, -6s)) infinite;
  }
}

@keyframes fieldDrift { from { transform: translateY(0); } to { transform: translateY(var(--drift-y)); } }
@keyframes sunBreathe { 0%, 100% { opacity: 0.72; transform: scale(1); } 50% { opacity: 1; transform: scale(1.07); } }
@keyframes moteRise {
  0%   { opacity: 0; transform: translateY(0) scale(0.5); }
  14%  { opacity: 0.8; }
  86%  { opacity: 0.3; }
  100% { opacity: 0; transform: translateY(-58vh) translateX(var(--drift, 14px)) scale(1); }
}
@keyframes drift3d {
  0%, 100% { transform: translate3d(0, 0, 0) rotateY(var(--ry, 0deg)); }
  50%      { transform: translate3d(var(--dx, 6px), var(--dy, -16px), 0) rotateY(calc(var(--ry, 0deg) + 8deg)); }
}
@keyframes haloPulse { 0%, 100% { opacity: 0.35; transform: scale(1); } 50% { opacity: 0.75; transform: scale(1.12); } }
@keyframes reel {
  0%   { transform: translateY(0); filter: blur(7px); opacity: 0.25; }
  55%  { filter: blur(2.5px); opacity: 1; }
  100% { transform: translateY(calc((10 + var(--d)) * -1em)); filter: blur(0); opacity: 1; }
}
@keyframes sway {
  0%, 100% { transform: rotate(calc(var(--rot) * -1)) scaleY(1); }
  50%      { transform: rotate(var(--rot)) scaleY(1.035); }
}
@keyframes fireRise {
  0%   { opacity: 0; transform: translate3d(0, 0, 0) scale(0.5); }
  16%  { opacity: 0.95; }
  78%  { opacity: 0.45; }
  100% { opacity: 0; transform: translate3d(var(--dx, 18px), -220px, 0) scale(1.1); }
}
@keyframes twinkle { 0%, 100% { opacity: 0.34; } 50% { opacity: 0.72; } }
@keyframes coverflow {
  0%,  14%   { transform: translateX(0) translateZ(0) rotateY(0deg) scale(1);              opacity: 1;    z-index: 10; }
  20%, 34%   { transform: translateX(-41rem) translateZ(-190px) rotateY(26deg) scale(0.9);  opacity: 0.42; z-index: 9; }
  40%, 54%   { transform: translateX(-82rem) translateZ(-280px) rotateY(26deg) scale(0.9);  opacity: 0;    z-index: 8; }
  54.1%, 74% { transform: translateX(82rem) translateZ(-280px) rotateY(-26deg) scale(0.9);  opacity: 0;    z-index: 8; }
  80%, 94%   { transform: translateX(41rem) translateZ(-190px) rotateY(-26deg) scale(0.9);  opacity: 0.42; z-index: 9; }
  100%       { transform: translateX(0) translateZ(0) rotateY(0deg) scale(1);              opacity: 1;    z-index: 10; }
}
@keyframes coverblur {
  0%, 14%  { filter: blur(0) saturate(1); }
  20%, 94% { filter: blur(2.5px) saturate(0.7); }
  100%     { filter: blur(0) saturate(1); }
}
@keyframes dotCycle {
  0%, 18%  { inline-size: 2.1rem; border-radius: 999px; background: var(--lh-glow); }
  20%, 98% { inline-size: 0.7rem; border-radius: 50%; background: color-mix(in oklab, #fff 26%, transparent); }
  100%     { inline-size: 2.1rem; border-radius: 999px; background: var(--lh-glow); }
}

/* ปิดการเคลื่อนไหว → แสดงตัวเลขนิ่งแทนวงล้อ และหยุดฉากทั้งหมด */
@media (prefers-reduced-motion: reduce) {
  .odo { display: none; }
  .lhero__count { display: block; }
}
:root[data-motion="off"] .odo { display: none; }
:root[data-motion="off"] .lhero__count { display: block; }

/* ═══════════════════ จอแคบ ═══════════════════ */

@media (max-width: 68rem) {
  /* ฉากมีพืชและสัตว์วางไว้ที่ช่องว่างริมซ้าย/ขวาของจอกว้าง — พอจอแคบ
     ตัวหนังสือกินเต็มความกว้าง ช่องว่างนั้นหายไป จึงต้องซ่อนไม่ให้ทับข้อความ */
  .flora { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .regsplit, .agesplit, .xwrap { grid-template-columns: minmax(0, 1fr); }
  .regmap__svg { max-inline-size: 15rem; }
  .allgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .spcard { grid-template-columns: 8.25rem 1fr; }
  .spcard__top { grid-column: 1 / -1; }
}
@media (max-width: 48rem) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .rrow { grid-template-columns: 1fr auto; row-gap: 4px; }
  .rrow__track { grid-column: 1 / -1; }
  .rrow__p { grid-column: 1 / -1; text-align: start; }
  .pyrrow { grid-template-columns: 1fr 5.5rem 1fr; }
  .pyrnum { display: none; }
  .carousel__stage { block-size: 31rem; }
  .slide { inline-size: min(100%, 22rem); margin-inline-start: min(-11rem, -50%); }
  .slide__card { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; padding: var(--space-md); }
  .slide__art { inline-size: 8rem; }
  .allgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .podium { grid-template-columns: minmax(0, 1fr); }
  .prov { min-block-size: 0; }
  .item { grid-template-columns: 2.25rem 1fr 5.5rem; }
  .item__track { display: none; }
  .donut__row { flex-direction: column; align-items: flex-start; }
}

/* ── ทุ่งข้าวสามมิติหลังหัวเรื่อง (scenes/hero-field.js) ───────────────────
   กรอบของฉากคือทั้งผืนหัวเรื่อง ฉากจึงต้องอยู่หลังตัวหนังสือและการ์ดทั้งหมด
   ผ้าใบร่วมตรึงอยู่ที่ z-index --z-stage3d จึงต้องยกเนื้อหาของหัวเรื่องขึ้นเหนือมัน */
/* เคยวางฉากนี้เต็มผืนหัวเรื่อง แล้วต้นข้าวขึ้นทับการ์ด KPI กับภาพพืชสัตว์จนรก
   วัดแล้วเนื้อหากินพื้นที่ 17.7%–91.6% ของความสูง และการ์ดกินเต็มความกว้าง
   หัวเรื่องจึงไม่มีที่ว่างให้ฉากเต็มเฟรมตั้งแต่แรก — เหลือไว้เป็นแถบล่างสุดเท่านั้น
   ซึ่งอยู่ใต้การ์ดพอดีและไม่ทับอะไรเลย
   ผ้าใบร่วมอยู่เหนือหัวเรื่องทั้งผืนเสมอ ลำดับชั้นจึงกันต้นข้าวไม่ให้ทับการ์ดไม่ได้
   ต้องกันด้วยขนาด — --lh-field-cap คือที่ว่างใต้การ์ดที่ home.js วัดมาให้ (capFieldHeight) */
.herofield {
  position: absolute;
  inset: auto 0 0 0;
  block-size: min(var(--lh-field-h), var(--lh-field-cap, var(--lh-field-h)));
  z-index: 0;
  pointer-events: none;
  /* จางหายขึ้นข้างบน ให้กลืนกับไล่เฉดของหัวเรื่อง ไม่มีเส้นตัดว่าแถบเริ่มตรงไหน */
  mask-image: linear-gradient(to top, #000 42%, transparent 100%);
  -webkit-mask-image: linear-gradient(to top, #000 42%, transparent 100%);
}
.lhero__inner { position: relative; z-index: calc(var(--z-stage3d) + 1); }

/* ทุ่งลายตารางเดิมอยู่ต่อเสมอ — แถบหญ้าเป็นของเสริมด้านล่าง ไม่ได้มาแทนที่ */



/* ── แผนที่รายจังหวัด (province-map.js) ───────────────────────────────────
   แทนแผนที่ 6 ภาคในกล่องเดิม (.regmap) จึงใช้ layout ของกล่องนั้นต่อได้เลย  */
.pmap__modes {
  display: flex; gap: var(--space-3xs);
  padding: var(--space-3xs);
  border: var(--rule-hair) solid var(--color-rule);
  border-radius: 999px;
  background: var(--color-paper-2);
}
.pmap__mode {
  border: 0; cursor: pointer;
  padding: var(--space-3xs) var(--space-sm);
  border-radius: 999px;
  background: transparent;
  color: var(--color-muted);
  font: inherit; font-size: var(--text-2xs);
  line-height: 1.6;
}
.pmap__mode[aria-pressed="true"] {
  background: var(--color-accent);
  color: var(--color-paper);
}
.pmap__mode:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

.pmap__stage { position: relative; inline-size: 100%; flex: 1 1 auto; min-block-size: 0; }
.pmap__svg {
  display: block; margin-inline: auto;
  inline-size: 100%; max-inline-size: 19rem; block-size: auto; max-block-size: 26rem;
}
.pmap__p {
  stroke: var(--color-paper);
  stroke-width: 1.4;
  stroke-linejoin: round;
  cursor: pointer;
  transition: filter 0.12s var(--ease-out);
}
.pmap__p:hover { filter: brightness(1.14); }
/* จังหวัดในภาคที่เลือกอยู่ — ขีดเส้นให้เห็นเป็นกลุ่มเดียวกัน ไม่เปลี่ยนสีพื้น
   เพราะสีพื้นกำลังบอกค่าอยู่ ถ้าย้อมทับก็อ่านค่าไม่ได้ */
.pmap__p[data-on="true"] { stroke: var(--color-ink); stroke-width: 2; }

/* ป้ายลอยของแผนที่ */
.maptip {
  position: absolute;
  z-index: 3;
  transform: translate(-50%, -135%);
  pointer-events: none;
  white-space: nowrap;
  display: flex; flex-direction: column; gap: 1px;
  padding: var(--space-3xs) var(--space-2xs);
  border-radius: var(--radius-sm, 4px);
  background: var(--color-ink);
  color: var(--color-paper);
  font-size: var(--text-2xs);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 10px -4px oklch(22% 0.02 132 / 0.5);
}
.maptip b { font-weight: 600; }
.maptip span { opacity: 0.82; }
.maptip[hidden] { display: none; }

@media (max-width: 52rem) {
  .pmap__svg { max-inline-size: 14rem; max-block-size: 19rem; }
}
