/* Paper-friendly reading typography + per-paper header card.
 *
 * Loaded via ``extra_css: [stylesheets/extra.css]`` in ``mkdocs.yml``.
 *
 * Goals:
 *   1. Body prose reads like a research paper — serif, narrower column,
 *      generous line-height.
 *   2. The ``<div class="paper-header">…</div>`` block emitted by
 *      ``scripts/gen_docs.py`` renders as a clean bordered card instead of
 *      a Material admonition.
 *   3. The ``<div class="grid cards">…</div>`` landing page gets proper
 *      vertical rhythm between cards.
 *   4. MathJax output gets enough breathing room that display equations
 *      don't crash into surrounding paragraphs.
 */

/* -------------------------------------------------------------------- */
/* Typography                                                            */
/* -------------------------------------------------------------------- */

/* Body prose in a serif font — closer to a real research paper than the
 * default Inter. Source Serif Pro / Charter are widely-installed open
 * fonts; the fallback chain keeps it readable on any machine. */
:root {
  --md-text-font: "Source Serif Pro", "Source Serif 4", Charter,
    "Iowan Old Style", "Apple Garamond", Baskerville, "Times New Roman",
    "Droid Serif", Times, "Source Serif Pro", serif;
  --md-typeset-font-size: 0.82rem;
}

/* Line height for body prose. The width constraint that used to live here
 * (max-width: 760px) was removed on 2026-11-30: the reader asked for the
 * full content column, so prose now uses the width the theme gives it. */
.md-typeset {
  line-height: 1.7;
}

/* Keep headings + UI chrome on the original sans font so the sidebar /
 * nav doesn't fight the serif body. */
.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4,
.md-typeset h5,
.md-typeset h6,
.md-header,
.md-tabs {
  font-family: var(--md-font-fallback);
}

/* Subtle separator under H1 — gives the per-paper pages a stronger
 * visual break between title and body. */
.md-typeset h1 {
  border-bottom: 1px solid var(--md-default-fg-color--lightest);
  padding-bottom: 0.4rem;
  margin-bottom: 1.4rem;
}

/* -------------------------------------------------------------------- */
/* Paper-header card                                                     */
/* -------------------------------------------------------------------- */

/* The ``<div class="paper-header" markdown>…</div>`` block that
 * ``gen_docs.py`` emits in place of the old ``!!! note "Metadata"``
 * admonition. Icon + key/value rows in a single bordered card. */
.paper-header {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0 0 1.6rem 0;
  padding: 1rem 1.2rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-left: 3px solid var(--md-accent-fg-color);
  border-radius: 4px;
  background: var(--md-code-bg-color);
  font-size: 0.82rem;
}
/* Every header row is ONE line: icon, key, value.
 *
 * The rows used to be grid items with ``display: contents``, which
 * handed the grid three items per row (the icon, the key and the
 * value) while the grid has two columns. The grid then placed them
 * in a staircase: the value of one row landed under the icon of the
 * next and the key of the next row landed in the value column. Flex
 * keeps a row on one line; the key's minimum width keeps the values
 * in a column of their own.
 */
.paper-header > p {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}
.paper-header strong {
  color: var(--md-default-fg-color--light);
  font-weight: 600;
  white-space: nowrap;
  min-width: 4.6rem;
}
.paper-header a {
  color: var(--md-accent-fg-color);
}

/* Material icon column gets tighter spacing + dim color. */
.paper-header .twemoji,
.paper-header .material-icon {
  flex: 0 0 auto;
  color: var(--md-default-fg-color--light);
}

/* Inline category chips (e.g. ``\`cs.AI\```). */
.paper-header code {
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  background: var(--md-default-bg-color);
  font-size: 0.78rem;
}

/* -------------------------------------------------------------------- */
/* Landing-page cards                                                    */
/* -------------------------------------------------------------------- */

/* mkdocs-material's "grid cards" pattern: each ``- …`` becomes a card.
 * The plugin's default already works, but tighten vertical rhythm and
 * give cards a thin border so they read as discrete items. */
.grid.cards > ul {
  grid-gap: 0.8rem;
}
.grid.cards > ul > li {
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 4px;
  padding: 0.8rem 1rem;
  transition: border-color 120ms ease;
}
.grid.cards > ul > li:hover {
  border-color: var(--md-accent-fg-color);
}
.grid.cards > ul > li > hr {
  margin: 0.4rem 0;
}

/* -------------------------------------------------------------------- */
/* Math                                                                  */
/* -------------------------------------------------------------------- */

/* Display equations: a touch of vertical space so \[...\] doesn't crash
 * into the next paragraph. */
mjx-container[display="true"] {
  margin: 1rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Inline math: tighten the spacing around the baseline. */
mjx-container:not([display="true"]) {
  margin: 0 0.1rem;
}

/* -------------------------------------------------------------------- */
/* Figures                                                               */
/* -------------------------------------------------------------------- */

/* Marker-pdf outputs inline images. Add a hairline border so the
 * figures don't bleed into the page on dark backgrounds. */
.md-typeset img {
  border-radius: 2px;
}

/* When the .md body has a heading + image sequence (figure-like layout),
 * give the image a touch of vertical breathing room. */
.md-typeset p > img:only-child {
  display: block;
  margin: 0.6rem auto;
}

/* -------------------------------------------------------------------- */
/* Cookie consent banner (Phase 5)                                       */
/* -------------------------------------------------------------------- */

/* The fixed-bottom banner injected by ``overrides/main.html``. Two
 * buttons (Accept / Reject non-essential) gated on a per-user
 * localStorage key (``dr-consent``). The banner element has
 * ``role="dialog"`` and ``aria-live="polite"`` for accessibility.
 *
 * Colours pull from the material theme CSS variables so the banner
 * stays in sync with light / dark palette switches — no hardcoded
 * background colours here. */
.cc-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--md-default-bg-color, #fff);
  border-top: 3px solid var(--md-primary-fg-color, #008080);
  padding: 1rem 1.5rem;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.18);
  font-size: 0.85rem;
  line-height: 1.45;
}
.cc-banner__inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}
.cc-banner__copy {
  margin: 0;
  flex: 1 1 60%;
  min-width: 250px;
  color: var(--md-default-fg-color, #222);
}
.cc-banner__actions {
  display: flex;
  gap: 0.5rem;
  flex: 0 0 auto;
}
.cc-banner__btn {
  border: 0;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  font-family: var(--md-text-font, inherit);
}
.cc-banner__btn--accept {
  background: var(--md-primary-fg-color, #008080);
  color: var(--md-primary-bg-color, #fff);
}
.cc-banner__btn--reject {
  background: transparent;
  color: var(--md-default-fg-color, #222);
  border: 1px solid var(--md-default-fg-color--light, #888);
}
@media (max-width: 600px) {
  .cc-banner__inner {
    flex-direction: column;
    align-items: stretch;
  }
  .cc-banner__actions {
    justify-content: stretch;
  }
  .cc-banner__btn {
    flex: 1 1 0;
  }
}

/* The "Manage cookies" pill that lives at the bottom-left corner
 * after the user has made a choice. GDPR / CCPA both require
 * giving users a persistent way to revisit their consent; this
 * is the canonical pattern. Hidden until consent has been
 * recorded (the JS in ``overrides/main.html`` toggles display). */
.cc-pill {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  z-index: 999;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--md-default-fg-color--light, #888);
  border-radius: 50%;
  background: var(--md-default-bg-color, #fff);
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  display: none;
  padding: 0;
  line-height: 1;
}
.cc-pill:hover {
  border-color: var(--md-primary-fg-color, #008080);
  transform: scale(1.05);
  transition: transform 120ms ease, border-color 120ms ease;
}


/* -------------------------------------------------------------------- */
/* Header navigation (2026-11-24)                                        */
/* -------------------------------------------------------------------- */

/* The site's own pages — Home, About, Contact, Privacy, Terms,
 * Disclaimer — live in the header row, right after the site name. The
 * row is rendered by ``overrides/partials/header.html``; the legal
 * pages left the sidebar's "Site" section on the same day (the
 * reader's instruction).
 *
 * The header row is a flex box: [logo] [title] [nav] [palette] [search].
 * Material gives the title ``flex-grow: 1``, which would push the nav
 * row to the far right, away from the site name. The title column is
 * therefore sized to the site name ("Daily Reading"), which is the
 * fixed text the header shows from now on.
 *
 * The title is FIXED. Material's scroll-spy toggles the class
 * ``.md-header__title--active`` on ``.md-header__title``: when the
 * page's ``h1`` comes into view, the theme's CSS hides the site name
 * and reveals the SECOND title topic — the running page title — in its
 * place. That second topic was removed from
 * ``overrides/partials/header.html`` (the reader's decision,
 * 2026-11-29: article titles are far too long for the header), so
 * there is nothing left to reveal; the rule below keeps the one
 * remaining topic visible regardless, which is what makes the fixed
 * title survive the scroll instead of going blank.
 *
 * The nav row is hidden below 60em: Material replaces the header with
 * the drawer at that width, and six links do not fit beside the site
 * name on a phone. A footer row (``.dr-footnav``) used to repeat the
 * same six links there; the reader removed it on 2026-11-29, so the
 * header row is now the only place the site's own pages are linked
 * from. */

/* Keep the fixed site name visible when the scroll-spy marks the
 * header title as active. This is the same selector Material uses and
 * the same specificity — but this stylesheet is emitted after the
 * theme's ``main.css``, so this rule wins. */
.md-header__title--active .md-header__topic {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
  z-index: 0;
}

.dr-headnav {
  display: none;
}
@media screen and (min-width: 60em) {
  .md-header__title {
    flex-grow: 0;
    flex-shrink: 0;
    width: 7.5rem;
  }
  .md-header__ellipsis {
    position: static;
  }
  .dr-headnav {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-left: 0.6rem;
    margin-right: auto;
    font-size: 0.72rem;
    line-height: 2.4rem;
    white-space: nowrap;
  }
  .dr-headnav__link {
    color: var(--md-primary-bg-color);
    opacity: 0.85;
    text-decoration: none;
  }
  .dr-headnav__link:hover,
  .dr-headnav__link:focus-visible {
    opacity: 1;
    text-decoration: underline;
  }
}

/* -------------------------------------------------------------------- */
/* Phase 2 — AdSense E-E-A-T enrichment blocks                           */
/* -------------------------------------------------------------------- */

/* The ``<div class="adsense-disclosure" markdown>`` banner emitted by
 * ``gen_docs.py::emit_records()`` immediately after the frontmatter.
 * A muted top-of-article callout with a thin border, telling readers
 * that the prose below is auto-converted from the paper's PDF via
 * marker-pdf. Google AdSense's E-E-A-T review expects this kind of
 * transparency on every AI-converted page. */
.adsense-disclosure {
  margin: 0 0 1.4rem 0;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-left: 3px solid var(--md-default-fg-color--light);
  border-radius: 4px;
  background: var(--md-code-bg-color);
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--md-default-fg-color--light);
}
.adsense-disclosure > p {
  margin: 0;
}
.adsense-disclosure strong {
  color: var(--md-default-fg-color);
  font-weight: 600;
}
.adsense-disclosure a {
  color: var(--md-accent-fg-color);
}

/* The ``<div class="tldr-card" markdown>`` block emitted right after
 * the disclosure banner. A smaller accent-tinted card carrying the
 * 200-300 char abstract excerpt that helps readers decide whether to
 * read further. Sits flush against the disclosure above and the
 * paper-header card below. */
.tldr-card {
  margin: 0 0 1.4rem 0;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-left: 3px solid var(--md-accent-fg-color);
  border-radius: 4px;
  background: var(--md-default-bg-color);
  font-size: 0.86rem;
  line-height: 1.6;
}
.tldr-card > p {
  margin: 0.4rem 0 0 0;
}
.tldr-card > p:first-child {
  margin-top: 0;
}
.tldr-card strong {
  color: var(--md-accent-fg-color);
  font-weight: 600;
}

/* The ``<div class="cite-block" markdown>`` block carries a BibTeX
 * citation. Monospace on a slightly inset light-grey background so
 * visitors can copy the entry into their reference manager
 * without losing line breaks. */
.cite-block {
  margin: 0 0 1.6rem 0;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 4px;
  background: var(--md-code-bg-color);
  font-size: 0.78rem;
}
.cite-block > p {
  margin: 0.4rem 0 0.6rem 0;
}
.cite-block > p:first-child {
  margin-top: 0;
}
.cite-block strong {
  color: var(--md-default-fg-color);
  font-weight: 600;
}
.cite-block pre {
  margin: 0;
  padding: 0.6rem 0.8rem;
  border-radius: 3px;
  background: var(--md-default-bg-color);
  overflow-x: auto;
  font-size: 0.78rem;
  line-height: 1.5;
}
.cite-block code {
  font-family: var(--md-code-font);
  white-space: pre;
}

/* JSON-LD ``<script type="application/ld+json">`` blocks need no
 * styling — they're invisible by spec. */

/* Narrow-viewport tuning: at small widths the cards stack but the
 * inner padding and font-size should shrink to avoid horizontal
 * scrollbars inside the disclosure / TL;DR / cite blocks. */
@media (max-width: 600px) {
  .adsense-disclosure,
  .tldr-card,
  .cite-block {
    padding: 0.7rem 0.9rem;
    font-size: 0.82rem;
  }
  .cite-block pre {
    font-size: 0.74rem;
  }
}
