/* ============================================================
   Ambient Agency — academic journal stylesheet
   A restrained, paper-like typographic system.
   ============================================================ */

:root {
  /* Palette — paper & ink */
  --paper:      #fcfcfa;
  --paper-2:    #f5f4ee;
  --panel:      #f1efe8;
  --ink:        #1a1d21;
  --ink-soft:   #43484f;
  --ink-faint:  #6b7077;
  --rule:       #dcd9cf;
  --rule-soft:  #e9e6dd;

  /* Accents — oxford ink-blue + scholarly ochre/burgundy */
  --accent:       #1f3a5f;   /* oxford blue */
  --accent-deep:  #16293f;
  --accent-soft:  #e7edf4;
  --ochre:        #9a6a2f;
  --burgundy:     #7a2e2e;
  --teal:         #2f6b66;

  /* Type */
  --serif: "Source Serif 4", "Spectral", Georgia, "Times New Roman", serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:  "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  --measure: 720px;     /* body text column */
  --wide:    1080px;    /* figures / wide blocks */
  --gut: 2rem;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.7;
  font-feature-settings: "kern" 1, "liga" 1, "onum" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-deep); }

/* subtle paper grain via repeating gradient on the very bottom */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% -10%, rgba(31,58,95,0.04), transparent 60%);
  z-index: -1;
}

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem clamp(1rem, 4vw, 2.4rem);
  background: rgba(252,252,250,0.86);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.brand {
  display: flex; align-items: center; gap: 0.6rem;
  font-family: var(--sans);
  font-weight: 600; letter-spacing: 0.01em;
  color: var(--ink); text-decoration: none;
  font-size: 0.95rem;
}
.brand .mark { display: inline-flex; }
.brand .mark svg { width: 26px; height: 26px; display: block; }
.brand small {
  display:block; font-weight: 500; color: var(--ink-faint);
  font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase;
}
.topnav { display: flex; gap: 1.4rem; font-family: var(--sans); font-size: 0.84rem; }
.topnav a {
  color: var(--ink-soft); text-decoration: none; letter-spacing: 0.01em;
  padding: 0.2rem 0; border-bottom: 2px solid transparent;
}
.topnav a:hover { color: var(--accent); border-color: var(--rule); }
.topnav a.active { color: var(--accent); border-color: var(--accent); }
.menu-btn { display:none; }

/* ============================================================
   Layout
   ============================================================ */
.layout {
  display: grid;
  grid-template-columns: minmax(0,1fr);
  max-width: 1320px; margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2.4rem);
}
@media (min-width: 1060px) {
  .layout { grid-template-columns: 250px minmax(0,1fr); gap: 3rem; }
}

/* Sidebar table of contents */
.toc {
  font-family: var(--sans);
  font-size: 0.82rem;
  align-self: start;
}
@media (min-width: 1060px) {
  .toc { position: sticky; top: 84px; max-height: calc(100vh - 110px); overflow:auto; padding: 1.6rem 0; }
}
.toc h4 {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--ink-faint); margin: 1.4rem 0 0.6rem; font-weight: 600;
}
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { margin: 0; }
.toc a {
  display: flex; gap: 0.55rem; align-items: baseline;
  color: var(--ink-soft); text-decoration: none;
  padding: 0.26rem 0.5rem 0.26rem 0;
  border-left: 2px solid transparent; padding-left: 0.7rem;
  line-height: 1.35;
}
.toc a .num { color: var(--ink-faint); font-variant-numeric: tabular-nums; font-size: 0.76rem; }
.toc a:hover { color: var(--accent); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

/* ============================================================
   Article
   ============================================================ */
.article { padding: 2.5rem 0 5rem; min-width: 0; }
.article > * { max-width: var(--measure); }

/* Masthead */
.masthead { max-width: var(--measure); border-bottom: 1px solid var(--rule); padding-bottom: 2rem; margin-bottom: 2.4rem; }
.eyebrow {
  font-family: var(--sans); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--ochre);
  margin: 0 0 1rem;
}
h1.title {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.1; letter-spacing: -0.015em;
  font-weight: 600; margin: 0 0 0.7rem;
}
.subtitle { font-size: 1.25rem; color: var(--ink-soft); font-style: italic; margin: 0 0 1.6rem; line-height: 1.4; }
.author { font-size: 1.15rem; font-weight: 600; margin: 0 0 0.15rem; color: var(--ink); }
.affil { font-family: var(--sans); font-size: 0.86rem; color: var(--ink-faint); margin: 0 0 1.4rem; }
.affil a { color: var(--accent); }
.byline {
  font-family: var(--sans); font-size: 0.82rem; color: var(--ink-faint);
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.4rem; align-items: center;
}

/* CCS / keywords front matter */
.frontmatter {
  max-width: var(--measure); margin: 0 0 2.6rem;
  font-family: var(--sans); font-size: 0.86rem; line-height: 1.6; color: var(--ink-soft);
  border-top: 1px solid var(--rule-soft); border-bottom: 1px solid var(--rule-soft);
  padding: 1rem 0;
}
.frontmatter p { margin: 0 0 0.5rem; }
.frontmatter p:last-child { margin: 0; }
.frontmatter .fm-label {
  font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ochre); font-weight: 700;
}
.frontmatter b { color: var(--ink); font-weight: 600; }

/* Plate figures (authored image figures) */
.figure .plate {
  display: block; margin: 0 auto; max-width: 100%; height: auto;
}
.figure.plate-frame .frame { text-align: center; background: #fff; padding: 1.8rem; }
.figref { font-variant-numeric: tabular-nums; }

/* Reference designators inside figure captions */
.rd {
  font-family: var(--mono); font-size: 0.82em; color: var(--accent);
  background: var(--accent-soft); border-radius: 3px; padding: 0.02em 0.32em;
}

/* Inline citation links */
a.ref {
  font-family: var(--sans); font-size: 0.82em; font-weight: 600;
  text-decoration: none; color: var(--accent); vertical-align: 0.2em;
  padding: 0 0.05em;
}
a.ref:hover { text-decoration: underline; }

/* References list */
ol.refs {
  max-width: var(--measure); font-family: var(--sans); font-size: 0.88rem;
  line-height: 1.55; color: var(--ink-soft); padding-left: 1.6rem;
}
ol.refs li { margin: 0 0 0.6rem; scroll-margin-top: 84px; }
ol.refs li:target { background: var(--accent-soft); border-radius: 3px; }
ol.refs em { color: var(--ink); font-style: italic; }
.byline .pill {
  border: 1px solid var(--rule); border-radius: 100px; padding: 0.15rem 0.7rem;
  color: var(--ink-soft); background: var(--paper-2);
}

/* Abstract */
.abstract {
  max-width: var(--measure);
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  padding: 1.6rem 1.8rem;
  border-radius: 3px;
  margin: 0 0 2.6rem;
}
.abstract h2 {
  font-family: var(--sans); font-size: 0.72rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--accent); margin: 0 0 0.7rem; font-weight: 700;
}
.abstract p { margin: 0 0 0.9rem; font-size: 1.02rem; }
.abstract p:last-child { margin-bottom: 0; }

/* Headings */
.article h2.section {
  font-size: 1.65rem; line-height: 1.2; font-weight: 600;
  letter-spacing: -0.01em; margin: 3.4rem 0 1rem;
  padding-top: 0.4rem;
  scroll-margin-top: 84px;
}
.article h2.section .sec-no {
  font-family: var(--sans); font-size: 0.95rem; font-weight: 600;
  color: var(--ochre); margin-right: 0.7rem; vertical-align: 0.12em;
}
.article h3 {
  font-size: 1.22rem; font-weight: 600; margin: 2.2rem 0 0.6rem;
  scroll-margin-top: 84px; color: var(--ink);
}
.article h3 .sec-no { font-family: var(--sans); font-size: 0.8rem; color: var(--ink-faint); margin-right: 0.5rem; }
.article p { margin: 0 0 1.15rem; }
.lead { font-size: 1.15rem; color: var(--ink-soft); }

.article strong { font-weight: 600; }
.term { font-style: italic; color: var(--accent-deep); font-weight: 600; }

/* Drop note / margin emphasis */
blockquote.pull {
  margin: 1.8rem 0; padding: 0.4rem 0 0.4rem 1.4rem;
  border-left: 3px solid var(--ochre);
  font-size: 1.18rem; font-style: italic; color: var(--ink-soft);
}

/* Definition box */
.definition {
  max-width: var(--measure);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--teal);
  background: var(--paper);
  padding: 1.3rem 1.5rem; border-radius: 3px; margin: 1.8rem 0;
}
.definition .label {
  font-family: var(--sans); font-size: 0.68rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--teal); font-weight: 700; margin-bottom: 0.5rem;
}
.definition .dterm { font-weight: 600; font-style: italic; }
.definition p { margin: 0; }

/* Callout — the central claim */
.claim {
  max-width: var(--measure);
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #f4f6f9; border-radius: 5px; padding: 2rem 2rem 1.8rem;
  margin: 2.6rem 0; box-shadow: 0 14px 40px -22px rgba(22,41,63,0.6);
}
.claim .label {
  font-family: var(--sans); font-size: 0.7rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: #aebfd2; font-weight: 700; margin-bottom: 0.7rem;
}
.claim p { font-size: 1.18rem; line-height: 1.55; margin: 0 0 0.8rem; }
.claim p:last-child { margin-bottom: 0; }
.claim em { color: #e9c98b; font-style: italic; }
.claim a { color: #cfe0f2; }

/* Obligation chips */
.obligation { font-family: var(--sans); font-weight: 600; font-size: 0.92rem; }

/* Lists */
.article ul, .article ol { padding-left: 1.3rem; margin: 0 0 1.3rem; }
.article li { margin: 0 0 0.5rem; }
.axes { list-style: none; padding: 0; }
.axes > li {
  border-left: 2px solid var(--rule); padding: 0.2rem 0 0.2rem 1rem; margin-bottom: 1rem;
}
.axes b { display:block; font-family: var(--sans); font-size: 0.95rem; color: var(--accent-deep); }

/* ============================================================
   Figures
   ============================================================ */
.figure {
  max-width: var(--wide);
  margin: 2.6rem 0;
}
.figure.full { width: 100%; }
.figure .frame {
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: 4px;
  padding: 1.6rem;
  overflow: hidden;
}
.figure figcaption {
  font-family: var(--sans); font-size: 0.84rem; color: var(--ink-soft);
  margin-top: 0.8rem; line-height: 1.55; max-width: var(--measure);
}
.figure figcaption b { color: var(--ink); font-weight: 600; }
.figure figcaption .fno { color: var(--ochre); font-weight: 700; }

/* SVG default text styling hooks */
svg text { font-family: var(--sans); }
.svg-serif { font-family: var(--serif); }

/* ============================================================
   Tables
   ============================================================ */
.tbl-wrap { max-width: var(--wide); overflow-x: auto; margin: 1.8rem 0; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 0.95rem;
  font-family: var(--sans);
}
table.data caption {
  text-align: left; font-size: 0.84rem; color: var(--ink-soft);
  margin-bottom: 0.7rem; font-family: var(--sans);
}
table.data th, table.data td {
  text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--rule-soft);
  vertical-align: top;
}
table.data thead th {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-faint); border-bottom: 1.5px solid var(--rule);
}
table.data tbody th { font-weight: 600; color: var(--accent-deep); width: 30%; }
table.data tbody tr:hover { background: var(--paper-2); }

/* ============================================================
   Math
   ============================================================ */
.math-block {
  max-width: var(--measure); margin: 1.8rem 0;
  padding: 1.4rem; background: var(--paper-2); border: 1px solid var(--rule);
  border-radius: 4px; overflow-x: auto; text-align: center;
}
.katex { font-size: 1.12em; }

/* ============================================================
   Cards (navigation to parts on home)
   ============================================================ */
.cards {
  max-width: var(--wide);
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin: 1.6rem 0 2.4rem;
}
.card {
  display: block; text-decoration: none; color: inherit;
  border: 1px solid var(--rule); border-radius: 5px; padding: 1.2rem 1.3rem;
  background: var(--paper); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 12px 30px -20px rgba(26,29,33,0.4); border-color: var(--accent); }
.card .k {
  font-family: var(--sans); font-size: 0.68rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ochre); font-weight: 700;
}
.card h4 { font-size: 1.08rem; margin: 0.4rem 0 0.4rem; font-weight: 600; }
.card p { font-size: 0.92rem; color: var(--ink-soft); margin: 0; }

/* Key terms strip */
.keyterms {
  max-width: var(--wide);
  display: grid; gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(200px,1fr));
  margin: 1.4rem 0 2rem;
}
.keyterms .kt {
  border: 1px solid var(--rule-soft); border-radius: 4px; padding: 0.9rem 1rem;
  background: var(--paper-2);
}
.keyterms .kt b { display:block; font-size: 0.98rem; }
.keyterms .kt span { font-size: 0.85rem; color: var(--ink-soft); font-family: var(--sans); }

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--rule);
  margin-top: 3rem;
  background: var(--paper-2);
}
.site-footer .inner {
  max-width: 1320px; margin: 0 auto; padding: 2.4rem clamp(1rem,4vw,2.4rem);
  display: grid; gap: 2rem; grid-template-columns: 1fr;
  font-family: var(--sans); font-size: 0.86rem; color: var(--ink-soft);
}
@media (min-width: 720px) { .site-footer .inner { grid-template-columns: 2fr 1fr 1fr; } }
.site-footer h5 { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); margin: 0 0 0.8rem; }
.site-footer a { color: var(--ink-soft); text-decoration: none; display: block; padding: 0.18rem 0; }
.site-footer a:hover { color: var(--accent); }
.cite {
  font-family: var(--mono); font-size: 0.78rem; color: var(--ink-soft);
  background: var(--paper); border: 1px solid var(--rule); border-radius: 4px;
  padding: 1rem; white-space: pre-wrap; line-height: 1.5; margin-top: 0.6rem;
  max-width: 100%; overflow-x: auto;
}

/* Section divider */
.rule { max-width: var(--wide); border: 0; border-top: 1px solid var(--rule); margin: 3rem 0; }

/* Footnote-ish small print */
.smallprint { font-family: var(--sans); font-size: 0.8rem; color: var(--ink-faint); }

/* Glossary specifics */
.glossary-grid { max-width: var(--wide); display: grid; gap: 1.1rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .glossary-grid { grid-template-columns: 1fr 1fr; } }
.gentry {
  border: 1px solid var(--rule); border-radius: 5px; padding: 1.1rem 1.3rem; background: var(--paper);
  scroll-margin-top: 84px;
}
.gentry h4 { margin: 0 0 0.3rem; font-size: 1.05rem; }
.gentry .gtag { font-family: var(--sans); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ochre); font-weight: 700; }
.gentry p { margin: 0.4rem 0 0; font-size: 0.94rem; color: var(--ink-soft); }

/* ============================================================
   Mobile
   ============================================================ */
@media (max-width: 1059px) {
  .toc.sidebar { display: none; }
}
@media (max-width: 680px) {
  .topnav { display: none; }
  .menu-btn {
    display: inline-flex; font-family: var(--sans); font-size: 0.82rem;
    background: none; border: 1px solid var(--rule); border-radius: 4px;
    padding: 0.35rem 0.7rem; color: var(--ink-soft); cursor: pointer;
  }
  .topnav.open {
    display: flex; flex-direction: column; position: absolute;
    top: 100%; right: clamp(1rem,4vw,2.4rem); gap: 0.2rem;
    background: var(--paper); border: 1px solid var(--rule); border-radius: 6px;
    padding: 0.6rem 0.9rem; box-shadow: 0 18px 40px -20px rgba(0,0,0,0.4);
  }
  body { font-size: 1.0rem; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
