/* ============================================================
   EntreDosLagunas — Galería v3
   Grid magazine + Lightbox + Video player custom
   ============================================================ */

/* ---------- Grid de la galería ---------- */
.gal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  margin-top: 28px;
}

@media (max-width: 980px) {
  .gal-grid { grid-template-columns: repeat(2, 1fr); gap: 20px; }
}
@media (max-width: 560px) {
  .gal-grid { grid-template-columns: 1fr; gap: 24px; }
}

/* ---------- Card ---------- */
.gal-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: transform .35s cubic-bezier(.2,.8,.2,1);
}

.gal-card:hover { transform: translateY(-4px); }
.gal-card:focus-visible {
  outline: 2px solid var(--olive);
  outline-offset: 4px;
  border-radius: 4px;
}

/* Thumbnail */
.gal-card__thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 6px;
  background: var(--cream-2);
}

.gal-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .7s cubic-bezier(.2,.8,.2,1);
}

.gal-card:hover .gal-card__thumb img { transform: scale(1.06); }

/* Placeholder cuando no hay imagen */
.gal-card__ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream-2);
  color: var(--olive-dust);
}
.gal-card__ph .material-symbols-outlined { font-size: 48px; }

/* Badge de tipo (esquina superior izquierda) */
.gal-card__type {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(245, 241, 232, .94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--olive);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.gal-card__type .material-symbols-outlined {
  font-size: 14px;
  font-variation-settings: 'FILL' 1;
}

/* Botón play overlay (solo videos) */
.gal-card__play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(45, 58, 31, .88);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: transform .3s ease, background .3s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.gal-card:hover .gal-card__play {
  transform: translate(-50%, -50%) scale(1.08);
  background: var(--accent);
}
.gal-card__play .material-symbols-outlined {
  font-size: 36px;
  font-variation-settings: 'FILL' 1;
  margin-left: 3px;
}

@media (max-width: 560px) {
  .gal-card__play { width: 56px; height: 56px; }
  .gal-card__play .material-symbols-outlined { font-size: 30px; }
}

/* Info debajo (título + meta) */
.gal-card__info {
  padding: 14px 2px 0;
}
.gal-card__title {
  font-family: var(--font-serif, 'Instrument Serif', serif);
  font-size: 20px;
  line-height: 1.25;
  color: var(--olive);
  margin: 0 0 6px;
  font-weight: 400;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gal-card__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--ink-soft);
  text-transform: uppercase;
  font-weight: 500;
}
.gal-card__date { color: var(--olive-dust); }
.gal-card__meta span + span::before {
  content: '·';
  margin-right: 10px;
  color: var(--olive-dust);
}

/* ============================================================
   LIGHTBOX
   ============================================================ */

.gal-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 10, .97);
  z-index: 9999;
  display: none;
  flex-direction: column;
  opacity: 0;
  transition: opacity .25s ease;
}

.gal-lightbox.is-open {
  display: flex;
  opacity: 1;
}

body.gal-lock { overflow: hidden; }

/* Top bar */
.gal-lightbox__bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  z-index: 10;
  background: linear-gradient(to bottom, rgba(0,0,0,.5), rgba(0,0,0,0));
}

.gal-lightbox__counter {
  color: rgba(245, 241, 232, .8);
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.gal-lightbox__icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(245, 241, 232, .1);
  border: 1px solid rgba(245, 241, 232, .18);
  color: var(--cream);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .2s ease, border-color .2s ease;
  padding: 0;
}
.gal-lightbox__icon-btn:hover {
  background: rgba(245, 241, 232, .2);
  border-color: rgba(245, 241, 232, .35);
}
.gal-lightbox__icon-btn .material-symbols-outlined { font-size: 22px; }

/* Botones de navegación */
.gal-lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(245, 241, 232, .08);
  border: 1px solid rgba(245, 241, 232, .15);
  color: var(--cream);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background .2s ease, transform .2s ease;
  padding: 0;
}
.gal-lightbox__nav:hover {
  background: rgba(245, 241, 232, .18);
  transform: translateY(-50%) scale(1.05);
}
.gal-lightbox__nav .material-symbols-outlined { font-size: 28px; }
.gal-lightbox__nav--prev { left: 24px; }
.gal-lightbox__nav--next { right: 24px; }

@media (max-width: 700px) {
  .gal-lightbox__nav {
    width: 42px;
    height: 42px;
    background: rgba(0,0,0,.5);
  }
  .gal-lightbox__nav .material-symbols-outlined { font-size: 24px; }
  .gal-lightbox__nav--prev { left: 10px; }
  .gal-lightbox__nav--next { right: 10px; }
  .gal-lightbox__bar { padding: 14px 14px; }
}

/* Stage (área del media) */
.gal-lightbox__stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 90px 20px;
  min-height: 0;
  position: relative;
}

@media (max-width: 700px) {
  .gal-lightbox__stage {
    padding: 70px 8px 12px;
  }
}

/* Imagen en el lightbox */
.gal-lightbox__stage img.gal-media {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}

/* Iframe (YouTube/Vimeo) */
.gal-lightbox__stage iframe.gal-media {
  width: 100%;
  max-width: 1200px;
  aspect-ratio: 16 / 9;
  max-height: 100%;
  border: 0;
  border-radius: 6px;
  background: #000;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}

/* Caption inferior */
.gal-lightbox__caption {
  flex-shrink: 0;
  padding: 14px 24px 22px;
  text-align: center;
  color: rgba(245, 241, 232, .85);
  max-width: 800px;
  margin: 0 auto;
}
.gal-lightbox__title {
  font-family: var(--font-serif, 'Instrument Serif', serif);
  color: var(--cream);
  font-size: 22px;
  font-weight: 400;
  margin: 0 0 6px;
  line-height: 1.3;
}
.gal-lightbox__meta {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(245, 241, 232, .55);
  margin-bottom: 8px;
  font-weight: 500;
}
.gal-lightbox__desc {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(245, 241, 232, .7);
  margin: 0;
}
.gal-lightbox__title:empty,
.gal-lightbox__meta:empty,
.gal-lightbox__desc:empty { display: none; }

@media (max-width: 700px) {
  .gal-lightbox__caption { padding: 10px 14px 16px; }
  .gal-lightbox__title { font-size: 17px; }
  .gal-lightbox__desc { font-size: 13px; }
}

/* ============================================================
   REPRODUCTOR DE VIDEO CUSTOM
   ============================================================ */

.vplayer {
  position: relative;
  width: 100%;
  max-width: 1200px;
  max-height: 100%;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
}

.vplayer__video {
  width: 100%;
  height: auto;
  max-height: 80vh;
  display: block;
  background: #000;
}

/* Fullscreen: video ocupa TODA la pantalla */
.vplayer:fullscreen,
.vplayer:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
  box-shadow: none;
}
.vplayer:fullscreen .vplayer__video,
.vplayer:-webkit-full-screen .vplayer__video {
  width: 100%;
  height: 100%;
  max-height: 100vh;
  object-fit: contain;
}

/* Botón play central */
.vplayer__center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(245, 241, 232, .94);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--olive);
  z-index: 5;
  transition: transform .25s ease, background .25s ease;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.vplayer__center:hover {
  transform: translate(-50%, -50%) scale(1.08);
  background: var(--cream);
}
.vplayer__center .material-symbols-outlined {
  font-size: 44px;
  font-variation-settings: 'FILL' 1;
  margin-left: 4px;
}
.vplayer.is-playing .vplayer__center {
  opacity: 0;
  pointer-events: none;
}

/* Controles inferiores */
.vplayer__controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 32px 16px 12px;
  background: linear-gradient(to top, rgba(0,0,0,.9) 0%, rgba(0,0,0,.5) 50%, rgba(0,0,0,0) 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 6;
  transition: opacity .3s ease, transform .3s ease;
  /* Necesario para el popup de volumen vertical en mobile */
  overflow: visible;
}
.vplayer.is-playing.is-idle .vplayer__controls {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

/* Barra de progreso */
.vplayer__progress {
  position: relative;
  width: 100%;
  height: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.vplayer__progress-bar {
  position: relative;
  width: 100%;
  height: 4px;
  background: rgba(245, 241, 232, .25);
  border-radius: 2px;
  overflow: hidden;
  transition: height .15s ease;
}
.vplayer__progress:hover .vplayer__progress-bar { height: 6px; }
.vplayer__progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  border-radius: 2px;
  transition: width .08s linear;
}
.vplayer__progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 14px;
  height: 14px;
  background: var(--cream);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.vplayer__progress:hover .vplayer__progress-thumb { opacity: 1; }

/* Fila de botones */
.vplayer__row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.vplayer__btn {
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  color: var(--cream);
  cursor: pointer;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease;
  flex-shrink: 0;
  padding: 0;
}
.vplayer__btn:hover { background: rgba(245, 241, 232, .15); }
.vplayer__btn .material-symbols-outlined {
  font-size: 24px;
  font-variation-settings: 'FILL' 1;
}
.vplayer__btn--play .material-symbols-outlined { font-size: 28px; }

/* ==========================================================
   Volumen — desktop horizontal, mobile vertical (popup)
   ========================================================== */
.vplayer__volume {
  display: inline-flex;
  align-items: center;
  position: relative;
}

/* ---- Slider HORIZONTAL (desktop / pantallas anchas) ---- */
.vplayer__volume-slider {
  width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  transition: width .25s ease, margin-left .25s ease;
}
.vplayer__volume:hover .vplayer__volume-slider,
.vplayer__volume.is-active .vplayer__volume-slider {
  width: 84px;
  margin-left: 4px;
}
.vplayer__volume-input {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  background: rgba(245, 241, 232, .3);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  margin: 0 4px;
}
.vplayer__volume-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  background: var(--cream);
  border-radius: 50%;
  cursor: pointer;
}
.vplayer__volume-input::-moz-range-thumb {
  width: 13px;
  height: 13px;
  background: var(--cream);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* ---- Slider VERTICAL en mobile (popup arriba del botón) ---- */
@media (max-width: 700px), (hover: none) {
  /* En mobile el hover NO abre el slider */
  .vplayer__volume:hover .vplayer__volume-slider {
    width: 0;
    margin-left: 0;
  }

  /* Panel popup vertical — aparece cuando is-active */
  .vplayer__volume.is-active .vplayer__volume-slider {
    width: auto;
    margin-left: 0;
    position: absolute;
    /* Sube sobre los controles — z-index mayor que .vplayer__controls */
    bottom: calc(100% + 14px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(12, 15, 8, .97);
    border: 1px solid rgba(245, 241, 232, .18);
    border-radius: 24px;
    padding: 16px 14px;
    height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .6);
    z-index: 50;
    overflow: visible;
  }

  /* Flechita inferior */
  .vplayer__volume.is-active .vplayer__volume-slider::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 7px solid rgba(12, 15, 8, .97);
  }

  /*
   * SOLUCIÓN iOS: en lugar de rotate(-90deg) que rompe el eje táctil en Safari,
   * usamos writing-mode: vertical-lr + direction: rtl para orientar el slider
   * verticalmente de forma nativa — iOS lo maneja correctamente.
   * Esto funciona en Safari 15+ (iOS 15+) y todos los navegadores modernos.
   */
  .vplayer__volume.is-active .vplayer__volume-input {
    -webkit-appearance: slider-vertical;
    appearance: slider-vertical;
    writing-mode: vertical-lr;
    direction: rtl;
    /*
     * El ancho del input define el ancho de la pista en modo vertical.
     * En Safari/iOS con writing-mode, "width" = grosor visual de la pista.
     * Hacemos el input más ancho que la pista para que el thumb tenga
     * espacio horizontal y quede centrado sin margin tricks.
     */
    width: 28px;   /* área touch ancha → thumb centrado naturalmente */
    height: 104px;
    margin: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    transform: none;
    align-self: center;
  }

  .vplayer__volume.is-active .vplayer__volume-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    background: var(--cream);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .55);
    /* Con writing-mode el thumb ya queda centrado automáticamente
       sobre la pista — no necesita margin-right */
    margin: 0;
  }

  .vplayer__volume.is-active .vplayer__volume-input::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: var(--cream);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .55);
  }

  .vplayer__volume.is-active .vplayer__volume-input::-webkit-slider-runnable-track {
    /* Con width=28px en el input, la pista se dibuja centrada */
    width: 5px;
    background: rgba(245, 241, 232, .28);
    border-radius: 3px;
  }

  .vplayer__volume.is-active .vplayer__volume-input::-moz-range-track {
    width: 5px;
    background: rgba(245, 241, 232, .28);
    border-radius: 3px;
  }
}

/* Tiempo */
.vplayer__time {
  font-size: 12px;
  color: var(--cream);
  font-variant-numeric: tabular-nums;
  letter-spacing: .03em;
  white-space: nowrap;
  padding: 0 8px;
  font-weight: 500;
}

.vplayer__spacer { flex: 1; }

@media (max-width: 560px) {
  .vplayer__center { width: 64px; height: 64px; }
  .vplayer__center .material-symbols-outlined { font-size: 36px; }
  .vplayer__btn { width: 34px; height: 34px; }
  .vplayer__btn .material-symbols-outlined { font-size: 22px; }
  .vplayer__time { font-size: 11px; padding: 0 4px; }
  .vplayer__controls { padding: 28px 8px 10px; }
}
