/* Effective Agents — shared site chrome
   Brand: Ship Outcomes, Not Chat
   Palette: #E10600 / #0A0A0A / #F5F2EB / steel greys
   Spacing: golden ratio φ ≈ 1.618 (8 → 13 → 21 → 34 → 55 → 89)
*/
:root {
  --black: #0A0A0A;
  --ink: #000000;
  --white: #F5F2EB;
  --white-pure: #FFFFFF;
  --red: #E10600;
  --red-deep: #B00000;
  --steel: #A8A29A;
  --steel-dim: #6B6560;
  --steel-light: #D4CFC6;
  --grey-1: #1C1B19;
  --grey-2: #2A2825;
  --grey-3: #3F3C38;

  /* φ scale */
  --phi: 1.618;
  --s1: 0.5rem;    /* 8 */
  --s2: 0.8125rem; /* 13 */
  --s3: 1.3125rem; /* 21 */
  --s4: 2.125rem;  /* 34 */
  --s5: 3.4375rem; /* 55 */
  --s6: 5.5625rem; /* 89 */

  --gutter: clamp(1.25rem, 3vw, 2.125rem);
  --frame-max: 72rem;
  --col: min(38.2rem, 61.8%); /* reading column ≈ 61.8% of max frame feel */
  --col-wide: 48rem;
  --para: var(--s3);
  --sect: var(--s5);
  --font-display: "Inter", "IBM Plex Sans", system-ui, sans-serif;
  --font-sans: "IBM Plex Sans", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", "SF Mono", Consolas, monospace;
  --bg: var(--black);
  --fg: var(--white);
  --fg-strong: var(--white-pure);
  --muted: var(--steel);
  --muted-dim: var(--steel-dim);
  --chip-bg: var(--white);
  --chip-fg: var(--ink);
  --border: rgba(168, 162, 154, 0.28);
  --grain-a: rgba(245, 242, 235, 0.035);
  --grain-b: rgba(0, 0, 0, 0.12);
  --px: 0px;
  --py: 0px;
}

html[data-theme="light"] {
  --bg: var(--white);
  --fg: #1a1816;
  --fg-strong: var(--ink);
  --muted: #5c574f;
  --muted-dim: #8a8378;
  --chip-bg: var(--ink);
  --chip-fg: var(--white);
  --border: rgba(10, 10, 10, 0.18);
  --grain-a: rgba(10, 10, 10, 0.03);
  --grain-b: rgba(245, 242, 235, 0.4);
  --grey-1: #ebe6dc;
  --grey-2: #e0d9cc;
  --grey-3: #cfc7b8;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: clamp(1.0625rem, 0.98rem + 0.35vw, 1.1875rem);
  line-height: 1.62;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

/* Grain overlay */
body::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  opacity: 0.045;
  mix-blend-mode: overlay;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 2px, var(--grain-a) 2px, var(--grain-a) 3px),
    repeating-linear-gradient(90deg, transparent, transparent 3px, var(--grain-b) 3px, var(--grain-b) 4px);
  animation: grain-shift 8s steps(4) infinite;
}

@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-1px, 1px); }
  50% { transform: translate(1px, -1px); }
  75% { transform: translate(-1px, -1px); }
  100% { transform: translate(0, 0); }
}

body::after {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.35);
  opacity: 0.5;
}
html[data-theme="light"] body::after {
  box-shadow: inset 0 0 60px rgba(10, 10, 10, 0.08);
  opacity: 0.7;
}

/* Rule of thirds overlay */
html.show-thirds body > .thirds-grid,
html.show-thirds::after {
  /* pseudo handled via injected element fallback */
}
html.show-thirds::before {
  /* keep grain; add thirds as extra fixed layer via .thirds-overlay */
}
.thirds-overlay {
  display: none;
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 998;
}
html.show-thirds .thirds-overlay {
  display: block;
  background:
    linear-gradient(to right, transparent calc(100% / 3 - 0.5px), rgba(225, 6, 0, 0.22) calc(100% / 3 - 0.5px), rgba(225, 6, 0, 0.22) calc(100% / 3 + 0.5px), transparent calc(100% / 3 + 0.5px)),
    linear-gradient(to right, transparent calc(200% / 3 - 0.5px), rgba(225, 6, 0, 0.22) calc(200% / 3 - 0.5px), rgba(225, 6, 0, 0.22) calc(200% / 3 + 0.5px), transparent calc(200% / 3 + 0.5px)),
    linear-gradient(to bottom, transparent calc(100% / 3 - 0.5px), rgba(225, 6, 0, 0.18) calc(100% / 3 - 0.5px), rgba(225, 6, 0, 0.18) calc(100% / 3 + 0.5px), transparent calc(100% / 3 + 0.5px)),
    linear-gradient(to bottom, transparent calc(200% / 3 - 0.5px), rgba(225, 6, 0, 0.18) calc(200% / 3 - 0.5px), rgba(225, 6, 0, 0.18) calc(200% / 3 + 0.5px), transparent calc(200% / 3 + 0.5px));
}

::selection {
  background: var(--red);
  color: var(--white);
}

a {
  color: var(--red);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease, color 0.15s ease;
}
a:hover { border-bottom-color: var(--red); }
a:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

.page {
  width: min(100%, calc(var(--frame-max) + 2 * var(--gutter)));
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.col {
  max-width: min(var(--col-wide), 61.8vw);
  min-width: min(100%, 20rem);
  margin: 0 auto;
  width: 100%;
}
@media (max-width: 900px) {
  .col { max-width: 100%; }
}
.col-narrow { max-width: 36rem; margin: 0 auto 0 0; }
.col-asymmetric {
  max-width: min(42rem, 61.8%);
  margin-left: max(0px, calc((100% - min(42rem, 61.8%)) * 0.382));
  margin-right: auto;
}

/* Nav */
.site-nav {
  position: relative;
  z-index: 50;
  padding: var(--s3) var(--gutter) var(--s2);
}
.site-nav .inner {
  max-width: calc(var(--frame-max) + 2 * var(--gutter));
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s1) var(--s2);
}
.nav-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.chip {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--chip-fg);
  background: var(--chip-bg);
  border: 1px solid var(--chip-bg);
  padding: 0.4rem 0.75rem;
  border-radius: 0;
  border-bottom: none;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}
.chip:hover {
  filter: brightness(1.08);
  border-bottom: none;
  color: var(--chip-fg);
}
.chip--brand span { color: var(--red); }
.chip--ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.chip--ghost:hover {
  color: var(--fg-strong);
  border-color: var(--muted);
  background: transparent;
}
.chip--active {
  background: var(--red);
  border-color: var(--red);
  color: var(--white-pure);
}
.chip--active:hover { color: var(--white-pure); filter: brightness(1.05); }
.chip--toggle {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Crop marks + asymmetric frame */
.framed {
  position: relative;
  margin: var(--s2) 0 var(--sect);
  padding: var(--s4) var(--s3) var(--s4);
  transform: translate(var(--px), var(--py));
  transition: transform 0.2s ease-out;
}
.framed::before,
.framed::after,
.crop-bl,
.crop-br {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
  pointer-events: none;
}
.framed::before {
  top: 0; left: 0;
  border-top: 2px solid var(--red);
  border-left: 2px solid var(--red);
}
.framed::after {
  top: 0; right: 0;
  border-top: 1px solid var(--muted-dim);
  border-right: 1px solid var(--muted-dim);
}
.framed .crop-bl {
  bottom: 0; left: 0;
  border-bottom: 1px solid var(--muted-dim);
  border-left: 1px solid var(--muted-dim);
}
.framed .crop-br {
  bottom: 0; right: 0;
  border-bottom: 2px solid var(--red);
  border-right: 2px solid var(--red);
}

.label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 var(--s2);
}
.label::before {
  content: "";
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  background: var(--red);
  margin-right: 0.55rem;
  vertical-align: middle;
  transform: translateY(-1px);
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(2.35rem, 1.1rem + 5vw, 5rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.045em;
  margin: 0 0 var(--s3);
  color: var(--fg-strong);
  max-width: 18ch;
}
h1 em { font-style: normal; color: var(--red); font-weight: 700; }

.tagline {
  font-family: var(--font-mono);
  font-size: clamp(0.8rem, 0.72rem + 0.35vw, 0.95rem);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 var(--s4);
}

.lede {
  font-size: 1.08em;
  color: var(--fg);
  max-width: 38rem;
  margin: 0;
  border-left: 3px solid var(--red);
  padding-left: var(--s3);
}

section.block {
  padding: 0 0 var(--sect);
  margin: 0;
  border: none;
  position: relative;
}

.sect-mark {
  position: absolute;
  top: 0;
  right: 0;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: var(--red);
  opacity: 0.7;
}

.ruled {
  position: relative;
  padding-left: var(--s3);
  border-left: 1px solid var(--border);
}

h2 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.15rem);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.03em;
  margin: 0 0 var(--s3);
  color: var(--fg-strong);
}

h3 {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 600;
  margin: var(--s4) 0 var(--s2);
  color: var(--fg-strong);
}

p { margin: 0 0 var(--para); }
p:last-child { margin-bottom: 0; }
strong { font-weight: 600; color: var(--fg-strong); }

blockquote.pull {
  margin: var(--s4) 0 0;
  padding: 0 0 0 var(--s3);
  border-left: 4px solid var(--red);
  font-family: var(--font-display);
  font-size: 1.25em;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg-strong);
  line-height: 1.35;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--s3);
  margin: var(--s4) 0;
}
.card {
  border: 1px solid var(--border);
  padding: var(--s3);
  background: transparent;
  transition: border-color 0.2s ease, transform 0.25s ease;
  position: relative;
}
.card:hover {
  border-color: var(--red);
  transform: translateY(-2px);
}
.card a { border-bottom: none; color: inherit; }
.card a:hover { border-bottom: none; }
.card .meta {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.55rem;
}
.card h3 { margin: 0 0 0.5rem; font-size: 1rem; line-height: 1.3; }
.card p { font-size: 0.9em; color: var(--muted); margin: 0; }

/* Footer */
footer.site-foot {
  padding: var(--s4) var(--gutter) var(--s5);
  border-top: 1px solid var(--border);
  margin-top: var(--s4);
}
footer.site-foot .inner {
  max-width: calc(var(--frame-max) + 2 * var(--gutter));
  margin: 0 auto;
}
.foot-marks {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--s3);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted-dim);
  letter-spacing: 0.15em;
}
.foot-marks .mark-l { color: var(--red); }
.foot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: var(--s3);
}
.foot-chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.04em;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--border);
  padding: 0.45rem 0.7rem;
  border-radius: 0;
  border-bottom: none;
}
.foot-chip:hover {
  border-color: var(--red);
  color: var(--fg-strong);
  border-bottom: none;
}
.foot-meta {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.05em;
  color: var(--muted-dim);
  line-height: 1.7;
}

.hero {
  padding: clamp(var(--s4), 6vw, var(--s6)) 0 var(--s2);
}
.hero h1 {
  /* rule of thirds: visual weight on upper-left third */
  margin-top: var(--s2);
}

.hero-media {
  display: block;
  width: min(100%, 42rem);
  margin: var(--s4) 0 0;
  border: 1px solid var(--border);
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
.hero-media--bleed {
  margin-left: calc(-1 * var(--s3));
  max-width: calc(100% + var(--s3));
}

/* Supporting page art (section figures) — full column, φ margin, hairline */
.page-art,
.section-art,
img.hero-art,
svg.hero-art {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: var(--s4) 0;
  border: 1px solid var(--border);
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
.page-art--narrow {
  width: min(100%, 28rem);
  margin-left: 0;
}
.col.ruled .page-art,
.col.ruled .section-art,
.prose-page .page-art,
.prose-page .section-art {
  margin-top: var(--s4);
  margin-bottom: var(--s4);
}
.hero .hero-media,
.hero .hero-art {
  /* keep under lede */
  width: 100%;
  max-width: 100%;
  margin-top: var(--s4);
}

/* Supporting art: cream plates read on both themes via border token */
html[data-theme="light"] img.hero-art,
html[data-theme="light"] img.section-art,
html[data-theme="light"] .page-art {
  border-color: rgba(10, 10, 10, 0.22);
  box-shadow: 0 1px 0 rgba(10, 10, 10, 0.04);
}
html[data-theme="dark"] img.hero-art,
html[data-theme="dark"] img.section-art,
html[data-theme="dark"] .page-art,
:root:not([data-theme="light"]) img.hero-art,
:root:not([data-theme="light"]) img.section-art {
  border-color: rgba(245, 242, 235, 0.14);
}



.ambient-dock {
  position: fixed;
  bottom: var(--s3);
  right: var(--s3);
  z-index: 1100;
  display: flex;
  gap: 0.35rem;
  opacity: 0.85;
}
.ambient-dock:hover { opacity: 1; }

/* Plain-text mode */
html.plain-text body::before,
html.plain-text body::after,
html.plain-text .thirds-overlay { display: none !important; }
html.plain-text {
  --bg: #fff !important;
  --fg: #000 !important;
  --fg-strong: #000 !important;
  --muted: #333 !important;
  --muted-dim: #555 !important;
  --chip-bg: #000 !important;
  --chip-fg: #fff !important;
  --border: #999 !important;
  --red: #000 !important;
}
html.plain-text body {
  font-family: "Courier New", Courier, monospace !important;
  font-size: 16px !important;
  line-height: 1.5 !important;
  max-width: 72ch;
  margin: 0 auto;
  background: #fff !important;
  color: #000 !important;
}
html.plain-text .chip,
html.plain-text .card,
html.plain-text .framed {
  border: 1px solid #000 !important;
  background: #fff !important;
  color: #000 !important;
  box-shadow: none !important;
  transform: none !important;
}
html.plain-text .ambient-dock,
html.plain-text .grain-hide-plain,
html.plain-text .cookie-banner,
html.plain-text .sect-mark { display: none !important; }
html.plain-text h1, html.plain-text h2, html.plain-text h3 {
  font-family: inherit !important;
  letter-spacing: 0 !important;
  color: #000 !important;
  max-width: none;
}
html.plain-text a { color: #000 !important; text-decoration: underline; border: none !important; }
html.plain-text .lede { border-left-color: #000; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: var(--s3) 0 var(--s4);
  align-items: center;
}
.input-search {
  flex: 1 1 180px;
  min-width: 140px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
}
.input-search:focus {
  outline: 2px solid var(--red);
  outline-offset: 2px;
  border-color: var(--red);
}
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  padding: 0.2rem 0.45rem;
  color: var(--muted);
  margin-right: 0.25rem;
}
.badge--red { border-color: var(--red); color: var(--red); }
.pin-btn {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
}
.pin-btn.pinned {
  border-color: var(--red);
  color: var(--red);
}
.card.pinned { border-color: var(--red); }

/* ——— Game V1 (Agent Ops 1987) ——— */
.game-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--s3);
}
.game-stats strong { color: var(--red); font-weight: 500; }

.game-stage {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  border: 2px solid var(--red);
  padding: var(--s3);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  min-height: 280px;
  background: #050505;
  color: #e8e4dc;
  position: relative;
  overflow: visible;
  z-index: 1;
}
html[data-theme="light"] .game-stage {
  background: #12100e;
  color: #f0ebe3;
}
.game-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(225, 6, 0, 0.03) 3px,
    rgba(225, 6, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 0;
}
.game-log {
  white-space: pre-wrap;
  margin: 0;
  line-height: 1.55;
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  max-height: min(42vh, 22rem);
  overflow-y: auto;
  padding-right: var(--s1);
}
.game-log .prompt { color: var(--red); }

.game-choices {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: var(--s2);
  position: relative;
  z-index: 3;
  flex: 0 0 auto;
  margin-top: auto;
  padding-top: var(--s2);
  border-top: 1px solid rgba(225, 6, 0, 0.35);
  background: #050505;
}
html[data-theme="light"] .game-choices {
  background: #12100e;
}
.game-choice {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--grey-1);
  border: 1px solid var(--steel-light);
  color: #f5f2eb;
  font-family: var(--font-mono);
  font-size: clamp(0.75rem, 0.7rem + 0.4vw, 0.85rem);
  line-height: 1.35;
  padding: var(--s2) var(--s3);
  cursor: pointer;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  position: relative;
  z-index: 4;
  appearance: none;
  -webkit-appearance: none;
}
.game-choice:hover,
.game-choice:focus-visible {
  border-color: var(--red);
  color: var(--white-pure);
  background: #1a0808;
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

/* Cookie banner */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1200;
  background: var(--bg);
  border-top: 2px solid var(--red);
  padding: var(--s3) var(--gutter);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
}
.cookie-banner__inner {
  max-width: calc(var(--frame-max) + 2 * var(--gutter));
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}
.cookie-banner p {
  margin: 0;
  flex: 1 1 16rem;
  font-size: 0.9em;
  color: var(--muted);
}
.cookie-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

/* Legal */
.legal-block {
  margin-bottom: var(--s5);
  scroll-margin-top: var(--s4);
}
.legal-block h2 { border-left: 4px solid var(--red); padding-left: var(--s2); }

/* Blog */
.prose .worry {
  border-left: 3px solid var(--red);
  padding-left: var(--s3);
  margin: var(--s4) 0;
  color: var(--muted);
}
.prose img, .prose svg.hero-art {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  margin: var(--s4) 0;
  border: 1px solid var(--border);
}
.audio-bar {
  margin: var(--s3) 0 var(--s4);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.audio-bar audio { display: block; margin-top: 0.5rem; width: min(100%, 360px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .framed { transform: none !important; }
  body::before { animation: none; }
}

@media (max-width: 640px) {
  :root { --gutter: 1.25rem; }
  .nav-cluster--links { display: none; }
  .framed { padding: var(--s3) var(--s2) var(--s3); }
  .ruled { padding-left: var(--s2); }
  .ambient-dock { bottom: 0.65rem; right: 0.65rem; }
  .game-log { max-height: 36vh; }
  .col-asymmetric { margin-left: 0; max-width: 100%; }
}
