/* ==========================================================================
   Stellion — Loops (lecteur vertical plein écran)
   Maquette : Loops. Toujours sombre, quel que soit le thème : le fond est la vidéo.
   Couleurs : jetons --media-* de tokens.css, identiques dans les deux thèmes.
   ========================================================================== */

/* Affichée par le JS (style.display = 'flex') */
.st-loops {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: none;
  flex-direction: column;
  background: var(--media-bg);
  color: var(--on-media);
  --accent: var(--media-accent);
  --like: var(--media-like);
}

.st-loops__head {
  position: absolute;
  top: calc(var(--space-2) + env(safe-area-inset-top, 0px));
  left: var(--space-2);
  right: var(--space-2);
  z-index: 6;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.st-loops__title {
  margin: 0;
  color: var(--on-media);
  padding-bottom: var(--space-1);
  border-bottom: 3px solid var(--accent);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

.st-loops__btn,
.st-loops__mini {
  width: var(--tap-min);
  height: var(--tap-min);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  box-shadow: none;
  color: var(--on-media);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
}

.st-loops__btn:hover,
.st-loops__mini:hover {
  background: var(--media-scrim);
  filter: none;
  transform: none;
  box-shadow: none;
}

#loop-container {
  flex: 1;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  overscroll-behavior: contain;
}

#loop-container::-webkit-scrollbar {
  display: none;
}

#loop-sentinel {
  height: 4px;
}

/* ---------- Une publication ---------- */

.loop-item {
  position: relative;
  width: 100%;
  height: 100dvh;
  flex-shrink: 0;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: var(--media-bg);
}

.loop-bg {
  position: absolute;
  inset: -20px;
  z-index: 0;
  background: var(--loop-bg) center / cover no-repeat;
  filter: blur(22px) brightness(0.3);
  transform: scale(1.1);
}

.loop-bg-dark {
  background: var(--media-bg);
  filter: none;
}

.loop-media-single,
.loop-carousel {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
}

.loop-media-single {
  display: flex;
  align-items: center;
  justify-content: center;
}

.loop-video,
.loop-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.loop-video {
  cursor: pointer;
}

.loop-carousel-track {
  height: 100%;
  display: flex;
  transition: transform var(--duration-base) var(--ease-out);
}

.loop-slide {
  min-width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.loop-carousel-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 150px;
  z-index: 3;
  display: flex;
  justify-content: center;
  gap: 6px;
}

.loop-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--on-media);
  opacity: 0.45;
}

.loop-dot.active {
  opacity: 1;
}

.loop-carousel-counter {
  position: absolute;
  top: calc(64px + env(safe-area-inset-top, 0px));
  right: var(--space-3);
  z-index: 3;
  height: 24px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-xs);
  background: var(--media-scrim);
  display: flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
}

/* Dégradés pour lire le texte posé sur la vidéo */
.loop-gradient-top,
.loop-gradient-bottom {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  pointer-events: none;
}

.loop-gradient-top {
  top: 0;
  height: 120px;
  background: var(--media-fade-top);
}

.loop-gradient-bottom {
  bottom: 0;
  height: 320px;
  background: var(--media-fade-bottom);
}

/* Colonne d'actions à droite */
.loop-actions {
  position: absolute;
  right: var(--space-2);
  bottom: calc(132px + env(safe-area-inset-bottom, 0px));
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.loop-author,
.loop-action-btn,
.loop-username {
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--on-media);
  font: inherit;
  letter-spacing: 0;
  cursor: pointer;
}

.loop-author:hover,
.loop-action-btn:hover,
.loop-username:hover {
  filter: none;
  transform: none;
  box-shadow: none;
}

.loop-author {
  margin-bottom: var(--space-1);
  border-radius: var(--radius-full);
  display: flex;
}

.loop-author > .st-avatar {
  --avatar-size: 46px;
  box-shadow: 0 0 0 2px var(--on-media);
}

.loop-action-btn {
  width: 52px;
  min-height: 52px;
  padding: var(--space-1) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.loop-action-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.loop-like-btn[aria-pressed="true"] {
  color: var(--like);
}

.loop-like-btn[aria-pressed="true"] > svg {
  fill: currentColor;
}

.loop-action-btn[aria-pressed="true"]:not(.loop-like-btn) {
  color: var(--accent);
}

/* Auteur, légende, nexus d'origine, musique */
.loop-overlay-bottom {
  position: absolute;
  left: var(--space-4);
  right: 76px;
  bottom: calc(var(--space-10) + env(safe-area-inset-bottom, 0px));
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

.loop-username {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  text-align: left;
}

.loop-username:hover {
  text-decoration: underline;
}

.loop-caption {
  margin: 0;
  max-height: calc(1.45em * 2);
  overflow: hidden;
  font-size: var(--text-base);
  line-height: 1.45;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.loop-caption.loop-caption-expanded {
  max-height: 40vh;
  overflow-y: auto;
}

.loop-nexus {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  opacity: 0.85;
}

.loop-music-chip {
  max-width: 100%;
  padding: 0 var(--space-1) 0 var(--space-3);
  border-radius: var(--radius-full);
  background: var(--media-scrim);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.loop-music-chip > svg {
  flex-shrink: 0;
}

.loop-music-chip__text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Barre de lecture : largeur donnée par --progress (loop.js) */
.loop-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  height: 3px;
  background: var(--media-track);
}

.loop-progress > span {
  display: block;
  width: var(--progress, 0%);
  height: 100%;
  background: var(--accent);
}

/* Ordinateur : la vidéo reste au format vertical, centrée */
@media (min-width: 1024px) {
  .loop-item > .loop-media-single,
  .loop-item > .loop-carousel {
    left: 50%;
    right: auto;
    width: min(480px, 56.25dvh);
    transform: translateX(-50%);
  }

  .loop-actions {
    right: calc(50% - min(240px, 28.125dvh) - 72px);
  }

  .loop-overlay-bottom {
    left: calc(50% - min(240px, 28.125dvh) + var(--space-4));
    right: calc(50% - min(240px, 28.125dvh) + 64px);
  }
}
