/* ============================================================
   CAT BluePrint Notes — iframe stylesheet
   Brand: BDO Grotesk + navy palette (matches alture-template).
   Structure-borrowed (border-left headings, callouts, figures)
   from sajag12/cat-notes' styles/notes.css.
   ============================================================ */

:root {
  --nv: #0d2442;        /* primary navy */
  --nv-soft: #1a3a5c;   /* secondary navy */
  --nv-tint: #f4f7fb;   /* very light navy bg */
  --nv-pale: #e3eaf3;   /* slightly stronger navy bg (callouts) */
  --rule: #d8dee7;      /* hairlines */
  --ink: #1f2937;       /* body text */
  --ink-soft: #475569;  /* secondary text */
  --ink-mute: #64748b;  /* tertiary / labels */
  --bg: #ffffff;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'BDO Grotesk VF', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  margin: 0 auto;
  max-width: 760px;
  padding: 1.75rem 1.25rem 5rem;
  -webkit-text-size-adjust: 100%;
}

p { margin: 0 0 0.85em; }
strong { color: var(--nv); font-weight: 600; }
em { font-style: italic; color: var(--ink-soft); }
a { color: var(--nv-soft); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--nv); }

/* ---------- Headings (border-left accent, like the repo) ---------- */

h1, h2, h3, h4 {
  font-family: inherit;
  color: var(--nv);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

h1 {
  font-size: 1.75rem;
  border-left: 4px solid var(--nv);
  border-bottom: 2px solid var(--nv);
  padding: 4px 0 6px 14px;
  margin: 0 0 1.75rem;
}

h2 {
  font-size: 1.25rem;
  border-left: 3px solid var(--nv);
  border-bottom: 1px solid var(--rule);
  padding: 4px 0 5px 12px;
  margin: 2.25rem 0 0.85rem;
}

h3 {
  font-size: 1.05rem;
  color: var(--nv-soft);
  border-left: 2px solid var(--nv-soft);
  padding: 2px 0 2px 10px;
  margin: 1.75rem 0 0.6rem;
}

h4 {
  font-size: 0.85rem;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  margin: 1.25rem 0 0.5rem;
}

/* ---------- Lists ---------- */

ul, ol {
  margin: 0.5em 0 1em;
  padding-left: 1.5em;
}
li { margin-bottom: 0.3em; color: var(--ink); }
ul li::marker { color: var(--nv); }
ol li::marker { color: var(--nv); font-weight: 600; }

/* `where: …` formula supplement: tighter, navy KaTeX */
ul.where-list { font-size: 0.92rem; line-height: 1.55; margin-top: 0.25em; }
ul.where-list .katex { color: var(--nv); font-weight: 600; }

/* GFM task lists (## Checklist sections) — boxy markers, no bullet */
ul:has(> li > input[type="checkbox"]) {
  list-style: none;
  padding-left: 0.5em;
}
li:has(> input[type="checkbox"]) {
  padding: 3px 0;
  line-height: 1.6;
}
li > input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--nv);
  border-radius: 3px;
  margin: 0 0.6em 0 0;
  background: #fff;
  vertical-align: -2px;
}

/* ---------- Tables ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.92rem;
}
thead th {
  background: var(--nv);
  color: #fff;
  text-align: left;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--nv);
  font-weight: 600;
}
tbody td {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--rule);
  vertical-align: top;
  color: var(--ink);
}
tbody tr:nth-child(even) td { background: var(--nv-tint); }

/* ---------- Blockquote callouts (Watch out / Key insight / etc.) ---------- */

blockquote {
  margin: 1.5rem 0;
  padding: 0.85rem 1rem 0.85rem 1.05rem;
  background: var(--nv-tint);
  border-left: 4px solid var(--nv);
  border-radius: 4px;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--ink);
}
blockquote p { margin: 0 0 0.5em; }
blockquote p:last-child { margin-bottom: 0; }
blockquote strong:first-child { color: var(--nv); }

/* Worked example — slightly different accent so it pops as a recipe block */
blockquote.callout-worked-example {
  border-left: 5px solid var(--nv-soft);
  background: var(--nv-pale);
  padding: 1rem 1.15rem 1rem 1.25rem;
  margin: 1.75rem 0;
}
blockquote.callout-worked-example > p:first-child > strong:first-child {
  color: var(--nv-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 0.4rem;
}

/* ---------- Math (KaTeX) ---------- */

.katex { font-size: 1.02em; }
.katex-display {
  margin: 1.25rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}
.katex-display > .katex { color: var(--nv); }
.katex-error {
  color: #b91c1c;
  background: #fef2f2;
  padding: 0.05em 0.25em;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
}

/* ---------- Diagrams ---------- */

figure.diagram {
  margin: 1.5rem 0;
  text-align: center;
}
figure.diagram .figure-label {
  font-size: 0.78rem;
  color: var(--ink-mute);
  text-transform: none;
  letter-spacing: 0.02em;
  margin-bottom: 0.5rem;
  font-weight: 500;
}
figure.diagram img {
  max-width: 92%;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 4px;
}
figure.diagram.missing {
  border: 1px dashed var(--rule);
  padding: 1.5rem;
  color: var(--ink-mute);
  font-style: italic;
}

/* ---------- Horizontal rule ---------- */

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2rem 0;
}

/* ---------- Inline code ---------- */

code {
  background: var(--nv-tint);
  color: var(--nv);
  padding: 0.05em 0.35em;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
}

/* ---------- Chapter cover page ---------- */

.title-page {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 90vh;
  margin: -1.75rem -1.25rem 3.5rem;
  padding: 4rem 2rem;
  background: linear-gradient(180deg, var(--nv) 0%, #122c4f 100%);
  color: #fff;
  page-break-after: always;
  break-after: page;
}
.title-content { max-width: 480px; }
.title-content h1 {
  color: #fff;
  font-size: clamp(2rem, 4.5vw, 2.6rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  padding: 0;
  border: none;
}
.title-rule {
  width: 56px;
  height: 1px;
  background: rgba(255, 255, 255, 0.45);
  margin: 1rem auto;
}
.subtitle {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 500;
  letter-spacing: 0.01em;
}
.title-year {
  margin-top: 0.85rem;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 500;
}
.bottom-accent {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: linear-gradient(90deg, #4a7bc8 0%, var(--nv-soft) 50%, #4a7bc8 100%);
}

/* ---------- Interactive checklist ---------- */

ul.checklist {
  list-style: none;
  padding-left: 0;
  margin: 0.5rem 0 1.5rem;
}
.checklist-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.65rem;
  margin: 0;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: background 0.15s ease;
  list-style: none;
}
/* Defensive: collapse any block element KaTeX, watermark, or markdown injects
 * inside an item — fractions otherwise inflate the row, and stray
 * `katex-display` / `<p>` wrappers can produce phantom row-height gaps. */
.checklist-item .cl-text { margin: 0; padding: 0; }
.checklist-item .cl-text .katex { font-size: 1em; vertical-align: middle; }
.checklist-item .cl-text .katex-display,
.checklist-item .cl-text p,
.checklist-item .cl-text br + br {
  display: inline;
  margin: 0;
  padding: 0;
}
ul.checklist { margin: 0.5rem 0 1.5rem; padding-left: 0; }
ul.checklist > li { margin: 0; }
.checklist-item:last-child { border-bottom: none; }
.checklist-item:hover { background: var(--nv-tint); }
.checklist-item .cl-checkbox {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 1.5px solid #b0b9c5;
  border-radius: 4px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.checklist-item .cl-checkbox svg {
  width: 12px;
  height: 12px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.checklist-item.is-checked .cl-checkbox {
  background: var(--nv);
  border-color: var(--nv);
}
.checklist-item.is-checked .cl-checkbox svg { opacity: 1; }
.checklist-item.is-checked .cl-text {
  color: var(--ink-mute);
  text-decoration: line-through;
}
.checklist-item .cl-text { flex: 1; line-height: 1.6; color: var(--ink); }

/* ---------- Practice question heading (with CAT-year slot tag) ---------- */

h3.question-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
h3.question-heading .question-text { flex: 0 0 auto; }
h3.question-heading .slot-tag {
  margin-left: auto;
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--ink-mute);
  text-transform: none;
  white-space: nowrap;
}

/* ---------- Practice MCQ options ---------- */

.mcq-options {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 1rem 0 0.75rem;
}
.mcq-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0.95rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.mcq-option:hover { border-color: var(--nv); background: var(--nv-tint); }
.mcq-letter {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: #fff;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.mcq-option-text { flex: 1; line-height: 1.55; color: var(--ink); }
.mcq-option.is-correct {
  border-color: #16a34a;
  background: #f0fdf4;
}
.mcq-option.is-correct .mcq-letter {
  border-color: #16a34a;
  background: #16a34a;
  color: #fff;
}
.mcq-option.is-wrong {
  border-color: #dc2626;
  background: #fef2f2;
}
.mcq-option.is-wrong .mcq-letter {
  border-color: #dc2626;
  background: #dc2626;
  color: #fff;
}
.mcq-option.is-disabled { cursor: default; }
.mcq-option.is-disabled:hover { background: inherit; border-color: inherit; }

.mcq-show-answer {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.95rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 100px;
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--ink-soft);
  cursor: pointer;
  margin: 0.25rem 0 1.5rem;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.mcq-show-answer:hover { border-color: var(--nv); color: var(--nv); }
.mcq-show-answer.is-hidden { display: none; }

/* ---------- Generic callouts (Answer reveal, etc.) ---------- */

.callout {
  margin: 1rem 0 1.5rem;
  padding: 0.85rem 1rem 0.85rem 1.05rem;
  background: var(--nv-tint);
  border-left: 4px solid var(--nv);
  border-radius: 4px;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--ink);
}
.callout p { margin: 0 0 0.5em; }
.callout p:last-child { margin-bottom: 0; }
.callout-default {
  border-left-color: var(--ink-mute);
  background: #f8fafc;
}
/* Answer reveal callout — navy + light-blue scheme (matches alture-template).
   Same styling regardless of correct/incorrect; only the tag text differs. */
.callout-key-insight {
  border-left-color: var(--nv);
  background: var(--nv-tint);
}
.callout-tag {
  display: inline-block;
  background: var(--nv);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.28rem 0.78rem;
  border-radius: 100px;
  margin-bottom: 0.7rem;
}
/* Optional muted tone for incorrect — keep navy pill but signal with subtle red border */
.callout-key-insight.is-incorrect {
  border-left-color: #dc2626;
}
.callout-key-insight.is-incorrect .callout-tag {
  background: #dc2626;
}

/* TITA (numeric / fill-in answers) — text input + check button */
.tita-input-row {
  display: flex;
  gap: 0.6rem;
  align-items: stretch;
  margin: 1rem 0 0.75rem;
  flex-wrap: wrap;
}
.tita-input {
  flex: 1;
  min-width: 200px;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease;
}
.tita-input:focus { border-color: var(--nv); }
.tita-input:disabled { background: var(--nv-tint); color: var(--ink-soft); cursor: default; }
.tita-check {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: var(--nv);
  border: none;
  border-radius: 8px;
  padding: 0 1.1rem;
  cursor: pointer;
  transition: background 0.15s ease;
}
.tita-check:hover { background: var(--nv-soft); }
.tita-input-row.is-answered .tita-check { display: none; }

/* ---------- Mobile ---------- */

@media (max-width: 720px) {
  body { font-size: 0.95rem; line-height: 1.6; padding: 1rem 1rem 4rem; }
  h1 { font-size: 1.45rem; margin-bottom: 1.25rem; }
  h2 { font-size: 1.1rem; margin: 1.75rem 0 0.65rem; }
  h3 { font-size: 1rem; margin: 1.25rem 0 0.5rem; }
  table { display: block; overflow-x: auto; white-space: nowrap; font-size: 0.88rem; }
  figure.diagram img { max-width: 100%; }
  blockquote { font-size: 0.9rem; padding: 0.7rem 0.9rem; }
  .katex-display { font-size: 0.95em; }
}
