/* ═══════════════════════════════════════════
   Keystone — Site Design System
   Palette: Graphite (#1F2933) + Copper (#B66A3C)
   extended with warm neutrals from the brand.
   ═══════════════════════════════════════════ */

/* ── Tokens ── */
:root {
  --graphite:    #1F2933;
  --copper:      #93491F;
  --copper-soft: #8B451B;
  --parchment:   #F4EFE6;
  --bone:        #faf7f2;
  --stone:       #6F675D;
  --fog:         #e8e3db;
  --faint:       #f0ebe3;
  --code-bg:     #1F2933;
  --code-text:   #F4EFE6;
  --code-accent: #c8845e;
  --code-muted:  #ADA69A;
  --nav-bg:      rgba(250, 247, 242, 0.88);
  --shadow-soft: rgba(31, 41, 51, 0.06);
  --logo-filter: none;

  --font-display: 'Libre Baskerville', Charter, Georgia, serif;
  --font-body:    'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', Consolas, monospace;

  --space-xs:  0.5rem;
  --space-sm:  1rem;
  --space-md:  1.5rem;
  --space-lg:  3rem;
  --space-xl:  5rem;
  --space-2xl: 8rem;

  --max-w: 1080px;
  --radius: 10px;
  color-scheme: light;
}

html[data-theme='dark'] {
  --graphite:    #F5EFE4;
  --copper:      #D38A5F;
  --copper-soft: #F0A979;
  --parchment:   #F4EFE6;
  --bone:        #11151A;
  --stone:       #ada69a;
  --fog:         #303842;
  --faint:       #1A2027;
  --code-bg:     #0B1117;
  --code-text:   #F4EFE6;
  --code-accent: #F0A979;
  --code-muted:  #B8AFA4;
  --nav-bg:      rgba(17, 21, 26, 0.9);
  --shadow-soft: rgba(0, 0, 0, 0.32);
  --logo-filter: drop-shadow(0 0 4px rgba(244, 239, 230, 0.18));
  color-scheme: dark;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  font-family: var(--font-body);
  color: var(--graphite);
  background: var(--bone);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.2s ease, color 0.2s ease;
}

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

a {
  color: var(--copper);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover { color: var(--copper-soft); }

/* ── Focus ── */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--copper);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ── Typography ── */
h1, h2 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.12;
}

h1 { font-size: clamp(2.4rem, 5.5vw, 3.8rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); }

h3 {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
}

/* ── Eyebrow ── */
.eyebrow,
.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--copper);
}

/* ════════════════════════════════════════════
   Navigation
   ════════════════════════════════════════════ */
nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--fog);
  transition: box-shadow 0.3s;
}

nav.scrolled {
  box-shadow: 0 1px 12px var(--shadow-soft);
}

.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0.75rem var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--graphite);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
}
.nav-logo:hover { color: var(--graphite); }

.nav-logo img,
.footer-left img {
  filter: var(--logo-filter);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.nav-links {
  display: flex;
  gap: var(--space-md);
}

.nav-links a {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--stone);
  text-decoration: none;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--graphite); }

.theme-toggle {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  background: var(--faint);
  border: 1px solid var(--fog);
  border-radius: 999px;
  color: var(--graphite);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.theme-toggle:hover {
  background: var(--parchment);
  border-color: var(--copper);
}

html[data-theme='dark'] .theme-toggle:hover {
  background: #232B34;
}

.theme-icon {
  position: relative;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  box-shadow: inset -0.28rem -0.2rem 0 0 currentColor;
}

html[data-theme='dark'] .theme-icon {
  background: currentColor;
  box-shadow:
    0 -0.48rem 0 -0.34rem currentColor,
    0 0.48rem 0 -0.34rem currentColor,
    0.48rem 0 0 -0.34rem currentColor,
    -0.48rem 0 0 -0.34rem currentColor;
}

/* ════════════════════════════════════════════
   Hero
   ════════════════════════════════════════════ */
.hero {
  position: relative;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 9rem var(--space-md) 3.5rem;
  display: grid;
  grid-template-columns: 1fr 0.5fr;
  align-items: start;
  gap: var(--space-lg);
  overflow: hidden;
}

.hero-inner {
  position: relative;
  z-index: 1;
}

.hero-eyebrow {
  margin-bottom: var(--space-sm);
  display: block;
}

.hero h1 {
  margin-bottom: var(--space-md);
  color: var(--graphite);
}

.hero-sub {
  font-size: 1.05rem;
  color: var(--stone);
  max-width: 520px;
  margin-bottom: var(--space-lg);
  line-height: 1.7;
}

.hero-invoke {
  display: inline-block;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.7rem 1.2rem;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: -0.01em;
}

.hero-invoke .hero-task {
  color: var(--copper-soft);
}

.hero-arch {
  position: relative;
  align-self: center;
  opacity: 1;
}

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

/* ════════════════════════════════════════════
   Sections
   ════════════════════════════════════════════ */
.section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3.5rem var(--space-md);
}

.section + .section {
  border-top: 1px solid var(--fog);
}

.section-head {
  margin-bottom: var(--space-lg);
}

.section-head .eyebrow {
  margin-bottom: var(--space-xs);
  display: block;
}

.section-head h2 {
  max-width: 600px;
}

.section-lede {
  color: var(--stone);
  max-width: 560px;
  margin-bottom: var(--space-lg);
  font-size: 1rem;
  line-height: 1.7;
}

.section-lede code {
  background: var(--faint);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--graphite);
}

.section-coda {
  margin-top: var(--space-lg);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--copper);
}

/* ════════════════════════════════════════════
   Problem / Failures
   ════════════════════════════════════════════ */
.failures-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-sm);
}

.failure {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: var(--space-sm) var(--space-md);
  background: var(--faint);
  border-radius: var(--radius);
}

.failure-icon {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  margin-top: 0.55rem;
  background: var(--copper);
  border-radius: 1px;
  transform: rotate(45deg);
}

.failure p {
  font-size: 0.92rem;
  color: var(--graphite);
}

/* ════════════════════════════════════════════
   How / Lifecycle
   ════════════════════════════════════════════ */
.lifecycle {
  display: flex;
  align-items: flex-start;
  gap: 0;
}

.lifecycle-step {
  flex: 1;
  padding-right: var(--space-sm);
}

.lifecycle-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--copper);
  margin-bottom: 0.3rem;
}

.lifecycle-step p {
  font-size: 0.88rem;
  color: var(--stone);
  line-height: 1.5;
}

.lifecycle-arrow {
  width: 1px;
  align-self: stretch;
  min-height: 60px;
  background: var(--fog);
  flex-shrink: 0;
  margin-right: var(--space-sm);
}

/* ════════════════════════════════════════════
   Modules
   ════════════════════════════════════════════ */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}

.module-card {
  padding: var(--space-md);
  background: var(--faint);
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: border-color 0.25s, transform 0.25s, box-shadow 0.25s;
  cursor: default;
}

.module-card:hover {
  border-color: var(--fog);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--shadow-soft);
}

.module-card h3 {
  color: var(--copper);
  margin-bottom: 0.4rem;
}

.module-card p {
  font-size: 0.88rem;
  color: var(--stone);
  line-height: 1.55;
}

.module-card em {
  color: var(--graphite);
  font-style: normal;
  font-weight: 500;
}

/* ════════════════════════════════════════════
   Workflows
   ════════════════════════════════════════════ */
.workflow-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.workflow-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--faint);
  border-radius: var(--radius);
}

.workflow-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  min-width: 130px;
  flex-shrink: 0;
}

.workflow-chain {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.wf-node {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--parchment);
  background: var(--copper);
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  border: 1px solid var(--copper);
}

.wf-node.accent {
  background: var(--copper);
  color: var(--parchment);
  border-color: var(--copper);
}

.wf-arrow {
  color: var(--stone);
  font-size: 0.8rem;
  opacity: 0.5;
}

.wf-or {
  font-size: 0.72rem;
  font-style: italic;
  color: var(--stone);
}

/* ════════════════════════════════════════════
   Gates
   ════════════════════════════════════════════ */
.gates-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-sm);
}

.gate-item {
  text-align: center;
}

.gate-bar {
  width: 100%;
  height: 3px;
  background: var(--copper);
  border-radius: 2px;
  margin-bottom: var(--space-sm);
  opacity: 0.4;
  transition: opacity 0.3s;
}

.gate-item:hover .gate-bar {
  opacity: 1;
}

.gate-item h3 {
  color: var(--graphite);
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
}

.gate-item p {
  font-size: 0.82rem;
  color: var(--stone);
  line-height: 1.45;
}

/* ════════════════════════════════════════════
   Install
   ════════════════════════════════════════════ */
.install-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.install-card {
  padding: var(--space-md);
  background: var(--code-bg);
  border-radius: var(--radius);
  color: var(--code-text);
}

.install-card h3 {
  color: var(--code-accent);
  margin-bottom: 0.6rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.install-code {
  overflow-x: auto;
}

.install-code code {
  display: block;
  font-size: 0.82rem;
  color: var(--code-text);
  white-space: nowrap;
  line-height: 1.8;
}

.install-then {
  font-size: 0.9rem;
  color: var(--stone);
  margin-bottom: var(--space-sm);
  text-align: center;
}

.install-hero-code {
  text-align: left;
  background: var(--code-bg);
  color: var(--code-text);
  padding: var(--space-sm) var(--space-md);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 1rem;
  max-width: 400px;
  margin: 0 auto;
}

.install-hero-code code {
  display: block;
}

.install-hero-code .dimmed {
  color: var(--code-muted);
}

/* ════════════════════════════════════════════
   Closing
   ════════════════════════════════════════════ */
.closing {
  text-align: center;
  padding: 5.6rem var(--space-md);
}

.closing-quote {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  line-height: 1.4;
  color: var(--graphite);
  max-width: 680px;
  margin: 0 auto;
  border: none;
  padding: 0;
  quotes: none;
}

/* ════════════════════════════════════════════
   Footer
   ════════════════════════════════════════════ */
footer {
  border-top: 1px solid var(--fog);
  padding: var(--space-md);
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  gap: var(--space-md);
}

.footer-links a {
  font-size: 0.82rem;
  color: var(--stone);
}
.footer-links a:hover { color: var(--graphite); }

.footer-license {
  font-size: 0.78rem;
  color: var(--stone);
}

/* ════════════════════════════════════════════
   Fade-in animation
   ════════════════════════════════════════════ */
.fade-in {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Hero entrance */
.hero-inner,
.hero-arch {
  animation: heroFadeUp 0.7s ease both;
}

.hero-arch {
  animation-delay: 0.15s;
}

@keyframes heroFadeUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ════════════════════════════════════════════
   Reduced motion
   ════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  .fade-in {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .hero-inner,
  .hero-arch {
    animation: none;
  }

  .module-card,
  .failure,
  .gate-bar {
    transition: none;
  }
}

/* ════════════════════════════════════════════
   Responsive
   ════════════════════════════════════════════ */
@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    padding-top: 7rem;
  }

  .hero-arch {
    display: none;
  }

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

  .gates-strip {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 680px) {
  .section {
    padding: 2.1rem var(--space-sm);
  }

  .hero {
    padding: 6rem var(--space-sm) 2.1rem;
  }

  .modules-grid {
    grid-template-columns: 1fr;
  }

  .install-grid {
    grid-template-columns: 1fr;
  }

  .gates-strip {
    grid-template-columns: 1fr 1fr;
  }

  .lifecycle {
    flex-direction: column;
    gap: 0;
  }

  .lifecycle-arrow {
    width: var(--space-xl);
    height: 1px;
    min-height: 0;
    margin-right: 0;
    margin-bottom: var(--space-sm);
    margin-top: var(--space-sm);
  }

  .lifecycle-step {
    padding-right: 0;
  }

  .workflow-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .workflow-name {
    min-width: 0;
  }

  .nav-links {
    gap: var(--space-sm);
  }

  .nav-links a {
    font-size: 0.76rem;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
    gap: 0.6rem;
  }
}

@media (max-width: 440px) {
  .gates-strip {
    grid-template-columns: 1fr;
  }

  .nav-links {
    display: none;
  }
}
