/* Public announcement site. Colours from the KTCS logo and the old app.
   Font: Sarabun (SIL OFL 1.1, fonts/OFL-Sarabun.txt), served from this site. */

@font-face { font-family: "Sarabun"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/assets/fonts/sarabun-thai-400-normal.woff2) format("woff2"); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Sarabun"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(/assets/fonts/sarabun-thai-600-normal.woff2) format("woff2"); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Sarabun"; font-style: normal; font-weight: 700; font-display: swap;
  src: url(/assets/fonts/sarabun-thai-700-normal.woff2) format("woff2"); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Sarabun"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/assets/fonts/sarabun-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Sarabun"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(/assets/fonts/sarabun-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Sarabun"; font-style: normal; font-weight: 700; font-display: swap;
  src: url(/assets/fonts/sarabun-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --brand: #01a6e6;          /* KTCS logo blue */
  --brand-dark: #0072a8;     /* links, labels on white */
  --brand-ink: #063a55;
  --brand-soft: #e8f6fd;
  --yellow: #ffd23f;
  --yellow-dark: #f5c000;
  --text: #1a2230;
  --text-2: #475467;
  --muted: #6b7484;
  --line: #e4e8ee;
  --bg: #f6f8fb;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-hover: 0 4px 12px rgba(16, 24, 40, 0.10);
  /* spacing scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --font: "Sarabun", "Leelawadee UI", "Thonburi", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 17px; line-height: 1.6; color: var(--text);
  background: var(--bg); min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; padding-top: var(--s6); padding-bottom: var(--s7); }
a { color: var(--brand-dark); text-underline-offset: 2px; }
a:hover { color: var(--brand-ink); }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.35; }
.wrap { width: 100%; max-width: 1200px; margin-left: auto; margin-right: auto; padding-left: var(--s5); padding-right: var(--s5); }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; background: #fff; padding: 8px 12px; z-index: 30; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; border-radius: 6px; }

/* ---- header: sticky blue bar, logo left, menu centred ---- */
.site-header { position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06); }
/* logo + name | menu centred in the space that is left | login (when shown) */
.header-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0; min-height: 68px; }
.brand { display: flex; align-items: center; gap: var(--s3); color: #fff; text-decoration: none; justify-self: start; min-width: 0; }
.brand:hover { color: #fff; }
.brand-logo { display: block; height: 40px; width: auto; }
.brand-site { font-size: 19px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.nav { display: flex; gap: var(--s2); justify-self: center; margin: 0 var(--s5); }
.header-end { justify-self: end; }
.header-end:not(:has(:not([hidden]))) { display: none; }  /* no login button: the menu centres in all the space left */
.nav-link {
  display: inline-flex; align-items: center; gap: var(--s2); padding: 8px 16px; border-radius: 999px;
  font-weight: 600; font-size: 16px; text-decoration: none; white-space: nowrap; line-height: 1.2;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.15s var(--ease);
}
.nav-link:active { transform: translateY(1px); }
.nav-icon { flex: none; }
.nav-short { display: none; }
.nav-home { color: #fff; background: rgba(255, 255, 255, 0.14); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28); }
.nav-home:hover { color: #fff; background: rgba(255, 255, 255, 0.26); }
.nav-home[aria-current="page"] { background: #fff; color: var(--brand-dark); box-shadow: none; }
.nav-yellow { color: var(--brand-ink); background: var(--yellow); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15); }
.nav-yellow:hover { color: var(--brand-ink); background: var(--yellow-dark); }
.nav-yellow[aria-current="page"] { box-shadow: 0 0 0 3px #fff; }
.nav-count {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--brand-ink); color: #fff;
  font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.nav-count-zero { background: rgba(6, 58, 85, 0.16); color: rgba(6, 58, 85, 0.7); }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); padding: 8px 18px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-size: 15px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.btn:hover { border-color: var(--brand); color: var(--brand-dark); }
.btn-small { padding: 4px 14px; font-size: 14px; }
/* staff sign-in: right end of the top bar, outlined so it does not read as a menu item */
.btn-staff {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; white-space: nowrap;
  color: #fff; text-decoration: none; font-size: 15px; font-weight: 600; line-height: 1.2; cursor: pointer;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.75);
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.btn-staff:hover { background: #fff; color: var(--brand-dark); }
.btn-staff[aria-disabled="true"] { cursor: default; }
.staff-icon { flex: none; }
/* notice under the staff button while the back office is not open yet */
.header-end { position: relative; }
.staff-toast {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; white-space: nowrap;
  padding: 8px 14px; border-radius: 8px; background: #fdecea; color: #b42318; border: 1px solid #f5b5ad;
  font-size: 14px; font-weight: 600; line-height: 1.3; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.staff-toast[hidden] { display: none; }
.staff-toast:empty { visibility: hidden; }

/* ---- tabs (home) ---- */
.tabs { display: flex; gap: var(--s2); flex-wrap: wrap; margin: 0 0 var(--s4); }
.tab {
  font: inherit; font-size: 16px; font-weight: 600; padding: 8px 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text-2);
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.tab:hover { border-color: var(--brand); color: var(--brand-dark); }
.tab[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }

.tabs-wrap { position: relative; }
.tabs-arrow {
  position: absolute; top: 0; bottom: var(--s1); z-index: 2; width: 40px; border: 0; padding: 0; cursor: pointer;
  color: var(--brand-dark); display: flex; align-items: center;
}
.tabs-arrow svg { display: block; }
.tabs-prev { left: calc(-1 * var(--s4)); justify-content: flex-start; padding-left: 6px; background: linear-gradient(90deg, var(--bg) 55%, rgba(246, 248, 251, 0)); }
.tabs-next { right: calc(-1 * var(--s4)); justify-content: flex-end; padding-right: 6px; background: linear-gradient(270deg, var(--bg) 55%, rgba(246, 248, 251, 0)); }
.tabs-arrow:hover { color: var(--brand-ink); }

/* ---- list head ---- */
.list-head { display: flex; align-items: center; gap: var(--s3) var(--s5); flex-wrap: wrap; margin-bottom: var(--s4); }
.list-title { font-size: 26px; margin: 0; flex: 1 1 240px; }
.search { flex: 0 1 380px; width: 100%; }
.search input {
  width: 100%; font: inherit; font-size: 16px; padding: 10px 16px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--card); color: var(--text);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(1, 166, 230, 0.2); }

/* ---- rows: cards with a square picture (the old app's picture slot) ---- */
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.row { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease); }
.row:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.row-link {
  display: grid; grid-template-columns: 88px 1fr 20px; gap: var(--s4); align-items: center;
  padding: var(--s4); color: inherit; text-decoration: none; border-radius: var(--radius);
}
.row-thumb { width: 88px; height: 88px; border-radius: 10px; overflow: hidden; background: var(--brand-soft); }
.row-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-date { color: var(--brand-dark); font-size: 14px; }
.row-title { font-weight: 700; font-size: 18px; line-height: 1.45; overflow-wrap: anywhere; }
.row-summary {
  color: var(--muted); font-size: 15px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow-wrap: anywhere;
}
.row-chevron { color: var(--muted); font-size: 26px; line-height: 1; text-align: center; transition: transform 0.2s var(--ease); }
.row:hover .row-chevron { transform: translateX(2px); color: var(--brand-dark); }
.state { text-align: center; color: var(--muted); padding: var(--s7) 0; }

/* empty / not found / error */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--s1); padding: var(--s7) var(--s4); }
.empty-icon { width: 56px; height: 56px; color: var(--brand); background: var(--brand-soft); border-radius: 50%; padding: 12px; margin-bottom: var(--s2); }
.empty-error .empty-icon { color: #b54708; background: #fef0e0; }
.empty-title { margin: 0; font-size: 19px; font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.empty-hint { margin: 0; font-size: 15px; color: var(--muted); }

/* default picture: the old app's "ประกาศ" tile, drawn with the site font */
.row-thumb-default {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #f2fafe 0%, var(--brand-soft) 100%); box-shadow: inset 0 0 0 1px #d4eef9;
}
.row-thumb-default span { color: var(--brand); font-weight: 700; font-size: 21px; letter-spacing: 0.2px; }

/* loading skeleton */
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.sk {
  display: block; border-radius: 6px;
  background: linear-gradient(90deg, #eceff3 25%, #f6f8fa 50%, #eceff3 75%); background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.sk-line { height: 14px; margin: 6px 0; width: 100%; }
.sk-short { width: 35%; }
.sk-mid { width: 60%; }
.sk-title { height: 18px; width: 75%; }
.sk-heading { height: 28px; width: 80%; margin: 10px 0 14px; }
.sk-block { height: 120px; margin: 20px 0; }
.row-skeleton:hover { box-shadow: var(--shadow); transform: none; }
.more { text-align: center; margin-top: var(--s5); }

/* ---- detail ---- */
.crumbs { font-size: 15px; color: var(--muted); margin: 0 0 var(--s4); overflow-wrap: anywhere; }
.crumb-sep { margin: 0 var(--s1); }
.crumbs span:last-child { color: var(--text); }
.article { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--s6); }
.article-head { margin-bottom: var(--s5); }
.eyebrow { color: var(--brand-dark); font-size: 15px; font-weight: 600; margin: 0 0 var(--s1); display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.chip { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--brand-soft); color: var(--brand-dark); }
.chip-open { background: #e7f6ec; color: #17663a; }
.chip-upcoming { background: #fff4d6; color: #7a5300; }
.chip-closed { background: #eef0f3; color: var(--text-2); }
.article-title { font-size: 30px; margin: 0 0 var(--s2); overflow-wrap: anywhere; }
.dateline { margin: 0; font-size: 17px; color: var(--text-2); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s5) var(--s6); margin: 0 0 var(--s5); }
.fields:empty { display: none; }
.field { min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field-label { color: var(--brand-dark); font-size: 14px; font-weight: 600; margin: 0 0 var(--s1); }
.field-value { font-size: 17px; margin: 0; overflow-wrap: anywhere; }
.article-body { overflow-wrap: anywhere; }
.article-body > :first-child { margin-top: 0; }
.article-body > :last-child { margin-bottom: 0; }
.article-body p, .article-body ul, .article-body ol, .article-body table { margin: 0 0 var(--s3); }
.article-body ul, .article-body ol { padding-left: 1.4em; }
.article-body table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; }
.article-body th, .article-body td { border: 1px solid var(--line); padding: 6px 12px; text-align: left; }
.article-body th { background: var(--bg); }
.article-body pre { white-space: pre-wrap; background: var(--bg); padding: var(--s3); border-radius: 8px; }
.article-body blockquote { margin: 0 0 var(--s3); padding-left: var(--s3); border-left: 4px solid var(--line); color: var(--muted); }

.media { margin-top: var(--s5); display: grid; gap: var(--s5); }
.photo { margin: 0; }
.photo img { display: block; max-width: 100%; height: auto; border-radius: 10px; }
.pdf { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pdf-head { display: flex; align-items: center; gap: var(--s3); justify-content: space-between; padding: var(--s3) var(--s4); background: var(--bg); }
.pdf-name { font-weight: 600; overflow-wrap: anywhere; }
.pdf-frame { display: block; width: 100%; height: 80vh; min-height: 480px; border: 0; background: #525659; }

.block { margin-top: var(--s6); padding-top: var(--s5); border-top: 1px solid var(--line); }
.block h2, .section-title { font-size: 19px; margin: 0 0 var(--s3); }
.section-title { margin-top: var(--s6); }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.file-link {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border: 1px solid var(--line);
  border-radius: 10px; text-decoration: none; color: var(--text); transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.file-link:hover { border-color: var(--brand); background: var(--brand-soft); }
.file-type {
  flex: none; min-width: 48px; text-align: center; font-size: 12px; font-weight: 700;
  background: var(--brand-soft); color: var(--brand-dark); border-radius: 6px; padding: 2px 6px;
}
.file-name { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--brand-dark); }
.file-kind { display: inline-block; margin-right: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.file-kind::after { content: " ·"; }
.file-size { flex: none; font-size: 13px; }
.channel-list { list-style: none; margin: 0 0 var(--s2); padding: 0; display: grid; gap: var(--s2); }
.channel { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); align-items: baseline; }
.channel-label { color: var(--muted); font-size: 15px; min-width: 140px; }
.channel-value { overflow-wrap: anywhere; font-weight: 600; }

/* ---- footer: one sticky line ---- */
.site-footer {
  position: sticky; bottom: 0; z-index: 10; text-align: center; font-size: 12px; line-height: 1;
  color: var(--muted); background: rgba(246, 248, 251, 0.94); border-top: 1px solid var(--line); padding: 6px 0 7px;
}

/* ---- motion: page cross-fade (supporting browsers) and content fade-in ---- */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.18s; }
.site-header { view-transition-name: site-header; }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fade-up 0.25s var(--ease) both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  @view-transition { navigation: none; }
}

/* ---- narrow screens ---- */
@media (max-width: 999px) and (min-width: 761px) {
  .brand-site { display: none; }
}
/* with the staff button the bar needs more room: drop the site name earlier (tablet/desktop only) */
@media (max-width: 1199px) and (min-width: 761px) {
  .header-row:has(.btn-staff:not([hidden])) .brand-site { display: none; }
}
@media (max-width: 760px) {
  body { font-size: 16px; }
  .wrap { padding-left: var(--s4); padding-right: var(--s4); }
  /* phones: slim top bar with the logo; the menu becomes a bottom navigation bar */
  .site-header { view-transition-name: none; }
  .header-row { grid-template-columns: 1fr auto; gap: var(--s3); padding-top: var(--s2); padding-bottom: var(--s2); min-height: 52px; }
  .brand { gap: var(--s2); }
  /* phones: square logo (picture source) + the full site name on one line */
  .brand-logo { height: 32px; width: 32px; border-radius: 7px; }
  .brand-site { font-size: 16px; overflow: visible; }
  .header-end { margin-left: var(--s2); }
  .btn-staff { padding: 6px 11px; font-size: 13px; gap: 5px; }
  .btn-staff .staff-icon { width: 16px; height: 16px; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; justify-self: stretch; align-self: end; width: auto;
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 6px; padding: 6px var(--s2) calc(6px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.97); border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(16, 24, 40, 0.06);
  }
  .nav-link {
    flex-direction: column; justify-content: center; gap: 2px; padding: 6px 2px; border-radius: 12px;
    font-size: 12px; position: relative; box-shadow: none;
  }
  .nav-label { display: none; }
  .nav-short { display: inline; white-space: nowrap; text-align: center; line-height: 1.2; }  /* full words on one line */
  .nav-icon { width: 22px; height: 22px; }
  .nav-home { color: var(--muted); background: transparent; box-shadow: none; }
  .nav-home:hover { color: var(--brand-dark); background: var(--brand-soft); }
  .nav-home[aria-current="page"] { color: var(--brand-dark); background: var(--brand-soft); }
  .nav-yellow { box-shadow: none; }
  .nav-yellow[aria-current="page"] { box-shadow: inset 0 0 0 2px var(--brand-ink); }
  .nav-count { position: absolute; top: 3px; right: calc(50% - 26px); min-width: 18px; height: 18px; font-size: 11px; padding: 0 5px; }
  main { padding-top: var(--s5); padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  /* footer scrolls with the page above the bottom bar instead of sticking */
  .site-footer { position: static; margin-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); background: transparent; border-top: 0; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(-1 * var(--s4)) var(--s4); padding: 0 var(--s4) var(--s1); scrollbar-width: none; scroll-padding: 0 36px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { font-size: 15px; padding: 6px 14px; white-space: nowrap; }
  .list-title { font-size: 22px; }
  .search { flex-basis: 100%; }
  .row-link { grid-template-columns: 64px 1fr 14px; gap: var(--s3); padding: var(--s3); }
  .row-thumb { width: 64px; height: 64px; }
  .row-thumb-default span { font-size: 16px; }
  .row-title { font-size: 16px; }
  .article { padding: var(--s5) var(--s4); }
  .article-title { font-size: 23px; }
  .dateline { font-size: 15px; }
  .fields { grid-template-columns: 1fr; gap: var(--s4); }
  .field-value { font-size: 16px; }
  .channel-label { min-width: 0; flex: 1 1 100%; }
}
@media (max-width: 359px) {
  .btn-staff .staff-icon { display: none; }  /* very small phones: keep the full words, drop the icon */
  .btn-staff { padding: 6px 9px; }
  .brand-site { font-size: 15px; white-space: normal; line-height: 1.15; }  /* only here may the name wrap */
  .nav-short { white-space: normal; }  /* and the menu words */
}
