/* live-hud-v70.css — CSS fullscreen, flight HUD and picture-in-picture map. */

/* ============================================================
   1. CSS fullscreen (replaces the native video player)
   ============================================================ */

.dc-fs-active {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9990 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  width: 100vw !important;
  max-width: none !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-height: none !important;
  background: #000 !important;
  display: flex !important;
  flex-direction: column !important;
}

/* Only the pane that is currently large fills the screen. Without the stage
   scoping these rules also hit the small picture-in-picture tile and stretch
   it over the full height. */
.dc-fs-active .dc-stage--video .video-wrap,
.dc-fs-active .dc-stage--map .dc-live-map-pane {
  flex: 1 1 auto;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  border-radius: 0 !important;
  margin: 0 !important;
}

.dc-fs-active .dc-stage--video .video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* The PiP tile keeps its tile shape in fullscreen. */
.dc-fs-active .dc-stage--video .dc-live-map-pane,
.dc-fs-active .dc-stage--map .video-wrap {
  flex: none;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: 4 / 3 !important;
  border-radius: 0.7rem !important;
}

.dc-fs-active .dc-stage--map .video-wrap video {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  object-fit: cover;
}

/* Hide chrome that only makes sense in the page layout. */
.dc-fs-active .stream-head,
.dc-fs-active .stream-telemetry,
.dc-fs-active .dc-live-view-switch-row,
.dc-fs-active .public-live-footer,
.dc-fs-active .public-share-extra {
  display: none !important;
}

body.dc-fs-open {
  overflow: hidden;
}

/* Fullscreen button stays reachable, clear of the iOS notch. */
.dc-video-fullscreen-button {
  z-index: 9995;
}

.dc-fs-active .dc-video-fullscreen-button {
  position: fixed;
  left: max(0.75rem, env(safe-area-inset-left));
  top: max(0.75rem, env(safe-area-inset-top));
}

/* ============================================================
   2. Flight HUD (bottom centre, over the video)
   ============================================================ */

.dc-hud {
  position: absolute;
  left: 50%;
  bottom: max(0.6rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.6rem, 2.5vw, 1.6rem);
  padding: 0.5rem 0.9rem;
  border-radius: 0.9rem;
  background: rgba(4, 8, 14, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  max-width: calc(100% - 1rem);
  flex-wrap: nowrap;
  box-sizing: border-box;
}

.dc-hud[hidden] {
  display: none;
}

.dc-hud-col {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.dc-hud-col.right {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: baseline;
  column-gap: 0.3rem;
  row-gap: 0.12rem;
}

.dc-hud-col.right .dc-hud-label {
  justify-self: end;
}

/* The values share one column, right aligned, so the digits line up. */
.dc-hud-col.right .dc-hud-value {
  justify-self: end;
  text-align: right;
}

.dc-hud-col.right .dc-hud-unit {
  justify-self: start;
}

.dc-hud-row {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  white-space: nowrap;
}

.dc-hud-label {
  font-size: clamp(0.55rem, 1.6vw, 0.7rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.82);
}

.dc-hud-value {
  font-size: clamp(0.95rem, 3vw, 1.5rem);
  font-weight: 800;
  line-height: 1.05;
}

.dc-hud-unit {
  font-size: clamp(0.5rem, 1.5vw, 0.68rem);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.82);
}

.dc-hud-coord {
  font-size: clamp(0.6rem, 1.8vw, 0.8rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Compass */
.dc-hud-compass {
  width: clamp(56px, 15vw, 96px);
  height: clamp(56px, 15vw, 96px);
  flex: 0 0 auto;
}

.dc-hud-compass svg {
  width: 100%;
  height: 100%;
  display: block;
}

.dc-compass-card {
  transform-origin: 50px 50px;
  /* Kein CSS-Übergang: Die Anzeige wird im Browser Bild für Bild
     interpoliert, ein zusätzlicher Übergang würde das verzögern. */
}

.dc-hud-value.low {
  color: #ff9a9a;
}

/* Stale telemetry: dim the whole HUD instead of showing wrong numbers. */
.dc-hud.stale {
  opacity: 0.55;
}

/* On very narrow screens drop the coordinates to keep the HUD readable. */
@media (max-width: 420px) {
  .dc-hud-coord {
    display: none;
  }
}

/* ============================================================
   3. Stage: video and map share one box, one big + one PiP tile
   ============================================================ */

.dc-stage {
  position: relative;
  width: 100%;
  /* Own stacking context so the panes' internals stay contained. */
  isolation: isolate;
}

/* Common PiP tile look, applied to whichever pane is currently small. */
.dc-stage--video .dc-live-map-pane,
.dc-stage--map .video-wrap {
  position: absolute;
  left: max(0.6rem, env(safe-area-inset-left));
  bottom: max(0.6rem, env(safe-area-inset-bottom));
  z-index: 40;
  width: clamp(120px, 26%, 240px);
  height: auto;
  aspect-ratio: 4 / 3;
  min-height: 0 !important;
  max-height: none;
  margin: 0;
  border-radius: 0.7rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  background: #0a0f16;
  cursor: pointer;
}

/* Label on the small tile ("Karte" / "Livebild"). */
.dc-stage--video .dc-live-map-pane::after,
.dc-stage--map .video-wrap::after {
  content: attr(data-pip-label);
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.2rem 0.4rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.78));
  pointer-events: none;
  z-index: 2;
}

/* The big pane fills the stage normally. Its own stacking context traps
   Leaflet's internal z-indexes (tiles 200 … controls 1000) so they cannot
   paint over the picture-in-picture tile. */
.dc-stage--video .video-wrap,
.dc-stage--map .dc-live-map-pane {
  position: relative;
  z-index: 0;
  width: 100%;
  cursor: default;
}

/* Map mode: Leaflet puts its zoom control at the top left, where the layer
   switch also starts — shift the switch clear of it. */
.dc-stage--map .dc-live-map-top-controls {
  padding-left: 3.2rem;
}

@media (max-width: 620px) {
  .dc-stage--map .dc-live-map-top-controls {
    padding-left: 2.9rem;
  }
}

/* Map mode: keep the footer clear of the video tile in the corner. */
.dc-stage--map .dc-live-map-footer {
  margin-left: calc(clamp(120px, 26%, 240px) + 1.2rem);
}

@media (max-width: 620px) {
  .dc-stage--map .dc-live-map-footer {
    margin-left: calc(clamp(88px, 26%, 130px) + 0.9rem);
  }
}

/* Small map: shrink Leaflet and hide its chrome. */
.dc-stage--video .dc-live-map-pane .dc-live-map-canvas,
.dc-stage--video .dc-live-map-pane .leaflet-container {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  border-radius: 0;
}

.dc-stage--video .dc-live-map-pane .leaflet-control-container,
.dc-stage--video .dc-live-map-pane .dc-live-map-top-controls,
.dc-stage--video .dc-live-map-pane .dc-live-map-footer,
.dc-stage--video .dc-live-map-pane .dc-live-map-waiting {
  display: none !important;
}

/* Small video: fill the tile, no controls. */
/* The base stylesheet forces a min-height on the video element
   (.video-wrap video{min-height:220px} and, for a single stream,
   min-height:min(68vh,48rem)). Inside the small tile that overflows the box
   so only a cropped sliver stays visible — it must be reset here. */
.dc-stage--map .video-wrap video {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  object-fit: cover;
}

.dc-stage--map .video-wrap .player-status,
.dc-stage--map .video-wrap .dc-video-fullscreen-button {
  display: none !important;
}

/* HUD belongs to the video: show it only while the video is the big pane. */
.dc-stage--map .dc-hud {
  display: none !important;
}

/* Keep the HUD clear of the PiP tile on wide screens. */
.dc-stage--video .dc-hud {
  left: calc(50% + clamp(50px, 12%, 110px));
}

/* --- Phones: HUD and PiP share the bottom band instead of stacking ---
   A 16:9 video on a 390px phone is only ~219px tall, so putting the HUD
   above the PiP tile would swallow the picture. Instead the tile stays
   bottom-left and the HUD sits centred in the space beside it, shrunk to
   fit. */
@media (max-width: 620px) {
  .dc-stage--video .dc-live-map-pane,
  .dc-stage--map .video-wrap {
    width: clamp(88px, 26%, 130px);
  }

  .dc-stage--video .dc-hud {
    left: calc(50% + 3.4rem);
    bottom: max(0.5rem, env(safe-area-inset-bottom));
    gap: 0.45rem;
    padding: 0.35rem 0.5rem;
    border-radius: 0.7rem;
  }

  .dc-hud-compass {
    width: 48px;
    height: 48px;
  }

  .dc-hud-value {
    font-size: 0.95rem;
  }

  .dc-hud-label,
  .dc-hud-unit {
    font-size: 0.55rem;
  }
}

/* --- Portrait phones: keep the map compact ---
   The base style gives the map pane min(58vh, 520px), which on a phone in
   portrait fills nearly the whole screen — the video tile in the corner then
   sits below the fold and is hard to reach. A shorter map keeps both panes
   visible; fullscreen (body.dc-fs-open) is deliberately excluded. */
@media (max-width: 640px) and (orientation: portrait) {
  body:not(.dc-fs-open) .dc-stage--map .dc-live-map-pane {
    height: min(42vh, 360px) !important;
    min-height: 210px !important;
  }

  /* Slightly larger tile so the live image stays an easy tap target. */
  body:not(.dc-fs-open) .dc-stage--map .video-wrap {
    width: clamp(104px, 32%, 150px);
  }

  /* The footer would otherwise eat the shortened map. */
  body:not(.dc-fs-open) .dc-stage--map .dc-live-map-footer {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
    font-size: 0.8rem;
  }
}

/* Very small phones: shrink once more so nothing clips. */
@media (max-width: 380px) {
  .dc-stage--video .dc-live-map-pane,
  .dc-stage--map .video-wrap {
    width: clamp(76px, 24%, 110px);
  }

  .dc-stage--video .dc-hud {
    left: calc(50% + 3rem);
    gap: 0.35rem;
    padding: 0.3rem 0.4rem;
  }

  .dc-hud-compass {
    width: 40px;
    height: 40px;
  }

  .dc-hud-value {
    font-size: 0.85rem;
  }
}

/* Landscape phones have plenty of width but very little height — keep the
   HUD flat and the tile small so the picture stays usable. */
@media (max-height: 460px) and (orientation: landscape) {
  .dc-stage--video .dc-live-map-pane,
  .dc-stage--map .video-wrap {
    width: clamp(88px, 18%, 150px);
  }

  .dc-hud-compass {
    width: 44px;
    height: 44px;
  }

  .dc-stage--video .dc-hud {
    padding: 0.3rem 0.6rem;
  }
}

/* In CSS fullscreen the stage fills the screen. */
.dc-fs-active .dc-stage {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Close button, only present while CSS fullscreen is active. */
.dc-fs-close {
  position: fixed;
  left: max(0.75rem, env(safe-area-inset-left));
  top: max(0.75rem, env(safe-area-inset-top));
  z-index: 9995;
  min-height: 2.75rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 0.75rem;
  background: rgba(2, 6, 23, 0.78);
  color: #fff;
  padding: 0.55rem 0.95rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.dc-fs-close:active {
  transform: translateY(1px);
}

/* ============================================================
   4. Public share view — chrome free, full viewport by default
   ============================================================ */

body.dc-share-page {
  overflow: hidden;
}

/* The portal main element centres and pads its content; the share view
   needs the whole viewport instead. */
/* Tailwind setzt auf .site-main max-width:80rem und Innenabstand. Für die
   Freigabe-Ansicht muss beides weg, sonst bleibt der Stream in der Mitte
   eingeklemmt statt den Bildschirm zu füllen. */
body.dc-share-page .site-main,
body.dc-share-page main.site-main {
  max-width: none !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

body.dc-share-page,
body.dc-share-page .site-main {
  min-height: 100dvh;
}

.dc-share-full {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  background: #000;
}

.dc-share-full .stream-card {
  position: absolute;
  inset: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #000;
  overflow: hidden;
  box-shadow: none;
}

.dc-share-full .dc-stage {
  position: absolute;
  inset: 0;
}

/* Whichever pane is large fills the screen; the PiP tile keeps its own
   rules from section 3. */
.dc-share-full .dc-stage--video > .video-wrap,
.dc-share-full .dc-stage--map > .dc-live-map-pane {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  border-radius: 0 !important;
  margin: 0 !important;
}

/* Standard: ganzes Bild zeigen, kein Beschnitt. Auf einem hochkant
   gehaltenen Handy würde "cover" rund drei Viertel der Bildbreite
   abschneiden — das ist bei einem Einsatzstream nicht vertretbar. */
.dc-share-full .dc-stage--video > .video-wrap video {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  object-fit: contain;
  background: #000;
}

/* Nur wenn das Fenster mindestens 16:9 ist, füllt das Bild den Schirm aus.
   Der Beschnitt bleibt dann unter etwa 6 Prozent und betrifft nur oben und
   unten — dafür verschwinden die schwarzen Balken. */
@media (min-aspect-ratio: 16/9) {
  .dc-share-full .dc-stage--video > .video-wrap video {
    object-fit: cover;
  }
}

/* Drone name, top left — the only branding the viewer sees. */
.dc-share-badge {
  position: absolute;
  top: max(0.7rem, env(safe-area-inset-top));
  left: max(0.7rem, env(safe-area-inset-left));
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  border-radius: 0.7rem;
  background: rgba(4, 8, 14, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  font-weight: 800;
  font-size: clamp(0.78rem, 2.2vw, 0.95rem);
  letter-spacing: 0.01em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  max-width: calc(100% - 1.4rem);
}

.dc-share-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dc-share-dot {
  flex: 0 0 auto;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 0.22rem rgba(34, 197, 94, 0.18);
}

/* Already full screen — the injected fullscreen button would only confuse. */
.dc-share-full .dc-video-fullscreen-button {
  display: none !important;
}

/* Keep the map footer from covering the video tile in map mode. */
.dc-share-full .dc-stage--map .dc-live-map-footer {
  margin-left: calc(clamp(120px, 26%, 240px) + 1.2rem);
}

@media (max-width: 620px) {
  .dc-share-full .dc-stage--map .dc-live-map-footer {
    margin-left: calc(clamp(88px, 26%, 130px) + 0.9rem);
  }
}
