/* =========================================================================
   Rigward — editorial design system.
   Same warm-paper bones as TimeBaQ / LessAlone; cobalt-steel accent so it
   reads "machine room" instead of "café." Candlelight dark mode for the
   late-night terminal crowd.
   ========================================================================= */

:root {
  /* Warm paper palette */
  --bg-base: #faf8f4;
  --bg-surface: #ffffff;
  --bg-overlay: #f3efe7;
  --bg-hover: #eeeae1;

  --text-primary: #1a2340;
  --text-secondary: #525d7a;
  --text-tertiary: #666d80;
  --text-heading: #12192d;
  --text-on-accent: #ffffff;

  --border-default: #e7e4dc;
  --border-subtle: #efece4;
  --border-strong: #c8c2b4;

  /* Accent — cobalt steel, the Rigward distinction */
  --accent-primary: #1e3a5f;
  --accent-primary-hover: #16304f;
  --accent-secondary: #3498db; /* Rigward's app seed color */

  --steel: #4a6f8a;
  --steel-wash: #e9eff5;
  --amber: #c89a54;
  --amber-wash: #faf6f0;

  --card-bg: #ffffff;
  --card-border: #ece8de;

  --display: 'Fraunces', ui-serif, Georgia, 'Times New Roman', serif;
  --body: 'Hanken Grotesk', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  color-scheme: light;
}

[data-theme='dark'] {
  /* Candlelight dark — warm, low-glare, terminal-friendly */
  --bg-base: #171310;
  --bg-surface: #221c16;
  --bg-overlay: #2a221a;
  --bg-hover: #2d2519;

  --text-primary: #ebe3d1;
  --text-secondary: #a8a08d;
  --text-tertiary: #9c937e;
  --text-heading: #fcf6e8;
  --text-on-accent: #1a1410;

  --border-default: #2f271c;
  --border-subtle: #251e15;
  --border-strong: #443827;

  --accent-primary: #7ab4e4;
  --accent-primary-hover: #92c3eb;
  --accent-secondary: #c89970;

  --steel: #7aabdf;
  --steel-wash: #1e2c4a;
  --amber: #d4aa6f;
  --amber-wash: #3d2e18;

  --card-bg: #221c16;
  --card-border: #2a221a;

  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg-base: #171310;
    --bg-surface: #221c16;
    --bg-overlay: #2a221a;
    --text-primary: #ebe3d1;
    --text-secondary: #a8a08d;
    --text-tertiary: #9c937e;
    --text-heading: #fcf6e8;
    --text-on-accent: #1a1410;
    --border-default: #2f271c;
    --border-subtle: #251e15;
    --border-strong: #443827;
    --accent-primary: #7ab4e4;
    --accent-primary-hover: #92c3eb;
    --accent-secondary: #c89970;
    --card-bg: #221c16;
    --card-border: #2a221a;
  }
}

/* ── reset / base ──────────────────────────────────────────────── */

* {
  box-sizing: border-box;
  margin: 0;
}

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

body {
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-base);
  background-image:
    radial-gradient(64rem 42rem at 82% -10%, rgba(30, 58, 95, 0.06), transparent 70%),
    radial-gradient(54rem 40rem at 6% 4%, rgba(52, 152, 219, 0.05), transparent 72%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

[data-theme='dark'] body {
  background-image:
    radial-gradient(64rem 42rem at 82% -10%, rgba(122, 180, 228, 0.05), transparent 70%),
    radial-gradient(54rem 40rem at 6% 4%, rgba(200, 153, 112, 0.05), transparent 72%);
}

a {
  color: var(--accent-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 120ms ease;
}

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

a:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 3px;
  border-radius: 2px;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--bg-overlay);
  padding: 0.08em 0.4em;
  border-radius: 4px;
  color: var(--text-heading);
  border: 1px solid var(--border-subtle);
}

em {
  font-style: italic;
  color: var(--text-heading);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
}
.skip:focus {
  left: 1rem;
  top: 1rem;
  background: var(--accent-primary);
  color: var(--text-on-accent);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  z-index: 99;
}

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

.container {
  max-width: 78ch;
  margin: 0 auto;
  padding: 0 1.5rem;
}

@media (min-width: 760px) {
  .container {
    padding: 0 2rem;
  }
}

/* ── masthead ──────────────────────────────────────────────────── */

.masthead {
  padding: 2rem 1.5rem 0.75rem;
  text-align: center;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-base);
}

.masthead-row {
  max-width: 78ch;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  text-transform: uppercase;
}

.masthead-meta {
  flex: 1;
  text-align: left;
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.wordmark {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(3.5rem, 11vw, 6.5rem);
  letter-spacing: -0.03em;
  color: var(--text-heading);
  line-height: 0.95;
  margin: 0;
  font-feature-settings: 'ss01';
}

.rule {
  width: 2.5rem;
  height: 1px;
  background: var(--border-strong);
  margin: 1.5rem auto 0;
}

/* ── hero ──────────────────────────────────────────────────────── */

.hero {
  padding: 4rem 1.5rem 5rem;
  text-align: center;
}

.kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 2rem;
}

.kicker-vol::before {
  content: '⁂';
  margin-right: 0.6rem;
  color: var(--accent-secondary);
  font-size: 1.05em;
}

.hero-h1 {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.4rem, 6.5vw, 4.4rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--text-heading);
  margin: 0 auto 1.75rem;
  max-width: 22ch;
  font-feature-settings: 'ss01';
}

.hero-h1 em {
  font-style: italic;
  color: var(--accent-primary);
  font-weight: 500;
}

.hero-deck {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.1rem, 2vw, 1.32rem);
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 56ch;
  margin: 0 auto 2.5rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.9rem;
  margin-bottom: 2.5rem;
}

.btn-primary,
.btn-secondary {
  font-family: var(--body);
  font-size: 0.98rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  padding: 0.78rem 1.6rem;
  border-radius: 999px;
  text-decoration: none;
  display: inline-block;
  transition: all 160ms ease;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--text-on-accent);
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  color: var(--text-on-accent);
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.hero-trust {
  font-size: 0.92rem;
  color: var(--text-tertiary);
  margin-bottom: 3rem;
  line-height: 1.7;
}

.mono {
  font-family: var(--mono);
  font-size: 0.84em;
  letter-spacing: 0.02em;
}

/* ── chapter index ─────────────────────────────────────────────── */

.chap-index {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  max-width: 48rem;
  margin: 0 auto;
  border-top: 1px solid var(--border-default);
  border-left: 1px solid var(--border-default);
}

@media (min-width: 720px) {
  .chap-index {
    grid-template-columns: repeat(4, 1fr);
  }
}

.chap-index a {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 1rem 1.2rem;
  text-decoration: none;
  color: var(--text-secondary);
  border-right: 1px solid var(--border-default);
  border-bottom: 1px solid var(--border-default);
  transition: all 150ms ease;
  text-align: left;
}

.chap-index a:hover {
  background: var(--bg-overlay);
  color: var(--accent-primary);
}

.idx-num {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--accent-primary);
  font-weight: 500;
}

.idx-title {
  font-family: var(--display);
  font-size: 0.96rem;
}

/* ── sections ──────────────────────────────────────────────────── */

.section {
  padding: 5rem 1.5rem 4rem;
  border-top: 1px solid var(--border-default);
}

.section--paper {
  background: var(--bg-overlay);
}

.section-marker {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-default);
  flex-wrap: wrap;
}

.section-marker .roman {
  font-family: var(--display);
  font-weight: 600;
  font-style: italic;
  font-size: 2rem;
  color: var(--accent-primary);
  line-height: 1;
}

.section-marker .label {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.section-marker .dot {
  color: var(--accent-secondary);
}

/* ── pact grid ─────────────────────────────────────────────────── */

.pact-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-bottom: 3rem;
}

@media (min-width: 760px) {
  .pact-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.pact-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 1.75rem 1.65rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02), 0 6px 22px rgba(26, 35, 64, 0.04);
}

.pact-card--inverted {
  background: var(--accent-primary);
  color: var(--bg-base);
  border-color: var(--accent-primary);
}

.pact-card--inverted .pact-h,
.pact-card--inverted em,
.pact-card--inverted code {
  color: var(--bg-base);
}

.pact-card--inverted code {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
}

.pact-h {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.35rem;
  line-height: 1.25;
  color: var(--text-heading);
  margin-bottom: 0.85rem;
  letter-spacing: -0.01em;
}

.pact-h em {
  color: var(--accent-primary);
  font-weight: 500;
}

.pact-card p {
  font-size: 0.98rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

.pact-card--inverted p {
  color: rgba(255, 255, 255, 0.85);
}

/* ── pull quote ────────────────────────────────────────────────── */

.pullquote {
  max-width: 50ch;
  margin: 3rem auto 0;
  padding: 1.5rem 1rem;
  border-top: 1px solid var(--border-default);
  border-bottom: 1px solid var(--border-default);
  text-align: center;
}

.pullquote blockquote p {
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(1.25rem, 2.4vw, 1.65rem);
  line-height: 1.4;
  color: var(--text-heading);
  font-weight: 400;
}

.pullquote em {
  color: var(--accent-primary);
  font-weight: 500;
}

.pullquote::before {
  content: '⁂';
  display: block;
  color: var(--accent-secondary);
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  letter-spacing: 0.2em;
}

/* ── ledger spread ─────────────────────────────────────────────── */

.ledger-spread {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
}

@media (min-width: 860px) {
  .ledger-spread {
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
  }
}

.essay p {
  font-family: var(--display);
  font-size: 1.06rem;
  line-height: 1.65;
  color: var(--text-secondary);
  margin-bottom: 1.1rem;
}

.drop {
  float: left;
  font-family: var(--display);
  font-weight: 600;
  font-size: 3.6rem;
  line-height: 0.85;
  padding: 0.35rem 0.5rem 0 0;
  color: var(--accent-primary);
  font-feature-settings: 'ss01';
}

.ledger-table {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ledger-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  padding: 1.1rem 0;
  border-top: 1px solid var(--border-default);
}

.ledger-row:last-child {
  border-bottom: 1px solid var(--border-default);
}

.ledger-num {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.4rem;
  color: var(--accent-primary);
  line-height: 1;
  padding-top: 0.1rem;
  font-weight: 500;
}

.ledger-row h4 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.08rem;
  color: var(--text-heading);
  margin-bottom: 0.35rem;
}

.ledger-row p {
  font-size: 0.96rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ── stack list ────────────────────────────────────────────────── */

.stack-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin-bottom: 3rem;
}

@media (min-width: 720px) {
  .stack-list {
    grid-template-columns: 8rem 1fr;
    gap: 0 2rem;
  }
}

.stack-list dt {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-primary);
  padding: 1.1rem 0 0.25rem;
  border-top: 1px solid var(--border-default);
  font-weight: 500;
}

.stack-list dd {
  font-family: var(--display);
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--text-secondary);
  padding: 0 0 1.1rem;
  margin: 0;
}

@media (min-width: 720px) {
  .stack-list dd {
    padding: 1.1rem 0;
    border-top: 1px solid var(--border-default);
  }
}

.stack-list dd:last-child,
.stack-list dt:last-of-type + dd {
  border-bottom: 1px solid var(--border-default);
}

/* ── "what we are not" ─────────────────────────────────────────── */

.not-spread {
  margin-top: 3rem;
  padding: 2rem;
  background: var(--steel-wash);
  border-left: 3px solid var(--steel);
  border-radius: 0 14px 14px 0;
}

.not-heading {
  font-family: var(--display);
  font-style: italic;
  font-weight: 500;
  font-size: 1.35rem;
  color: var(--text-heading);
  margin-bottom: 1.25rem;
}

.not-heading em {
  color: var(--accent-primary);
}

.not-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.not-list li {
  font-size: 0.98rem;
  line-height: 1.6;
  color: var(--text-secondary);
  padding-left: 1.4rem;
  position: relative;
}

.not-list li::before {
  content: '×';
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--accent-primary);
  line-height: 1;
}

.not-list strong {
  color: var(--text-heading);
  font-weight: 600;
  font-family: var(--display);
}

/* ── price grid ────────────────────────────────────────────────── */

.price-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

@media (min-width: 760px) {
  .price-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.price-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 1.85rem 1.7rem;
  display: flex;
  flex-direction: column;
}

.price-card--pro {
  border-color: var(--accent-primary);
  border-width: 1.5px;
}

.price-h {
  font-family: var(--display);
  font-weight: 600;
  font-style: italic;
  font-size: 1.7rem;
  color: var(--accent-primary);
  margin-bottom: 0.6rem;
}

.price-deck {
  font-family: var(--display);
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.price-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.price-list li {
  font-size: 0.95rem;
  color: var(--text-secondary);
  padding-left: 1.25rem;
  position: relative;
  line-height: 1.5;
}

.price-list li::before {
  content: '·';
  position: absolute;
  left: 0.35rem;
  top: -0.3rem;
  color: var(--accent-secondary);
  font-size: 1.5rem;
  line-height: 1;
}

.price-note {
  font-family: var(--display);
  font-size: 1rem;
  text-align: center;
  color: var(--text-tertiary);
  margin-top: 1rem;
  line-height: 1.5;
}

/* ── CTA ───────────────────────────────────────────────────────── */

.cta {
  padding: 5rem 1.5rem;
  text-align: center;
  border-top: 1px solid var(--border-default);
}

.cta-h {
  font-family: var(--display);
  font-weight: 500;
  font-style: italic;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.1;
  color: var(--text-heading);
  margin-bottom: 1rem;
  letter-spacing: -0.015em;
}

.cta-deck {
  font-family: var(--display);
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 50ch;
  margin: 0 auto 2rem;
  line-height: 1.55;
}

/* ── colophon ──────────────────────────────────────────────────── */

.colophon {
  background: var(--bg-overlay);
  padding: 2.5rem 0 3rem;
  border-top: 1px solid var(--border-default);
  text-align: center;
}

.colophon-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.86rem;
  color: var(--text-tertiary);
  line-height: 1.6;
}

.colophon-row:not(:last-child) {
  margin-bottom: 0.8rem;
}

.colophon-links a {
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px dotted var(--border-strong);
  padding-bottom: 1px;
}

.colophon-links a:hover {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.rule-tiny {
  display: inline-block;
  width: 1.25rem;
  height: 1px;
  background: var(--border-strong);
}

/* ── reduced motion ────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
