/* Pesca Cam — estilos para iPhone / Safari */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#preview {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #111;
  z-index: 0;
}

#ui {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

#ui .panel,
#ui button {
  pointer-events: auto;
}

.hidden {
  display: none !important;
}

#start-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: calc(24px + env(safe-area-inset-top));
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-align: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#start-screen h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(145deg, #ff3b30 0%, #c62828 100%);
  box-shadow: 0 4px 16px rgba(255, 59, 48, 0.35);
  position: relative;
}

.brand-icon::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: #007aff;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.25);
}

.subtitle {
  color: #aaa;
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.tagline {
  color: #777;
  font-size: 0.82rem;
  margin-bottom: 24px;
  max-width: 320px;
}

.setup-box {
  width: min(92vw, 400px);
  text-align: left;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 20px;
}

.setup-box h2 {
  font-size: 0.9rem;
  margin-bottom: 10px;
  color: #fff;
}

.setup-steps {
  padding-left: 1.2rem;
  font-size: 0.8rem;
  color: #ccc;
  line-height: 1.55;
}

.setup-steps li {
  margin-bottom: 6px;
}

.setup-note {
  margin-top: 10px;
  font-size: 0.75rem;
  color: #888;
  line-height: 1.4;
}

.cert-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.cert-box h3 {
  font-size: 0.85rem;
  color: #ff9500;
  margin-bottom: 6px;
}

.cert-lead {
  font-size: 0.78rem;
  color: #ccc;
  margin-bottom: 8px;
  line-height: 1.4;
}

.cert-steps {
  padding-left: 1.2rem;
  font-size: 0.78rem;
  color: #ccc;
  line-height: 1.55;
}

.cert-steps li {
  margin-bottom: 5px;
}

.link-cert {
  color: #007aff;
  font-weight: 600;
  text-decoration: underline;
}

.env-warning {
  width: min(92vw, 400px);
  background: rgba(255, 149, 0, 0.15);
  border: 1px solid rgba(255, 149, 0, 0.45);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  text-align: left;
  font-size: 0.8rem;
  color: #ffb340;
  line-height: 1.45;
}

.env-warning p {
  margin-bottom: 4px;
}

.env-warning p:last-child {
  margin-bottom: 0;
}

.setup-box code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.78rem;
  word-break: break-all;
}

.buffer-bar {
  width: min(92vw, 360px);
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
}

.buffer-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff3b30, #ff9500);
  border-radius: 2px;
  transition: width 0.35s ease;
}

.btn {
  border: none;
  border-radius: 14px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.rec-dot.saving {
  background: #ff9500;
  animation: pulse 0.8s ease-in-out infinite;
}

.btn-save.recording {
  background: #ff9500;
  box-shadow: 0 4px 24px rgba(255, 149, 0, 0.45);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: #007aff;
  color: #fff;
  padding: 16px 28px;
  min-width: 240px;
}

.btn-secondary {
  background: #34c759;
  color: #fff;
  padding: 14px 24px;
  min-width: 120px;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  padding: 14px 24px;
}

a.btn-ghost,
a.btn-secondary,
a.btn-primary {
  display: inline-block;
  text-align: center;
  text-decoration: none;
}

#camera-screen {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 16px 20px 28px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, transparent 100%);
}

/* Visor estilo action cam (GoPro) */
.cam-hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 15;
  pointer-events: none;
  padding:
    calc(10px + env(safe-area-inset-top))
    calc(14px + env(safe-area-inset-right))
    10px
    calc(14px + env(safe-area-inset-left));
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.35) 70%, transparent 100%);
  font-variant-numeric: tabular-nums;
}

.hud-gpad-icon,
.hud-bt-icon {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top));
  line-height: 0;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.95));
  opacity: 0.88;
}

.hud-bt-icon {
  right: calc(10px + env(safe-area-inset-right));
  color: rgba(90, 200, 250, 0.92);
}

.hud-gpad-icon {
  right: calc(36px + env(safe-area-inset-right));
  color: rgba(191, 148, 255, 0.95);
}

.hud-bt-icon.pulse {
  animation: bt-pulse 0.45s ease-out;
}

.hud-gpad-icon.pulse {
  animation: gpad-pulse 0.45s ease-out;
}

@keyframes bt-pulse {
  0% { transform: scale(1); opacity: 0.88; color: rgba(90, 200, 250, 0.92); }
  40% { transform: scale(1.25); opacity: 1; color: #30d158; }
  100% { transform: scale(1); opacity: 0.88; color: rgba(90, 200, 250, 0.92); }
}

@keyframes gpad-pulse {
  0% { transform: scale(1); opacity: 0.88; color: rgba(191, 148, 255, 0.95); }
  40% { transform: scale(1.25); opacity: 1; color: #30d158; }
  100% { transform: scale(1); opacity: 0.88; color: rgba(191, 148, 255, 0.95); }
}

.hud-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: start;
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  justify-self: center;
}

.hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  justify-self: end;
}

.hud-rec-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #666;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.hud-rec-dot.live {
  background: #ff3b30;
  animation: pulse 1s ease-in-out infinite;
}

.hud-rec-dot.recording {
  background: #ff3b30;
  animation: pulse 0.55s ease-in-out infinite;
}

.hud-rec-dot.paused {
  background: #ff9500;
  animation: none;
}

.hud-mode {
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
}

.hud-label {
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.65);
  text-transform: uppercase;
}

.hud-time {
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.95);
  line-height: 1.1;
}

.hud-time.hud-clip {
  font-size: 1.55rem;
  color: #ff453a;
}

.hud-sub {
  margin-top: 6px;
  text-align: center;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.04em;
}

#status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #eee;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #666;
  flex-shrink: 0;
}

.rec-dot.active {
  background: #ff3b30;
  animation: pulse 1.2s ease-in-out infinite;
}

.rec-dot.paused {
  background: #ff9500;
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.btn-save {
  width: min(92vw, 360px);
  padding: 22px 24px;
  font-size: 1.5rem;
  letter-spacing: 0.08em;
  background: #ff3b30;
  color: #fff;
  box-shadow: 0 4px 24px rgba(255, 59, 48, 0.45);
}

.btn-save:not(:disabled):active {
  background: #e0352b;
}

.instructions {
  margin-top: 12px;
  max-width: 420px;
  text-align: left;
  font-size: 0.82rem;
  color: #ccc;
  line-height: 1.5;
}

.instructions summary {
  cursor: pointer;
  color: #007aff;
  font-weight: 600;
  margin-bottom: 8px;
}

.instructions h3 {
  font-size: 0.85rem;
  margin: 14px 0 6px;
  color: #fff;
}

.instructions ol,
.instructions ul {
  padding-left: 1.2rem;
}

.instructions li {
  margin-bottom: 4px;
}

.instructions code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.78rem;
  word-break: break-all;
}

/* Painel do vídeo salvo */
.save-panel {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

.save-panel-inner {
  width: min(92vw, 400px);
  text-align: center;
}

.save-panel-inner h2 {
  font-size: 1.25rem;
  margin-bottom: 4px;
}

.save-hint {
  color: #aaa;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

#saved-preview {
  width: 100%;
  border-radius: 12px;
  background: #111;
  margin-bottom: 16px;
}

.save-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.toast {
  position: fixed;
  bottom: calc(28px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(40, 40, 40, 0.92);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: opacity 0.3s ease;
}

.toast.hidden {
  opacity: 0;
  pointer-events: none;
}
