:root {
  --bg: #e4eaee;
  --paper: #f5f7f8;
  --ink: #14212b;
  --muted: #56666f;
  --rule: #c7d1d7;
  --focus: #1f4fd1;
  --warn: #9c2a14;

  /* lähteiden tunnusvärit */
  --fmi: #2b59c3;
  --yr: #0b7f66;
  --foreca: #a87300;

  /* symbolit */
  --sun: #f0b31a;
  --moon: #7f90a6;
  --cloud: #ffffff;
  --cloud-edge: #95a5b0;
  --cloud-far: #d3dce2;
  --cloud-dark: #7c8b96;
  --rain: #2b6cd6;
  --snow: #5f82a6;
  --bolt: #f2b705;

  color-scheme: light dark;
  font-family: "Schibsted Grotesk", system-ui, sans-serif;
  font-size: 100%;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1920;
    --paper: #15232c;
    --ink: #e2e9ed;
    --muted: #93a3ad;
    --rule: #2a3a45;
    --focus: #8ab0ff;
    --warn: #ff9a80;
    --fmi: #7a9cf2;
    --yr: #3cc2a0;
    --foreca: #e3ae35;
    --moon: #dce3e9;
    --cloud: #c8d3da;
    --cloud-edge: #8a9aa5;
    --cloud-far: #56666f;
    --cloud-dark: #5a6973;
    --rain: #6fa2ff;
    --snow: #b7cbe0;
  }
}

* { box-sizing: border-box; }
body { margin: 0 auto; max-width: 62rem; padding: 2rem 1.25rem 4rem; }
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.p-fmi { --c: var(--fmi); }
.p-yr { --c: var(--yr); }
.p-foreca { --c: var(--foreca); }

/* ---------- yläosa ---------- */

.brand {
  display: inline-block;
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: inherit;
  text-decoration: none;
}
.tagline { margin-top: .35rem; color: var(--muted); }

.search { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.5rem; }
.combo { position: relative; flex: 1 1 18rem; }
.search input {
  width: 100%;
  padding: .8rem 1rem;
  font-size: 1.1rem;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 6px;
}
.search button {
  padding: .8rem 1.2rem;
  font-weight: 700;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
}
.search button.ghost { background: transparent; color: var(--ink); }
.search button:disabled { opacity: .55; cursor: progress; }

#suggestions {
  position: absolute;
  z-index: 5;
  inset: calc(100% + 4px) 0 auto;
  margin: 0;
  padding: .3rem 0;
  list-style: none;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: 0 10px 24px -12px rgb(20 33 43 / .35);
}
#suggestions li { padding: .55rem 1rem; cursor: pointer; }
#suggestions li[aria-selected="true"], #suggestions li:hover { background: var(--bg); }
.opt-name { font-weight: 700; }
.opt-meta { color: var(--muted); font-size: .9rem; }

.status { min-height: 1.5em; margin-top: .75rem; color: var(--muted); }

/* ---------- tyhjä tila ---------- */

.empty { max-width: 38rem; margin-top: 2.5rem; font-size: 1.1rem; }
.picks { margin-top: 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; color: var(--muted); }
.picks button {
  padding: .35rem .8rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper);
  cursor: pointer;
}

/* ---------- paikka ja näkymä ---------- */

.place { margin-top: 2rem; }
.place h1 { font-size: clamp(2.4rem, 7vw, 4rem); font-weight: 800; letter-spacing: -0.035em; line-height: .95; }
.place p { margin-top: .4rem; color: var(--muted); font-size: 1.1rem; }

.view-switch { display: flex; gap: 1.5rem; margin: 1.75rem 0 .5rem; border-bottom: 1px solid var(--rule); }
.view-switch button {
  padding: .5rem 0;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.view-switch button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }

[aria-busy="true"] #days, [aria-busy="true"] #hours { opacity: .45; }

/* ---------- lähteen nimi värimerkillä ---------- */

.src { display: inline-flex; align-items: center; gap: .5rem; font-weight: 500; white-space: nowrap; }
.src::before { content: ""; width: .75rem; height: .75rem; border-radius: 2px; background: var(--c); flex: none; }

/* ---------- asteikkoseloste ---------- */

.scale {
  display: grid;
  grid-template-columns: 9.5rem 2.6rem 5.4rem minmax(5rem, 1fr) 4.4rem 4rem;
  align-items: center;
  gap: .9rem;
  margin-top: .75rem;
  font-size: .85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.scale-track { display: flex; align-items: center; gap: .5rem; }
.scale-track b { font-weight: 500; }
.scale-track i {
  flex: 1;
  height: 1px;
  font-style: normal;
  background: repeating-linear-gradient(90deg, var(--rule) 0 4px, transparent 4px 8px);
}
.scale-note { margin-top: .3rem; max-width: 62ch; font-size: .82rem; color: var(--muted); }

/* ---------- päivät ---------- */

.day { padding: 1.1rem 0 .9rem; border-bottom: 1px solid var(--rule); }
.day-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem 1rem; margin-bottom: .4rem; }
.day-head h2 { font-size: 1.2rem; font-weight: 700; }
.agree { color: var(--muted); font-size: .92rem; }
.agree.wide { color: var(--warn); font-weight: 700; }

.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: 9.5rem 2.6rem 5.4rem minmax(5rem, 1fr) 4.4rem 4rem;
  align-items: center;
  gap: .9rem;
  padding: .2rem 0;
  font-variant-numeric: tabular-nums;
}
.row .missing { grid-column: 2 / -1; color: var(--muted); font-style: italic; }
.ico { display: inline-flex; }
.row .wx { width: 2.6rem; height: 2.6rem; }
.temps { display: flex; align-items: baseline; gap: .45rem; }
.hi { font-size: 1.3rem; font-weight: 700; }
.lo { color: var(--muted); }
.bar { position: relative; height: .5rem; border-radius: 99px; background: color-mix(in srgb, var(--rule) 55%, transparent); }
.bar i { position: absolute; top: 0; bottom: 0; border-radius: 99px; background: var(--c); }
.rain, .wind { text-align: right; }
.rain { color: var(--rain); font-weight: 500; }
.rain.dry, .wind { color: var(--muted); font-weight: 400; }

/* ---------- tunnit ---------- */

.table-wrap { overflow-x: auto; margin-top: .5rem; }
table.hours { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.hours thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: .6rem .6rem .5rem;
  text-align: left;
  background: var(--bg);
  border-bottom: 3px solid var(--c, var(--ink));
}
.hours tbody th { padding: .3rem .6rem .3rem 0; text-align: left; font-weight: 500; color: var(--muted); white-space: nowrap; }
.hours td { padding: .3rem .6rem; border-bottom: 1px solid color-mix(in srgb, var(--rule) 60%, transparent); }
.hours td.none { color: var(--muted); }
.hours tr.sep th { padding: 1.1rem 0 .35rem; color: var(--ink); font-weight: 700; font-size: 1.05rem; border-bottom: 1px solid var(--rule); }
.cell { display: flex; align-items: center; gap: .45rem; }
.cell .wx { width: 1.9rem; height: 1.9rem; flex: none; }
.cell .t { font-weight: 700; font-size: 1.05rem; min-width: 2.3rem; }
.meta { display: flex; flex-direction: column; font-size: .78rem; line-height: 1.25; color: var(--muted); }
.meta .r { color: var(--rain); }
.arrow { display: inline-block; margin-right: .2rem; }

/* ---------- lähteet ---------- */

.sources { margin-top: 3rem; }
.sources h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: .75rem; }
#sources { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.source { display: grid; grid-template-columns: .35rem 1fr auto; gap: .9rem; align-items: start; }
.source .swatch { align-self: stretch; border-radius: 2px; background: var(--c); }
.source.disabled .swatch, .source.error .swatch { opacity: .35; }
.source h3 { font-size: 1rem; }
.source p { font-size: .92rem; color: var(--muted); }
.source.error p:first-of-type, .source.stale p:first-of-type { color: var(--warn); }
.source .attr { font-size: .82rem; }
.source a { color: inherit; font-weight: 500; white-space: nowrap; }
.method { margin-top: 1.5rem; max-width: 62ch; font-size: .88rem; color: var(--muted); }

/* ---------- symbolit ---------- */

.wx .sun { fill: var(--sun); }
.wx .ray { stroke: var(--sun); stroke-width: 2.6; stroke-linecap: round; }
.wx .moon { fill: var(--moon); }
.wx .cloud { fill: var(--cloud); stroke: var(--cloud-edge); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.wx .cloud.far { fill: var(--cloud-far); }
.wx .cloud.dark { fill: var(--cloud-dark); }
.wx .rain { fill: none; stroke: var(--rain); stroke-width: 3; stroke-linecap: round; }
.wx .snow { fill: none; stroke: var(--snow); stroke-width: 2; stroke-linecap: round; }
.wx .fog { stroke: var(--cloud-edge); stroke-width: 3.2; stroke-linecap: round; }
.wx .bolt { fill: var(--bolt); }

/* ---------- kapea näyttö ---------- */

@media (max-width: 40rem) {
  body { padding-top: 1.25rem; }
  .row {
    grid-template-columns: 2.4rem 4.6rem minmax(3rem, 1fr) 3.6rem 3.4rem;
    grid-template-areas: "src src src src src" "ico temps bar rain wind";
    gap: .1rem .6rem;
    padding: .35rem 0;
  }
  .row .src { grid-area: src; font-size: .85rem; }
  .row .ico { grid-area: ico; }
  .row .temps { grid-area: temps; }
  .row .bar { grid-area: bar; }
  .row .rain { grid-area: rain; font-size: .9rem; }
  .row .wind { grid-area: wind; font-size: .9rem; }
  .row .missing { grid-column: 1 / -1; font-size: .9rem; }
  .row .wx { width: 2.3rem; height: 2.3rem; }
  .source { grid-template-columns: .35rem 1fr; }
  .source a { grid-column: 2; }
}
