/* =========================================================================
   สสอ.เมืองศรีสะเกษ — Design tokens, typography, accessibility, base
   ========================================================================= */

/* ---- Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@300;400;500;600;700;800&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
  /* Brand — Ministry of Public Health green, refined */
  --brand-900: #06301f;
  --brand-800: #0a4730;
  --brand-700: #0b5a3b;   /* primary */
  --brand-600: #0e6f49;
  --brand-500: #138a59;
  --brand-400: #2aa572;
  --brand-300: #6cc4a0;
  --brand-100: #d9efe4;
  --brand-50:  #eef7f2;

  /* Dignity gold accent */
  --gold-700: #9a6f24;
  --gold-600: #b8862f;
  --gold-500: #d6a544;
  --gold-100: #f7ecd2;

  /* Functional */
  --emergency: #c23b32;
  --emergency-dark: #9c2c25;
  --info-600: #1c6cb0;
  --info-100: #e2eff9;
  --warn-600: #c98a16;
  --warn-100: #fbf0d6;
  --ok-600: #1f8a4c;

  /* Ink + surfaces */
  --ink-900: #10211a;
  --ink-800: #1c3127;
  --ink-700: #314a3e;
  --ink-500: #5d7268;
  --ink-400: #8499900;
  --ink-300: #aebbb4;
  --line: #dde6e0;
  --line-strong: #c4d2ca;
  --bg: #f3f7f4;
  --surface: #ffffff;
  --surface-2: #f8fbf9;

  /* Typography */
  --font-head: 'Noto Sans Thai', system-ui, sans-serif;
  --font-body: 'Sarabun', 'Noto Sans Thai', system-ui, sans-serif;

  /* Accessibility — user-adjustable base scale */
  --font-scale: 1;
  --fs-base: calc(17px * var(--font-scale));

  /* Radii + shadow */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(16,33,26,.06), 0 1px 3px rgba(16,33,26,.05);
  --shadow-md: 0 4px 14px rgba(16,33,26,.08), 0 2px 6px rgba(16,33,26,.05);
  --shadow-lg: 0 18px 44px rgba(11,90,59,.16), 0 6px 16px rgba(16,33,26,.08);

  /* Layout */
  --maxw: 1240px;
  --gutter: clamp(16px, 4vw, 40px);
}

/* ---- High contrast mode ---- */
.contrast-high {
  --brand-700: #053a24;
  --brand-600: #064a2e;
  --ink-700: #0a1812;
  --ink-500: #243a30;
  --line: #2e4a3c;
  --line-strong: #1c3527;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --gold-600: #7a5410;
}
.contrast-high a { text-decoration: underline; }
.contrast-high .card,
.contrast-high .surface { border: 2px solid var(--line-strong) !important; }

/* ---- Reset / base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.65;
  color: var(--ink-800);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5 { font-family: var(--font-head); font-weight: 700; line-height: 1.25; color: var(--ink-900); margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
ul { margin: 0; padding: 0; list-style: none; }

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

/* ---- Layout helpers ---- */
.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: clamp(40px, 6vw, 76px); }
.eyebrow {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: .82em;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--brand-600);
  display: inline-flex; align-items: center; gap: 8px;
}
.contrast-high .eyebrow { color: var(--brand-700); }

.h-xl { font-size: clamp(2rem, 4.6vw, 3.1rem); }
.h-lg { font-size: clamp(1.6rem, 3.2vw, 2.3rem); }
.h-md { font-size: clamp(1.25rem, 2vw, 1.6rem); }
.muted { color: var(--ink-500); }
.lead { font-size: 1.12em; color: var(--ink-700); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--font-head); font-weight: 600;
  padding: 13px 22px; border-radius: var(--r-pill);
  border: 1.5px solid transparent; background: var(--brand-700); color: #fff;
  text-decoration: none; transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--brand-800); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn--lg { padding: 16px 30px; font-size: 1.05em; }
.btn--gold { background: var(--gold-600); color: #2a1e05; }
.btn--gold:hover { background: var(--gold-700); color: #fff; }
.btn--ghost { background: transparent; color: var(--brand-700); border-color: var(--line-strong); }
.btn--ghost:hover { background: var(--brand-50); border-color: var(--brand-400); }
.btn--white { background: #fff; color: var(--brand-700); }
.btn--white:hover { background: var(--brand-50); }
.btn--emergency { background: var(--emergency); }
.btn--emergency:hover { background: var(--emergency-dark); }
.btn--block { width: 100%; }

/* ---- Cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.card--hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--brand-300); }

/* ---- Chips / badges ---- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-head); font-weight: 600; font-size: .8em;
  padding: 5px 12px; border-radius: var(--r-pill);
  background: var(--brand-50); color: var(--brand-700);
  white-space: nowrap;
}
.chip--gold { background: var(--gold-100); color: var(--gold-700); }
.chip--info { background: var(--info-100); color: var(--info-600); }
.chip--warn { background: var(--warn-100); color: var(--warn-600); }
.chip--red  { background: #fbe6e4; color: var(--emergency-dark); }

/* ---- Forms ---- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-family: var(--font-head); font-weight: 600; font-size: .92em; color: var(--ink-800); }
.field .req { color: var(--emergency); }
.input, .select, .textarea {
  font-family: var(--font-body); font-size: 1em; color: var(--ink-900);
  padding: 12px 14px; border: 1.5px solid var(--line-strong); border-radius: var(--r-md);
  background: #fff; width: 100%; transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 4px var(--brand-50); }
.textarea { resize: vertical; min-height: 120px; }
.hint { font-size: .85em; color: var(--ink-500); }

/* ---- Utility ---- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 200; background: var(--brand-700); color: #fff; padding: 10px 18px; border-radius: var(--r-md); transition: top .2s ease; }
.skip-link:focus { top: 12px; }
.grid { display: grid; gap: clamp(16px, 2vw, 24px); }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
