/* ─────────────────────────────────────────────────────────────────────────
   Tverken – mørkt tema.
   Ingen webfonter: systemets egen skrift er allerede lastet og gir raskest
   førsteinntrykk. Tallene settes med tabular-nums så kolonner står i ro.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  color-scheme: dark;

  --bg:          #0a0e0d;
  --bg-soft:     #0f1514;
  --surface:     #141b19;
  --surface-2:   #1a2321;
  --line:        #253230;
  --line-soft:   #1c2725;

  --text:        #e9efec;
  --text-2:      #b6c4c0;
  --muted:       #7e918c;

  --accent:      #7ad3ac;
  --accent-dim:  #2c4a3e;
  --sun:         #f3c04a;
  --moon:        #cdd8e6;
  --cloud:       #62726f;
  --rain:        #58a5e6;
  --snowflake:   #d8ecff;
  --frost:       #8ec6f2;
  --warm:        #f08a5d;
  --alert:       #e2705c;

  --radius:      14px;
  --radius-lg:   20px;
  --gap:         16px;
  --shadow:      0 1px 0 rgba(255,255,255,.03) inset, 0 8px 28px rgba(0,0,0,.35);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background:
    radial-gradient(1100px 620px at 18% -12%, #16211e 0%, transparent 62%),
    radial-gradient(900px 560px at 92% 4%, #131c22 0%, transparent 58%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
a:hover { text-decoration-thickness: 2px; }

/* ── Topplinje ─────────────────────────────────────────────────────────── */

.top {
  display: flex; align-items: baseline; flex-wrap: wrap;
  gap: 10px 18px; margin-bottom: 22px;
}
.top h1 {
  margin: 0; font-size: 27px; letter-spacing: -.02em; font-weight: 650;
}
.top .sub { color: var(--muted); font-size: 14px; }
.top .right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.now-temp { font-size: 27px; font-weight: 650; letter-spacing: -.02em; color: var(--accent); }
.now-temp.cold { color: var(--frost); }
.now-temp.warm { color: var(--warm); }
.now-temp small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }

/* ── Rutenett ──────────────────────────────────────────────────────────── */

.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(12, 1fr); }
.col-12 { grid-column: span 12; }
.col-8  { grid-column: span 8; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }
.col-5  { grid-column: span 5; }
.col-7  { grid-column: span 7; }

@media (max-width: 900px) {
  .col-8, .col-7, .col-5, .col-6, .col-4 { grid-column: span 12; }
  .wrap { padding: 20px 14px 48px; }
}

/* ── Kort ──────────────────────────────────────────────────────────────── */

.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px 20px 20px;
  min-width: 0;
}
.card.flush { padding: 0; overflow: hidden; }

.card h2 {
  margin: 0 0 14px;
  font-size: 12px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
  display: flex; align-items: center; gap: 10px;
}
.card h2 .tail { margin-left: auto; font-weight: 500; letter-spacing: 0; text-transform: none; font-size: 12px; }

.empty { color: var(--muted); font-size: 14px; margin: 6px 0; }

/* ── Webkamera ─────────────────────────────────────────────────────────── */

.cam { position: relative; background: #0b0f0e; }

/* To bildelag oppå hverandre. Under avspilling lastes neste bilde i det
   bakre laget og tones fram først når det er ferdig lastet, så det aldri
   blinker. Uten avspilling er bare det fremste laget i bruk. */
.cam-stage { position: relative; aspect-ratio: 16 / 10; background: #0b0f0e; }
.cam-layer {
  position: absolute; inset: 0; display: block;
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .45s ease;
}
.cam-layer.is-front { opacity: 1; }
.cam-layer:not([src]) { display: none; }

@media (prefers-reduced-motion: reduce) { .cam-layer { transition: none; } }
.cam .cam-meta {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 30px 18px 14px;
  background: linear-gradient(to top, rgba(6,10,9,.88), transparent);
  font-size: 13px;
}
.cam .cam-name { font-weight: 600; font-size: 15px; }
.cam .cam-time { color: var(--text-2); }
.cam .cam-temp { margin-left: auto; font-weight: 600; color: var(--accent); }

.cam-tabs { display: flex; gap: 6px; padding: 12px 14px; flex-wrap: wrap; border-top: 1px solid var(--line-soft); }
.cam-tabs a {
  padding: 6px 12px; border-radius: 999px; font-size: 13px; text-decoration: none;
  color: var(--text-2); border: 1px solid var(--line);
}
.cam-tabs a:hover { border-color: var(--accent-dim); color: var(--text); }
.cam-tabs a[aria-current="true"] {
  background: var(--accent-dim); border-color: transparent; color: #d6f5e6; font-weight: 600;
}

/* Avspillingsknappen står fast helt til venstre; klokkeslettene scroller
   forbi den hvis de ikke får plass. */
.timeline-row { display: flex; align-items: center; gap: 10px; padding: 0 14px 14px; min-width: 0; }

/* position: relative gjør at knappenes offsetLeft måles fra stripa selv.
   Uten den måles de fra <body>, og autorullingen under avspilling regner feil. */
.timeline { display: flex; gap: 6px; overflow-x: auto; min-width: 0; position: relative;
             scrollbar-width: thin; -webkit-overflow-scrolling: touch;
             mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
             -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
.timeline button {
  flex: 0 0 auto; width: 74px; padding: 0; cursor: pointer;
  background: none; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  color: var(--muted); font: inherit; font-size: 11px; line-height: 22px;
}
.timeline button[aria-pressed="true"] { border-color: var(--accent); color: var(--text); }

.cam-play {
  flex: 0 0 auto; width: 26px; height: 26px; padding: 0; cursor: pointer;
  display: grid; place-items: center;
  background: none; border: 1px solid var(--line); border-radius: 50%;
  color: var(--text-2); transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.cam-play:hover { color: var(--text); border-color: var(--accent-dim); background: var(--surface-2); }
.cam-play:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cam-play svg { margin-left: 1px; }                    /* optisk sentrering av trekanten */
.cam-play .ic-stop { display: none; }
.cam-play[aria-pressed="true"] {
  color: #d6f5e6; border-color: transparent; background: var(--accent-dim);
}
.cam-play[aria-pressed="true"] svg { margin-left: 0; }
.cam-play[aria-pressed="true"] .ic-play { display: none; }
.cam-play[aria-pressed="true"] .ic-stop { display: inline; }
.cam-play.is-loading { color: var(--muted); cursor: progress; }
.cam-play.is-loading svg { animation: camPulse 1s ease-in-out infinite; }

@keyframes camPulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .cam-play.is-loading svg { animation: none; } }

/* Tynn framdriftslinje langs underkanten av bildet, bare under avspilling. */
.cam-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
                background: rgba(255,255,255,.1); z-index: 2; }
.cam-progress span { display: block; height: 100%; width: 0;
                     background: var(--accent); transition: width .2s linear; }

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

/* ── Nøkkeltall ────────────────────────────────────────────────────────── */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 2px;
         background: var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.stat { background: var(--surface); padding: 14px 15px 15px; }
.stat .k { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; }
.stat .n { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat .v.cold { color: var(--frost); }
.stat .v.warm { color: var(--warm); }

/* ── Stasjonsliste ─────────────────────────────────────────────────────── */

.stations { display: flex; flex-direction: column; }
.st {
  display: grid; grid-template-columns: 1fr auto auto;
  align-items: center; gap: 14px;
  padding: 11px 0; border-bottom: 1px solid var(--line-soft);
}
.st:last-child { border-bottom: 0; }
.st .nm { font-weight: 550; }
.st .nt { font-size: 12px; color: var(--muted); }
.st .spark { color: var(--accent); opacity: .85; width: 110px; height: 28px; }
.st .tv { font-size: 18px; font-weight: 650; min-width: 68px; text-align: right; }
.st.offline { opacity: .45; }
.st .delta { font-size: 12px; color: var(--muted); font-weight: 500; }
.st .delta.up { color: var(--warm); }
.st .delta.down { color: var(--frost); }

@media (max-width: 460px) { .st .spark { display: none; } }

/* ── Meteogram ─────────────────────────────────────────────────────────── */

.scroller { overflow-x: auto; margin: 0 -6px; padding: 0 6px 4px; }
.meteogram { display: block; min-width: 100%; }
.meteogram .grid { stroke: var(--line-soft); stroke-width: 1; }
.meteogram .grid-zero { stroke: color-mix(in srgb, var(--frost) 45%, transparent); stroke-dasharray: 3 3; }
.meteogram .daybreak { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.meteogram .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.meteogram .axis.dim { fill: var(--muted); opacity: .7; text-transform: capitalize; }
.meteogram .templine { fill: none; stroke: var(--warm); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.meteogram .tempdot { fill: var(--warm); }
.meteogram .precip { fill: var(--rain); opacity: .85; }
.meteogram .precip-label { fill: var(--rain); font-size: 10px; font-family: var(--font); }

/* ── Døgnvarsel ────────────────────────────────────────────────────────── */

.days { display: grid; gap: 2px; background: var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.day {
  display: grid; grid-template-columns: 86px 44px 1fr auto;
  align-items: center; gap: 12px;
  background: var(--surface); padding: 9px 14px;
}
.day .dn { font-weight: 550; }
.day .dd { font-size: 12px; color: var(--muted); }
.day .bar { position: relative; height: 6px; border-radius: 3px; background: var(--line); }
.day .bar span { position: absolute; top: 0; bottom: 0; border-radius: 3px;
                 background: linear-gradient(90deg, var(--frost), var(--warm)); }
.day .tt { font-weight: 600; min-width: 92px; text-align: right; }
.day .tt .lo { color: var(--muted); font-weight: 500; }
.day .pp { font-size: 12px; color: var(--rain); min-width: 52px; text-align: right; }

@media (max-width: 560px) { .day { grid-template-columns: 80px 38px 1fr auto; } .day .bar { display: none; } }

/* ── Løypestatus ───────────────────────────────────────────────────────── */

.trails { display: flex; flex-direction: column; gap: 2px; }
.trail {
  display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--line-soft);
}
.trail:last-child { border-bottom: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.fresh { background: #4ade9b; box-shadow: 0 0 0 4px rgba(74,222,155,.14); }
.dot.good  { background: #7ad3ac; }
.dot.ok    { background: var(--sun); }
.dot.old   { background: var(--warm); }
.dot.stale { background: #6b7c78; }
.dot.none  { background: #3a4643; }
.trail .tn { font-weight: 550; }
.trail .ts { font-size: 12.5px; color: var(--muted); }
.trail .tk { font-size: 13px; color: var(--text-2); text-align: right; white-space: nowrap; }
.trail .tk b { color: var(--text); font-weight: 600; }

/* ── Åpningstider ──────────────────────────────────────────────────────── */

.cabins { display: grid; gap: 12px; grid-template-columns: 1fr; }

.cabin { border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px; background: var(--surface); }
.cabin.is-open { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.cabin .ch { display: flex; align-items: center; gap: 9px; }
.cabin .cn { font-weight: 600; font-size: 16px; }
.cabin .pill {
  margin-left: auto; font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
}
.cabin.is-open .pill { background: var(--accent-dim); color: #cdf3e2; }
.cabin .cd { margin-top: 8px; font-size: 15px; }
.cabin .cw { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.cabin .cnote { margin-top: 10px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.cabin .creason { margin-top: 6px; font-size: 12.5px; color: var(--sun); }

/* ── Sol, måne, nedbør nå ──────────────────────────────────────────────── */

.sunrow { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.sunrow .item { display: flex; align-items: center; gap: 9px; }
.sunrow .lbl { font-size: 12px; color: var(--muted); }
.sunrow .val { font-weight: 600; }
.moon-disc { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2);
             border: 1px solid var(--line); position: relative; overflow: hidden; flex: 0 0 auto; }
.moon-disc i { position: absolute; inset: 0; background: var(--moon); }

.nowcast { display: block; margin-top: 10px; border-radius: 6px; overflow: hidden; }
.nowcast .nc-wet { fill: var(--rain); }
.nowcast .nc-dry { fill: var(--line); }
.nc-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 5px; }
.dry { margin: 6px 0 0; font-size: 14px; color: var(--text-2); display: flex; align-items: center; gap: 9px; }
.dry::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }

/* ── Bunn ──────────────────────────────────────────────────────────────── */

.foot {
  margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line-soft);
  color: var(--muted); font-size: 12.5px; line-height: 1.7;
}
.foot a { color: var(--text-2); }
.foot .refresh { float: right; margin-left: 18px; }
@media (max-width: 700px) { .foot .refresh { float: none; display: block; margin: 0 0 8px; } }

.wi { display: block; flex: 0 0 auto; }

@media (prefers-reduced-motion: no-preference) {
  .card { transition: border-color .2s ease; }
}
