/* ==========================================================================
   หน่วยศึกษานิเทศก์ — Design tokens
   ========================================================================== */
:root {
  --navy-950: #060f24;
  --navy-900: #0b1a33;
  --navy-800: #122344;
  --navy-700: #1a2f52;
  --navy-600: #24406b;

  --gold-400: #d4af37;
  --gold-300: #e8c766;
  --gold-glow: rgba(212, 175, 55, 0.18);

  --ivory-50: #f5f2ea;
  --slate-300: #b8c2d6;
  --slate-500: #8b98b3;

  --line: rgba(212, 175, 55, 0.25);
  --line-soft: rgba(184, 194, 214, 0.14);

  --font-display: "Taviraj", "Sarabun", serif;
  --font-body: "Sarabun", "Taviraj", sans-serif;

  --header-h: 84px;
  --header-h-mobile: 68px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   Reset
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--navy-900);
  color: var(--ivory-50);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 600; color: var(--ivory-50); }
p { margin: 0; }

:focus-visible {
  outline: 2px solid var(--gold-400);
  outline-offset: 3px;
  border-radius: 2px;
}

.container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 48px);
}

/* ==========================================================================
   Header / Nav — always solid, never overlays video
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--navy-900);
  border-bottom: 1px solid var(--line-soft);
  transition: box-shadow 0.3s var(--ease), background-color 0.3s var(--ease);
}
.site-header.is-scrolled {
  box-shadow: 0 12px 32px -12px rgba(0,0,0,0.55);
  background: var(--navy-950);
}
.header-inner {
  height: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 48px);
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: auto;
  min-width: 0;
}
.brand .emblem { width: 44px; height: 44px; flex-shrink: 0; }
.emblem img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-th {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.02rem;
  color: var(--ivory-50);
  white-space: nowrap;
}
.brand-en {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate-500);
  white-space: nowrap;
}

.main-nav ul {
  display: flex;
  align-items: center;
  gap: clamp(16px, 2vw, 34px);
}
.main-nav a {
  position: relative;
  font-size: 0.94rem;
  font-weight: 500;
  color: var(--slate-300);
  padding: 8px 2px;
  transition: color 0.25s var(--ease);
  white-space: nowrap;
}
.main-nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: 0;
  height: 2px;
  background: var(--gold-400);
  transition: right 0.28s var(--ease);
}
.main-nav a:hover { color: var(--ivory-50); }
.main-nav a:hover::after { right: 0; }
.main-nav a.active {
  color: var(--gold-300);
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--gold-400);
}
.main-nav a.active::after { right: 0; }

.lang-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
}
.lang-btn {
  padding: 7px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--slate-300);
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}
.lang-btn.active { background: var(--gold-400); color: var(--navy-950); }
.lang-btn:not(.active):hover { color: var(--ivory-50); }

.nav-toggle {
  display: none;
  width: 40px; height: 40px;
  flex-shrink: 0;
  position: relative;
}
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px;
  height: 2px;
  background: var(--ivory-50);
  transition: transform 0.25s var(--ease), opacity 0.25s var(--ease), top 0.25s var(--ease);
}
.nav-toggle span { top: 19px; }
.nav-toggle span::before { top: -8px; }
.nav-toggle span::after { top: 8px; }
.nav-toggle[aria-expanded="true"] span { background: transparent; }
.nav-toggle[aria-expanded="true"] span::before { top: 0; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] span::after { top: 0; transform: rotate(-45deg); }

/* ==========================================================================
   Hero video — clean, textless, never covered by header
   ========================================================================== */
.hero-video-section {
  position: relative;
  width: 100%;
  height: 88vh;
  min-height: 460px;
  background: var(--navy-950);
  overflow: hidden;
}
.hero-video-section video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.hero-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(6,15,36,0.35) 0%, rgba(6,15,36,0) 18%, rgba(6,15,36,0) 78%, rgba(6,15,36,0.85) 100%);
}
.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: 30px; height: 30px;
  opacity: 0.85;
  animation: scrollBounce 2.2s ease-in-out infinite;
}
@keyframes scrollBounce {
  0%, 100% { transform: translate(-50%, 0); opacity: 0.55; }
  50% { transform: translate(-50%, 8px); opacity: 1; }
}

/* ==========================================================================
   Section rhythm — seamless gradient blends, no hard seams
   ========================================================================== */
.section { position: relative; padding: clamp(64px, 9vw, 128px) 0; }
.section--950 { background: var(--navy-950); }
.section--900 { background: linear-gradient(180deg, var(--navy-950) 0%, var(--navy-900) 100%); }
.section--800 { background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-800) 100%); }
.section--800-flat { background: var(--navy-800); }

.section-label {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-400);
  margin-bottom: 14px;
}
.section-heading { font-size: clamp(1.8rem, 3.4vw, 2.7rem); line-height: 1.2; }
.section-body { color: var(--slate-300); font-size: 1.05rem; max-width: 62ch; }

/* Intro / mission */
.intro { text-align: left; max-width: 780px; }
.intro .section-heading { margin-bottom: 20px; }
.intro .section-body { margin-top: 4px; }

/* Stats strip */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(24px, 3vw, 40px);
  margin-top: 12px;
}
.stat { border-left: 2px solid var(--line); padding-left: 20px; }
.stat-number {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 4vw, 3.4rem);
  font-weight: 700;
  color: var(--ivory-50);
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
.stat-number .stat-suffix { font-size: 1.1rem; color: var(--gold-300); font-weight: 600; }
.stat-label { display: block; margin-top: 8px; font-size: 0.9rem; color: var(--slate-500); }

/* Teaser grid */
.teaser-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  margin-top: 12px;
  background: var(--line-soft);
}
.teaser-item {
  background: var(--navy-800);
  padding: clamp(28px, 3vw, 44px);
  border-left: 3px solid var(--gold-400);
  transition: background 0.3s var(--ease), transform 0.3s var(--ease);
}
.teaser-item:hover { background: var(--navy-700); transform: translateY(-2px); }
.teaser-item h3 { font-size: 1.4rem; margin-bottom: 10px; }
.teaser-item p { color: var(--slate-300); margin-bottom: 16px; }
.teaser-link { color: var(--gold-300); font-weight: 600; font-size: 0.92rem; }
.teaser-item:hover .teaser-link { text-decoration: underline; }

/* Announcements */
.announce-list { margin-top: 8px; border-top: 1px solid var(--line-soft); }
.announce-item {
  display: flex;
  align-items: baseline;
  gap: 24px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line-soft);
  transition: padding-left 0.25s var(--ease), color 0.25s var(--ease);
}
.announce-item:hover { padding-left: 10px; color: var(--gold-300); }
.announce-date { font-size: 0.8rem; color: var(--slate-500); flex-shrink: 0; width: 92px; }
.announce-title { font-weight: 500; }

/* ==========================================================================
   Reveal-on-scroll (plain IntersectionObserver, no libraries)
   ========================================================================== */
.reveal {
  opacity: 0;
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
  transition-delay: calc(var(--i, 0) * 90ms);
}
.reveal[data-animation="fade-up"] { transform: translateY(36px); }
.reveal[data-animation="slide-left"] { transform: translateX(-52px); }
.reveal[data-animation="slide-right"] { transform: translateX(52px); }
.reveal[data-animation="scale-in"] { transform: scale(0.92); }
.reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { transition: none !important; opacity: 1 !important; transform: none !important; }
  .scroll-cue { animation: none; }
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer { background: var(--navy-950); border-top: 1px solid var(--line-soft); padding: 56px 0 28px; }
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 40px;
  padding-bottom: 36px;
}
.footer-brand { display: flex; gap: 14px; }
.footer-brand .emblem { width: 46px; height: 46px; flex-shrink: 0; }
.footer-brand-text .brand-th { display: block; font-family: var(--font-display); font-size: 1.05rem; margin-bottom: 4px; }
.footer-brand-text p { color: var(--slate-500); font-size: 0.88rem; max-width: 32ch; }
.footer-col h4 { font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold-400); margin-bottom: 16px; }
.footer-col ul li { margin-bottom: 10px; }
.footer-col a { color: var(--slate-300); font-size: 0.92rem; transition: color 0.25s var(--ease); }
.footer-col a:hover { color: var(--gold-300); }
.footer-bottom {
  border-top: 1px solid var(--line-soft);
  padding-top: 22px;
  font-size: 0.8rem;
  color: var(--slate-500);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

/* ==========================================================================
   Page-header banner (non-home pages — no video)
   ========================================================================== */
.page-banner {
  position: relative;
  background: var(--navy-900);
  padding: clamp(72px, 10vw, 120px) 0 clamp(48px, 6vw, 72px);
  overflow: hidden;
  border-bottom: 1px solid var(--line-soft);
}
.page-banner::before {
  content: "";
  position: absolute;
  top: -30%; right: -10%;
  width: 60%; height: 160%;
  background: radial-gradient(closest-side, var(--gold-glow), transparent 70%);
  pointer-events: none;
}
.breadcrumb { font-size: 0.82rem; color: var(--slate-500); margin-bottom: 18px; position: relative; }
.breadcrumb a { color: var(--slate-300); }
.breadcrumb a:hover { color: var(--gold-300); }
.page-banner h1 { font-size: clamp(2.1rem, 4vw, 3.2rem); position: relative; }
.page-banner .subtitle { margin-top: 10px; color: var(--slate-300); font-size: 1.05rem; position: relative; }

/* ==========================================================================
   About page
   ========================================================================== */
.pillars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; margin-top: 12px; }
.pillar { border-top: 2px solid var(--gold-400); padding-top: 20px; }
.pillar .pillar-icon { width: 40px; height: 40px; margin-bottom: 16px; color: var(--gold-400); }
.pillar h3 { font-size: 1.2rem; margin-bottom: 10px; }
.pillar p { color: var(--slate-300); font-size: 0.96rem; }

.org-chart { margin-top: 16px; }
.org-level { text-align: center; margin-bottom: 28px; }
.org-level .org-title { font-family: var(--font-display); font-weight: 600; }
.org-level--1 .org-title { font-size: 1.6rem; color: var(--gold-300); }
.org-level--2 .org-title, .org-level--3 .org-title, .org-level--4 .org-title { font-size: 1.1rem; }
.org-level--5 .org-title { font-size: 0.92rem; color: var(--slate-300); font-weight: 400; }
.org-connector { width: 1px; height: 26px; background: var(--line); margin: 0 auto 0; }

.staff-list { margin-top: 8px; border-top: 1px solid var(--line-soft); }
.staff-item { display: flex; justify-content: space-between; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.staff-name { font-weight: 500; }
.staff-role { color: var(--slate-500); font-size: 0.9rem; text-align: right; }

/* ==========================================================================
   Resources page
   ========================================================================== */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 32px; }
.filter-btn {
  padding: 9px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.86rem;
  color: var(--slate-300);
  transition: background 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.filter-btn:hover { border-color: var(--gold-400); color: var(--ivory-50); }
.filter-btn.active { background: var(--gold-400); color: var(--navy-950); border-color: var(--gold-400); font-weight: 600; }

.doc-list { border-top: 1px solid var(--line-soft); }
.doc-item {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 4px;
  border-bottom: 1px solid var(--line-soft);
  transition: background 0.25s var(--ease);
}
.doc-item:hover { background: var(--navy-800); }
.doc-badge {
  flex-shrink: 0;
  width: 52px; height: 52px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--navy-700);
  color: var(--gold-300);
  border: 1px solid var(--line);
}
.doc-info { flex: 1 1 auto; min-width: 0; }
.doc-title { font-weight: 500; margin-bottom: 4px; }
.doc-meta { font-size: 0.82rem; color: var(--slate-500); }
.doc-download { flex-shrink: 0; color: var(--gold-300); font-size: 0.9rem; font-weight: 600; white-space: nowrap; }
.doc-download:hover { text-decoration: underline; }

/* ==========================================================================
   E-Services page
   ========================================================================== */
.service-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; margin-top: 8px; background: var(--line-soft); }
.service-item {
  background: var(--navy-900);
  padding: clamp(26px, 3vw, 38px);
  border-left: 3px solid var(--gold-400);
}
.service-item h3 { font-size: 1.25rem; margin-bottom: 10px; }
.service-item p { color: var(--slate-300); margin-bottom: 16px; font-size: 0.96rem; }
.service-link { color: var(--gold-300); font-weight: 600; font-size: 0.92rem; }
.service-link:hover { text-decoration: underline; }

/* ==========================================================================
   Contact page
   ========================================================================== */
.contact-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: clamp(32px, 5vw, 72px); align-items: start; }
.contact-info h3 { font-size: 1rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold-400); margin: 28px 0 10px; }
.contact-info h3:first-child { margin-top: 0; }
.contact-info p { color: var(--slate-300); }
.contact-info a:hover { color: var(--gold-300); }

.map-placeholder {
  margin-top: 28px;
  background: var(--navy-800);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 40px 24px;
  text-align: center;
}
.map-placeholder svg { width: 44px; height: 44px; margin: 0 auto 14px; color: var(--gold-400); }
.map-placeholder .map-caption { color: var(--slate-300); font-size: 0.92rem; margin-bottom: 14px; }
.map-placeholder a { color: var(--gold-300); font-weight: 600; font-size: 0.9rem; }
.map-placeholder a:hover { text-decoration: underline; }

.contact-form { display: flex; flex-direction: column; gap: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 0.86rem; color: var(--slate-300); }
.field input, .field textarea {
  background: var(--navy-800);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  color: var(--ivory-50);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.25s var(--ease);
}
.field input:focus, .field textarea:focus { border-color: var(--gold-400); }
.field textarea { resize: vertical; min-height: 130px; }
.form-note { font-size: 0.8rem; color: var(--slate-500); }
.submit-btn {
  align-self: flex-start;
  padding: 13px 34px;
  background: var(--gold-400);
  color: var(--navy-950);
  font-weight: 700;
  border-radius: 999px;
  transition: background 0.25s var(--ease), transform 0.25s var(--ease);
}
.submit-btn:hover { background: var(--gold-300); transform: translateY(-2px); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1024px) {
  .stats-strip { grid-template-columns: repeat(2, 1fr); row-gap: 32px; }
  .teaser-grid, .service-list { grid-template-columns: 1fr; }
  .pillars { grid-template-columns: 1fr; gap: 28px; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
  .contact-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .site-header { height: var(--header-h-mobile); }
  .nav-toggle { display: block; }
  .main-nav {
    position: static;
    order: 3;
    flex-basis: 100%;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s var(--ease);
  }
  .site-header.nav-open .main-nav { max-height: 420px; }
  .main-nav ul {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 10px 0 18px;
  }
  .main-nav a { display: block; padding: 12px 4px; width: 100%; }
  .header-inner { flex-wrap: wrap; }
  .hero-video-section {
    height: auto;
    aspect-ratio: 1280 / 568;
    min-height: 140px;
    max-height: 62vh;
  }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-strip { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; }
  .doc-item { flex-wrap: wrap; }
}
