/* ============================================================
   Site overrides — layout width, modal reader, hidden fix
   Loaded after site.css to take precedence.
   ============================================================ */

/* ---- Wider content ---------------------------------------- */
:root {
  --col-content: 1440px;
  --col-prose:    780px;
  --site-pad:      48px;
}

/* Post page grid — override hardcoded widths from site.css */
.post-page-grid {
  max-width: 1440px;
}
.post-page-grid.no-sidenotes {
  max-width: 1120px;
}

/* ToC wrap: sticky + scrollable for long tables of contents */
.post-toc-wrap {
  position: sticky;
  top: 90px;
  align-self: start;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  /* thin scrollbar so it doesn't eat into the 220px column */
  scrollbar-width: thin;
  scrollbar-color: var(--hairline-strong) transparent;
}
/* Inner .post-toc is already sticky via site.css; the wrap handles it now */
.post-toc-wrap .post-toc {
  position: static;
  align-self: auto;
}
@media (max-width: 1080px) {
  .post-toc-wrap {
    position: static;
    max-height: none;
    overflow-y: visible;
  }
}

/* ---- Callout boxes (concept, definition, note) ------------ */
.callout {
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin: 28px 0;
  border-left: 3px solid;
}
.callout > .callout-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin: 0 0 10px;
}
.callout p:last-child { margin-bottom: 0; }

.callout-concept {
  background: var(--bg-panel);
  border-color: var(--accent-mid, var(--accent));
}
.callout-concept .callout-title { color: var(--accent-strong); }

.callout-definition {
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-page));
  border-color: var(--accent);
}
.callout-definition .callout-title { color: var(--accent-strong); }

.callout-note {
  background: color-mix(in srgb, #f59e0b 8%, var(--bg-page));
  border-color: #f59e0b;
}
.callout-note .callout-title { color: #b45309; }
[data-theme="dark"] .callout-note .callout-title { color: #fbbf24; }

/* KaTeX display math centering */
.katex-display { overflow-x: auto; overflow-y: hidden; }

/* ---- Reader pane: wide centered modal --------------------- */

/* Hidden attribute must win even when display:flex is declared */
.reader-scrim[hidden] { display: none !important; }

/* Scrim doubles as the centering flex container */
.reader-scrim {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(10, 14, 12, 0.65);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 24px 80px;
  overflow-y: auto;
  animation: scrim-in .18s ease;
}

/* Modal panel — centered, rounded, no longer pinned to right edge */
.reader-pane {
  position: relative;
  top: auto; right: auto; bottom: auto;
  width: 100%;
  max-width: 920px;
  /* no explicit height — grows with content; scrim scrolls */
  min-height: 300px;
  background: var(--bg-page);
  border: 1px solid var(--hairline-strong);
  border-left: 1px solid var(--hairline-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), 0 24px 64px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  animation: modal-in .22s ease;
  flex-shrink: 0; /* don't squish inside the scrim flex row */
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* Header: rounded top corners */
.reader-head {
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  flex-shrink: 0;
}

/* Body: generous padding, no max-height (scrim handles scroll) */
.reader-body {
  flex: 1;
  overflow-y: visible;
  padding: 32px 44px 60px;
}

/* ---- README markdown styles ------------------------------- */
.reader-md img {
  max-width: 100%;
  height: auto;
}

/* Badge images (shields.io etc.) — keep inline */
.reader-md img[src*="shields.io"],
.reader-md img[src*="img.shields.io"] {
  display: inline;
  vertical-align: middle;
  height: 20px;
  width: auto;
  margin: 0 3px;
}

/* Badges wrapped in paragraph links — don't force block */
.reader-md p:has(> a > img[src*="shields.io"]),
.reader-md p:has(> img[src*="shields.io"]) {
  line-height: 1.8;
}

/* Hide broken images (empty src or hash-only) */
.reader-md img[src="#"],
.reader-md img[src=""] {
  display: none;
}

/* ---- Syntax highlighting (highlight.js) ------------------- */

pre.hljs {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.65;
  margin: 24px 0;
}

/* Language label */
pre.hljs[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-4, var(--fg-3));
  opacity: 0.7;
}

pre.hljs code {
  background: none;
  padding: 0;
  border: none;
  font-size: inherit;
  color: var(--fg-1);
}

/* Light theme tokens */
[data-theme="light"] .hljs-keyword,
[data-theme="light"] .hljs-selector-tag,
[data-theme="light"] .hljs-built_in { color: #d73a49; }

[data-theme="light"] .hljs-string,
[data-theme="light"] .hljs-attr,
[data-theme="light"] .hljs-template-tag { color: #032f62; }

[data-theme="light"] .hljs-number,
[data-theme="light"] .hljs-literal { color: #005cc5; }

[data-theme="light"] .hljs-comment,
[data-theme="light"] .hljs-quote { color: #6a737d; font-style: italic; }

[data-theme="light"] .hljs-title,
[data-theme="light"] .hljs-section,
[data-theme="light"] .hljs-name { color: #6f42c1; }

[data-theme="light"] .hljs-type,
[data-theme="light"] .hljs-class { color: #e36209; }

[data-theme="light"] .hljs-variable,
[data-theme="light"] .hljs-template-variable { color: #24292e; }

[data-theme="light"] .hljs-addition { color: #22863a; background: #f0fff4; }
[data-theme="light"] .hljs-deletion  { color: #b31d28; background: #ffeef0; }

[data-theme="light"] .hljs-meta,
[data-theme="light"] .hljs-doctag { color: #005cc5; }

[data-theme="light"] .hljs-symbol,
[data-theme="light"] .hljs-bullet { color: #e36209; }

[data-theme="light"] .hljs-emphasis  { font-style: italic; }
[data-theme="light"] .hljs-strong    { font-weight: bold; }

/* Dark theme tokens */
[data-theme="dark"] .hljs-keyword,
[data-theme="dark"] .hljs-selector-tag,
[data-theme="dark"] .hljs-built_in { color: #ff7b72; }

[data-theme="dark"] .hljs-string,
[data-theme="dark"] .hljs-attr,
[data-theme="dark"] .hljs-template-tag { color: #a5d6ff; }

[data-theme="dark"] .hljs-number,
[data-theme="dark"] .hljs-literal { color: #79c0ff; }

[data-theme="dark"] .hljs-comment,
[data-theme="dark"] .hljs-quote { color: #8b949e; font-style: italic; }

[data-theme="dark"] .hljs-title,
[data-theme="dark"] .hljs-section,
[data-theme="dark"] .hljs-name { color: #d2a8ff; }

[data-theme="dark"] .hljs-type,
[data-theme="dark"] .hljs-class { color: #ffa657; }

[data-theme="dark"] .hljs-variable,
[data-theme="dark"] .hljs-template-variable { color: #c9d1d9; }

[data-theme="dark"] .hljs-addition { color: #56d364; background: rgba(86,211,100,0.1); }
[data-theme="dark"] .hljs-deletion  { color: #f85149; background: rgba(248,81,73,0.1); }

[data-theme="dark"] .hljs-meta,
[data-theme="dark"] .hljs-doctag { color: #79c0ff; }

[data-theme="dark"] .hljs-symbol,
[data-theme="dark"] .hljs-bullet { color: #ffa657; }

[data-theme="dark"] .hljs-emphasis  { font-style: italic; }
[data-theme="dark"] .hljs-strong    { font-weight: bold; }
