/* =============================================================
   1. Tokens
   Layout: una columna estrecha tipo papeleta; la herramienta arriba,
   contenido y partidos debajo. Tinta índigo neutral (ningún color de partido).
   ============================================================= */
:root {
  --bg: #F2F4F3;
  --surface: #FFFFFF;
  --surface-2: #E8ECEA;
  --ink: #16201E;
  --muted: #56635F;
  --line: #D5DCD9;
  --accent: #2F3A8F;
  --accent-ink: #FFFFFF;
  --accent-soft: #E3E6F6;
  --ad-bg: #EDEFEE;
  --ad-line: #A9B3AF;
  --shadow: 0 1px 2px rgba(22, 32, 30, .06), 0 8px 28px rgba(22, 32, 30, .07);

  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --sans: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --radius: 14px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --wrap: 1080px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101514; --surface: #182120; --surface-2: #212C2A; --ink: #E9EFED; --muted: #9DAAA6;
    --line: #2C3836; --accent: #9DA8F2; --accent-ink: #10152E; --accent-soft: #232A52;
    --ad-bg: #1C2423; --ad-line: #4A5754;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 28px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101514; --surface: #182120; --surface-2: #212C2A; --ink: #E9EFED; --muted: #9DAAA6;
  --line: #2C3836; --accent: #9DA8F2; --accent-ink: #10152E; --accent-soft: #232A52;
  --ad-bg: #1C2423; --ad-line: #4A5754;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 28px rgba(0,0,0,.35);
  color-scheme: dark;
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: var(--accent); }
p { text-wrap: pretty; }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; line-height: 1.1; letter-spacing: -0.02em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* =============================================================
   3. Utilities
   ============================================================= */
.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 9999;
  padding: .6rem 1rem; background: var(--accent); color: var(--accent-ink); border-radius: 8px;
}
.skip-link:focus { top: 1rem; }
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 16px; }
.narrow { max-width: 760px; }
.eyebrow {
  font-family: var(--mono); font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}

/* =============================================================
   4. Header
   ============================================================= */
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .8rem; }
.brand { display: flex; align-items: center; gap: .55rem; color: var(--ink); text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 1.12rem; }
.brand svg { width: 28px; height: 28px; color: var(--accent); }
.site-nav { display: flex; gap: 1.1rem; font-size: .95rem; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover { color: var(--ink); }

/* =============================================================
   5. Hero + herramienta
   ============================================================= */
.hero { padding-block: 1.4rem .6rem; }
.hero h1 { font-size: clamp(1.6rem, 4.6vw, 2.6rem); font-weight: 800; }
.hero-sub { margin-top: .5rem; color: var(--muted); font-size: 1.02rem; max-width: 62ch; }
.hero-pills { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; padding: 0; list-style: none; }
.hero-pills li {
  font-size: .82rem; padding: .2rem .65rem; border-radius: 999px; background: var(--surface-2); color: var(--ink);
}

.tool { padding-block: .6rem 1.2rem; scroll-margin-top: 12px; }
.quiz {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; scroll-margin-top: 12px;
}
.q-progress { height: 6px; background: var(--surface-2); }
.q-progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s var(--ease-out); }

.q-panel, .r-panel { padding: 1.1rem 1.1rem 1.25rem; }
.quiz[data-state="asking"] .r-panel,
.quiz[data-state="done"] .q-panel { display: none; }
.quiz:not([data-state]) .q-panel, .quiz:not([data-state]) .r-panel { display: none; }

.q-meta { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.q-count { font-family: var(--mono); font-size: .9rem; font-variant-numeric: tabular-nums; color: var(--muted); }
.q-count strong { color: var(--ink); font-weight: 600; font-size: 1.05rem; }
.q-topic {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); padding: .2rem .55rem; border-radius: 6px;
}
.q-stage { margin-top: .9rem; }
.q-stage.enter { animation: qIn .35s var(--ease-out); }
@keyframes qIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.q-text { font-size: clamp(1.18rem, 3.4vw, 1.55rem); font-weight: 650; min-height: 2.4em; outline: none; }
.q-ctx { margin-top: .45rem; color: var(--muted); font-size: .93rem; }

.q-opts { display: grid; grid-template-columns: 1fr; gap: .5rem; margin-top: 1.05rem; }
.opt {
  display: flex; align-items: center; gap: .75rem; width: 100%; text-align: left;
  padding: .8rem .95rem; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface);
  transition: border-color .15s, background .15s, transform .15s var(--ease-out);
}
.opt:hover { border-color: var(--accent); }
.opt:active { transform: scale(.985); }
.opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.opt:disabled { cursor: default; }
.opt-key {
  flex: none; width: 1.6rem; height: 1.6rem; display: grid; place-items: center; border-radius: 6px;
  font-family: var(--mono); font-size: .8rem; background: var(--surface-2); color: var(--muted);
}
.opt[aria-pressed="true"] .opt-key { background: var(--accent); color: var(--accent-ink); }
.opt-label { flex: 1; font-weight: 600; }
.opt-scale { display: flex; gap: 4px; }
.opt-scale i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--muted); }
.opt-scale i.on { background: var(--accent); border-color: var(--accent); }
.opt-scale i.x { width: 12px; height: 12px; border: 0; border-radius: 0; position: relative; }
.opt-scale i.x::before, .opt-scale i.x::after {
  content: ""; position: absolute; left: 50%; top: 0; width: 2px; height: 12px; background: var(--muted); border-radius: 1px;
}
.opt-scale i.x::before { transform: translateX(-50%) rotate(45deg); }
.opt-scale i.x::after { transform: translateX(-50%) rotate(-45deg); }

.q-foot { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-top: 1rem; font-size: .9rem; color: var(--muted); }
.link-btn { color: var(--accent); font-weight: 600; padding: .3rem 0; }
.link-btn:disabled { color: var(--muted); opacity: .45; cursor: default; }
.kbd-hint { display: none; }

.noscript-msg { padding: 1.2rem; }

/* Resultado */
.r-head { display: flex; align-items: center; gap: 1rem; }
.r-head h2 { font-size: clamp(1.4rem, 4vw, 2rem); outline: none; }
.r-pct { font-family: var(--mono); font-size: 1.05rem; font-variant-numeric: tabular-nums; color: var(--muted); margin-top: .2rem; }
.r-pct strong { color: var(--ink); font-size: 1.4rem; }
.r-desc { margin-top: .85rem; color: var(--ink); }
.r-more { display: inline-block; margin-top: .35rem; font-size: .93rem; }
.r-subtitle { margin-top: 1.4rem; font-size: 1rem; font-family: var(--sans); font-weight: 700; letter-spacing: 0; }
.rank { list-style: none; padding: 0; margin-top: .6rem; display: grid; gap: .45rem; }
.rank-row { display: grid; grid-template-columns: 1.4rem 2.1rem minmax(0, 8.5rem) 1fr 3.3rem; align-items: center; gap: .55rem; font-size: .93rem; }
.rank-pos { font-family: var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.rank-row.is-top .rank-name { font-weight: 700; }
.rank-track { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.rank-fill { display: block; height: 100%; background: var(--pc); border-radius: 99px; }
.rank-pct { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.r-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1.3rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .75rem 1.15rem; border-radius: 10px; font-weight: 700; text-decoration: none;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn svg { width: 18px; height: 18px; }
.r-note { margin-top: 1rem; font-size: .85rem; color: var(--muted); }

.privacy { margin-top: .7rem; font-size: .88rem; color: var(--muted); display: flex; gap: .45rem; align-items: flex-start; }
.privacy svg { flex: none; width: 16px; height: 16px; margin-top: .2rem; }

/* Distintivos de partido */
.badge {
  display: inline-grid; place-items: center; flex: none; width: 2.1rem; height: 2.1rem; border-radius: 50%;
  background: var(--pc); color: var(--pi); font-family: var(--display); font-weight: 800; letter-spacing: -.02em;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.18);
}
.badge span { font-size: .5rem; line-height: 1; }
.badge-lg { width: 4.4rem; height: 4.4rem; }
.badge-lg span { font-size: .9rem; }
.badge-md { width: 3.4rem; height: 3.4rem; }
.badge-md span { font-size: .72rem; }

/* =============================================================
   6. Huecos publicitarios (placeholders)
   ============================================================= */
.ad-slot {
  display: grid; place-items: center; text-align: center; margin-inline: auto;
  background: var(--ad-bg); border: 1.5px dashed var(--ad-line); border-radius: 10px;
  color: var(--muted); font-family: var(--mono); font-size: .8rem; letter-spacing: .14em;
}
.ad-slot b { display: block; font-size: 1rem; letter-spacing: .3em; color: var(--ink); }
.ad-leaderboard { width: 100%; max-width: 970px; min-height: 100px; }
.ad-incontent { width: 100%; max-width: 336px; min-height: 280px; }
.ad-band { padding-block: .4rem 1.6rem; }

.ad-modal { border: 0; padding: 0; background: transparent; max-width: calc(100vw - 32px); color: var(--ink); }
.ad-modal::backdrop { background: rgba(10, 14, 13, .62); }
.ad-modal[open] { display: block; }
.ad-modal-box {
  position: relative; width: min(420px, calc(100vw - 32px)); background: var(--surface); border-radius: var(--radius);
  padding: 2.4rem 1.2rem 1.2rem; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.ad-modal-x {
  position: absolute; top: .5rem; right: .5rem; width: 2.2rem; height: 2.2rem; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.3rem; line-height: 1; background: var(--surface-2);
}
.ad-modal-msg { font-size: .9rem; color: var(--muted); margin-bottom: .8rem; }
.ad-popup { width: 100%; min-height: 250px; }
.ad-modal-box .btn { width: 100%; margin-top: .9rem; }

.ad-toast {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 50;
  width: 260px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: .6rem .6rem .7rem;
}
.ad-toast.show { animation: toastIn .4s var(--ease-out); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.ad-toast-head { display: flex; justify-content: space-between; align-items: center; font-size: .72rem; color: var(--muted); font-family: var(--mono); letter-spacing: .08em; }
.ad-toast-head button { width: 1.8rem; height: 1.8rem; border-radius: 50%; font-size: 1.1rem; display: grid; place-items: center; }
.ad-toast-head button:hover { background: var(--surface-2); }
.ad-toast .ad-slot { min-height: 80px; margin-top: .3rem; }

/* =============================================================
   7. Contenido
   ============================================================= */
.section { padding-block: 2.2rem; }
.section + .section { border-top: 1px solid var(--line); }
.section h2 { font-size: clamp(1.4rem, 3.4vw, 2rem); }
.section-lead { margin-top: .5rem; color: var(--muted); max-width: 64ch; }
.prose p { margin-top: .9rem; max-width: 68ch; }
.prose h3 { margin-top: 1.6rem; font-size: 1.2rem; }

.steps { list-style: none; padding: 0; display: grid; gap: 1rem; margin-top: 1.2rem; }
.step { display: grid; grid-template-columns: 2.4rem 1fr; gap: .8rem; align-items: start; }
.step-n {
  width: 2.4rem; height: 2.4rem; display: grid; place-items: center; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-family: var(--mono); font-weight: 600;
}
.step h3 { font-size: 1.05rem; font-family: var(--sans); letter-spacing: 0; }
.step p { color: var(--muted); font-size: .95rem; margin-top: .15rem; }

.scale-table { margin-top: 1rem; overflow-x: auto; }
.scale-table table { border-collapse: collapse; font-size: .92rem; min-width: 420px; }
.scale-table th, .scale-table td { text-align: left; padding: .45rem .9rem .45rem 0; border-bottom: 1px solid var(--line); }
.scale-table td:last-child { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.ad-mid { margin-block: 1.8rem .4rem; }

.parties { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr; gap: .9rem; margin-top: 1.3rem; }
.party {
  display: grid; grid-template-columns: auto 1fr; gap: .9rem; align-items: start;
  padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  scroll-margin-top: 16px;
}
.party:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.party h3 { font-size: 1.1rem; }
.party-tag { font-size: .78rem; color: var(--muted); font-family: var(--mono); letter-spacing: .04em; margin-top: .15rem; }
.party-desc { margin-top: .45rem; font-size: .94rem; }
.party-keys { margin-top: .5rem; display: flex; flex-wrap: wrap; gap: .3rem; padding: 0; list-style: none; }
.party-keys li { font-size: .76rem; padding: .12rem .5rem; border-radius: 99px; background: var(--surface-2); }
.parties-note { margin-top: 1rem; font-size: .85rem; color: var(--muted); }

.faq { margin-top: 1rem; display: grid; gap: .55rem; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .2rem 1rem; }
.faq summary { cursor: pointer; font-weight: 700; padding-block: .75rem; list-style-position: outside; }
.faq details p { padding-bottom: .9rem; color: var(--ink); }

.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding-block: 1.6rem 5rem; font-size: .88rem; color: var(--muted); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: .5rem; }
.site-footer a { color: var(--muted); }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (max-width: 539px) {
  .site-nav { display: none; }
  .rank-row { grid-template-columns: 1.2rem 2.1rem minmax(0, 1fr) 3.1rem; }
  .rank-track { grid-column: 2 / 5; grid-row: 2; margin-top: -.1rem; }
  .ad-toast { width: calc(100vw - 32px); max-width: 320px; }
}
@media (min-width: 720px) {
  .hero { padding-block: 2.2rem .8rem; }
  .q-panel, .r-panel { padding: 1.6rem 1.8rem 1.8rem; }
  .q-opts { grid-template-columns: repeat(4, 1fr); }
  .opt { flex-direction: column; align-items: center; text-align: center; gap: .5rem; padding: 1rem .6rem; }
  .opt-label { flex: none; }
  .kbd-hint { display: inline; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .step { grid-template-columns: 1fr; }
  .parties { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 960px) {
  .parties { grid-template-columns: repeat(3, 1fr); }
}

/* =============================================================
   9. Reduced motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .q-stage.enter, .ad-toast.show { animation: none; }
}
