/* The AEGIS Directive -- shared stylesheet. See docs/aegis-website-build.md #4 for the
   design-language rationale: leaked programme documentation, not tactical-gaming dark mode. */

:root {
  --ground: #0E1418;
  --surface: #151D23;
  --surface-2: #1C262D;
  --line: #2A363E;
  --ink: #DCE3E7;
  --ink-muted: #8496A0;
  --accent: #D08B2C;
  --hazard: #C05F47;
  --ok: #6E9A72;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --ground: #D9D8D1;
    --surface: #E6E5DE;
    --surface-2: #CDCCC3;
    --line: #B7B6AB;
    --ink: #1B2126;
    --ink-muted: #59636C;
    --accent: #96600F;
    --hazard: #8C3B28;
    --ok: #46663F;
  }
}

:root[data-theme="light"] {
  --ground: #D9D8D1;
  --surface: #E6E5DE;
  --surface-2: #CDCCC3;
  --line: #B7B6AB;
  --ink: #1B2126;
  --ink-muted: #59636C;
  --accent: #96600F;
  --hazard: #8C3B28;
  --ok: #46663F;
}

:root[data-theme="dark"] {
  --ground: #0E1418;
  --surface: #151D23;
  --surface-2: #1C262D;
  --line: #2A363E;
  --ink: #DCE3E7;
  --ink-muted: #8496A0;
  --accent: #D08B2C;
  --hazard: #C05F47;
  --ok: #6E9A72;
}

* { box-sizing: border-box; }

html { background: var(--ground); }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: 'Spectral', Georgia, 'Times New Roman', serif;
  font-size: 17px;
  line-height: 1.65;
}

h1, h2, h3, .brand-name, .navlink {
  font-family: 'Saira Condensed', 'Arial Narrow', sans-serif;
  font-weight: 700;
  letter-spacing: 0.01em;
}

code, .mono, .classbar, .doc-code, .tag {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
}

a { color: var(--accent); }

/* ---------- masthead ---------- */
.masthead {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.masthead-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  margin-right: auto;
}
.brand-mark { color: var(--accent); display: flex; }
.brand-mark svg { display: block; width: 21px; height: 21px; }
.brand-name { font-size: 1.15rem; text-transform: uppercase; }

.sitenav {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.navlink {
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}
.navlink:hover { color: var(--ink); }
.navlink[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink-muted);
  width: 30px;
  height: 30px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 14px;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-muted); }

/* ---------- classification bar ---------- */
.classbar {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 6px 24px;
  display: flex;
  justify-content: space-between;
  max-width: 1120px;
  margin: 0 auto;
}
.classbar-code { color: var(--accent); }

/* ---------- document body ---------- */
.doc {
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}
.doc > .measure { max-width: 66ch; }

.doc h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  text-transform: uppercase;
  margin: 0 0 8px;
}
.doc .kicker {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}
.doc .kicker::before { content: "\00a7 "; color: var(--ink-muted); }

.doc section { margin-top: 56px; padding-top: 40px; border-top: 1px solid var(--line); }
.doc section:first-of-type { margin-top: 40px; }
.doc h2 {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  text-transform: uppercase;
  margin: 0 0 20px;
}
.doc p { max-width: 66ch; color: var(--ink); }
.doc p.dim { color: var(--ink-muted); }

.doc table {
  border-collapse: collapse;
  width: 100%;
  margin: 20px 0;
  font-size: 0.95rem;
}
.doc th, .doc td {
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--line);
  vertical-align: top;
}
.doc th {
  background: var(--surface);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.callout {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  background: var(--surface);
  padding: 16px 20px;
  margin: 24px 0;
}
.callout.hazard { border-left-color: var(--hazard); }
.callout.ok { border-left-color: var(--ok); }
.callout p:last-child { margin-bottom: 0; }

/* ---------- faction / info cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin: 24px 0;
}
.card {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 20px;
}
/* Faction marks -- one 100-unit grid, one stroke weight, currentColor so they
   follow the theme accent. See docs/aegis-website-build.md. */
.card .mark {
  display: block;
  width: 34px;
  height: 34px;
  margin-bottom: 14px;
  color: var(--accent);
}
.card.redacted .mark { color: var(--hazard); }

.card .tag {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 10px;
}
.card h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  text-transform: uppercase;
}
.card p { font-size: 0.92rem; color: var(--ink-muted); margin: 0; }

/* ---------- rule cards (start page; native <details>, no JS) ---------- */
/* Collapsed by default. Add the `open` attribute to a <details> to show it expanded. */
.rule-cards {
  display: grid;
  gap: 10px;
  max-width: 66ch; /* same measure as the page's running text */
  margin: 18px 0 0;
}
.rule-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  background: var(--surface);
}
.rule-card[open] { border-left-color: var(--accent); }
.rule-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.rule-card summary::-webkit-details-marker { display: none; }
.rule-card summary::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}
.rule-card[open] summary::after { transform: rotate(-135deg); margin-top: 4px; }
.rule-card summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rule-card p { margin: 0; padding: 0 18px 16px; }
@media (prefers-reduced-motion: reduce) {
  .rule-card summary::after { transition: none; }
}

/* ---------- redaction (content, not decoration -- see build.py doc rule #2) ---------- */
.card.redacted {
  border: 1px dashed var(--hazard);
}
.card.redacted h3 { color: var(--hazard); }
.redact-bar {
  display: inline-block;
  background: var(--ink);
  color: transparent;
  border-radius: 1px;
  user-select: none;
}

/* ---------- placeholders -- see build.py doc #6, never ship a fabricated fact ---------- */
[data-placeholder], .tbc {
  display: inline-block;
  border: 1px dashed var(--hazard);
  color: var(--hazard);
  padding: 1px 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85em;
  border-radius: 2px;
}

/* ---------- connect widget (server-connect, Session 5) ---------- */
.connect-widget {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 20px;
  margin: 20px 0 8px;
  max-width: 66ch;
}
.connect-widget-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.connect-widget-row + .connect-widget-row { margin-top: 12px; }
.connect-widget-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.connect-widget-ip {
  font-size: 1.05rem;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 2px;
}
.connect-widget-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 6px 14px;
  border-radius: 2px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  line-height: 1.2;
}
.connect-widget-btn:hover { border-color: var(--accent); color: var(--accent); }
.connect-widget-note { margin: 14px 0 0; font-size: 0.85rem; }

@media (max-width: 640px) {
  .connect-widget-row { flex-direction: column; align-items: stretch; }
  .connect-widget-btn { text-align: center; }
}

/* ---------- footer ---------- */
.sitefoot {
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.sitefoot-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--ink-muted);
}

@media (max-width: 640px) {
  .masthead-inner { flex-wrap: wrap; }
  .sitenav { order: 3; width: 100%; gap: 14px; }
  .classbar { flex-direction: column; gap: 2px; }
}

/* ---------- donate fallback link (/fund/) ---------- */
/* Visible by default so a visitor whose blocker stops PayPal's script still has a way to
   donate. The page's own script sets [hidden] once the real button has drawn. */
#donate-fallback { margin: 12px 0 4px; }
#donate-fallback[hidden] { display: none; }
