/*
 * Research notebook: long-form reading. Loaded after detail.css, whose shared panel-summary rule
 * this file refines for notebook pages.
 *
 * Layout: a compact header bar, a sticky table-of-contents rail on desktop (`248px`), and a
 * dedicated reading column so prose fills its panel cleanly without half-empty whitespace.
 */

.research-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 4px 0 20px; padding-bottom: 16px; border-bottom: 1px solid var(--soft-line); }
.research-heading h2 { font-size: var(--text-2xl); font-stretch: 85%; margin: 0 0 6px; }
.research-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; font-size: var(--text-s); color: var(--muted); }
.research-meta p { margin: 0; }
.research-progress { display: contents; }
.research-progress-status { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-weight: 500; }
.status-dot.warning { background: var(--warning); }
.research-gaps { flex-basis: 100%; margin: 6px 0 0; padding-left: 18px; color: var(--warning); font-size: var(--text-s); line-height: 1.5; }
.notebook-controls { display: flex; gap: 8px; }

/* Two-column editorial layout: sticky contents rail + main reading column. */
.notebook-layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 24px; align-items: start; }
.research-sections { min-width: 0; }

/* Contents rail: every page one click away, active open chapters clearly marked. */
.notebook-contents { position: sticky; top: 16px; max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--sunk); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; scrollbar-width: thin; }
.notebook-contents ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 2px; }
.notebook-contents a { display: flex; gap: 9px; align-items: baseline; padding: 7px 9px; border-radius: var(--radius-control); font-size: 13px; line-height: 1.35; color: var(--ink-2); transition: background 120ms ease, color 120ms ease; }
.notebook-contents a:hover { background: #e9eeea; color: var(--ink); }
.notebook-contents li.active > a { background: var(--paper); color: var(--ink); font-weight: 550; box-shadow: inset 0 0 0 1px var(--soft-line); }
.contents-number { min-width: 2ch; color: var(--muted); font-size: var(--text-s); flex-shrink: 0; }
.notebook-contents li.active .contents-number { color: var(--forest); font-weight: 600; }

/* Page panels. scroll-margin leaves a gap above a page or heading reached by a link. */
.research-section { margin-bottom: 16px; scroll-margin-top: 16px; }
.research-section > summary { padding: 18px 28px; font-size: 18px; font-weight: 650; color: var(--ink); gap: 12px; }
.research-section[open] > summary { border-bottom: 1px solid var(--soft-line); background: #fafbfa; }
.section-number { min-width: 28px; padding: 2px 7px; border-radius: var(--radius-tag); background: var(--soft-green); color: var(--forest); font-size: 12px; font-weight: 650; text-align: center; line-height: 1.4; flex-shrink: 0; }

/* Body text. Reading column fits prose comfortably without leaving half the card empty. */
.prose { --measure: 64rem; font-size: 14.5px; line-height: 1.72; color: var(--ink-2); overflow-wrap: break-word; }
.research-section .prose { padding: 22px 32px 28px; }
.prose > :not(.prose-table-scroll) { max-width: var(--measure); }
.prose > :first-child { margin-top: 0; }
.prose p { line-height: 1.72; margin: 0 0 15px; }
/* Subheadings step neatly inside the 18px chapter title with clean section dividers. */
.prose h2, .prose h3 { font-size: 17px; line-height: 1.35; color: var(--ink); font-weight: 650; margin: 28px 0 12px; padding-top: 18px; border-top: 1px solid var(--soft-line); }
.prose > :is(h2, h3):first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.prose h4 { font-size: 15px; color: var(--ink); font-weight: 600; margin: 22px 0 8px; }
.prose h5, .prose h6 { font-size: var(--text-m); color: var(--ink-2); font-weight: 600; margin: 18px 0 6px; }
.prose :is(h2, h3, h4, h5, h6) { scroll-margin-top: 16px; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 15px; }
.prose li { padding-left: 3px; margin-bottom: 7px; }
.prose li > ul, .prose li > ol { margin: 6px 0 0; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose code { font-size: 12px; color: var(--muted); background: var(--sunk); border: 0; border-radius: var(--radius-tag); padding: 1px 5px; overflow-wrap: anywhere; }
.prose a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }
.prose blockquote { margin: 0 0 15px; padding: 2px 0 2px 16px; border-left: 3px solid var(--line); color: var(--ink-2); }
.prose hr { border: 0; border-top: 1px solid var(--soft-line); margin: 24px 0; }
.prose-sources { font-size: var(--text-s); line-height: 1.65; color: var(--muted); border-top: 1px solid var(--soft-line); padding-top: 14px; margin: 22px 0 0 !important; }

/* The "#" link beside a heading: shown on hover or keyboard focus, always on touch screens. */
.prose .heading-anchor { margin-left: .4em; color: var(--muted); font-weight: 400; text-decoration: none; opacity: 0; }
.prose :is(h2, h3, h4, h5, h6):hover .heading-anchor, .prose .heading-anchor:focus-visible { opacity: 1; }
@media (hover: none) { .prose .heading-anchor { opacity: 1; } }

/*
 * Citations recede (muted, 4.9:1) so the argument reads first. A resolved ID is an underlined
 * link; an ID with no published source gets a dotted warning underline and stays plain text.
 */
.citation { color: var(--muted); }
.citation a { color: var(--ink-2); }
.citation-source { text-decoration: underline dotted var(--line); text-underline-offset: 3px; }
.citation-unresolved { text-decoration: underline dotted var(--warning); text-underline-offset: 3px; }

/*
 * Tables. Text cells wrap but keep a 9em floor, so a long explanation is not squeezed into a
 * sliver beside a row of figures; figures stay on one line, right-aligned, in tabular numerals.
 */
.prose-table-scroll { margin: 14px 0 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.prose-table { font-size: 13px; line-height: 1.55; }
.prose-table th, .prose-table td { white-space: normal; vertical-align: top; padding: 10px 14px; }
.prose-table :is(th, td):not(.align-right):not(.align-center) { min-width: 9em; }
.prose-table thead th:first-child, .prose-table tbody th[scope="row"] { position: sticky; left: 0; z-index: 1; }
.prose-table thead th:first-child { background: var(--sunk); }
.prose-table tbody th[scope="row"] { background: var(--paper); font-weight: 550; color: var(--ink-2); }
.prose-table tbody tr:last-child > * { border-bottom: 0; }
.prose-table .align-right { text-align: right; white-space: nowrap; }
.prose-table .align-center { text-align: center; }

@media (pointer: coarse) { .notebook-contents a { min-height: 44px; align-items: center; } }

@media (max-width: 960px) {
  .notebook-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .notebook-contents { position: static; max-height: none; padding: 14px 16px; }
  .notebook-contents ol { grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 2px 16px; }
}

@media (max-width: 600px) {
  .research-section > summary { padding: 16px 20px; font-size: 16px; gap: 10px; }
  .notebook-contents { padding: 12px; }
  .research-section .prose { padding: 18px 20px 22px; font-size: var(--text-m); }
  .notebook-contents ol { grid-template-columns: minmax(0, 1fr); }
  .prose-table th, .prose-table td { padding: 8px 10px; }
  /* A narrow pinned label column, so most of the screen is left for the scrolling figures. */
  /* `.prose` raises specificity above the 9em text-cell floor above. */
  .prose .prose-table tbody th[scope="row"], .prose .prose-table thead th:first-child { width: 7em; min-width: 7em; }
}
