/* Shared layout for the live camera demos: full-screen canvas, nav link, error screen, the bottom
   camera bar (built by camera-kit.js), and the dark controls panel. Pages add only their own bits. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #000; }

#nav {
  position: fixed;
  top: 16px;
  left: 20px;
  z-index: 100;
  color: rgba(255,255,255,0.55);
  font-family: system-ui, sans-serif;
  font-size: 0.82rem;
  text-decoration: none;
}
#nav:hover { color: rgba(255,255,255,0.9); }

canvas.stage {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: block;
}

/* Buttons and the camera surface only (panel text stays selectable): a long press must not select
   text or open the iOS callout, since press-and-hold records video; double-tap must not zoom. */
#camBar, #controls button, canvas.stage {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#btnSnap.recording { background: #e5312b; border-color: #fff; }
#recTime {
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(229,49,43,0.9);
  color: #fff;
  font: 600 0.8rem system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
#recTime[hidden] { display: none; }

#error {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
  color: #888;
  font-family: system-ui, sans-serif;
  font-size: 1rem;
  text-align: center;
  padding: 2rem;
  background: #000;
  line-height: 1.5;
}
#error.visible { display: flex; }

/* Camera bar: zoom over lens chips over [extras torch] [shutter] [flip], like a camera app. */
#camBar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
#camBar > * { pointer-events: auto; }
#zoomWrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,0.5);
  color: #ddd;
  font: 600 0.75rem system-ui, sans-serif;
}
#zoomWrap[hidden] { display: none; }
#zoomWrap input { width: 140px; accent-color: rgba(255,255,255,0.8); }
#lenses {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
#lenses[hidden] { display: none; }
.lens-btn {
  min-width: 40px;
  height: 32px;
  padding: 0 10px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #ddd;
  font: 600 0.75rem system-ui, sans-serif;
  cursor: pointer;
}
.lens-btn.active { background: rgba(255,255,255,0.9); color: #000; }
#shutterRow {
  display: grid;
  grid-template-columns: 1fr 64px 1fr;
  gap: 24px;
  align-items: center;
  width: 100%;
  max-width: 360px;
}
.side { display: flex; gap: 12px; }
.side.left { justify-self: end; }
.side.right { justify-self: start; }
.round-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.round-btn[hidden] { display: none; }
.round-btn.active { background: rgba(255,214,10,0.85); color: #000; }
#btnSnap {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: rgba(255,255,255,0.3);
  cursor: pointer;
}
#btnSnap:active { background: #fff; }

/* Controls panel, sits above the camera bar. */
#controls {
  position: fixed;
  bottom: 140px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 16px 20px;
  color: #e0e0e0;
  font-family: system-ui, sans-serif;
  font-size: 0.8rem;
  min-width: 280px;
  max-width: 380px;
  width: calc(100vw - 40px);
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}
#controls.hidden { display: none; }
#controls [hidden] { display: none !important; }

.toggle-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.toggle-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  background: transparent;
  color: #999;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.toggle-btn.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-color: rgba(255,255,255,0.4);
}

.slider-row { margin-bottom: 10px; }
.slider-row label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  color: #bbb;
}
.slider-row .val {
  color: #fff;
  font-variant-numeric: tabular-nums;
  min-width: 2.5em;
  text-align: right;
}
.slider-row .desc {
  color: #555;
  font-size: 0.72rem;
}
.slider-row input[type=range] {
  width: 100%;
  accent-color: rgba(255,255,255,0.6);
  cursor: pointer;
}
.presets { margin-top: 4px; margin-bottom: 12px; }
.hint {
  margin-top: 12px;
  color: #555;
  font-size: 0.72rem;
  text-align: center;
  line-height: 1.4;
}

@media (orientation: landscape) and (max-height: 500px) {
  #controls {
    bottom: auto;
    top: 50%;
    right: 12px;
    left: auto;
    transform: translateY(-50%);
    width: 200px;
    min-width: 0;
    max-width: none;
    padding: 10px 12px;
    font-size: 0.75rem;
    max-height: calc(100vh - 24px);
  }
  #camBar { bottom: 8px; }
  .toggle-row { margin-bottom: 8px; }
  .toggle-btn { padding: 6px; }
  .slider-row { margin-bottom: 5px; }
  .slider-row .desc { display: none; }
  .hint { display: none; }
}
