/* Blog post styles, ported from pensive-school apps/web/src/routes/schools/blog
   (-blog-detail.tsx and -blog-markdown.module.css). Builds on /style.css tokens. */

.blog-page { --content-width: 1032px; --text-body: rgba(24, 33, 46, 0.8); --text-caption: rgba(24, 33, 46, 0.55); --hairline: rgba(24, 33, 46, 0.12); }
.blog-page main { padding-top: 40px; }

/* Sticky top bar: Contact stays in reach while reading. The bar also lists the main sections,
   which scroll sideways if they don't fit. */
.blog-page { --bar-h: 60px; }
html { scroll-padding-top: 60px; }
.top-bar { position: sticky; top: 0; z-index: 20; background: var(--landing-background); border-bottom: 1px solid transparent; transition: border-color 150ms; }
.top-bar.scrolled { border-bottom-color: var(--hairline); }
.top-bar .site-header { min-height: var(--bar-h); }
.top-bar .brand { flex: none; }
.top-bar .nav { align-self: stretch; min-width: 0; white-space: nowrap; }
.nav-sections { display: flex; align-items: center; align-self: stretch; gap: inherit; min-width: 0; overflow-x: auto; scrollbar-width: none; padding-right: 12px; margin-right: -12px; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 12px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 12px), transparent); }
.nav-sections::-webkit-scrollbar { display: none; }
/* Wide screens: the section links show above the post and give way to the side contents once it is in view (blog.js adds .in-post). */
@media (min-width: 1200px) {
  .nav-sections { transition: opacity 150ms, visibility 150ms; }
  .top-bar.in-post .nav-sections { opacity: 0; visibility: hidden; }
}
.top-bar .nav a[aria-current] { font-weight: 400; } /* no width change as the marker moves */
@media (max-width: 760px) {
  .blog-page { --bar-h: 52px; }
  html { scroll-padding-top: 52px; }
}

/* Page header and leaderboard share the article's column */
.blog-page main > :is(.intro, .leaderboard) { max-width: 760px; margin-left: auto; margin-right: auto; }
.byline { margin: 22px 0 0; font-family: var(--font-landing); font-size: 15px; color: var(--landing-faint); }
.post { margin-top: clamp(48px, 6vw, 72px); }
.post-body > h2:first-child { margin-top: 0; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* Body column with the contents list in the left margin on wide screens */
.post-columns { position: relative; max-width: 760px; margin: 0 auto; }
.toc { display: none; }
@media (min-width: 1200px) {
  .toc {
    display: block;
    position: absolute;
    top: 0;
    bottom: 0;
    right: 100%;
    width: 180px;
    margin-right: 32px;
  }
  .toc > * { position: sticky; }
  .toc > ol { top: calc(var(--bar-h) + 32px); max-height: calc(100vh - var(--bar-h) - 64px); overflow-y: auto; }
}
@media (min-width: 1360px) {
  .toc { width: 200px; margin-right: 48px; }
}
.toc-title { display: none; }
.toc ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; font-family: var(--font-landing); font-size: 13px; line-height: 18px; }
.toc ol ol { margin-top: 8px; padding-left: 14px; gap: 7px; }
/* Subsections show only for the section being read (blog.js adds .expanded). */
.toc > ol > li:not(.expanded) > ol { display: none; }
.toc a { display: block; color: var(--text-body); text-decoration: none; border-radius: 2px; transition: color 150ms; }
.toc ol ol a { color: var(--text-caption); }
.toc a:hover { color: var(--landing-header); }
.toc a[aria-current] { color: var(--landing-header); font-weight: 500; }

/* Markdown body */
.post-body { font-family: var(--font-landing); font-feature-settings: "blwf", "cv09", "cv03", "cv04", "cv11"; }
.post-body h2, .post-body h3, .post-body h4 { font-family: var(--font-landing); font-weight: 500; color: var(--landing-header); letter-spacing: 0; scroll-margin-top: 24px; }
.post-body h2 { font-size: 24px; line-height: 1.4; margin: 48px 0 16px; }
.post-body h3 { font-size: 20px; line-height: 28px; margin: 32px 0 16px; }
.post-body h4 { font-size: 17px; line-height: 26px; margin: 24px 0 12px; }
.post-body p, .post-body li { font-size: 16px; line-height: 26px; color: var(--text-body); }
.post-body p { margin: 0 0 16px; }
.post-body ul, .post-body ol { margin: 0 0 16px; padding-left: 24px; }
.post-body li { margin-bottom: 8px; }
.post-body strong { font-weight: 600; color: var(--landing-header); }
.post-body a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }

.post-body figure { margin: 32px 0; }
.post-body img { display: block; width: 100%; height: auto; border-radius: 12px; }
.post-body p.caption { font-size: 13px; line-height: 20px; color: var(--text-caption); }
.post-body figcaption { margin-top: 12px; font-size: 13px; line-height: 20px; font-style: italic; text-align: left; color: var(--text-caption); }

.post-body .table-scroll { margin: 24px 0 32px; overflow-x: auto; }
/* A caption sits close to its table, with the larger gap after the caption. */
.post-body figure > .table-scroll:has(+ figcaption) { margin-bottom: 0; }
.post-body .table-scroll:has(+ p.caption) { margin-bottom: 12px; }
.post-body .table-scroll + p.caption { margin-bottom: 32px; }
.post-body table { width: 100%; font-size: 14px; line-height: 20px; color: var(--landing-header); }
.post-body thead th {
  font-family: var(--font-landing);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--landing-header);
  background: rgba(0, 128, 128, 0.06);
  padding: 8px 12px;
  vertical-align: middle;
}
.post-body :is(td, th) { padding: 8px 12px; border-bottom: 1px solid var(--hairline); white-space: normal; }
.post-body :is(td, th):first-child { padding-left: 12px; }
.post-body :is(td, th):last-child { padding-right: 12px; }

.post-body pre {
  margin: 24px 0;
  padding: 20px 24px;
  border-radius: 12px;
  background: rgba(24, 33, 46, 0.04);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 20px;
  white-space: pre-wrap;
  color: var(--landing-header);
}

/* Embeds */
.chip-tabs { margin: 32px 0; display: flex; flex-direction: column; gap: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  padding: 8px 16px;
  border: 0;
  border-radius: 9999px;
  background: var(--landing-surface);
  color: var(--landing-muted);
  font-family: var(--font-landing);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms, color 150ms;
}
.chips button:hover { color: var(--landing-header); }
.chips button[aria-selected="true"] { background: var(--landing-header); color: #fff; }
.chip-tabs figure { margin: 0; }

.score-chips table { table-layout: fixed; }
.score-chips thead th { width: 38%; }
.score-chips thead th + th { width: auto; }
.score-chips tbody th { font-weight: 400; }
.bar { display: flex; align-items: center; gap: 10px; }
.bar-track { position: relative; flex: 1; height: 8px; border-radius: 9999px; background: #efede7; }
.bar-track b { position: absolute; top: 50%; height: 12px; margin-top: -6px; border: solid var(--landing-header); border-width: 0 1.5px; }
.bar-track b::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; margin-top: -0.75px; border-top: 1.5px solid var(--landing-header); }
.bar-track i { position: absolute; inset: 0 auto 0 0; border-radius: 9999px; background: var(--chart-bar); }
.bar-value { width: 48px; flex: none; text-align: right; font-variant-numeric: tabular-nums; }

.carousel { margin: 32px 0; }
.carousel-frame { overflow: hidden; border-radius: 12px; border: 1px solid rgba(24, 33, 46, 0.08); }
.carousel-track { display: flex; transition: transform 300ms ease-out; }
.carousel-track > div { flex: none; width: 100%; }
.post-body .carousel img { border: 0; border-radius: 0; }
.carousel-controls { display: flex; align-items: flex-start; gap: 12px; margin-top: 16px; }
.post-body .carousel-caption { flex: 1; margin: 0; text-align: center; font-size: 14px; line-height: 22px; color: var(--text-caption); }
.carousel-caption span { display: block; margin-top: 4px; font-size: 13px; }
.round {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--landing-surface);
  color: var(--landing-header);
  cursor: pointer;
  transition: background-color 150ms;
}
.round:hover:not(:disabled) { background: #efe9df; }
.round:disabled { opacity: 0.4; cursor: default; }
.round svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.citation { position: relative; margin: 24px 0; }
.post-body .citation pre { margin: 0; padding-right: 72px; white-space: pre; overflow-x: auto; }
.copy {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 10px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--landing-background);
  color: var(--landing-muted);
  font-family: var(--font-landing);
  font-size: 12px;
  cursor: pointer;
}
.copy:hover { color: var(--landing-header); }

.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 560px) {
  .score-chips thead th { width: 46%; }
}

/* Which way models miss: harsh bars grow left from the middle, lenient bars grow right */
.direction { --dir-label: 52px; }
.direction table { table-layout: fixed; }
.direction thead th:first-child { width: 30%; }
.direction thead th.harsh { text-align: right; }
.post-body .direction tbody th { font-weight: 400; }
.post-body .direction td { padding-top: 6px; padding-bottom: 6px; }
.post-body .direction td.harsh { padding-right: 0; border-right: 1px solid rgba(24, 33, 46, 0.35); }
.post-body .direction td.lenient { padding-left: 0; }
.dir-bar { display: flex; align-items: center; gap: 8px; }
.harsh .dir-bar { flex-direction: row-reverse; }
.harsh .dir-bar b { text-align: right; }
.dir-bar i { height: 14px; flex: none; }
.harsh .dir-bar i { background: #c0563f; border-radius: 3px 0 0 3px; }
.lenient .dir-bar i { background: #5a8fbf; border-radius: 0 3px 3px 0; }
.dir-bar b { width: calc(var(--dir-label) - 8px); flex: none; font-weight: 400; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--landing-header); }

/* Failure cases: the rubric with the instructor's and each model's items */
.rubric-case { margin: 16px 0 40px; }
.post-body .rubric-case .table-scroll { margin: 0; }
.rubric-case table { min-width: 560px; }
.post-body .rubric-case :is(td, th) { padding: 8px 10px; vertical-align: middle; }
.rubric-case .num, .rubric-case .pts { width: 1%; white-space: nowrap; color: var(--text-caption); font-variant-numeric: tabular-nums; }
.rubric-case .pts { text-align: right; }
.post-body .rubric-case thead th.pick { width: 76px; padding: 8px 4px; text-align: center; font-size: 13px; line-height: 16px; }
.rubric-case thead th.pick img { display: block; width: 14px; height: 14px; margin: 0 auto 4px; border: 0; border-radius: 0; }
.rubric-case td.pick { position: relative; text-align: center; padding: 0; }
.rubric-case thead th.pick small { display: block; font-size: 11px; font-weight: 400; color: var(--text-caption); }
.rubric-case .search { border-left: 1px solid var(--hairline); }
.rubric-case .search + .search { border-left: 0; }
.rubric-case td.pick svg { width: 16px; height: 16px; vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.rubric-case td.instructor { background: var(--chart-bar); color: #fff; }
.rubric-case td.agree { background: rgba(9, 129, 107, 0.12); color: var(--chart-bar); }
.rubric-case td.wrong { background: rgba(196, 60, 46, 0.12); color: #b23a2c; }
.rubric-case figcaption { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 16px; font-style: normal; }
.rubric-case .legend-item { display: inline-flex; align-items: center; gap: 6px; }
.rubric-case .key { width: 12px; height: 12px; border-radius: 3px; }
.rubric-case .key.instructor { background: var(--chart-bar); }
.rubric-case .key.agree { background: rgba(9, 129, 107, 0.22); }
.rubric-case .key.wrong { background: rgba(196, 60, 46, 0.22); }

/* Failure-case decks: one card per case, side by side, snapping into place */
.case-deck { margin: 16px 0 40px; }
/* A single example outside a deck gets the deck's spacing. */
.post-body .case:not(.case-track > .case) { margin: 16px 0 40px; }
.case-track {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden; /* the page scrolls vertically, never the deck */
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  transition: height 250ms ease-out;
}
.case-track::-webkit-scrollbar { display: none; }
.case {
  flex: 0 0 100%;
  min-width: 0; /* a wide rubric table scrolls inside the card instead of stretching it */
  box-sizing: border-box;
  scroll-snap-align: start;
  padding: 24px;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  background: #fff;
}
.post-body .case-label {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
}
.post-body .case figure { margin: 20px 0 16px; }
/* Fold-out with the student's page, for cards that revisit an earlier example. */
.post-body details.work { margin: 14px 0 18px; }
.post-body details.work summary { width: fit-content; cursor: pointer; font-size: 15px; color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.post-body details.work summary:hover { color: var(--primary-800); }
.post-body details.work figure { margin: 14px 0 0; }
/* Tall scans shrink to fit so every card stays a similar height. */
/* At most 420px tall; sized from --ar so the card keeps its height while the image loads. */
.post-body .case figure img { width: min(100%, calc(420px * var(--ar))); margin: 0 auto; }
.case .rubric-case { margin: 0; }
.case > :last-child { margin-bottom: 0; }
.case-controls { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.case-dots { display: flex; gap: 8px; margin-left: auto; }
.case-dots button { width: 8px; height: 8px; padding: 0; border: 0; border-radius: 50%; background: rgba(24, 33, 46, 0.18); cursor: pointer; transition: background-color 150ms, width 150ms; }
.case-dots button[aria-current="true"] { width: 20px; border-radius: 9999px; background: var(--landing-header); }
.case-count { margin-right: auto; font-family: var(--font-landing); font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text-caption); }
@media (prefers-reduced-motion: reduce) { .case-track { transition: none; } }

/* Fit the rubric and all four graders on a phone: drop the item number, narrow the tick columns. */
@media (max-width: 560px) {
  .rubric-case table { min-width: 0; font-size: 13px; line-height: 18px; }
  .rubric-case .num { display: none; }
  .post-body .rubric-case :is(td, th) { padding: 7px 6px; }
  .post-body .rubric-case thead th.pick { width: 38px; padding: 6px 1px; font-size: 10.5px; line-height: 13px; }
  .post-body .rubric-case .pts { padding-right: 2px; }
  .rubric-case td.pick svg { width: 14px; height: 14px; }
  .case { padding: 16px 14px; border-radius: 12px; }
}

/* Chart of which way models miss, on a phone: smaller labels so the bars keep their length. */
@media (max-width: 560px) {
  .direction { --dir-label: 38px; }
  .direction thead th:first-child { width: 28%; }
  .post-body .direction :is(td, th) { padding-left: 4px; padding-right: 4px; font-size: 12px; }
  .dir-bar { gap: 4px; }
  .dir-bar b { font-size: 11px; }
  .dir-bar i { height: 12px; }
}
