/**
 * hminstagram · front.css
 * Sección de Instagram de marca: historias (burbujas) + feed (grid).
 * Paleta Hakuna: mostaza #d9a441 · sage #6f8568 · burdeos #7d2e3a.
 */

.hmig {
  --hmig-mostaza: #d9a441;
  --hmig-sage: #6f8568;
  --hmig-burdeos: #7d2e3a;
  --hmig-cols: 6;
  display: block;
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 12px 24px;
  box-sizing: border-box;
}

.hmig *,
.hmig *::before,
.hmig *::after { box-sizing: border-box; }

.hmig--loading { min-height: 120px; }

/* Anidada dentro de la sección .hk-ig del theme: sin doble ancho/padding. */
.hk-ig .hmig {
  max-width: none;
  padding: 0;
  margin: 4px 0 26px;
}
.hk-ig .hmig .hmig-stories { margin-bottom: 0; }

/* ============ SEGUIDORES ============ */
.hmig-followers {
  margin: 0 0 22px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--hmig-burdeos);
  letter-spacing: .2px;
}

/* ============ HISTORIAS ============ */
.hmig-stories { margin-bottom: 28px; }

.hmig-stories__title,
.hmig-feed__title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 16px;
  text-align: center;
  color: var(--hmig-burdeos);
}

.hmig-stories__vp {
  position: relative;
  max-width: 472px; /* exactamente 5 burbujas (sin asomar la 6ª); resto con flechitas */
  margin: 0 auto;
}

.hmig-stories__row {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  padding: 4px 2px 10px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  justify-content: safe center; /* centra si caben; no corta si hay scroll */
  scroll-snap-type: x mandatory; /* al pasar, encajan (no quedan a medias) */
  scroll-padding: 0 2px;
}
.hmig-stories__row::-webkit-scrollbar { display: none; }

/* Flechitas de navegación de la fila de burbujas (se ocultan si no hay scroll) */
.hmig-arrow {
  position: absolute;
  top: 42px; /* centro de la burbuja */
  transform: translateY(-50%);
  z-index: 4;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .18);
  background: transparent; /* sutiles, no molestan (estilo foto 2) */
  color: rgba(0, 0, 0, .45);
  cursor: pointer;
  box-shadow: none;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.hmig-arrow:hover {
  background: rgba(255, 255, 255, .6);
  border-color: rgba(0, 0, 0, .3);
  color: var(--hmig-burdeos);
}
/* Fuera de las burbujas para no taparlas */
.hmig-arrow--prev { left: -44px; }
.hmig-arrow--next { right: -44px; }
.hmig-arrow[hidden] { display: none; }

/* En pantallas estrechas no hay sitio fuera → al borde (siguen transparentes) */
@media (max-width: 560px) {
  .hmig-arrow--prev { left: 0; }
  .hmig-arrow--next { right: 0; }
}
@media (max-width: 420px) {
  .hmig-arrow { top: 38px; width: 32px; height: 32px; }
}

.hmig-story {
  flex: 0 0 auto;
  width: 78px;
  text-align: center;
  text-decoration: none;
  color: inherit;
  scroll-snap-align: start;
}

.hmig-story__ring {
  display: block;
  width: 76px;
  height: 76px;
  margin: 0 auto;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(45deg, var(--hmig-mostaza), var(--hmig-burdeos) 55%, var(--hmig-sage));
  transition: transform .15s ease;
}
.hmig-story:hover .hmig-story__ring { transform: scale(1.05); }

/* Destacados: anillo gris (como los highlights del perfil oficial de IG),
   frente al anillo de color de las historias. */
.hmig-highlights .hmig-story__ring {
  background: #d9d9d9;
}

.hmig-story__img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-color: #f3f3f3;
  border: 3px solid #fff;
}

.hmig-story__label {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.2;
  color: #555;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ FEED ============ */
.hmig-feed__grid {
  display: grid;
  grid-template-columns: repeat(var(--hmig-cols), 1fr);
  gap: 8px;
}

.hmig-feed__item {
  position: relative;
  display: block;
  aspect-ratio: 4 / 5; /* vertical, como el grid actual de Instagram */
  overflow: hidden;
  border-radius: 8px;
  text-decoration: none;
}

.hmig-feed__img {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-color: #f3f3f3;
  transition: transform .35s ease;
}
.hmig-feed__item:hover .hmig-feed__img { transform: scale(1.06); }

.hmig-feed__play {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent #fff;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, .5));
}

.hmig-feed__follow {
  display: inline-block;
  margin: 18px auto 0;
  padding: 8px 22px;
  border-radius: 999px;
  background: var(--hmig-burdeos);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s ease;
}
.hmig-feed { text-align: center; }
.hmig-feed__follow:hover { background: var(--hmig-sage); color: #fff; }

/* Viewport del feed: contenedor relativo para las flechas. En desktop el grid
   no desborda → las flechas se ocultan solas (mismo patrón que las historias). */
.hmig-feed__vp { position: relative; }
.hmig-feed__vp .hmig-arrow {
  top: 50%; /* centrado vertical sobre la fila del feed (imágenes altas) */
  background: rgba(255, 255, 255, .92);
  border-color: rgba(0, 0, 0, .1);
  color: var(--hmig-burdeos);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .14);
}
.hmig-feed__vp .hmig-arrow:hover { background: #fff; color: var(--hmig-burdeos); }
.hmig-feed__vp .hmig-arrow--prev { left: 6px; }
.hmig-feed__vp .hmig-arrow--next { right: 6px; }

/* ============ Responsive feed ============ */
/* Tablet y móvil: una sola fila con scroll horizontal + flechas (no envuelve).
   Tablet grande (≤1024px) muestra 4 columnas · tablet (≤768px) 3 · móvil (≤560px) 2.
   El corte a 1024px cubre el rango de tablet (iPad/Air en vertical y apaisado),
   que antes quedaba por encima de 768px y caía en el grid multifila de escritorio. */
@media (max-width: 1024px) {
  .hmig-feed__grid {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: calc((100% - 24px) / 4); /* 4 visibles (3 gaps de 8px) */
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  .hmig-feed__grid::-webkit-scrollbar { display: none; }
  .hmig-feed__item { scroll-snap-align: start; }
}
/* Tablet pequeña: 3 columnas visibles. */
@media (max-width: 768px) {
  .hmig-feed__grid { grid-auto-columns: calc((100% - 16px) / 3); /* 3 visibles (2 gaps de 8px) */ }
}
/* Móvil: 2 columnas visibles. */
@media (max-width: 560px) {
  .hmig-feed__grid { grid-auto-columns: calc((100% - 8px) / 2); }
}
@media (max-width: 420px) {
  .hmig-story { width: 70px; }
  .hmig-story__ring { width: 68px; height: 68px; }
}
