/* Flag palette: #346EAA blue, #E13940 red, #FFFFFF white, #000000 black.
   Blue carries text/UI (white-on-blue 5.3:1); red is the accent for large
   text and graphics only (4.3:1 on white, so it never sets body-size text). */
:root {
  --bg: #f7f9fb;
  --ink: #0a0a0a;
  --body: #222222;
  --muted: #5c6570;
  --accent: #346eaa;
  --accent2: #e13940;
  --accent-soft: #e8f0f8;
  --line: #dfe5eb;
  --card: #ffffff;
  --btn-bg: #346eaa;
  --btn-text: #ffffff;
  --logo-dim: #9db8d2;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --ink: #ffffff;
    --body: #d3d7db;
    --muted: #9aa3ac;
    --accent: #7fb0e0;
    --accent2: #ed5f66;
    --accent-soft: #12212f;
    --line: #262c33;
    --card: #14171b;
    --btn-bg: #7fb0e0;
    --btn-text: #06101a;
    --logo-dim: #4a6076;
  }
}

html { color-scheme: light dark; }

* { box-sizing: border-box; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.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) {
  * { transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

header {
  padding: 18px 20px 0;
  max-width: 640px;
  margin: 0 auto;
}

header h1 {
  font-size: 19px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

/* 19px bold qualifies as WCAG large text, where the flag red's
   contrast (4.3:1 light, 6+:1 dark) clears the 3:1 requirement */
header h1 span { color: var(--accent2); }

header p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: inherit;
}

.logo {
  width: 27px;
  height: 27px;
  flex: none;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}

h2 {
  font-size: 26px;
  letter-spacing: -0.02em;
  margin: 20px 0 6px;
}

.hint { color: var(--muted); margin: 0 0 20px; font-size: 15px; }
.stepnum {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 18px 0 0;
}

.progress {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.progress .bar {
  height: 100%;
  background: var(--accent2);
  transition: width .3s ease;
}

.sub { font-size: 17px; margin: 28px 0 10px; }

/* Option grids */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.opt, .card {
  font: inherit;
  text-align: left;
  padding: 13px 34px 13px 15px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--ink);
  position: relative;
  transition: border-color .15s, background .15s;
}

.opt.sel::after, .card.sel::after {
  content: "\2713";
  position: absolute;
  top: 11px;
  right: 13px;
  color: var(--accent);
  font-weight: 700;
}

.opt:hover, .card:hover { border-color: var(--accent); }

.opt.sel, .card.sel {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.cards { display: grid; gap: 10px; }
.card { display: flex; flex-direction: column; gap: 2px; }
.card span { color: var(--muted); font-size: 14px; }

/* Budget slider */
.budget { margin-top: 28px; }

.budget label {
  display: block;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 10px;
}

.budget input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.budget output {
  display: block;
  margin-top: 8px;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

/* Importance sliders */
.weights { margin-top: 4px; }
.weight-row { margin-top: 20px; }

.weight-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 600;
  font-size: 14.5px;
  margin-bottom: 4px;
}
.weight-head output {
  color: var(--accent);
  font-size: 17px;
  font-weight: 700;
}

.weight-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Radar graph */
.radar-wrap {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 12px;
  margin-bottom: 18px;
}
.radar-wrap h3 {
  margin: 0 0 4px;
  font-size: 16px;
  text-align: center;
}
.radar-wrap svg {
  display: block;
  width: 100%;
  max-width: 520px;
  height: auto;
  margin: 0 auto;
}
.radar-grid, .radar-axis { fill: none; stroke: var(--line); stroke-width: 1; }
.radar-user {
  fill: var(--accent);
  fill-opacity: .22;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
}
.radar-city {
  fill: none;
  stroke: var(--accent2);
  stroke-width: 2;
  stroke-dasharray: 5 4;
  stroke-linejoin: round;
}
.radar-label { fill: var(--muted); font-size: 12px; }

.radar-legend {
  display: flex;
  justify-content: center;
  gap: 22px;
  font-size: 13px;
  color: var(--muted);
  padding: 6px 0 4px;
}
.leg::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 0;
  margin-right: 7px;
  vertical-align: middle;
}
.leg-user::before { border-top: 3px solid var(--accent); }
.leg-city::before { border-top: 3px dashed var(--accent2); }

/* Nav */
.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
}

button.primary {
  font: inherit;
  font-weight: 600;
  background: var(--btn-bg);
  color: var(--btn-text);
  border: none;
  border-radius: var(--radius);
  padding: 13px 26px;
  cursor: pointer;
}
button.primary:disabled { opacity: .35; cursor: default; }

button.ghost {
  font: inherit;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 13px 8px;
}

/* Results */
.results { display: grid; gap: 10px; margin-top: 8px; }

.result {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
}
.result[open] { border-color: var(--accent); }

.result summary {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}
.result summary::-webkit-details-marker { display: none; }

.ring {
  --p: 0;
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--line) 0);
  display: grid;
  place-items: center;
}
.ring > span {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--card);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}

.cityname { display: flex; flex-direction: column; flex: 1; }
.cityname strong { font-size: 17px; }
.cityname em { font-style: normal; color: var(--muted); font-size: 13px; }

.chev { color: var(--muted); font-size: 20px; transition: transform .2s; }
.result[open] .chev { transform: rotate(90deg); }

.breakdown { padding: 4px 16px 16px; border-top: 1px solid var(--line); }

.factor { margin-top: 16px; }
.factor-head {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  font-size: 14px;
}
.factor-head .pct { color: var(--accent); }

.meter {
  height: 5px;
  background: var(--line);
  border-radius: 3px;
  margin: 6px 0 6px;
  overflow: hidden;
}
.meter div { height: 100%; background: var(--accent); border-radius: 3px; }

.factor p { margin: 4px 0 0; font-size: 14px; color: var(--body); }
.factor .source {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.factor .source a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.disclaimer {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 32px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

/* Home page */
.homelink { text-decoration: none; color: inherit; }
.homelink span { color: var(--accent); }

.home main { padding-bottom: 20px; }
.home section { margin-top: 44px; }

.hero h2 {
  font-size: clamp(26px, 5vw, 50px);
  line-height: 1.15;
  margin: 8px 0 18px;
}

.hero h2 .line2 { display: block; }

.home p { color: var(--body); }
.home h3 { font-size: 20px; letter-spacing: -0.01em; margin: 0 0 8px; }

.cta {
  display: inline-block;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius);
  padding: 14px 28px;
  margin-top: 10px;
}
.cta-note { font-size: 13px; color: var(--muted) !important; margin-top: 10px; }

.factors, .sources {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  display: grid;
  gap: 10px;
}
.factors li, .sources li {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 15px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.factors span, .sources span { color: var(--muted); font-size: 14px; }
.sources a, .fineprint a { color: var(--accent); }

.fineprint {
  font-size: 14px;
  color: var(--muted) !important;
  border-left: 3px solid var(--accent-soft);
  padding-left: 14px;
  margin-top: 18px;
}

footer {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 20px 40px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}
footer a { color: var(--accent); font-weight: 600; }

@media (min-width: 540px) {
  .factors { grid-template-columns: 1fr 1fr; }
}

/* Wider layout on larger screens */
@media (min-width: 900px) {
  header, main, footer { max-width: 1000px; }
  .home section { margin-top: 56px; }
  .factors { grid-template-columns: repeat(3, 1fr); }
  .sources { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr 1fr; }
  h2 { font-size: 22px; }
}
