/* ==========================================================================
   The Tenets — living constitution
   Breaks from site chrome: serif body (Cardo), small-caps display (Cormorant SC).
   ========================================================================== */

:root {
  --tn-bg: #0a0a12;
  --tn-bg-soft: #0e0e18;
  --tn-ink: #d8d4c8;
  --tn-ink-bright: #f0ebdd;
  --tn-ink-dim: #8a8476;
  --tn-rule: #2a2738;
  --tn-violet: #9933ff;
  --tn-blue: #3388ff;
  --tn-green: #33cc55;
  --tn-orange: #ffbb33;
  --tn-red: #ff3333;
  --tn-gold: #c9a960;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--tn-bg);
  color: var(--tn-ink);
}

body {
  font-family: 'Cardo', Georgia, 'Times New Roman', serif;
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-nav {
  position: absolute; top: -40px; left: 0;
  background: var(--tn-ink-bright); color: var(--tn-bg);
  padding: 8px 16px; z-index: 100;
  text-decoration: none;
  font-family: 'Cormorant SC', serif;
  letter-spacing: 0.08em;
}
.skip-nav:focus { top: 0; }

/* ─── Header ──────────────────────────────────────────────────────── */

.tenets-header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 20px 32px;
  border-bottom: 1px solid var(--tn-rule);
  background: var(--tn-bg);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--tn-ink);
  text-decoration: none;
  font-family: 'Cormorant SC', serif;
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  transition: color 0.2s;
}
.back-link:hover { color: var(--tn-ink-bright); }
.back-link svg { display: block; }

/* ─── Main layout ─────────────────────────────────────────────────── */

.tenets-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 32px 120px;
}

/* ─── Preamble (overlay) ──────────────────────────────────────────── */

.preamble-overlay {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, 52%);
  text-align: center;
  pointer-events: none;
  z-index: 1;
}
.preamble-overlay > * { pointer-events: auto; }

.tenets-title {
  font-family: 'Cormorant SC', serif;
  font-weight: 500;
  font-size: clamp(2.2rem, 4.4vw, 3.4rem);
  letter-spacing: 0.16em;
  color: var(--tn-ink-bright);
  margin: 0 0 10px;
  line-height: 1.1;
}

.tenets-kicker {
  font-family: 'Cardo', serif;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--tn-ink-dim);
  margin: 0 0 28px;
  letter-spacing: 0.02em;
}

.preamble {
  font-size: 0.89rem;
  line-height: 1.45;
  color: var(--tn-ink);
  margin: 0 auto;
  text-align: left;
  max-width: 520px;
}

/* ─── Organ ───────────────────────────────────────────────────────── */

.organ-section {
  position: relative;
  margin: 0 0 120px;
}

.organ-stage {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

.organ-svg {
  width: 100%;
  height: auto;
  display: block;
  margin-top: 65px;
  filter: drop-shadow(0 20px 40px rgba(0,0,0,0.4));
  /* Reserve space before the viewBox is set by JS, so the overlay doesn't
     jump when the tenets API returns. Ratio matches the final organ. */
  aspect-ratio: 1571 / 664;
}

.organ-legend {
  text-align: center;
  font-family: 'Cardo', serif;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--tn-ink-dim);
  margin: 24px 0 0;
}

/* Pipe interactions */
.pipe-group { cursor: pointer; }
.pipe-group .pipe-body { transition: filter 0.18s; }
.pipe-group:hover .pipe-body {
  filter: brightness(1.3) drop-shadow(0 0 8px currentColor);
}
.pipe-group:focus { outline: none; }
.pipe-group:focus .pipe-body {
  filter: brightness(1.4) drop-shadow(0 0 10px currentColor);
}

.pillar-label {
  font-family: 'Cormorant SC', serif;
  font-weight: 500;
  letter-spacing: 0.18em;
  fill: var(--tn-ink-dim);
}

/* ─── Pipe tooltip ────────────────────────────────────────────── */

.pipe-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  padding: 6px 12px;
  background: #0a0a12;
  border: 1px solid var(--tier-color, var(--tn-rule));
  border-radius: 4px;
  font-family: 'Cormorant SC', serif;
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: 0.16em;
  color: var(--tn-ink-bright);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity 0.15s ease-out;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.pipe-tooltip.visible {
  opacity: 1;
}

.organ-base {
  fill: #0a0a14;
  stroke: var(--tn-rule);
  stroke-width: 1;
}

/* ─── Chambers ────────────────────────────────────────────────────── */

.chambers {
  display: flex;
  flex-direction: column;
  gap: 80px;
  max-width: 820px;
  margin: 0 auto;
}

.chamber {
  position: relative;
  padding-left: 32px;
  border-left: 1px solid var(--tier-color, var(--tn-rule));
  scroll-margin-top: 40px;
}

.chamber-label {
  font-family: 'Cormorant SC', serif;
  font-weight: 600;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  letter-spacing: 0.18em;
  color: var(--tn-ink-bright);
  margin: 0 0 4px;
  line-height: 1;
}

.chamber-definition {
  font-family: 'Cardo', serif;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--tn-ink-dim);
  margin: 0 0 32px;
  max-width: 620px;
}

.tenet {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 20px;
  padding: 20px 16px;
  border-top: 1px solid var(--tn-rule);
  scroll-margin-top: 80px;
  border-radius: 4px;
}
.tenet:first-of-type { border-top: none; padding-top: 8px; }

.tenet-number {
  font-family: 'Cormorant SC', serif;
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--tier-color, var(--tn-ink-dim));
  letter-spacing: 0.06em;
  padding-top: 2px;
  white-space: nowrap;
}

/* ─── Jump-to-tenet flash — persistent whiteish wash that fades, like
       Chrome's scroll-to-text anchor highlight but in white, not yellow. */

.tenet.flash {
  animation: tenetAnchorFlash 2.2s ease-out forwards;
}

@keyframes tenetAnchorFlash {
  0%   { background-color: rgba(255, 255, 255, 0.22); }
  30%  { background-color: rgba(255, 255, 255, 0.22); }
  100% { background-color: transparent; }
}

.tenet-body {
  /* Chad-quote font: system UI stack, big block letters — without the all-caps */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 1.32rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--tn-ink-bright);
}

.chamber-note {
  margin: 40px 0 0;
  padding: 20px 24px;
  background: var(--tn-bg-soft);
  border-left: 2px solid var(--tier-color, var(--tn-rule));
}

.chamber-note-title {
  font-family: 'Cormorant SC', serif;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.14em;
  color: var(--tn-ink-bright);
  margin: 0 0 10px;
}

.chamber-note-body {
  font-family: 'Cardo', serif;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--tn-ink);
  margin: 0;
}

/* ─── Procedural ──────────────────────────────────────────────────── */

.procedural {
  max-width: 820px;
  margin: 120px auto 0;
  padding-top: 60px;
  border-top: 1px solid var(--tn-rule);
}

.procedural-heading {
  font-family: 'Cormorant SC', serif;
  font-weight: 500;
  letter-spacing: 0.18em;
  font-size: 1.6rem;
  color: var(--tn-ink-bright);
  margin: 0 0 8px;
  text-align: center;
}

.procedural-kicker {
  font-family: 'Cardo', serif;
  font-style: italic;
  color: var(--tn-ink-dim);
  text-align: center;
  margin: 0 0 48px;
}

.procedural-block {
  margin: 0 0 56px;
}

.procedural-block-title {
  font-family: 'Cormorant SC', serif;
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: 0.14em;
  color: var(--tn-ink-bright);
  margin: 0 0 16px;
}

.procedural-block-body {
  font-family: 'Cardo', serif;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--tn-ink);
  margin: 0 0 14px;
}

.procedural-block-body strong { color: var(--tn-ink-bright); font-weight: 700; }

.procedural-list {
  margin: 14px 0;
  padding: 0 0 0 24px;
}

.procedural-list li {
  font-family: 'Cardo', serif;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--tn-ink);
  margin: 0 0 8px;
}

/* ─── See-also (subtle link to Amendments) ──────────────────────── */

.tenets-see-also {
  text-align: center;
  font-family: 'Cardo', serif;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--tn-ink-dim);
  margin: 80px auto 0;
  max-width: 520px;
}
.tenets-see-also a {
  color: var(--tn-ink);
  text-decoration: none;
  border-bottom: 1px solid var(--tn-rule);
  transition: color 0.2s, border-color 0.2s;
}
.tenets-see-also a:hover {
  color: var(--tn-ink-bright);
  border-bottom-color: var(--tn-gold);
}

/* ─── Footer ──────────────────────────────────────────────────────── */

.tenets-footer {
  margin: 40px auto 0;
  padding-top: 40px;
  border-top: 1px solid var(--tn-rule);
  text-align: center;
}

.footer-note {
  font-family: 'Cormorant SC', serif;
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  color: var(--tn-ink-dim);
  margin: 0;
}

/* ─── Mobile ──────────────────────────────────────────────────────── */

@media (max-width: 860px) {
  /* On narrow screens the overlay has no breathing room between the
     bookend pillars, so drop it back above the organ as a stacked block. */
  .preamble-overlay {
    position: static;
    transform: none;
    width: 100%;
    max-width: 680px;
    margin: 0 auto 48px;
  }
}

@media (max-width: 640px) {
  .tenets-main { padding: 48px 20px 80px; }
  .organ-section { margin-bottom: 72px; }
  .chambers { gap: 56px; }
  .tenet { grid-template-columns: 56px 1fr; gap: 14px; padding: 16px 10px; }
  .tenet-body { font-size: 1rem; }
  .chamber { padding-left: 20px; }
  .procedural { margin-top: 80px; }
}
