/* Compound detail page styles. Extracted verbatim from compound-template.html's
   inline <style> so the markup is thin and the rules are reusable/cacheable.
   Loaded AFTER style.css + receptor-profile.css and BEFORE theme-overrides.css
   (same cascade position as the old inline block). */

/* Long identifiers (InChI) must wrap instead of overflowing the table cell. */
#id-inchi { word-break: break-all; }

.compound-page .subtitle {
  margin: 8px 0 0;
  color: var(--text-soft);
  line-height: 1.7;
  max-width: 72ch;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

/* Cross-links to closely related entries (compound ↔ salt/formulation).
   A clean inline row — no callout box — with the brand accent on the link so
   it reads as a link and stays legible in both light and dark themes. */
.related-compounds {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px 10px;
  margin: 10px 0 0;
  font-size: 0.9rem;
}
.related-compounds .related-label {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-soft);
  opacity: 0.75;
}
.related-compounds .related-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.related-compounds a {
  color: var(--accent);
  /* Some ancestor link styling pins -webkit-text-fill-color to the body text
     colour, which paints over `color`; set it explicitly so the accent shows. */
  -webkit-text-fill-color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.related-compounds a:hover,
.related-compounds a:focus-visible {
  color: var(--accent-strong, var(--accent));
  -webkit-text-fill-color: var(--accent-strong, var(--accent));
  border-bottom-color: currentColor;
}
.related-compounds .related-note {
  color: var(--text-soft);
  font-size: 0.82rem;
}
.related-compounds .related-sep {
  color: var(--border);
  font-weight: 700;
}

.compound-page .status-flag-row,
.compound-page .evidence-badges,
.compound-page .source-supports,
.compound-page .infobox-meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.compound-page .status-flag-row {
  margin-top: 14px;
}

.compound-page .meta-pill,
.compound-page .status-pill,
.compound-page .source-badge,
.compound-page .support-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  /* These pills carry data-driven, sometimes list-like content
     ("Source types: Regulatory, Database, Drug label, …"). Allow them to
     wrap and cap their width so they never widen the column past the page. */
  white-space: normal;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.compound-page .status-pill--warning,
.compound-page .meta-pill--warning {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.24);
  color: var(--text);
}

.compound-page .status-pill--danger {
  background: rgba(244, 63, 94, 0.14);
  border-color: rgba(244, 63, 94, 0.24);
  color: var(--text);
}

.compound-page .status-pill--ok,
.compound-page .meta-pill--ok {
  background: rgba(var(--accent-rgb), 0.14);
  border-color: rgba(var(--accent-rgb), 0.24);
  color: var(--text);
}

.compound-page .meta-pill--muted,
.compound-page .status-pill--muted {
  color: var(--text-soft);
}

.compound-page .section-note {
  margin: 12px 0 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  color: var(--text-soft);
  line-height: 1.7;
  font-size: 0.95rem;
}

.compound-page .section-note strong {
  color: var(--text);
}

.compound-page .empty-note {
  color: var(--text-muted);
  font-style: italic;
}

.compound-page .infobox h3 {
  margin: 0 0 14px;
  color: var(--text);
  letter-spacing: -0.02em;
}

.compound-page .infobox-metadata {
  display: grid;
  gap: 10px;
  margin: 14px 0 18px;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.compound-page .infobox-metadata > div {
  display: grid;
  gap: 3px;
}

.compound-page .infobox-metadata span {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.compound-page .infobox-metadata strong {
  color: var(--text);
  font-size: 0.95rem;
}

.compound-page .infobox-metadata small {
  color: var(--text-muted);
  line-height: 1.5;
}

/* The expert sections mark up their data with placeholder utility classes
   (w-full, py-1, …) that no stylesheet backs, so these tables had no width
   cap: long values (SMILES, InChI, metabolism notes) stretched them — and
   the whole column — past the viewport. Pin every compound-page table to
   its column and let cell values wrap instead of overflowing. */
.compound-page table {
  width: 100%;
  table-layout: fixed;
}

.compound-page th,
.compound-page td {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.compound-page .infobox table {
  table-layout: fixed;
}

.compound-page .infobox tr {
  vertical-align: top;
}

.compound-page .infobox th {
  width: 38%;
}

.compound-page .infobox td {
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

.compound-page .infobox table tr:nth-child(3) td {
  text-align: left;
  line-height: 1.55;
  padding-left: 12px;
}

.compound-page .sources-summary {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.compound-page .source-group + .source-group {
  margin-top: 20px;
}

.compound-page .source-group h4 {
  margin: 0 0 12px;
  color: var(--text);
  letter-spacing: -0.02em;
}

.compound-page .source-grid {
  display: grid;
  gap: 14px;
}

.compound-page .source-card {
  padding: 14px 15px;
  border-radius: 16px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.compound-page .source-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.compound-page .source-card__title {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  line-height: 1.55;
}

.compound-page .source-card__title:hover,
.compound-page .source-card__title:focus-visible {
  text-decoration: underline;
}

.compound-page .source-card__meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.6;
}

.compound-page .source-card__note {
  margin: 10px 0 0;
  color: var(--text-soft);
  line-height: 1.7;
  font-size: 0.93rem;
}

.compound-page .source-badge--regulatory {
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.22);
  color: var(--text);
}

.compound-page .source-badge--database,
.compound-page .source-badge--drug_label {
  background: rgba(var(--accent-rgb), 0.12);
  border-color: rgba(var(--accent-rgb), 0.22);
  color: var(--text);
}

.compound-page .source-badge--review,
.compound-page .source-badge--study {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.22);
  color: var(--text);
}

.compound-page .source-badge--reference {
  background: rgba(100, 116, 139, 0.12);
  border-color: rgba(100, 116, 139, 0.22);
  color: var(--text);
}

.compound-page .source-badge--external {
  color: var(--text-soft);
}

/* Badge + reuse-licence grouped together on the right of a bibliography row. */
.compound-page .ref-item__meta {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
}
.compound-page .source-license {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-soft);
  text-decoration: none;
  white-space: nowrap;
}
.compound-page .source-license:hover,
.compound-page .source-license:focus-visible {
  color: var(--text);
  border-color: var(--accent);
}

.compound-page .support-chip {
  background: rgba(var(--accent-rgb), 0.08);
  border-color: rgba(var(--accent-rgb), 0.16);
  color: var(--text);
  font-size: 0.76rem;
}

/* Inline citation markers: small [n] superscripts after a sourced statement. */
.compound-page sup.cite {
  font-size: 0.68em;
  line-height: 0;
  white-space: nowrap;
}
.compound-page sup.cite a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.compound-page sup.cite a:hover,
.compound-page sup.cite a:focus-visible {
  text-decoration: underline;
}

/* Numbered bibliography at the foot of the page. */
.compound-page .ref-list {
  margin: 14px 0 0;
  padding-left: 2.3em;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  overflow-wrap: anywhere;
  gap: 12px;
}
.compound-page .ref-list li {
  line-height: 1.6;
}
.compound-page .ref-item__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.compound-page .ref-item:target {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 8px;
}

.compound-page .list-reset {
  margin: 0;
  padding-left: 18px;
}

.compound-page .list-reset li {
  line-height: 1.7;
  margin-bottom: 6px;
}

@media (max-width: 900px) {
  .compound-page .source-card__head {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ===== Overview (always-visible summary) ===== */
.compound-page .overview-card {
  margin: 6px 0 18px;
  padding: 18px 20px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.compound-page .overview-card h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}
.compound-page .overview-lead {
  margin: 0 0 14px;
  line-height: 1.75;
  color: var(--text-soft);
}
.compound-page .overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.compound-page .overview-cell {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
}
.compound-page .overview-cell span {
  display: block;
  color: var(--text-muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}
.compound-page .overview-cell strong {
  color: var(--text);
  font-size: 0.95rem;
}
.compound-page .overview-risk {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.22);
  color: var(--text);
  line-height: 1.65;
}

.compound-page .compound-disclaimer {
  margin: 12px 0 18px;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  border-radius: 0 12px 12px 0;
  background: var(--surface-muted);
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.65;
}

.compound-page .compound-disclaimer strong {
  color: var(--text);
}

/* ===== Dosing & duration ===== */
.compound-page .dose-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin: 6px 0 4px;
}
.compound-page .dose-cell {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
}
.compound-page .dose-cell span {
  display: block;
  color: var(--text-muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}
.compound-page .dose-cell strong {
  color: var(--text);
  font-size: 0.98rem;
}
.compound-page .dose-subhead {
  margin: 16px 0 4px;
  color: var(--text);
  font-size: 0.95rem;
}
.compound-page .dose-routes {
  margin: 0 0 4px;
  color: var(--text-soft);
}

/* ===== Glossary tooltip ===== */
.compound-page .glossary {
  border-bottom: 1px dotted var(--text-muted);
  cursor: help;
  position: relative;
}
.compound-page .glossary::after {
  content: attr(data-tip);
  display: none;
  position: absolute;
  left: var(--glossary-offset, 0px);
  top: 145%;
  width: max-content;
  box-sizing: border-box;
  max-width: min(284px, calc(100vw - 32px));
  padding: 8px 11px;
  border-radius: 12px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  color: var(--text-soft);
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.5;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms ease;
  z-index: 50;
}
.compound-page .glossary:hover::after,
.compound-page .glossary:focus-visible::after {
  display: block;
  opacity: 1;
  visibility: visible;
}
/* Each detail card carries backdrop-filter, which makes it its own stacking
   context; a later sibling card would otherwise paint over an earlier card's
   glossary tooltip (the tooltip's own z-index can't escape its card). Lift the
   card that holds the active tooltip above the following cards on hover/focus so
   the tooltip always shows on the topmost layer. */
.compound-page details {
  position: relative;
}
.compound-page details:hover,
.compound-page details:focus-within {
  z-index: 5;
}

/* Plain-language sections first, the deeper chemistry/PK reference blocks next,
   sources/links last — without moving the HTML, so the render script keeps
   targeting the same IDs. */
.compound-page .compound-content {
  display: flex;
  flex-direction: column;
}
.compound-page .compound-content > .detail-block { order: 2; }
.compound-page .compound-content > #sourcesEvidence { order: 3; }
.compound-page .compound-content > #further-info { order: 4; }

/* ---------------------------------------------------------------------------
   Structured Interactions & Contraindications (assets/js/compound-blocks.js).
   Severity colours are semantic, separate from the purple accent. Dark-first
   like the rest of the theme, with a light-mode override. Legacy string lists
   render through the plain .list-reset <ul> and are unaffected. */
:root {
  --sev-danger: #f0918a; --sev-danger-bg: rgba(240, 145, 138, .14);
  --sev-caution: #e6bd6a; --sev-caution-bg: rgba(230, 189, 106, .14);
  --sev-additive: #e8a878; --sev-additive-bg: rgba(232, 168, 120, .14);
  --sev-reduce: #9db0dd; --sev-reduce-bg: rgba(157, 176, 221, .14);
}
html[data-theme="light"] {
  --sev-danger: #c0362c; --sev-danger-bg: #fbeae8;
  --sev-caution: #8a5d00; --sev-caution-bg: #fbf1dc;
  --sev-additive: #a24a12; --sev-additive-bg: #fbeee2;
  --sev-reduce: #42527d; --sev-reduce-bg: #e9edf7;
}
.compound-page .cx-subhead {
  font-size: .72rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 700; margin: .9rem 0 .5rem;
}
.compound-page #interactions-wrap[hidden],
.compound-page #contraindications-wrap[hidden] { display: none; }
.compound-page .ix-row {
  display: flex; gap: .6rem; align-items: flex-start;
  background: var(--surface-muted, var(--surface-soft));
  border: 1px solid var(--border); border-left-width: 4px;
  border-radius: 10px; padding: .55rem .7rem; margin-bottom: .5rem;
}
.compound-page .ix-dangerous { border-left-color: var(--sev-danger); }
.compound-page .ix-caution { border-left-color: var(--sev-caution); }
.compound-page .ix-additive { border-left-color: var(--sev-additive); }
.compound-page .ix-reduces-effect { border-left-color: var(--sev-reduce); }
.compound-page .ix-sev {
  flex: none; font-size: .66rem; font-weight: 800; letter-spacing: .05em;
  text-transform: uppercase; padding: .15rem .45rem; border-radius: 999px;
  white-space: nowrap; margin-top: .1rem;
}
.compound-page .ix-sev-dangerous { color: var(--sev-danger); background: var(--sev-danger-bg); }
.compound-page .ix-sev-caution { color: var(--sev-caution); background: var(--sev-caution-bg); }
.compound-page .ix-sev-additive { color: var(--sev-additive); background: var(--sev-additive-bg); }
.compound-page .ix-sev-reduces-effect { color: var(--sev-reduce); background: var(--sev-reduce-bg); }
.compound-page .ix-body { min-width: 0; flex: 1; }
.compound-page .ix-agents { display: block; font-weight: 650; font-size: .92rem; }
.compound-page .ix-effect { display: block; font-size: .88rem; color: var(--text-muted); margin-top: .1rem; }
.compound-page .cx-tags { display: flex; flex-wrap: wrap; gap: .45rem; }
.compound-page .cx-pill {
  font-size: .84rem; padding: .25rem .6rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--text);
  border: 1px solid var(--border); font-weight: 600;
}
.compound-page .cx-pill .cx-why { color: var(--text-muted); font-weight: 400; }

/* Effects — grouped tags from effects.registry.json (compound-blocks.renderEffects). */
.compound-page .ef-group { margin-bottom: .8rem; }
.compound-page .ef-group:last-child { margin-bottom: 0; }
.compound-page .ef-glabel {
  font-size: .68rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 700; margin-bottom: .4rem;
}
.compound-page .ef-tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.compound-page .ef-pill {
  font-size: .84rem; padding: .24rem .6rem; border-radius: 999px;
  background: var(--surface-muted, var(--surface-soft)); color: var(--text);
  border: 1px solid var(--border); font-weight: 600;
}
.compound-page .ef-pill .ef-why { color: var(--text-muted); font-weight: 400; }

/* Safety flags — quick-scan severity chips above the safety prose. */
:root { --sev-good: #3fa06a; --sev-good-bg: rgba(63, 160, 106, .14); }
html[data-theme="light"] { --sev-good: #2f7a52; --sev-good-bg: #e6f3ec; }
.compound-page .sf-flags { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .9rem; }
.compound-page .sf-flags:empty { display: none; }
.compound-page .sf-flag {
  font-size: .8rem; font-weight: 600; padding: .22rem .6rem; border-radius: 7px;
  display: inline-flex; align-items: center; gap: .35rem;
}
.compound-page .sf-good { color: var(--sev-good); background: var(--sev-good-bg); }
.compound-page .sf-warn { color: var(--sev-caution); background: var(--sev-caution-bg); }
.compound-page .sf-crit { color: var(--sev-danger); background: var(--sev-danger-bg); }

/* Pharmacokinetic value — emphasised figure, muted qualifier. The structured
   low/high/unit numbers stay in the data (for CI and comparison) but are not shown. */
.compound-page .pk-val { font-weight: 650; }
.compound-page .pk-note { color: var(--text-muted); font-size: .92em; }

/* Half-life sidebar value: emphasise the leading figure, let the qualifier that
   follows (route, active metabolite, redistribution note) recede, so a crisp
   range and an "≈"/"Not established" read at one glance. Applied by the
   fmtHalfLife render heuristic in compound-template.html. */
.compound-page .pk-hl-primary { font-weight: 600; }
.compound-page .pk-hl-unknown { font-weight: 400; font-style: italic; color: var(--text-muted, #6b7280); }
.compound-page .pk-hl-note { color: var(--text-muted, #6b7280); font-size: 0.92em; }
