/* =====================================================
   CUSTOM PROPERTIES
===================================================== */
:root {
  --gap:      14px;
  --pad:      14px;
  --radius:   12px;
  --rail-w:   380px;
  --bg:       #0a0a0b;
  --tile:     #101012;
  --line:     rgba(255, 255, 255, .07);
  --accent:   #4a9eed;
  --live:     #e23a3a;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: #fff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color-scheme: dark;
  overflow: hidden;
}

/* =====================================================
   APP LAYOUT — grote stage + zijbalk
===================================================== */
.app {
  display: grid;
  grid-template-columns: 1fr var(--rail-w);
  gap: var(--gap);
  padding: var(--pad);
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

.stage {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--tile);
  border: 1px solid var(--line);
  min-width: 0;
}

.rail {
  display: grid;
  grid-template-rows: repeat(5, 1fr);
  gap: var(--gap);
  min-height: 0;
}

/* =====================================================
   CAMERA TEGELS
===================================================== */
.cam {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--tile);
  border: 1px solid var(--line);
}

/* De cam die op de stage staat vult het hele vlak (stage heeft z'n eigen kader) */
.stage > .cam { border: 0; border-radius: 0; }

.cam > img,
.cam > video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 0;
  display: block;
  /* Forceer compositing i.p.v. de hardware video-overlay:
     voorkomt de zwarte flits bij clip-wissels op oudere Chromecasts.
     will-change dwingt de compositor-laag betrouwbaar af. */
  will-change: transform;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Object-position per cam */
.cam-oefenweide > img { object-position: top left; }
.cam-see        > img { object-position: bottom left; }
.cam-panomax    > video { object-position: bottom; }

/* Verouderde still (kon niet verversen → laatste goede frame blijft staan) */
.cam.stale > img { opacity: .78; transition: opacity .4s ease; }

/* =====================================================
   LIVE / OFFLINE BADGES
===================================================== */
.stage > .cam::after,
.offline::after {
  position: absolute;
  z-index: 6;
  pointer-events: none;
  font-weight: 700;
  letter-spacing: .06em;
  border-radius: 20px;
}

/* Grote LIVE-badge op de stage */
.stage > .cam::after {
  content: "● LIVE";
  top: 16px;
  left: 16px;
  padding: 5px 13px;
  font-size: 14px;
  color: #fff;
  background: rgba(226, 58, 58, .85);
}

/* Kleine OFFLINE-badge in de zijbalk */
.offline::after {
  content: "OFFLINE";
  top: 9px;
  left: 9px;
  padding: 3px 8px;
  font-size: 10px;
  color: rgba(255, 255, 255, .6);
  background: rgba(0, 0, 0, .6);
}

/* Stage én offline → grote OFFLINE-badge */
.stage > .cam.offline::after {
  content: "OFFLINE";
  top: 16px;
  left: 16px;
  padding: 5px 13px;
  font-size: 14px;
  color: rgba(255, 255, 255, .6);
  background: rgba(0, 0, 0, .55);
}

/* =====================================================
   WEER-PANEEL (overlay op de stage)
===================================================== */
.wx {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 7;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: clamp(18px, 1.8vw, 30px);
  padding: clamp(10px, 1.1vw, 16px) clamp(18px, 1.6vw, 28px);
  border-radius: 16px;
  /* Apple frosted glass (donker) */
  background: rgba(20, 22, 28, .42);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, .18);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .28);
}

/* Zachte glans-rand bovenop het glas */
.wx::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(150deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 44%);
}

.wx-item { display: flex; align-items: center; gap: 10px; }

.ico {
  width: clamp(20px, 1.8vw, 30px);
  height: clamp(20px, 1.8vw, 30px);
  opacity: .7;
  flex: none;
}
.ico-fill   { fill: currentColor; }
.ico-stroke { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.wx-temp {
  font-size: clamp(1.2rem, 1.7vw, 2rem);
  font-weight: 800;
}
.wx-temp .u { font-size: .58em; font-weight: 600; opacity: .7; margin-left: 3px; }

.wx-data { display: flex; flex-direction: column; line-height: 1.05; }

.wx-val {
  font-size: clamp(1.1rem, 1.5vw, 1.8rem);
  font-weight: 800;
  color: var(--accent);
}
.wx-val .u { font-size: .55em; font-weight: 600; color: rgba(255, 255, 255, .6); margin-left: 3px; }

.wx-lab {
  margin-top: 2px;
  font-size: clamp(.6rem, .7vw, .8rem);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .55;
}

/* =====================================================
   KLOK (overlay op de stage, rechtsboven)
===================================================== */
#clock {
  position: absolute;
  top: 16px;
  right: 18px;
  z-index: 7;
  pointer-events: none;
  padding: clamp(6px, .7vw, 10px) clamp(12px, 1.1vw, 18px);
  border-radius: 14px;
  font-size: clamp(1.1rem, 1.5vw, 1.9rem);
  font-weight: 700;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  color: #fff;
  /* Frosted glass (donker) — passend bij het weer-paneel */
  background: rgba(20, 22, 28, .42);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, .18);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .28);
}

/* =====================================================
   RADIO PILL (overlay op de stage, rechtsonder)
===================================================== */
#radioNow {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 7;
  max-width: 46%;
  padding: 7px 14px;
  font-size: clamp(11px, .85vw, 14px);
  font-weight: 600;
  color: #fff;
  border-radius: 20px;
  /* Frosted glass (donker) — consistent met weer-paneel en klok */
  background: rgba(20, 22, 28, .42);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, .18);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .28);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* =====================================================
   MOBIEL / KLEIN SCHERM  (Chromecast = 1080p, dit is fallback)
===================================================== */
@media (max-width: 900px) {
  html, body { overflow: auto; }

  .app {
    grid-template-columns: 1fr;
    height: auto;
  }

  .stage { aspect-ratio: 16 / 9; }

  .rail {
    grid-template-rows: none;
    grid-template-columns: 1fr 1fr;
  }
  .rail .cam { aspect-ratio: 16 / 9; height: auto; }

  #radioNow { display: none; }
}
