/* home.css — หน้าแรก (index.html) และหน้าศูนย์ (center.html) แบบ D2 · ใช้ token ของ assets/ui/niems.css
   ตัวแปรที่โมดูลแผนที่จาก landing อ่าน (centers-map.ts: --map-* --indigo --yellow --text) ผูกกับ token ที่นี่ */
:root{--map-bg:#EEF2F9;--map-community:#D9A400;--map-network:#2D8FCE;
  --indigo:var(--ui-indigo);--yellow:var(--ui-yellow);--text:var(--ui-text)}

/* ── จอแรก + ค้นหาศูนย์ (ซ้าย) กับแผนที่ค้างขวา · จอ ≤900px: จอแรก → แผนที่ → ค้นหา · ไม่มีแผนที่ = คอลัมน์เดียว ── */
.stage{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.12fr);grid-template-areas:"intro viz" "find viz";border-bottom:1px solid var(--ui-line)}
/* R071-I2: จอกว้างมาก (เช่น 3440×900) กรอบแผนที่กว้างเกินกรอบภาพ 88–115 E — ภาพรวมประเทศไทยต้องพอดีความสูง จึงกว้างได้ไม่เกิน
   (สูงกรอบ − ขอบบน/ล่าง 126 px) × 1.68 (ประเทศไทย 15.3° เมอร์เคเตอร์ : กรอบภาพ 27°) · ปกติ 52.83% = 1.12fr เดิม · เบราว์เซอร์ไม่รู้จัก min() ใช้บรรทัดบน */
.stage{grid-template-columns:minmax(0,1fr) min(52.83%,max(30%,calc((100vh - var(--ui-header-h) - 126px) * 1.68)));grid-template-columns:minmax(0,1fr) min(52.83%,max(30%,calc((100svh - var(--ui-header-h) - 126px) * 1.68)))}
.stage.no-map{grid-template-columns:minmax(0,1fr);grid-template-areas:"intro" "find"}
.intro{grid-area:intro;display:flex;flex-direction:column;justify-content:center;min-height:calc(100vh - var(--ui-header-h));min-height:calc(100svh - var(--ui-header-h));padding:48px 48px 56px max(16px,calc((100vw - 1200px) / 2))}
.find{grid-area:find;padding:56px 48px 80px max(16px,calc((100vw - 1200px) / 2))}
.stage.no-map .intro,.stage.no-map .find{padding-right:max(16px,calc((100vw - 1200px) / 2))}
.stage.no-map .intro{min-height:0}
.intro h1{margin:0;font-weight:820;font-stretch:76%;font-size:clamp(2.3rem,3.6vw,3.4rem);line-height:1.12}
.intro h1 span{display:block}
@media (min-width:1101px){.intro h1 span{white-space:nowrap}}
.lead{max-width:32em;margin:20px 0 0;color:var(--ui-muted)}
.facts{margin:26px 0 0;padding:16px 0 0;border-top:1px solid var(--ui-line);color:var(--ui-muted);font-size:.95rem}
.facts a{color:var(--ui-indigo);font-weight:700}
.draft{margin-top:16px}
.tasks{display:grid;gap:12px;margin:28px 0 0;padding:0;list-style:none}
.task{display:grid;grid-template-columns:56px 1fr;gap:18px;align-items:center;padding:20px 22px;border:1px solid var(--ui-line);border-radius:var(--ui-r2);background:var(--ui-surface);text-decoration:none}
.task:hover{border-color:var(--ui-indigo)}
.task .ico{display:grid;place-items:center;width:56px;height:56px;border-radius:16px;background:var(--ui-pale);color:var(--ui-indigo)}
.task .ico svg{width:28px;height:28px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.task b{display:block;font-size:1.2rem;font-stretch:88%;line-height:1.35}
.task span span{display:block;color:var(--ui-muted);font-size:.93rem;line-height:1.55}
.task.main{border-color:var(--ui-indigo);background:var(--ui-indigo);color:#fff}
.task.main span span{color:#C6D5F2}
.task.main .ico{background:rgba(255,255,255,.12);color:var(--ui-yellow)}
.find h2{margin:0 0 6px;color:var(--ui-indigo);font-weight:800;font-stretch:80%;font-size:clamp(1.9rem,3vw,2.6rem)}
.find .note{margin:0 0 18px;color:var(--ui-muted)}
/* vh ก่อน svh — เบราว์เซอร์ที่ไม่รู้จัก svh (Safari < 15.4) ใช้ vh แทน ไม่งั้นกรอบแผนที่สูง 0px (R050r1-I2) */
.viz{grid-area:viz;position:sticky;top:var(--ui-header-h);align-self:start;height:calc(100vh - var(--ui-header-h));height:calc(100svh - var(--ui-header-h));overflow:hidden;background:var(--map-bg)}
@media (max-width:900px){
  .stage{grid-template-columns:1fr;grid-template-areas:"intro" "viz" "find"}
  .intro{min-height:0;padding:36px 16px 32px}
  .find{padding:40px 16px 64px}
  .viz{position:relative;top:auto;height:70vh;height:70svh;min-height:420px}
}

/* ── รายการศูนย์ (landing centers.ts สร้าง) ── */
.centers-controls{display:grid;gap:10px;margin-bottom:12px}
.centers-row{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.ui-chip.near{border-color:var(--ui-yellow);background:#FBFAD9}
.ui-chip.near[aria-pressed="true"]{border-color:var(--ui-yellow);background:var(--ui-yellow);color:var(--ui-text)}
.centers-status{margin:8px 0;color:var(--ui-muted);font-size:.95rem}
.centers-list{margin:0;padding:0;list-style:none;border-top:1px solid var(--ui-line)}
.centers-list li{border-bottom:1px solid var(--ui-line)}
.centers-list button{all:unset;box-sizing:border-box;display:flex;gap:12px;align-items:flex-start;width:100%;padding:13px 10px;border-radius:12px;cursor:pointer}
.centers-list button:hover,.centers-list button[aria-current="true"]{background:var(--ui-pale)}
.centers-list button:focus-visible{outline:3px solid var(--ui-sky);outline-offset:-3px}
.centers-list .dot{flex:none;width:12px;height:12px;margin-top:8px;border:2px solid #fff;border-radius:50%;box-shadow:0 0 0 1px rgba(25,38,69,.18)}
.dot.t1{background:var(--map-community)}.dot.t2{background:var(--map-network)}.dot.t0{background:#fff;box-shadow:inset 0 0 0 1.5px #9AA3B5}
.centers-list b{display:block;line-height:1.45;overflow-wrap:anywhere}
.centers-list small{display:block;color:var(--ui-muted);font-size:.85rem;line-height:1.5}
.centers-more{margin-top:14px}

/* ── แผนที่ (landing centers-map.ts) ── */
.viz .map-canvas{position:absolute;inset:0}
.map-fallback{position:absolute;inset:0;display:grid;place-items:center;margin:0;padding:24px;color:var(--ui-muted);text-align:center}
.map-key,.map-tip,.map-card,.map-tl{position:absolute;z-index:3}
.map-key{left:14px;top:14px;display:grid;gap:2px;padding:9px 12px;border:1px solid var(--ui-line);border-radius:14px;background:rgba(255,255,255,.92);font-size:.8rem;line-height:1.55}
.map-key span{display:flex;align-items:center;gap:8px}
.map-key i{flex:none;width:11px;height:11px;border-radius:50%}
.map-key .k1{background:var(--map-community)}.map-key .k2{background:var(--map-network)}
.map-tip{max-width:260px;padding:7px 11px;border-radius:10px;background:var(--ui-text);color:#fff;font-size:.85rem;line-height:1.45;pointer-events:none;transform:translate(-50%,calc(-100% - 14px))}
.map-tip small{display:block;color:#C6D0E6}
.map-card{left:14px;top:14px;width:min(340px,calc(100% - 72px));padding:16px 18px;border:1px solid var(--ui-line);border-radius:18px;background:#fff;box-shadow:0 10px 30px rgba(25,38,69,.14)}
.map-card.card-inline{position:relative;left:auto;top:auto;width:auto;margin:0 0 14px;box-shadow:none}
.map-card h3{margin:4px 0 2px;padding-right:30px;font-size:1.1rem;line-height:1.4;overflow-wrap:anywhere}
.map-card p{margin:0;color:var(--ui-muted);font-size:.9rem}
.map-card p:empty{display:none}
.map-card .acts{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}
.map-card .acts a{padding:9px 14px;border:1.5px solid var(--ui-line);border-radius:999px;background:#fff;color:var(--ui-indigo);font:600 .88rem/1 var(--ui-font);text-decoration:none}
.map-card .acts a.go{border-color:var(--ui-indigo);background:var(--ui-indigo);color:#fff}
.map-card .x{position:absolute;right:10px;top:10px;width:32px;height:32px;border:0;border-radius:50%;background:var(--ui-soft);color:var(--ui-text);font-size:1.1rem;line-height:1;cursor:pointer}
.tag{display:inline-block;padding:1px 9px;border-radius:999px;font-size:.75rem;font-weight:700}
.tag.t1{background:#FBF4D2;color:#6B5A00}.tag.t2{background:#E3F0FA;color:#1C5F8F}
/* แถบล่างซ้าย: จำนวนศูนย์ + เดือนที่ภาพแสดง + ปุ่ม ↻ เล่นการเติบโตอีกครั้ง (0.6.5 ตาม niems-landing 0.5.3–0.5.4: ไม่มีปุ่มหยุด/แถบเลื่อน — ภาพเล่นครั้งเดียว 4.5 วิ) */
.map-tl{left:14px;bottom:14px;display:flex;align-items:center;gap:12px;padding:8px 8px 8px 14px;border:1px solid var(--ui-line);border-radius:16px;background:rgba(255,255,255,.94);transition:bottom .25s}
.map-tl output{flex:none;font-size:.85rem;line-height:1.35}
.map-tl output b{display:block;color:var(--ui-indigo);font-size:1rem}
.map-replay{flex:none;display:grid;place-items:center;width:38px;height:38px;border:1px solid var(--ui-line);border-radius:50%;background:var(--ui-surface);cursor:pointer}
.map-replay:hover{border-color:var(--ui-indigo)}
.map-replay svg{width:20px;height:20px;fill:none;stroke:var(--ui-indigo);stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
/* ที่มาของแผนที่อยู่ล่างสุดของกรอบ — กางออกแล้วแถบจำนวนเลื่อนขึ้นหลบ ไม่ทับกัน (:has ไม่มีใน Safari < 15.4 = ไม่หลบ แต่ข้อความย่อเองหลัง 5 วิ) */
.viz .maplibregl-ctrl-bottom-right{left:0;display:flex;justify-content:flex-end}
.viz:has(.maplibregl-ctrl-attrib.maplibregl-compact-show) .map-tl{bottom:50px}
.viz .maplibregl-ctrl-attrib{background:rgba(255,255,255,.85);font-size:.68rem}
@media (max-width:900px){
  .map-key{right:56px;grid-template-columns:1fr 1fr;gap:2px 10px;font-size:.74rem}
  .map-tl output{min-width:0;font-size:.78rem}
  .viz:has(.maplibregl-ctrl-attrib.maplibregl-compact-show) .map-tl{bottom:66px}
}

/* ── ส่วนเต็มความกว้าง ── */
.sec{padding:80px 0}
.head{display:grid;grid-template-columns:7fr 5fr;gap:40px;align-items:end;margin-bottom:28px}
.head h2{margin:0;color:var(--ui-indigo);font-weight:800;font-stretch:80%;font-size:clamp(1.9rem,3.4vw,2.8rem)}
.head p{margin:0;color:var(--ui-muted)}
.head a{color:var(--ui-indigo);font-weight:700}
.loading{color:var(--ui-muted)}
@media (max-width:900px){.sec{padding:56px 0}.head{grid-template-columns:1fr;gap:10px}}

/* ตรวจสอบศูนย์ + การ์ดผล (ใช้ร่วมกับตรวจสถานะ) */
.verify-form{display:grid;gap:8px;max-width:640px}
.verify-form .row{display:flex;flex-wrap:wrap;gap:10px}
.verify-form .ui-input{flex:1 1 240px;width:auto}
.result-card{max-width:760px;margin-top:20px;padding:24px 28px;border:1px solid var(--ui-line);border-radius:var(--ui-r2);background:var(--ui-surface);color:var(--ui-text)}
.result-card h3{margin:10px 0 4px;font-size:1.3rem}
.result-card .where{margin:0;color:var(--ui-muted)}
.result-card .more{margin:18px 0 0}
.result-card .ui-note{margin-top:14px}
.facts-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px 24px;margin:18px 0 0}
.facts-grid dt{color:var(--ui-muted);font-size:.88rem}
.facts-grid dd{margin:0;font-weight:700;overflow-wrap:anywhere}

/* 5 ขั้น (เป็นลำดับจริงจึงมีเลข) */
.steps{position:relative;display:grid;grid-template-columns:repeat(5,1fr);margin:0;padding:0;list-style:none;counter-reset:s}
.steps::before{content:"";position:absolute;left:28px;right:28px;top:27px;height:3px;background:var(--ui-line)}
.steps li{position:relative;padding:0 16px 0 0;counter-increment:s}
.steps li::before{content:counter(s);position:relative;display:grid;place-items:center;width:56px;height:56px;margin-bottom:14px;border:3px solid var(--ui-indigo);border-radius:50%;background:var(--ui-surface);color:var(--ui-indigo);font-weight:800;font-size:1.3rem}
.steps b{display:block;font-size:1.1rem}
.steps span{display:block;color:var(--ui-muted);font-size:.92rem;line-height:1.6}
@media (max-width:900px){
  .steps{grid-template-columns:1fr;gap:18px}
  .steps::before{left:27px;right:auto;top:0;bottom:0;width:3px;height:auto}
  .steps li{padding-left:76px}
  .steps li::before{position:absolute;left:0;top:0;margin:0}
}
.before{display:flex;flex-wrap:wrap;align-items:center;gap:10px 28px;margin:32px 0 0;padding:20px 24px;border-radius:18px;background:var(--ui-pale)}
.before p{margin:0}
.before .ui-btn{margin-left:auto}

/* ตรวจสถานะ */
.status-panel{display:grid;grid-template-columns:1fr 1.2fr;gap:40px;align-items:center;padding:40px;border-radius:var(--ui-r3);background:var(--ui-indigo-deep);color:#fff}
.status-panel h2{margin:0;font-weight:800;font-stretch:80%;font-size:clamp(1.8rem,3vw,2.4rem)}
.status-panel p{margin:10px 0 0;color:#C6D5F2}
.status-form{display:grid;grid-template-columns:1fr auto;gap:10px}
.status-form #status-q{grid-column:1/-1}
.status-form .status-msg{grid-column:1/-1;margin:0;color:#FFD9D4;font-weight:600}
.status-result{margin-top:4px}
@media (max-width:900px){.status-panel{grid-template-columns:1fr;padding:28px}}
@media (max-width:480px){.status-form{grid-template-columns:1fr}}

/* สถิติ */
.kpis,.insights{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:16px;margin:0}
.insights{margin-top:16px}
.kpis div,.insights div{padding:20px 22px;border:1px solid var(--ui-line);border-radius:var(--ui-r2);background:var(--ui-surface)}
.kpis dt,.insights dt{color:var(--ui-muted);font-size:.92rem}
.kpis dd{margin:4px 0 0;color:var(--ui-indigo);font-weight:800;font-stretch:80%;font-size:2.2rem;line-height:1.15}
.insights dd{margin:4px 0 0;font-weight:700;font-size:1.25rem}
.kpis dd small,.insights dd small{display:block;color:var(--ui-muted);font-weight:400;font-stretch:100%;font-size:.85rem}
.stats-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin-top:16px}
.stats-grid figure{margin:0;padding:20px 22px;border:1px solid var(--ui-line);border-radius:var(--ui-r2);background:var(--ui-surface)}
.stats-grid figure.wide{grid-column:1/-1}
.stats-grid figcaption{margin-bottom:12px;font-weight:700}
@media (max-width:900px){.stats-grid{grid-template-columns:1fr}}
.chart{display:block;width:100%;height:auto}
.chart .bar{fill:var(--ui-indigo)}
.chart .lbl{fill:var(--ui-muted);font-size:12px}
.chart .val{fill:var(--ui-text);font-size:12px;font-weight:700}
.hbars{display:grid;gap:8px;margin:0;padding:0;list-style:none}
.hbars li{display:grid;grid-template-columns:minmax(6.5em,auto) 1fr auto;gap:10px;align-items:center;font-size:.92rem}
.hbars .track{height:10px;border-radius:999px;background:var(--ui-soft);overflow:hidden}
.hbars .fill{display:block;height:100%;border-radius:999px;background:var(--ui-sky)}
.recent{margin:0;padding:0;list-style:none}
.recent li{display:flex;flex-wrap:wrap;justify-content:space-between;gap:4px 12px;padding:10px 0;border-top:1px solid var(--ui-line)}
.recent a{font-weight:600}
.recent small{color:var(--ui-muted)}

/* ข่าว */
.news{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px}
.news article{padding:22px;border:1px solid var(--ui-line);border-radius:var(--ui-r2);background:var(--ui-surface)}
.news article.pinned{border-color:var(--ui-indigo)}
.news .meta{margin:0;color:var(--ui-muted);font-size:.85rem}
.news h3{margin:6px 0 8px;font-size:1.12rem;line-height:1.45}
.news h3 button{all:unset;cursor:pointer;text-decoration:underline;text-decoration-color:var(--ui-line);text-underline-offset:4px}
.news h3 button:hover{text-decoration-color:var(--ui-indigo)}
.news h3 button:focus-visible{outline:3px solid var(--ui-sky);outline-offset:3px;border-radius:4px}
.news p.ex{margin:0;color:var(--ui-muted);font-size:.93rem}
.news-body{white-space:pre-line}
@media (max-width:900px){.news{grid-template-columns:1fr}}

/* ทุน สสส. */
.tssh{display:grid;grid-template-columns:1fr 1fr;gap:24px 40px;padding:32px;border:1px solid #ECE79A;border-radius:var(--ui-r3);background:#FBFAD9}
.tssh h2{margin:4px 0 8px;color:var(--ui-indigo-deep);font-weight:800;font-stretch:80%;font-size:clamp(1.6rem,2.8vw,2.2rem)}
.tssh .by{margin:0;color:var(--ui-wait);font-weight:700}
.tssh h3{margin:0;font-size:1.05rem}
.tssh ol{margin:8px 0 0;padding-left:1.3em}
.tssh .docs{grid-column:1/-1}
@media (max-width:900px){.tssh{grid-template-columns:1fr;padding:24px}}

/* เอกสาร + FAQ */
.library{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:32px}
.library h3{margin:0 0 6px;color:var(--ui-indigo);font-size:1.1rem}
.res-list{margin:0;padding:0;list-style:none}
.res-list li{border-top:1px solid var(--ui-line)}
.res{display:flex;gap:12px;align-items:baseline;padding:12px 0;text-decoration:none}
a.res:hover b{text-decoration:underline}
.res .ft{flex:none;min-width:3.2em;padding:1px 6px;border-radius:6px;background:var(--ui-soft);color:var(--ui-muted);font-size:.72rem;font-weight:800;text-align:center}
.res small{display:block;color:var(--ui-muted);font-size:.88rem}
.res em{display:block;color:var(--ui-indigo);font-style:normal;font-weight:700;font-size:.85rem}
.res.is-coming em{color:var(--ui-muted)}
.faq{grid-column:1/-1}
.faq details{padding:4px 0;border-top:1px solid var(--ui-line)}
.faq summary{padding:10px 0;font-weight:700;cursor:pointer}
.faq details p{margin:0 0 12px;white-space:pre-line}
@media (max-width:900px){.library{grid-template-columns:1fr}}

/* แถบล่างบนมือถือ (ปุ่มเข้าสู่ระบบ / ยื่นคำขอ แบบหน้าเดิม) */
.mobile-cta{display:none}
@media (max-width:700px){
  body.ui{padding-bottom:72px}
  .mobile-cta{position:fixed;left:0;right:0;bottom:0;z-index:900;display:grid;grid-template-columns:1fr 1.4fr;gap:8px;padding:10px 16px calc(10px + env(safe-area-inset-bottom));border-top:1px solid var(--ui-line);background:rgba(250,251,248,.97)}
}

/* ── หน้าศูนย์ 1 แห่ง (center.html — landing center-view.ts) ── */
.page{padding:32px 0 64px}
.crumbs{display:flex;flex-wrap:wrap;gap:6px;margin:0 0 20px;padding:0;color:var(--ui-muted);font-size:.9rem;list-style:none}
.crumbs li+li::before{content:"›";margin-right:6px}
.page h1{margin:8px 0 4px;color:var(--ui-indigo);font-weight:800;font-stretch:80%;font-size:clamp(1.8rem,3.6vw,2.6rem)}
.center-facts{display:grid;grid-template-columns:auto 1fr;gap:8px 24px;margin:24px 0}
.center-facts dt{color:var(--ui-muted)}
.center-facts dd{margin:0;font-weight:600}
.center-map{position:relative;height:360px;border:1px solid var(--ui-line);border-radius:var(--ui-r2);overflow:hidden;background:var(--map-bg)}
.center-map:empty{display:none}
.center-actions{margin:20px 0 0}
@media (max-width:640px){.center-facts{grid-template-columns:1fr}.center-facts dd{margin-bottom:8px}}
@media (prefers-reduced-motion: reduce){.map-tl{transition:none}}
