/* หน้ารวม SDG (แบบ O-D) และหน้าเป้าหมาย (แบบ G-A)
   ใช้เฉพาะคลาส .sdg-* ไม่ให้สไตล์ไปทับข่าวหรือหลังบ้าน
   ระยะซ้าย 380px ตามหน้าในจริง จนจอกว้างไม่เกิน 900px จึงยุบเมนู
   ไอคอนทางการของสหประชาชาติเป็นสี่เหลี่ยม ไม่ตัดมุม ไม่ย้อมสี
   รูปใช้ height: auto เพื่อไม่ให้แอตทริบิวต์ height ใน HTML ดันความสูงเกินสัดส่วน */
.sdg-page {
  --sdg-purple: #9e5da5;
  --sdg-deep: #7d4485;
  --sdg-soft: #ebdcee;
  --sdg-page: #fbf8fc;
  --sdg-ink: #2a2130;
  --sdg-muted: #64596b;
  --sdg-card: #ffffff;
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  padding: 104px var(--g, 24px) 80px calc(var(--g, 24px) + 380px);
  background: var(--sdg-page);
  color: var(--sdg-ink);
  font-family: "LINE Seed Sans TH", "LINE Seed", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
}

.sdg-page *,
.sdg-page *::before,
.sdg-page *::after { box-sizing: border-box; }

.sdg-page :focus-visible {
  outline: 3px solid #7d4485;
  outline-offset: 4px;
}

.sdg-page h1,
.sdg-page h2,
.sdg-page p { margin: 0; }

.sdg-page a { color: var(--sdg-deep); }

/* กันแอตทริบิวต์ height ใน HTML ไม่ให้ดันรูปสูงเกินสัดส่วนที่ CSS กำหนด */
.sdg-page img {
  max-width: 100%;
  height: auto;
}

.sdg-status,
.sdg-error {
  margin: 0 0 16px;
  color: var(--sdg-muted);
}

.sdg-error { color: var(--sdg-deep); }

.sdg-bc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--sdg-muted);
}

.sdg-bc a { color: inherit; text-decoration: none; }

.sdg-sample {
  display: inline-block;
  margin-top: 16px;
  padding: 4px 12px;
  border-radius: 8px;
  background: var(--sdg-soft);
  color: var(--sdg-deep);
  font-size: 12px;
  line-height: 1.7;
}

/* ===== หัวหน้ารวมแบบ O-D (กะทัดรัด ไม่มีภาพนำ) ===== */
.sdg-ov-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 8px 24px;
  margin-bottom: 8px;
}

.sdg-ov-head h1 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.35;
}

.sdg-ov-desc {
  margin-top: 4px;
  max-width: 46em;
  color: var(--sdg-muted);
  font-size: 15px;
  line-height: 1.5;
}

.sdg-ov-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sdg-ov-stats span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  background: var(--sdg-soft);
  color: var(--sdg-deep);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.sdg-page .sdg-ov-note {
  margin: 0 0 32px;
  color: var(--sdg-muted);
  font-size: 13px;
  line-height: 1.45;
}

/* กริดการ์ดขาว 4 คอลัมน์ ไอคอนคู่ชื่อไทย จำนวนข่าวอยู่ในคอลัมน์ข้อความ ไม่แยกแถบล่าง */
.sdg-grid-od {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
  align-items: stretch;
}

.sdg-tile-od {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  min-height: 44px;
  padding: 16px;
  background: var(--sdg-card);
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.sdg-tile-od:hover { transform: translateY(-2px); }

.sdg-tile-od-top {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  flex: 1 1 auto;
}

.sdg-tile-od img {
  display: block;
  width: 88px;
  height: 88px;
  object-fit: contain;
  background: transparent;
  border-radius: 0;
}

.sdg-tile-od-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.sdg-tile-od-name {
  font-size: 15px;
  line-height: 1.45;
  color: var(--sdg-ink);
}

.sdg-tile-od-count {
  display: block;
  margin: 0;
  padding: 0;
  background: transparent;
  color: var(--sdg-muted);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
}

.sdg-tile-od.has-news .sdg-tile-od-count {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 99px;
  background: #ebdcee;
  color: #7d4485;
  font-weight: 700;
  line-height: 1.3;
}

/* ===== หัวหน้าเป้าหมายแบบ G-A ===== */
.sdg-goal-head {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 16px 20px;
  align-items: center;
  margin-bottom: 14px;
}

.sdg-goal-head img {
  display: block;
  width: 112px;
  height: 112px;
  object-fit: contain;
  background: transparent;
  border-radius: 0;
}

.sdg-goal-kicker {
  display: block;
  color: var(--sdg-deep);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.sdg-goal-head h1 {
  margin: 2px 0 4px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.35;
}

.sdg-goal-lead {
  color: var(--sdg-muted);
  font-size: 15px;
  line-height: 1.5;
}

.sdg-goal-count {
  margin-top: 6px;
  color: var(--sdg-muted);
  font-size: 14px;
}

.sdg-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 14px;
}

.sdg-switch-lbl {
  flex: 1 1 auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--sdg-ink);
}

.sdg-switch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1 1 100%;
}

.sdg-switch-row a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 4px;
  text-decoration: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.sdg-switch-row a:hover { transform: translateY(-1px); }

.sdg-switch-row a img {
  display: block;
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 0;
}

.sdg-switch-row a.is-current { background: var(--sdg-soft); opacity: 1; }

.sdg-switch-row a[data-count="0"] { opacity: 0.72; }

.sdg-switch-row a.is-current[data-count="0"] { opacity: 1; }

.sdg-all {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.sdg-pager {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.sdg-pager a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 8px;
  font-weight: 700;
  text-decoration: none;
}

/* การ์ดข่าว 4 คอลัมน์ ภาพ 16:9 */
.sdg-news {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.sdg-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--sdg-card);
  color: inherit;
  border-radius: 12px;
}

.sdg-media {
  display: block;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  color: inherit;
  text-decoration: none;
  background: var(--sdg-soft);
  border-radius: 12px 12px 0 0;
}

.sdg-media img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
}

.sdg-img-miss {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  width: 100%;
  min-height: 80px;
  aspect-ratio: 16 / 9;
  color: var(--sdg-muted);
  font-size: 14px;
  background: var(--sdg-soft);
}

.sdg-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px 14px;
}

.sdg-card time,
.sdg-card-date { color: var(--sdg-muted); font-size: 13px; }

.sdg-card h2 {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
  padding: 2px 0;
}

.sdg-card h2 a { color: var(--sdg-ink); text-decoration: none; }

.sdg-card h2 a:hover { color: var(--sdg-deep); }

.sdg-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.sdg-badges a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 6px;
  text-decoration: none;
}

.sdg-badges img {
  width: 32px;
  height: 32px;
  border-radius: 0;
  object-fit: contain;
  background: transparent;
}

.sdg-more {
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.sdg-empty {
  padding: 24px;
  border-radius: 12px;
  background: var(--sdg-card);
}

.sdg-empty h2 {
  margin-bottom: 8px;
  font-size: 22px;
  line-height: 1.45;
}

.sdg-empty p { color: var(--sdg-muted); }

.sdg-empty p + p { margin-top: 8px; }

.sdg-page .sdg-fine {
  margin-top: 48px;
  color: var(--sdg-muted);
  font-size: 12px;
  line-height: 1.7;
}

.sdg-fine a { color: var(--sdg-deep); }

/* ===== จอ ===== */
@media (max-width: 1199px) {
  .sdg-grid-od { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sdg-news { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sdg-ov-head h1,
  .sdg-goal-head h1 { font-size: 24px; }
}

@media (max-width: 900px) {
  .sdg-page { padding: 88px 16px 96px; }
  .sdg-bc { padding-left: 72px; }
}

@media (max-width: 768px) {
  /* กันแถบนำทางล่าง (.mnav-bar) ทับเนื้อหาท้ายหน้า รวมข้อความที่มาไอคอน ระยะอยู่ท้าย .sdg-page ไม่ใส่ที่กริด/รายการข่าว เพื่อไม่ให้หน้าว่างมีช่องว่างเกิน */
  html { scroll-padding-bottom: 120px; }
  .sdg-page { padding-bottom: 120px; }
  .sdg-grid-od {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }
  .sdg-tile-od-top { grid-template-columns: 1fr; gap: 8px; }
  .sdg-tile-od img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
  }
  .sdg-tile-od-name { font-size: 13px; }
  .sdg-ov-head h1 { font-size: 24px; line-height: 1.4; }
  .sdg-goal-head {
    grid-template-columns: 80px minmax(0, 1fr);
    gap: 12px;
  }
  .sdg-goal-head img { width: 80px; height: 80px; }
  .sdg-goal-head h1 { font-size: 22px; }
  .sdg-news {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .sdg-card h2 { font-size: 15px; }
  .sdg-card-body { padding: 10px 10px 12px; }
}

@media (max-width: 359px) {
  .sdg-grid-od { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .sdg-tile-od,
  .sdg-switch-row a { transition: none; }
  .sdg-tile-od:hover,
  .sdg-switch-row a:hover { transform: none; }
}
