/* Cadrele secundei / The Frames of the Second
   Visual Theme: Optical Laboratory & Stroboscopic Darkroom */

:root {
  --bg-dark: #07090e;
  --bg-card: #0e121a;
  --bg-card-hover: #141924;
  --bg-panel: #121722;
  --border-subtle: #1f2737;
  --border-active: #3b475e;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.18);
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.18);
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.18);
  --accent-rose: #f43f5e;
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Apple Garamond", "Baskerville", "Times New Roman", "Droid Serif", Times, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  
  --max-width: 980px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background: 
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(245, 158, 11, 0.07), transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 60%, rgba(6, 182, 212, 0.04), transparent 60%),
    var(--bg-dark);
}

.site-container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header & Nav */
header.site-header {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.brand-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  transition: color 0.2s ease;
}

.brand-link:hover {
  color: var(--text-primary);
}

.nav-tools {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.lang-switch {
  display: inline-flex;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.lang-switch a {
  padding: 4px 10px;
  text-decoration: none;
  color: var(--text-muted);
  border-radius: 4px;
  transition: all 0.2s ease;
}

.lang-switch a.active {
  background: var(--border-active);
  color: var(--text-primary);
  font-weight: 600;
}

.lang-switch a:hover:not(.active) {
  color: var(--text-secondary);
}

/* Hero Section */
.hero {
  padding: 3.5rem 0 2.5rem;
  text-align: center;
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 20px;
  color: var(--accent-amber);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1.5rem;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-amber);
  box-shadow: 0 0 8px var(--accent-amber);
}

h1.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 600;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  letter-spacing: -0.01em;
}

p.hero-deck {
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  color: var(--text-secondary);
  max-width: 760px;
  margin: 0 auto 2.5rem;
  font-weight: 350;
  line-height: 1.55;
}

/* Key Stat Callout Banner */
.stat-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 3.5rem;
}

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  text-align: left;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-box::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--border-active);
}

.stat-box.highlight::before {
  background: var(--accent-amber);
}

.stat-box:hover {
  border-color: var(--border-active);
  transform: translateY(-2px);
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 0.25rem;
}

.stat-value span.unit {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-muted);
}

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

/* Section Headings */
section.interactive-block {
  padding: 3rem 0;
  border-top: 1px solid var(--border-subtle);
}

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

.section-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
  display: block;
}

.section-title {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.section-desc {
  color: var(--text-secondary);
  font-size: 1rem;
  max-width: 720px;
}

/* Workbench Grid & Panels */
.workbench-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

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

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
}

.panel-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Stroboscope Optical Display */
.strobe-display-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1 / 1;
  background: #000000;
  border-radius: 50%;
  border: 2px solid var(--border-subtle);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

canvas#strobeCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.canvas-center-target {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-dark);
  border: 2px solid var(--accent-amber);
  pointer-events: none;
}

.strobe-status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 30px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  transition: all 0.3s ease;
}

.strobe-status-badge.flicker {
  border-color: var(--accent-rose);
  color: #fda4af;
  background: rgba(244, 63, 94, 0.1);
}

.strobe-status-badge.fused {
  border-color: var(--accent-emerald);
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.1);
}

/* Controls */
.control-group {
  margin-bottom: 1.5rem;
}

.control-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.6rem;
}

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

.control-value-readout {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-amber);
}

input[type="range"].custom-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

input[type="range"].custom-slider:focus {
  border-color: var(--accent-amber);
}

input[type="range"].custom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-amber);
  box-shadow: 0 0 10px var(--accent-amber-glow);
  border: 2px solid var(--bg-card);
  cursor: pointer;
  transition: transform 0.1s ease;
}

input[type="range"].custom-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="range"].custom-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-amber);
  box-shadow: 0 0 10px var(--accent-amber-glow);
  border: 2px solid var(--bg-card);
  cursor: pointer;
}

/* Frequency Preset Buttons */
.preset-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.preset-btn {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-btn:hover {
  border-color: var(--border-active);
  color: var(--text-primary);
}

.preset-btn.active {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--accent-amber);
  color: var(--accent-amber);
  font-weight: 600;
}

/* Diagnostic Readout Box */
.diagnostic-box {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-size: 0.875rem;
}

.diagnostic-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.diagnostic-label {
  color: var(--text-muted);
}

.diagnostic-val {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-weight: 500;
}

/* Species Selector Carousel & Grid */
.species-selector-track {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.25rem 0 1rem;
  margin-bottom: 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border-active) transparent;
}

.species-selector-track::-webkit-scrollbar {
  height: 4px;
}

.species-selector-track::-webkit-scrollbar-thumb {
  background: var(--border-active);
  border-radius: 4px;
}

.species-chip {
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  min-width: 140px;
}

.species-chip:hover {
  border-color: var(--border-active);
  background: var(--bg-card-hover);
}

.species-chip.active {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.08);
  box-shadow: 0 0 15px var(--accent-cyan-glow);
}

.chip-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.chip-hz {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-cyan);
}

.chip-ratio {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Species Scene Simulation Viewer */
.simulation-box {
  background: #000000;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  height: 280px;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
}

canvas#sceneCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.simulation-overlay {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  right: 0.75rem;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.sim-tag {
  background: rgba(14, 18, 26, 0.85);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Pulse Timeline Bar (1 Real Second) */
.timeline-pulse-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 0.5rem;
}

.timeline-bar-wrapper {
  position: relative;
  width: 100%;
  height: 36px;
  background: #05070a;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

canvas#timelineCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.timeline-markers {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Species Narrative Detail Box */
.species-detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-top: 1.5rem;
}

.detail-header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.species-latin-name {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.species-quote-text {
  font-size: 1.05rem;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: 1.25rem;
  font-family: var(--font-serif);
}

.species-metabolic-note {
  font-size: 0.875rem;
  color: var(--text-secondary);
  background: var(--bg-panel);
  border-left: 3px solid var(--accent-cyan);
  padding: 0.75rem 1rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Allometric Table & Cards */
.phenomena-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.phenomenon-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, border-color 0.2s;
}

.phenomenon-card:hover {
  border-color: var(--border-active);
  transform: translateY(-2px);
}

.phenomenon-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  line-height: 1.35;
}

.phenomenon-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* Data Table */
.table-responsive-wrapper {
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

table.data-table th, table.data-table td {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border-subtle);
}

table.data-table th {
  background: var(--bg-panel);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

table.data-table tr:last-child td {
  border-bottom: none;
}

table.data-table tr:hover td {
  background: var(--bg-card-hover);
}

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

table.data-table tr.highlight-human td {
  background: rgba(245, 158, 11, 0.06);
  font-weight: 600;
}

/* Methodology & Literature */
.method-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-top: 1.5rem;
}

.method-prose {
  font-size: 0.925rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 1.25rem;
}

.biblio-list {
  list-style: none;
  font-size: 0.825rem;
  color: var(--text-muted);
  line-height: 1.5;
  border-top: 1px solid var(--border-subtle);
  padding-top: 1rem;
}

.biblio-list li {
  margin-bottom: 0.75rem;
  padding-left: 1.25rem;
  text-indent: -1.25rem;
}

.biblio-list a {
  color: var(--accent-cyan);
  text-decoration: none;
}

.biblio-list a:hover {
  text-decoration: underline;
}

/* Footer */
footer.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  padding: 2.5rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

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

.footer-links {
  display: flex;
  gap: 1.25rem;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-links a:hover {
  color: var(--text-primary);
}

.back-to-top-btn {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.back-to-top-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-active);
}

/* Reduced Motion & Fallbacks */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .stat-box:hover, .phenomenon-card:hover {
    transform: none;
  }
  input[type="range"].custom-slider::-webkit-slider-thumb:hover {
    transform: none;
  }
}

/* Noscript notice */
.noscript-banner {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid var(--accent-amber);
  color: var(--text-primary);
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 2rem;
  font-size: 0.9rem;
}
