/* Thasala School — เว็บไซต์สาธารณะ
   Layout: แถบกลุ่มผู้ใช้ → header + เมนู 6 หมวด → เนื้อหาเป็นแถบ ๆ → footer 3 คอลัมน์ (แนวทาง kku.ac.th)
   ค่าสีหลัก/รอง/พื้นหลังถูกแทนด้วยค่าจาก CONFIG ตอนโหลดหน้า */
:root {
  --purple: #400080;
  --purple-deep: #2b0057;
  --purple-tint: #efe8f7;
  --orange: #F28C28;
  --orange-ink: #a85500;
  --bg: #F7F5FA;
  --surface: #ffffff;
  --ink: #1e1530;
  --muted: #5d5470;
  --line: #e3dbee;
  --font: "IBM Plex Sans Thai", "Sarabun", "Noto Sans Thai", "Tahoma", sans-serif;
  --radius: 10px;
  --wrap: 1180px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.3; text-wrap: balance; margin: 0; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; border-radius: 4px; }
.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: 16px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } html { scroll-behavior: auto; } }

/* ---------- แถบบนสุด ---------- */
.topbar { background: var(--purple-deep); color: #e9e0f5; font-size: 13.5px; }
.topbar .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; padding-block: 6px; }
.topbar .aud { display: flex; flex-wrap: wrap; gap: 4px 16px; flex: 1; min-width: 0; }
.topbar a { text-decoration: none; opacity: .9; }
.topbar a:hover { opacity: 1; text-decoration: underline; }
.topbar .tools { display: flex; gap: 10px; align-items: center; }
.btn-en { border: 1px solid rgba(255,255,255,.35); border-radius: 999px; padding: 1px 10px; font-weight: 600; letter-spacing: .04em; }
.search { display: flex; }
.search input { width: 150px; border: 0; border-radius: 999px 0 0 999px; padding: 3px 12px; font: inherit; font-size: 13px; background: rgba(255,255,255,.12); color: #fff; }
.search input::placeholder { color: #cbbde0; }
.search button { border: 0; border-radius: 0 999px 999px 0; background: var(--orange); color: #fff; padding: 0 10px; cursor: pointer; font: inherit; font-size: 13px; }

/* ---------- header + เมนู ---------- */
.header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; }
.header .wrap { display: flex; align-items: center; gap: 20px; min-height: 76px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; flex-shrink: 0; }
.brand .logo { width: 52px; height: 52px; border-radius: 50%; object-fit: contain; }
.brand .mono { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--purple); color: #fff; font-weight: 700; font-size: 24px; box-shadow: inset 0 0 0 3px var(--orange); }
.brand .th { font-weight: 700; font-size: 20px; color: var(--purple); display: block; line-height: 1.2; }
.brand .en { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); display: block; }
.nav { margin-left: auto; }
.nav > ul { list-style: none; margin: 0; padding: 0; display: flex; }
.nav > ul > li { position: relative; }
.nav > ul > li > a { display: block; white-space: nowrap; padding: 26px 9px; text-decoration: none; font-weight: 600; font-size: 15px; border-bottom: 3px solid transparent; }
.nav > ul > li > a .n { color: var(--orange-ink); font-size: 12px; margin-right: 4px; font-variant-numeric: tabular-nums; }
.nav > ul > li:hover > a, .nav > ul > li:focus-within > a, .nav > ul > li > a.on { border-bottom-color: var(--orange); color: var(--purple); }
.mega { position: absolute; right: 0; top: 100%; width: 330px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--purple); border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 18px 40px rgba(43,0,87,.14); padding: 16px 18px; display: none; }
.nav > ul > li:nth-child(-n+3) .mega { left: 0; right: auto; }
.nav > ul > li:hover .mega, .nav > ul > li:focus-within .mega { display: block; }
.mega .aud { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.mega ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.mega a { display: block; padding: 6px 8px; border-radius: 6px; text-decoration: none; font-size: 15px; }
.mega a:hover { background: var(--purple-tint); color: var(--purple); }
.burger { display: none; margin-left: auto; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 12px; font: inherit; font-weight: 600; cursor: pointer; color: var(--purple); }

@media (max-width: 1260px) {
  .burger { display: block; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 100%; background: var(--surface); border-bottom: 1px solid var(--line); max-height: 75vh; overflow-y: auto; }
  .nav.open { display: block; }
  .nav > ul { flex-direction: column; padding: 8px 16px 16px; }
  .nav > ul > li > a { padding: 12px 4px; border-bottom: 1px solid var(--line); }
  .mega { position: static; display: block; width: auto; border: 0; box-shadow: none; padding: 4px 0 10px 14px; }
  .mega .aud { display: none; }
  .search input { width: 110px; }
}

@media (max-width: 600px) { .topbar .aud { display: none; } .topbar .tools { flex: 1; justify-content: space-between; } .search input { width: 100%; } .search { flex: 1; } }

/* ---------- ส่วนประกอบทั่วไป ---------- */
main { min-height: 50vh; }
.band { padding-block: 44px; }
.band.alt { background: var(--surface); border-block: 1px solid var(--line); }
.band-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.band-head h2 { font-size: 26px; color: var(--purple); }
.band-head h2::after { content: ""; display: block; width: 44px; height: 4px; background: var(--orange); border-radius: 2px; margin-top: 8px; }
.more { color: var(--purple); font-weight: 600; text-decoration: none; font-size: 15px; }
.more:hover { text-decoration: underline; }
.empty { border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 22px; color: var(--muted); text-align: center; background: var(--surface); }
.sample-note { background: #fff4e6; color: var(--orange-ink); border: 1px solid #f6d3ad; border-radius: var(--radius); padding: 8px 14px; font-size: 14px; margin-bottom: 16px; }
.loading { color: var(--muted); padding-block: 60px; text-align: center; }

/* ---------- hero ---------- */
.hero { background: var(--purple); color: #fff; position: relative; overflow: hidden; }
.hero .wrap { display: grid; grid-template-columns: 1.2fr .8fr; gap: 32px; align-items: center; padding-block: 48px; position: relative; }
.hero .eyebrow { color: var(--orange); font-weight: 600; letter-spacing: .08em; font-size: 14px; }
.hero h1 { font-size: clamp(30px, 4.4vw, 48px); margin: 6px 0 12px; }
.hero p { margin: 0 0 22px; color: #e5dbf3; max-width: 34em; }
.hero .cta { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-block; text-decoration: none; font-weight: 600; padding: 10px 20px; border-radius: 999px; border: 2px solid transparent; }
.btn.primary { background: var(--orange); color: #fff; }
.btn.ghost { border-color: rgba(255,255,255,.55); color: #fff; }
.btn:hover { filter: brightness(1.07); }
.hero .slide { aspect-ratio: 16 / 9; width: 100%; max-width: 100%; border-radius: var(--radius); background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); overflow: hidden; display: grid; place-items: center; text-align: center; color: #d9cbee; font-size: 14px; }
.hero .slide img { width: 100%; height: 100%; object-fit: cover; }
.hero::before { content: ""; position: absolute; right: -120px; top: -120px; width: 380px; height: 380px; border-radius: 50%; border: 56px solid rgba(242,140,40,.16); }
@media (max-width: 760px) { .hero .wrap { grid-template-columns: 1fr; padding-block: 32px; } }

.jump { background: var(--surface); border-bottom: 1px solid var(--line); }
.jump .wrap { display: flex; gap: 6px 22px; flex-wrap: wrap; padding-block: 10px; font-size: 14px; }
.jump a { text-decoration: none; color: var(--muted); font-weight: 600; }
.jump a:hover { color: var(--purple); }

/* ---------- e-Service ---------- */
.services { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.svc { display: flex; flex-direction: column; gap: 10px; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; transition: border-color .15s, transform .15s; }
.svc:hover { border-color: var(--purple); transform: translateY(-2px); }
.svc .ic { width: 40px; height: 40px; border-radius: 10px; background: var(--purple-tint); color: var(--purple); display: grid; place-items: center; }
.svc .ic svg { width: 22px; height: 22px; }
.svc b { font-size: 15px; line-height: 1.35; }

/* ---------- ข่าว ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; display: flex; flex-direction: column; }
.card .cover { aspect-ratio: 16 / 9; max-width: 100%; background: var(--purple-tint); display: grid; place-items: center; color: var(--purple); font-weight: 700; }
.card .cover img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 14px 16px 18px; display: grid; gap: 6px; }
.card time, .meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card h3 { font-size: 17px; }
.card:hover h3 { color: var(--purple); }
.tag { display: inline-block; font-size: 12px; font-weight: 600; color: var(--orange-ink); background: #fff1e2; border-radius: 999px; padding: 0 9px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { font: inherit; font-weight: 600; font-size: 15px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 6px 16px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--purple); color: #fff; border-color: var(--purple); }
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.list li + li { border-top: 1px solid var(--line); }
.list a { display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 12px 16px; text-decoration: none; }
.list a:hover { background: var(--purple-tint); }
.list a > span:last-child { min-width: 0; }
@media (max-width: 520px) { .list a { grid-template-columns: 1fr; gap: 2px; } }

.events { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.ev { display: grid; grid-template-columns: 62px 1fr; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.ev .d { background: var(--purple); color: #fff; border-radius: 8px; text-align: center; padding: 6px 0; line-height: 1.15; }
.ev .d b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.ev .d span { font-size: 13px; color: #f9c58f; }
.ev h3 { font-size: 16px; }

/* ---------- หน้าหมวด ---------- */
.banner { background: var(--purple); color: #fff; }
.banner .wrap { padding-block: 36px 32px; }
.crumb { font-size: 14px; color: #d4c4ea; margin-bottom: 8px; }
.crumb a { text-decoration: none; }
.crumb a:hover { text-decoration: underline; }
.banner .num { color: var(--orange); font-weight: 700; font-variant-numeric: tabular-nums; }
.banner h1 { font-size: clamp(28px, 4vw, 40px); }
.banner p { margin: 8px 0 0; color: #e0d4f0; }
.subgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.sub { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; font-weight: 600; }
.sub::after { content: "→"; color: var(--orange-ink); }
.sub:hover { border-color: var(--purple); color: var(--purple); }

.page-layout { display: grid; grid-template-columns: 250px 1fr; gap: 28px; align-items: start; }
.side { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; position: sticky; top: 96px; }
.side a { display: block; padding: 7px 10px; border-radius: 6px; text-decoration: none; font-size: 15px; }
.side a.on { background: var(--purple); color: #fff; }
.side a:not(.on):hover { background: var(--purple-tint); }
.content { min-width: 0; }
@media (max-width: 860px) { .page-layout { grid-template-columns: 1fr; } .side { position: static; } }

/* กล่องจาก Page Builder (ตาราง 12 คอลัมน์) */
.grid12 { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.blk { min-width: 0; background: var(--surface); border-radius: var(--radius); }
.blk.text { padding: 20px 22px; border: 1px solid var(--line); }
.blk.text :first-child { margin-top: 0; }
@media (max-width: 760px) { .grid12 { grid-template-columns: 1fr; } .blk { grid-column: auto !important; } }

.article { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.article .cover { margin: -24px -24px 20px; aspect-ratio: 16/9; overflow: hidden; border-radius: var(--radius) var(--radius) 0 0; }
.article .cover img { width: 100%; height: 100%; object-fit: cover; }

/* ค้นหาเกียรติบัตร */
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.form label { display: grid; gap: 4px; font-size: 14px; font-weight: 600; color: var(--muted); }
.form input { font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.form button { font: inherit; font-weight: 600; background: var(--purple); color: #fff; border: 0; border-radius: 8px; padding: 10px 16px; cursor: pointer; }
.table-wrap { overflow-x: auto; margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--purple-tint); color: var(--purple); }
td { font-variant-numeric: tabular-nums; }

/* ---------- footer ---------- */
.footer { background: var(--purple-deep); color: #d9cdea; margin-top: 56px; font-size: 15px; }
.footer .cols { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: 28px; padding-block: 40px 28px; }
.footer h4 { color: #fff; margin: 0 0 10px; font-size: 16px; }
.footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.footer a { text-decoration: none; }
.footer a:hover { color: #fff; text-decoration: underline; }
.footer .addr { display: grid; gap: 4px; }
.footer .copy { border-top: 1px solid rgba(255,255,255,.12); padding-block: 14px; font-size: 13px; color: #b6a6cf; }
@media (max-width: 860px) { .footer .cols { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .footer .cols { grid-template-columns: 1fr; } }

/* ---------- สไลด์โชว์เต็มความกว้าง 16:9 ---------- */
.slider { position: relative; width: 100%; aspect-ratio: 16 / 9; max-width: 100%; overflow: hidden; background: var(--purple-deep); }
.slider-track { display: flex; height: 100%; transition: transform .6s ease; }
.slide-item { flex: 0 0 100%; height: 100%; }
.slide-item a, .slide-item img { display: block; width: 100%; height: 100%; }
.slide-item img { object-fit: cover; }
.sl-btn { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(43,0,87,.55); color: #fff; font-size: 28px; line-height: 1; cursor: pointer; display: grid; place-items: center; padding-bottom: 4px; }
.sl-btn:hover { background: var(--orange); }
.sl-btn.prev { left: 16px; }
.sl-btn.next { right: 16px; }
.sl-dots { position: absolute; left: 0; right: 0; bottom: 14px; display: flex; justify-content: center; gap: 8px; }
.sl-dots button { width: 10px; height: 10px; border-radius: 50%; border: 0; background: rgba(255,255,255,.55); cursor: pointer; padding: 0; }
.sl-dots button[aria-current="true"] { background: var(--orange); width: 26px; border-radius: 5px; }
@media (max-width: 600px) { .sl-btn { width: 34px; height: 34px; font-size: 22px; } .sl-dots { bottom: 8px; } }

.footer .copy { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.admin-link { color: #f9c58f; font-weight: 600; }
