/**
 * styles.css — Battle of the Candidates
 *
 * Design concept: a campaign-broadsheet-meets-fight-poster. Navy/crimson/gold
 * (Texas ballot colors) carry through the whole thing; Anton (poster-condensed)
 * is used for anything shouting a headline, Source Serif for anything meant
 * to be read (the actual policy text is the point of this app).
 *
 * Section map: tokens -> base -> layout -> masthead -> fighter stage ->
 * briefing card -> race select -> matchup cards -> track record ->
 * results -> utility/a11y.
 */

/* ---------- Tokens ---------- */
:root {
  --navy: #16233E;
  --navy-deep: #0A1122;
  --navy-mid: #1E3055;
  --crimson: #C8102E;
  --crimson-deep: #8C0A21;
  --gold: #C6A15B;
  --gold-bright: #E7CD8E;
  --cream: #F6F1E4;
  --paper: #FFFFFF;
  --ink: #1C2230;
  --ink-soft: #59617A;
  --line: #E1D9C4;
  --dem: #2E6DA4;
  --rep: #C8412E;

  --radius-card: 10px;
  --radius-tight: 6px;
  --radius-pill: 999px;

  --shadow-soft: 0 8px 20px rgba(10, 17, 34, 0.16);
  --shadow-deep: 0 18px 40px rgba(10, 17, 34, 0.34);

  /* Updated font tokens for cleaner readability */
  --font-display: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-serif: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 0%, var(--navy-mid) 0%, transparent 75%),
    linear-gradient(180deg, var(--navy-deep) 0%, #05080F 100%);
  color: var(--ink);
  font-family: var(--font-sans);
  display: flex;
  justify-content: center;
  padding: clamp(16px, 5vw, 28px) 16px calc(48px + env(safe-area-inset-bottom, 0px));
}

.app { width: 100%; max-width: 740px; position: relative; }

button { font-family: inherit; }

:focus-visible {
  outline: 3px solid var(--gold-bright);
  outline-offset: 2px;
}

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

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

/* ---------- Masthead ---------- */
.masthead {
  text-align: center;
  margin-bottom: 20px;
  padding: 20px 16px 18px;
  background: linear-gradient(135deg, var(--navy) 0%, #001F3F 100%);
  border: 2px solid var(--gold);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-deep);
  position: relative;
}

.masthead::before {
  content: "★";
  display: block;
  color: var(--gold);
  font-size: 20px;
  margin-bottom: 8px;
  opacity: 0.85;
}

.masthead .eyebrow {
  letter-spacing: 0.22em;
  font-size: 15px;
  color: #9FB0C9;
  text-transform: uppercase;
  font-weight: 700;
  font-family: var(--font-sans);
}

.masthead h1 {
  font-family: var(--font-sans);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: clamp(32px, 8vw, 40px);
  margin: 6px 0 6px;
  color: #FFFFFF;
  text-shadow: none;
  line-height: 1.1;
}

.masthead p {
  font-family: var(--font-sans);
  font-size: 17px;
  color: #D9E1EF;
  margin: 0;
  line-height: 1.4;
}

/* ---------- Screens ---------- */
.screen { display: none; }
.screen.active { display: block; }

/* ---------- Fighter stage ---------- */
.fighter-stage {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  background: linear-gradient(180deg, #101B2B 0%, var(--navy-mid) 100%);
  border: 2px solid var(--gold);
  border-radius: var(--radius-card);
  padding: 12px 20px 0;
  margin-bottom: 16px;
  position: relative;
  height: 100px;
  overflow: hidden;
}

.fighter {
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.15s ease;
}

.fighter-sprite {
  font-size: clamp(34px, 9vw, 42px);
  line-height: 1;
  filter: drop-shadow(0px 4px 6px rgba(0, 0, 0, 0.6));
  user-select: none;
}

.fighter-left .fighter-sprite { transform: scaleX(-1); }

.fighter-tag {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.05em;
  color: #FFFFFF;
  background: rgba(0, 0, 0, 0.55);
  padding: 3px 7px;
  border-radius: var(--radius-tight);
  margin-bottom: 4px;
}

.vs-badge {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 26px;
  color: var(--gold);
  text-shadow: none;
  margin-bottom: 28px;
}

.punch-fx {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5) rotate(-10deg);
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 34px;
  color: #FF3B3B;
  text-shadow: none;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
  z-index: 10;
}

.punch-fx.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.3) rotate(5deg);
}

/* ---------- Briefing card ---------- */
.brief {
  background: var(--paper);
  border-radius: var(--radius-card);
  padding: 22px 18px;
  box-shadow: var(--shadow-soft);
  border-top: 5px solid var(--crimson);
}

.stamp-label {
  font-size: 15px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--navy);
  font-weight: 800;
  margin-bottom: 10px;
}

.brief ul {
  list-style-type: none;
  padding-left: 0;
  margin: 12px 0;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.55;
  color: #2D3748;
}

.brief li { margin-bottom: 10px; }

.disclaimer {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.5;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 14px;
}

.disclaimer a { color: var(--navy); font-weight: bold; }

/* ---------- Standout Home Intro Card ---------- */
.home-intro-card {
  background: linear-gradient(135deg, var(--navy) 0%, #1E3055 100%);
  border-radius: var(--radius-card);
  padding: 20px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-deep);
  border: 2px solid var(--gold);
  border-left: 6px solid var(--crimson);
}

.home-intro-card h2 {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gold-bright);
  margin: 0 0 8px 0;
  text-shadow: none;
}

.home-intro-card p {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: #F6F1E4;
  margin: 0;
}

.home-intro-card strong {
  color: var(--gold-bright);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 17px;
  padding: 14px 20px;
  min-height: 48px;
  border-radius: var(--radius-tight);
  border: none;
  background: linear-gradient(180deg, var(--crimson) 0%, var(--crimson-deep) 100%);
  color: #FFFFFF;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(200, 16, 46, 0.4);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(0.98); }
.btn-full { width: 100%; text-align: center; margin-top: 8px; }

.btn-alt {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  box-shadow: 0 4px 12px rgba(22, 35, 62, 0.4);
}

/* ---------- Race select ---------- */
.race-card {
  width: 100%;
  background: var(--paper);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: none;
  border-left: 6px solid var(--navy);
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.race-card:hover,
.race-card:focus-visible {
  transform: translateY(-2px);
  border-left-color: var(--crimson);
}

.rc-text { display: flex; flex-direction: column; }

.race-card .rc-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 21px;
  color: var(--navy);
}

.race-card .rc-sub {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ink-soft);
  margin-top: 3px;
  font-weight: 500;
}

.race-card .rc-go {
  font-size: 24px;
  color: var(--gold);
  font-weight: bold;
  flex-shrink: 0;
}

/* ---------- Progress tracker ---------- */
.tracker {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 15px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #A0AEC0;
  margin-bottom: 6px;
  font-weight: 700;
}

.tracker b { color: var(--gold); }

.track-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}

.track-bar span {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-bright) 100%);
  width: 0%;
  transition: width 0.3s ease;
}

.topic-label {
  text-align: center;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
}

/* ---------- Matchup / choice cards ---------- */
.matchup { position: relative; }

.pos-card {
  display: block;
  width: 100%;
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius-card);
  padding: 18px 16px;
  box-shadow: var(--shadow-soft);
  border: 3px solid transparent;
  margin-bottom: 12px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease, opacity 0.25s ease;
}

.pos-card:hover,
.pos-card:focus-visible { border-color: var(--navy); }

.pos-card:disabled { cursor: default; }

.pos-card .letter {
  font-size: 15px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--navy);
  font-weight: 800;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pos-card .ptext {
  display: block;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: #2D3748;
}

.pos-card .ptext strong { color: var(--navy); }

.ptext-block { display: block; margin-bottom: 10px; }
.ptext-lede {
  display: block;
  margin-bottom: 12px;
  font-weight: 600;
  color: var(--navy);
  font-size: 16px;
}

.pos-card.chosen {
  border-color: var(--gold);
  background: var(--cream);
}

.pos-card.faded { opacity: 0.4; }

.record-card { cursor: default; }
.record-card:hover { border-color: transparent; }

/* ---------- Track record actions ---------- */
.track-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.yesno-btn {
  flex: 1;
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 16px;
  padding: 12px;
  min-height: 44px;
  border-radius: var(--radius-tight);
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s ease, filter 0.1s ease;
}

.yesno-btn:hover { filter: brightness(1.1); }
.yesno-btn:active { transform: scale(0.98); }
.yesno-btn:disabled { cursor: default; opacity: 0.7; }

.btn-yes { background: linear-gradient(180deg, #2FA84F 0%, #1E7E34 100%); color: #FFFFFF; }
.btn-no { background: linear-gradient(180deg, var(--crimson) 0%, var(--crimson-deep) 100%); color: #FFFFFF; }

.divider {
  text-align: center;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.08em;
  color: #FFFFFF;
  margin: 10px 0;
  text-transform: uppercase;
}

.hint {
  text-align: center;
  font-size: 14px;
  color: #A0AEC0;
  margin-top: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---------- Results ---------- */
#results .filecard {
  background: var(--paper);
  border-radius: var(--radius-card);
  padding: 26px 18px;
  box-shadow: var(--shadow-deep);
  text-align: center;
  border-top: 6px solid var(--gold);
}

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px auto 8px;
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 26px;
  color: #FFFFFF;
  border: 3px solid #FFFFFF;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

#results h2 {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 26px;
  margin: 6px 0 2px;
  color: var(--navy);
}

#results .party-line {
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.bars {
  text-align: left;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.bar-row { margin-bottom: 12px; }

.bar-row .label {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  margin-bottom: 4px;
  font-weight: 600;
}

.bar-track {
  height: 10px;
  background: #EDF2F7;
  border-radius: 5px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0%;
  transition: width 0.6s ease;
}

.result-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.result-actions .btn {
  flex: 1;
  font-size: 15px;
  padding: 12px 8px;
}

/* ---------- Upgraded Breakdown Styles ---------- */
.result-breakdown {
  text-align: left;
  margin-top: 24px;
  border-top: 2px solid var(--navy);
  padding-top: 20px;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 8px;
}

.breakdown-container h3 {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 17px;
  color: var(--navy);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
}

.breakdown-topic {
  background: #FDFBF7;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.breakdown-topic h4 {
  font-family: var(--font-sans);
  font-size: 17px;
  color: #000000;
  font-weight: 800;
  margin: 0 0 12px 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--navy);
  padding-bottom: 6px;
  text-align: left;
  text-shadow: none !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Dynamic Party Colors for Candidate Names */
.breakdown-cand {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 15px;
  display: block;
  margin-top: 14px;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  -webkit-font-smoothing: antialiased;
}

.breakdown-cand[data-party="D"] {
  color: var(--dem);
}

.breakdown-cand[data-party="R"] {
  color: var(--rep);
}

.breakdown-stance {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: #2D3748;
  margin-bottom: 8px;
}

.breakdown-point {
  display: block;
  margin-bottom: 6px;
}

.breakdown-point strong {
  font-family: var(--font-sans);
  font-weight: 700;
  color: #1A202C;
}

/* ---------- Small screens ---------- */
@media (max-width: 360px) {
  .fighter-stage { padding: 10px 12px 0; }
  .vs-badge { font-size: 20px; }
}