/* ===========================================================
   Exam-prep note styling — TH Sarabun PSK
   Local "TH Sarabun PSK" first; web "Sarabun" (Google) as fallback
   so the page reads correctly on devices without the system font.
   =========================================================== */

@import url("https://fonts.googleapis.com/css2?family=Sarabun:ital,wght@0,400;0,500;0,700;1,400&display=swap");

:root {
  --sarabun-stack: "TH Sarabun PSK", "TH Sarabun New", "Sarabun", "Noto Sans Thai", sans-serif;
}

/* Apply Sarabun to the whole article (title, meta, body) */
.post,
.post-title,
.post-meta,
.post-content {
  font-family: var(--sarabun-stack);
}

/* TH Sarabun renders small — bump up size and line-height for comfortable study reading */
.post-content {
  font-size: 1rem;
  line-height: 1.6;
  letter-spacing: 0.1px;
}

.post-title {
  font-size: 1.625rem;
  line-height: 1.25;
}

.post-content h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 2.4rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid currentColor;
}

.post-content h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 1.8rem;
}

.post-content h4 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 1.4rem;
}

.post-content p,
.post-content li {
  font-size: 1rem;
  line-height: 1.6;
}

/* Key-term highlight */
.post-content strong {
  font-weight: 700;
}

/* English technical terms inline — keep a hair smaller and tracked-out */
.post-content em {
  font-style: italic;
}

/* Callout boxes for "สรุปประเด็นสอบ" */
.exam-box {
  border-left: 4px solid currentColor;
  padding: 0.8rem 1.2rem;
  margin: 1.6rem 0;
  background: rgba(127, 127, 127, 0.08);
  border-radius: 4px;
}

.exam-box .exam-box__title {
  font-weight: 700;
  font-size: 1.35rem;
  margin-bottom: 0.4rem;
}

/* Definition table */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4rem 0;
  font-size: 1rem;
}

.post-content th,
.post-content td {
  border: 1px solid rgba(127, 127, 127, 0.4);
  padding: 0.55rem 0.8rem;
  text-align: left;
  vertical-align: top;
}

.post-content th {
  font-weight: 700;
  background: rgba(127, 127, 127, 0.1);
}

/* Figure images pulled from the original Nature article */
.post-content figure.fig {
  margin: 1.8rem 0;
  text-align: center;
}

.post-content figure.fig img {
  max-width: 100%;
  height: auto;
  border: 1px solid rgba(127, 127, 127, 0.35);
  border-radius: 6px;
  background: #fff;
  padding: 0.5rem;
}

.post-content figure.fig figcaption {
  margin-top: 0.6rem;
  font-size: 1.05rem;
  opacity: 0.7;
  font-style: italic;
}

/* Block quotes / abstract */
.post-content blockquote {
  border-left: 4px solid currentColor;
  padding-left: 1rem;
  margin-left: 0;
  font-size: 1rem;
  opacity: 0.92;
}

/* ══════════════════════════════════════════════════════════════════
   Interactive Visualization Widgets
   ══════════════════════════════════════════════════════════════════ */

[id^="vis-"] {
  margin: 2rem 0;
  border: 1px solid rgba(127, 127, 127, 0.28);
  border-radius: 10px;
  overflow: hidden;
  background: var(--color-surface);
  font-family: var(--sarabun-stack);
}

.dlv-head {
  padding: 0.55rem 1rem;
  font-weight: 700;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(127, 127, 127, 0.2);
  background: rgba(127, 127, 127, 0.05);
  letter-spacing: 0.01em;
}

.dlv-canvas {
  display: block;
  width: 100%;
  background: var(--color-bg);
}

.dlv-foot {
  padding: 0.65rem 1rem 0.8rem;
  border-top: 1px solid rgba(127, 127, 127, 0.2);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.dlv-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.dlv-btns {
  display: flex;
  gap: 0.35rem;
}

.dlv-btn {
  padding: 0.22rem 0.7rem;
  border: 1px solid rgba(127, 127, 127, 0.38);
  border-radius: 4px;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  font-size: 0.82rem;
  font-family: var(--sarabun-stack);
  transition: background 0.14s, color 0.14s, border-color 0.14s;
  line-height: 1.5;
}
.dlv-btn:hover {
  background: var(--color-link);
  color: #fff;
  border-color: var(--color-link);
}
.dlv-btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}
.dlv-btn-p {
  background: var(--color-link);
  color: #fff !important;
  border-color: var(--color-link);
}
.dlv-btn-p:hover {
  opacity: 0.88;
}

.dlv-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
}

.dlv-slider {
  width: 96px;
  accent-color: var(--color-link);
  vertical-align: middle;
}

.dlv-select {
  padding: 0.18rem 0.45rem;
  border: 1px solid rgba(127, 127, 127, 0.38);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.82rem;
  font-family: var(--sarabun-stack);
}

.dlv-info {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
}

.dlv-hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-style: italic;
  margin: 0;
}

.dlv-compute {
  font-size: 0.76rem;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  color: var(--color-text-muted);
  min-height: 1.3rem;
  word-break: break-all;
}

/* Backprop step info box */
.dlv-step-box {
  padding: 0.65rem 1rem;
  border-top: 1px solid rgba(127, 127, 127, 0.15);
  background: rgba(127, 127, 127, 0.03);
  font-size: 0.82rem;
  line-height: 1.65;
  min-height: 4.5rem;
}
.dlv-step-box strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.84rem;
}
.dlv-step-box code {
  font-size: 0.74rem;
  background: none;
  border: none;
  padding: 0;
  color: var(--color-text-muted);
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
}
