/* Treizeci și nouă de biți pe secundă - Typography & Layout */
:root {
  --bg: #faf8f5;
  --bg-surface: #ffffff;
  --bg-subtle: #f2ede4;
  --bg-card: #f9f6f0;
  --border: #e2dacd;
  --border-strong: #c8bcab;
  --text-main: #1d1b18;
  --text-muted: #5e5950;
  --text-dim: #8c8577;
  --accent: #b84a39;
  --accent-light: #fbeee8;
  --accent-dark: #8c2a1c;
  --teal: #1b6a73;
  --teal-light: #e5f3f4;
  --indigo: #2c3e6b;
  --indigo-light: #e8ecf8;
  --gold: #b37d14;
  --gold-light: #fef6e2;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Roboto Mono", Consolas, monospace;
}

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

html {
  font-size: 18px;
  line-height: 1.65;
  color: var(--text-main);
  background-color: var(--bg);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-serif);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Container */
.container {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.wide-container {
  width: 100%;
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

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

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-brand {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.site-brand:hover {
  color: var(--accent);
}

.lang-switch {
  display: inline-flex;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--bg-subtle);
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.lang-switch a {
  text-decoration: none;
  color: var(--text-muted);
  padding: 0.1rem 0.35rem;
  border-radius: 2px;
}

.lang-switch a.active {
  background: var(--bg-surface);
  color: var(--text-main);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Article Hero */
.hero {
  padding: 3.5rem 0 2rem 0;
}

.kicker {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.75rem;
  display: block;
}

h1.title {
  font-family: var(--font-serif);
  font-size: 2.6rem;
  line-height: 1.15;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
}

.deck {
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-style: italic;
}

.metadata-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  margin-bottom: 2.5rem;
}

/* Text Content */
article p {
  margin-bottom: 1.35rem;
  text-align: justify;
  text-justify: inter-word;
}

article h2 {
  font-family: var(--font-sans);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 2.8rem 0 1rem 0;
  letter-spacing: -0.01em;
}

article h3 {
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 1.8rem 0 0.6rem 0;
}

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

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.stat-card.featured {
  border-left: 4px solid var(--accent);
  background: var(--accent-light);
}

.stat-card.teal {
  border-left: 4px solid var(--teal);
  background: var(--teal-light);
}

.stat-card.indigo {
  border-left: 4px solid var(--indigo);
  background: var(--indigo-light);
}

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

.stat-unit {
  font-size: 0.85rem;
  font-weight: normal;
  color: var(--text-muted);
}

.stat-label {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.stat-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Interactive Oscilloscope & Bandwidth Instrument */
.instrument-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin: 2.5rem 0;
  box-shadow: var(--shadow-md);
}

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

.instrument-title {
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.instrument-subtitle {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Tabs & Tool selectors */
.instrument-modes {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.mode-btn {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.mode-btn:hover {
  background: var(--bg-card);
  color: var(--text-main);
}

.mode-btn.active {
  background: var(--text-main);
  color: #ffffff;
  border-color: var(--text-main);
}

/* Chart Canvas / SVG Container */
.chart-container {
  position: relative;
  width: 100%;
  height: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.chart-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Scatter dots & hover */
.scatter-dot {
  cursor: pointer;
  transition: transform 0.15s ease, r 0.15s ease;
}

.scatter-dot:hover, .scatter-dot.selected {
  stroke: #1d1b18;
  stroke-width: 2.5px;
  r: 8px;
}

.scatter-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  fill: var(--text-main);
  pointer-events: none;
}

/* Interactive Pulse Simulator */
.pulse-board {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.stream-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.lang-selector-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lang-select {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
}

.action-btn {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 1rem;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.15s ease;
}

.action-btn:hover {
  background: var(--accent-dark);
}

.action-btn.secondary {
  background: var(--bg-subtle);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.action-btn.secondary:hover {
  background: var(--border);
}

/* Packet Stream Visualizer */
.packet-track {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  margin-bottom: 1rem;
  min-height: 85px;
  position: relative;
  overflow: hidden;
}

.packet-track-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
  display: flex;
  justify-content: space-between;
}

.syllables-stream {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.syllable-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.2rem 0.45rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.syllable-badge.fired {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent-dark);
  transform: scale(1.08);
  font-weight: 700;
}

/* Bandwidth Meter Gauge */
.bandwidth-meter-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
}

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

.meter-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.meter-track {
  width: 100%;
  height: 16px;
  background: var(--bg-subtle);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.meter-fill {
  height: 100%;
  background: linear-gradient(90deg, #2a9d8f, #e76f51, #e63946);
  width: 0%;
  transition: width 0.25s ease-out;
}

.meter-target-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 61.17%; /* 39.15 / 64 max */
  width: 2px;
  background: #1d1b18;
  z-index: 2;
}

.meter-target-label {
  position: absolute;
  top: -16px;
  left: 61.17%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--text-main);
}

/* Dual Race Simulator */
.dual-race-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

@media (max-width: 680px) {
  .dual-race-grid {
    grid-template-columns: 1fr;
  }
}

.race-lane {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
}

.lane-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

.lane-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.95rem;
}

.lane-stats {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.lane-bar-track {
  width: 100%;
  height: 8px;
  background: var(--bg-subtle);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.lane-bar-fill {
  height: 100%;
  background: var(--teal);
  width: 0%;
  transition: width 0.1s linear;
}

/* Language Detail Card */
.lang-info-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-top: 1rem;
}

.lang-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.info-item {
  display: flex;
  flex-direction: column;
}

.info-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-dim);
}

.info-val {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.sentence-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  margin-top: 0.5rem;
}

.sentence-orig {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-style: italic;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.sentence-trans {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Theoretical Extremes Slider */
.slider-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin: 1.5rem 0;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0.75rem 0;
}

.slider-input {
  flex-grow: 1;
  accent-color: var(--accent);
  cursor: pointer;
}

.slider-val-box {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  min-width: 80px;
  text-align: right;
}

.slider-feedback {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  line-height: 1.45;
}

.slider-feedback.warning {
  border-left: 4px solid var(--accent);
  background: var(--accent-light);
}

.slider-feedback.optimal {
  border-left: 4px solid var(--teal);
  background: var(--teal-light);
}

/* Static Fallback Table */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 2rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

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

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

table.data-table th {
  font-family: var(--font-sans);
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text-main);
  position: sticky;
  top: 0;
}

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

table.data-table .num {
  font-family: var(--font-mono);
  text-align: right;
}

/* Notes & Methodology */
.method-note {
  background: var(--bg-card);
  border-left: 3px solid var(--text-dim);
  padding: 1.25rem;
  margin: 2.5rem 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.method-note h3 {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

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

.footer-inner {
  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;
}

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

/* Back to Top */
#back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  z-index: 100;
  font-size: 1.1rem;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#back-to-top.visible {
  display: flex;
}

#back-to-top:hover {
  background: var(--text-main);
  color: #ffffff;
}

/* Responsive */
@media (max-width: 600px) {
  h1.title {
    font-size: 1.95rem;
  }
  .deck {
    font-size: 1.05rem;
  }
  .stat-number {
    font-size: 1.75rem;
  }
  .chart-container {
    height: 300px;
  }
  .metadata-bar {
    gap: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
