/* Thai typography tweaks for readability (see translating-to-thai-technical conventions). */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;600;700;800&display=swap');

:root {
  --content-max-width: 760px;
  --okf-grad: linear-gradient(135deg, #6d5efc 0%, #8b5cf6 40%, #d946ef 100%);
}

.content {
  font-family: "Noto Sans Thai", "Sarabun", system-ui, sans-serif;
  line-height: 1.75;
}

.content h1, .content h2, .content h3 {
  font-family: "Noto Sans Thai", system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.4;
}

.content code, .content pre, .hljs {
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

.content table { line-height: 1.6; }
.content blockquote { border-inline-start: 3px solid var(--quote-border); }

/* ── Cover / hero ─────────────────────────────────────────────── */
.okf-cover {
  margin: -1rem 0 2.5rem;
  padding: 3rem 2rem 3.25rem;
  border-radius: 18px;
  background: var(--okf-grad);
  color: #fff;
  text-align: center;
  box-shadow: 0 18px 50px -18px rgba(109, 94, 252, 0.6);
  position: relative;
  overflow: hidden;
}
.okf-cover svg.okf-net { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.18; }
.okf-cover > * { position: relative; z-index: 1; }
.okf-cover-badge {
  display: inline-block; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.04em;
  background: rgba(255,255,255,0.18); border: 1px solid rgba(255,255,255,0.35);
  padding: 0.25rem 0.85rem; border-radius: 999px; margin-bottom: 1rem;
}
.okf-cover-title {
  font-size: clamp(2.1rem, 6vw, 3.2rem); font-weight: 800; margin: 0.2rem 0 0.4rem;
  color: #fff; border: none; line-height: 1.1;
}
.okf-cover-title small { display:block; font-size: 0.42em; font-weight: 600; opacity: 0.92; margin-top: 0.5rem; }
.okf-cover-sub { font-size: 1.08rem; max-width: 30rem; margin: 0.4rem auto 1.6rem; opacity: 0.95; }
.okf-cover-cta { display: flex; gap: 0.7rem; justify-content: center; flex-wrap: wrap; }
.okf-btn {
  display: inline-block; padding: 0.6rem 1.25rem; border-radius: 10px; font-weight: 600;
  text-decoration: none !important; transition: transform .12s ease, box-shadow .12s ease;
  background: rgba(255,255,255,0.16); color: #fff !important; border: 1px solid rgba(255,255,255,0.4);
}
.okf-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px -8px rgba(0,0,0,0.4); }
.okf-btn-primary { background: #fff; color: #6d5efc !important; border-color: #fff; }
.okf-cover-logo { width: 62px; height: 62px; margin: 0 auto 0.9rem; }
.okf-cover-logo svg { width: 100%; height: 100%; }
.okf-cover-meta { margin-top: 1.6rem; font-size: 0.92rem; opacity: 0.92; }
.okf-cover-meta strong { font-weight: 700; }

/* ── In-page Table of Contents (cards) ────────────────────────── */
.okf-toc-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.9rem; margin: 1.2rem 0 2rem;
}
.okf-toc-card {
  display: block; padding: 1rem 1.1rem; border-radius: 12px; text-decoration: none !important;
  border: 1px solid var(--table-border-color, #e3e3e3); background: var(--table-alternate-bg, #f7f7f7);
  transition: transform .12s ease, border-color .12s ease;
}
.okf-toc-card:hover { transform: translateY(-3px); border-color: #8b5cf6; }
.okf-toc-card .num {
  display: inline-block; font-size: 0.72rem; font-weight: 700; color: #8b5cf6;
  letter-spacing: 0.06em; margin-bottom: 0.3rem;
}
.okf-toc-card .ttl { display: block; font-weight: 700; color: var(--fg); margin-bottom: 0.2rem; }
.okf-toc-card .dsc { display: block; font-size: 0.85rem; color: var(--sidebar-fg, #6b7280); line-height: 1.5; }
.okf-toc-card svg.ico { width: 26px; height: 26px; color: #8b5cf6; display: block; margin-bottom: 0.45rem; }
.okf-cover-meta br { line-height: 2; }

/* dedicated Table-of-Contents page */
.okf-tocpage strong { display: block; margin: 1.1rem 0 0.1rem; color: #8b5cf6; font-size: 1.02rem; }
.okf-tocpage ul { margin-top: 0.15rem; }
.okf-tocpage .okf-leader, .okf-tocpage .okf-pg { display: none; }   /* web: plain clickable list */
@media print {
  /* no page-break here: mdBook already starts each chapter on a fresh page; adding our
     own break double-broke and left a blank page before the TOC. */
  /* tighten so all entries fit on ONE page (EN entries were spilling 2 lines over) */
  .okf-tocpage { line-height: 1.4; font-size: 0.95rem; }
  .okf-tocpage h1 { margin-bottom: 0.4rem; }
  .okf-tocpage p { margin: 0.45rem 0 0.05rem; }
  .okf-tocpage strong { font-size: 0.97rem; }
  .okf-tocpage ul { list-style: none; padding-left: 0.4rem; margin: 0.1rem 0; }
  .okf-tocpage li { margin: 0.03rem 0; }
  .okf-tocpage li { display: flex; align-items: flex-end; }
  .okf-tocpage li > a { flex: 0 1 auto; }
  /* leader dots show only when a real page number was injected */
  .okf-tocpage li:has(.okf-pg:not(:empty)) .okf-leader {
    display: block; flex: 1 1 auto; border-bottom: 1px dotted #b9a7e6; margin: 0 0.4rem 0.34rem; min-width: 1rem;
  }
  .okf-tocpage li .okf-pg:not(:empty) { display: inline; font-variant-numeric: tabular-nums; color: #555; white-space: nowrap; }
}

/* language switch button injected into the top menu bar */
#okf-lang { font-weight: 700; }

/* ── Print vs screen: iframes don't render in PDF, show a link fallback ── */
.okf-print-only { display: none; }
@media print {
  .okf-screen-only { display: none !important; }
  .okf-print-only { display: block !important; }
}
.okf-embed-fallback {
  border: 1px dashed #8b5cf6; border-radius: 12px; padding: 1rem 1.2rem; margin: 0.6rem 0;
  background: rgba(139, 92, 246, 0.07); line-height: 1.7;
}
.okf-embed-fallback .okf-url { font-family: ui-monospace, monospace; word-break: break-all; }

/* ── Figures, diagrams, illustrations ─────────────────────────── */
pre.mermaid { background: transparent; border: 0; text-align: center; margin: 1.3rem 0; line-height: normal; }
pre.mermaid svg { max-width: 100%; height: auto; }
figure.okf-fig { margin: 1.4rem 0; text-align: center; }
figure.okf-fig svg { max-width: 100%; height: auto; }
figure.okf-fig figcaption { font-size: 0.85rem; color: var(--sidebar-fg, #6b7280); margin-top: 0.5rem; font-style: italic; }
.okf-era {
  margin: 1.8rem 0 0.6rem; padding: 0.55rem 0.95rem; border-radius: 10px;
  background: linear-gradient(90deg, rgba(139,92,246,0.13), transparent);
  border-left: 4px solid #8b5cf6;
}
.okf-era .yr { font-weight: 800; color: #8b5cf6; font-size: 0.8rem; letter-spacing: 0.03em; }
.okf-era .ti { font-weight: 700; font-size: 1.15rem; display: block; margin-top: 0.1rem; }
.okf-lead { font-size: 1.05rem; line-height: 1.85; }
.okf-lead .drop { float: left; font-size: 3rem; line-height: 0.8; font-weight: 800; color: #8b5cf6; padding: 0.3rem 0.5rem 0 0; }

/* ── Full-page A4 cover in the PDF ─────────────────────────────── */
@media print {
  @page { size: A4; margin: 17mm 15mm; }   /* room for the running header + page-number footer */
  @page :first { margin: 0; }              /* cover = full-bleed, no header/footer */
  .okf-cover-meta { margin-top: auto; padding-top: 1.5rem; }   /* pin author/date to the bottom of the cover */
  .okf-cover {
    box-sizing: border-box;
    min-height: 100vh;                  /* fill the whole A4 page */
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    break-after: page;                  /* preface starts on page 2 */
    page-break-after: always;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;          /* keep the gradient when printing */
  }
  .okf-cover-title { font-size: 3rem; }
  .okf-cover-sub { font-size: 1.15rem; }
  .okf-cover-cta { display: none !important; }   /* web buttons are useless on paper */
}
