/* =========================================================
   TÆRUDDALEN – Dus, nordisk palett
   Kompass: hvitt hus + sorte retninger, tynnere nål-outline
   Infobokser: rød kant (samme som logo/knappene)
   + Mobile: hide center logo, keep sticky header
   ========================================================= */

/* ---------- PALETT (LYS) ---------- */
:root{
    /* Bakgrunn – litt gråere og dus */
    --bg:            #eff1f3;  /* hovedbakgrunn (dus grå-blå) */
    --bg-2:          #f5f6f8;  /* seksjonstopper/overganger */

    /* Overflater (mindre «hvit-hot») */
    --surface:       #fbfcfd;  /* kort/panel */
    --surface-2:     #f4f6f8;  /* innholdsfelt */
    --surface-3:     #edf2f6;  /* chips/badges */

    /* Linjer/skyggar */
    --border:        #cfd7df;  /* skillelinjer (tydelig nok) */
    --ring:          #bcc7d2;
    --shadow:        0 8px 22px rgba(10, 25, 40, .09);
    --radius:        16px;

    /* Tekst – ikke helt sort, men høy lesbarhet */
    --ink:           #1a2430;  /* brødtekst (mørk skifer) */
    --ink-strong:    #16202b;  /* store tall/verdier */
    --muted:         #5a6675;  /* sekundær tekst */
    --muted-2:       #718095;

    /* Yr/met-blåtoner (dempet) */
    --blue-900:      #15344f;
    --blue-800:      #1b4668;
    --blue-700:      #1e5a83;
    --blue-600:      #216f9f;  /* lenker/sekundær knapp */
    --blue-500:      #2b86b9;
    --blue-300:      #7fb1d7;
    --blue-200:      #c2d8e8;

    /* Skedsmo-rød – dempet (brukes på knapper + bokskanter) */
    --brand-red:     #c74248;  /* primær rød (dempet) */
    --brand-red-d:   #a93a40;  /* mørkere kant */

    /* Tilstand */
    --good:          #2b8a68;
    --warn:          #c08525;
    --bad:           #c53a3f;

    /* Interaksjon */
    --link:          var(--blue-600);
    --focus:         #bf3c43;  /* fokusramme (rød, men dempet) */

    /* Typografi – roligere vekt og leselige størrelser */
    --fs-xs: 14px;
    --fs-sm: 15px;
    --fs-md: clamp(16px, 1.6vw, 17px);
    --fs-lg: clamp(18px, 2vw, 20px);
    --fs-xl: clamp(22px, 3vw, 26px);
    --fs-xxl: clamp(30px, 6vw, 40px); /* store tall, litt mindre for ro */

    --lh-1: 1.15;
    --lh-2: 1.35;
    --lh-3: 1.55;

    /* Min trykk-område for klikk */
    --tap: 44px;
}

/* =========================================================
   BASIS LAYOUT & TYPO
   ========================================================= */
*{ box-sizing:border-box }

html, body{
    height:100%;
    margin:0;
    display:flex;
    flex-direction:column;
    min-height:100svh;
}

body{
    margin:0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji";
    font-size: var(--fs-md);
    line-height: var(--lh-3);
    color: var(--ink);
    background:
            radial-gradient(1200px 600px at 85% -10%, rgba(25, 45, 70, .05) 0%, rgba(25, 45, 70, 0) 55%),
            linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 640px, var(--bg) 100%);
}

/* Høyere kontrast ved brukerpreferanse */
@media (prefers-contrast: more){
    :root{ --border:#b8c2cc; --ring:#98a6b5; }
}

/* =========================================================
   HEADER – lys og rolig, logo i midten (hidden on phone)
   ========================================================= */
.site-header{
    position: sticky; top: 0; z-index: 20;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    padding: 14px clamp(12px,4vw,28px);
    background: #fbfbfc;                     /* litt mindre hvit */
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 rgba(0,0,0,0.04);
    /* iOS safe-area for notch */
    padding-top: calc(14px + env(safe-area-inset-top));
    background-clip: padding-box;
}
.site-header .header-left h1{
    margin:0;
    font-size: var(--fs-lg);
    font-weight: 700;                        /* roligere */
    color: var(--blue-900);
    letter-spacing: .2px;
    line-height: var(--lh-1);
}
.site-header .header-logo{
    justify-self:center;
    display:inline-flex; align-items:center; justify-content:center;
    height: 46px;
}
.site-header .header-logo img{ height:100%; width:auto; display:block; }
.site-header .header-right{ justify-self:end; }
.site-header .updated{ font-size: var(--fs-sm); color: var(--muted); }
.site-header a{ text-decoration:none; color:inherit; }
.site-header a:focus-visible{ outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 8px; }

/* ---- Phone tweaks: hide center logo, keep sticky ---- */
@media (max-width: 720px){
    .site-header{
        /* still sticky; adjust grid when logo is hidden */
        grid-template-columns: 1fr 1fr;
        padding: 10px clamp(10px,4vw,18px);
        padding-top: calc(10px + env(safe-area-inset-top));
    }
    .site-header .header-logo{
        display: none; /* hide logo in the middle on phone */
    }
    .site-header .header-left h1{
        font-size: 17px;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        max-width: 100%;
    }
    .site-header .updated{ font-size: 13px; justify-self: end; }
}

/* =========================================================
   CONTAINER / GRID
   ========================================================= */
.wrap{
    max-width: 1250px;
    margin: 22px auto 28px;
    padding: 0 clamp(12px,3vw,24px) 40px;
    flex: 1;
}

.grid{
    display: grid;
    grid-template-columns: 1.4fr 0.8fr;
    gap: 18px;
}
@media (max-width:980px){ .grid{ grid-template-columns: 1fr; } }

/* =========================================================
   KORT / PANELER – mindre «hvite», rolige
   ========================================================= */
.card{
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card .head{
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    color: var(--blue-800);
    font-weight: 700;
    font-size: var(--fs-md);
    letter-spacing: .2px;
}
.card .body{ padding: 18px; }

/* =========================================================
   VIND / STATISTIKKER – leselig og rolig
   ========================================================= */
.wind-layout{ display:grid; grid-template-columns: 1fr; gap: 16px; }

.dial-wrap{
    display:grid;
    grid-template-columns: 380px 1fr;
    gap:20px;
    align-items:center;
}
@media (max-width:860px){ .dial-wrap{ grid-template-columns: 1fr; } }

.stats{
    display:grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap:14px;
}
@media (max-width:600px){ .stats{ grid-template-columns: 1fr; } }

/* === INFOBOKSER: rød kant (samme som logo/knapper) === */
.stat{
    background: var(--surface-2);
    border: 1.5px solid var(--brand-red);    /* <-- rød kant */
    border-radius: 14px;
    padding: 14px;
}
.stat h3{
    margin:0 0 8px;
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--muted);
    letter-spacing:.35px; text-transform:uppercase;
}
.big{
    font-weight: 700;
    font-size: var(--fs-xxl);
    line-height: var(--lh-1);
    color: var(--ink-strong);
    letter-spacing: -0.005em;
}
.sub{ font-size: var(--fs-md); color: var(--muted); line-height: var(--lh-2); }

.badge{
    font-size: var(--fs-sm);
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--ring);
    color: var(--blue-900);
    background: var(--surface-3);
    font-weight: 700;
}
.badge.ok{ border-color: color-mix(in srgb, var(--good) 45%, var(--ring)); color:#11533a; background:#e8f3ef; }
.badge.warn{ border-color: color-mix(in srgb, var(--warn) 45%, var(--ring)); color:#644607; background:#fff2df; }

/* =========================================================
   KOMPASS / VIND-DIAL – HVITT hus, sorte retninger,
   dus rød pil, tynnere svart outline
   (Overstyrer SVG uten HTML-endring)
   ========================================================= */

/* Størrelse og plassering */
.dial{
    width:100%;
    max-width:380px;
    aspect-ratio:1/1;
    display:block;
    margin:auto;
}
.dial-title{
    font-size: var(--fs-sm);
    color: var(--muted);
    margin: 0 0 8px 4px;
    letter-spacing:.4px;
}

/* Kompass-hus (ytterring) – GJØR DEN HVIT */
svg.dial circle[cx="50"][cy="50"][r="46"]{
    fill: #ffffff !important;               /* <-- hvitt hus */
    stroke: #808b97 !important;             /* myk grå kant */
    stroke-width: 1.2px !important;
}

/* Deaktiver merkbar effekt fra gradient ved å gjøre stoppene hvite (failsafe) */
svg.dial #g stop:first-child{ stop-color: #ffffff !important; }
svg.dial #g stop:last-child{  stop-color: #ffffff !important; }

/* Ticks / markører – middels grå */
svg.dial #ticks circle{ fill: #b6c1cc !important; }

/* Midtpunkt – dus grå */
svg.dial circle[cx="50"][cy="50"][r="2.4"]{ fill: #6a7786 !important; }

/* Kardinal-/diagonaltekst – SORTE bokstaver */
svg.dial text{
    fill: #111111 !important;               /* <-- sorte retninger */
    font-weight: 700 !important;            /* tydelig, men ikke «boldest» */
}

/* Pilen (nåla) – dus rød og TYNNERE svart kant */
svg.dial #needle polygon:first-of-type{ fill: #d86a6f !important; }   /* lys side (dempet rød) */
svg.dial #needle polygon:nth-of-type(2){  fill: #c74248 !important; } /* mørk side (dempet primær) */

/* Tynnere outline/rygg – svart, men smal */
svg.dial #needle line,
svg.dial #needle path{
    stroke: #111111 !important;             /* svart kontur */
    stroke-width: 1.4px !important;         /* <-- tynnere kant */
}

/* Overlay blend for evt. effekter */
svg.dial #overlay { mix-blend-mode: multiply; }

/* =========================================================
   DETALJ-TABELL
   ========================================================= */
.table{ display:grid; grid-template-columns: 1.1fr .9fr; gap:12px; }
.row{
    display:flex; align-items:center; justify-content:space-between;
    padding: 12px 14px;
    border-bottom:1px dashed var(--ring);
    font-size: var(--fs-md);
}
.row:last-child{ border-bottom:none }
.label{ color: var(--muted); font-weight: 600; }
.val{ font-weight: 700; color: var(--blue-900); }

/* =========================================================
   LENKER / KNAPPER – dempet rød, ikke «flashy»
   ========================================================= */
a{ color: var(--link); text-underline-offset: 3px; }

a.btn{
    display:inline-flex; align-items:center; justify-content:center;
    min-height: var(--tap);
    padding: 9px 16px;
    font-weight: 700;
    font-size: var(--fs-md);
    border-radius: 12px;
    text-decoration:none; color:#fff;
    background: var(--brand-red);            /* dempet rød */
    border:1px solid var(--brand-red-d);     /* dempet kant */
    box-shadow: 0 6px 16px rgba(199,66,72,.10);
    transition: filter .15s ease, transform .02s ease, box-shadow .15s ease;
}
a.btn:hover{ filter: brightness(0.99); box-shadow: 0 8px 18px rgba(199,66,72,.14); }
a.btn:active{ transform: translateY(1px); }

/* Sekundær (blå) */
a.btn.btn--secondary{
    background: var(--blue-600);
    border-color: #1b5e87;
    box-shadow: 0 6px 16px rgba(33,111,159,.12);
}
a.btn.btn--secondary:hover{ box-shadow: 0 8px 18px rgba(33,111,159,.18); }

/* Tekstknapp-variant (rolig link-knapp) */
a.btn.btn--text{
    background: transparent;
    color: var(--blue-700);
    border: 1px solid var(--border);
}

/* =========================================================
   FOOTER
   ========================================================= */
.footer{
    text-align:center;
    padding: 16px;
    font-size: var(--fs-sm);
    color: var(--muted);
    background: linear-gradient(to top, rgba(16,24,32,.05), rgba(16,24,32,0));
    border-top:1px solid var(--border);
}

/* =========================================================
   iOS-LIGNENDE TOGGLE (roligere uttrykk)
   ========================================================= */
.switch-ios{ display:flex; align-items:center; gap:12px; user-select:none; }
.switch-caption{ margin-left:8px; font-size: var(--fs-sm); color: var(--muted); }
.switch-side{ font-size: var(--fs-sm); letter-spacing:.02em; color: var(--muted); }
.switch-off{ min-width:2ch; text-align:right; }
.switch-on{  min-width:2ch; }

.ios-switch{ position:relative; display:inline-block; line-height:0; }
.ios-switch input{ position:absolute; opacity:0; width:0; height:0; }
.ios-switch .track{
    --w: 58px; --h: 34px; --pad: 3px;
    width:var(--w); height:var(--h);
    background:#d2d8de;
    border-radius:9999px;
    display:inline-block; position:relative;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.05);
    transition: background-color 180ms ease, box-shadow 180ms ease;
}
.ios-switch .thumb{
    --size: calc(var(--h) - var(--pad) * 2);
    position:absolute; top:var(--pad); left:var(--pad);
    width:var(--size); height:var(--size); border-radius:9999px; background:#fff;
    box-shadow: 0 1px 2px rgba(0,0,0,.22), 0 4px 10px rgba(0,0,0,.10);
    transition: transform 180ms ease; will-change: transform;
}
.ios-switch input:checked + .track{ background:#32c05f; box-shadow: inset 0 0 0 1px rgba(0,0,0,.03); }
.ios-switch input:checked + .track .thumb{ transform: translateX(calc(58px - 34px)); }
.ios-switch input:focus-visible + .track{ outline: 3px solid var(--focus); outline-offset: 4px; }
.ios-switch input:disabled + .track{ opacity:.6; filter:grayscale(.1); cursor:not-allowed; }
.ios-switch input:disabled + .track .thumb{ box-shadow: 0 1px 2px rgba(0,0,0,.16); }

/* Redusert bevegelse */
@media (prefers-reduced-motion: reduce){
    .ios-switch .track, .ios-switch .thumb{ transition:none; }
}

/* ============================================
   KOMPASS: Flytt alle retningsbokstaver innover
   (uten å endre HTML). Vi antar at gruppa med
   bokstaver er siste <g> i SVG-en.
   ============================================ */

/* Tillat transform på enkelttagger */
svg.dial > g:last-of-type > text{
    transform-box: fill-box;
    transform-origin: center;
}

/* N (1): flytt litt ned */
svg.dial > g:last-of-type > text:nth-child(1){
    transform: translateY(4px);
}

/* Ø (2): litt mot venstre */
svg.dial > g:last-of-type > text:nth-child(2){
    transform: translateX(-4px);
}

/* S (3): litt opp */
svg.dial > g:last-of-type > text:nth-child(3){
    transform: translateY(-4px);
}

/* V (4): litt mot høyre */
svg.dial > g:last-of-type > text:nth-child(4){
    transform: translateX(4px);
}

/* NØ (5): inn mot sentrum (venstre + ned) */
svg.dial > g:last-of-type > text:nth-child(5){
    transform: translate(-4px, 4px);
}

/* SØ (6): inn (venstre + opp) */
svg.dial > g:last-of-type > text:nth-child(6){
    transform: translate(-4px, -4px);
}

/* SV (7): inn (høyre + opp) */
svg.dial > g:last-of-type > text:nth-child(7){
    transform: translate(4px, -4px);
}

/* NV (8): inn (høyre + ned) */
svg.dial > g:last-of-type > text:nth-child(8){
    transform: translate(4px, 4px);
}

/* (Valgfritt) litt mindre skrift for ekstra margin mot ringen på mobil */
@media (max-width: 560px){
    svg.dial > g:last-of-type > text{ font-size: 6px !important; }
}

/* =======================
   WEBCAM MODAL
   ======================= */

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.modal.is-open {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.modal-content {
    position: relative;
    background: var(--surface-2, #0f1720);
    padding: 1rem;
    border-radius: 16px;
    max-width: 90vw;
    max-height: 90vh;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    border: 1px solid var(--border, #1a2532);
}

.modal-content img {
    max-width: 100%;
    max-height: 80vh;
    display: block;
}

.modal-close {
    position: absolute;
    top: 15px;           /* litt lenger ned */
    right: 20px;         /* litt lenger inn */
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 2.2rem;   /* større X */
    line-height: 1;
    cursor: pointer;
}
