/* Pick-a-Pol — lightweight, dependency-free styles. WCAG 2.1 AA: color is
   never the only signal, focus is visible, contrast targets 4.5:1. */
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --ink: #16202b;
  --muted: #5a6472;
  --line: #dfe3e8;
  --brand: #1f5fa8;
  --brand-ink: #ffffff;
  --agree: #1f7a4d;
  --disagree: #b4402a;
  --warn-bg: #fff4e0;
  --warn-ink: #7a4b00;
  --focus: #ffbf47;
  --radius: 10px;
  /* Old Glory palette — decorative accents only (kept off body text so the
     WCAG AA contrast targets above are unaffected). */
  --flag-red: #b22234;
  --flag-blue: #0a3161;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff;
  padding: 8px 12px; z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

/* Stars-and-stripes ribbon across the very top of the page. */
.us-ribbon { height: 5px; background:
    linear-gradient(90deg, var(--flag-red) 0 34%, #eef1f6 34% 66%, var(--flag-blue) 66% 100%);
  position: sticky; top: 0; z-index: 200; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(10, 49, 97, .04), 0 6px 18px -12px rgba(10, 49, 97, .25); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-weight: 700; font-size: 1.2rem; text-decoration: none; color: var(--ink);
  display: inline-flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 1.3rem; }
.site-header nav a { margin-left: 16px; text-decoration: none; }

/* Gently fluttering flag beside the wordmark. */
.flag { display: inline-block; width: 34px; height: 22px; border-radius: 2px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transform-origin: left center;
  animation: flagwave 3.6s ease-in-out infinite; }
.flag svg { display: block; width: 100%; height: 100%; }

@keyframes flagwave {
  0%, 100% { transform: perspective(90px) rotateY(0deg) skewY(0deg); }
  25%      { transform: perspective(90px) rotateY(-7deg) skewY(-1.3deg); }
  75%      { transform: perspective(90px) rotateY(7deg) skewY(1.3deg); }
}

.steps { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 16px 0 0; margin: 0; font-size: .85rem; }
.steps li { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.steps li::before { content: attr(data-n); display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%; background: var(--line); color: var(--ink); font-weight: 700; }
.steps li[aria-current="step"] { color: var(--ink); font-weight: 700; }
.steps li[aria-current="step"]::before { background: var(--brand); color: #fff; }
.steps li[data-done="1"]::before { content: "✓"; background: var(--agree); color: #fff; }

main { padding: 20px 0 40px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
  animation: rise .4s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
h1 { font-size: 1.6rem; margin: 0 0 8px; }
h2 { font-size: 1.25rem; }
.lead { color: var(--muted); font-size: 1.05rem; }

label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type="text"], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 1rem; background: var(--surface); color: var(--ink);
}
.btn {
  display: inline-block; background: var(--brand); color: var(--brand-ink); border: 1px solid var(--brand);
  padding: 10px 18px; border-radius: 8px; font-size: 1rem; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease, background .12s ease;
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 6px 16px -8px rgba(10, 49, 97, .55); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn.secondary { background: transparent; color: var(--brand); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; align-items: center; }
/* .candmeta defaults to --muted (gray-blue) for light card backgrounds; on a
   solid-blue .btn (e.g. the election-choice list) that's nearly invisible. */
.btn .candmeta { color: var(--brand-ink); opacity: .85; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.badge.high { background: #e2f2ea; color: var(--agree); }
.badge.medium { background: var(--warn-bg); color: var(--warn-ink); }
.badge.low { background: #fbe3dd; color: var(--disagree); }
.badge.gray { background: var(--line); color: var(--muted); }
.badge.explicit { background: #e2f2ea; color: var(--agree); }
.badge.inferred { background: #e7eef7; color: var(--brand); }

.hint { color: var(--muted); font-size: .9rem; }
.callout { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 12px 14px; margin: 12px 0; }
.callout a { color: var(--warn-ink); }

.race { border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 12px;
  border-left: 3px solid var(--flag-blue); animation: rise .4s cubic-bezier(.2, .7, .2, 1) both; }
.race:nth-child(2) { animation-delay: .04s; } .race:nth-child(3) { animation-delay: .08s; }
.race:nth-child(4) { animation-delay: .12s; } .race:nth-child(5) { animation-delay: .16s; }
.race:nth-child(n+6) { animation-delay: .2s; }
.race header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.race h3 { margin: 0; font-size: 1.05rem; }
.candlist { list-style: none; margin: 10px 0 0; padding: 0; }
.candlist li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px dashed var(--line); }
.candlist li:first-child { border-top: none; }
.candmeta { color: var(--muted); font-size: .85rem; }
.cand-id { display: flex; align-items: center; gap: 10px; min-width: 0; }

/* Candidate avatar: real portrait when available, tasteful initials otherwise.
   Kept a single flag-blue tint for everyone (non-partisan — party is shown as
   text, never implied by avatar color). */
.avatar { position: relative; flex: 0 0 auto; display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%; overflow: hidden; color: #fff;
  font-weight: 700; font-size: .95rem; letter-spacing: .5px; user-select: none;
  background: linear-gradient(135deg, var(--flag-blue), var(--brand));
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line), 0 2px 6px -2px rgba(10, 49, 97, .5);
  transition: transform .15s ease; }
.avatar.sm { width: 34px; height: 34px; font-size: .8rem; }
.avatar.lg { width: 60px; height: 60px; font-size: 1.15rem; }
/* Portrait variant: a rounded rectangle at the sketches' native 2:3 ratio, so
   the whole stylized portrait (face included) shows rather than a center crop. */
.avatar.portrait { width: 60px; height: 90px; border-radius: 10px; }
/* Hero size for the candidate profile page. */
.avatar.portrait.xl { width: 140px; height: 210px; border-radius: 14px; font-size: 2.2rem; }
.avatar .avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center top; opacity: 0; transition: opacity .35s ease; }
.avatar.has-img .avatar-img { opacity: 1; }
.candlist li:hover .avatar, .result:hover .avatar { transform: scale(1.05); }
/* Hovering a portrait pops it to a larger size and gives it a playful wiggle,
   so voters can get a good look at the stylized headshot. Only real pictures
   (.has-img) zoom; the enlarged card lifts above neighbouring rows. */
.avatar.portrait { transition: transform .2s ease; transform-origin: center center; }
.avatar.portrait.has-img:hover { transform: scale(2.1); z-index: 6; overflow: visible; }
.avatar.portrait.has-img:hover .avatar-img { border-radius: 10px;
  box-shadow: 0 8px 22px -6px rgba(10, 49, 97, .6);
  animation: portraitWiggle .5s ease-in-out .18s infinite; }
@keyframes portraitWiggle {
  0%, 100% { transform: rotate(-2.5deg); }
  50%      { transform: rotate(2.5deg); }
}
@media (prefers-reduced-motion: reduce) {
  .avatar.portrait.has-img:hover { transform: scale(2.1); }
  .avatar.portrait.has-img:hover .avatar-img { animation: none; }
}
/* The already-large profile-page hero doesn't need the list hover-zoom. */
.avatar.portrait.xl.has-img:hover { transform: none; animation: none; }
.avatar.portrait.xl.has-img:hover .avatar-img { animation: none; }

/* Questionnaire */
.qcount { color: var(--muted); font-weight: 600; }
.statement { font-size: 1.25rem; margin: 8px 0 18px; }
.likert { display: grid; gap: 8px; }
.likert button {
  text-align: left; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font-size: 1rem; cursor: pointer;
}
.likert button[aria-pressed="true"] { border-color: var(--brand); background: #eef4fb; font-weight: 700; }
.importance { margin-top: 14px; display: flex; align-items: center; gap: 8px; }
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 6px 0 16px; }
.progress > span { display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--flag-blue), var(--brand));
  transition: width .5s cubic-bezier(.2, .7, .2, 1); }

/* Results */
.result { border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 14px;
  animation: rise .4s cubic-bezier(.2, .7, .2, 1) both; }
.result:nth-child(2) { animation-delay: .05s; } .result:nth-child(3) { animation-delay: .1s; }
.result:nth-child(4) { animation-delay: .15s; } .result:nth-child(5) { animation-delay: .2s; }
.result:nth-child(n+6) { animation-delay: .25s; }
.result:first-of-type { border-color: var(--flag-blue); box-shadow: 0 6px 22px -14px rgba(10, 49, 97, .6); }
.matchbar { height: 14px; background: var(--line); border-radius: 999px; overflow: hidden; }
.matchbar > span { display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--brand), var(--agree));
  transition: width .9s cubic-bezier(.2, .7, .2, 1); }
.result h4 { margin: 4px 0; display: flex; align-items: center; gap: 8px; }
.rank { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 700; font-size: .8rem; flex: 0 0 auto;
  animation: pop .35s cubic-bezier(.2, 1.4, .4, 1) both; }
.result:first-of-type .rank { background: var(--flag-red); }
@keyframes pop { 0% { transform: scale(0); } 100% { transform: scale(1); } }
details.breakdown { margin-top: 8px; }
details.breakdown summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.qrow { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.qrow .agree { color: var(--agree); font-weight: 700; }
.qrow .disagree { color: var(--disagree); font-weight: 700; }
.qrow .sources a { font-size: .85rem; }
.agree-dot::before, .disagree-dot::before, .unknown-dot::before { margin-right: 4px; font-weight: 700; }
.agree-dot::before { content: "▲"; color: var(--agree); }
.disagree-dot::before { content: "▼"; color: var(--disagree); }
.unknown-dot::before { content: "—"; color: var(--muted); }

.ad-slot { background: repeating-linear-gradient(45deg, #eee, #eee 10px, #f5f5f5 10px, #f5f5f5 20px);
  color: var(--muted); text-align: center; padding: 22px; border-radius: 8px; margin: 8px 0; }

.site-footer { background: var(--surface); border-top: 1px solid var(--line); margin-top: 40px; padding: 20px 0; color: var(--muted); font-size: .9rem; }

table.matrix { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.matrix th, table.matrix td { border: 1px solid var(--line); padding: 6px 8px; text-align: center; }
table.matrix th:first-child, table.matrix td:first-child { text-align: left; }

.compare-grid { overflow-x: auto; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Respect users who ask for less motion: keep the UI, drop the movement. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
  .avatar .avatar-img { opacity: 1; }
  .matchbar > span { width: var(--target-width, 0); }
}

/* Admin hub tool cards (admin.html) */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.tool-card { display: block; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  text-decoration: none; color: var(--ink); background: var(--surface); }
.tool-card:hover { border-color: var(--brand); }
.tool-card h3 { margin: 0 0 4px; color: var(--brand); }
.tool-card p { margin: 0; color: var(--muted); font-size: .9rem; }
