/* ==========================================================================
   CSI — Capability-Seconds Index
   Page-specific layout and structure styles.
   Foundation (colors, typography, spacing, components) lives in design-system.css.
   ========================================================================== */

:root {
  /* Legacy color tokens — used by page-specific styles below */
  --navy: #0a1628;
  --navy-light: #132038;
  --navy-mid: #1c2d4a;
  --white: #ffffff;
  --off-white: #f4f5f7;
  --gold: #c9a227;
  --gold-dim: #a88b20;
  --slate: #3a4a5c;
  --slate-light: #8494a7;
  --green: #2a9d6e;
  --red: #c44d4d;
  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-mono: 'IBM Plex Mono', 'Consolas', 'Menlo', monospace;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --max-w: 1080px;
}

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

html { scroll-behavior: smooth; }

/* — Layout — */

/* — Header / Nav — */
header {
  background: var(--navy);
  border-bottom: 3px solid var(--gold);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  z-index: 100;
}
.masthead {
  padding: 0.9rem 2rem 0.7rem;
  text-align: left;
}
.nav-bar {
  border-top: 1px solid rgba(201,162,39,0.3);
}
.nav-bar .container {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 2rem;
}
.logo {
  font-family: var(--font-heading);
  font-size: 22px;
  color: var(--white);
  text-decoration: none;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.logo span { color: var(--gold); }
nav { display: flex; gap: 1.75rem; align-items: center; flex-shrink: 0; }
nav a {
  color: #94A3B8;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color 0.2s;
  padding: 0.6rem 0;
}
nav a:hover, nav a.active { color: var(--white); }
nav a.active { border-bottom: 2px solid var(--accent-gold); padding-bottom: calc(0.6rem - 2px); }

/* — Hero Index — */
.hero {
  background: var(--navy);
  text-align: center;
  padding: 4rem 0 3.5rem;
}
.hero-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--slate-light);
  margin-bottom: 0.75rem;
}
.hero-number {
  font-family: var(--font-display);
  font-size: 6rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1;
  margin-bottom: 0.5rem;
}
.hero-number .decimal { color: var(--gold); }
.hero-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--slate-light);
  margin-top: 0.75rem;
}
.hero-sub {
  font-size: 0.95rem;
  color: var(--slate-light);
  max-width: 520px;
  margin: 1.25rem auto 0;
  line-height: 1.6;
}

/* — Stat Cards — */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin: 2rem 0;
}
/* stat-card base styles now in design-system.css */
.stat-card .label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-tertiary);
  margin-bottom: 0.5rem;
}
.stat-card .value {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text-primary);
}
.stat-card .unit {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* — Section — */
section { padding: 3rem 0; }
section + section { border-top: 1px solid var(--border); }

h1 {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}
h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-primary);
}
h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

p { margin-bottom: 1rem; max-width: 68ch; }
p + p { margin-top: 0; }

/* — Tables — */
.table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
  border-radius: 6px;
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
thead {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
th {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.85rem 1rem;
  text-align: left;
  font-weight: 700;
  white-space: nowrap;
  color: #374151;
}
th.num, td.num { text-align: right; }
td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-secondary); }

.model-name {
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--text-primary);
}

/* — Formula / Code blocks — */
.formula-block {
  background: #EEF2F7;
  color: #1A1A2E;
  border: 1px solid #D1D9E6;
  border-radius: 6px;
  padding: 1.5rem 2rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 2;
  margin: 1.5rem 0;
  overflow-x: auto;
}
.formula-block .var { color: #1E3A5F; font-weight: 600; }
.formula-block .comment { color: var(--text-tertiary); }

/* — Prose content — */
.prose { max-width: 720px; line-height: 1.6; }
.prose ul, .prose ol { margin: 0.75rem 0 1.25rem 1.5rem; }
.prose li { margin-bottom: 0.4rem; }
.prose code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-tertiary);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}
.prose a { color: var(--gold-dim); text-decoration: underline; }
.prose a:hover { color: var(--text-primary); }

/* — Fallback / empty state — */
.fallback {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-tertiary);
}
.fallback-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}
.fallback p { margin: 0 auto; max-width: 400px; }

/* — Download buttons — */
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  padding: 8px 16px;
  background: #FFFFFF;
  color: #374151;
  border: 1px solid #D1D9E6;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.btn-download:hover { background: #F8F9FB; border-color: #B8C4D1; }
.btn-download:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-download svg { flex-shrink: 0; }

/* — Callout / Insight box — */
.callout-box {
  background: #EEF2F7;
  border: 1px solid #D1D9E6;
  border-left: 3px solid var(--accent-gold);
  border-radius: 4px;
  padding: 1.25rem 1.5rem;
  margin: 0.5rem 0;
}
.callout-box p {
  font-style: italic;
  color: #374151;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.7;
  margin: 0;
  max-width: none;
}
.callout-box strong {
  color: var(--accent-gold);
  font-style: normal;
}

/* — Footer — */
footer {
  background: var(--bg-primary);
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  padding: 32px 0;
  font-size: 13px;
  margin-top: 3rem;
}
footer .container {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
}
footer .footer-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
footer .footer-right {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: right;
}
footer .footer-brand {
  font-family: var(--font-heading);
  font-size: 16px;
  color: var(--text-primary);
}
footer a { color: var(--accent-gold); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* — Badge — badge base styles now in design-system.css */
.badge-up { background: #e6f5ee; color: var(--green); }
.badge-down { background: #fce8e8; color: var(--red); }
.badge-neutral { background: #ebedf0; color: var(--text-secondary); }

/* — Loading spinner — */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--slate-light);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* — Loading skeleton — */
@keyframes pulse { 0%,100% { opacity:0.4 } 50% { opacity:0.7 } }
.skeleton { animation: pulse 1.5s ease-in-out infinite; background: #EEF2F7; border-radius: 8px; }

/* — Hamburger toggle (hidden on desktop) — */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 12px;
  min-width: 48px;
  min-height: 48px;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--white);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

/* — Responsive — */
@media (max-width: 768px) {
  .nav-toggle { display: flex; }
  .logo { font-size: 1rem; }
  .masthead { padding: 0.6rem 1rem 0.4rem; }
  .nav-bar .container { flex-wrap: wrap; padding: 0 1rem; }
  nav {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 0;
    padding-top: 0;
    transition: max-height 0.3s ease;
  }
  nav.open { display: flex; }
  nav a {
    padding: 12px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--navy-mid);
    min-height: 48px;
    display: flex;
    align-items: center;
  }
  nav a:last-child { border-bottom: none; }
  nav a.active { border-bottom: 1px solid var(--navy-mid); padding-bottom: 12px; }
  nav a:last-child.active { border-bottom: none; }
  .stat-row { grid-template-columns: 1fr; }
  h1 { font-size: 1.75rem; }
  footer .container { flex-direction: column; gap: 1rem; }
  footer .footer-right { text-align: left; }
  /* Cost charts single column on mobile */
  [style*="grid-template-columns:1fr 1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 375px) {
  body { font-size: 14px; }
}
