/* ------------------------------------------------------------------
   Project pages. Loaded AFTER the root style.css, so it inherits the
   site's colour tokens, body font, and dark-mode block. No inline
   styles / no external fonts anywhere here -- the site CSP is strict
   (default-src 'self'); everything must be same-origin.
   ------------------------------------------------------------------ */

:root {
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;
  --plate: #ffffff;          /* figure plates stay light in both themes */
  --plate-line: #d9d5cb;
}

/* ---------- slim page header ---------- */
.proj-header {
  border-bottom: 1px solid var(--line);
  background: var(--card-bg);
}
.proj-header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.9rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1rem;
}
.proj-home {
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  font-size: 0.9rem;
}
.proj-home:hover { color: var(--accent); }
.proj-header-title {
  font-weight: 600;
  color: var(--text);
}
.proj-header-title::before {
  content: "/ ";
  color: var(--muted);
  font-weight: 400;
}

/* ---------- left sub-nav + content ---------- */
.proj-layout {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 2.75rem;
  align-items: start;
}
.proj-side {
  position: sticky;
  top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 2rem 0;
}
.proj-side-group {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin: 0 0 0.6rem;
  font-weight: 600;
}
.proj-side a,
.proj-side .soon {
  font-size: 0.9rem;
  line-height: 1.35;
  padding: 0.35rem 0 0.35rem 0.8rem;
  border-left: 2px solid transparent;
  text-decoration: none;
  color: var(--muted);
}
.proj-side a:hover { color: var(--accent); }
.proj-side a.active {
  color: var(--text);
  border-left-color: var(--accent);
}
.proj-side .soon {
  color: var(--muted);
  opacity: 0.5;
}
.proj-side .soon::after {
  content: " \00b7 soon";
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}
.proj-side .proj-side-back {
  margin-top: 1.5rem;
  font-size: 0.82rem;
}

.proj-content {
  padding: 2.25rem 0 6rem;
  min-width: 0;
}

/* ---------- project / area index listings ---------- */
.proj-lede {
  color: var(--muted);
  font-size: 1rem;
  max-width: 60ch;
  margin: 0.4rem 0 2rem;
}
.proj-h1 {
  font-size: 1.5rem;
  margin: 0 0 0.2rem;
  letter-spacing: -0.01em;
}
.proj-eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.7rem;
}
.proj-section-h {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 2.6rem 0 0.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  letter-spacing: 0;
}
.proj-section-h:first-of-type { margin-top: 1.2rem; }
.proj-section-note {
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 60ch;
  margin: 0 0 1.1rem;
}
.card-list { display: grid; gap: 0.9rem; }
.card {
  display: block;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-bg);
  padding: 1.1rem 1.25rem;
  text-decoration: none;
  color: var(--text);
}
a.card:hover { border-color: var(--accent); }
div.card { opacity: 0.62; }
.card h3 { margin: 0 0 0.3rem; font-size: 1.05rem; }
.card h3 .soon {
  font-family: var(--mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0.15em 0.55em;
  vertical-align: 0.15em;
  margin-left: 0.45rem;
}
.card p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.card .card-meta {
  margin-top: 0.6rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.03em;
}

/* ==================================================================
   One-pager  (.paper)
   ================================================================== */
.paper { font-size: 16px; line-height: 1.62; }
.paper h1 {
  font-size: clamp(1.7rem, 4.5vw, 2.4rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 0.6rem;
  text-wrap: balance;
}
.paper .dek {
  font-size: clamp(1rem, 2.3vw, 1.12rem);
  color: var(--muted);
  max-width: 62ch;
  margin: 0 0 0.9rem;
}
.byline {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin: 0 0 2rem;
}
.byline strong { color: var(--text); font-weight: 600; }
.paper h2 {
  font-size: 1.25rem;
  text-transform: none;
  letter-spacing: -0.01em;
  color: var(--text);
  border: 0;
  padding: 0;
  margin: 0 0 0.4rem;
  text-wrap: balance;
}
.paper section {
  margin: 2.75rem 0 0;
  padding: 1.9rem 0 0;
  border-top: 1px solid var(--line);
  scroll-margin-top: 0;
}
.paper section.plain { border: 0; padding-top: 0; }
.paper section > p { max-width: 66ch; color: var(--muted); }
.paper section > p strong { color: var(--text); font-weight: 600; }
.paper em { font-style: italic; }

/* conditions box */
.cond {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-bg);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  overflow: hidden;
  margin: 1.4rem 0 0;
}
.cond div {
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--line);
}
.cond dt {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.2rem;
}
.cond dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text);
}

/* result tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.7rem;
  margin: 1.3rem 0 0;
}
.tile {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}
.tile .k {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.5rem;
}
.tile .v {
  font-family: var(--mono);
  font-size: 1.4rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.tile .s { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }
.tile.good .v { color: var(--accent); }
.tile.warm .v { color: #c2603a; }
@media (prefers-color-scheme: dark) {
  .tile.warm .v { color: #e08a63; }
}

/* figures -- permanently light "plate", both themes */
.paper figure { margin: 1.5rem 0 0; }
.paper figure img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--plate);
  border: 1px solid var(--plate-line);
  border-radius: 10px;
  padding: 0.5rem;
}
.paper figcaption {
  font-size: 0.83rem;
  color: var(--muted);
  margin-top: 0.6rem;
  border-left: 2px solid var(--line);
  padding-left: 0.75rem;
  max-width: 70ch;
}
.paper figcaption b { color: var(--text); font-weight: 600; }

/* inline code + chips */
.paper code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.06em 0.36em;
}
.chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.02em 0.5em;
  border-radius: 20px;
  border: 1px solid currentColor;
  vertical-align: baseline;
}
.chip.cool { color: #2f6fc0; }
.chip.warm { color: #c85b46; }
@media (prefers-color-scheme: dark) {
  .chip.cool { color: #6ba6e6; }
  .chip.warm { color: #e58a72; }
}

/* dash bullet lists */
.paper ul { padding: 0; list-style: none; max-width: 70ch; }
.paper ul li { position: relative; padding-left: 1.4rem; margin: 0.5rem 0; color: var(--muted); }
.paper ul li::before { content: "\2014"; position: absolute; left: 0; color: var(--accent); }
.paper ul li strong { color: var(--text); font-weight: 600; }

/* correction-table grid */
.gridwrap { overflow-x: auto; margin: 1.2rem 0 0; }
table.grid {
  border-collapse: separate;
  border-spacing: 3px;
  font-family: var(--mono);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}
table.grid td {
  width: 3.1rem;
  height: 2rem;
  text-align: center;
  border-radius: 5px;
  color: #1b1d22;
  letter-spacing: -0.02em;
}
/* diverging blue<->red buckets, fixed set (CSP: no inline style) */
.d-5 { background: #1c5cab; color: #fff; }
.d-4 { background: #3f7fca; color: #fff; }
.d-3 { background: #6da7ec; }
.d-2 { background: #9cc4f2; }
.d-1 { background: #cfe0f5; }
.d0  { background: #eceae4; }
.d1  { background: #f6d5cf; }
.d2  { background: #ef9f95; }
.d3  { background: #e5705f; color: #fff; }
.d4  { background: #d1493c; color: #fff; }
.d5  { background: #b5271b; color: #fff; }

/* plain data table + command block (design-doc pages) */
table.tbl { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
table.tbl th,
table.tbl td {
  text-align: left;
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.tbl th {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
pre.cmd {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin: 1.1rem 0 0;
  overflow-x: auto;
  color: var(--text);
}

/* inline SVG diagram (shared with the two-zone rig artifact) */
.plate-fig {
  --ink: var(--text);
  --border: var(--line);
  --metal: #e7ebef;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
  margin: 1.4rem 0 0;
  overflow-x: auto;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .plate-fig { --metal: #2a3038; }
}
:root[data-theme="dark"] .plate-fig { --metal: #2a3038; }
.plate-fig svg {
  display: block;
  width: 100%;
  max-width: 600px;
  height: auto;
  margin: 0 auto;
}
.plate-fig svg text { font-family: var(--mono); }
.fig-note {
  font-size: 0.83rem;
  color: var(--muted);
  border-left: 2px solid var(--line);
  padding-left: 0.75rem;
  margin: 0.7rem 0 0;
  max-width: 70ch;
}

/* in-text citation markers + reference list */
.cite {
  font-size: 0.82em;
  white-space: nowrap;
}
.cite a { text-decoration: none; }
ol.refs {
  margin: 0.4rem 0 0;
  padding-left: 1.4rem;
  max-width: 74ch;
}
ol.refs li {
  margin: 0.55rem 0;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
}
ol.refs li em { color: var(--muted); font-style: italic; }
ol.refs li:target {
  background: var(--card-bg);
  border-radius: 4px;
  box-shadow: 0 0 0 6px var(--card-bg);
}

.apply {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.3rem 1.15rem;
  margin: 1.3rem 0 0;
}
.apply p { font-size: 0.86rem; color: var(--muted); }
.apply b { color: var(--text); }

.paper .foot {
  margin-top: 3.5rem;
  padding-top: 1.3rem;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.8;
}

/* ---------- narrow screens: sub-nav becomes a top strip ---------- */
@media (max-width: 820px) {
  .proj-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .proj-side {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.25rem 1.1rem;
    padding: 1.1rem 0;
    border-bottom: 1px solid var(--line);
  }
  .proj-side-group { width: 100%; margin-bottom: 0.2rem; }
  .proj-side a,
  .proj-side .soon {
    border-left: none;
    padding: 0.2rem 0;
  }
  .proj-side a.active { border-left: none; text-decoration: underline; }
  .proj-side .proj-side-back { margin-top: 0; width: 100%; }
  .proj-content { padding: 1.75rem 0 4rem; }
}

@media (max-width: 560px) {
  table.grid td { width: 2.5rem; height: 1.8rem; font-size: 0.68rem; }
}
