/* ==========================================================================
   ARHIPELAGUL DIN UMBRĂ — Stylesheet Editorial & Forensic UI
   Autor: Marius Comper
   ========================================================================== */

:root {
  --font-serif: "Fraunces", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", Consolas, monospace;

  --bg-page: #f8f6f0;
  --bg-card: #ffffff;
  --bg-dark: #0f172a;
  --bg-dark-card: #1e293b;
  --bg-subtle: #f1ede4;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dark-muted: #94a3b8;
  --text-light: #f8fafc;

  --color-emerald: #10b981;
  --color-emerald-glow: rgba(16, 185, 129, 0.2);
  --color-blue: #2563eb;
  --color-navy: #1e3a8a;
  --color-amber: #d97706;
  --color-rose: #e11d48;

  --border-light: #e2e8f0;
  --border-dark: #334155;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --max-w: 1200px;
}

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

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

body {
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography Utility */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-main);
}

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

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-rose);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Header & Topbar */
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  padding: 2.5rem 1.5rem 2rem;
}

.topbar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.lang-switch {
  display: flex;
  gap: 0.5rem;
  align-self: flex-end;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.lang-link {
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  transition: all 0.2s;
}

.lang-link.active, .lang-link:hover {
  background: var(--text-main);
  color: #fff;
  border-color: var(--text-main);
}

.topbar h1 {
  font-size: clamp(2rem, 4.5vw, 3.25rem);
  letter-spacing: -0.02em;
  max-width: 1000px;
}

.standfirst {
  font-size: clamp(1.0625rem, 1.8vw, 1.25rem);
  color: #334155;
  line-height: 1.55;
  max-width: 960px;
}

.source-meta {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Navigation Index Bar */
.sticky-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(248, 246, 240, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-light);
  padding: 0.75rem 1.5rem;
}

.sticky-nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.sticky-nav-inner::-webkit-scrollbar {
  display: none;
}

.nav-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.sticky-nav a {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-main);
  text-decoration: none;
  white-space: nowrap;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.sticky-nav a:hover, .sticky-nav a:focus {
  background: var(--bg-subtle);
  color: var(--color-blue);
}

/* Main Layout Shell */
.shell {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  width: 100%;
}

.section-block {
  margin-bottom: 4.5rem;
}

.section-header {
  margin-bottom: 2rem;
}

.section-header h2 {
  font-size: clamp(1.625rem, 3vw, 2.25rem);
  margin-bottom: 0.5rem;
}

.section-subtitle {
  font-size: 1.0625rem;
  color: var(--text-muted);
  max-width: 800px;
}

/* Executive Summary Grid */
.executive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.executive-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}

.executive-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-kicker {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--color-blue);
  font-weight: 600;
  display: block;
  margin-bottom: 0.5rem;
}

.executive-card h3 {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
}

.executive-card p {
  font-size: 0.9375rem;
  color: #334155;
  line-height: 1.5;
}

/* Signal Laboratory Darkroom */
.signal-lab-darkroom {
  background: var(--bg-dark);
  color: var(--text-light);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-dark);
}

.signal-lab-darkroom h2, .signal-lab-darkroom h3 {
  color: #fff;
}

.lab-tabs {
  display: flex;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-dark);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.lab-tab-btn {
  background: transparent;
  border: 1px solid var(--border-dark);
  color: var(--text-dark-muted);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.lab-tab-btn:hover, .lab-tab-btn.active {
  background: var(--color-emerald);
  color: var(--bg-dark);
  font-weight: 600;
  border-color: var(--color-emerald);
}

.lab-panel {
  display: none;
}

.lab-panel.active {
  display: block;
}

/* rPPG Visualizer Layout */
.rppg-layout {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 850px) {
  .rppg-layout {
    grid-template-columns: 1fr;
  }
}

.rppg-canvas-wrap {
  background: #000;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  padding: 1rem;
  position: relative;
}

#rppg-canvas {
  width: 100%;
  height: 240px;
  display: block;
}

.rppg-metrics-hud {
  display: flex;
  justify-content: space-between;
  margin-top: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.hud-pill {
  background: var(--bg-dark-card);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-dark);
}

.hud-green {
  color: var(--color-emerald);
  font-weight: 700;
}

.lab-controls-card {
  background: var(--bg-dark-card);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.control-label {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-dark-muted);
  display: flex;
  justify-content: space-between;
}

.lab-slider {
  width: 100%;
  accent-color: var(--color-emerald);
}

.lab-formula-box {
  background: #0b1120;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #38bdf8;
  line-height: 1.4;
}

/* FACS Visualizer Layout */
.facs-layout {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 2rem;
}

@media (max-width: 850px) {
  .facs-layout {
    grid-template-columns: 1fr;
  }
}

.facs-face-card {
  background: #000;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.facs-svg {
  width: 180px;
  height: 180px;
}

.facs-scores-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  width: 100%;
  text-align: center;
  font-family: var(--font-mono);
}

.facs-score-box {
  background: var(--bg-dark-card);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-dark);
}

.facs-score-box small {
  display: block;
  font-size: 0.6875rem;
  color: var(--text-dark-muted);
}

.facs-score-box strong {
  font-size: 1.1rem;
  color: #38bdf8;
}

.facs-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.au-item {
  background: var(--bg-dark-card);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8125rem;
  cursor: pointer;
}

.au-item input {
  accent-color: var(--color-emerald);
}

/* Profiler Plus Layout */
.profiler-layout {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.profiler-presets {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.profiler-preset-btn {
  background: var(--bg-dark-card);
  border: 1px solid var(--border-dark);
  color: var(--text-dark-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.profiler-preset-btn:hover {
  color: #fff;
  border-color: #38bdf8;
}

.profiler-textarea {
  width: 100%;
  height: 100px;
  background: #000;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  padding: 0.75rem;
  resize: vertical;
}

.profiler-textarea:focus {
  outline: 2px solid var(--color-emerald);
}

.profiler-btn {
  align-self: flex-start;
  background: var(--color-emerald);
  color: var(--bg-dark);
  border: none;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 700;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.profiler-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

.motive-card {
  background: var(--bg-dark-card);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  font-family: var(--font-mono);
}

.motive-card small {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dark-muted);
  margin-bottom: 0.25rem;
}

.motive-card strong {
  font-size: 1.5rem;
  color: var(--color-emerald);
}

/* Capability Matrix */
.matrix-container {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.matrix-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.matrix-select {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: #fff;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.matrix-table th, .matrix-table td {
  padding: 0.75rem 0.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border-light);
}

.matrix-table th:first-child, .matrix-table td:first-child {
  text-align: left;
  font-weight: 600;
  font-family: var(--font-mono);
  min-width: 160px;
}

.matrix-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.cell-confirmed {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.cell-inferred {
  background: #fef3c7;
  color: #92400e;
  border: 1px dashed #fcd34d;
}

.cell-absent {
  background: #f1f5f9;
  color: #94a3b8;
}

.matrix-cell:hover {
  transform: scale(1.15);
  box-shadow: var(--shadow-md);
}

/* Dossiers Section */
.dossier-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.dossier-nav-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-subtle);
  overflow-x: auto;
}

.dossier-tab-btn {
  background: transparent;
  border: none;
  padding: 1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.dossier-tab-btn.active {
  color: var(--color-navy);
  border-bottom-color: var(--color-blue);
  background: #fff;
}

.dossier-content-panel {
  display: none;
  padding: 2rem;
}

.dossier-content-panel.active {
  display: block;
}

.dossier-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
}

@media (max-width: 850px) {
  .dossier-grid {
    grid-template-columns: 1fr;
  }
}

.dossier-stats-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

/* Inferences Rail */
.inferences-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.5rem;
}

.inference-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.inference-card h3 {
  font-size: 1.15rem;
  line-height: 1.3;
}

.inference-badge {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  align-self: flex-start;
}

.badge-source {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-reading {
  background: #fef3c7;
  color: #b45309;
}

.badge-counter {
  background: #ffe4e6;
  color: #be123c;
}

.inference-block {
  font-size: 0.875rem;
  line-height: 1.45;
}

.inference-block p {
  color: #334155;
}

/* Legal & Guardrails */
.legal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.legal-card {
  background: var(--bg-card);
  border-left: 4px solid var(--color-amber);
  border-top: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
}

.legal-card h3 {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

.legal-card p {
  font-size: 0.875rem;
  color: #334155;
  line-height: 1.5;
}

/* Contracts Explorer */
.contracts-toolbar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 260px;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: #fff;
}

.contracts-list-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.contract-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.contract-card:hover, .contract-card:focus {
  border-color: var(--color-blue);
  transform: translateX(4px);
  outline: none;
}

.contract-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.contract-unit-tag {
  background: var(--bg-subtle);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--color-navy);
}

.contract-date {
  color: var(--text-muted);
}

.contract-title {
  font-size: 1rem;
  font-family: var(--font-sans);
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-main);
}

.contract-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.contract-vendor {
  color: var(--text-muted);
}

.contract-value {
  color: var(--color-blue);
  font-weight: 700;
}

/* Detail Drawer Modal */
.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 95vw);
  background: #fff;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  z-index: 100;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  padding: 2rem;
}

.detail-drawer.open {
  transform: translateX(0);
}

.detail-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg-subtle);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-weight: bold;
}

.detail-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.detail-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-blue);
  font-weight: 700;
}

.detail-id {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.detail-title {
  font-size: 1.35rem;
  margin-bottom: 1.5rem;
}

.detail-grid-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.detail-grid-metrics div small {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.detail-grid-metrics div strong {
  font-size: 0.9375rem;
}

.detail-raw-quote {
  background: #f8fafc;
  border-left: 3px solid var(--color-blue);
  padding: 0.75rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: #334155;
  margin-top: 0.5rem;
  line-height: 1.45;
}

.detail-actions {
  margin-top: 2rem;
}

.detail-sicap-link {
  display: inline-block;
  background: var(--text-main);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
}

.detail-sicap-link:hover {
  background: var(--color-blue);
}

/* Colophon & Footer */
.colophon-footer {
  margin-top: auto;
  background: var(--bg-card);
  border-top: 1px solid var(--border-light);
  padding: 2.5rem 1.5rem;
}

.colophon-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  font-size: 0.875rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.colophon-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.colophon-links a {
  color: var(--text-main);
  text-decoration: none;
  font-weight: 600;
}

.colophon-links a:hover {
  text-decoration: underline;
}

/* Back to top button */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--bg-dark);
  color: #fff;
  border: 1px solid var(--border-dark);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 40;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-top:hover {
  transform: translateY(-2px);
  background: var(--color-blue);
}

/* Reduced Motion Mode */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
