/* ==========================================================
   Thep Academy — site styles (index.html, m1.html)
   Minimal editorial / modern academic, from design-preview/.
   Colours sampled from the logo (navy + gold).
   pretest.html keeps its own inline styles.
   ========================================================== */

:root {
  /* colour */
  --paper: #F7F6F2;
  --paper-2: #EFEDE6;
  --ink: #0F1B2D;
  --muted: #4F5866;
  --rule: rgba(15, 27, 45, 0.16);
  --navy: #0E3E67;          /* logo navy */
  --gold: #B99442;          /* logo gold: decoration / large text only */
  --gold-ink: #7A5E1F;      /* gold for small text on paper (AA) */
  --gold-on-navy: #DCC27F;  /* gold for text on navy (AA) */
  --on-navy: #F7F6F2;
  --on-navy-muted: #C3CDD9;

  /* type */
  --font-display: 'Archivo', 'IBM Plex Sans Thai', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans Thai', 'Archivo', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'IBM Plex Sans Thai', ui-monospace, monospace;

  /* layout */
  --gutter: clamp(16px, 2.2vw, 32px);
  --max: 1440px;
  --nav-h: 64px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }

.container {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* Latin display face for English words; Thai keeps natural tracking */
.latin {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.5;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 14px;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

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

/* ─────────────── nav ─────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.nav-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: var(--nav-h);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

/* Shows only the round emblem of the existing logo file (CSS crop, file untouched) */
.brand-mark {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.brand-mark img {
  position: absolute;
  width: 129px;
  max-width: none;
  left: -15.5px;
  top: -18.3px;
  mix-blend-mode: multiply;
}

.brand-word {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--navy);
}

.nav-links {
  display: flex;
  justify-content: center;
  gap: clamp(16px, 2.2vw, 32px);
}

.nav-links a,
.footer-links a {
  position: relative;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  padding: 4px 0;
}

.nav-links a::after,
.footer-links a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}

.nav-links a:hover::after,
.nav-links a[aria-current]::after,
.footer-links a:hover::after { transform: scaleX(1); }

.nav-side {
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  padding: 7px 14px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease;
}
.nav-side:hover { background: var(--ink); color: var(--paper); }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  display: inline-block;
  flex-shrink: 0;
}

.menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--ink);
  color: var(--ink);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.menu-btn[aria-expanded="true"] {
  background: var(--ink);
  color: var(--paper);
}

/* mobile menu overlay */
.mobile-menu {
  position: fixed;
  inset: var(--nav-h) 0 0 0;
  z-index: 40;
  background: var(--paper);
  padding: 24px var(--gutter) 40px;
  overflow-y: auto;
  border-top: 1px solid var(--rule);
}
.mobile-menu[hidden] { display: none; }
.mobile-menu nav { display: flex; flex-direction: column; }
.mobile-menu nav a {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
}
.mobile-menu nav a .mono { color: var(--muted); }

/* ─────────────── buttons & status ─────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  border: 1px solid var(--ink);
  transition: background 0.2s ease, color 0.2s ease;
}
.btn-solid { background: var(--ink); color: var(--paper); }
.btn-solid:hover { background: var(--navy); border-color: var(--navy); }
.btn-line { background: transparent; color: var(--ink); }
.btn-line:hover { background: var(--ink); color: var(--paper); }

.text-link {
  font-weight: 600;
  color: var(--navy);
  text-underline-offset: 4px;
}

/* status is a label, never a button */
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--gold-ink);
  white-space: nowrap;
}
.status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
}
.status-open { color: var(--navy); border-color: var(--navy); }
.status-open::before { background: var(--navy); }

/* ─────────────── hero ─────────────── */
.hero {
  padding-top: clamp(40px, 7vw, 96px);
  padding-bottom: clamp(56px, 8vw, 112px);
  border-bottom: 1px solid var(--rule);
}

.eyebrow { color: var(--muted); margin-bottom: 20px; }

.hero-title {
  display: flex;
  flex-direction: column;
  font-weight: 700;
}
.hero-title .th {
  font-size: clamp(2.4rem, 6.4vw, 6rem);
  line-height: 1.2;
}
.hero-m4 {
  font-weight: 900;
  font-size: clamp(7rem, 26vw, 24rem);
  line-height: 0.82;
  letter-spacing: -0.05em;
  color: var(--navy);
  margin-left: -0.04em;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
  gap: clamp(32px, 6vw, 96px);
  margin-top: clamp(32px, 4vw, 56px);
  align-items: end;
}

.lead {
  font-size: clamp(17px, 1.5vw, 20px);
  line-height: 1.8;
  max-width: 34em;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  margin-top: 28px;
}

.hero-index { border-top: 1px solid var(--ink); }
.hero-index li {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: baseline;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}
.hero-index .mono { color: var(--muted); }
.hero-index .latin { font-weight: 800; font-size: clamp(20px, 2vw, 26px); }
.th-sm { font-size: 15px; color: var(--muted); }

/* ─────────────── sections ─────────────── */
.section {
  padding-top: clamp(64px, 9vw, 128px);
  padding-bottom: clamp(16px, 2vw, 24px);
}

.section-head {
  display: grid;
  grid-template-columns: minmax(80px, 2fr) minmax(0, 10fr);
  column-gap: var(--gutter);
  margin-bottom: clamp(32px, 4vw, 56px);
}
.section-num { color: var(--muted); padding-top: 0.9em; }
.section-head h2 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  font-weight: 700;
  line-height: 1.25;
}
.section-head h2 .latin { font-weight: 800; color: var(--navy); }
.section-sub {
  grid-column: 2;
  margin-top: 12px;
  color: var(--muted);
  max-width: 42em;
}

/* content that sits in the 10-column body next to the section number */
.offset {
  margin-left: calc((100% - var(--gutter)) * 2 / 12 + var(--gutter));
}

/* principles */
.principles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--ink);
}
.principle {
  padding: 24px 24px 32px 0;
  border-right: 1px solid var(--rule);
}
.principle + .principle { padding-left: 24px; }
.principle:last-child { border-right: 0; }
.principle-num { color: var(--gold-ink); margin-bottom: 20px; }
.principle h3 { font-size: 21px; font-weight: 700; line-height: 1.4; margin-bottom: 8px; }
.principle p:last-child { color: var(--muted); font-size: 16px; }

/* pathway route */
.route {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}
.route-end { color: var(--muted); }
.route-line {
  position: relative;
  height: 14px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}
.route-line::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1px dashed var(--ink);
}
.route-line i {
  position: relative;
  justify-self: start;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--ink);
}
.route-line i.mars {
  justify-self: end;
  background: var(--navy);
  border-color: var(--navy);
}

.stages {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0 var(--gutter);
}
.stage {
  padding-top: 24px;
  border-top: 1px solid var(--ink);
  margin-top: 16px;
}
.stage-num { color: var(--gold-ink); }
.stage h3 {
  font-weight: 800;
  font-size: clamp(30px, 3.2vw, 46px);
  line-height: 1.05;
  margin-top: 16px;
}
.stage-th { font-weight: 600; margin-top: 6px; }
.stage ul {
  margin-top: 16px;
  font-size: 15px;
  color: var(--muted);
}
.stage li { padding: 8px 0; border-top: 1px solid var(--rule); line-height: 1.6; }

/* editorial list rows (programs, practice, M.1 courses) */
.rows { border-top: 1px solid var(--ink); }
.row {
  display: grid;
  grid-template-columns: minmax(80px, 2fr) minmax(0, 4fr) minmax(0, 5fr) auto;
  column-gap: var(--gutter);
  align-items: start;
  padding: 28px 0;
  border-bottom: 1px solid var(--rule);
  transition: background 0.25s ease;
}
.row:hover { background: var(--paper-2); }
.row-num { color: var(--muted); padding-top: 8px; }
.row h3 {
  font-size: clamp(24px, 2.6vw, 36px);
  font-weight: 700;
  line-height: 1.25;
}
.row h3 .latin { font-weight: 800; }
.row-for { margin-top: 6px; color: var(--muted); font-size: 15px; }
.row-desc { color: var(--muted); padding-top: 4px; }
.row-desc .text-link { display: inline-block; margin-top: 10px; }
.row-end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  padding-top: 6px;
}

/* M.1 entry block on the home page (index.html#subcourses, linked from pretest.html) */
.m1-entry {
  display: grid;
  grid-template-columns: minmax(80px, 2fr) minmax(0, 6fr) minmax(0, 4fr);
  column-gap: var(--gutter);
  padding: clamp(32px, 4vw, 48px) 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}
.m1-entry h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); font-weight: 700; line-height: 1.3; }
.m1-entry h2 .latin { color: var(--navy); font-weight: 800; }
.m1-entry p { color: var(--muted); margin-top: 8px; }
.m1-courses { margin-top: 20px; border-top: 1px solid var(--rule); }
.m1-courses li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}
.m1-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 12px;
}

/* instructor */
.instructor {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(32px, 6vw, 96px);
  align-items: start;
}
.instructor-name { font-size: clamp(2.4rem, 5vw, 4.2rem); font-weight: 700; line-height: 1.2; }
.instructor-quote {
  margin-top: 20px;
  font-size: clamp(18px, 1.8vw, 22px);
  line-height: 1.75;
  max-width: 28em;
}
.list-label { color: var(--muted); margin-bottom: 12px; }
.creds { border-top: 1px solid var(--ink); }
.creds + .list-label { margin-top: 40px; }
.creds li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 24px;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
}
.creds .latin { font-weight: 700; font-size: 18px; }
.creds .mono { color: var(--muted); }
.papers li {
  display: block;
  padding: 14px 0;
}
.papers .paper-title { font-weight: 600; line-height: 1.6; }
.papers .mono { display: block; margin-top: 4px; }

/* faq */
.faq { border-top: 1px solid var(--ink); }
.faq details { border-bottom: 1px solid var(--rule); }
.faq summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 0;
  font-size: clamp(17px, 1.6vw, 20px);
  font-weight: 600;
  line-height: 1.5;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: '+';
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 22px;
  line-height: 1.2;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { padding: 0 48px 24px 0; color: var(--muted); max-width: 46em; }
.ext {
  color: var(--navy);
  font-weight: 600;
  text-underline-offset: 3px;
  white-space: nowrap;
}

/* M.1 page */
.page-hero {
  padding-top: clamp(40px, 6vw, 88px);
  padding-bottom: clamp(48px, 6vw, 88px);
  border-bottom: 1px solid var(--rule);
}
.page-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(32px, 6vw, 96px);
  align-items: end;
}
.page-title {
  font-size: clamp(2.6rem, 6vw, 5.4rem);
  font-weight: 700;
  line-height: 1.2;
}
.page-title .latin { display: block; color: var(--navy); font-weight: 900; letter-spacing: -0.04em; line-height: 1; }
.page-hero .lead { margin-top: 24px; }
.cover {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--paper-2);
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-caption { margin-top: 8px; color: var(--muted); }

/* ─────────────── footer ─────────────── */
.footer {
  margin-top: clamp(80px, 10vw, 144px);
  border-top: 1px solid var(--ink);
  padding-top: 28px;
  overflow: hidden;
}
.footer-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 16px 32px;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 28px; }
.footer-note { color: var(--muted); }
.wordmark {
  font-weight: 900;
  /* "THEP ACADEMY" in Archivo 900 measures ~8.13em wide: size it to the content box */
  font-size: min(calc((100vw - 2 * var(--gutter)) / 8.7), 160px);
  line-height: 0.85;
  letter-spacing: -0.045em;
  color: var(--navy);
  margin: clamp(40px, 6vw, 80px) 0 0;
  white-space: nowrap;
}
.footer-base {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding: 20px 0 28px;
  color: var(--muted);
}
.footer-base a { text-decoration: none; }
.footer-base a:hover { text-decoration: underline; }

/* ─────────────── reveal (only when JS is on) ─────────────── */
.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.js .reveal.is-in { opacity: 1; transform: none; }

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

/* ─────────────── responsive ─────────────── */
@media (max-width: 1100px) {
  .nav-links { gap: 18px; }
  .stages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row { grid-template-columns: minmax(48px, 1fr) minmax(0, 5fr) auto; }
  .row-desc { grid-column: 2 / 3; grid-row: 2; padding-top: 12px; }
  .m1-entry { grid-template-columns: minmax(48px, 1fr) minmax(0, 5fr); }
  .m1-actions { grid-column: 2; margin-top: 24px; }
}

@media (max-width: 960px) {
  .nav-inner { grid-template-columns: 1fr auto; }
  .nav-links,
  .nav-side { display: none; }
  .menu-btn { display: inline-flex; }

  .hero-grid,
  .page-hero-grid,
  .instructor { grid-template-columns: 1fr; }

  .section-head { grid-template-columns: 1fr; }
  .section-num { padding-top: 0; margin-bottom: 8px; }
  .section-sub { grid-column: 1; }
  .offset { margin-left: 0; }

  .principles { grid-template-columns: 1fr; }
  .principle,
  .principle + .principle { padding: 20px 0 24px; border-right: 0; }
  .principle:nth-child(n+2) { border-top: 1px solid var(--rule); }
  .principle-num { margin-bottom: 8px; }
}

@media (max-width: 600px) {
  body { font-size: 16px; }

  .stages { grid-template-columns: 1fr; }

  .row { grid-template-columns: 1fr; row-gap: 8px; }
  .row-num { padding-top: 0; }
  .row-desc { grid-column: 1; grid-row: auto; padding-top: 0; }
  .row-end { align-items: flex-start; padding-top: 4px; }

  .m1-entry { grid-template-columns: 1fr; }
  .m1-entry .section-num { margin-bottom: 8px; }
  .m1-actions { grid-column: 1; }

  .faq details p { padding-right: 0; }
  .btn { width: 100%; justify-content: center; }
  .hero-actions { flex-direction: column; align-items: stretch; }
  .hero-actions .text-link { text-align: center; }
}
