/* ==========================================================================
   Duellen — designsystem
   Skala: allt är medvetet stort. Basen är 18px och rubriker/kort växer med
   clamp() så att en projektor eller storbildsskärm fylls utan att mobilen
   spricker. Färgerna följer Sambruks grafiska profil (grön), med en mörkare
   grön för text/knappar eftersom signaturgrönt (#58A618) bara ger 3,05:1
   mot vitt och därmed inte duger som brödtext eller knapp med vit text.
   ========================================================================== */

:root {
  /* Ytor */
  --bg: #f5f7f2;
  --card: #ffffff;
  --card-2: #f7f9f4;
  --text: #16210f;
  --muted: #5c6655;
  --border: #dfe5d8;

  /* Sambruk-grönt */
  --brand: #58a618;          /* signaturgrönt — dekor, staplar, ramar */
  --primary: #3f7a11;        /* knappar och länkar (WCAG-säker mot vitt) */
  --primary-d: #326009;
  --primary-fg: #ffffff;
  --link: #326009;
  --soft: rgba(88, 166, 24, .12);

  /* Signaler */
  --accent: #0e7c5a;
  --accent-fg: #ffffff;
  --danger: #b62828;
  --danger-fg: #ffffff;
  --warn: #9a5b00;
  --warn-fg: #ffffff;

  --shadow: 0 6px 28px rgba(22, 33, 15, .08);
  --shadow-lg: 0 14px 44px rgba(22, 33, 15, .14);
  --radius: 20px;
  --radius-sm: 12px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f140c;
    --card: #19200f;
    --card-2: #212a16;
    --text: #eef3e7;
    --muted: #a9b69c;
    --border: #33401f;
    --brand: #7cc94a;
    --primary: #6cb32c;
    --primary-d: #58a618;
    --primary-fg: #0d1406;
    --link: #9bd84f;
    --soft: rgba(124, 201, 74, .16);
    --accent: #2fae83;
    --accent-fg: #05130d;
    --danger: #ff7a7a;
    --danger-fg: #2a0606;
    --warn: #f0b429;
    --warn-fg: #241800;
    --shadow: 0 6px 28px rgba(0, 0, 0, .45);
    --shadow-lg: 0 14px 44px rgba(0, 0, 0, .55);
  }
}

[data-theme="dark"] {
  --bg: #0f140c; --card: #19200f; --card-2: #212a16; --text: #eef3e7;
  --muted: #a9b69c; --border: #33401f; --brand: #7cc94a; --primary: #6cb32c;
  --primary-d: #58a618; --primary-fg: #0d1406; --link: #9bd84f;
  --soft: rgba(124,201,74,.16); --accent: #2fae83; --accent-fg: #05130d;
  --danger: #ff7a7a; --danger-fg: #2a0606; --warn: #f0b429; --warn-fg: #241800;
  --shadow: 0 6px 28px rgba(0,0,0,.45); --shadow-lg: 0 14px 44px rgba(0,0,0,.55);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 18px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); }
a:hover { text-decoration: none; }

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---- Topbar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
  padding: 18px clamp(16px, 3vw, 32px);
  max-width: 1280px; width: 100%; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 14px; font-weight: 800; }
.brand .logo { height: clamp(56px, 8vw, 96px); width: auto; display: block; }

.topnav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.topnav a, .topnav button {
  font: inherit; font-size: 1rem; font-weight: 700; cursor: pointer;
  text-decoration: none; color: var(--muted); background: transparent;
  border: 1.5px solid transparent; border-radius: var(--radius-sm);
  padding: 11px 16px; line-height: 1.2;
}
.topnav a:hover, .topnav button:hover { background: var(--card); color: var(--text); }
.topnav a.active {
  color: var(--primary); background: var(--card); border-color: var(--border);
}
.topnav .theme-btn { font-size: 1.2rem; padding: 9px 14px; }

/* ---- Layout ---- */
.wrap {
  max-width: 900px; width: 100%; margin: 0 auto;
  padding: 8px clamp(16px, 3vw, 28px) 72px;
  flex: 1;
}
.wrap.wide { max-width: 1160px; }
.wrap.narrow { max-width: 720px; }

.hero { text-align: center; margin: 8px 0 30px; }
.hero.compact { margin: 4px 0 18px; }
.hero.compact h1 { font-size: clamp(1.4rem, 2.9vw, 2.15rem); }
.hero.compact .datechip { font-size: .88rem; margin-top: 8px; }
.hero h1 {
  font-size: clamp(1.9rem, 4.2vw, 3rem);
  line-height: 1.15; letter-spacing: -.02em; font-weight: 800;
}
.hero p { color: var(--muted); margin-top: 12px; font-size: clamp(1.05rem, 1.6vw, 1.3rem); }
.datechip { color: var(--muted); font-size: .95rem; margin-top: 10px; }

.lead { font-size: 1.15rem; }
h2 { font-size: clamp(1.3rem, 2.2vw, 1.7rem); line-height: 1.25; letter-spacing: -.01em; }
h3 { font-size: 1.15rem; line-height: 1.3; }

/* ---- Röstning ---- */
.vote-prompt {
  text-align: center; font-size: clamp(1.15rem, 2.2vw, 1.45rem);
  font-weight: 700; margin: 0 auto 8px;
}
.vote-hint { text-align: center; color: var(--muted); margin-bottom: 22px; font-size: 1rem; }

.versus { display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: stretch; }
.choice {
  background: var(--card); border: 2px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(28px, 4vw, 46px) clamp(20px, 3vw, 34px) 54px;
  min-height: clamp(230px, 34vh, 340px);
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: clamp(1.3rem, 2.4vw, 1.85rem); font-weight: 700; line-height: 1.3;
  cursor: pointer; white-space: pre-line;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
  position: relative; overflow: hidden;
}
/* Storleken anpassas efter hur lång texten är: korta alternativ blir stora och
   syns över rummet, långa blir läsbara stycken i stället för att spränga sidan. */
.choice.t-s  { font-size: clamp(1.6rem, 3.2vw, 2.4rem); }
.choice.t-m  { font-size: clamp(1.3rem, 2.3vw, 1.75rem); }
.choice.t-l  { font-size: clamp(1.08rem, 1.5vw, 1.25rem); font-weight: 600; line-height: 1.45; text-align: left; }
.choice.t-xl { font-size: clamp(1rem, 1.25vw, 1.1rem); font-weight: 600; line-height: 1.5; text-align: left; }
.choice.t-l, .choice.t-xl { align-items: flex-start; }

.choice:hover {
  transform: translateY(-5px); border-color: var(--brand); box-shadow: var(--shadow-lg);
}
.choice:active { transform: scale(.985); }
.choice .kbd {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  font-size: .85rem; font-weight: 600; color: var(--muted); white-space: nowrap;
  border: 1.5px solid var(--border); border-radius: 8px; padding: 4px 10px;
}
.choice.picked {
  border-color: var(--brand); background: var(--soft);
  box-shadow: 0 0 0 4px var(--soft);
}
.vs {
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; color: var(--muted); font-size: 1.3rem; letter-spacing: .06em;
}

@media (max-width: 720px) {
  .topbar { padding: 10px 12px 6px; gap: 6px; justify-content: center; }
  .brand .logo { height: 50px; }
  .topnav { gap: 2px; width: 100%; justify-content: center; }
  .topnav a, .topnav button { font-size: .88rem; padding: 7px 9px; }
  .topnav .theme-btn { padding: 6px 8px; font-size: 1.05rem; }
}

@media (max-width: 700px) {
  .versus { grid-template-columns: 1fr; gap: 12px; }
  .vs { padding: 2px 0; }
  .choice { min-height: 150px; padding: 26px 20px 48px; font-size: 1.25rem; }
  .choice .kbd { display: none; }
}

.tools {
  display: flex; gap: 12px; justify-content: center; margin-top: 28px; flex-wrap: wrap;
}

/* ---- Knappar ---- */
.btn {
  font: inherit; font-size: 1.05rem; font-weight: 700; cursor: pointer;
  border: 2px solid transparent; border-radius: 14px;
  padding: 14px 24px; background: var(--primary); color: var(--primary-fg);
  text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
  line-height: 1.2;
  transition: filter .12s ease, transform .12s ease, background .12s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.98); }
.btn.big { font-size: 1.15rem; padding: 17px 30px; }
.btn.ghost {
  background: transparent; color: var(--text); border-color: var(--border);
}
.btn.ghost:hover { background: var(--card); border-color: var(--brand); }
.btn.accent { background: var(--accent); color: var(--accent-fg); }
.btn.danger { background: var(--danger); color: var(--danger-fg); }
.btn.warn { background: var(--warn); color: var(--warn-fg); }
/* Destruktivt är lågmält tills man verkligen siktar på det — röd fyllning på en
   hel rad av knappar drar blicken till fel sak. */
.btn.quiet-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn.quiet-danger:hover { border-color: var(--danger); background: transparent; }
.btn.sm { padding: 9px 15px; font-size: .95rem; border-radius: 11px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---- Kort ---- */
.card {
  background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: clamp(22px, 3vw, 32px); margin-bottom: 20px;
}
.card h2 { margin-bottom: 6px; }
.card .sub { color: var(--muted); font-size: 1rem; margin-bottom: 18px; }
.card p + p { margin-top: 12px; }
.card.tinted { background: var(--card-2); }

/* Färgat "öra" på informationskort så avsändaren syns direkt */
.card.about { border-left: 6px solid var(--brand); }
.card.about-org { border-left: 6px solid var(--muted); }
.eyebrow {
  display: inline-block; font-size: .82rem; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--primary); margin-bottom: 6px;
}
.eyebrow.gray { color: var(--muted); }

/* ---- Formulär ---- */
label { display: block; font-weight: 700; font-size: 1rem; margin: 18px 0 8px; }
/* Hjälpknapp bredvid etiketten: förklaringen ligger i en tooltip i stället för
   att ta plats som brödtext. Visas vid hover och vid fokus (fokus = tap på mobil). */
.hint-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; margin-left: 8px; padding: 0; vertical-align: middle;
  font-family: inherit; font-size: .85rem; font-weight: 800; line-height: 1;
  color: var(--primary); background: var(--soft);
  border: 1.5px solid var(--primary); border-radius: 50%; cursor: help;
}
.hint-btn::after {
  content: attr(data-tip);
  position: absolute; top: calc(100% + 10px); left: -6px;
  width: max-content; max-width: min(340px, 72vw);
  padding: 12px 14px; border-radius: 12px;
  background: var(--text); color: var(--bg);
  font-size: .92rem; font-weight: 400; line-height: 1.5;
  text-align: left; white-space: normal; box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .12s ease, transform .12s ease; z-index: 40;
}
.hint-btn:hover::after, .hint-btn:focus::after { opacity: 1; visibility: visible; transform: none; }
input[type=text], input[type=password], input[type=email], input[type=number], textarea, select {
  width: 100%; font: inherit; font-size: 1.05rem; padding: 15px 17px; border-radius: 13px;
  border: 2px solid var(--border); background: var(--card-2); color: var(--text);
}
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.switch { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 1rem; cursor: pointer; }
.switch input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--primary); cursor: pointer; }

/* ---- Steg (så funkar det) ---- */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.step { background: var(--card-2); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 24px; }
.step .num {
  display: flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--primary); color: var(--primary-fg);
  font-size: 1.25rem; font-weight: 800; margin-bottom: 14px;
}
.step h3 { margin-bottom: 6px; }
.step p { color: var(--muted); font-size: 1rem; }

.faq { border-top: 1.5px solid var(--border); padding: 20px 0; }
.faq:last-of-type { border-bottom: 1.5px solid var(--border); }
.faq h3 { margin-bottom: 6px; }
.faq p { color: var(--muted); }

/* ---- Resultat ---- */
.rank-item {
  display: grid; grid-template-columns: 56px 1fr 96px; gap: 16px; align-items: center;
  padding: 18px 4px; border-bottom: 1.5px solid var(--border);
}
.rank-item:last-child { border-bottom: none; }
.rank-num { font-weight: 800; color: var(--muted); font-size: 1.5rem; text-align: center; }
.rank-num.top { color: var(--primary); }
.rank-text { font-weight: 600; font-size: 1.08rem; line-height: 1.45; white-space: pre-line; }
.rank-meta { font-size: .92rem; color: var(--muted); margin-top: 6px; }
.bar { height: 12px; border-radius: 8px; background: var(--border); overflow: hidden; margin-top: 10px; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--brand)); }
.score-badge { font-weight: 800; font-size: 1.7rem; text-align: right; }
@media (max-width: 560px) {
  .rank-item { grid-template-columns: 40px 1fr 64px; gap: 10px; }
  .score-badge { font-size: 1.25rem; }
  .rank-text { font-size: 1.02rem; }
}

.pill { display: inline-block; font-size: .82rem; font-weight: 700; padding: 5px 12px; border-radius: 999px; }
.pill.green { background: var(--soft); color: var(--primary); }
.pill.amber { background: rgba(154,91,0,.14); color: var(--warn); }
.pill.gray  { background: var(--card-2); color: var(--muted); border: 1.5px solid var(--border); }
.pill.red   { background: rgba(182,40,40,.14); color: var(--danger); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 14px; }
.stat { background: var(--card-2); border: 1.5px solid var(--border); border-radius: 16px; padding: 18px 20px; }
.stat .n { font-size: 2.1rem; font-weight: 800; line-height: 1.1; }
.stat .l { font-size: .92rem; color: var(--muted); }

.big-count { font-size: 2.4rem; font-weight: 800; line-height: 1.1; }
.vote-count { font-size: 1.15rem; font-weight: 700; color: var(--muted); margin-top: 24px; min-height: 1.6em; }

.muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none !important; }
.spacer { height: 12px; }
.divider { border: none; border-top: 1.5px solid var(--border); margin: 26px 0; }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 15px 26px; border-radius: 14px;
  font-weight: 700; font-size: 1.05rem; box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity .2s; z-index: 50; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; }

.qlist-item {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  padding: 18px; border: 1.5px solid var(--border); border-radius: 16px; margin-bottom: 12px;
  background: var(--card-2); flex-wrap: wrap;
}
.qlist-item .meta { font-size: .92rem; color: var(--muted); margin-top: 5px; }

.fade-in { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  /* Storleken anpassas efter hur lång texten är: korta alternativ blir stora och
   syns över rummet, långa blir läsbara stycken i stället för att spränga sidan. */
.choice.t-s  { font-size: clamp(1.6rem, 3.2vw, 2.4rem); }
.choice.t-m  { font-size: clamp(1.3rem, 2.3vw, 1.75rem); }
.choice.t-l  { font-size: clamp(1.08rem, 1.5vw, 1.25rem); font-weight: 600; line-height: 1.45; text-align: left; }
.choice.t-xl { font-size: clamp(1rem, 1.25vw, 1.1rem); font-weight: 600; line-height: 1.5; text-align: left; }
.choice.t-l, .choice.t-xl { align-items: flex-start; }

.choice:hover { transform: none; }
}

/* ---- Sidfot (injiceras av common.js på varje sida) ---- */
.site-footer { margin-top: 60px; border-top: 1.5px solid var(--border); background: var(--card); }
.foot-inner {
  max-width: 820px; margin: 0 auto; padding: 30px 20px; text-align: center;
  color: var(--muted); font-size: 1rem; line-height: 1.6;
}
.foot-links { margin-top: 14px; }
.foot-links a { font-weight: 700; }
.foot-links .sep { margin: 0 12px; color: var(--border); }
.foot-support { margin-top: 10px; font-size: .95rem; }
.foot-support a { font-weight: 700; }
.print-logo { display: none; }

/* ---- Utskrift ----
   Resultatsidan ska bli ett rent A4-blad: ingen meny, inga knappar, ljus palett
   även för den som surfar i mörkt läge, och staplar som faktiskt trycks. */
@media print {
  :root, [data-theme="dark"], :root:not([data-theme="light"]) {
    --bg: #fff; --card: #fff; --card-2: #fff; --text: #16210f; --muted: #4a5544;
    --border: #c9d2c0; --primary: #3f7a11; --brand: #58a618; --link: #3f7a11;
    --shadow: none; --shadow-lg: none;
  }
  body { background: #fff; font-size: 12pt; }
  .topbar, .tools, .site-footer, .toast, #exportTools, #board .btn, .live-note { display: none !important; }
  .print-logo { display: block; height: 70px; width: auto; margin: 0 auto 14px; }
  .wrap { max-width: none; padding: 0; }
  .card { box-shadow: none; border: 1px solid var(--border); break-inside: avoid; }
  .rank-item { break-inside: avoid; page-break-inside: avoid; }
  .hero h1 { font-size: 20pt; }
  .bar, .bar > span {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  a[href^="http"]::after { content: ""; }
}
