/* Live Daintree footage as the forest background, crossfaded above the still photograph. */
#live-view {
  position: absolute;
  inset: 0;
  z-index: -3; /* after <picture> in the DOM, so it paints above it and below .forest::before (-2) */
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.4s ease;
}
#live-view[hidden],
#camera-controls[hidden] { display: none; }
#live-view ~ picture { z-index: -4; } /* only matches if the DOM order is reversed */
body.camera-visible #live-view { opacity: 1; }
#live-view .video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  transition: filter 1.2s ease;
}
.in-clearing #live-view .video { filter: saturate(.82) sepia(.16) hue-rotate(-8deg) brightness(.78) contrast(1.06); }

/* Quiet top-right HUD: translucent backing plus a small local scrim keeps it legible on bright footage. */
#camera-controls {
  position: fixed;
  z-index: 3;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  max-width: calc(100vw - 8rem);
  min-height: 44px;
  padding-left: 14px;
  border-radius: 22px;
  color: #f5f8f1;
  font: 500 .72rem/1.2 system-ui, sans-serif;
  font-weight: 500;
  letter-spacing: .018em;

  text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
  background: rgba(7, 15, 11, .52);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .14);
}
#camera-controls::before {
  content: "";
  position: absolute;
  inset: -16px -16px -32px -48px;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(closest-side at 70% 40%, rgba(5, 12, 9, .38), transparent);
}
.cam-state { display: flex; align-items: center; gap: 7px; padding-right: 10px; }
.cam-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #aab2ab; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }
[data-state="live"] .cam-dot { background: #b9e2b0; box-shadow: 0 0 7px #9ed59c70; }
[data-state="loading"] .cam-dot,
[data-state="buffering"] .cam-dot { background: #e8b04a; }
[data-state="offline"] .cam-dot { background: transparent; box-shadow: inset 0 0 0 1.5px #cfd6d0; }
.cam-src {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 6px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cam-src:hover { text-decoration: underline; text-underline-offset: 3px; }
.cam-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: inherit;
  background: transparent;
  cursor: pointer;
}
.cam-btn:hover { background: rgba(255, 255, 255, .14); }
.cam-src:focus-visible,
.cam-btn:focus-visible { outline: 2px solid #fff; outline-offset: -3px; border-radius: 22px; }
.cam-btn svg { display: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[data-act="pause"] .i-pause,
[data-act="play"] .i-play,
[data-act="retry"] .i-retry { display: block; }
.cam-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* Slim in portrait and short landscape: drop the state word, keep dot, credit and button. */
@media (max-width: 640px), (max-height: 480px) {
  #camera-controls { top: max(6px, env(safe-area-inset-top)); right: max(6px, env(safe-area-inset-right)); padding-left: 10px; font-size: .6875rem; letter-spacing: .06em; max-width: calc(100vw - 7rem); }
  .cam-state { padding-right: 4px; }
  .cam-state { gap: 4px; }
  .cam-state > span { font-size: 10px; letter-spacing: 0; }
  .cam-src { padding-inline: 3px; }
  .cam-dot { width: 5px; height: 5px; }
  .cam-btn { width: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  #live-view { transition-duration: .2s; }
  .cam-dot { animation: none !important; }
}

/* Stack the source and camera state in the same left-hand hit area on small phones. */
@media (max-width: 389px) {
  #camera-controls { width: 137px; max-width: 46vw; padding-left: 9px; }
  #camera-controls .cam-state {
    position: absolute;
    top: 5px;
    left: 12px;
    pointer-events: none;
  }
  #camera-controls .cam-src {
    flex: 1;
    padding: 15px 0 0 2px;
    font-size: 11px;
  }
}
