/* ==========================================================================
   Fest Foto — estilos mobile-first
   ========================================================================== */

* { box-sizing: border-box; }

:root {
  --bg: #0a0a0f;
  --surface: #16161f;
  --accent: #ff3d68;
  --text: #f5f5f7;
  --text-dim: #9a9aa5;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-height: 60px;
  --demo-badge-height: 0px;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

.screen {
  position: fixed;
  top: var(--demo-badge-height);
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
}
.screen--active { display: block; }

.demo-badge {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 300;
  background: var(--accent);
  color: #3a0a16;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  padding: 4px 12px calc(4px + var(--safe-bottom) * 0);
  padding-top: calc(4px + var(--safe-top));
}

/* ---------------- Onboarding ---------------- */

.onboarding {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 24px calc(32px + var(--safe-bottom));
  gap: 40px;
}

.onboarding__brand { text-align: center; }
.onboarding__brand h1 { font-size: 28px; margin: 0 0 8px; }
.onboarding__date { color: var(--text-dim); margin: 0; font-size: 14px; }

.onboarding__form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field { display: flex; flex-direction: column; gap: 8px; }
.field__label { font-size: 13px; color: var(--text-dim); }
.field input {
  background: var(--surface);
  border: 1px solid #2a2a35;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 16px;
  color: var(--text);
  outline: none;
}
.field input:focus { border-color: var(--accent); }
.field__error { color: var(--accent); font-size: 13px; margin: 0; }

.btn {
  border: none;
  border-radius: 14px;
  padding: 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn--primary { background: var(--accent); color: white; }
.btn--ghost { background: rgba(255,255,255,0.08); color: var(--text); border: 1px solid #2a2a35; }
.btn--block { width: 100%; }

/* ---------------- Cámara ---------------- */

.camera {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
}

.camera__video { display: none; }

.camera__canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera__canvas-hidden { display: none; }

.camera__top-bar {
  position: absolute;
  top: calc(16px + var(--safe-top));
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 5;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.45);
  color: white;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn--text { width: auto; padding: 0 16px; font-size: 13px; font-weight: 700; letter-spacing: 0.5px; }
.icon-btn--active { background: var(--accent); }

.camera__status {
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.45);
  padding: 6px 12px;
  border-radius: 999px;
  min-height: 12px;
}

.capture-limit-badge {
  position: absolute;
  top: calc(70px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55);
  color: var(--text-dim);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  margin: 0;
  z-index: 5;
}
.capture-limit-badge.is-full { color: var(--accent); }

.countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 120px;
  font-weight: 700;
  color: white;
  text-shadow: 0 4px 24px rgba(0,0,0,0.6);
  z-index: 9;
  pointer-events: none;
}

.camera__timer {
  position: absolute;
  top: calc(70px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  font-variant-numeric: tabular-nums;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 5;
}

.camera__bottom-bar {
  position: absolute;
  bottom: calc(20px + var(--nav-height) + var(--safe-bottom));
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  z-index: 5;
}

.filter-strip {
  position: absolute;
  bottom: calc(112px + var(--nav-height) + var(--safe-bottom));
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  padding: 0 16px;
  overflow-x: auto;
  z-index: 5;
  scrollbar-width: none;
}
.filter-strip::-webkit-scrollbar { display: none; }

.filter-chip {
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0, 0, 0, 0.45);
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  white-space: nowrap;
}
.filter-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
}

.capture-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 4px solid white;
  background: transparent;
  padding: 0;
}
.capture-btn__inner {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: white;
  transition: transform 0.15s ease, background 0.15s ease;
}
.capture-btn.is-recording .capture-btn__inner {
  background: var(--accent);
  border-radius: 10px;
  transform: scale(0.55);
}

.camera__error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px;
  text-align: center;
  background: rgba(10, 10, 15, 0.95);
  z-index: 10;
}

.camera__flash {
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
  z-index: 8;
}
.camera__flash.is-flashing {
  opacity: 0.85;
  transition: opacity 0.25s ease;
}

/* ---------------- Revisión de captura ---------------- */

.review {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #000;
}

.review__media {
  flex: 1;
  width: 100%;
  min-height: 0;
  object-fit: contain;
  background: #000;
}

.review__actions {
  display: flex;
  gap: 12px;
  padding: 16px 20px calc(20px + var(--safe-bottom));
  background: var(--bg);
}
.review__actions .btn { flex: 1; }

/* ---------------- Feed estilo Instagram ---------------- */

.feed {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}

.feed__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #1e1e28;
}
.feed__header h2 { font-size: 17px; margin: 0; }

.feed__grid {
  flex: 1;
  overflow-y: auto;
  padding: 2px 2px calc(var(--nav-height) + 24px + var(--safe-bottom));
  display: grid;
  /* auto-fill + minmax: el número de columnas se recalcula solo según el
     ancho real de la pantalla (celular angosto, celular grande, tablet,
     navegador de escritorio) — no hay un número de columnas fijo. */
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 2px;
  -webkit-overflow-scrolling: touch;
}

/* Pantallas más anchas (tablet / desktop): miniaturas un poco más grandes y
   el grid centrado para que no se vea estirado al infinito. */
@media (min-width: 700px) {
  .feed__grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 4px;
    max-width: 900px;
    margin: 0 auto;
  }
}

.feed__empty {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 24px;
  font-size: 14px;
}

.feed-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #111118;
  overflow: hidden;
  border: none;
  padding: 0;
}

.feed-tile__media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.feed-tile__video-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 12px;
  color: white;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.feed-tile__likes {
  position: absolute;
  bottom: 4px;
  left: 4px;
  font-size: 10px;
  color: white;
  background: rgba(0, 0, 0, 0.45);
  padding: 2px 6px;
  border-radius: 999px;
}

/* ---------------- Visor a pantalla completa (lightbox) ---------------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 60;
  display: flex;
  flex-direction: column;
}

.lightbox__close {
  position: absolute;
  top: calc(16px + var(--safe-top));
  right: 16px;
  z-index: 5;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 16px;
}

.lightbox__media-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox__media {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.lightbox__footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px calc(16px + var(--safe-bottom));
  background: #0a0a0f;
}

.feed-card__like {
  background: none;
  border: none;
  font-size: 22px;
  padding: 4px;
  color: var(--text-dim);
  cursor: pointer;
  line-height: 1;
}
.feed-card__like.is-liked { color: var(--accent); }

.feed-card__share {
  background: none;
  border: none;
  font-size: 19px;
  padding: 4px;
  color: var(--text-dim);
  cursor: pointer;
  line-height: 1;
}

.feed-card__delete {
  background: none;
  border: none;
  font-size: 18px;
  padding: 4px;
  color: var(--text-dim);
  cursor: pointer;
  line-height: 1;
}

.feed-card__meta { font-size: 13px; color: var(--text-dim); margin-left: auto; }
.feed-card__meta strong { color: var(--text); font-weight: 600; }

/* ---------------- Navegación inferior ---------------- */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(10, 10, 15, 0.92);
  border-top: 1px solid #1e1e28;
  display: none;
  z-index: 20;
}
.bottom-nav.is-visible { display: flex; }

.bottom-nav__btn {
  flex: 1;
  border: none;
  background: none;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
}
.bottom-nav__btn.is-active { color: var(--text); }
.bottom-nav__icon { font-size: 20px; }

/* ---------------- Toasts (subida en segundo plano) ---------------- */

.toast-container {
  position: fixed;
  bottom: calc(16px + var(--nav-height) + var(--safe-bottom));
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 50;
  pointer-events: none;
}

.toast {
  background: rgba(22, 22, 31, 0.95);
  border: 1px solid #2a2a35;
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast--error { border-color: var(--accent); }
