/* Shared styles for the nest camera pages (nestcam-*.html). */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #eef2eb;
  color: #253529;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  line-height: 1.6;
}

header {
  padding: 2.5rem 1rem;
  background: #304b38;
  color: #fff;
  text-align: center;
}

header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 3rem);
}

header p {
  margin: 0.5rem 0 0;
}

main {
  width: min(100% - 2rem, 1600px);
  margin: 2rem auto;
}

.camera-card {
  padding: clamp(1rem, 3vw, 2rem);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 8%);
}

.camera-card h2 {
  margin-top: 0;
}

/* Two cameras side by side on wide screens, stacked on narrow ones. */
.camera-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr));
  gap: clamp(1rem, 2.5vw, 2rem);
  align-items: start;
}

.camera-panel h3 {
  margin: 0 0 0.6rem;
  font-size: 1.25rem;
}

.note {
  color: #58645b;
  font-size: 0.95rem;
}

a {
  color: #305d3d;
}

footer {
  padding: 0 1rem 2rem;
  text-align: center;
  color: #58645b;
}

/* Video and controls */
.nest-player {
  background: #142019;
  border-radius: 10px;
  overflow: hidden;
}

.video-viewport {
  position: relative;
  overflow: hidden;
  background: #000;
  /* Allow page scrolling with one finger; two-finger pinch zooms the picture. */
  touch-action: pan-x pan-y;
}

/* When zoomed in, dragging moves around the picture instead of scrolling the page. */
.nest-player.is-zoomed .video-viewport {
  touch-action: none;
  cursor: grab;
}

.nest-player.is-dragging .video-viewport {
  cursor: grabbing;
}

/* Video format label (H.265 / H.264) in the top-right corner of each video. */
.codec-label {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgb(0 0 0 / 65%);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.zoom-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 8px 14px;
  border-radius: 8px;
  background: rgb(0 0 0 / 72%);
  color: #fff;
  font-size: 0.95rem;
  pointer-events: none;
  white-space: nowrap;
}

.nest-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border-radius: 0;
  transform: scale(1);
  transform-origin: 50% 50%;
}

/* Compact icon control bar */
.player-controls,
.zoom-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  color: #fff;
}

.zoom-controls {
  gap: 6px 14px;
  border-top: 1px solid rgb(255 255 255 / 15%);
  font-size: 0.9rem;
}

.zoom-controls label,
.zoom-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.zoom-group {
  padding: 0 6px;
  color: #dfe9da;
}

.zoom-group svg { flex: 0 0 auto; }

.player-controls input[type="range"],
.zoom-controls input[type="range"] {
  width: 100px;
  max-width: 100%;
  accent-color: #a6cf91;
}

.zoom-value {
  min-width: 3.2ch;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.controls-spacer { flex: 1 1 0; }

.quality-control {
  display: flex;
  align-items: center;
}

.quality-select {
  min-height: 36px;
  padding: 4px 6px;
  border: 1px solid rgb(255 255 255 / 30%);
  border-radius: 6px;
  background: #24342a;
  color: #fff;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  width: 6.5rem;
}

.quality-select:focus-visible {
  outline: 3px solid #f0d36b;
  outline-offset: 2px;
}

.nest-player button {
  min-height: 36px;
  padding: 4px 10px;
  border: 1px solid #b8c8b5;
  border-radius: 6px;
  background: #eef2eb;
  color: #253529;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.nest-player .icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
}

.nest-player .icon-button:hover:not(:disabled) {
  background: rgb(255 255 255 / 14%);
}

.nest-player .icon-button svg { display: block; }

.muted-mark {
  stroke: #ff4d4f;
  stroke-width: 2.2;
}

.nest-player button:disabled {
  opacity: 0.4;
  cursor: default;
}

.nest-player button:focus-visible,
.nest-player input:focus-visible {
  outline: 3px solid #f0d36b;
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Show/hide buttons above the cameras (pages with more than one camera). */
.camera-toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 1rem;
}

.camera-toggles-label {
  color: #58645b;
  font-size: 0.95rem;
}

.camera-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 4px 12px 4px 8px;
  border: 1px solid #b8c8b5;
  border-radius: 999px;
  background: #eef2eb;
  color: #253529;
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

.camera-toggle .toggle-icon svg { display: block; width: 20px; height: 20px; }

.camera-toggle[aria-pressed="false"] {
  background: #fff;
  color: #6b736d;
  border-style: dashed;
}

.camera-toggle:disabled { cursor: default; opacity: 0.75; }

.camera-toggle:focus-visible {
  outline: 3px solid #f0d36b;
  outline-offset: 2px;
}

[hidden] { display: none !important; }
.video-stage { width: 100%; overflow: hidden; aspect-ratio: 16 / 9; }

/* Keep the picture and controls visible in fullscreen. */
.nest-player:fullscreen {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  border-radius: 0;
  overflow: auto;
}

.nest-player:fullscreen .video-viewport {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nest-player:fullscreen .nest-video {
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.nest-player:fullscreen .custom-controls {
  flex: 0 0 auto;
}

.snapshot-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 8px;
}


/* Snapshot preview */
.snapshot-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 10px;
  border: 1px solid #d5ddd2;
  border-radius: 10px;
  background: #f6f8f4;
}
.snapshot-thumb-button {
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}
.snapshot-thumb-button img {
  display: block;
  width: 180px;
  max-width: 40vw;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 15%);
}
.snapshot-thumb-button:focus-visible {
  outline: 3px solid #f0d36b;
  outline-offset: 3px;
}
.snapshot-preview-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.95rem;
}
.snapshot-preview-info a,
.snapshot-preview-info button {
  align-self: flex-start;
  padding: 6px 10px;
  border: 1px solid #b8c8b5;
  border-radius: 6px;
  background: #fff;
  color: #253529;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
.snapshot-dialog {
  max-width: 95vw;
  max-height: 95vh;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: #000;
}
.snapshot-dialog::backdrop { background: rgb(0 0 0 / 75%); }
.snapshot-dialog img {
  display: block;
  max-width: 95vw;
  max-height: calc(95vh - 52px);
}
.snapshot-dialog form {
  display: flex;
  justify-content: flex-end;
  padding: 8px;
}
.snapshot-dialog button {
  padding: 6px 12px;
  border: 0;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}

/* Single-camera pages use a narrower layout. */
main.single-camera {
  width: min(100% - 2rem, 1100px);
}

.camera-grid.single-camera {
  grid-template-columns: 1fr;
}

.camera-error {
  padding: 1rem;
  border: 1px solid #d9a3a3;
  border-radius: 10px;
  background: #fbefef;
  color: #6b2626;
}

/* Narrow phones: keep the control bar to as few rows as possible. */
@media (max-width: 420px) {
  .player-controls input[type="range"] { width: 72px; }
  .nest-player .icon-button { width: 36px; }
}
