/* polyhelper.ai/research/ — papers and notes. A light reading page between the site's dark-lilac header and footer
   (/chrome.css); on a dark device the whole page is dark. Fonts from /fonts (chrome.css), nothing from other
   addresses, no scripts. Text column about 70 characters; on a desktop the contents stay beside the text. */

:root {
  --blue: #667eea;
  --purple: #764ba2;
  --pink: #f093fb;
  /* text gradient: on the light page the pink end is darkened (#b03cc4, 4.7:1 on the page; #f093fb was 2:1) */
  --grad-text: linear-gradient(135deg, #5a67d8, #764ba2 55%, #b03cc4);
  --bg: #fbfaff;
  --card: #ffffff;
  --text: #1d1a26;
  --muted: #5d5870;
  --line: #e6e1f2;
  --soft: #f4f1fb;
  --link: #5b47c7;
  --link-hover: #8a3fb3;
  --h2: #764ba2;
  --measure: 70ch;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --grad-text: linear-gradient(135deg, #8d9cf2, #b48ee6 55%, #f093fb);
    --bg: #110a1c;
    --card: #170f26;
    --text: #ece8f5;
    --muted: #b3abc6;
    --line: #2e2440;
    --soft: #1d1430;
    --link: #b9a6ff;
    --link-hover: #f3b0fb;
    --h2: #c5b2ff;
  }
}

*, ::before, ::after { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body.research {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.7 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-wrap: break-word;
}
main a { color: var(--link); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent); text-underline-offset: 2px; }
main a:hover { color: var(--link-hover); text-decoration-color: currentColor; }
main :focus-visible { outline: 2px solid var(--link-hover); outline-offset: 3px; border-radius: 3px; }

main { display: block; max-width: calc(var(--measure) + 40px); margin: 0 auto; padding: 28px 20px 56px; }

h1, h2, h3, h4 { font-family: Montserrat, system-ui, sans-serif; line-height: 1.3; }
h1.title {
  font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.6rem); font-weight: 800; margin: .2em 0 .45em;
  background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.paper h1:not(.title) { font-size: 1.45rem; margin: 2.2em 0 .6em; }
.paper h2, .note h2, .shelves h2 { font-size: 1.4rem; margin: 2.1em 0 .6em; color: var(--h2); }
.paper h3, .note h3 { font-size: 1.15rem; margin: 1.8em 0 .5em; }
.paper h4 { font-size: 1rem; margin: 1.5em 0 .4em; }
h2[id], h3[id], h1[id], p[id] { scroll-margin-top: 16px; }

/* under the title and author */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 18px 0 10px; }
main .btn-pdf {
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 24px; border-radius: 999px;
  background: linear-gradient(135deg, #5a67d8, var(--purple)); color: #fff; font: 700 1rem/1 Montserrat, system-ui, sans-serif; text-decoration: none;
  box-shadow: 0 6px 18px rgb(118 75 162 / .28);
}
main .btn-pdf:hover { color: #fff; filter: brightness(1.07); }
.btn-pdf::before { content: "↓"; margin-right: 10px; font-weight: 800; }
.pdf-size { color: var(--muted); font-size: .9rem; }
.ids { margin: 0 0 10px; color: var(--muted); font-size: .95rem; }

/* topic tags */
.tags { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 0 0 18px; padding: 0; }
.tags a, .tags span {
  display: inline-flex; align-items: center; padding: 2px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--soft); color: var(--muted); font: 600 .8rem/1.6 Montserrat, system-ui, sans-serif; text-decoration: none;
}
.tags a { min-height: 32px; }
.tags a:hover { color: var(--link); border-color: var(--link); }

/* the table of contents: folded on a phone, a sticky side column on a desktop */
.toc { margin: 8px 0 28px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); scroll-margin-top: 12px; }
.toc summary { display: flex; align-items: center; gap: 6px; min-height: 48px; cursor: pointer; padding: 0 16px; font: 700 1rem/1.4 Montserrat, system-ui, sans-serif; }
.toc summary span { color: var(--muted); font-weight: 500; font-size: .9rem; }
.toc ol { margin: 0; padding: 0 16px 14px 34px; font-size: .95rem; line-height: 1.5; }
.toc ol.plain, .toc ol.plain ol { list-style: none; padding-left: 16px; }
.toc ol ol { padding: 2px 0 4px 18px; list-style: circle; font-size: .92rem; }
.toc ol.plain ol { padding-left: 14px; }
.toc li { margin: 0; }
.toc a { display: block; padding: 5px 0; text-decoration: none; }
/* the fixed link back to the contents, on a phone */
main .to-toc {
  position: fixed; right: 14px; bottom: 14px; z-index: 4;
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px;
  background: #110a1c; color: #f3f0fa; font: 700 .9rem/1 Montserrat, system-ui, sans-serif; text-decoration: none;
  box-shadow: 0 6px 18px rgb(17 10 28 / .35); border: 1px solid rgb(185 166 255 / .35);
}
main .to-toc:hover { color: #fff; }
/* it appears once the reader has scrolled past the top (scroll-driven, no script; always shown where unsupported) */
@supports (animation-timeline: scroll()) {
  main .to-toc { animation: to-toc-in linear both; animation-timeline: scroll(root); animation-range: 0 900px; }
  @keyframes to-toc-in { 0%, 70% { opacity: 0; visibility: hidden; } 100% { opacity: 1; visibility: visible; } }
}
/* "↑ Contents" opens the folded list: no script, the list is the link's :target */
.toc:target details::details-content { content-visibility: visible; display: block; }
.toc:target summary { color: var(--link); }

@media (min-width: 1100px) {
  main:has(.has-toc) { max-width: calc(var(--measure) + 360px); }
  .paper.has-toc { display: grid; grid-template-columns: 260px minmax(0, var(--measure)); column-gap: 56px; }
  .paper.has-toc > .p-head { grid-column: 2; }
  .paper.has-toc > .p-grid { display: contents; }
  .paper.has-toc .toc {
    grid-column: 1; align-self: start; position: sticky; top: 16px; margin: 6px 0 0;
    max-height: calc(100vh - 32px); overflow: auto; background: transparent; border: 0; border-right: 1px solid var(--line); border-radius: 0;
  }
  .paper.has-toc .toc summary { pointer-events: none; padding: 0 12px 0 0; min-height: 36px; list-style: none; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
  .paper.has-toc .toc summary::-webkit-details-marker { display: none; }
  .paper.has-toc .toc details::details-content { content-visibility: visible; display: block; }
  .paper.has-toc .toc ol { padding: 0 12px 12px 18px; font-size: .88rem; }
  .paper.has-toc .toc ol.plain { padding-left: 0; }
  .paper.has-toc .toc a { padding: 4px 0; color: var(--muted); }
  .paper.has-toc .toc a:hover { color: var(--link); }
  .paper.has-toc .p-body { grid-column: 2; min-width: 0; }
  main .to-toc { display: none; }
}

/* the paper's text */
.paper img, .note img { display: block; max-width: 100%; height: auto !important; margin: 0 auto; }
@media (prefers-color-scheme: dark) {
  /* figures drawn black on transparent stay readable: a white card under each */
  .paper img { background: #fff; padding: 6px; border-radius: 6px; }
}
.paper math[display="block"] { display: block; overflow-x: auto; overflow-y: hidden; margin: 1em 0; font-size: 1.1em; }
.paper math { font-family: "STIX Two Math", "Cambria Math", "Latin Modern Math", math; }
.paper table { border-collapse: collapse; display: block; max-width: 100%; overflow-x: auto; margin: 20px 0; font-size: .9rem; line-height: 1.5; }
.paper th, .paper td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; vertical-align: top; }
.paper th { background: var(--soft); }
.paper blockquote, .note blockquote { margin: 18px 0; padding: 2px 0 2px 16px; border-left: 3px solid var(--blue); color: var(--muted); }
.paper code, .note code { background: var(--soft); padding: 1px 5px; border-radius: 4px; font-size: .88em; }
.paper pre, .note pre { background: var(--soft); padding: 12px 14px; overflow-x: auto; border-radius: 8px; line-height: 1.45; }
.paper pre code { background: none; padding: 0; }
.paper hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.paper figure { margin: 24px 0; }
.paper figcaption { color: var(--muted); font-size: .9rem; }
.paper .footnotes { font-size: .92rem; }
.paper ul, .paper ol, .note ul, .note ol { padding-left: 1.4em; }

/* How to cite, related */
.cite .apa { padding-left: 1.5em; text-indent: -1.5em; }
.cite pre { font-size: .82rem; }
.related .rel { list-style: none; padding: 0; margin: 0; }
.related .rel li { border-top: 1px solid var(--line); }
.related .rel a { display: flex; align-items: center; min-height: 44px; padding: 8px 0 0; font-weight: 600; text-decoration: none; }
.related .rel span { display: block; padding: 0 0 8px; color: var(--muted); font-size: .88rem; }
.app-line { margin: 36px 0 0; color: var(--muted); font-size: .92rem; }

.tr-note { font-size: .9rem; color: var(--muted); margin: -4px 0 16px; }
.r-hero .tr-note { color: #b9b0cf; margin: 10px 0 0; }
.r-hero .tr-note a { color: #cdbfff; }

.kicker { margin: 0; font: 700 .85rem/1.4 Montserrat, system-ui, sans-serif; text-transform: uppercase; letter-spacing: .06em; }
.kicker a { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }
.byline { color: var(--muted); margin: 0 0 14px; }
.back { margin: 48px 0 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .95rem; }

/* the index */
main.shelves { max-width: 1180px; padding-top: 0; }
/* the dark-lilac band under the header, full width without a horizontal scroll (box-shadow + clip-path) */
.r-hero {
  margin: 0 0 8px; padding: 30px 0 34px; color: #e6e0f3;
  background: #110a1c; box-shadow: 0 0 0 100vmax #110a1c; clip-path: inset(0 -100vmax);
}
.r-hero h1.title { margin-top: 0; background: linear-gradient(135deg, #8d9cf2, #b48ee6 55%, #f093fb); -webkit-background-clip: text; background-clip: text; }
.r-hero .lead { max-width: 68ch; font-size: 1.08rem; color: #c9c1dc; margin: 0; }
.shelves h2 { margin: 1.6em 0 .7em; }
.cards { list-style: none; margin: 0; padding: 0; }
.cards.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 16px; }
.card {
  position: relative; display: flex; flex-direction: column; padding: 18px 20px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; transition: border-color .2s, box-shadow .2s;
}
.card:hover { border-color: color-mix(in srgb, var(--link) 45%, var(--line)); box-shadow: 0 8px 24px rgb(118 75 162 / .12); }
.card h3 { margin: 0 0 8px; font-size: 1.08rem; line-height: 1.35; }
.card h3 a { display: block; min-height: 44px; color: var(--text); text-decoration: none; }
.card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: 14px; }   /* the whole card is the link */
.card h3 a:focus-visible { outline: none; }
.card:has(h3 a:focus-visible) { outline: 2px solid var(--link-hover); outline-offset: 2px; }
.card .meta { margin: 0 0 8px; color: var(--muted); font-size: .85rem; }
.card .kind { font: 700 .75rem/1 Montserrat, system-ui, sans-serif; text-transform: uppercase; letter-spacing: .06em; color: var(--h2); }
.card .ab { margin: 0 0 12px; font-size: .95rem; line-height: 1.55; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.card .tags { margin: auto 0 0; }
.card.feature { padding: 0; overflow: hidden; grid-column: 1 / -1; }
.card.feature img { width: 100%; height: auto; display: block; aspect-ratio: 1200 / 630; }
.card.feature > :not(img) { margin-left: 20px; margin-right: 20px; }
.card.feature .meta { margin-top: 16px; }
.card.feature h3 { font-size: 1.35rem; }
.card.feature .tags { margin-bottom: 16px; }
@media (min-width: 900px) {
  .latest .cards.grid { grid-template-columns: 2fr 1fr; grid-template-rows: auto auto; }
  .card.feature { grid-column: 1; grid-row: 1 / span 2; }
}
.shelf-sub { color: var(--muted); margin: -4px 0 14px; }
.feed { margin: 40px 0 0; color: var(--muted); font-size: .92rem; }

/* topic filter: no script; each chip targets an empty anchor, and the anchor hides the cards of other topics */
.shelf { scroll-margin-top: 8px; }
.tgt { display: block; position: relative; top: -8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 32px 0 0; }
main .chips a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); text-decoration: none;
  font: 600 .9rem/1.2 Montserrat, system-ui, sans-serif;
}
main .chips a:hover { border-color: var(--link); color: var(--link); }
.shelf:not(:has(.tgt:target)) .chips a.all,
#t-oversight:target ~ .chips a[data-k="oversight"], #t-evaluation:target ~ .chips a[data-k="evaluation"],
#t-agents:target ~ .chips a[data-k="agents"], #t-law:target ~ .chips a[data-k="law"],
#t-commerce:target ~ .chips a[data-k="commerce"], #t-metrics:target ~ .chips a[data-k="metrics"] {
  background: linear-gradient(135deg, #5a67d8, var(--purple)); border-color: transparent; color: #fff;
}
#t-oversight:target ~ section .card:not([data-t~="oversight"]),
#t-evaluation:target ~ section .card:not([data-t~="evaluation"]),
#t-agents:target ~ section .card:not([data-t~="agents"]),
#t-law:target ~ section .card:not([data-t~="law"]),
#t-commerce:target ~ section .card:not([data-t~="commerce"]),
#t-metrics:target ~ section .card:not([data-t~="metrics"]) { display: none; }
#t-oversight:target ~ section:not(:has(.card[data-t~="oversight"])),
#t-evaluation:target ~ section:not(:has(.card[data-t~="evaluation"])),
#t-agents:target ~ section:not(:has(.card[data-t~="agents"])),
#t-law:target ~ section:not(:has(.card[data-t~="law"])),
#t-commerce:target ~ section:not(:has(.card[data-t~="commerce"])),
#t-metrics:target ~ section:not(:has(.card[data-t~="metrics"])) { display: none; }

@media (max-width: 560px) {
  body.research { font-size: 16px; }
  main { padding: 16px 16px 72px; }
  .r-hero { padding: 22px 0 24px; }
  main .btn-pdf { width: 100%; justify-content: center; }
  .card { padding: 16px; }
}
@media print {
  .toc, .actions, .back, .to-toc, .tags, .related, .app-line { display: none; }
  body.research { background: #fff; color: #000; }
  h1.title { color: #000; background: none; }
}
/* room under the footer's last line for the fixed "↑ Contents" link */
@media (max-width: 1099px) { body.research:has(.to-toc) .site-footer { padding-bottom: 84px; } }
