/* European BESS Index - Clean, techy, data-focused design */

:root {
  --bg: #fafafa;
  --bg-card: #ffffff;
  --bg-code: #f4f4f5;
  --text: #18181b;
  --text-muted: #71717a;
  --text-light: #a1a1aa;
  --border: #e4e4e7;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #ea580c;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --max-w: 1120px;
  --radius: 6px;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 24px; }
.container-narrow { max-width: 780px; margin: 0 auto; padding: 0 24px; }

/* Navigation */
nav {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}
nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.nav-brand {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-brand .dot {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  display: inline-block;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.nav-links { display: flex; gap: 4px; list-style: none; }
.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: all 0.15s;
  font-weight: 500;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--text);
  background: var(--bg-code);
}

/* Mobile nav */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--text);
}
.nav-toggle svg { width: 20px; height: 20px; }

@media (max-width: 768px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 8px 24px 16px;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 10px 12px; }
}

/* Typography */
h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 16px;
}
h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin-bottom: 12px;
  margin-top: 40px;
}
h3 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
  margin-top: 24px;
}
p { margin-bottom: 16px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 3px;
}
small { font-size: 0.82rem; color: var(--text-muted); }

/* Hero */
.hero {
  padding: 64px 0 48px;
  border-bottom: 1px solid var(--border);
}
.hero h1 { font-size: 2.4rem; max-width: 640px; }
.hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 560px;
  line-height: 1.7;
}
.hero-meta {
  margin-top: 20px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.hero-meta span {
  font-size: 0.78rem;
  color: var(--text-light);
  font-family: var(--font-mono);
}

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 32px 0;
  overflow: hidden;
}
.stat {
  background: var(--bg-card);
  padding: 20px 24px;
}
.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-family: var(--font-mono);
}
.stat-value.green { color: var(--green); }
.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.card h3 { margin-top: 0; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 24px 0;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
thead { background: var(--bg-code); }
th {
  text-align: left;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
tr:hover { background: var(--bg-code); }
.mono { font-family: var(--font-mono); font-size: 0.82rem; }

/* Tags / badges */
.tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--bg-code);
  color: var(--text-muted);
  font-weight: 500;
  margin: 1px 2px;
  white-space: nowrap;
}
.tag-green { background: #dcfce7; color: #166534; }
.tag-blue { background: #dbeafe; color: #1e40af; }
.tag-orange { background: #ffedd5; color: #9a3412; }

/* Section */
.section {
  padding: 40px 0;
  border-bottom: 1px solid var(--border);
}
.section:last-child { border-bottom: none; }
.section-header {
  margin-bottom: 24px;
}
.section-header p { color: var(--text-muted); }

/* Charts area */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin: 24px 0;
  min-height: 300px;
}
.chart-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 16px;
}
.chart-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: -12px;
  margin-bottom: 16px;
}

/* Bar chart (CSS-based) */
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.bar-label {
  width: 80px;
  font-size: 0.78rem;
  font-weight: 500;
  text-align: right;
  flex-shrink: 0;
}
.bar-track {
  flex: 1;
  height: 24px;
  background: var(--bg-code);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.6s ease;
  display: flex;
  align-items: center;
  padding-left: 8px;
}
.bar-fill span {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
}

/* Heat map */
.heatmap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 4px;
  margin: 16px 0;
}
.heatmap-cell {
  padding: 12px 8px;
  text-align: center;
  border-radius: 4px;
  font-size: 0.78rem;
}
.heatmap-cell .country { font-weight: 600; font-size: 0.82rem; display: block; }
.heatmap-cell .value { font-family: var(--font-mono); font-size: 0.75rem; display: block; margin-top: 2px; }
.heat-5 { background: #166534; color: #fff; }
.heat-4 { background: #16a34a; color: #fff; }
.heat-3 { background: #86efac; color: #166534; }
.heat-2 { background: #bbf7d0; color: #166534; }
.heat-1 { background: #dcfce7; color: #166534; }
.heat-0 { background: var(--bg-code); color: var(--text-muted); }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  background: var(--bg-card);
  color: var(--text);
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-group textarea { min-height: 120px; resize: vertical; }
.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

.btn {
  display: inline-block;
  padding: 10px 20px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; text-decoration: none; }

/* Comparison table specific */
.company-row td:first-child { font-weight: 600; }
.check { color: var(--green); }
.cross { color: var(--text-light); }

/* Filter controls */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.filter-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-sans);
  color: var(--text-muted);
}
.filter-btn:hover, .filter-btn.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* Methodology note */
.methodology {
  background: var(--bg-code);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 24px 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.methodology strong { color: var(--text); }

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: 40px;
}
footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}
footer p { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0; }
footer a { color: var(--text-muted); }
footer a:hover { color: var(--text); }

/* Breadcrumb */
.breadcrumb {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 16px 0 0;
}
.breadcrumb a { color: var(--text-muted); }

/* Page header */
.page-header {
  padding: 40px 0 32px;
  border-bottom: 1px solid var(--border);
}
.page-header h1 { margin-bottom: 8px; }
.page-header p { color: var(--text-muted); max-width: 600px; }

/* Last updated strip */
.last-updated {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-light);
  padding: 8px 0;
}

/* Prose content */
.prose { max-width: 680px; }
.prose h2 { margin-top: 48px; }
.prose h3 { margin-top: 32px; }
.prose ul, .prose ol {
  margin-bottom: 16px;
  padding-left: 24px;
}
.prose li { margin-bottom: 6px; }
.prose blockquote {
  border-left: 3px solid var(--border);
  padding-left: 16px;
  color: var(--text-muted);
  margin: 16px 0;
}

/* Accordion */
.accordion-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.accordion-trigger {
  width: 100%;
  padding: 14px 16px;
  background: none;
  border: none;
  text-align: left;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text);
}
.accordion-trigger:hover { background: var(--bg-code); }
.accordion-trigger::after { content: '+'; font-weight: 400; color: var(--text-muted); }
.accordion-trigger.open::after { content: '−'; }
.accordion-content {
  display: none;
  padding: 0 16px 16px;
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text-muted);
}
.accordion-content.open { display: block; }

/* Comparison matrix */
.comparison-matrix { position: relative; }
.comparison-matrix th.sticky {
  position: sticky;
  left: 0;
  background: var(--bg-code);
  z-index: 1;
}
.comparison-matrix td.sticky {
  position: sticky;
  left: 0;
  background: var(--bg-card);
  z-index: 1;
}

/* Tooltip */
.tooltip {
  position: relative;
  cursor: help;
  border-bottom: 1px dotted var(--text-muted);
}
.tooltip:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 3px;
  white-space: nowrap;
  z-index: 10;
}

/* Print */
@media print {
  nav, footer, .filters, .btn { display: none; }
  .container { max-width: 100%; }
}

/* Revenue range bars */
.revenue-range {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.revenue-bar {
  height: 16px;
  background: linear-gradient(90deg, var(--green), var(--accent));
  border-radius: 2px;
  min-width: 20px;
}

/* Sticky table header */
.table-wrap.sticky-header thead th {
  position: sticky;
  top: 56px;
  background: var(--bg-code);
  z-index: 5;
}

/* Fix table header readability */
thead th {
  background: #f4f4f5;
  font-size: 0.72rem;
  padding: 12px 16px;
  white-space: nowrap;
  vertical-align: bottom;
}
thead th small {
  display: block;
  font-weight: 400;
  color: var(--text-light);
  margin-top: 2px;
}

/* Responsive table improvements */
@media (max-width: 768px) {
  .table-wrap { font-size: 0.82rem; }
  td, th { padding: 8px 10px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 1.6rem; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.2rem; }
}
