/* ============================================
   app.css — Page and component styles (Paper Firehose UI)
   ============================================

   Loaded by base.html AFTER tokens.css: every value here is a
   var(--token) defined there.

   MOBILE FIRST: the rules without conditions ARE the phone layout.
   Wider screens only gain things (inline navigation, two columns),
   switched on by `@container app (min-width: 600px)` blocks.

   Why container queries instead of media queries? A media query asks
   "how wide is the browser window?"; a container query asks "how wide
   is the element I sit in?". base.html marks <div class="app"> as the
   container, so a component adapts to the space it actually gets.

   Sections, in page order:
     base elements · app bar · page header · buttons · segmented control ·
     form fields · checkboxes/chips/slider · disclosure · notices and run
     status · topic list · paper list · history filters · pager ·
     link list · empty state · landing page (worked example) ·
     results page (tools, "More", carousel)
*/

/* ---------- Base elements ---------- */

/* Make width/height include padding and border — far easier to size */
*, *::before, *::after { box-sizing: border-box; }
/* Stop iPhones from enlarging text on their own in landscape */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 400 16px/24px var(--font-sans);
    -webkit-font-smoothing: antialiased;
}

/* The page shell: the container for the container queries below */
.app { container: app / inline-size; }
/* The single page column: centred, at most --size-content wide */
.page {
    max-width: var(--size-content);
    margin: 0 auto;
    padding: var(--space-4) var(--space-4) var(--space-12);
}
/* A narrower column for short forms (sign in) */
.page-narrow { max-width: 440px; }

h1 { font: 700 28px/34px var(--font-sans); letter-spacing: -0.02em; margin: var(--space-2) 0 var(--space-6); }
h2 { font: 600 17px/24px var(--font-sans); margin: var(--space-8) 0 var(--space-3); }
p { margin: 0 0 var(--space-4); }
ul, ol { margin: 0 0 var(--space-4); padding-left: 1.25em; }
li + li { margin-top: var(--space-2); }
.muted { color: var(--ink-muted); }
.text-small { font: 400 14px/20px var(--font-sans); }

/* Links are underlined (colour alone is not enough to tell them apart),
   with a light underline that darkens on hover */
a {
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    text-decoration-color: var(--control-border);
}
a:hover { text-decoration-color: currentColor; }

code {
    font: 400 14px/20px var(--font-mono);
    background: var(--paper-sunken);
    border-radius: var(--radius-sm);
    padding: 1px var(--space-1);
    overflow-wrap: anywhere;   /* long regexes wrap instead of overflowing */
}

/* Keyboard focus ring. :focus-visible shows it for keyboard users but
   not after a mouse click or tap. Never remove it. */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* The `hidden` attribute must always win. By default it only means
   "display: none" at the browser's lowest priority, so any class that
   sets a display of its own (.btn is inline-flex) would show a hidden
   element again. */
[hidden] { display: none !important; }

/* Hidden on screen, still read by screen readers (e.g. a search label) */
.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- App bar (top navigation) ----------
   Phone: brand + a "Menu" <details> disclosure that opens a full-width
   list. From 600px: the links sit inline and the Menu is hidden.
   base.html renders the links in both places. */
.appbar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: var(--size-appbar);
    padding: 0 var(--space-4);
    border-bottom: 1px solid var(--rule);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font: 600 17px/23px var(--font-sans);
    letter-spacing: -0.01em;
    color: var(--ink);
    text-decoration: none;
}
/* The logo, an inline SVG in base.html (a faucet with one drop). Its
   shapes carry classes instead of colours, so the theme paints them:
   lines and solids in ink, the drop in the accent colour. */
.brand-mark { flex: none; width: 24px; height: 24px; }
.brand-mark .mark-line { fill: none; stroke: var(--ink); }
.brand-mark .mark-solid { fill: var(--ink); }
.brand-mark .mark-drop { fill: var(--accent); }
.appbar-links { display: none; }
.appbar-links a,
.appbar-menu nav a { color: var(--ink-muted); text-decoration: none; }
.appbar-links a:hover,
.appbar-menu nav a:hover { color: var(--ink); }
/* The current section (aria-current="page") gets the red-pencil underline */
.appbar-links a[aria-current="page"],
.appbar-menu nav a[aria-current="page"] {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 6px;
}
.appbar-menu summary {
    display: inline-flex;
    align-items: center;
    min-height: var(--size-tap);
    padding: 0 var(--space-3);
    margin-right: calc(-1 * var(--space-3));
    font: 600 16px/20px var(--font-sans);
    list-style: none;          /* hide the default triangle (Firefox) */
    cursor: pointer;
}
.appbar-menu summary::-webkit-details-marker { display: none; }  /* ...and Safari */
.appbar-menu[open] summary { color: var(--ink-muted); }
.appbar-menu nav {
    position: absolute;
    z-index: 10;
    top: 100%;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    padding: var(--space-2) var(--space-4) var(--space-4);
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
}
.appbar-menu nav a { display: flex; align-items: center; min-height: var(--size-tap); }
@container app (min-width: 600px) {
    .appbar { padding: 0 var(--space-6); }
    .appbar-links { display: flex; align-items: center; gap: var(--space-6); }
    .appbar-menu { display: none; }
}

/* ---------- Page header ---------- */
.back {
    display: inline-flex;
    align-items: center;
    min-height: var(--size-tap);   /* doubles as a comfortable tap target */
    font: 400 14px/20px var(--font-sans);
    color: var(--ink-muted);
    text-decoration: none;
}
.back:hover { color: var(--ink); }
.page-head {
    display: flex;
    flex-wrap: wrap;               /* the action wraps under the title on phones */
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3) var(--space-4);
    margin: var(--space-2) 0 var(--space-6);
}
.page-head h1 { margin: 0; }

/* ---------- Buttons ----------
   .btn + one kind: primary (ink fill, one per page), secondary
   (outlined), quiet (an underlined word), danger (outlined, red text).
   Works on <button> and <a>. */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--size-tap);
    margin: 0;
    padding: 0 var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--ink);
    font: 600 16px/20px var(--font-sans);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn-primary:hover { opacity: 0.88; }
.btn-secondary { background: var(--paper-raised); border-color: var(--control-border); }
.btn-secondary:hover { background: var(--paper-sunken); }
.btn-quiet {
    padding: 0 var(--space-2);
    font-weight: 400;
    text-decoration: underline;
    text-decoration-color: var(--control-border);
    text-underline-offset: 3px;
}
.btn-quiet:hover { text-decoration-color: currentColor; }
.btn-danger { background: var(--paper-raised); border-color: var(--control-border); color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn:disabled,
.btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
/* Full width on phones (easy to hit with a thumb), natural width from 600px */
.btn-block { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
/* A <form> wrapping one button inside a row: let its button join the row */
.button-row form { display: contents; }
@container app (min-width: 600px) {
    .btn-block { width: auto; }
}

/* ---------- Segmented control (switch between views) ---------- */
.segmented {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--control-border);
    border-radius: var(--radius-md);
    background: var(--paper-raised);
}
.segmented a,
.segmented button {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 var(--space-3);
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink-muted);
    font: 600 14px/20px var(--font-sans);
    text-decoration: none;
    cursor: pointer;
}
.segmented [aria-current="true"],
.segmented [aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }

/* ---------- Form fields ---------- */
.field { margin: 0 0 var(--space-6); }
/* A field's label sits above its control — except a checkbox row
   (label.check), which keeps its own one-line layout */
.field > label:not(.check),
.field-label {
    display: block;
    margin: 0 0 var(--space-2);
    font: 600 14px/20px var(--font-sans);
}
.field-optional { font-weight: 400; color: var(--ink-muted); }
.field-help { margin: var(--space-2) 0 0; font: 400 14px/20px var(--font-sans); color: var(--ink-muted); }
.field-error { margin: var(--space-2) 0 0; font: 600 14px/20px var(--font-sans); color: var(--danger); }

/* Native controls are styled directly, no class needed. 16px text: iOS
   zooms the whole page into any input whose text is smaller. */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="number"],
select,
textarea {
    width: 100%;
    min-height: var(--size-tap);
    margin: 0;
    padding: 9px var(--space-3);
    border: 1px solid var(--control-border);
    border-radius: var(--radius-md);
    background-color: var(--paper-raised);
    color: var(--ink);
    font: 400 16px/24px var(--font-sans);
    -webkit-appearance: none;   /* drop the platform's own look (inner shadows, gradients) */
    appearance: none;
}
textarea { font-family: var(--font-mono); resize: vertical; }
/* appearance: none also removes the select's arrow; draw a small chevron
   from two diagonal gradients so it can use the theme's colour */
select {
    padding-right: 40px;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%),
        linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
    background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}
input:focus,
select:focus,
textarea:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
::placeholder { color: var(--ink-muted); opacity: 1; }
[aria-invalid="true"] { border-color: var(--danger); }

/* A group of fields under its own h2, divided from the previous group
   by a hairline. The first <section> of this kind among its siblings
   needs no line above it (:first-of-type counts elements of the same
   tag, so use a <div class="form-section"> to keep the line). */
.form-section { margin-top: var(--space-8); padding-top: var(--space-6); border-top: 1px solid var(--rule); }
.form-section:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.form-section > h2 { margin-top: 0; }

/* A sub-heading inside a form section (settings: "Run it on your own
   computer"). Smaller than the section's h2. */
.subhead { margin: var(--space-6) 0 var(--space-2); font: 600 16px/24px var(--font-sans); }
/* A command to copy, on a line of its own. Long commands wrap (the
   base `code` rule allows a break anywhere) instead of pushing the page
   wider than a phone. */
.command { display: block; margin-top: var(--space-1); padding: var(--space-2) var(--space-3); }

/* ---------- Checkboxes, chips, slider ---------- */

/* A whole row is the tap target: the <label> wraps the checkbox */
.check {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: var(--size-tap);
    font: 400 16px/22px var(--font-sans);
    cursor: pointer;
}
.check input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--ink); }
.check-small { gap: var(--space-2); font: 400 14px/20px var(--font-sans); color: var(--ink-muted); }
.check-small input { width: 18px; height: 18px; }
.check-group { min-width: 0; margin: 0 0 var(--space-6); padding: 0; border: 0; }
.check-group > legend { margin: 0 0 var(--space-1); padding: 0; font: 600 14px/20px var(--font-sans); }
/* "Select all" row above a group's feeds: same row as a feed, in the
   muted ink, so it reads as a control and not as one more journal */
.check-all { color: var(--ink-muted); }
/* One column on phones, two from 600px */
.check-list { display: grid; grid-template-columns: minmax(0, 1fr); column-gap: var(--space-6); }
@container app (min-width: 600px) {
    .check-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Chips: the real checkbox is stretched over the pill and made
   invisible (still focusable and clickable); the <span> draws the pill
   and turns ink-filled when the box is checked. */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { position: relative; display: inline-flex; }
.chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.chip span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--size-tap);
    min-height: var(--size-tap);
    padding: 0 var(--space-3);
    border: 1px solid var(--control-border);
    border-radius: var(--radius-pill);
    background: var(--paper-raised);
    font: 600 14px/20px var(--font-sans);
}
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.chip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.range { display: flex; align-items: center; gap: var(--space-4); min-height: var(--size-tap); }
.range input[type="range"] { flex: 1; min-width: 0; margin: 0; accent-color: var(--ink); }
.range output { min-width: 4ch; text-align: right; font: 600 16px/24px var(--font-mono); }

/* ---------- Disclosure ("+ Filters", "+ Edit the regex by hand") ----------
   A native <details>: the browser opens and closes it, no JavaScript. */
.disclosure > summary,
.filters-more > summary {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--size-tap);
    list-style: none;
    cursor: pointer;
    font: 400 14px/20px var(--font-sans);
    color: var(--ink-muted);
}
.disclosure > summary::-webkit-details-marker,
.filters-more > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before,
.filters-more > summary::before { content: "+"; width: 1ch; font: 600 16px/20px var(--font-mono); color: var(--ink); }
.disclosure[open] > summary::before,
.filters-more[open] > summary::before { content: "\2212"; }   /* a minus sign */

/* ---------- Notices (flashed messages) and run status ---------- */
.dot { flex: none; width: 8px; height: 8px; border-radius: var(--radius-pill); background: var(--ink-muted); }
.notice {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin: 0 0 var(--space-4);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    background: var(--paper-raised);
}
.notice .dot { margin-top: 8px; }
.notice-error { border-color: var(--danger); }
.notice-success .dot,
.status-success .dot { background: var(--success); }
.notice-error .dot,
.status-failed .dot { background: var(--danger); }
.status-running .dot { background: var(--warning); }
/* "● Done · 83 matched · 2 h ago" — a block of text with an inline dot,
   so the spaces around the " · " separators stay as written */
.status {
    display: block;
    font: 400 14px/20px var(--font-sans);
    color: var(--ink-muted);
}
.status .dot { display: inline-block; vertical-align: 1px; margin-right: var(--space-2); }
.status strong { font-weight: 600; color: var(--ink); }
.status-failed strong { color: var(--danger); }
/* The running dot pulses — unless the user asked the system for less motion */
@media (prefers-reduced-motion: no-preference) {
    .status-running .dot { animation: pf-pulse 1.6s ease-in-out infinite; }
}
@keyframes pf-pulse { 50% { opacity: 0.3; } }

/* ---------- Topic list ---------- */
.topic-list { margin: 0; padding: 0; list-style: none; border-bottom: 1px solid var(--rule); }
.topic { margin: 0; padding: var(--space-6) 0; border-top: 1px solid var(--rule); }
.topic-name { margin: 0 0 var(--space-1); font: 600 17px/23px var(--font-sans); letter-spacing: -0.01em; }
.topic-desc { margin: 0 0 var(--space-2); color: var(--ink-muted); }
.topic-meta { margin: 0 0 var(--space-2); font: 400 14px/20px var(--font-sans); color: var(--ink-muted); }
.topic .status { margin: 0 0 var(--space-4); }
.topic-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.topic-actions form { display: flex; align-items: center; gap: var(--space-3); margin: 0 var(--space-2) 0 0; }

/* ---------- Paper list (history) ---------- */
.count { margin: 0 0 var(--space-2); font: 400 14px/20px var(--font-sans); color: var(--ink-muted); }
.paper-list { margin: 0; padding: 0; list-style: none; border-bottom: 1px solid var(--rule); }
.paper { margin: 0; padding: var(--space-4) 0; border-top: 1px solid var(--rule); }
.paper-kicker {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 var(--space-2);
    margin: 0 0 var(--space-1);
    font: 400 14px/20px var(--font-sans);
    color: var(--ink-muted);
}
.score { font: 600 14px/20px var(--font-mono); color: var(--ink-muted); }
/* At or above the topic's rank threshold: the red pencil */
.score-high { color: var(--accent); }
.paper-title { margin: 0 0 var(--space-1); font: 600 17px/23px var(--font-sans); letter-spacing: -0.01em; }
.paper-title a { text-decoration: none; }
.paper-title a:hover { text-decoration: underline; }
.paper-authors { margin: 0 0 var(--space-2); font: 400 14px/20px var(--font-sans); color: var(--ink-muted); }
/* Show at most three lines of the abstract, ending in "…" */
.paper-excerpt {
    margin: 0;
    color: var(--ink-muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------- History filters ---------- */
.filters { margin: 0 0 var(--space-4); }
.search { display: flex; gap: var(--space-2); }
.search input { flex: 1; min-width: 0; }
.filters-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); padding: 0 0 var(--space-2); }
.filters-grid .field { margin: 0; }
@container app (min-width: 600px) {
    .filters-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Pager ---------- */
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin: var(--space-6) 0 0;
    font: 400 14px/20px var(--font-sans);
    color: var(--ink-muted);
}

/* ---------- Link list (dashboard) ----------
   Full-width rows that each lead somewhere: a title and one line of
   explanation, divided by hairlines. */
.link-list { margin: 0; padding: 0; list-style: none; border-bottom: 1px solid var(--rule); }
.link-list li { margin: 0; border-top: 1px solid var(--rule); }
.link-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: 64px;
    padding: var(--space-3) 0;
    text-decoration: none;
}
.link-list a::after { content: "\203A"; font-size: 20px; color: var(--ink-muted); }   /* › */
.link-list strong { display: block; font-weight: 600; }
.link-list span { display: block; font: 400 14px/20px var(--font-sans); color: var(--ink-muted); }

/* ---------- Empty state ---------- */
.empty { padding: var(--space-12) 0; border-top: 1px solid var(--rule); }
.empty h2 { margin: 0 0 var(--space-2); font: 600 17px/23px var(--font-sans); letter-spacing: -0.01em; }
.empty p { max-width: 46ch; color: var(--ink-muted); }

/* ---------- Landing page: the worked example ----------
   "Setting up a topic" on home.html: numbered steps, each with a panel
   showing what a user would enter (.demo) and what the app makes of it
   (.match-list: kept/dropped; the ranked papers reuse .paper-list). */

/* The example starts a new part of the page: a hairline and more air */
.steps-head { margin-top: var(--space-12); padding-top: var(--space-8); border-top: 1px solid var(--rule); }
.step { margin: var(--space-8) 0 0; }
.step:last-of-type { margin-bottom: var(--space-6); }
.step-title {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0 0 var(--space-2);
    font: 600 17px/24px var(--font-sans);
}
/* The step number in an ink disc */
.step-number {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-pill);
    background: var(--ink);
    color: var(--on-ink);
    font: 600 14px/20px var(--font-mono);
}
/* A panel that SHOWS a form value. Deliberately not an <input>: it has
   the hairline of a notice, not the darker edge of a control, so it
   does not look like something to type into. */
.demo {
    margin: var(--space-4) 0;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    background: var(--paper-raised);
}
.demo-label { margin: 0 0 var(--space-1); font: 600 14px/20px var(--font-sans); color: var(--ink-muted); }
.demo-value { margin: 0; }
/* One entry of a list of values: never broken across two lines */
.demo-item { white-space: nowrap; }
/* Inside the panel the keywords need no second box around them */
.demo-value code { padding: 0; background: none; font-size: 16px; line-height: 24px; }
/* Kept / Dropped: one row per sample paper, the verdict in a fixed
   column so the titles line up */
.match-list { margin: 0; padding: 0; list-style: none; border-bottom: 1px solid var(--rule); }
.match {
    display: flex;
    align-items: baseline;
    gap: var(--space-3);
    margin: 0;
    padding: var(--space-3) 0;
    border-top: 1px solid var(--rule);
}
.match-mark { flex: none; width: 8ch; font: 600 14px/20px var(--font-sans); }
.match-kept .match-mark { color: var(--success); }
.match-dropped { color: var(--ink-muted); }
.match-why { display: block; font: 400 14px/20px var(--font-sans); }

/* ---------- Results page ----------
   The paper rows are the same as in the history browser (.paper-list
   above). Added here: the tools row, journal headings, "More", and the
   carousel. */

/* Filter box + Carousel button (the row layout is .search) */
.results-tools { margin: var(--space-4) 0; }
/* When the script scrolls a paper to the top of the screen (after the
   carousel is closed), leave this much air above it */
.paper-group .paper { scroll-margin-top: var(--space-2); }
.results-foot { margin-top: var(--space-6); }

/* "By journal": a heading per feed above its papers */
.paper-group-name {
    margin: var(--space-8) 0 var(--space-2);
    font: 600 14px/20px var(--font-sans);
    color: var(--ink-muted);
}
.paper-group:first-of-type .paper-group-name { margin-top: var(--space-4); }

/* "More" / "Less" under a shortened abstract: a quiet underlined word
   with a tap target of full height */
.paper-more {
    display: inline-flex;
    align-items: center;
    min-height: var(--size-tap);
    margin: 0 0 calc(-1 * var(--space-3));
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ink);
    font: 400 14px/20px var(--font-sans);
    text-decoration: underline;
    text-decoration-color: var(--control-border);
    text-underline-offset: 3px;
    cursor: pointer;
}
.paper-more:hover { text-decoration-color: currentColor; }
/* The whole abstract instead of three lines:
   - after "More" was pressed (results.js adds .is-open)
   - always inside the carousel
   - on the results page when JavaScript is off: results.html puts the
     class "js" on <html> with a one-line script, so html:not(.js) means
     "no More button will appear" */
.paper.is-open .paper-excerpt,
.carousel-card .paper-excerpt,
html:not(.js) .paper-group .paper-excerpt {
    display: block;
    -webkit-line-clamp: none;
    line-clamp: none;
    overflow: visible;
}
/* ...and where it was opened to be read, in full-strength ink */
.paper.is-open .paper-excerpt,
.carousel-card .paper-excerpt { color: var(--ink); }

/* The carousel: a <dialog> showing one paper at a time.
   Phone: the whole screen. Wider screens: a centred sheet.
   Three parts stacked in a column — bar (position, Close), the card
   (scrolls if the abstract is long), navigation (Previous / Next). The
   navigation sits at the bottom, where a thumb reaches it. */
.carousel {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;      /* "dynamic" viewport height: right on phones whose address bar slides away */
    max-height: none;
    margin: auto;
    padding: 0;
    border: 0;
    background: var(--paper);
    color: var(--ink);
}
/* Only while open: a closed <dialog> must keep its display: none */
.carousel[open] { display: flex; flex-direction: column; }
/* The dimmed page behind the sheet */
.carousel::backdrop { background: rgb(0 0 0 / 0.55); }
.carousel-bar {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-1) var(--space-2) var(--space-1) var(--space-4);
    border-bottom: 1px solid var(--rule);
    font: 400 14px/20px var(--font-mono);
    color: var(--ink-muted);
}
.carousel-card {
    flex: 1;
    min-height: 0;                   /* lets a flex item shrink so that it scrolls */
    overflow-y: auto;
    overscroll-behavior: contain;    /* scrolling past the end does not move the page behind */
    padding: var(--space-6) var(--space-4);
}
.carousel-card .paper-title { margin-bottom: var(--space-2); font: 600 20px/27px var(--font-sans); }
.carousel-card .paper-authors { margin-bottom: var(--space-4); }
.carousel-nav {
    flex: none;
    display: flex;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    /* keep clear of the home indicator bar on phones without a button */
    padding-bottom: max(var(--space-3), env(safe-area-inset-bottom));
    border-top: 1px solid var(--rule);
}
.carousel-nav .btn { flex: 1; }
/* A media query (not a container query): a dialog is laid out against
   the browser window, so the window's width is the right question */
@media (min-width: 720px) {
    .carousel {
        width: var(--size-content);
        height: min(86vh, 760px);
        border: 1px solid var(--rule);
        border-radius: var(--radius-md);
    }
    .carousel-card { padding: var(--space-8) var(--space-8); }
    .carousel-nav { padding: var(--space-3) var(--space-8); }
    .carousel-bar { padding-left: var(--space-8); padding-right: var(--space-6); }
}
