/* ==========================================================================
   THE AUTONOMOUS ENGINEER — Swiss Editorial Stylesheet
   Palette synced 1:1 with book/cover/cover-b-swiss-editorial.svg
   ========================================================================== */

:root {
  --paper: #F5F3EE;
  --paper-alt: #ECE9E1;
  --white: #FFFFFF;
  --ink: #111827;
  --ink-muted: #374151;
  --ink-subtle: #6B7280;
  --slate-950: #0F172A;
  --slate-800: #1E293B;
  --slate-700: #334155;
  --slate-400: #94A3B8;
  --teal: #0F766E;
  --teal-bright: #14B8A6;
  --teal-light: #5EEAD4;
  --vermilion: #DC4C2E;
  --vermilion-dark: #B93A20;
  --rule: #D6D3CB;

  --font-sans: "Inter", "Plus Jakarta Sans", sans-serif;
  --font-mono: "IBM Plex Mono", "JetBrains Mono", monospace;
}

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

html {
  scroll-behavior: smooth;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  line-height: 1.6;
}

img, svg {
  display: block;
  max-width: 100%;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: rgba(15, 23, 42, 0.07);
  padding: 0.12em 0.36em;
  border-radius: 3px;
}

.mono {
  font-family: var(--font-mono);
}

.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;
}

.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 28px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(245, 243, 238, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
}

.brand-mark {
  width: 14px;
  height: 14px;
  background: var(--vermilion);
  border: 3px solid var(--ink);
  display: inline-block;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 28px;
}

.site-nav a {
  text-decoration: none;
  color: var(--ink-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

.site-nav a:hover {
  color: var(--ink);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 22px;
  font-family: var(--font-sans);
  font-size: 0.94rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 3px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-ink {
  background: var(--ink);
  color: var(--white);
}

.btn-ink:hover {
  background: var(--slate-800);
}

.btn-vermilion {
  background: var(--vermilion);
  color: var(--white);
}

.btn-vermilion:hover {
  background: var(--vermilion-dark);
}

.btn-outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}

.btn-outline:hover {
  background: var(--ink);
  color: var(--white);
}

/* Typography helpers */
.kicker {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--vermilion);
  margin-bottom: 14px;
}

.kicker-teal {
  color: var(--teal-light);
}

h1, h2, h3, h4 {
  margin: 0;
  line-height: 1.12;
  letter-spacing: -0.025em;
}

/* Hero */
.hero {
  padding: 72px 0 88px;
  border-bottom: 1px solid var(--rule);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 64px;
  align-items: center;
}

.hero h1 {
  font-size: clamp(2.5rem, 4.5vw, 3.75rem);
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 22px;
}

.hero-lead {
  font-size: 1.12rem;
  color: var(--ink-muted);
  margin: 0 0 32px;
  max-width: 56ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 42px;
}

.hero-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  padding-top: 24px;
  border-top: 2px solid var(--ink);
}

.meta-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-subtle);
  margin-bottom: 4px;
}

.meta-value {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
}

/* Physical Book Object (Pure CSS) */
.book-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.book-object {
  position: relative;
  width: 100%;
  max-width: 360px;
  border-radius: 2px 6px 6px 2px;
  box-shadow:
    -14px 18px 36px rgba(15, 23, 42, 0.22),
    -3px 4px 10px rgba(15, 23, 42, 0.14);
  background: var(--paper);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.book-object:hover {
  transform: translateY(-4px);
  box-shadow:
    -18px 24px 44px rgba(15, 23, 42, 0.26),
    -4px 6px 12px rgba(15, 23, 42, 0.16);
}

.book-cover-img {
  width: 100%;
  height: auto;
  border-radius: 2px 5px 5px 2px;
  border: 1px solid rgba(17, 24, 39, 0.14);
}

.book-spine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 16px;
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.16) 0%,
    rgba(255, 255, 255, 0.25) 28%,
    rgba(0, 0, 0, 0.08) 58%,
    rgba(0, 0, 0, 0) 100%
  );
  border-radius: 2px 0 0 2px;
  pointer-events: none;
}

.book-pages {
  position: absolute;
  top: 4px;
  bottom: 4px;
  right: -8px;
  width: 8px;
  background: repeating-linear-gradient(
    to right,
    #EAE6DC 0px,
    #EAE6DC 1px,
    #FFFFFF 1px,
    #FFFFFF 2px
  );
  border: 1px solid rgba(17, 24, 39, 0.14);
  border-left: none;
  border-radius: 0 3px 3px 0;
  z-index: -1;
}

.book-caption {
  margin-top: 18px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--ink-subtle);
  text-align: center;
}

/* Thesis Band (Dark Slate) */
.thesis-band {
  background: var(--slate-950);
  color: var(--white);
  padding: 84px 0;
}

.thesis-grid {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 56px;
  align-items: center;
}

.thesis-band h2 {
  font-size: clamp(1.9rem, 3.2vw, 2.5rem);
  font-weight: 800;
  margin-bottom: 18px;
}

.thesis-band p {
  color: #CBD5E1;
  font-size: 1.04rem;
  margin: 0 0 32px;
}

.thesis-band code {
  background: var(--slate-800);
  color: var(--teal-light);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  padding-top: 24px;
  border-top: 1px solid var(--slate-700);
}

.stat-num {
  display: block;
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--teal-light);
  line-height: 1.1;
  margin-bottom: 6px;
}

.stat-lbl {
  display: block;
  font-size: 0.84rem;
  color: var(--slate-400);
  line-height: 1.4;
}

.pipeline-card {
  background: #0B1120;
  border: 1px solid var(--slate-700);
  border-radius: 4px;
  padding: 20px;
}

.pipeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  color: var(--slate-400);
  margin-bottom: 12px;
}

.badge-teal {
  color: var(--teal-light);
  border: 1px solid rgba(20, 184, 166, 0.4);
  padding: 3px 8px;
  border-radius: 2px;
}

.pipeline-svg {
  width: 100%;
  height: auto;
}

.pipeline-steps {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  margin-top: 12px;
  border-top: 1px solid var(--slate-800);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  color: var(--slate-400);
}

.step-accent {
  color: var(--teal-light);
  font-weight: 700;
}

/* Generic Sections */
.section {
  padding: 88px 0;
  border-bottom: 1px solid var(--rule);
}

.section-tinted {
  background: var(--paper-alt);
}

.section h2 {
  font-size: clamp(1.9rem, 3vw, 2.5rem);
  font-weight: 800;
  margin-bottom: 12px;
}

.section-sub {
  color: var(--ink-muted);
  margin: 0;
  max-width: 60ch;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 44px;
}

/* Part Tabs & Chapters */
.part-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.part-tab {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 13px;
  border: 1px solid var(--rule);
  background: var(--white);
  color: var(--ink-muted);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.part-tab:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.part-tab.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--white);
}

.parts-list {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.part-block {
  display: grid;
  grid-template-columns: 0.34fr 0.66fr;
  gap: 36px;
  padding-top: 28px;
  border-top: 2px solid var(--ink);
}

.part-block.is-hidden {
  display: none;
}

.part-num {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--teal);
  margin-bottom: 6px;
}

.part-summary h3 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 10px;
}

.part-summary p {
  font-size: 0.94rem;
  color: var(--ink-muted);
  margin: 0;
}

.chapter-list {
  display: flex;
  flex-direction: column;
}

.chapter-row {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
}

.chapter-row:first-child {
  padding-top: 0;
}

.chapter-row:last-child {
  border-bottom: none;
}

.ch-num {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--vermilion);
  padding-top: 3px;
}

.chapter-row h4 {
  font-size: 1.06rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.chapter-row p {
  font-size: 0.92rem;
  color: var(--ink-muted);
  margin: 0;
}

.appendices-bar {
  margin-top: 40px;
  padding: 18px 22px;
  background: var(--white);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--teal);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px 28px;
  font-size: 0.92rem;
}

.app-label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--teal);
}

/* Twelve Rules Grid */
.rules-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.rule-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--ink);
  padding: 22px;
  transition: border-top-color 0.15s ease;
}

.rule-card:hover {
  border-top-color: var(--vermilion);
}

.rule-num {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--vermilion);
  margin-bottom: 8px;
}

.rule-card h3 {
  font-size: 1.04rem;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.25;
}

.rule-card p {
  font-size: 0.89rem;
  color: var(--ink-muted);
  margin: 0;
}

/* Companion Repo Section */
.repo-grid {
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 48px;
  align-items: center;
}

.repo-copy p {
  color: var(--ink-muted);
  font-size: 1.02rem;
  margin: 16px 0 24px;
}

.stack-tags {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stack-tags li {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 6px 10px;
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 2px;
  color: var(--ink);
}

.terminal-box {
  background: var(--slate-950);
  color: #E2E8F0;
  border-radius: 4px;
  border: 1px solid var(--slate-700);
  overflow: hidden;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.14);
}

.terminal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--slate-800);
  font-size: 0.76rem;
  color: var(--slate-400);
}

.t-dots {
  display: inline-flex;
  gap: 6px;
}

.t-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #475569;
}

.terminal-body {
  margin: 0;
  padding: 20px;
  font-size: 0.8rem;
  line-height: 1.65;
  overflow-x: auto;
}

.terminal-body code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.t-prompt { color: var(--vermilion); font-weight: 700; }
.t-pass { color: var(--teal-bright); font-weight: 700; }
.t-accent { color: var(--teal-light); font-weight: 600; }

/* Audience */
.audience-grid {
  margin-top: 32px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
}

.aud-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 22px;
}

.aud-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.aud-card p {
  font-size: 0.9rem;
  color: var(--ink-muted);
  margin: 0;
}

/* Author */
.author-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 56px;
  align-items: start;
}

.author-bio {
  color: var(--ink-muted);
  font-size: 1.02rem;
  margin: 14px 0 0;
}

.author-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.inline-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--teal);
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.inline-link:hover {
  color: var(--vermilion);
  text-decoration-color: var(--vermilion);
}

.bib-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 2px solid var(--ink);
}

.bib-list li {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
}

.bib-year {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--teal);
  padding-top: 3px;
}

.bib-list strong {
  display: block;
  font-size: 0.98rem;
  color: var(--ink);
}

.bib-list span {
  font-size: 0.88rem;
  color: var(--ink-subtle);
}

/* CTA Band */
.cta-band {
  background: var(--slate-950);
  color: var(--white);
  padding: 76px 0;
  border-top: 6px solid var(--vermilion);
}

.cta-inner {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 48px;
  align-items: center;
}

.cta-band h2 {
  font-size: clamp(1.75rem, 3vw, 2.3rem);
  font-weight: 800;
  margin-bottom: 12px;
}

.cta-band p {
  color: #CBD5E1;
  margin: 0;
}

.cta-band code {
  background: var(--slate-800);
  color: var(--teal-light);
}

.form-row {
  display: flex;
  gap: 10px;
}

.notify-form input[type="email"] {
  flex: 1;
  min-width: 0;
  padding: 13px 16px;
  font-family: var(--font-sans);
  font-size: 0.96rem;
  background: var(--slate-800);
  color: var(--white);
  border: 1.5px solid var(--slate-700);
  border-radius: 3px;
}

.notify-form input[type="email"]::placeholder {
  color: var(--slate-400);
}

.notify-form input[type="email"]:focus {
  outline: none;
  border-color: var(--teal-bright);
}

.form-status {
  margin-top: 10px;
  font-size: 0.78rem;
  min-height: 1.2em;
  color: var(--teal-light);
}

.form-status.is-error {
  color: #FCA5A5;
}

/* Footer */
.site-footer {
  background: var(--paper);
  padding: 28px 0;
  font-size: 0.84rem;
  color: var(--ink-subtle);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* Responsive */
@media (max-width: 960px) {
  .hero-grid,
  .thesis-grid,
  .repo-grid,
  .author-grid,
  .cta-inner {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .part-block {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .rules-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .audience-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .brand {
    font-size: 0.74rem;
    letter-spacing: 0.08em;
  }

  .site-nav {
    display: none;
  }

  .hero {
    padding: 48px 0 64px;
  }

  .hero-meta,
  .stat-row,
  .rules-grid,
  .audience-grid {
    grid-template-columns: 1fr;
  }

  .chapter-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .form-row {
    flex-direction: column;
  }
}
