/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0e17;
  --bg2: #111827;
  --bg3: #1f2937;
  --text: #e5e7eb;
  --text-dim: #9ca3af;
  --accent: #3b82f6;
  --accent2: #8b5cf6;
  --gold: #f59e0b;
  --red: #ef4444;
  --green: #22c55e;
  --border: #374151;
  --card: #1a2332;
  --card-hover: #243044;
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

/* === HERO === */
.hero {
  position: relative;
  min-height: 50vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #0c1445 0%, #1a0a2e 40%, #0a1628 100%);
  z-index: 0;
}

.hero-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 50%, rgba(59,130,246,0.15) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 50%, rgba(139,92,246,0.1) 0%, transparent 60%);
}

.hero-content {
  position: relative;
  z-index: 1;
  padding: 3rem 1rem;
}

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 5rem);
  font-weight: 800;
  background: linear-gradient(135deg, #60a5fa, #a78bfa, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
  letter-spacing: -1px;
}

.subtitle {
  font-size: 1.2rem;
  color: var(--text-dim);
  margin-bottom: 2rem;
}

.main-nav {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.nav-btn {
  padding: 0.6rem 1.5rem;
  border-radius: 2rem;
  background: var(--bg3);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s;
  border: 1px solid var(--border);
}
.nav-btn:hover, .nav-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* === SECTIONS === */
.section {
  max-width: 1400px;
  margin: 0 auto;
  padding: 4rem 1.5rem;
}

.section h2 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #fff;
}

.section-desc {
  color: var(--text-dim);
  margin-bottom: 2rem;
  font-size: 1rem;
}

/* === BUTTONS === */
.btn {
  padding: 0.5rem 1.5rem;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #2563eb; }

/* === TIMELINE === */
.timeline-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.year-display {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  min-width: 140px;
}

#timelineSlider {
  flex: 1;
  min-width: 200px;
  accent-color: var(--accent);
  height: 6px;
}

.timeline-container {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (max-width: 900px) {
  .timeline-container { grid-template-columns: 1fr; }
}

.gov-animation {
  background: var(--card);
  border-radius: 1rem;
  padding: 1.5rem;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  border: 1px solid var(--border);
  position: relative;
  overflow-y: auto;
  max-height: 600px;
}

.gov-info-panel {
  background: var(--card);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  overflow-y: auto;
  max-height: 450px;
}

.gov-info-panel h3 { color: var(--accent); margin-bottom: 0.5rem; }
.gov-info-panel .pm-name {
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.3rem;
}
.gov-info-panel .pm-party {
  color: var(--text-dim);
  margin-bottom: 1rem;
}
.gov-info-panel .coalition-list {
  list-style: none;
}
.gov-info-panel .coalition-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.party-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* Timeline bar */
.timeline-bar-container {
  background: var(--bg3);
  border-radius: 0.5rem;
  padding: 1rem;
  overflow-x: auto;
}

#timelineBar {
  display: flex;
  height: 60px;
  border-radius: 0.5rem;
  overflow: hidden;
  min-width: 800px;
}

.timeline-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
  padding: 0.25rem;
  cursor: pointer;
  transition: opacity 0.3s, filter 0.3s;
  line-height: 1.2;
  position: relative;
  overflow: hidden;
}
.timeline-segment:hover {
  filter: brightness(1.3);
}
.timeline-segment.active {
  outline: 3px solid var(--gold);
  outline-offset: -3px;
}

/* === KNESSET SPLIT VIEW (Coalition vs Opposition) === */
.knesset-split {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  width: 100%;
}

.knesset-group {
  flex: 1;
  min-width: 0;
}

.group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.coalition-group .group-header { border-color: var(--green); }
.opposition-group .group-header { border-color: #6b7280; }

.group-label {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.coalition-group .group-label { color: var(--green); }
.opposition-group .group-label { color: #9ca3af; }

.group-count {
  font-size: 1.5rem;
  font-weight: 800;
}
.coalition-group .group-count { color: var(--green); }
.opposition-group .group-count { color: #6b7280; }

.seat-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: 0.75rem;
}

.seat-grid .seat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.opposition-group .seat-dot { opacity: 0.45; }

.knesset-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding-top: 2rem;
  flex-shrink: 0;
}

.divider-line {
  width: 2px;
  height: 30px;
  background: var(--border);
}

.divider-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold);
  background: var(--bg3);
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
}

.party-legend {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.legend-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-seats {
  font-weight: 700;
  color: var(--text);
  min-width: 20px;
  text-align: right;
}

@media (max-width: 600px) {
  .knesset-split { flex-direction: column; }
  .knesset-divider { flex-direction: row; padding-top: 0; }
  .divider-line { width: 30px; height: 2px; }
}

/* === ELECTIONS === */
.election-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.election-tab {
  padding: 0.5rem 1rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
}
.election-tab:hover { border-color: var(--accent); color: var(--accent); }
.election-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.election-tab.no-govt { border-left: 3px solid var(--red); }

.election-detail {
  background: var(--card);
  border-radius: 1rem;
  padding: 2rem;
  border: 1px solid var(--border);
}

.election-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.election-header h3 {
  font-size: 1.5rem;
  color: #fff;
}

.election-meta {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.meta-item {
  text-align: center;
}
.meta-item .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}
.meta-item .label {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.main-topic {
  background: var(--bg3);
  border-left: 4px solid var(--gold);
  padding: 1rem;
  border-radius: 0 0.5rem 0.5rem 0;
  margin-bottom: 1.5rem;
  font-style: italic;
  color: var(--text-dim);
}

/* Parties table */
.parties-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 2rem;
}

.parties-table th {
  background: var(--bg3);
  padding: 0.6rem 0.8rem;
  text-align: left;
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.parties-table td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.parties-table tr:hover td {
  background: var(--bg3);
}

.party-name-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.vote-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--accent);
  transition: width 1s ease;
}

.seats-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 1rem;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
}

.in-coalition {
  background: var(--green) !important;
}

/* Coalition section */
.coalition-section {
  background: var(--bg2);
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}
.coalition-section h4 {
  color: var(--gold);
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

/* Knesset seats visualization */
.knesset-viz {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin: 1rem 0;
  justify-content: center;
}
.seat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transition: all 0.5s;
}

/* Achievement ratings */
.achievement-list {
  list-style: none;
}

.achievement-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.achievement-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}

.achievement-name {
  font-weight: 600;
  color: #fff;
}

.rating-badge {
  padding: 0.2rem 0.6rem;
  border-radius: 1rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
}

.rating-0, .rating-1 { background: #dc2626; }
.rating-2, .rating-3 { background: #ea580c; }
.rating-4, .rating-5 { background: #ca8a04; }
.rating-6, .rating-7 { background: #65a30d; }
.rating-8, .rating-9, .rating-10 { background: #16a34a; }

.achievement-note {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.overall-rating {
  text-align: center;
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 0.75rem;
}

.overall-rating .value {
  font-size: 3rem;
  font-weight: 800;
}

.overall-rating .label {
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* Lost votes callout */
.lost-votes-callout {
  background: linear-gradient(135deg, #7f1d1d33, #1f293700);
  border: 1px solid #dc2626;
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-top: 1.5rem;
}

.lost-votes-callout h4 {
  color: var(--red);
  margin-bottom: 0.5rem;
}

/* === STATS GRID === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 1.5rem;
}

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

.stat-card {
  background: var(--card);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  transition: border-color 0.3s;
}
.stat-card:hover { border-color: var(--accent); }

.stat-card h3 {
  font-size: 1rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
  font-weight: 600;
}

/* === COMPARE === */
.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.compare-card {
  background: var(--card);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  transition: transform 0.3s, border-color 0.3s;
  cursor: default;
}
.compare-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.compare-card .pm { font-size: 1.2rem; font-weight: 700; color: #fff; }
.compare-card .period { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 0.5rem; }
.compare-card .rating-big {
  font-size: 2.5rem;
  font-weight: 800;
  text-align: center;
  margin: 0.5rem 0;
}

.compare-chart-container {
  background: var(--card);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  max-height: 500px;
}

/* === LOST VOTES === */
#lostVotesContent {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.lost-vote-card {
  background: var(--card);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
}
.lost-vote-card.critical {
  border-color: var(--red);
  background: linear-gradient(135deg, #1a233266, #7f1d1d22);
}

.lost-vote-card h4 { color: var(--accent); margin-bottom: 0.5rem; }
.lost-vote-card .pct { font-size: 2rem; font-weight: 800; color: var(--red); }

/* === FOOTER === */
footer {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  max-width: 1400px;
  margin: 0 auto;
}

/* === ANIMATIONS === */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.fade-in {
  animation: fadeInUp 0.6s ease forwards;
}

.knesset-semicircle {
  position: relative;
  width: 300px;
  height: 160px;
  margin: 0 auto;
}

/* PM portrait placeholder */
.pm-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  margin: 0 auto 1rem;
  border: 3px solid var(--gold);
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* Responsive */
@media (max-width: 768px) {
  .section { padding: 2rem 1rem; }
  .election-header { flex-direction: column; }
  .timeline-controls { flex-direction: column; align-items: stretch; }
  .stats-grid { grid-template-columns: 1fr; }
}

/* Tooltip */
.tooltip {
  position: fixed;
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  color: var(--text);
  pointer-events: none;
  z-index: 1000;
  max-width: 300px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

/* No-govt badge */
.no-govt-badge {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  background: var(--red);
  color: #fff;
  border-radius: 1rem;
  font-weight: 700;
  font-size: 0.8rem;
}

/* Progress bar for rating */
.rating-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.3rem;
}
.rating-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 1s ease;
}
