@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,500;0,600;1,500&family=Work+Sans:wght@400;500;600&display=swap');

:root {
  --wine: #3A1930;
  --wine-deep: #241220;
  --wine-light: #55254A;
  --gold: #C7A76C;
  --gold-soft: rgba(199, 167, 108, 0.35);
  --blush: #E7B8BE;
  --cream: #FBF6F0;
  --ink: #241220;
  --ink-soft: #7A6473;
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--wine-deep);
  color: var(--cream);
  font-family: 'Work Sans', sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.01em;
}

a { color: inherit; }

button {
  font-family: 'Work Sans', sans-serif;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.btn {
  border: 1px solid var(--gold-soft);
  background: transparent;
  color: var(--cream);
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-weight: 500;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.btn:hover { border-color: var(--gold); }
.btn-primary {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--wine-deep);
  font-weight: 600;
}
.btn-primary:hover { background: #d4b57e; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  border-color: transparent;
  color: var(--blush);
  padding: 0.5rem 0.8rem;
}
.btn-ghost:hover { color: var(--gold); border-color: transparent; }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1.1rem;
  text-align: left;
}
.field label {
  font-size: 0.78rem;
  color: var(--blush);
}
.field input {
  background: rgba(251, 246, 240, 0.06);
  border: 1px solid rgba(251, 246, 240, 0.18);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  color: var(--cream);
  font-size: 0.98rem;
  font-family: 'Work Sans', sans-serif;
}
.field input:focus { border-color: var(--gold); }

/* ---------- Login ---------- */
.login-page {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(600px 400px at 50% 15%, var(--wine-light), transparent 70%),
    var(--wine-deep);
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.mark {
  width: 34px;
  height: 34px;
  margin: 0 auto 1.4rem;
  border: 1px solid var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
}
.login-card h1 {
  font-size: 2.1rem;
  font-style: italic;
  margin-bottom: 0.4rem;
}
.login-card .subtitle {
  color: var(--ink-soft);
  color: var(--blush);
  font-size: 0.88rem;
  margin-bottom: 2rem;
}
.login-form { margin-top: 1.5rem; }
.login-error {
  color: #f0a7a7;
  font-size: 0.85rem;
  min-height: 1.2em;
  margin-top: -0.4rem;
  margin-bottom: 0.8rem;
}

/* ---------- Chrome compartido (header) ---------- */
.app-shell { min-height: 100svh; background: var(--wine-deep); }
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.6rem;
  background: var(--wine);
  border-bottom: 1px solid rgba(199, 167, 108, 0.18);
}
.app-header .title {
  font-size: 1.4rem;
  font-style: italic;
}
.app-header .title small {
  display: block;
  font-family: 'Work Sans', sans-serif;
  font-style: normal;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--blush);
  margin-top: 0.1rem;
}
.app-header nav { display: flex; align-items: center; gap: 0.4rem; }

.app-main { max-width: 1100px; margin: 0 auto; padding: 2rem 1.6rem 4rem; }

.section-label {
  color: var(--blush);
  font-size: 0.85rem;
  margin-bottom: 1.2rem;
}
.section-label strong { color: var(--cream); }

/* ---------- Panel del fotógrafo ---------- */
.dropzone {
  border: 1.5px dashed var(--gold-soft);
  border-radius: var(--radius);
  padding: 3.2rem 1.5rem;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
  cursor: pointer;
  margin-bottom: 2.4rem;
}
.dropzone.dragover { border-color: var(--gold); background: rgba(199, 167, 108, 0.06); }
.dropzone h2 { font-size: 1.6rem; font-style: italic; margin-bottom: 0.5rem; }
.dropzone p { color: var(--ink-soft); color: var(--blush); font-size: 0.88rem; margin: 0; }
.dropzone input[type="file"] { display: none; }

.upload-list { display: flex; flex-direction: column; gap: 0.6rem; }
.upload-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: rgba(251, 246, 240, 0.04);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
}
.upload-row .thumb {
  width: 42px; height: 42px; border-radius: 4px; object-fit: cover;
  background: var(--wine-light); flex-shrink: 0;
}
.upload-row .name { flex: 1; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-row .status { font-size: 0.78rem; color: var(--blush); flex-shrink: 0; }
.upload-row .status.ok { color: #a7d9a7; }
.upload-row .status.error { color: #f0a7a7; }
.progress-track {
  width: 90px; height: 3px; background: rgba(251,246,240,0.15); border-radius: 2px; overflow: hidden; flex-shrink: 0;
}
.progress-fill { height: 100%; background: var(--gold); width: 0%; transition: width 0.2s ease; }

/* ---------- Galería ---------- */
.gallery-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.4rem;
  flex-wrap: wrap;
  gap: 0.8rem;
}
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.photo-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  overflow: hidden;
  background: var(--wine-light);
  cursor: pointer;
}
.photo-tile img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform 0.25s ease;
}
.photo-tile:hover img { transform: scale(1.04); }
.photo-tile .select-mark {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid rgba(251,246,240,0.7);
  background: rgba(36, 18, 32, 0.35);
}
.photo-tile.selected .select-mark {
  background: var(--gold); border-color: var(--gold);
}
.photo-tile.selected .select-mark::after {
  content: "✓"; color: var(--wine-deep); font-size: 0.75rem;
  display: flex; align-items: center; justify-content: center; height: 100%;
}
.empty-state {
  text-align: center; padding: 4rem 1rem; color: var(--blush);
}
.empty-state h2 { font-style: italic; font-size: 1.6rem; margin-bottom: 0.5rem; color: var(--cream); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; background: rgba(15, 8, 13, 0.94);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 88vw; max-height: 80vh; border-radius: 4px; }
.lightbox .lb-close {
  position: absolute; top: 1.2rem; right: 1.4rem;
  background: none; border: none; color: var(--cream); font-size: 1.6rem;
}
.lightbox .lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--gold); font-size: 2rem; padding: 1rem;
}
.lightbox .lb-prev { left: 0.5rem; }
.lightbox .lb-next { right: 0.5rem; }
.lightbox .lb-download {
  position: absolute; bottom: 1.4rem; left: 50%; transform: translateX(-50%);
}

@media (max-width: 640px) {
  .app-header { padding: 0.9rem 1rem; }
  .app-main { padding: 1.4rem 1rem 3rem; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
}

/* ---------- Toasts ---------- */
.toast-container {
  position: fixed;
  top: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 100;
  width: min(420px, calc(100vw - 2rem));
}
.toast {
  background: var(--wine);
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  color: var(--cream);
  box-shadow: 0 8px 24px rgba(15, 8, 13, 0.4);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  cursor: pointer;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { border-color: #d97a7a; }
.toast-success { border-color: #7bbf7b; }
.toast-info { border-color: var(--gold); }

/* ---------- Curaduría (mostrar/ocultar en la galería) ---------- */
.photo-tile.hidden-photo { opacity: 0.4; }
.photo-tile .curate-badges {
  position: absolute; top: 8px; left: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.photo-tile .curate-toggle {
  background: rgba(36, 18, 32, 0.75);
  border: 1px solid var(--gold-soft);
  border-radius: 4px;
  color: var(--cream);
  font-size: 0.65rem;
  padding: 0.2rem 0.45rem;
  text-align: left;
}
.photo-tile .curate-toggle:hover { border-color: var(--gold); }
.photo-tile .curate-toggle-public { border-color: rgba(231, 184, 190, 0.4); }
.photo-tile .curate-toggle-public:hover { border-color: var(--blush); }
.upload-row .status.duplicate { color: #e0c27a; }

/* ---------- Visor público: disuasivos anti-copia ---------- */
.album-page, .album-page * {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-touch-callout: none; /* evita el menú de "guardar imagen" al mantener tocado en iOS */
}
.protected-photo { position: relative; }
.protected-photo img {
  pointer-events: none; /* los eventos de mouse pasan a la capa de arriba */
  -webkit-user-drag: none;
  user-drag: none;
}
.protected-shield {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: transparent;
}
.lb-protected { display: inline-block; max-width: 88vw; max-height: 80vh; }
.lb-protected img { max-width: 88vw; max-height: 80vh; border-radius: 4px; display: block; }

/* ---------- Visor tipo reel (scroll vertical con snap, estilo TikTok) ---------- */
.reel-viewer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  top: var(--header-h, 64px);
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  background: #000;
  z-index: 30;
  -webkit-overflow-scrolling: touch;
}
.reel-slide {
  height: calc(100svh - var(--header-h, 64px));
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.reel-slide img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
}
.reel-counter {
  position: absolute;
  bottom: 1.2rem;
  right: 1rem;
  background: rgba(36, 18, 32, 0.6);
  color: var(--cream);
  font-size: 0.78rem;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  pointer-events: none;
}
.reel-hint {
  position: absolute;
  bottom: 1.2rem;
  left: 1rem;
  color: var(--blush);
  font-size: 0.72rem;
  opacity: 0.8;
  pointer-events: none;
}

/* En pantallas chicas, el reel es el modo por defecto; en desktop, el grid. */
@media (max-width: 640px) {
  body.reel-capable .app-main { display: none; }
  body.reel-capable .reel-viewer { display: block !important; }
}
@media (min-width: 641px) {
  #reelToggle { display: none; } /* el swipe vertical es un gesto de mobile; en desktop no aplica */
}
