/* ============================================================
   หน้า hub, ใช้ token ร่วมจาก mathlit-study/shared/theme.css
   ห้ามประกาศ :root ซ้ำที่นี่ เพื่อไม่ให้ธีมสองชุดเพี้ยนออกจากกัน
   ลวดลายประจำหน้า คือเส้นประคู่ที่มีแถบสี 5 ขั้นของวงจรคั่นกลาง
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.68;
  -webkit-text-size-adjust: 100%;
}

img,
svg {
  max-width: 100%;
}

.wrap {
  width: min(1180px, 100% - 40px);
  margin-inline: auto;
}

@media (max-width: 600px) {
  .wrap {
    width: min(1180px, 100% - 28px);
  }
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  line-height: 1.25;
  margin: 0 0 0.5em;
}

h1 {
  font-size: clamp(2rem, 5.6vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}

h2 {
  font-size: clamp(1.5rem, 3.4vw, 2.25rem);
  font-weight: 700;
}

h3 {
  font-size: clamp(1.13rem, 2.1vw, 1.4rem);
  font-weight: 600;
}

h4 {
  font-size: 1.02rem;
  font-weight: 600;
  margin-bottom: 0.35em;
}

p {
  margin: 0 0 1.05em;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.92rem;
  line-height: 1.62;
}

.kicker {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.9em;
}

a {
  color: var(--solve-deep);
}

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--formulate);
  outline-offset: 3px;
}

.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 {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 900;
  background: var(--ink);
  color: var(--paper);
  padding: 12px 20px;
  font-family: var(--font-display);
  font-weight: 600;
  transition: top 0.18s;
}

.skip:focus {
  top: 12px;
}

/* ---------- แถบนำทาง ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 500;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(9px);
  border-bottom: var(--rule);
}

.nav-in {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 11px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.06rem;
  text-decoration: none;
  color: var(--ink);
  margin-inline-end: auto;
  min-height: var(--tap);
}

.brand svg {
  flex: none;
}

.nav a.nlink {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 12px;
  font-size: 0.94rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--ink);
  border: 2px solid transparent;
}

.nav a.nlink:hover {
  border-color: var(--ink);
  background: var(--card);
}

#hero,
#why,
#start,
#media,
#plc,
#faq,
#about {
  scroll-margin-top: 80px;
}

@media (max-width: 760px) {
  #hero,
  #why,
  #start,
  #media,
  #plc,
  #faq,
  #about {
    scroll-margin-top: 128px;
  }
}

/* ---------- ปุ่ม ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: var(--tap);
  padding: 10px 22px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  color: var(--ink);
  background: var(--card);
  border: var(--rule);
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  cursor: pointer;
}

.btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--ink);
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.btn--p {
  background: var(--ink);
  color: var(--paper);
}

.btn--sm {
  min-height: var(--tap);
  padding: 8px 15px;
  font-size: 0.9rem;
}

.btn[aria-disabled="true"] {
  opacity: 0.55;
  box-shadow: none;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- ลวดลายประจำหน้า ---------- */
.motif {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 auto 44px;
  max-width: 640px;
}

.motif::before,
.motif::after {
  content: '';
  flex: 1;
  height: 3px;
  background-image: repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 11px);
}

.motif-bars {
  display: flex;
  gap: 4px;
  flex: none;
}

.motif-bars i {
  display: block;
  width: 15px;
  height: 11px;
}

.motif-bars i:nth-child(1) {
  background: var(--formulate);
}

.motif-bars i:nth-child(2) {
  background: var(--solve);
}

.motif-bars i:nth-child(3) {
  background: var(--interpret);
}

.motif-bars i:nth-child(4) {
  background: var(--evaluate);
}

.motif-bars i:nth-child(5) {
  background: var(--report);
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 74px 0 66px;
  border-bottom: var(--rule);
}

.hero::before {
  content: '';
  position: absolute;
  top: -34%;
  left: 50%;
  translate: -50% 0;
  width: 74vw;
  height: 74vw;
  max-width: 820px;
  max-height: 820px;
  z-index: -1;
  background: radial-gradient(circle, var(--formulate-soft) 0%, transparent 68%);
}

.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='168' height='168' viewBox='0 0 168 168'%3E%3Cg fill='none' stroke='%23171c2b' stroke-opacity='.07' stroke-width='1.2'%3E%3Ccircle cx='84' cy='84' r='58'/%3E%3Ccircle cx='84' cy='84' r='30'/%3E%3Cpath d='M84 26v-14M142 84h14M84 142v14M26 84H12'/%3E%3C/g%3E%3C/svg%3E");
}

.hero-lead {
  font-size: clamp(1.06rem, 2.2vw, 1.3rem);
  max-width: 46ch;
  margin-bottom: 1.6em;
}

.hero-cta {
  display: flex;
  gap: 13px;
  flex-wrap: wrap;
  margin-bottom: 40px;
}

.pills {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  list-style: none;
  padding: 0;
  margin: 0;
}

.pill {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px 17px;
  background: var(--card);
  border: var(--rule);
}

.pill b {
  font-family: var(--font-mono);
  font-size: 1.32rem;
  font-weight: 600;
  line-height: 1.1;
}

.pill span {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ---------- ส่วนทั่วไป ---------- */
section {
  padding: 66px 0;
}

section + section {
  border-top: var(--rule);
}

.sec-head {
  max-width: 60ch;
  margin-bottom: 38px;
}

/* ---------- ตัวเลข ---------- */
.figs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 34px;
}

.fig {
  padding: 20px 22px;
  background: var(--card);
  border: var(--rule);
}

.fig b {
  display: block;
  font-family: var(--font-mono);
  font-size: 2.05rem;
  font-weight: 600;
  line-height: 1.05;
}

.fig span {
  font-size: 0.9rem;
  color: var(--muted);
}

.fig--report b {
  color: var(--report-deep);
}

.fig--report {
  border-left: 9px solid var(--report);
}

.fig--solve b {
  color: var(--solve-deep);
}

.fig--solve {
  border-left: 9px solid var(--solve);
}

.fig--eval b {
  color: var(--evaluate-deep);
}

.fig--eval {
  border-left: 9px solid var(--evaluate);
}

/* ---------- การ์ด ---------- */
.grid {
  display: grid;
  gap: 18px;
}

.g3 {
  grid-template-columns: repeat(auto-fit, minmax(292px, 1fr));
}

.g2 {
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 24px 26px;
  background: var(--card);
  border: var(--rule);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.card::before,
.card::after {
  content: '';
  position: absolute;
  width: 15px;
  height: 15px;
  pointer-events: none;
  transition: border-color 0.18s ease;
}

.card::before {
  top: -2.5px;
  left: -2.5px;
  border-top: 5px solid var(--line);
  border-left: 5px solid var(--line);
}

.card::after {
  bottom: -2.5px;
  right: -2.5px;
  border-bottom: 5px solid var(--line);
  border-right: 5px solid var(--line);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.card p:last-child {
  margin-bottom: 0;
}

.card--formulate::before,
.card--formulate::after {
  border-color: var(--formulate);
}

.card--solve::before,
.card--solve::after {
  border-color: var(--solve);
}

.card--interpret::before,
.card--interpret::after {
  border-color: var(--interpret);
}

.card--evaluate::before,
.card--evaluate::after {
  border-color: var(--evaluate);
}

.card--report::before,
.card--report::after {
  border-color: var(--report);
}

.card-icon {
  width: 34px;
  height: 34px;
  margin-bottom: 6px;
}

.card-foot {
  margin-top: auto;
  padding-top: 16px;
}

.role {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- การ์ดสื่อ ---------- */
.media-card {
  cursor: pointer;
  text-align: start;
  font: inherit;
  color: inherit;
  width: 100%;
}

.media-card .tagrow {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  border: 2px solid currentColor;
}

.tag--key {
  color: var(--evaluate-deep);
  background: var(--evaluate-soft);
}

.tag--free {
  color: var(--interpret-deep);
  background: var(--interpret-soft);
}

.tag--todo {
  color: var(--report-deep);
  background: var(--report-soft);
}

.card.is-pending {
  opacity: 0.62;
}

/* ---------- แท็บ ---------- */
.tabs {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.tab-btn {
  min-height: var(--tap);
  padding: 9px 19px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.96rem;
  background: var(--card);
  color: var(--ink);
  border: var(--rule);
  cursor: pointer;
}

.tab-btn[aria-selected="true"] {
  background: var(--ink);
  color: var(--paper);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.steps li {
  display: flex;
  gap: 15px;
  padding: 16px 20px;
  background: var(--card);
  border: var(--rule);
}

.steps b {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--muted);
  flex: none;
  padding-top: 2px;
}

/* ---------- คำถามพบบ่อย ---------- */
.faq {
  display: grid;
  gap: 11px;
}

details.qa {
  background: var(--card);
  border: var(--rule);
}

details.qa summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  padding: 13px 20px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.02rem;
  cursor: pointer;
  list-style: none;
}

details.qa summary::-webkit-details-marker {
  display: none;
}

details.qa summary .chev {
  flex: none;
  transition: transform 0.2s ease;
}

details.qa[open] summary .chev {
  transform: rotate(90deg);
}

details.qa .qa-body {
  padding: 0 20px 18px 51px;
}

details.qa .qa-body p:last-child {
  margin-bottom: 0;
}

/* ---------- โมดัล ---------- */
.ov {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(13, 16, 23, 0.76);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.ov[hidden] {
  display: none;
}

.mpanel {
  position: relative;
  width: min(640px, 100%);
  max-height: 86vh;
  overflow: auto;
  padding: 32px 34px;
  background: var(--card);
  border: var(--rule);
  box-shadow: var(--shadow-lift);
}

.mclose {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  background: var(--card);
  color: var(--ink);
  border: var(--rule);
  cursor: pointer;
}

.mpanel ul {
  margin: 0 0 1em;
  padding-inline-start: 1.25em;
}

.mpanel li {
  margin-bottom: 0.4em;
}

/* ---------- แถวเลือกชุดเรียนรู้ในหน้าต่าง ---------- */
.deck-pick {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  min-height: var(--tap);
  background: var(--paper);
  border: 2px solid var(--line);
  border-inline-start: 6px solid var(--formulate);
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.16s, background 0.16s, transform 0.16s;
}

.deck-pick:hover {
  border-color: var(--ink);
  border-inline-start-color: var(--formulate-deep);
  background: var(--formulate-soft);
  transform: translateX(2px);
}

.deck-pick__no {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--formulate-deep);
  flex: none;
  width: 32px;
}

.deck-pick__body {
  flex: 1;
  min-width: 0;
}

.deck-pick__name {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.98rem;
  line-height: 1.42;
}

.deck-pick__lead {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

.deck-pick__ai {
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  text-align: end;
  max-width: 98px;
  line-height: 1.45;
}

@media (max-width: 520px) {
  .deck-pick__ai {
    display: none;
  }
}

/* ---------- footer ---------- */
footer {
  padding: 56px 0 72px;
  border-top: var(--rule);
  background: var(--card);
}

footer p {
  margin-bottom: 0.75em;
}

/* ---------- reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
  }
}