/* Fonts are served from sva.la itself — no requests to Google or anyone else.
   Average and Fira Sans are both under the SIL Open Font License (see fonts/LICENSE-*). */
@font-face { font-family: "Average"; src: url("/fonts/average-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Fira Sans"; src: url("/fonts/fira-sans-300.woff2") format("woff2"); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: "Fira Sans"; src: url("/fonts/fira-sans-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Fira Sans"; src: url("/fonts/fira-sans-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }

:root {
  --serif: "Average", Georgia, "Times New Roman", serif;
  --sans: "Fira Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font: var(--serif);

  --bg: #f8f8f3;
  --band: #efefe9;
  --ink: #2c4a51;
  --text: #33393b;
  --link: #3a5b92;
  --muted: #6b7070;
  --rule: #dcdcd6;
  --chip: #d9dcdc;
  --chip-ink: #2c4a51;
}
[data-theme="dark"] {
  --bg: #1d1e20;
  --band: #18191a;
  --ink: #a8c2c7;
  --text: #b9bfc1;
  --link: #9fb6db;
  --muted: #8c9293;
  --rule: #2f3134;
  --chip: #2b3236;
  --chip-ink: #c6d6d9;
}
[data-font="sans"] { --font: var(--sans); }

* { box-sizing: border-box; }
html { font-size: 100%; } /* 1rem = the reader's own default size (16px unless changed) */
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  transition: background .2s, color .2s;
}
a { color: inherit; text-decoration: none; transition: color .15s; }
.latest .t { transition: color .15s; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; border-radius: 2px; }

/* ---------- Header ---------- */
header.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
}
.logo { grid-column: 2; justify-self: center; font-family: var(--serif); font-size: 1.375rem; color: var(--ink); letter-spacing: .01em; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; color: var(--ink); border-radius: 8px; }
.icon-btn:hover { background: var(--band); }
.icon-btn svg { width: 20px; height: 20px; }
.back { grid-column: 1; visibility: hidden; }
.back.show { visibility: visible; }
.settings-btn { grid-column: 3; }

main { min-height: calc(100vh - 120px); }

/* ---------- Front page ---------- */
.front { display: block; }
/* Mobile: headlines fill ~80% of the screen like a front page; latest news below the fold */
.col-hero {
  min-height: calc(80vh - 61px);
  min-height: calc(80svh - 61px);
  display: flex;
}
.hero { list-style: none; margin: 0; padding: 8px 0; width: 100%; display: flex; flex-direction: column; }
.hero li { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; }
.hero li + li::before {
  content: ""; position: absolute; top: 0; left: 15%; right: 15%; border-top: 1px solid var(--rule);
}
.hero a, .hero span.nolink {
  display: block; text-align: center;
  padding: 18px 26px;
  font-size: 1.5625rem; line-height: 1.2; color: var(--ink);
  text-wrap: balance;
}
.hero a:hover { color: var(--link); }

.col-latest { border-top: 1px solid var(--rule); padding: 14px 44px 20px; }
.latest-head { display: none; }
.day {
  font-family: var(--sans); font-size: 0.6875rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 18px 0 4px; margin: 0; font-weight: 500;
}
.day .ex { text-transform: none; letter-spacing: 0; font-weight: 400; }
.more, .end {
  display: block; width: fit-content; margin: 24px 0 12px;
  font-family: var(--sans); font-size: 0.8125rem; color: var(--ink);
}
.more { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule); }
.more:hover { color: var(--link); }
.more[aria-busy] { color: var(--muted); text-decoration: none; }
.end { color: var(--muted); }
.latest { list-style: none; margin: 0; padding: 0; }
.latest a { display: flex; align-items: baseline; gap: 14px; padding: 11px 0; }
.latest time { order: -1; width: 34px; flex: none; font-family: var(--sans); font-size: 0.6875rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.latest .t { font-size: 1.0625rem; color: var(--ink); line-height: 1.3; }
.latest a:hover .t { color: var(--link); }

/* ---------- Article ---------- */
article.story {
  max-width: 640px; margin: 0 auto; padding: 48px 44px 60px;
}
.story h1 { font-weight: 400; font-size: 2rem; line-height: 1.15; color: var(--ink); margin: 0 0 16px; text-wrap: balance; }
.meta { display: flex; gap: 10px; align-items: baseline; font-family: var(--sans); font-size: 0.6875rem; color: var(--muted); margin-bottom: 22px; }
.meta .cat { font-weight: 500; letter-spacing: .06em; color: var(--text); }
.story p { font-size: 1.0625rem; line-height: 1.6; margin: 0 0 1.1em; }
.source { margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--rule); font-family: var(--sans); font-size: 0.75rem; color: var(--muted); }
.source a { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- About ---------- */
.about h1 { margin-bottom: 22px; }
.about p { font-size: 1rem; }
.about a { text-decoration: underline; text-underline-offset: 2px; color: var(--ink); }

/* ---------- Footer ---------- */
footer { text-align: center; padding: 28px 16px 40px; font-family: var(--sans); font-size: 0.75rem; color: var(--muted); }
footer a { text-decoration: underline; text-underline-offset: 2px; }
footer a:hover, .about a:hover { color: var(--link); }

/* ---------- Settings sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 20;
  display: none; align-items: flex-start; justify-content: center;
}
.sheet-backdrop.open { display: flex; }
.sheet {
  background: var(--bg); width: 100%; min-height: 100%;
  padding: 0 0 40px;
}
.sheet header {
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid var(--rule);
}
.sheet header h2 { grid-column: 2; justify-self: center; margin: 0; font-weight: 400; font-size: 1.25rem; color: var(--ink); }
.sheet header .icon-btn { grid-column: 3; }
.group { text-align: center; margin-top: 24px; }
.group h3 { font-weight: 400; font-size: 0.875rem; color: var(--text); margin: 0 0 12px; }
.opts { display: inline-flex; gap: 10px; }
.opt {
  width: 76px; height: 76px; border: 1px solid var(--rule); border-radius: 3px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--ink); font-size: 0.8125rem;
}
.opt svg { width: 28px; height: 28px; stroke-width: 1.2; }
.opt .aa { font-size: 1.875rem; line-height: 1; }
.opt.sans, .opt.sans .aa { font-family: var(--sans); font-weight: 300; }
.opt.serif, .opt.serif .aa { font-family: var(--serif); }
.opt[aria-pressed="true"] { background: var(--chip); color: var(--chip-ink); border-color: var(--muted); }

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
  header.top { border-bottom: 0; padding: 36px 24px 20px; grid-template-columns: 60px 1fr 60px; }
  .logo { font-size: 2.375rem; }
  .front {
    display: grid; grid-template-columns: 1fr 1fr;
    max-width: 1100px; margin: 0 auto;
  }
  /* Front page on desktop: fixed screen. Header on top, footer always visible,
     latest news scrolls inside its own column (max 70% of the screen). */
  body.is-front { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
  body.is-front header.top { flex: none; }
  body.is-front main { flex: 1; min-height: 0; display: flex; align-items: center; }
  body.is-front footer { flex: none; padding: 16px 16px 24px; }
  .front { width: 100%; align-items: start; }
  .front .col-hero {
    min-height: 0; max-height: 70vh; overflow-y: auto;
    padding: 0 60px 0 0; justify-content: flex-end; align-items: flex-start;
  }
  .front .col-latest {
    border-top: 0; border-left: 1px solid var(--rule);
    height: 70vh; overflow-y: auto; padding: 0 0 0 60px;
    scrollbar-width: thin; scrollbar-color: var(--rule) transparent;
  }
  .front .hero li:first-child a, .front .hero li:first-child span.nolink { padding-top: 6px; }
  .hero { max-width: 420px; padding: 0; }
  .hero li { flex: none; }
  .hero li + li::before { left: 0; right: 0; }
  .hero a, .hero span.nolink { font-size: 1.6875rem; padding: 34px 10px; }
  .day:first-of-type { padding-top: 4px; }
  .latest a { gap: 18px; padding: 13px 0; }
  .latest .t { font-size: 1.125rem; }
  article.story { padding: 40px 22px 60px; }
  .story h1 { font-size: 2.625rem; }
  .story p { font-size: 1.125rem; }
  .sheet-backdrop { align-items: center; }
  .sheet { width: 380px; min-height: 0; border-radius: 6px; border: 1px solid var(--rule); box-shadow: 0 20px 50px rgba(0,0,0,.18); }
}

/* ---------- Sport filter (setting "Sportnyheter: Dölj") ---------- */
[data-sport="hide"] [data-cat="SPORT"] { display: none; }
.day-group[hidden] { display: none; }

/* ---------- Day pages ---------- */
.story .day-list { margin-top: 8px; }
.day-nav { display: flex; justify-content: space-between; gap: 16px; margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--rule); font-family: var(--sans); font-size: 0.8125rem; }
.day-nav a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule); }
.day-nav a:hover { color: var(--link); }
.month-list { list-style: none; margin: 0; padding: 0; }
.month-list li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.month-list a { color: var(--ink); }
.month-list a:hover { color: var(--link); }
.month-list span { font-family: var(--sans); font-size: 0.75rem; color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
