/* ==========================================================================
   Podeaua de sub pendul / The Floor Under the Pendulum
   Visual family: 19th Century Astronomical Observatory & Precision Instrument
   ========================================================================== */

:root {
  --bg-deep: #0a0d12;
  --bg-surface: #12171f;
  --bg-card: #18202c;
  --bg-card-hover: #1f2937;
  --border-subtle: #232c3d;
  --border-strong: #3b475d;
  
  --brass-glow: #fbbf24;
  --brass-main: #d97706;
  --brass-dark: #78350f;
  --brass-tint: rgba(217, 119, 6, 0.12);
  
  --copper-needle: #f97316;
  --copper-glow: rgba(249, 115, 22, 0.4);
  
  --pin-active: #e2e8f0;
  --pin-down: #475569;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --font-display: 'Cinzel', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  
  --max-width: 1040px;
}

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

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

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

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.visually-hidden:focus {
  position: static !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  clip: auto !important;
  white-space: normal !important;
  padding: 0.5rem 1rem !important;
  background: var(--brass-main) !important;
  color: #000 !important;
  font-weight: 700 !important;
  z-index: 1000 !important;
}

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

/* --------------------------------------------------------------------------
   Top Bar & Language Switcher
   -------------------------------------------------------------------------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.brand {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 700;
  transition: color 0.15s ease;
}

.brand:hover {
  color: var(--brass-glow);
}

.langsw {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.langsw a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.langsw a[aria-current="page"] {
  color: var(--brass-glow);
  font-weight: 700;
  background: var(--brass-tint);
}

.langsw a:hover:not([aria-current="page"]) {
  color: var(--text-primary);
}

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

.kicker {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass-main);
  margin-bottom: 0.85rem;
  font-weight: 500;
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.15;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  font-weight: 700;
}

.standfirst {
  font-size: clamp(1.05rem, 2vw, 1.22rem);
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: 820px;
  margin-bottom: 2.5rem;
}

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

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

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--brass-main), transparent);
  opacity: 0.6;
}

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

.stat-num {
  font-family: var(--font-mono);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--brass-glow);
  line-height: 1.2;
  margin-bottom: 0.35rem;
}

.stat-label {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

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

/* --------------------------------------------------------------------------
   Interactive Observatory Dial (Signature Element)
   -------------------------------------------------------------------------- */
.stage-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 2.25rem 1.75rem;
  margin-bottom: 4rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.stage-head {
  text-align: center;
  max-width: 680px;
  margin: 0 auto 2rem;
}

.stage-head h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.stage-head p {
  color: var(--text-secondary);
  font-size: 0.98rem;
}

.stage-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 2rem;
  align-items: center;
}

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

.dial-container {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  padding: 1rem;
}

.dial-wrap {
  width: 100%;
  max-width: 440px;
  aspect-ratio: 1 / 1;
  position: relative;
}

#pendulum-canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  background: radial-gradient(circle, #131a26 0%, #0c1017 70%, #080b0f 100%);
  box-shadow: inset 0 0 30px rgba(0,0,0,0.8), 0 0 0 2px var(--border-strong), 0 0 25px rgba(217, 119, 6, 0.15);
}

/* Control Panel */
.deck {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.deck-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.deck-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.deck-val {
  color: var(--brass-glow);
  font-weight: 600;
}

/* Readouts Box */
.readout-box {
  background: rgba(10, 13, 18, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

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

.readout-k {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.readout-v {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.readout-v.highlight {
  color: var(--brass-glow);
}

/* Buttons and Controls */
.btn-group {
  display: flex;
  gap: 0.5rem;
}

.btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
  flex: 1;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--brass-main);
  color: var(--brass-glow);
}

.btn.primary {
  background: var(--brass-main);
  border-color: var(--brass-main);
  color: #000;
  font-weight: 700;
}

.btn.primary:hover {
  background: var(--brass-glow);
  border-color: var(--brass-glow);
  color: #000;
}

.btn[aria-pressed="true"] {
  background: var(--brass-tint);
  border-color: var(--brass-glow);
  color: var(--brass-glow);
  font-weight: 700;
}

/* Radio Pill Group */
.pill-group {
  display: flex;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.2rem;
  gap: 0.2rem;
}

.pill-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.45rem 0.5rem;
  border-radius: calc(var(--radius-sm) - 1px);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.pill-btn:hover {
  color: var(--text-primary);
}

.pill-btn[aria-pressed="true"] {
  background: var(--bg-card-hover);
  color: var(--brass-glow);
  font-weight: 600;
}

/* Range Inputs */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  outline: none;
  margin: 0.4rem 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brass-glow);
  border: 2px solid #000;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
  transition: transform 0.1s ease;
}

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

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brass-glow);
  border: 2px solid #000;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

/* Presets Bar */
.presets-container {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
}

.presets-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.preset-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

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

.preset-chip:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.preset-chip[aria-pressed="true"] {
  background: var(--brass-tint);
  border-color: var(--brass-main);
  color: var(--brass-glow);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Essay & Editorial Sections
   -------------------------------------------------------------------------- */
.prose-section {
  padding: 2.5rem 0;
  border-top: 1px solid var(--border-subtle);
}

.prose-content {
  max-width: 760px;
  margin: 0 auto;
}

.prose-block {
  margin-bottom: 3.25rem;
}

.prose-block h2 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  letter-spacing: 0.02em;
  color: var(--text-primary);
  margin-bottom: 1.1rem;
  font-weight: 700;
  line-height: 1.25;
}

.prose-block p {
  font-size: 1.08rem;
  line-height: 1.75;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

/* Comparison Table */
.data-table-wrap {
  margin: 2rem 0;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

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

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

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

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

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.data-table td.highlight {
  color: var(--brass-glow);
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   Sources Section
   -------------------------------------------------------------------------- */
.sources-section {
  padding: 3rem 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
}

.sources-content {
  max-width: 760px;
  margin: 0 auto;
}

.sources-content h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.sources-content p {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.sources-list {
  list-style: decimal inside;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sources-list li {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.sources-list a {
  color: var(--brass-glow);
  text-decoration: none;
  transition: text-decoration 0.15s ease;
}

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

.source-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  padding-left: 1rem;
  border-left: 2px solid var(--border-strong);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
footer {
  padding: 2.5rem 0;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 1rem;
}

footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}

footer a:hover {
  color: var(--brass-glow);
}

.totop {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  padding: 0.35rem 0.7rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.totop:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Reduced Motion Support
   -------------------------------------------------------------------------- */
@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;
  }
}
