:root{
    --overlay-bg: rgba(0,0,0,.35);
    --overlay-text: #fff;
    --radius: 14px;
    --gap: 10px;
    --pad: 12px;
    --font: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}
*{ box-sizing: border-box }
html, body { height: 100% }
body{
    margin:0;
    background:#0b1117;
    color:#e6edf3;
    font-family: var(--font);
    display:flex;
    align-items:flex-start;
    justify-content:center;
    padding: clamp(8px, 2vw, 24px);
}

.page{ width: min(95vw, 1400px); display:grid; gap: 12px; }

.stage{
    position: relative;
    border-radius: var(--radius);
    overflow: clip;
    box-shadow: 0 10px 30px rgba(0,0,0,.35);
    background: #000;
}
.stage img{
    display:block;
    width: 100%;
    height: auto;
    object-fit: contain;
    background:#000;
}

/* Væroverlay – NEDRE VENSTRE (desktop) */
.overlay{
    position: absolute;
    left: var(--gap);
    bottom: var(--gap);
    max-width: min(92%, 540px);
    background: var(--overlay-bg);
    color: var(--overlay-text);
    padding: var(--pad);
    border-radius: var(--radius);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    border: 1px solid rgba(255,255,255,.10);
    box-shadow: 0 6px 18px rgba(0,0,0,.35);
    line-height: 1.32;
    font-size: clamp(14px, 1.6vw, 16px);
    max-height: 45vh;
    overflow: auto;
}
.overlay h3{ margin: 0 0 6px 0; font-size: 1em; font-weight: 700; color: #ffffff; letter-spacing: .2px; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.overlay ul{ margin: 0 0 8px 18px; padding: 0; color: #ffffff; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.overlay li{ margin: 2px 0; }

/* Status-badge – NEDRE HØYRE med trafikklys */
.status-pill{
    position:absolute;
    right: var(--gap);
    bottom: var(--gap);
    color:#fff;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.18);
    font-size: clamp(12px, 1.3vw, 13px);
    display:flex; align-items:center; gap:8px;
    box-shadow: 0 6px 18px rgba(0,0,0,.35);
    background: rgba(0,0,0,.35);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.dot{ width: 10px; height: 10px; border-radius:50%; box-shadow: 0 0 8px rgba(0,0,0,.4) inset, 0 0 6px rgba(255,255,255,.15); }
.ok   .dot{ background:#26c281; }
.warn .dot{ background:#f5c04f; }
.bad  .dot{ background:#ff4d4f; }

@media (max-width: 640px) { .status-pill { display: none; } }

/* Måne + tide */
.moon-card{
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 10px 12px 12px 12px;
  box-shadow: 0 6px 16px rgba(0,0,0,.25);
  position: relative;
  flex: 0 0 320px;
}
.moon-card .fcH-solar{
  margin-top: 12px;               /* space above solar events section */  
  padding: 8px 0;
}

.moon-card .fcH-solar .moon-title {
  position: absolute;
  left: 12px;
  top: 22px;                 /* tweak this value to nudge vertical position */
  transform: translateY(-50%);
  background: rgba(11,17,23,.04); /* visually match card background */
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 !important;
  line-height: 1;
}

.moon-card > div:last-child {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.moon-svg{
  width: 120px;
  height: 120px;
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.55)) drop-shadow(0 0 10px rgba(255,255,255,.20)) drop-shadow(0 0 20px rgba(255,255,255,.10));
}

.moon-info{
  display: grid;
  gap: 4px;
  line-height: 1.35;
  flex: 1;
}

.moon-title{ font-size: 1.05rem; font-weight:700;}
.muted{ opacity:.85 }
.moon-card circle[stroke]{ stroke: rgba(255,255,255,.28) !important; stroke-width: 1.5 !important; }

.tide-under-moon{ margin-top:.4rem; padding:.15rem 0; } /* slightly tighter */
.tide-under-moon .tide-row{ display:flex; align-items:baseline; justify-content:space-between; gap: 0.25em; padding: 2px 2px;  }
.tide-under-moon .tide-label{ color:#a9b3bd; }
.tide-under-moon .tide-value{ font-variant-numeric:tabular-nums; font-weight:600; }

/* Time-for-time */
.forecastHourly{ background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); border-radius: 14px; padding: 10px; box-shadow: 0 6px 16px rgba(0,0,0,.25); }
.fcH-head{ display:flex; align-items:baseline; justify-content:space-between; gap:8px; padding: 0 2px; font-size: 1.05rem; font-weight:700; }
.fcH-note{ opacity:.8; font-size:.95em }
.fcH-strip{ display:flex; gap:8px; overflow-x:auto; padding-bottom:6px; scroll-snap-type: x mandatory; }
.fcH-card{ flex: 0 0 96px; background: rgba(0,0,0,.2); border: 1px solid rgba(255,255,255,.10); border-radius: 12px; padding: 8px; display:grid; gap:6px; justify-items:center; text-align:center; scroll-snap-align: start; }
.fcH-time{ font-weight:700 }
.fcH-icon img{ width:88px; height:88px }
.fcH-t{ font-variant-numeric: tabular-nums }
.fcH-mm{ opacity:.9; font-size:.95em }
.fcH-wind { font-size: .85rem; opacity: .9; line-height: 1.3; }

/* Tilpasning for Entur-tekstblokken */
#entur-next-dep div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin: .4rem 0;   /* mer luft mellom linjene */
}
#entur-next-dep strong {
    color: #a9b3bd;
    font-weight: 600;
    margin-right: .3rem;
}
#entur-next-dep .row-actions {
    flex-shrink: 0;
}
#entur-next-dep {
    font-size: .95rem;
    line-height: 1.45;
    color: #e6edf3;
}





/* Tilpasning for Entur-kortet */
#entur-actions { gap: .35rem; }

/* Hourly forecast spacing – kun for Entur */
#entur-section .fcH-strip {
    display: flex;
    justify-content: space-around;
    gap: 1rem;
}
#entur-section .fcH-card {
    flex: 0 0 90px;
    text-align: center;
}

/* Mobiljustering for Entur-kortet */
@media (max-width: 640px) {
    #entur-section .fcH-strip {
        overflow-x: auto;
        justify-content: flex-start;
        gap: 0.5rem;
    }
    #entur-section .fcH-card { flex: 0 0 60px; }
}

.wind-arrow { display: inline-block; margin-left: .25rem; }
.wind-barb{ width:34px; height:34px; margin-left:.25rem; vertical-align:middle; }
@media (max-width:640px){ .wind-barb{ width:28px; height:28px; } }

@media (max-width: 640px){ #forecastHourly { grid-template-columns: repeat(3, minmax(0,1fr)); } }

@media (max-width: 640px){
    .overlay{ position: static; left: auto; bottom: auto; right: auto; width: auto; max-width: none; margin: 8px; max-height: 38vh; }
    .status-pill{ right: 10px; bottom: 10px; }
    .moon-card > div:last-child {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .fcH-card{ flex-basis: 86px; }
}

/* Måne + varsel samme linje */
.astro-row{ display: flex; gap: 8px; align-items: stretch; }
.moon-card{ flex: 0 0 320px; }
.fcH-head{ flex: 0 0 auto; }
.fcH-strip{ flex: 1 1 auto; min-height: 0; overflow-y: auto; }

@media (max-width: 640px){ .astro-row{ display: grid; grid-template-columns: 1fr; } .moon-card{ flex: none; } }

/* === (NYTT) Felles styling for BÅTER og FLY seksjoner === */
#ais-section, #adsb-section { --card-bg: #0b0b0b99; --text: #e9eef3; --muted: #a9b3bd; --border: #2a3340; --hover: #10161f80; max-width: 1100px; margin: 1rem auto; padding: 0 1rem; color: var(--text); }
#ais-section .ais-card, #adsb-section .ais-card{ background: var(--card-bg); backdrop-filter: blur(6px); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
#ais-section header, #adsb-section header{ display: flex; align-items: baseline; gap: .75rem; margin-bottom: .5rem; }
#ais-section header h2, #adsb-section header h2{ font-size: 1.05rem; font-weight: 600; margin: 0; }
#ais-section .meta, #adsb-section .meta{ font-size: .9rem; color: var(--muted); }
#ais-section .meta .dot, #adsb-section .meta .dot{ padding: 0 .4rem; }

/* Tabeller: båter + fly */
#ais-table, #adsb-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .95rem; border-radius: 8px; overflow: hidden; }
#ais-table th, #ais-table td, #adsb-table th, #adsb-table td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; word-wrap: break-word; }
#ais-table thead th, #adsb-table thead th { font-weight: 600; color: var(--muted); background: #0f141a66; }
#ais-table tbody tr, #adsb-table tbody tr { cursor: pointer; }
#ais-table tbody tr:hover, #adsb-table tbody tr:hover { background: var(--hover); }

#ais-section .empty, #ais-section .error, #adsb-section .empty, #adsb-section .error{ padding: .6rem .75rem; border: 1px dashed var(--border); border-radius: 8px; color: var(--muted); margin-top: .5rem; }
#ais-section .error, #adsb-section .error { color: #ffb3b3; border-color: #6b1f1f; }

/* Små skjermer: AIS skjuler kolonner 2–4; ADS-B skjuler høyde, fart og retning */
@media (max-width: 640px) {
    #ais-table th:nth-child(2), #ais-table td:nth-child(2),
    #ais-table th:nth-child(3), #ais-table td:nth-child(3),
    #ais-table th:nth-child(4), #ais-table td:nth-child(4) { display:none; }

    #adsb-table th:nth-child(3), #adsb-table td:nth-child(3)  /* Flyselskap */
    { display:none; }

    #adsb-table th:nth-child(2), #adsb-table td:nth-child(2), /* Høyde */
    #adsb-table th:nth-child(3), #adsb-table td:nth-child(3), /* Fart */
    #adsb-table th:nth-child(4), #adsb-table td:nth-child(4)  /* Retning */
    { display:none; }

    /* Skjul lenkekolonne på små skjermer */
    #ais-table th:nth-child(7), #ais-table td:nth-child(7),
    #adsb-table th:nth-child(8), #adsb-table td:nth-child(8) { display:none; }
}

/* Retningspil (gjenbruk til både AIS COG og ADS-B heading) */
.cog-wrap{display:flex;align-items:center;gap:.45rem}
.cog-arrow{ width:22px; height:32px; transform-origin:50% 50%; }
.cog-arrow .shaft{ stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; }
.cog-arrow .head{ fill: currentColor; }
.cog-arrow .outline{ stroke: rgba(0,0,0,.45); stroke-width: 5.4; stroke-linecap: round; fill: none; }
.cog-text{opacity:.85; min-width: 3ch;}

/* Nettbrett-tilpasning for overlay */
@media (min-width: 700px) and (max-width: 1024px) { .overlay{ max-width: min(52%, 520px); font-size: 14px; padding: 6px 8px; } }
@media (min-width: 600px) and (max-width: 820px) and (orientation: portrait){ .overlay{ max-width: min(46%, 460px); font-size: 13.5px; padding: 6px 8px; } }
@media (max-height: 600px) and (min-width: 700px){ .overlay{ max-width: 42%; font-size: 13px; padding: 5px 7px; } }

/* AIS hover-tooltip */
#ais-tooltip{
    position: fixed;
    left: 0; top: 0;
    transform: translate(-9999px,-9999px);
    background: rgba(8,12,18,.92);
    color: #e6edf3;
    border: 1px solid #2a3340;
    border-radius: 8px;
    padding: 8px 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,.45);
    font-size: .9rem;
    line-height: 1.35;
    white-space: pre-line;
    z-index: 9999;
    pointer-events: none;
    max-width: 360px;
}
#ais-tooltip[hidden]{ display:none !important; }



/* Rad-ikonknapper */
.row-actions{ display:flex; gap:.35rem; align-items:center; }
.iconbtn{
    display:inline-flex; align-items:center; justify-content:center;
    width:28px; height:28px; border-radius:8px;
    border:1px solid rgba(255,255,255,.15);
    background: rgba(255,255,255,.06);
    cursor:pointer; text-decoration:none; color:#e6edf3;
}
.iconbtn:hover{ background: rgba(255,255,255,.12); }
.iconbtn svg{ width:16px; height:16px; display:block; }


.fcH-card {
    flex: 0 0 60px;
}
/* Begrens layouten */
.charts-wrap{
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    gap: 16px;
}
/* Hver graf har fast (rimelig) høyde */
.chart-box{ height: 400px;        /* juster 240–400px etter smak */
    width: 100%;
}
/* Canvas skal bruke hele boksen, men ikke større enn containeren */
.chart-box canvas{
    width: 100% !important;
    height: 100% !important;
    display: block;
}


#tempChart, #windChart {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* Badge for "(i morgen)" */
.badge-tomorrow{
    display:inline-block;
    font-size:.8em;
    padding:0 .4em;
    border-radius:.5em;
    background:rgba(255,255,255,.12);
    border:1px solid rgba(255,255,255,.25);
    margin-left:.35em;
    vertical-align:baseline;
    line-height:1.4;
}

/* Sunrise/Sunset section styling */
.sunrise-sunset {
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 14px;
    padding: 10px;
    box-shadow: 0 6px 16px rgba(0,0,0,.25);
    flex: 0 0 240px;
}

.sun-strip {
    padding: 8px 2px;
}

.sun-event {
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: var(--radius);
    background: rgba(255,255,255,.02);
    flex: 1;
    min-width: 0;
}

.sun-event .sun-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.sun-event .sun-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sun-event .sun-label {
    font-size: 0.9rem;
    color: #a9b3bd;
    opacity: .85;
    line-height: 1.2;
}

.sun-event .sun-time {
    font-weight: 600;
    color: #e6edf3;
    font-size: 0.95rem;
    line-height: 1.2;
}

.sun-separator {
    display: none;
}

.sun-events{
  display: flex;
  gap: 8px;
  align-items: stretch;
  flex-wrap: wrap; /* allow items to wrap if space is constrained */
}

/* Make each event take an equal column but be allowed to shrink */
.sun-events > .sun-event {
  flex: 1 1 60px; /* grow, shrink, base width */
  min-width: 40px;
}

.sun-event .sun-label,
.sun-event .sun-time,
.tide-under-moon .tide-label,
.tide-under-moon .tide-value {
  font-family: var(--font);
  font-size: .95rem;       /* same size for both */
  line-height: 1.35;
}

/* Keep visual weight differences (labels vs values) */
.sun-event .sun-label,
.tide-under-moon .tide-label { color: #a9b3bd; font-weight: 600; }
.sun-event .sun-time,
.tide-under-moon .tide-value { color: #a9b3bd; font-weight: 600; }

/* Mobile/smaller screens - stack vertically */
@media (max-width: 640px) {
    .sun-events {
        flex-direction: column;
        gap: 8px;
    }

    .sun-event {
        flex: none;
    }

    /* Ensure moon card solar events also stack vertically on mobile */
    .moon-card .fcH-solar .sun-events {
        flex-direction: column !important;
        gap: 8px !important;
    }
}

/* Adjust astro-row for three columns */
.astro-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.forecastHourly.compact {
    flex: 1 1 auto;
}

.sunrise-sunset.compact {
    flex: 0 0 240px;
}

.moon-card {
    flex: 0 0 320px;
}

/* Moon layout: phase box + tide box side-by-side */
.moon-grid{ display:flex; gap:8px; align-items:stretch; margin-top:8px; } /* was 12px */


/* Generic box used for both phase and tide */
.moon-box{
  position:relative;
  flex: 0 1 220px;
  min-width: 160px;
  background: rgba(11,17,23,.04);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 10px;
  padding: 8px;
  display:flex;
  flex-direction:column;
  align-items:center;
}

/* Title pinned top-left inside each box */
.moon-box > .moon-title{
  position:absolute;
  left:10px;
  top:8px;
  margin:0;
  background: rgba(11,17,23,.04);
  padding: 3px 3px;
  border-radius:6px;
  font-size: 1rem;
  font-weight:700;
  line-height:1;
}

/* Phase box: svg centered */
.phase-box .moon-svg{
  width: 80px;
  height: 80px;
  display:block;
  margin-top:28px; /* room below the pinned title */
}

/* small description under the svg */
.moon-desc{
  margin-top:10px;
  text-align:center;
  color: var(--muted, #a9b3bd);
  font-size:0.95rem;
}

/* Tide box: use existing tide-under-moon styles but ensure spacing */
.tide-box{ align-items:stretch; }
.tide-box .tide-under-moon{ margin-top:24px; }

/* Responsive: stack on small screens */
@media (max-width:640px){
  .moon-grid{ flex-direction:column; }
  .moon-box{ width:100%; }
  .phase-box .moon-svg{ width:88px; height:88px; }
}

@media (max-width: 900px) {
    .astro-row {
        display: grid;
        grid-template-columns: 1fr;
    }

    .sunrise-sunset.compact,
    .moon-card {
        flex: none;
    }
}

/* Solar Events Responsive Layout */
.fcH-solar {
  margin-top: 12px;
  padding: 8px 0;
}

.fcH-solar-head {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: #a9b3bd;
}

.sun-events-list {
  display: flex;
  flex-direction: row;
  gap: 16px;
  flex-wrap: wrap;
}

.sun-event-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 12px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  min-width: 120px;
  flex: 1;
}

.sun-event-item.sun-event-next {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1);
}

.sun-event-type {
  font-size: 0.85rem;
  font-weight: 600;
  color: #a9b3bd;
  margin-bottom: 4px;
  text-transform: capitalize;
}

.sun-event-time {
  font-size: 0.8rem;
  color: #a9b3bd;
  opacity: 0.9;
}

.sun-error, .sun-none, .sun-loading {
  padding: 8px 12px;
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.8;
}

.sun-error {
  color: #ff6b6b;
}

.sun-none {
  color: #a9b3bd;
}

.sun-loading {
  color: #a9b3bd;
}

/* Responsive: Stack vertically on smaller screens */
@media (max-width: 768px) {
  .sun-events-list {
    flex-direction: column;
    gap: 8px;
  }

  .sun-event-item {
    flex-direction: row;
    text-align: left;
    justify-content: space-between;
    align-items: center;
    min-width: unset;
  }

  .sun-event-type {
    margin-bottom: 0;
    margin-right: 8px;
  }
}

/* Extra small screens: Keep compact layout */
@media (max-width: 480px) {
  .sun-event-item {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .sun-event-type {
    font-size: 0.8rem;
  }

  .sun-event-time {
    font-size: 0.75rem;
  }
}
