/* Math In Words — shared site theme (index, shop, privacy, admin).
 * Navy ground of the index hero, brand blue #1670C0, peach + yellow accents,
 * Kanit headings / Sarabun body. Learning-media pages keep their own styles.
 */
:root {
  --primary: #1670C0; --primary-hover: #0F5490; --primary-light: rgba(22,112,192,.12);
  --yellow: #FFEEA7; --peach: #FFBF6F; --peach-deep: #F2A64B;
  --text-dark: #123049; --text-mid: #5C7A90;
  --navy-1: #123A6B; --navy-2: #0E2749; --navy-3: #0C1E3A; --navy-4: #081529;
  --on-dark: #F2F6FB; --on-dark-mid: rgba(242,246,251,.70); --on-dark-dim: rgba(242,246,251,.45);
  --on-dark-rule: rgba(255,255,255,.13); --glass: rgba(255,255,255,.055); --glass-2: rgba(255,255,255,.09);
  --success: #3DD598; --success-ink: #1C9A6C; --error: #FF7A7F; --error-ink: #E5484D;
  --font-h: 'Kanit', 'Sarabun', sans-serif; --font-b: 'Sarabun', sans-serif;
  --r-pill: 9999px; --nav-h: 70px; --ease-out: cubic-bezier(.22, 1, .36, 1);
  /* names the login/profile dialogs use (they sit on white cards) */
  --text: #123049; --gray-text: #5C7A90; --border: #DCEEF7;
}
/* white dialogs on the dark site keep dark text */
.auth-card, #notifDrawer, .noti, .drawer { color: var(--text-dark); }
.auth-card input, .auth-card select, #notifDrawer input { color: var(--text-dark); background: #fff; }
.auth-card ::placeholder { color: #8AA0B2; }
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 8px); }
html, body { overflow-x: clip; }
body.site { font-family: var(--font-b); color: var(--on-dark); background: var(--navy-3); min-height: 100vh; }
:where(body.site) a { color: inherit; text-decoration: none; }
:where(body.site) img { display: block; max-width: 100%; }
:where(body.site) button { font: inherit; }
:where(body.site) :focus-visible { outline: 3px solid var(--peach); outline-offset: 2px; }

/* navy ground: the index hero colours + squared paper fading out */
.ground { position: relative;
  background:
    radial-gradient(900px 520px at 12% 0%, #2E7FD0 0%, transparent 62%),
    radial-gradient(760px 520px at 92% 10%, #1B5FA8 0%, transparent 58%),
    linear-gradient(175deg, var(--navy-1) 0%, var(--navy-2) 30%, var(--navy-3) 70%, var(--navy-4) 100%); }
.ground::before { content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(110% 50% at 20% 0%, #000 25%, transparent 80%); -webkit-mask-image: radial-gradient(110% 50% at 20% 0%, #000 25%, transparent 80%); }
.ground > * { position: relative; }

/* ── navbar: dark glass, logo in a circle ── */
.nav { position: fixed; inset: 0 0 auto; z-index: 60; height: var(--nav-h); background: rgba(12,30,58,.72); backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2); border-bottom: 1px solid var(--on-dark-rule); color: var(--on-dark); transition: background .25s; }
.nav.scrolled { background: rgba(10,24,46,.94); }
.nav-in { max-width: 1440px; height: 100%; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand-ico { width: 46px; height: 46px; border-radius: 50%; background: #fff; display: grid; place-items: center; overflow: hidden; box-shadow: 0 0 0 3px rgba(255,191,111,.6), 0 6px 16px -6px rgba(0,0,0,.5); flex-shrink: 0; }
.brand-ico img { width: 118%; height: 118%; object-fit: contain; }
.brand-txt b { display: block; font-family: var(--font-h); font-weight: 800; font-size: 19px; line-height: 1.05; white-space: nowrap; }
.brand-txt small { display: block; font-family: var(--font-h); font-weight: 500; font-size: 11px; letter-spacing: .7px; color: var(--on-dark-mid); white-space: nowrap; }
.links { display: flex; gap: 2px; margin: 0 auto; }
.links a { position: relative; font-family: var(--font-h); font-weight: 600; font-size: 15px; padding: 8px 14px; border-radius: var(--r-pill); color: var(--on-dark-mid); white-space: nowrap; transition: color .2s, background .2s; }
.links a:hover { color: var(--on-dark); background: rgba(255,255,255,.07); }
.links a.on { color: var(--on-dark); }
.links a.on::after { content: ''; position: absolute; left: 14px; right: 14px; bottom: 2px; height: 3px; border-radius: 3px; background: var(--peach); }
.nav-r { display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-left: auto; }
.links + .nav-r { margin-left: 0; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--on-dark-rule); background: rgba(255,255,255,.06); color: var(--on-dark); display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.icon-btn:hover { background: rgba(255,255,255,.14); }
.pill-btn { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-h); font-weight: 700; font-size: 14px; padding: 9px 18px; border-radius: var(--r-pill); background: var(--peach); color: var(--navy-3); white-space: nowrap; border: 0; cursor: pointer; }
.pill-btn:hover { background: var(--peach-deep); }
.lang-btn { font-family: var(--font-h); font-weight: 700; font-size: 13px; padding: 7px 12px; border-radius: var(--r-pill); border: 1px solid var(--on-dark-rule); background: transparent; color: var(--on-dark-mid); cursor: pointer; }
.lang-btn:hover { color: var(--on-dark); background: rgba(255,255,255,.08); }
.burger { display: none; }
.site-drawer { position: fixed; inset: var(--nav-h) 0 auto; z-index: 59; background: rgba(10,24,46,.97); padding: 10px 16px 18px; display: none; flex-direction: column; gap: 2px; border-bottom: 1px solid var(--on-dark-rule); }
.site-drawer.open { display: flex; }
.site-drawer a { font-family: var(--font-h); font-weight: 600; font-size: 17px; color: var(--on-dark); padding: 12px 10px; border-radius: 12px; }
.site-drawer a:hover { background: rgba(255,255,255,.07); }
@media (max-width: 1100px) { .links { display: none; } .burger { display: grid; } .nav-r, .links + .nav-r { margin-left: auto; } }
@media (max-width: 600px) {
  .nav-in { padding: 0 12px; gap: 8px; }
  .brand-txt small { display: none; }
  .brand-ico { width: 40px; height: 40px; }
  .brand-txt b { font-size: 17px; }
}
@media (max-width: 400px) { .brand-txt { display: none; } }

/* ── shared pieces ── */
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 600px) { .wrap { padding: 0 16px; } }
.page-head { padding: calc(var(--nav-h) + 44px) 0 34px; }
.page-head h1 { font-family: var(--font-h); font-weight: 800; font-size: clamp(32px, 5vw, 56px); line-height: 1.1; color: #fff; }
.page-head p { color: var(--on-dark-mid); font-size: clamp(15px, 1.6vw, 18px); line-height: 1.75; margin-top: 10px; max-width: 42em; text-wrap: balance; }
.badge-soft { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,238,167,.12); color: var(--yellow); border: 1px solid rgba(255,238,167,.32); font-family: var(--font-h); font-weight: 700; font-size: 13px; padding: 6px 16px; border-radius: var(--r-pill); margin-bottom: 18px; }
.glass { background: var(--glass); border: 1px solid var(--on-dark-rule); border-radius: 22px; }
.sec-title { font-family: var(--font-h); font-weight: 800; font-size: clamp(26px, 3.4vw, 40px); color: #fff; line-height: 1.12; }
.sec-desc { color: var(--on-dark-mid); font-size: 16px; line-height: 1.8; margin-top: 8px; max-width: 40em; text-wrap: balance; }
.accent { color: var(--yellow); }

/* dark form controls */
.dark-field, body.site .df input[type=text], body.site .df input[type=email], body.site .df input[type=number], body.site .df input[type=password], body.site .df textarea, body.site .df select {
  width: 100%; padding: 11px 14px; border-radius: 14px; border: 1.5px solid var(--on-dark-rule); background: rgba(0,0,0,.22); color: var(--on-dark);
  font-family: var(--font-b); font-size: 15px; transition: border-color .2s, box-shadow .2s; }
body.site .df ::placeholder { color: var(--on-dark-dim); }
body.site .df input:focus, body.site .df textarea:focus, body.site .df select:focus { outline: none; border-color: var(--peach); box-shadow: 0 0 0 3px rgba(255,191,111,.18); }

/* footer */
.site-foot { border-top: 1px solid var(--on-dark-rule); background: var(--navy-4); color: var(--on-dark-mid); }
.site-foot .in { max-width: 1240px; margin: 0 auto; padding: 30px 24px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 28px; font-family: var(--font-h); font-size: 14px; }
.site-foot .fb { display: flex; align-items: center; gap: 12px; }
.site-foot .fb b { color: var(--on-dark); font-size: 16px; display: block; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.site-foot a:hover { color: #fff; }

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition-duration: 1ms !important; animation: none !important; } }

/* Thai line breaking: break at word boundaries, avoid one-word last lines, balance headings */
body.site { line-break: strict; overflow-wrap: break-word; }
body.site p, body.site li, body.site .panel p, body.site .game-b > span { text-wrap: pretty; }
body.site h1, body.site h2, body.site h3, body.site .hero-sub { text-wrap: balance; }
