/* ==========================================================================
   Implant Dental · Reels de Instagram (reels.css)
   Tarjetas 9:16 + modal con <dialog>. Móvil: carrusel con scroll-snap.
   ========================================================================== */

.reels {
  --reel-w: min(72vw, 270px);
}

/* Reserva de espacio mientras carga el JSON (CLS 0) */
.reels:not(.is-ready) {
  min-height: 420px;
  border-radius: var(--r-lg);
  background: linear-gradient(100deg, var(--bg-2) 30%, var(--white) 50%, var(--bg-2) 70%) 0 0 / 200% 100%;
  animation: reelsSkeleton 1.4s linear infinite;
}
@keyframes reelsSkeleton { to { background-position: -200% 0; } }

.reels__list {
  list-style: none;
  margin: 0;
  padding: 0 var(--gutter) var(--s-3);
  margin-inline: calc(var(--gutter) * -1);   /* el carrusel llega al borde y insinúa la siguiente tarjeta */
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--reel-w);
  gap: var(--s-4);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--gutter);
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.reels__list::-webkit-scrollbar { display: none; }

.reels__item {
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

@media (min-width: 900px) {
  .reels__list {
    margin-inline: 0;
    padding: 0;
    overflow: visible;
    grid-auto-flow: row;
    grid-auto-columns: auto;
    grid-template-columns: repeat(3, minmax(0, 320px));
    justify-content: center;
    gap: var(--s-5);
  }
  .reels__list[data-count="1"] { grid-template-columns: minmax(0, 320px); }
  .reels__list[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 320px)); }
}

.reel {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  padding: 0;
  border: 0;
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  background: var(--ink);
  color: var(--white);
  box-shadow: var(--shadow-soft);
  isolation: isolate;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.reel:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.reel:active { transform: translateY(-1px); }
.reel:focus-visible { outline: 3px solid var(--accent-ink); outline-offset: 3px; }

.reel__cover { position: absolute; inset: 0; display: block; }
.reel__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Portada de marca generada con CSS */
.reel__cover--brand {
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.14), transparent 45%),
    radial-gradient(rgba(255, 255, 255, 0.07) 1.2px, transparent 1.6px) 0 0 / 16px 16px,
    linear-gradient(165deg, color-mix(in srgb, var(--accent) 70%, #000) 0%, color-mix(in srgb, var(--accent) 38%, #000) 100%);
}
.reel__brand {
  position: absolute;
  inset-inline: 0;
  top: 14%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  color: rgba(255, 255, 255, 0.92);
}
.reel__handle {
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.reel__play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--white);
  color: var(--accent-ink);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s var(--ease), background 0.3s, color 0.3s;
}
.reel__play svg { margin-left: 3px; }
.reel:hover .reel__play { transform: scale(1.08); background: var(--accent); color: var(--white); }
.reel:active .reel__play { transform: scale(0.97); }

.reel__title {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--ink-2);
  line-height: 1.4;
}

/* ---------- Modal ---------- */
.reels-modal {
  padding: 0;
  border: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100dvh;
  overflow: visible;
  color: var(--white);
}
.reels-modal::backdrop {
  background: rgba(8, 14, 20, 0.82);
  backdrop-filter: blur(4px);
}
.reels-modal[open] { animation: reelsIn 0.28s var(--ease); }
@keyframes reelsIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.reels-modal__box {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  padding: 56px var(--s-4) var(--s-4);
}

.reels-modal__close {
  position: absolute;
  top: var(--s-2);
  right: var(--s-2);
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.25s var(--ease), background 0.25s, color 0.25s;
}
.reels-modal__close:hover { background: var(--accent); color: var(--white); transform: scale(1.06); }
.reels-modal__close:active { transform: scale(0.96); }
.reels-modal__close:focus-visible { outline: 3px solid var(--white); outline-offset: 2px; }

.reels-modal__frame {
  width: min(92vw, 400px);
  height: min(76dvh, 720px);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--white);
}
.reels-modal__iframe { width: 100%; height: 100%; border: 0; display: block; }

.reels-modal__link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-4);
  border-radius: var(--r-pill);
  color: var(--white);
  font-weight: 600;
  font-size: var(--fs-sm);
  text-decoration: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  transition: background 0.25s, color 0.25s;
}
.reels-modal__link:hover { background: var(--white); color: var(--ink); }
.reels-modal__link:active { transform: scale(0.98); }
.reels-modal__link:focus-visible { outline: 3px solid var(--white); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .reels:not(.is-ready), .reels-modal[open] { animation: none; }
  .reel, .reel__play, .reels-modal__close { transition: none; }
  .reel:hover { transform: none; }
}
