/* =============================================
   MAKUS ORO — Carosello Video "Reels"
   ============================================= */

.reels {
  --card-w: clamp(210px, 24vw, 330px);
  position: relative;
  isolation: isolate;
}

/* Bagliore ambientale: il poster del video attivo, sfocato, dietro al carosello */
.reels-ambient {
  position: absolute;
  inset: -10% 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
  -webkit-mask-image: radial-gradient(ellipse 60% 55% at 50% 45%, #000 20%, transparent 75%);
          mask-image: radial-gradient(ellipse 60% 55% at 50% 45%, #000 20%, transparent 75%);
}
.reels-ambient img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(70px) saturate(1.5);
  opacity: 0.45;
  transform: scale(1.2);
  transition: opacity 0.6s ease;
}

/* ---------- Filtri ---------- */
.reels-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 2.5rem;
}
.reels-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: 50px;
  border: 1px solid rgba(201,168,76,0.3);
  background: rgba(255,255,255,0.04);
  color: var(--white-70);
  font: 600 0.9rem var(--font-body);
  cursor: pointer;
  transition: var(--transition);
}
.reels-filter span {
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  border-radius: 20px;
  background: rgba(201,168,76,0.15);
  color: var(--gold-light);
}
.reels-filter:hover { border-color: var(--gold); color: var(--white); }
.reels-filter.active {
  background: var(--gradient-gold);
  color: var(--black);
  border-color: transparent;
  box-shadow: 0 8px 25px var(--gold-glow);
}
.reels-filter.active span { background: rgba(0,0,0,0.15); color: var(--black); }

/* ---------- Palco 3D ---------- */
.reels-stage {
  position: relative;
  height: calc(var(--card-w) * 16 / 9 + 40px);
  perspective: 1400px;
  outline: none;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.reels-track {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}
.reels-card {
  position: absolute;
  top: 20px;
  left: 50%;
  width: var(--card-w);
  aspect-ratio: 9 / 16;
  margin-left: calc(var(--card-w) / -2);
  border-radius: 22px;
  overflow: hidden;
  background: var(--dark-3);
  cursor: pointer;
  box-shadow: 0 30px 60px rgba(0,0,0,0.55);
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.6s ease, filter 0.6s ease;
  will-change: transform;
}
.reels-card > img,
.reels-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  -webkit-user-drag: none;
}
.reels-video { z-index: 1; background: #000; }

/* Cornice dorata animata sulla card attiva */
.reels-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 2px;
  background: conic-gradient(from var(--reels-angle, 0deg), #9A7730, #F5E6C8, #C9A84C, #9A7730, #E8C96C, #9A7730);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 4;
  pointer-events: none;
}
.reels-card.is-active::after {
  opacity: 1;
  animation: reelsSpin 5s linear infinite;
}
.reels-card.is-active {
  cursor: default;
  box-shadow: 0 40px 90px rgba(0,0,0,0.6), 0 0 60px rgba(201,168,76,0.35);
}
@property --reels-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}
@keyframes reelsSpin { to { --reels-angle: 360deg; } }

.reels-card-shade {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,0.85) 100%);
  pointer-events: none;
}
.reels-card-label {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 3;
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.3;
  text-shadow: 0 2px 10px rgba(0,0,0,0.6);
  transition: opacity 0.4s ease;
}
.reels-card-label span {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-light);
  margin-bottom: 0.3rem;
}
.reels-card-play {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--black);
  background: var(--gradient-gold);
  box-shadow: 0 0 0 8px rgba(201,168,76,0.2);
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.reels-card:not(.is-active):hover .reels-card-play { transform: scale(1.12); }
.reels-card.is-active .reels-card-play,
.reels-card.is-active .reels-card-label { opacity: 0; }
.reels-blocked .reels-card.is-active .reels-card-play { opacity: 1; z-index: 5; }

/* HUD della card attiva */
.reels-hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
.reels-progress {
  position: absolute;
  top: 12px;
  left: 14px;
  right: 14px;
  height: 3px;
  border-radius: 3px;
  background: rgba(255,255,255,0.25);
  overflow: hidden;
}
.reels-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--gradient-gold);
  box-shadow: 0 0 10px var(--gold);
  transition: width 0.25s linear;
}
.reels-hud-btns {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}
.reels-hud-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 38px;
  min-width: 38px;
  padding: 0 0.7rem;
  justify-content: center;
  border-radius: 50px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(10,10,10,0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  cursor: pointer;
  font: 600 0.78rem var(--font-body);
  transition: var(--transition);
}
.reels-hud-btn em { font-style: normal; }
.reels-hud-btn:hover { border-color: var(--gold); color: var(--gold-light); }
.reels-sound { margin-right: auto; }
.reels-sound:not(.on) {
  background: var(--gradient-gold);
  color: var(--black);
  border-color: transparent;
  animation: reelsPulse 2s ease-in-out infinite;
}
@keyframes reelsPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201,168,76,0.6); }
  50% { box-shadow: 0 0 0 8px rgba(201,168,76,0); }
}

/* Frecce */
.reels-arrow {
  position: absolute;
  top: 50%;
  z-index: 200;
  width: 54px;
  height: 54px;
  margin-top: -27px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(201,168,76,0.45);
  background: rgba(10,10,10,0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--gold-light);
  cursor: pointer;
  transition: var(--transition);
}
.reels-arrow:hover {
  background: var(--gradient-gold);
  color: var(--black);
  transform: scale(1.08);
  box-shadow: 0 10px 30px var(--gold-glow);
}
.reels-prev { left: max(0px, calc(50% - var(--card-w) * 1.6)); }
.reels-next { right: max(0px, calc(50% - var(--card-w) * 1.6)); }

/* ---------- Info video attivo ---------- */
.reels-info {
  max-width: 680px;
  margin: 2.5rem auto 0;
  text-align: center;
}
.reels-info.swap > * { animation: reelsInfoIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) both; }
.reels-info.swap > *:nth-child(2) { animation-delay: 0.05s; }
.reels-info.swap > *:nth-child(3) { animation-delay: 0.1s; }
.reels-info.swap > *:nth-child(4) { animation-delay: 0.15s; }
@keyframes reelsInfoIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.reels-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.9rem;
}
.reels-count {
  font-size: 0.9rem;
  color: var(--white-70);
  letter-spacing: 0.1em;
}
.reels-count b {
  font-family: var(--font-display);
  font-size: 1.5rem;
  background: var(--gradient-gold);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.reels-chip {
  display: inline-block;
  padding: 0.25rem 0.8rem;
  border-radius: 50px;
  border: 1px solid rgba(201,168,76,0.4);
  background: rgba(201,168,76,0.12);
  color: var(--gold-light);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.reels-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  line-height: 1.2;
  color: var(--white);
  margin-bottom: 0.8rem;
}
.reels-text {
  color: var(--white-70);
  line-height: 1.75;
  font-size: 1.02rem;
  margin-bottom: 1.6rem;
  min-height: 5.3em;
}
.reels-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
}
.reels-actions svg { width: 18px; height: 18px; }

/* ---------- Dock miniature ---------- */
.reels-dock {
  display: flex;
  gap: 0.7rem;
  margin-top: 3rem;
  padding: 0.6rem 0.4rem 1rem;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dark) transparent;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}
.reels-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 72px;
  aspect-ratio: 9 / 16;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  padding: 0;
  background: var(--dark-3);
  cursor: pointer;
  scroll-snap-align: center;
  opacity: 0.55;
  transition: var(--transition);
}
.reels-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.reels-thumb span {
  position: absolute;
  left: 6px;
  bottom: 4px;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.reels-thumb:hover { opacity: 0.9; transform: translateY(-3px); }
.reels-thumb.active {
  opacity: 1;
  border-color: var(--gold);
  box-shadow: 0 8px 20px var(--gold-glow);
  transform: translateY(-4px);
}

/* ---------- Lightbox ---------- */
html.reels-lock { overflow: hidden; }
.reels-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: calc(env(safe-area-inset-top, 0px) + 1rem) 1rem calc(env(safe-area-inset-bottom, 0px) + 1rem);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.reels-lightbox[hidden] { display: none; }
.reels-lightbox.open { opacity: 1; }
.rl-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5,5,5,0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.rl-body {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2.5rem;
  max-height: 100%;
  transform: scale(0.96);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.reels-lightbox.open .rl-body { transform: none; }
.rl-player {
  height: min(86vh, 860px);
  aspect-ratio: 9 / 16;
  max-width: 92vw;
  border-radius: 20px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 1px rgba(201,168,76,0.4), 0 30px 90px rgba(0,0,0,0.7), 0 0 80px rgba(201,168,76,0.2);
}
.rl-player video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.rl-info { width: 320px; color: #fff; }
.rl-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  line-height: 1.2;
  margin: 0.9rem 0 0.8rem;
}
.rl-text { color: rgba(255,255,255,0.72); line-height: 1.75; margin-bottom: 1.6rem; }
.rl-close, .rl-nav {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(201,168,76,0.45);
  background: rgba(20,20,20,0.7);
  color: var(--gold-light);
  cursor: pointer;
  transition: var(--transition);
}
.rl-nav { width: 52px; height: 52px; flex: 0 0 auto; }
.rl-close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 1rem);
  right: 1rem;
  width: 48px;
  height: 48px;
}
.rl-close:hover, .rl-nav:hover { background: var(--gradient-gold); color: var(--black); }

/* ---------- Variante compatta (home) ---------- */
.reels-compact { --card-w: clamp(190px, 20vw, 270px); }
.reels-compact .reels-info { margin-top: 2rem; }

/* ---------- Tema giorno ---------- */
body.light-mode .reels-filter { background: #fff; color: #444; }
body.light-mode .reels-filter:hover { color: #1A1A1A; }
body.light-mode .reels-filter.active { color: var(--black); }
body.light-mode .reels-filter span { color: var(--gold-dark); }
body.light-mode .reels-filter.active span { color: var(--black); }
body.light-mode .reels-ambient img { opacity: 0.3; }
body.light-mode .reels-card { box-shadow: 0 30px 60px rgba(0,0,0,0.25); }
body.light-mode .reels-title { color: #1A1A1A; }
body.light-mode .reels-text,
body.light-mode .reels-count { color: #555; }
body.light-mode .reels-chip { color: var(--gold-dark); }
body.light-mode .rl-info .reels-chip { color: var(--gold-light); }
body.light-mode .reels-arrow { background: rgba(255,255,255,0.85); color: var(--gold-dark); }
body.light-mode .reels-arrow:hover { background: var(--gradient-gold); color: var(--black); }
body.light-mode .reels .btn-secondary { color: #1A1A1A; border-color: rgba(201,168,76,0.5); background: rgba(255,255,255,0.7); }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .rl-body { flex-direction: column; gap: 1rem; }
  .rl-info { display: none; }
  .rl-nav { position: absolute; top: 50%; margin-top: -26px; }
  .rl-prev { left: 1rem; }
  .rl-next { right: 1rem; }
}
@media (max-width: 640px) {
  .reels { --card-w: min(62vw, 280px); }
  .reels-compact { --card-w: min(58vw, 250px); }
  .reels-arrow { width: 44px; height: 44px; margin-top: -22px; }
  .reels-prev { left: -6px; }
  .reels-next { right: -6px; }
  .reels-filters {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 0.4rem;
    margin-inline: -1rem;
    padding-inline: 1rem;
    scrollbar-width: none;
  }
  .reels-filter { flex: 0 0 auto; }
  .reels-hud-btn em { display: none; }
  .reels-sound:not(.on) em { display: inline; }
  .reels-text { min-height: 0; }
  .rl-player { height: auto; width: 100%; max-height: 82vh; }
  .rl-nav { width: 44px; height: 44px; margin-top: -22px; }
  .rl-prev { left: 0.4rem; }
  .rl-next { right: 0.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  .reels-card, .reels-info.swap > *, .reels-card.is-active::after, .reels-sound:not(.on) {
    transition: none;
    animation: none;
  }
}

/* ---------- Pagina Video ---------- */
.reels-page-section { overflow: hidden; }
.reels-cta-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: -1.5rem;
}
body.light-mode .reels-cta-actions .btn-secondary { color: #1A1A1A; border-color: rgba(201,168,76,0.5); }
