/* ─── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #050a14;
  --bg-card:   #0d1526;
  --bg-card2:  #111c35;
  --accent:    #6366f1;
  --accent2:   #8b5cf6;
  --glow:      rgba(99,102,241,.35);
  --text:      #e2e8f0;
  --muted:     #64748b;
  --border:    rgba(99,102,241,.2);
  --video-c:   #7c3aed;
  --foto-c:    #0ea5e9;
  --texto-c:   #10b981;
  --danger:    #ef4444;
  --radius:    12px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
}

/* ─── Globe Page ────────────────────────────────────────── */
#globe-container {
  position: fixed;
  inset: 0;
  z-index: 0;
}
#globe-container::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 55vmin; height: 55vmin;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99,102,241,.10) 0%, rgba(139,92,246,.06) 40%, transparent 70%);
  pointer-events: none;
  z-index: -1;
}
#globe-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ─── HUD ───────────────────────────────────────────────── */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: linear-gradient(180deg, rgba(5,10,20,.9) 0%, transparent 100%);
  backdrop-filter: blur(4px);
}

#hud-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: .06em;
  background: linear-gradient(90deg, #a5b4fc, #c4b5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Admin link — bottom right */
#admin-link {
  position: fixed; bottom: 14px; right: 18px; z-index: 20;
  color: var(--accent); text-decoration: none; font-size: .82rem; font-weight: 600;
  opacity: .7; transition: opacity .2s;
}
#admin-link:hover { opacity: 1; }

/* Sound permission prompt */
#sound-prompt {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5,10,20,.85); backdrop-filter: blur(8px);
  transition: opacity .3s;
}
#sound-prompt.hidden { opacity: 0; pointer-events: none; }
.sound-prompt-box {
  text-align: center; padding: 32px 28px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
  max-width: 320px; width: 90%;
}
.sound-prompt-icon { font-size: 2.5rem; margin-bottom: 12px; }
.sound-prompt-box p { font-size: 1rem; font-weight: 600; margin-bottom: 20px; color: var(--text); }
.sound-prompt-btns { display: flex; flex-direction: column; gap: 10px; }
.sound-prompt-btns button {
  padding: 12px; border: none; border-radius: 10px;
  font-size: .95rem; font-weight: 700; cursor: pointer; font-family: inherit;
  background: var(--accent); color: #fff; transition: background .2s;
}
.sound-prompt-btns button:hover { background: #5558e0; }
.sound-prompt-btns button.secondary {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
}
.sound-prompt-btns button.secondary:hover { border-color: var(--accent); color: var(--text); }


#hud-counter {
  font-size: .8rem;
  color: var(--muted);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
}

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; cursor: pointer; border-radius: 8px;
  font-size: .9rem; font-weight: 600;
  transition: all .2s;
  padding: 8px 18px;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 18px var(--glow);
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 6px 12px; font-size: .82rem; }

/* ─── Tooltip hint ──────────────────────────────────────── */
#hint {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  color: var(--muted);
  font-size: .8rem;
  letter-spacing: .04em;
  pointer-events: none;
  animation: fadeHint 4s ease forwards;
}
@keyframes fadeHint {
  0%   { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ─── Modals ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
}
.modal-overlay.open {
  opacity: 1; pointer-events: all;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: min(540px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 0 60px rgba(99,102,241,.15);
  animation: slideUp .3s ease;
}
@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 1.5rem; line-height: 1;
  transition: color .2s;
}
.modal-close:hover { color: var(--text); }

#modal-add .modal-close {
  top: 13px;
  right: 14px;
  width: auto;
  height: auto;
  border-radius: 0;
  border: none;
  background: none;
  color: #ffffff;
  display: block;
  font-size: 1.9rem;
  line-height: 1;
}
#modal-add .modal-close:hover {
  color: #ffffff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
}

#modal-add .cam-switch-icon {
  position: absolute;
  top: 13px;
  right: 62px;
  width: 33px;
  height: 33px;
  border-radius: 50%;
  border: 1px solid rgba(82, 255, 146, 0.95);
  background: rgba(8, 70, 28, 0.9);
  color: #9dffbe;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: all .2s ease;
}
#modal-add .cam-switch-icon:hover {
  border-color: rgba(135, 255, 178, 1);
  box-shadow: 0 0 14px rgba(76, 255, 146, 0.55);
}
#modal-add .cam-switch-icon.rear {
  color: #d7ffe5;
  border-color: rgba(170, 255, 200, 1);
  box-shadow: 0 0 15px rgba(96, 255, 164, 0.62);
}

#modal-add .orientation-switch-icon {
  position: absolute;
  top: 13px;
  right: 110px;
  width: 33px;
  height: 33px;
  border-radius: 50%;
  border: 1px solid rgba(82, 255, 146, 0.95);
  background: rgba(8, 70, 28, 0.9);
  color: #9dffbe;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.02rem;
  line-height: 1;
  transition: all .2s ease;
}
#modal-add .orientation-switch-icon:hover {
  border-color: rgba(135, 255, 178, 1);
  box-shadow: 0 0 14px rgba(76, 255, 146, 0.55);
}
#modal-add .orientation-switch-icon .ori-glyph {
  display: inline-block;
  transform: rotate(0deg);
  transition: transform .2s ease;
}
#modal-add .orientation-switch-icon.landscape .ori-glyph {
  transform: rotate(90deg);
}

/* ─── Projector Canvas ──────────────────────────────────── */
#projector-canvas {
  position: fixed; inset: 0; z-index: 95;
  pointer-events: none;
  display: none;
}

/* ─── View Modal — projeção pura sem caixa ──────────────── */
#modal-view {
  background: rgba(0,0,0,.3);
  backdrop-filter: blur(1px);
}
#modal-view .modal-box {
  max-width: 680px;
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  animation: projectorOn .6s ease;
  overflow: visible;
}
@keyframes projectorOn {
  0%   { opacity: 0; transform: scale(.85); filter: brightness(4) blur(12px); }
  30%  { opacity: 1; filter: brightness(2) blur(4px); }
  60%  { filter: brightness(1.3) blur(1px); }
  100% { transform: scale(1); filter: brightness(1) blur(0); }
}
#modal-view .modal-close {
  color: rgba(255,255,255,.5);
  font-size: 2.2rem;
  top: -40px; right: 0;
  z-index: 10;
  text-shadow: 0 0 20px rgba(0,0,0,.8);
  filter: drop-shadow(0 0 6px rgba(255,255,255,.3));
}
#modal-view .modal-close:hover { color: #fff; }

/* Nome do autor — flutuando embaixo da projeção */
.dep-header {
  display: flex; align-items: center; gap: 12px;
  margin-top: 16px;
  padding: 0;
  border: none;
  justify-content: center;
}
.dep-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .85rem; flex-shrink: 0;
  color: #fff;
  box-shadow: 0 0 18px rgba(255,255,255,.2);
}
.dep-name {
  font-weight: 600; font-size: .95rem;
  color: rgba(255,255,255,.7);
  text-shadow: 0 0 20px rgba(255,255,255,.3);
}
.dep-meta { font-size: .72rem; color: rgba(255,255,255,.3); margin-top: 2px; }
.dep-badge {
  font-size: .65rem; font-weight: 700; letter-spacing: .06em;
  padding: 2px 8px; border-radius: 20px; text-transform: uppercase;
}
.badge-video  { background: rgba(124,58,237,.3); color: #c4b5fd; }
.badge-foto   { background: rgba(14,165,233,.3);  color: #7dd3fc; }
.badge-texto  { background: rgba(16,185,129,.3);  color: #6ee7b7; }

/* ─── Conteúdo projetado ────────────────────────────────── */
.dep-content { margin-top: 0; }

/* Foto/vídeo — retrato vertical, projeção flutuante */
.dep-content img,
.dep-content video {
  display: block;
  margin: 0 auto;
  max-height: 70vh;
  max-width: 100%;
  width: auto;
  border-radius: 10px;
  box-shadow:
    0 0 40px rgba(200,210,255,.25),
    0 0 80px rgba(150,160,255,.1),
    0 0 160px rgba(100,110,255,.06);
}

/* ─── Texto — pergaminho teatral ────────────────────────── */
.dep-content .texto-scroll {
  position: relative;
  background:
    linear-gradient(135deg, #f5f0e8 0%, #ede4d3 25%, #f8f3eb 50%, #ebe2d0 75%, #f5f0e8 100%);
  color: #2c1810;
  padding: 50px 44px 44px;
  min-height: 200px;
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 1.15rem;
  line-height: 1.9;
  text-align: center;
  box-shadow:
    0 0 50px rgba(200,180,140,.3),
    0 0 100px rgba(180,160,120,.15),
    0 0 160px rgba(100,110,255,.06),
    inset 0 0 60px rgba(180,160,120,.15);
  border: none;
  border-radius: 12px;
  /* Textura de papel velho */
  background-image:
    linear-gradient(135deg, #f5f0e8 0%, #ede4d3 25%, #f8f3eb 50%, #ebe2d0 75%, #f5f0e8 100%),
    url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)' opacity='.04'/%3E%3C/svg%3E");
}
.dep-content .texto-scroll::before {
  content: '\201C';
  position: absolute;
  top: 8px; left: 20px;
  font-size: 4.5rem;
  color: rgba(59,130,246,.35);
  font-family: 'Georgia', serif;
  line-height: 1;
}
.dep-content .texto-scroll::after {
  content: '\201D';
  position: absolute;
  bottom: -10px; right: 20px;
  font-size: 4.5rem;
  color: rgba(59,130,246,.35);
  font-family: 'Georgia', serif;
  line-height: 1;
}
.dep-content .texto-scroll p {
  color: #1e3a6e;
  font-style: italic;
  margin: 0;
  position: relative;
  z-index: 1;
}
.dep-content .texto-scroll .scroll-author {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid rgba(140,100,60,.2);
  font-style: normal;
  font-size: .9rem;
  font-weight: 600;
  color: rgba(80,50,20,.6);
  letter-spacing: .05em;
}
.dep-content .texto-scroll .scroll-date {
  font-size: .75rem;
  color: rgba(80,50,20,.35);
  margin-top: 4px;
  font-style: normal;
}

/* Ornamentos do pergaminho */
.dep-content .texto-scroll .ornament {
  display: block;
  text-align: center;
  color: rgba(236,147,180,.5);
  font-size: 1.2rem;
  letter-spacing: .4em;
  margin-bottom: 16px;
  user-select: none;
}
.dep-content .texto-scroll .ornament-bottom {
  margin-top: 16px;
  margin-bottom: 0;
}

/* ─── Add Modal ─────────────────────────────────────────── */
#modal-add .modal-box { max-width: 560px; }
#modal-add h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 20px;
  padding-right: 150px;
}

/* Tabs */
.tabs {
  display: flex; gap: 6px;
  margin-bottom: 22px;
  background: var(--bg); padding: 4px;
  border-radius: 10px;
}
.tab-btn {
  flex: 1; padding: 9px; border: 1px solid transparent; border-radius: 8px;
  font-weight: 600; font-size: .88rem; cursor: pointer;
  background: transparent; color: #eaf2ff;
  transition: all .2s;
}
.tab-btn:hover { color: #ffffff; border-color: rgba(82, 255, 146, 0.45); }
.tab-btn.active {
  background: rgba(8, 70, 28, 0.25);
  color: #ffffff;
  border-color: rgba(82, 255, 146, 0.95);
  box-shadow: 0 0 14px rgba(76, 255, 146, 0.45);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Camera / preview — vertical para selfie */
.camera-wrap {
  position: relative;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 9/14;
  max-height: 55vh;
  margin: 0 auto 14px;
  max-width: 320px;
}
.camera-wrap.capture-frame.landscape {
  aspect-ratio: 16 / 9;
  max-width: 480px;
}
.camera-wrap video {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
.camera-wrap video.cam-mirror {
  transform: scaleX(-1) scale(var(--cam-scale, 1));
  transform-origin: center center;
}
.camera-wrap video#foto-preview { object-fit: cover; }
.camera-wrap video#vid-preview { object-fit: cover; background: #000; }
.camera-wrap img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
.camera-wrap img#foto-result { object-fit: cover; background: #000; }
/* Não espelha o preview de resultado (já gravado) */
.camera-wrap video#vid-result { transform: none; object-fit: contain; background: #000; }
.camera-wrap video#foto-preview-playback { transform: none; }

/* Countdown overlay */
#countdown-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.45);
  font-size: 5rem; font-weight: 900;
  color: #fff;
  pointer-events: none;
  transition: color .3s;
}
#countdown-overlay.urgent { color: var(--danger); }
#countdown-overlay.hidden { display: none; }

/* Progress bar inside camera */
#rec-progress {
  position: absolute; bottom: 0; left: 0;
  height: 4px; background: var(--danger);
  width: 100%;
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 1s linear;
}

.rec-indicator {
  position: absolute; top: 10px; left: 10px;
  display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,.6); padding: 4px 10px; border-radius: 20px;
  font-size: .78rem; font-weight: 600; color: #fff;
}
.rec-dot {
  width: 8px; height: 8px; background: var(--danger); border-radius: 50%;
  animation: blink 1s infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.cam-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Text form */
#texto-form textarea {
  width: 100%; height: 130px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; color: var(--text);
  font-size: .95rem; resize: none;
  transition: border-color .2s;
}
#texto-form textarea:focus { outline: none; border-color: var(--accent); }
#texto-count { font-size: .78rem; color: var(--muted); float: right; }

/* ─── Status toast ──────────────────────────────────────── */
#toast {
  position: fixed; bottom: 30px; right: 24px; z-index: 200;
  padding: 12px 22px; border-radius: 8px;
  font-weight: 600; font-size: .9rem;
  opacity: 0; transform: translateY(10px);
  transition: all .35s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.success { background: #065f46; color: #6ee7b7; border: 1px solid #059669; }
#toast.error   { background: #7f1d1d; color: #fca5a5; border: 1px solid #dc2626; }

/* ─── Login Page ────────────────────────────────────────── */
body.page-login {
  overflow: auto;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}
.login-wrap {
  width: min(420px, 94vw);
  padding: 40px 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 0 80px rgba(99,102,241,.12);
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo h1 {
  font-size: 2rem; font-weight: 900; letter-spacing: .12em;
  background: linear-gradient(90deg,#a5b4fc,#c4b5fd);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.login-logo p { color: var(--muted); font-size: .88rem; margin-top: 6px; }

.form-tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.form-tab {
  flex: 1; padding: 10px; text-align: center;
  background: none; border: none; color: var(--muted);
  font-size: .92rem; font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: all .2s;
}
.form-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input {
  width: 100%; padding: 10px 14px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: .95rem;
  transition: border-color .2s;
}
.field input:focus { outline: none; border-color: var(--accent); }

.field-error { color: var(--danger); font-size: .8rem; margin-top: 4px; }

#login-error {
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3);
  color: #fca5a5; padding: 10px 14px; border-radius: 8px;
  font-size: .85rem; margin-bottom: 14px; display: none;
}

.login-wrap .btn-primary { width: 100%; justify-content: center; padding: 12px; font-size: 1rem; margin-top: 4px; }

/* ─── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ═══════════════════════════════════════════════════════════
   MOBILE — responsividade para selfie vertical
═══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  /* HUD compacto — mobile */
  #hud {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  #hud-title { font-size: 1rem; }
  #hud-right .btn-sm { padding: 5px 10px; font-size: .75rem; }
  /* Testimonial button centered in mobile */
  #hud-right .btn-primary {
    position: fixed;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 21;
  }

  /* Modal — ocupa mais tela */
  .modal-box {
    width: 96vw !important;
    padding: 18px !important;
    max-height: 94vh;
  }
  #modal-add .modal-box { max-width: 96vw; }

  /* Câmera maior no mobile */
  .camera-wrap {
    max-width: 100%;
    max-height: 50vh;
    aspect-ratio: 9/14;
  }
  .camera-wrap.capture-frame.landscape {
    aspect-ratio: 16/9;
    max-height: 40vh;
  }

  /* Projeção — vídeo/foto vertical */
  #modal-view .modal-box { max-width: 96vw; }
  .dep-content img,
  .dep-content video {
    max-height: 60vh;
  }
  .dep-header { gap: 10px; }
  .dep-avatar { width: 32px; height: 32px; font-size: .75rem; }
  .dep-name { font-size: .85rem; }
  #modal-view .modal-close { top: -32px; right: 4px; font-size: 1.6rem; }

  /* Pergaminho menor */
  .dep-content .texto-scroll {
    padding: 36px 24px 30px;
    font-size: 1rem;
    line-height: 1.7;
  }
  .dep-content .texto-scroll::before { font-size: 3rem; top: 4px; left: 10px; }
  .dep-content .texto-scroll::after  { font-size: 3rem; bottom: -8px; right: 10px; }

  /* Tabs e botões */
  .tabs { margin-bottom: 14px; }
  .tab-btn { padding: 7px; font-size: .8rem; }
  .cam-actions { justify-content: center; }

  /* Toast */
  #toast { bottom: 16px; right: 12px; left: 12px; text-align: center; font-size: .82rem; }

  /* Hint */
  #hint { font-size: .7rem; bottom: 12px; }
}

/* Extra small phones */
@media (max-width: 380px) {
  #hud-title { font-size: .85rem; letter-spacing: .06em; }
  #hud-counter { display: none; }
  .camera-wrap { aspect-ratio: 9/16; max-height: 45vh; }
  .camera-wrap.capture-frame.landscape { aspect-ratio: 16/9; max-height: 36vh; }
  .modal-box { padding: 14px !important; }
}
