/* ═══════════════════════════════════════════════
   ElectionSim - Political Campaign Aesthetic
   Bold reds/blues, newspaper/rally poster vibe
   ═══════════════════════════════════════════════ */

:root {
  --red: #b91c1c;
  --red-light: #fecaca;
  --blue: #1e40af;
  --blue-light: #bfdbfe;
  --gold: #b45309;
  --gold-light: #fef3c7;
  --green: #15803d;
  --green-light: #bbf7d0;
  --bg: #faf9f6;
  --bg-dark: #1c1917;
  --text: #1c1917;
  --text-muted: #78716c;
  --border: #d6d3d1;
  --card-bg: #ffffff;
  --shadow: 0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.15);
  --radius: 6px;
  --font: 'Georgia', 'Times New Roman', serif;
  --font-sans: 'Arial', 'Helvetica Neue', sans-serif;
  --font-mono: 'Courier New', monospace;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Typography ── */

h1, h2, h3, h4 {
  font-family: var(--font);
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }

.headline {
  font-family: var(--font);
  font-size: 3rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.03em;
  line-height: 1.1;
  border-bottom: 4px solid var(--text);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.subheadline {
  font-family: var(--font);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.text-muted { color: var(--text-muted); }
.text-red { color: var(--red); }
.text-blue { color: var(--blue); }
.text-green { color: var(--green); }
.text-gold { color: var(--gold); }

/* ── Layout ── */

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.container-wide {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.flex-col { display: flex; flex-direction: column; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ── Header/Banner ── */

.banner {
  background: var(--bg-dark);
  color: white;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 4px solid var(--red);
}

.banner h1 {
  font-family: var(--font);
  font-size: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.banner .round-info {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--gold-light);
}

/* ── Cards ── */

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card-header {
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.card-campaign {
  border-left: 4px solid var(--blue);
}

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

.card-danger {
  border-left: 4px solid var(--red);
}

.card-success {
  border-left: 4px solid var(--green);
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}
.btn-primary:hover { background: #1e3a8a; }

.btn-danger {
  background: var(--red);
  color: white;
  border-color: var(--red);
}
.btn-danger:hover { background: #991b1b; }

.btn-success {
  background: var(--green);
  color: white;
  border-color: var(--green);
}

.btn-gold {
  background: var(--gold);
  color: white;
  border-color: var(--gold);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover { border-color: var(--text); }

.btn-sm { padding: 0.3rem 0.8rem; font-size: 0.75rem; }
.btn-lg { padding: 0.8rem 2rem; font-size: 1.1rem; }
.btn-block { display: flex; width: 100%; }

/* ── Forms ── */

.form-group { margin-bottom: 1rem; }

.form-group label {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: var(--font-sans);
  background: white;
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--blue);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2378716c' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

/* ── Ideology Buttons ── */

.ideology-btn {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: white;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.ideology-btn:hover {
  border-color: var(--ideo-color, var(--blue));
}

.ideology-btn.selected {
  border-color: var(--ideo-color, var(--blue));
  background: color-mix(in srgb, var(--ideo-color, var(--blue)) 12%, white);
  box-shadow: inset 0 0 0 2px var(--ideo-color, var(--blue));
}

/* ── Approval Bars ── */

.approval-bar {
  margin-bottom: 0.5rem;
}

.approval-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 2px;
}

.approval-bar-track {
  height: 20px;
  background: #e7e5e4;
  border-radius: 3px;
  overflow: hidden;
  display: flex;
}

.approval-bar-fill {
  height: 100%;
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
  min-width: 2rem;
}

/* ── Player Cards ── */

.player-card {
  border: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  transition: border-color 0.2s;
}

.player-card.active {
  border-color: var(--blue);
  box-shadow: var(--shadow-lg);
}

.player-color {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin: 0 auto 0.5rem;
  border: 3px solid var(--border);
}

.player-name {
  font-family: var(--font);
  font-weight: 700;
  font-size: 1.1rem;
}

.player-party {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.player-pc {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* ── Tabs ── */

.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1rem;
}

.tab {
  padding: 0.5rem 1rem;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  color: var(--text-muted);
}

.tab:hover { color: var(--text); }
.tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Modal ── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 550px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  border-top: 6px solid var(--gold);
}

.modal h2 {
  font-family: var(--font);
  margin-bottom: 0.5rem;
}

.modal-choices {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-choice {
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  background: white;
}

.modal-choice:hover {
  border-color: var(--blue);
  background: var(--blue-light);
}

.modal-choice-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.modal-choice-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Turn Transition Screen ── */

.turn-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.turn-screen.active {
  opacity: 1;
  pointer-events: auto;
}

.turn-screen h1 {
  font-family: var(--font);
  font-size: 2.5rem;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.turn-screen .turn-party {
  font-style: italic;
  font-size: 1.2rem;
  color: var(--gold-light);
  margin-bottom: 2rem;
}

/* ── Preset Cards ── */

.preset-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.preset-card:hover { border-color: var(--blue); }
.preset-card.selected {
  border-color: var(--blue);
  background: var(--blue-light);
}

.preset-flag { font-size: 2rem; margin-bottom: 0.5rem; }
.preset-name { font-weight: 700; font-size: 1rem; }
.preset-desc { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ── Results ── */

.result-banner {
  text-align: center;
  padding: 3rem 1rem;
  background: var(--bg-dark);
  color: white;
}

.result-banner h1 {
  font-size: 3rem;
  text-transform: uppercase;
}

.result-bar {
  display: flex;
  height: 50px;
  border-radius: var(--radius);
  overflow: hidden;
  margin: 1rem 0;
}

.result-bar-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
  transition: width 2s ease;
}

/* ── Responsive ── */

@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .headline { font-size: 2rem; }
  .container { padding: 1rem; }
}

/* ── Utility ── */

.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

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

/* ── Loading ── */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.3s ease; }
