/* viewer.css — Visor de Asteria (Fase 4)
   Identidad: paleta D07, fuentes D08, tono D10. Mobile-first. BEM con prefijo ec-. */

@font-face { font-family: 'Plus Jakarta Sans'; font-weight: 400; font-display: swap; src: url('/fonts/plus-jakarta-sans-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-weight: 500; font-display: swap; src: url('/fonts/plus-jakarta-sans-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-weight: 700; font-display: swap; src: url('/fonts/plus-jakarta-sans-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Fraunces'; font-weight: 600; font-display: swap; src: url('/fonts/fraunces-latin-600-normal.woff2') format('woff2'); }

:root {
  --ec-color-light: #F7F8F6;
  --ec-color-ink: #171329;
  --ec-color-primary: #6F4BFF;
  --ec-color-accent: #18D9C5;
  --ec-color-glass: rgba(23, 19, 41, 0.72);
  --ec-font-ui: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ec-font-brand: 'Fraunces', Georgia, serif;
  --ec-safe-top: env(safe-area-inset-top, 0px);
  --ec-safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* "hidden" siempre gana, aunque el elemento tenga su propio display */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ec-color-ink);
  color: var(--ec-color-light);
  font-family: var(--ec-font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Cámara y capa del video ---------- */
.ec-viewer__camera,
.ec-viewer__overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ec-viewer__camera { opacity: 0; transition: opacity .6s ease; }
.ec-viewer:not([data-state="intro"]):not([data-state="message"]) .ec-viewer__camera { opacity: 1; }
.ec-viewer__overlay { pointer-events: none; }
.ec-viewer__source {
  position: fixed;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: .01;
  pointer-events: none;
}

/* ---------- Encabezado ---------- */
.ec-hud {
  position: fixed;
  top: calc(16px + var(--ec-safe-top));
  left: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  background: var(--ec-color-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity .4s ease;
}
.ec-viewer:is([data-state="scanning"], [data-state="revealing"], [data-state="locking"], [data-state="playing"]) .ec-hud { opacity: 1; }
.ec-hud__star { width: 18px; height: 18px; fill: var(--ec-color-accent); }
.ec-hud__brand { font-family: var(--ec-font-brand); font-weight: 600; font-size: 16px; letter-spacing: .01em; }

/* ---------- Mira ---------- */
.ec-finder {
  position: fixed;
  left: 50%;
  top: 46%;
  width: min(72vw, 360px);
  aspect-ratio: 3 / 4;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity .4s ease;
}
.ec-viewer[data-state="scanning"] .ec-finder { opacity: 1; }
.ec-finder span {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 3px solid var(--ec-color-accent);
  filter: drop-shadow(0 0 6px rgba(24, 217, 197, .55));
  animation: ec-breathe 2.4s ease-in-out infinite;
}
.ec-finder span:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 14px; }
.ec-finder span:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 14px; }
.ec-finder span:nth-child(3) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 14px; }
.ec-finder span:nth-child(4) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 14px; }
@keyframes ec-breathe { 50% { opacity: .45; } }

/* ---------- Estado (abajo) ---------- */
.ec-status {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--ec-safe-bottom));
  transform: translate(-50%, 8px);
  width: min(calc(100vw - 32px), 420px);
  padding: 14px 18px;
  border-radius: 20px;
  background: var(--ec-color-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  text-align: center;
  opacity: 0;
  transition: opacity .35s ease, transform .35s ease;
}
.ec-viewer:is([data-state="scanning"], [data-state="revealing"], [data-state="locking"], [data-state="starting"]) .ec-status {
  opacity: 1;
  transform: translate(-50%, 0);
}
.ec-status__title { margin: 0; font-weight: 700; font-size: 17px; line-height: 1.3; }
.ec-status__hint { margin: 4px 0 0; font-size: 14px; line-height: 1.4; color: rgba(247, 248, 246, .78); }
.ec-status__bar {
  height: 6px;
  margin-top: 12px;
  border-radius: 99px;
  background: rgba(247, 248, 246, .16);
  overflow: hidden;
}
.ec-status__bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ec-color-primary), var(--ec-color-accent));
  transition: width .2s ease;
}

/* ---------- Título del recuerdo ---------- */
.ec-memory-title {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--ec-safe-bottom));
  transform: translate(-50%, 6px);
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ec-color-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-family: var(--ec-font-brand);
  font-weight: 600;
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transition: opacity .5s ease, transform .5s ease;
}
.ec-memory-title::before { content: '✦ '; color: var(--ec-color-accent); }
.ec-memory-title.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Botones ---------- */
.ec-button {
  appearance: none;
  border: 0;
  min-height: 52px;
  padding: 14px 28px;
  border-radius: 999px;
  background: var(--ec-color-primary);
  color: var(--ec-color-light);
  font: 700 17px/1.2 var(--ec-font-ui);
  box-shadow: 0 10px 30px rgba(111, 75, 255, .4);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.ec-button:active { transform: scale(.97); }
.ec-button:focus-visible,
.ec-sound:focus-visible { outline: 3px solid var(--ec-color-accent); outline-offset: 3px; }

.ec-sound {
  position: fixed;
  right: 16px;
  top: calc(16px + var(--ec-safe-top));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--ec-color-accent);
  color: var(--ec-color-ink);
  font: 700 15px/1 var(--ec-font-ui);
  cursor: pointer;
}
.ec-sound svg { width: 20px; height: 20px; fill: currentColor; }

.ec-toast {
  position: fixed;
  left: 50%;
  top: calc(72px + var(--ec-safe-top));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--ec-color-light);
  color: var(--ec-color-ink);
  font-weight: 500;
  font-size: 14px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}

/* ---------- Pantallas completas ---------- */
.ec-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(32px + var(--ec-safe-top)) 24px calc(32px + var(--ec-safe-bottom));
  text-align: center;
  background: var(--ec-color-ink);
  overflow: hidden;
  transition: opacity .5s ease, visibility .5s;
}
.ec-viewer:not([data-state="intro"]) .ec-screen--intro { opacity: 0; visibility: hidden; }
.ec-screen[hidden] { display: none; }
.ec-screen__glow {
  position: absolute;
  width: 140vmax;
  height: 140vmax;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(circle at 50% 50%, rgba(111, 75, 255, .28), transparent 38%),
    radial-gradient(circle at 62% 42%, rgba(24, 217, 197, .16), transparent 30%);
  pointer-events: none;
}
.ec-screen__logo { position: relative; width: 96px; height: 96px; margin-bottom: 8px; animation: ec-float 5s ease-in-out infinite; }
@keyframes ec-float { 50% { transform: translateY(-6px); } }
.ec-screen__brand {
  position: relative;
  margin: 0;
  font-family: var(--ec-font-brand);
  font-weight: 600;
  font-size: clamp(44px, 13vw, 64px);
  line-height: 1;
  letter-spacing: -.01em;
}
.ec-screen__tagline {
  position: relative;
  margin: 10px 0 0;
  color: var(--ec-color-accent);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.ec-screen__heading { margin: 0; font-family: var(--ec-font-brand); font-weight: 600; font-size: 28px; line-height: 1.2; }
.ec-screen__text {
  position: relative;
  max-width: 340px;
  margin: 20px 0 28px;
  font-size: 17px;
  line-height: 1.5;
  color: rgba(247, 248, 246, .88);
}
.ec-screen__note {
  position: relative;
  max-width: 300px;
  margin: 20px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(247, 248, 246, .62);
}

@media (min-width: 768px) {
  .ec-status__title { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
}

/* ---------- Modo de diagnóstico (?debug; solo para calibrar) ---------- */
.ec-debug {
  position: fixed;
  top: calc(var(--ec-safe-top) + 68px);
  left: 16px;
  right: 16px;
  max-width: 420px;
  z-index: 50;
  font-size: 12px;
  line-height: 1.4;
}
.ec-debug__toggle,
.ec-debug button {
  font: inherit;
  color: var(--ec-color-light);
  background: var(--ec-color-glass);
  border: 1px solid rgba(247, 248, 246, 0.25);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
}
.ec-debug button.is-active { background: var(--ec-color-primary); border-color: var(--ec-color-primary); }
.ec-debug__body {
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--ec-color-glass);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.ec-debug__info { margin: 0 0 6px; color: var(--ec-color-accent); font-weight: 700; }
.ec-debug__label { margin: 8px 0 4px; opacity: .8; }
.ec-debug__buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.ec-debug__row { display: grid; grid-template-columns: 9.5em 1fr; align-items: center; gap: 8px; margin-top: 8px; }
.ec-debug__row input { width: 100%; accent-color: var(--ec-color-accent); }
.ec-debug__values { margin: 8px 0; font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-word; }
