/* ============================================================
   ios-like.css - iOS-style Camera Viewfinder & Controls
   ============================================================ */

/* ---- Top Bar ---- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 8px) 20px 10px;
  flex-shrink: 0;
  z-index: 10;
}

.top-bar-label {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
}

.live-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: var(--danger);
  background: rgba(255, 69, 58, 0.15);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255,69,58,0.3);
  display: none; /* shown when camera is active */
}

.live-badge.visible { display: inline-block; }

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  transition: opacity 0.15s;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:active { opacity: 0.6; }

/* ---- Viewport Wrapper ---- */
.viewport-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  min-height: 0;
}

/* ---- Viewport (viewfinder) ---- */
.viewport {
  position: relative;
  width: min(calc(100vw - 0px), calc((100dvh - 250px) * 3/4));
  aspect-ratio: 3 / 4;
  border-radius: 0;
  overflow: hidden;
  background: #111;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.08),
    0 20px 60px rgba(0,0,0,0.7),
    inset 0 0 0 1px rgba(255,255,255,0.06);
  touch-action: none;
  cursor: pointer;
}

/* Canvas fills viewport exactly */
#mainCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  will-change: transform;
}

/* ---- Secret Status Dot ---- */
.status-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 50;
  transition: background-color 0.4s ease, box-shadow 0.4s ease;
}

.status-idle {
  background: #FF3B30;
  box-shadow: 0 0 4px rgba(255,59,48,0.6);
}

.status-warning {
  background: #FFD60A;
  box-shadow: 0 0 6px rgba(255,214,10,0.8);
  animation: dotPulse 0.5s ease-in-out infinite alternate;
}

.status-active {
  background: #30D158;
  box-shadow: 0 0 8px rgba(48,209,88,0.9);
  animation: dotPulse 0.3s ease-in-out infinite alternate;
}

@keyframes dotPulse {
  from { opacity: 0.7; transform: scale(0.9); }
  to   { opacity: 1;   transform: scale(1.15); }
}

/* ---- Gesture hint ---- */
.gesture-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.55);
  color: rgba(255,255,255,0.75);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 20px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 40;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeHint 1s ease 4s forwards;
}

@keyframes fadeHint {
  to { opacity: 0; }
}

/* ---- Focus ring on tap ---- */
.viewport::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  box-shadow: inset 0 0 0 2px rgba(255,214,10,0.6);
}

.viewport.triggered::after {
  opacity: 1;
}

/* ---- Corner brackets iOS focus style ---- */
.viewport-bracket {
  position: absolute;
  width: 28px;
  height: 28px;
  pointer-events: none;
  z-index: 30;
  opacity: 0;
  transition: opacity 0.3s;
}

/* ---- Loading placeholder ---- */
.camera-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 20;
  background: #0a0a0a;
}

.camera-loading .spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.camera-loading p {
  color: var(--text-secondary);
  font-size: 14px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Countdown overlay (dentro del viewport) ---- */
.countdown-overlay {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 44px;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 2px 16px rgba(0,0,0,0.8);
  pointer-events: none;
  z-index: 40;
  opacity: 0;
  transition: opacity 0.3s;
  font-variant-numeric: tabular-nums;
}

.countdown-overlay.visible {
  opacity: 1;
}

/* ---- Bottom Controls ---- */
.bottom-controls {
  flex-shrink: 0;
  padding: 14px 20px calc(var(--safe-bottom) + 14px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

/* Shutter Button */
.shutter-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 4px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
  flex-shrink: 0;
}

.shutter-btn:active { transform: scale(0.94); }

.shutter-inner {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #fff;
  transition: background 0.15s, transform 0.1s;
}

.shutter-btn:active .shutter-inner {
  background: rgba(255,255,255,0.8);
  transform: scale(0.95);
}

/* Side buttons */
.side-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  transition: background 0.15s;
}

.side-btn:active { background: rgba(255,255,255,0.22); }
.side-btn svg { width: 22px; height: 22px; }

.gallery-thumb {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
  border: 2px solid rgba(255,255,255,0.3);
}

/* Mode Selector */
.mode-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.mode-item {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.4);
  transition: color 0.2s;
  cursor: default;
}

.mode-item.mode-active {
  color: var(--accent);
}

/* ---- Pinch zoom visual ring (aparece brevemente) ---- */
.zoom-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 16px;
  pointer-events: none;
  z-index: 45;
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.zoom-indicator.visible {
  opacity: 1;
}

/* Portrait adjustments for very small screens */
@media (max-height: 700px) {
  .top-bar { padding-top: calc(var(--safe-top) + 2px); }
  .shutter-btn { width: 66px; height: 66px; }
  .shutter-inner { width: 52px; height: 52px; }
  .bottom-controls { padding-top: 8px; gap: 8px; }
  .mode-selector { gap: 18px; }
}
