/*
 * Design tokens lifted from olandsbladet.se (main.css / jalla-casual.css),
 * theme "gota-blue" — so the widget sits in an article without looking bolted on.
 *
 * BNSansVariable is loaded from the paper's own asset path, which resolves when
 * the widget is served from the same origin as the site. Hosted anywhere else the
 * font request simply fails and the fallback stack takes over; set --ob-font-base
 * to point somewhere else if the assets move.
 */

@font-face {
  font-family: BNSansVariable;
  src: url("/assets/rev/fonts/bnsans/BNSans-Variable-R2XC4SMD.woff2") format("woff2-variations"),
       url("/assets/rev/fonts/bnsans/BNSans-Variable-R2XC4SMD.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bn-sans-family: BNSansVariable, "Helvetica Neue", Helvetica, Arial, sans-serif;

  --color-surface-page: #ffffff;
  --color-surface-minimal: #f7f9fb;
  --color-surface-subtle: #eef1f5;
  --color-surface-moderate: #e4e8ee;

  --color-text: #1f1f1f;
  --color-text-secondary: #505762;

  --color-theme-primary: #006fb4;
  --color-theme-secondary: #005f99;
  --color-theme-tertiary: #edf7fb;

  --color-button-primary-foreground: #ffffff;

  --radius-button: .125rem;
  --radius-button-themed: 62.4375rem;
  --radius-surface: .75rem;

  color-scheme: light dark;
}

/* Mirrors html.allow-dark-mode on the site: follows the reader's system setting. */
@media (prefers-color-scheme: dark) {
  :root {
    --color-surface-page: #141414;
    --color-surface-minimal: #1f1f1f;
    --color-surface-subtle: #373a3f;
    --color-surface-moderate: #505762;

    --color-text: #f7f9fb;
    --color-text-secondary: #e4e8ee;

    --color-theme-primary: #64a3d0;
    --color-theme-secondary: #9ac3ea;
    --color-theme-tertiary: #1a334c;

    --color-button-primary-foreground: #141414;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--color-surface-page); }

body {
  color: var(--color-text);
  font-family: var(--bn-sans-family);
  font-size: .875rem;
  line-height: 1.45;
  padding: .5rem;
  /* Inherited, so headings and short text wrap in balanced lines everywhere. */
  text-wrap: balance;
}

.poll {
  max-width: 520px;
  margin: 0 auto;
  background: var(--color-surface-page);
  border: 1px solid var(--color-surface-subtle);
  border-radius: var(--radius-surface);
  padding: 1.5rem 1.375rem;
}

.eyebrow {
  margin: 0 0 .125rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--color-theme-primary);
}

.eyebrow .category {
  padding: .1875rem .5rem;
  border-radius: var(--radius-button-themed);
  background: var(--color-theme-tertiary);
  color: var(--color-theme-secondary);
  letter-spacing: .05em;
  font-size: .625rem;
}

h1 {
  margin: .375rem 0 .25rem;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.015em;
}

.meta { margin: 0; font-size: .8125rem; color: var(--color-text-secondary); }

.status { margin-top: .25rem; font-weight: 600; }

.question { margin: 1.25rem 0 .75rem; font-size: 1.0625rem; font-weight: 700; letter-spacing: -.01em; }

.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }

.choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .1875rem;
  padding: .875rem .375rem;
  border: 1px solid var(--color-surface-moderate);
  border-radius: var(--radius-button);
  background: var(--color-surface-page);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color .14s ease, background .14s ease, color .14s ease, transform .06s ease;
}

.choice:hover:not(:disabled) {
  border-color: var(--color-theme-primary);
  background: var(--color-theme-tertiary);
}

.choice:active:not(:disabled) { transform: translateY(1px); }

.choice:focus-visible { outline: 2px solid var(--color-theme-primary); outline-offset: 2px; }

.choice[aria-pressed="true"] {
  border-color: var(--color-theme-primary);
  background: var(--color-theme-tertiary);
  color: var(--color-theme-secondary);
}

.choice[aria-pressed="true"] .sign { color: var(--color-theme-primary); }

.choice:disabled { cursor: not-allowed; opacity: .55; }

.choice .sign { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }

.choice .team {
  font-size: .6875rem;
  color: var(--color-text-secondary);
  text-align: center;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.choice[aria-pressed="true"] .team { color: inherit; }

.results { margin-top: 1.25rem; display: grid; gap: .75rem; }

.row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .75rem;
  margin-bottom: .3125rem;
  font-size: .8125rem;
}

.row-head .name { font-weight: 600; }

.figures { display: flex; align-items: baseline; gap: .5rem; flex-shrink: 0; }
.figures .count { font-size: .75rem; color: var(--color-text-secondary); }
.figures .pct { font-variant-numeric: tabular-nums; font-weight: 700; }

.track {
  height: .5rem;
  border-radius: var(--radius-button-themed);
  background: var(--color-surface-subtle);
  overflow: hidden;
}

.fill {
  height: 100%;
  width: 0;
  border-radius: var(--radius-button-themed);
  background: color-mix(in srgb, var(--color-theme-primary) 32%, var(--color-surface-subtle));
  transition: width .45s cubic-bezier(.22, .61, .36, 1);
}

/* The reader's own pick, and the winner once voting closes, get the full accent. */
.row.mine .fill,
.row.winner .fill {
  background: linear-gradient(90deg, var(--color-theme-secondary), var(--color-theme-primary));
}

.row.mine .row-head .name,
.row.mine .row-head .pct { color: var(--color-theme-secondary); }

footer {
  margin-top: 1.25rem;
  padding-top: .875rem;
  border-top: 1px solid var(--color-surface-subtle);
  font-size: .75rem;
  color: var(--color-text-secondary);
}

footer p { margin: 0; }
#summary { font-weight: 600; color: var(--color-text); }

.total {
  margin-top: .125rem;
  font-size: .6875rem;
  color: var(--color-text-secondary);
}

.error { color: #d73c3c; font-weight: 600; }

.thanks {
  display: inline-block;
  margin-top: .5rem;
  padding: .1875rem .5625rem;
  border-radius: var(--radius-button-themed);
  background: var(--color-theme-tertiary);
  color: var(--color-theme-secondary);
  font-size: .6875rem;
  font-weight: 700;
}

/* The option most readers picked, once voting has closed. */
.row.winner .row-head .name::after {
  content: "★";
  margin-left: .375rem;
  color: var(--color-theme-primary);
}

/* Reserve the widget's rough height while loading, so the article doesn't jump. */
.skeleton { display: grid; gap: 1rem; }

.sk {
  border-radius: var(--radius-button);
  background: linear-gradient(
    90deg,
    var(--color-surface-subtle) 25%,
    var(--color-surface-moderate) 37%,
    var(--color-surface-subtle) 63%
  );
  background-size: 400% 100%;
  animation: sk-shimmer 1.4s ease infinite;
}

.sk-line { height: .75rem; }
.sk-eyebrow { width: 40%; }
.sk-title { width: 75%; height: 1.5rem; }
.sk-choices { height: 4.25rem; border-radius: var(--radius-surface); }
.sk-bar { height: 2.25rem; }

@keyframes sk-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

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

@media (prefers-reduced-motion: reduce) {
  .fill, .choice, .sk { transition: none; animation: none; }
}

[hidden] { display: none !important; }
