/* =================================================================
   taxonomy.css — document-page styles for /taxonomy/
   Built on the site tokens in styles.css (load this AFTER styles.css).
   Adds: doc hero, sticky TOC, long-form typography, tier cards, tables.
   ================================================================= */

:root {
  /* Tier semantics — muted to sit inside the slate/navy palette */
  --t-allowed:        #5cba8f;
  --t-allowed-dim:    rgba(92, 186, 143, 0.13);
  --t-dual:           #d6a23e;
  --t-dual-dim:       rgba(214, 162, 62, 0.13);
  --t-high:           #df8a4c;
  --t-high-dim:       rgba(223, 138, 76, 0.13);
  --t-disallowed:     #d56b6b;
  --t-disallowed-dim: rgba(213, 107, 107, 0.13);

  --doc-measure: 760px;   /* comfortable reading column */
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Menlo, Consolas, monospace;
}

/* ---------- Constellation backdrop ----------
   Fixed, subtle starfield carried over from the original doc design,
   re-tuned from the old bright blue to the site's slate accent.
   z-index:-1 keeps it behind all in-flow content (header, main, footer)
   without needing to position any of them. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-repeat: no-repeat;
  background-image:
    radial-gradient(2px   2px   at 12% 18%, rgba(156, 184, 207, 0.40), transparent),
    radial-gradient(1.6px 1.6px at 22% 62%, rgba(123, 155, 181, 0.30), transparent),
    radial-gradient(1.4px 1.4px at 34% 30%, rgba(123, 155, 181, 0.26), transparent),
    radial-gradient(2px   2px   at 46% 78%, rgba(156, 184, 207, 0.34), transparent),
    radial-gradient(1.4px 1.4px at 58% 22%, rgba(123, 155, 181, 0.28), transparent),
    radial-gradient(1.8px 1.8px at 67% 54%, rgba(156, 184, 207, 0.36), transparent),
    radial-gradient(1.4px 1.4px at 75% 84%, rgba(123, 155, 181, 0.24), transparent),
    radial-gradient(2px   2px   at 83% 32%, rgba(156, 184, 207, 0.34), transparent),
    radial-gradient(1.5px 1.5px at 90% 68%, rgba(123, 155, 181, 0.28), transparent),
    radial-gradient(1.6px 1.6px at 8%  88%, rgba(123, 155, 181, 0.26), transparent),
    radial-gradient(1.3px 1.3px at 52% 48%, rgba(123, 155, 181, 0.22), transparent),
    radial-gradient(1.8px 1.8px at 95% 12%, rgba(156, 184, 207, 0.32), transparent),
    radial-gradient(1.5px 1.5px at 17% 40%, rgba(156, 184, 207, 0.28), transparent),
    radial-gradient(1.3px 1.3px at 40% 92%, rgba(123, 155, 181, 0.24), transparent),
    radial-gradient(1.6px 1.6px at 62% 70%, rgba(156, 184, 207, 0.30), transparent),
    radial-gradient(1.4px 1.4px at 78% 16%, rgba(123, 155, 181, 0.26), transparent),
    radial-gradient(1.5px 1.5px at 30% 8%,  rgba(156, 184, 207, 0.30), transparent),
    radial-gradient(1.3px 1.3px at 88% 50%, rgba(123, 155, 181, 0.24), transparent);
}

/* ---------- Document hero ---------- */
.doc-hero {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: transparent;   /* let the constellation show through the hero too */
}
.doc-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(58% 70% at 82% 12%, rgba(123, 155, 181, 0.18), transparent 70%),
    radial-gradient(46% 60% at 6% 96%, rgba(123, 155, 181, 0.08), transparent 72%);
  pointer-events: none;
}
.doc-hero__inner {
  position: relative;
  z-index: 1;
  padding-block: clamp(3.5rem, 9vh, 6rem) clamp(2.5rem, 6vh, 4rem);
  max-width: 64ch;
}
.doc-eyebrow {
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.26em;
  font-size: 0.78rem;
  color: var(--accent);
  margin: 0 0 1.25rem;
}
.doc-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(2.1rem, 5vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 1.25rem;
}
.doc-subtitle {
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
  color: var(--text-soft);
  max-width: 60ch;
  margin: 0 0 2rem;
}
.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.75rem;
  font-family: var(--font-head);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}
.doc-meta strong { color: var(--text-soft); font-weight: 600; }
.doc-meta .dot { color: var(--accent); }
.doc-actions { display: flex; flex-wrap: wrap; gap: 0.85rem; }

/* ---------- Shell: sticky TOC + reading column ---------- */
.doc-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
  padding-block: clamp(2.5rem, 6vh, 4.5rem) clamp(3.5rem, 9vh, 6rem);
}
@media (min-width: 1024px) {
  .doc-shell {
    grid-template-columns: 210px minmax(0, var(--doc-measure));
    justify-content: center;
    gap: clamp(2rem, 5vw, 4.5rem);
    align-items: start;
  }
}

/* ---------- Table of contents ---------- */
.doc-toc { display: none; }
@media (min-width: 1024px) {
  .doc-toc {
    display: block;
    position: sticky;
    top: 92px;
    font-family: var(--font-head);
  }
}
.doc-toc__title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  margin: 0 0 1rem;
}
.doc-toc nav { display: flex; flex-direction: column; gap: 0.1rem; border-left: 1px solid var(--border); }
.doc-toc a {
  font-size: 0.9rem;
  color: var(--text-soft);
  padding: 0.4rem 0 0.4rem 1rem;
  margin-left: -1px;
  border-left: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
.doc-toc a:hover { color: var(--text); border-left-color: var(--accent); }

/* ---------- Long-form typography ---------- */
.doc-main { min-width: 0; }
.doc-main > section + section { margin-top: 3.25rem; }
.doc-main h2 {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: clamp(1.5rem, 2.6vw, 1.9rem);
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0 0 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 92px;
}
.doc-main h3 {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.15rem;
  margin: 2rem 0 0.6rem;
  color: var(--text);
}
.doc-main p { color: var(--text-soft); margin: 0 0 1.15rem; }
.doc-main ul, .doc-main ol {
  list-style: revert;
  color: var(--text-soft);
  margin: 0 0 1.25rem;
  padding-left: 1.4rem;
}
.doc-main li { margin-bottom: 0.5rem; }
.doc-main li::marker { color: var(--accent); }
.doc-main strong { color: var(--text); font-weight: 600; }
.doc-main em { color: var(--text); font-style: italic; }
.doc-main a {
  color: var(--accent);
  border-bottom: 1px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
.doc-main a:hover { color: var(--accent-bright); border-bottom-color: var(--accent-bright); }
.doc-main code {
  font-family: var(--mono);
  font-size: 0.88em;
  color: var(--accent-bright);
  background: var(--accent-dim);
  padding: 0.08em 0.4em;
  border-radius: 5px;
}
.doc-lead {
  font-size: 1.12rem;
  color: var(--text) !important;
}

/* Rendered remote papers: keep ASCII operators literal (Inter ligates
   "<-", "->", "<->" into arrow glyphs, which mangles boundary notation). */
.paper-render { font-feature-settings: "liga" 0, "calt" 0; }

/* Trust-tier accents (Agent Tool Permission Matrix). Inline pills so dual-tier
   cells ("Tier 1 ..., Tier 2 ...") read clearly. Reuses the taxonomy tier
   tokens: 0 = teal/observe, 1 = amber/scoped, 2 = coral/privileged. */
.paper-render .tier-pill {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.82em;
  white-space: nowrap;
  padding: 0.06em 0.5em;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.paper-render .tier-pill--0 { color: var(--t-allowed); background: var(--t-allowed-dim); }
.paper-render .tier-pill--1 { color: var(--t-dual); background: var(--t-dual-dim); }
.paper-render .tier-pill--2 { color: var(--t-disallowed); background: var(--t-disallowed-dim); }

/* ---------- Block code + ASCII diagrams (rendered papers) ---------- */
.doc-main pre {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin: 1.5rem 0;
  overflow-x: auto;          /* wide ASCII diagrams scroll, never overflow */
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-soft);
}
.doc-main pre code {        /* reset the inline-code pill inside blocks */
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  white-space: pre;          /* preserve diagram whitespace */
}

/* ---------- Blockquote (executive summary / notes in rendered papers) ---------- */
.doc-main blockquote {
  border-left: 3px solid var(--accent);
  background: var(--accent-dim);
  border-radius: var(--radius);
  padding: 1rem 1.3rem;
  margin: 1.5rem 0;
}
.doc-main blockquote p { color: var(--text-soft); }
.doc-main blockquote p:last-child { margin-bottom: 0; }

/* ---------- "At a glance" table ---------- */
.table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
thead { background: var(--panel); }
th {
  text-align: left;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  padding: 0.9rem 1.05rem;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 0.9rem 1.05rem;
  color: var(--text-soft);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--panel); }
.tier-dot {
  display: inline-block;
  width: 0.6rem; height: 0.6rem;
  border-radius: 50%;
  margin-right: 0.5rem;
  vertical-align: 0.05em;
}
.tier-dot--allowed    { background: var(--t-allowed); }
.tier-dot--dual       { background: var(--t-dual); }
.tier-dot--high       { background: var(--t-high); }
.tier-dot--disallowed { background: var(--t-disallowed); }
td .tname { font-family: var(--font-head); font-weight: 600; color: var(--text); white-space: nowrap; }

/* ---------- Tier cards ---------- */
.tier {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-left: 4px solid var(--border);
  padding: 1.75rem 1.85rem;
  margin: 1.4rem 0;
  transition: transform var(--transition), border-color var(--transition), background var(--transition);
}
.tier:hover { transform: translateY(-3px); background: var(--panel-hover); }
.tier__head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.tier__num {
  display: grid;
  place-items: center;
  width: 2.1rem; height: 2.1rem;
  flex: none;
  border-radius: 9px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1rem;
  color: var(--bg);
}
.tier__name {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.2rem;
  margin: 0;
}
.tier__label {
  margin-left: auto;
  font-family: var(--font-head);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
}
.tier p { color: var(--text-soft); }
.tier-field { margin-top: 1.1rem; }
.tier-field__label {
  font-family: var(--font-head);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.45rem;
}
.tier-field ul { margin-bottom: 0; }
.tier-field p { margin-bottom: 0; }

.tier--allowed    { border-left-color: var(--t-allowed); }
.tier--allowed    .tier__num   { background: var(--t-allowed); }
.tier--allowed    .tier__label { background: var(--t-allowed-dim); color: var(--t-allowed); }
.tier--allowed:hover    { border-color: var(--t-allowed); }
.tier--dual       { border-left-color: var(--t-dual); }
.tier--dual       .tier__num   { background: var(--t-dual); }
.tier--dual       .tier__label { background: var(--t-dual-dim); color: var(--t-dual); }
.tier--dual:hover       { border-color: var(--t-dual); }
.tier--high       { border-left-color: var(--t-high); }
.tier--high       .tier__num   { background: var(--t-high); }
.tier--high       .tier__label { background: var(--t-high-dim); color: var(--t-high); }
.tier--high:hover       { border-color: var(--t-high); }
.tier--disallowed { border-left-color: var(--t-disallowed); }
.tier--disallowed .tier__num   { background: var(--t-disallowed); }
.tier--disallowed .tier__label { background: var(--t-disallowed-dim); color: var(--t-disallowed); }
.tier--disallowed:hover { border-color: var(--t-disallowed); }

/* ---------- Callout aside (key principle) ---------- */
.doc-callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--accent-dim);
  border-radius: var(--radius);
  padding: 1.4rem 1.6rem;
  margin: 1.75rem 0;
}
.doc-callout__label {
  display: block;
  font-family: var(--font-head);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.doc-callout p:last-child { margin-bottom: 0; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .tier { padding: 1.35rem 1.25rem; }
  .tier__label { margin-left: 0; }
  .tier__head { flex-wrap: wrap; }
}
