/* Silo Observatory Design System — Zero-Build Modern CSS */
:root {
  color-scheme: light dark;
  --font-display: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, sans-serif;
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --bg-page: light-dark(#f6f8fc, #090d16);
  --bg-surface: light-dark(#ffffff, #111827);
  --bg-elevated: light-dark(#f1f5f9, #182235);
  --bg-hero: light-dark(linear-gradient(135deg, #eef4ff 0%, #f8fafc 55%, #ecfdf5 100%), linear-gradient(135deg, #0f172a 0%, #090d16 55%, #06211c 100%));
  --border-subtle: light-dark(#e2e8f0, #233046);
  --border-strong: light-dark(#cbd5e1, #334155);

  --text-primary: light-dark(#0f172a, #f1f5f9);
  --text-secondary: light-dark(#475569, #94a3b8);
  --text-muted: light-dark(#64748b, #64748b);

  --accent: light-dark(#2563eb, #60a5fa);
  --accent-solid: #2563eb;
  --accent-soft: light-dark(#dbeafe, rgba(37, 99, 235, 0.18));
  --ok: light-dark(#059669, #34d399);
  --ok-soft: light-dark(#d1fae5, rgba(16, 185, 129, 0.18));
  --warn: light-dark(#d97706, #fbbf24);
  --warn-soft: light-dark(#fef3c7, rgba(245, 158, 11, 0.18));
  --danger: light-dark(#dc2626, #f87171);
  --danger-soft: light-dark(#fee2e2, rgba(239, 68, 68, 0.18));

  --shadow-sm: light-dark(0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(0, 0, 0, 0.35));
  --shadow-md: light-dark(0 10px 30px -10px rgba(15, 23, 42, 0.10), 0 12px 32px -12px rgba(0, 0, 0, 0.55));
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --container-max: 1220px;

  &:has(> head > meta[name="color-scheme"][content="dark"]) {
    color-scheme: dark;
  }
  &:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
  }
}

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

html {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  accent-color: var(--accent);
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

.container {
  width: min(100% - 2rem, var(--container-max));
  margin-inline: auto;
}

/* Header & Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(12px);
  background: light-dark(rgba(255, 255, 255, 0.88), rgba(9, 13, 22, 0.88));
  border-bottom: 1px solid var(--border-subtle);
}

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

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-decoration: none;
}

.brand-badge {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #059669);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 500;
}
.nav-links a:hover, .nav-links a[aria-current="page"] {
  color: var(--text-primary);
  text-decoration: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

/* Color-scheme two-state toggle (driven without requiring JS for icon visibility) */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
}

.theme-toggle .icon-light { display: none; }
.theme-toggle .icon-dark { display: inline; }

@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-toggle .icon-light { display: inline; }
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-toggle .icon-dark { display: none; }
}
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-toggle .icon-light { display: inline; }
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-toggle .icon-dark { display: none; }

.sr-only {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

/* Hero & Dynamic Interactive Index */
.hero-observatory {
  background: var(--bg-hero);
  border-bottom: 1px solid var(--border-subtle);
  padding: 3.25rem 0 2.75rem;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px light-dark(rgba(5, 150, 105, 0.2), rgba(52, 211, 153, 0.22));
}

h1, h2, h3 {
  font-family: var(--font-display);
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-top: 0;
}

.hero-title {
  font-size: clamp(2rem, 4vw, 3.1rem);
  max-width: 18ch;
  margin-bottom: 0.85rem;
}

.hero-subtitle {
  font-size: 1.08rem;
  color: var(--text-secondary);
  max-width: 65ch;
  margin-bottom: 1.75rem;
}

.solver-bar {
  display: flex;
  gap: 0.6rem;
  max-width: 720px;
  background: var(--bg-surface);
  padding: 0.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
}

.solver-bar input[type="search"] {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 1rem;
  padding: 0.65rem 0.85rem;
  outline: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 1.15rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.btn:hover { text-decoration: none; opacity: 0.94; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent-solid); color: #fff; }
.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.42rem 0.8rem; font-size: 0.83rem; }

/* Stats & Silo Pills */
.telemetry-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.85rem;
  margin-top: 1.75rem;
}

.stat-tile {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.1rem;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.silo-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 1.5rem 0;
}

.chip {
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}
.chip.is-active, .chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* Grids & Cards */
.section-block { padding: 2.5rem 0; }

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
}

.module-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.9rem;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.module-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-neutral { background: var(--bg-elevated); color: var(--text-secondary); }

/* Interactive Workspace (Tool Page) */
.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 2rem;
  align-items: start;
  padding: 2rem 0 3rem;
}
@media (max-width: 960px) {
  .tool-layout { grid-template-columns: 1fr; }
}

.answer-first-box {
  background: var(--bg-surface);
  border-left: 4px solid var(--ok);
  border-top: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.2rem 1.35rem;
  margin: 1.25rem 0 1.75rem;
}

.workspace-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 2rem;
}

.workspace-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  margin-bottom: 1rem;
}

.field-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.field-control {
  width: 100%;
  padding: 0.62rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
}

input[type="range"].field-range {
  width: 100%;
  cursor: pointer;
}

/* Progressive fallback when accent-color is unsupported */
@supports not (accent-color: var(--accent)) {
  input[type="range"].field-range {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
  }
  input[type="range"].field-range::-webkit-slider-runnable-track {
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, var(--accent) var(--progress, 50%), var(--border-strong) var(--progress, 50%));
  }
  input[type="range"].field-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: -5px;
  }
}

.results-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.verdict-banner {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.output-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.kpi-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
}
.kpi-val {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
}
.kpi-lbl { font-size: 0.78rem; color: var(--text-secondary); }

/* Responsive Tables (Modern Container Query Pattern) */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(520px, 75vh);
  container-type: inline-size;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

.data-table th, .data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  background: var(--bg-elevated);
}

.data-table tbody th {
  position: sticky;
  inset-inline-start: 0;
  background: var(--bg-surface);
  font-weight: 600;
}

@container (width < 600px) {
  .data-table, .data-table thead, .data-table tbody, .data-table tr, .data-table th, .data-table td {
    display: block;
  }
  .data-table thead { display: none; }
  .data-table tr {
    margin-block-end: 1rem;
    border-bottom: 2px solid var(--border-strong);
    padding: 0.5rem;
  }
  .data-table tbody th {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: var(--bg-elevated);
    border-radius: 6px;
  }
  .data-table td[data-label]::before {
    content: attr(data-label) ": ";
    font-weight: 600;
    color: var(--text-secondary);
  }
}

/* Below-the-fold performance optimization */
.heavy-section-deferred {
  content-visibility: auto;
  contain-intrinsic-size: auto none auto 280px;
}

/* AdSense Safe Zones (never adjacent to interactive buttons/sliders) */
.ad-slot-zone {
  margin: 2rem 0;
  padding: 1rem;
  min-height: 110px;
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  text-align: center;
}
.ad-slot-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

/* Diff Timeline & FAQs */
.diff-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.75rem; }
.diff-item {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border-left: 3px solid var(--accent);
}
.faq-item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.1rem;
  background: var(--bg-surface);
  margin-bottom: 0.7rem;
}
.faq-item summary { font-weight: 600; cursor: pointer; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 2.5rem 0;
  margin-top: 3rem;
  color: var(--text-secondary);
  font-size: 0.88rem;
}
.footer-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.5rem;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 1.15rem; }

/* Admin Layout */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.25rem;
}
.mono { font-family: var(--font-mono); }
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-weight: 500;
}
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }

@media print {
  .site-header, .site-footer, .ad-slot-zone, #helpfulFeedbackBox, .btn, .theme-toggle {
    display: none !important;
  }
  body { background: #fff !important; color: #000 !important; }
  .workspace-card, .card, .answer-first-box {
    box-shadow: none !important;
    border-color: #cbd5e1 !important;
  }
}
