/* Sugi Predict — app-specific styles (structures, inline-reverse, autocomplete).
   Built on the ported atlas.css design tokens. Loaded after atlas.css. */

/* ---- autocomplete dropdown ---- */
.ac { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; z-index: 50;
      background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm);
      box-shadow: var(--shadow-md); overflow: hidden; display: none; }
.ac.open { display: block; }
.ac a { display: block; padding: 8px 12px; color: var(--fg); text-decoration: none; font-size: 14px; }
.ac a small { color: var(--fg-muted); }
.ac a:hover { background: var(--table-row-hover); }

/* ---- structure depiction (always light bg — molecules render dark-on-white) ---- */
.struct { display: block; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.struct-big { margin-right: 4px; }

/* ---- compound grid (target landscape) ---- */
.compound-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.compound-card { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.compound-card .struct { width: 100%; height: auto; aspect-ratio: 240/148; }
.compound-card-meta { display: flex; align-items: center; gap: 10px; margin: 0; }
.section-title { margin: 28px 0 12px; }
.section-sub { color: var(--fg-muted); font-size: 13px; }

/* ---- stacked datasheet cards: space consecutive .entity-main sections ---- */
.entity-main + .entity-main { margin-top: 1.25rem; }

/* ---- compound header (structure + meta side by side) ---- */
.compound-head { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.compound-head-meta { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.compound-head-meta .entity-title { margin: 0; }
.compound-smiles { word-break: break-all; color: var(--fg-muted); font-size: 12px; margin: 0; }
.compound-conf { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }

/* ---- predicted-targets table: clickable rows + expand chevron ---- */
.pred-row { cursor: pointer; }
.pred-row:hover { background: var(--table-row-hover); }
.pred-row .exp { color: var(--fg-muted); font-family: var(--font-mono); width: 1.4em; user-select: none; }
.reverse-row > td { padding: 0 !important; border: 0 !important; }
.reverse { display: none; padding: 0; }
.reverse.open { display: block; padding: 12px 14px 16px; background: var(--bg-soft); }
.rev-head { color: var(--fg-muted); font-size: 13px; margin-bottom: 8px; }
.rev-item { display: inline-flex; gap: 8px; align-items: center; padding: 5px 10px; margin: 0 8px 8px 0;
            border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elev);
            color: var(--fg); text-decoration: none; font-size: 13px; }
.rev-item:hover { border-color: var(--border-strong); }
.rev-full { display: inline-block; margin-top: 4px; color: var(--accent); font-weight: 600; font-size: 13px; }

/* ---- patents table ---- */
.pat-table td { padding: 7px 10px; }

/* ---- hide the header search on the home page (the hero already carries it) ---- */
body:has(.hero-search) .header-search { display: none; }

/* ---- named compound: SCHEMBL id shown small under the name ---- */
.compound-altid { color: var(--fg-soft); font-size: 12px; letter-spacing: 0.02em; margin: 0; }

/* ---- home hero: theme-aware elevated surface (light=white, dark=dark) ---- */
.hero-search {
  background:
    radial-gradient(60% 50% at 50% 50%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%),
    linear-gradient(to bottom, var(--bg-elev), var(--bg));
}

/* ---- footer: bulletproof centering (each line centered as a flex item) ---- */
.site-footer .container { display: flex; flex-direction: column; align-items: center; }
.site-footer-tagline { max-width: 70ch; }

/* ---- structure image: shimmer skeleton while the lazy SVG loads ---- */
.struct-loading {
  background-image: linear-gradient(90deg, var(--bg-soft) 25%, var(--bg) 50%, var(--bg-soft) 75%);
  background-size: 200% 100%;
  animation: structShimmer 1.3s ease-in-out infinite;
}
.struct img, img.struct { display: block; }
@keyframes structShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---- listing-page card stat (predicted-compound count) ---- */
.card-stat { color: var(--fg-soft); font-size: 13px; margin: 6px 0 0; }
.card-stat b { color: var(--accent); font-variant-numeric: tabular-nums; }
.cat-lead { color: var(--fg-muted); max-width: 70ch; margin: 0 0 1.5rem; }

/* ---- known targets (grounding): green badges + ticks + sugi cross-links ---- */
.kbadges { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 10px; }
.kbadge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-weight: 600; font-size: 14px;
  background: color-mix(in srgb, var(--band-high-edge) 14%, transparent); color: var(--band-high-fg);
  border: 1px solid color-mix(in srgb, var(--band-high-edge) 40%, transparent); }
.kbadge:hover { text-decoration: none; border-color: var(--band-high-edge); }
.known-tick { display: inline-block; font-size: 11px; font-weight: 600; margin-left: 6px; padding: 1px 7px;
  border-radius: 5px; background: color-mix(in srgb, var(--band-high-edge) 16%, transparent); color: var(--band-high-fg); }
.compound-sugi { margin: 4px 0 0; font-size: 13px; }

/* ---- provenance table: patent title column ---- */
.pat-title { color: var(--fg-muted); font-size: 13px; max-width: 34ch; }

/* ---- target dossier: cross-modal context blocks (trials / literature / related proteins) ---- */
.ctx-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.25rem; align-items: start; }
.ctx-grid .entity-main { margin-top: 0; }
.ctx-block h3 { margin: 0 0 8px; font-size: 15px; }
.ctx-item { display: block; padding: 8px 0; border-bottom: 1px solid var(--border); }
.ctx-item:last-child { border-bottom: 0; }
.ctx-item:hover { text-decoration: none; }
.ctx-title { display: block; font-size: 13px; color: var(--fg); line-height: 1.4; }
.ctx-item:hover .ctx-title { color: var(--accent); }
.ctx-meta { display: block; font-size: 12px; color: var(--fg-soft); margin-top: 2px; }
.ctx-prots { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 0; }
.ctx-prot { display: inline-block; padding: 4px 11px; border-radius: 999px; font-weight: 600; font-size: 13px;
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--fg); }
.ctx-prot small { color: var(--fg-soft); font-weight: 400; }
.ctx-prot:hover { border-color: var(--accent); text-decoration: none; }

/* ---- dossier tables: let long literature titles wrap, align cells to top ---- */
.entity-main .data-table td { vertical-align: top; white-space: normal; }

/* ---- autocomplete dropdown status message (searching… / no match) ---- */
.ac .ac-msg { padding: 9px 12px; color: var(--fg-soft); font-size: 13px; }

/* ---- autocomplete entry type tag (target / compound) ---- */
.ac-type { float: right; font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--fg-soft); background: var(--bg-soft); padding: 1px 6px; border-radius: 4px; margin-left: 8px; }

/* ---- autocomplete footer: "see all results" deeper-search link ---- */
.ac-deeper { display: block; padding: 9px 12px; font-size: 13px; font-weight: 500; color: var(--accent);
  border-top: 1px solid var(--border); background: var(--bg-soft); }
.ac-deeper:hover { background: var(--table-row-hover); text-decoration: none; }

/* ---- target-page patent-compound landscape as a table (small structure thumbnail) ---- */
.compound-trow { cursor: pointer; }
.compound-trow:hover { background: var(--table-row-hover); }
.compound-table td { vertical-align: middle; }
.struct-cell { width: 216px; padding: 6px 10px; }
.struct-sm { width: 192px; height: 120px; border-radius: 4px; background: #fff; }

/* nav category dots — target = accent (blue), compound = green (mirrors the hero chips) */
.site-nav-group a.nav-targets::before,
.site-nav-group a.nav-compounds::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;
}
.site-nav-group a.nav-targets::before { background: var(--accent); }
.site-nav-group a.nav-compounds::before { background: #16a34a; }

/* entity hero band — sugi cat-hero style: a bordered section with a type-coloured top gradient,
   holding the title, a lead description, and the headline number (target = blue, compound = green) */
.entity-target, .entity-compound { padding-top: 0; }
.entity-hero { border-bottom: 1px solid var(--border); padding: 3rem 0 2rem; margin-bottom: 1.75rem; }
.entity-target  .entity-hero { background: radial-gradient(50% 50% at 0% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%), var(--bg-elev); }
.entity-compound .entity-hero { background: radial-gradient(50% 50% at 0% 0%, color-mix(in srgb, #16a34a 14%, transparent), transparent 70%), var(--bg-elev); }
.entity-hero .breadcrumb { margin-bottom: 0.9rem; }
.entity-hero .entity-header { margin-bottom: 0.5rem; }
.entity-hero .entity-title { margin: 0; }
.entity-hero .cat-lead { margin-bottom: 0; }
.entity-lead { color: var(--fg-muted); margin: 0 0 0.7rem; }
.entity-figure { font-size: 1.1rem; margin: 0; }
.entity-figure b { font-variant-numeric: tabular-nums; color: var(--fg); }
.entity-figure-note { color: var(--fg-soft); font-size: 0.85em; font-weight: 400; }

/* ─────────────────────────────────────────────────────────────────────────
   "On this page" table of contents (JS-injected by static/js/toc.js).
   Adapted from the Sugi Atlas entity TOC (atlas.css). Floating aside on wide
   screens; inline <details> on narrow screens (≤1100px). Navigation only —
   no collapse/expand sync, since patent-atlas sections are plain.
   ───────────────────────────────────────────────────────────────────────── */
.entity-toc-aside {
  position: fixed;
  top: 76px;
  right: 0;
  width: 220px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 10px 0 0 10px;
  padding: 0.85rem 0.95rem 0.85rem 0.55rem;
  box-shadow: -2px 6px 20px rgba(0, 0, 0, 0.08);
  scrollbar-width: thin;
  z-index: 5;
}
.entity-toc-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 0.35rem;
  right: 0.4rem;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--fg-soft);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}
.entity-toc-close:hover {
  background: var(--bg-soft);
  color: var(--fg);
}
.entity-toc-reopen { display: none; }
body.toc-collapsed .entity-toc-aside { display: none; }
body.toc-collapsed .entity-toc-reopen {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 76px;
  right: 0.5rem;
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  color: var(--fg-muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  z-index: 5;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
body.toc-collapsed .entity-toc-reopen:hover {
  background: var(--bg-soft);
  color: var(--accent);
  border-color: var(--border-strong);
}
@media (max-width: 1100px) {
  .entity-toc-aside,
  .entity-toc-reopen { display: none !important; }
}
/* Inline mobile TOC — shown only when the floating aside is hidden. */
.entity-toc-inline { display: none; }
@media (max-width: 1100px) {
  .entity-toc-inline {
    display: block;
    margin: 0 0 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elev);
  }
  .entity-toc-inline > summary {
    cursor: pointer;
    padding: 0.6rem 0.85rem;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-muted);
    list-style: none;
  }
  .entity-toc-inline > summary::-webkit-details-marker { display: none; }
  .entity-toc-inline > summary::before {
    content: "›";
    display: inline-block;
    margin-right: 0.45rem;
    transition: transform 120ms ease;
  }
  .entity-toc-inline[open] > summary::before { transform: rotate(90deg); }
  .entity-toc-inline nav {
    padding: 0.25rem 0.85rem 0.85rem;
    border-top: 1px solid var(--border);
  }
  .entity-toc-inline nav ul {
    list-style: none;
    margin: 0.4rem 0 0;
    padding-left: 1rem;
    font-size: 0.9rem;
    line-height: 1.7;
  }
  .entity-toc-inline nav > ul { padding-left: 0; }
  .entity-toc-inline nav a { color: var(--fg); text-decoration: none; }
  .entity-toc-inline nav a:hover { color: var(--accent); }
  .entity-toc-inline nav a.active { color: var(--accent); font-weight: 600; }
}
.entity-toc-label {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-soft);
  font-weight: 600;
  padding-left: 0.4rem;
}
.entity-toc-aside nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.entity-toc-aside nav > ul > li { margin-bottom: 0.35rem; }
/* Top-level (H2) TOC entries — main sections of the page, slightly bolder. */
.entity-toc-aside nav > ul > li > a {
  font-weight: 600;
  color: var(--fg);
}
.entity-toc-aside nav a {
  display: block;
  padding: 0.3rem 0.55rem;
  color: var(--fg-muted);
  border-left: 2px solid transparent;
  text-decoration: none;
  font-size: 0.86rem;
  line-height: 1.4;
  border-radius: 0 4px 4px 0;
  transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.entity-toc-aside nav a:hover {
  color: var(--fg);
  background: var(--bg-soft);
  text-decoration: none;
}
/* Active section (scroll-spy). */
.entity-toc-aside nav a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--bg-soft);
}
.entity-toc-aside nav > ul > li > a.active { color: var(--accent); }
/* Nested (H3) sub-items. */
.entity-toc-aside nav ul ul {
  margin: 0.2rem 0 0.55rem 0.6rem;
  padding-left: 0.45rem;
  border-left: 1px solid var(--border);
}
.entity-toc-aside nav ul ul a {
  font-size: 0.82rem;
  padding: 0.22rem 0.55rem;
  color: var(--fg-muted);
  font-weight: 400;
}
.entity-toc-aside nav ul ul a:hover { color: var(--fg); }

/* ═══ Method (inlined preprint) page ══════════════════════════════════════
   The /method page inlines the make4ht preprint (static/preprint/main.html).
   Its typography comes from static/preprint/main.css, scoped under
   .preprint-doc so it never touches the site header/nav/footer. These rules
   frame the paper inside the site chrome and keep wide tables/figures from
   pushing the whole page (and the mobile drawer) off-screen. */
.preprint-page { padding: 1.5rem 0 3rem; }
.preprint-header {
  margin: 0.5rem 0 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.preprint-title {
  margin: 0 0 0.4rem;
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.preprint-tagline {
  font-size: 0.95rem;
  color: var(--fg-muted);
  margin: 0;
  line-height: 1.55;
}
.preprint-tagline a { color: var(--accent); }
/* The inlined paper: a wider centred column (main.css scopes typography to it).
   overflow-wrap keeps long tokens (URLs, ids) from forcing a horizontal scroll. */
.preprint-doc {
  max-width: 68em;
  margin: 1rem auto 0;
  padding: 2rem 2.75rem 3rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-wrap: break-word;
}
.preprint-doc img,
.preprint-doc svg,
.preprint-doc table { max-width: 100%; height: auto; }
@media (max-width: 768px) {
  /* Confine any wide tex4ht table/figure to the paper: it scrolls horizontally
     while the page chrome (and the header drawer at right:0) stays put. */
  .preprint-doc {
    padding: 1.25rem;
    overflow-x: auto;
    border-radius: 0;
    margin-left: -0.75rem;
    margin-right: -0.75rem;
  }
}
