/* ============================================================
   CB AGENCY — Reels Page Styles
   reels.css
   ============================================================ */

/* === REELS CONTAINER === */
.reels-page {
  position: relative;
  width: 100%;
  height: 100svh;
  height: 100vh;
  overflow: hidden;
  background: #000;
  touch-action: none; /* we handle touch manually */
}

/* === REEL FEED (scrollable track) === */
.reels-feed {
  position: relative;
  width: 100%;
  height: 100%;
  will-change: transform;
  transition: transform 0.38s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.reels-feed.is-dragging {
  transition: none;
}

/* === SINGLE REEL ITEM === */
.reel-item {
  position: absolute;
  left: 0;
  width: 100%;
  height: 100svh;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  contain: layout style paint;
}

/* Position each reel */
.reel-item:nth-child(1) { top: 0; }
.reel-item:nth-child(2) { top: 100vh; }
.reel-item:nth-child(3) { top: 200vh; }
/* JS positions remaining items dynamically */

/* === VIDEO ELEMENT === */
.reel-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

/* === IMAGE REEL === */
.reel-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  user-select: none;
  -webkit-user-drag: none;
}

.reel-type-badge {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 56px);
  right: var(--sp-4);
  padding: 4px 10px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--r-full);
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
  backdrop-filter: blur(8px);
  z-index: 15;
  letter-spacing: 0.04em;
}

/* === GRADIENT OVERLAYS === */
.reel-overlay-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 180px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
  z-index: 2;
  pointer-events: none;
}

.reel-overlay-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 280px;
  background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.6) 50%, transparent 100%);
  z-index: 2;
  pointer-events: none;
}

/* === HEADER BAR (inside reel) === */
.reel-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px var(--sp-4);
  padding-top: calc(16px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

.reel-header-logo {
  height: 28px;
  width: auto;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
}

.reel-quality-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--r-full);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--c-accent);
  backdrop-filter: blur(8px);
}

.quality-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--c-accent);
}

/* === CATEGORY FILTER (top bar) === */
.reels-category-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(env(safe-area-inset-top) + 52px) var(--sp-4) var(--sp-2);
  z-index: 20;
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.reels-category-bar::-webkit-scrollbar { display: none; }

.cat-chip {
  flex-shrink: 0;
  padding: 6px 14px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--r-full);
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: all var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.cat-chip:hover,
.cat-chip.active {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #000;
}

/* === REEL INFO (bottom left) === */
.reel-info {
  position: absolute;
  bottom: calc(var(--nav-bottom) + var(--sp-4));
  left: var(--sp-4);
  right: 70px; /* space for action buttons */
  z-index: 10;
}

.reel-category-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  background: var(--c-accent-dim);
  border: 1px solid rgba(245,200,0,0.3);
  border-radius: var(--r-full);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--c-accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--sp-2);
}

.reel-title {
  font-family: var(--font-display);
  font-size: clamp(1rem, 3.5vw, 1.3rem);
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  margin-bottom: var(--sp-2);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.reel-desc {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.75);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* === ACTION BUTTONS (right side) === */
.reel-actions {
  position: absolute;
  bottom: calc(var(--nav-bottom) + var(--sp-6));
  right: var(--sp-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-5);
  z-index: 10;
}

.reel-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--t-spring);
  padding: 4px;
}

.reel-action-btn:active {
  transform: scale(0.85);
}

.action-icon-wrap {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-base);
}

.reel-action-btn:hover .action-icon-wrap,
.reel-action-btn.active .action-icon-wrap {
  background: rgba(245,200,0,0.25);
  border-color: rgba(245,200,0,0.5);
}

.reel-action-btn svg {
  width: 22px;
  height: 22px;
}

.action-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* Like button state */
.btn-like.liked .action-icon-wrap {
  background: rgba(224,52,52,0.25);
  border-color: rgba(224,52,52,0.5);
}
.btn-like.liked svg {
  color: #FF4C4C;
  animation: heart-pop var(--t-spring) forwards;
}

@keyframes heart-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* WhatsApp button */
.btn-whatsapp-reel .action-icon-wrap {
  background: rgba(37,211,102,0.2);
  border-color: rgba(37,211,102,0.4);
}
.btn-whatsapp-reel svg { color: #25D366; }
.btn-whatsapp-reel:hover .action-icon-wrap {
  background: rgba(37,211,102,0.4);
  border-color: rgba(37,211,102,0.7);
}

/* Mute/Unmute toggle */
.btn-mute-toggle svg {
  width: 20px;
  height: 20px;
}
.btn-mute-toggle .icon-muted { color: rgba(255,255,255,0.6); }
.btn-mute-toggle .icon-unmuted { color: #fff; }
.btn-mute-toggle:hover .action-icon-wrap {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.4);
}

/* === PAUSE INDICATOR === */
.pause-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  transition: all 0.2s ease;
  pointer-events: none;
}

.pause-indicator.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.pause-indicator.hide {
  transform: translate(-50%, -50%) scale(1.3);
  opacity: 0;
}

.pause-indicator svg {
  width: 32px;
  height: 32px;
  color: #fff;
}

/* === PROGRESS BAR === */
.reel-progress {
  position: absolute;
  bottom: var(--nav-bottom);
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255,255,255,0.2);
  z-index: 10;
}

.reel-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--c-accent), #FF8C00);
  width: 0%;
  transition: width 0.1s linear;
  border-radius: 0 2px 2px 0;
}

/* === SCROLL INDICATOR === */
.scroll-indicator {
  position: fixed;
  right: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 15;
}

.scroll-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transition: all var(--t-base);
}

.scroll-dot.active {
  background: var(--c-accent);
  transform: scaleY(2.5);
  border-radius: 2px;
}

/* === LOADING SPINNER === */
.reel-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  display: none;
}

.reel-loading.show { display: block; }

.spinner-ring {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(245,200,0,0.2);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* === EMPTY STATE === */
.reels-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  text-align: center;
  padding: var(--sp-8);
}

.reels-empty svg {
  width: 64px;
  height: 64px;
  color: var(--c-text-muted);
  margin-bottom: var(--sp-2);
}

.reels-empty h3 {
  font-size: 1.2rem;
  color: var(--c-text-secondary);
}

.reels-empty p {
  font-size: 0.875rem;
  color: var(--c-text-muted);
  max-width: 280px;
}

/* === SWIPE HINT === */
.swipe-hint {
  position: fixed;
  bottom: calc(var(--nav-bottom) + 40px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  color: rgba(255,255,255,0.5);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  z-index: 20;
  animation: swipe-hint-anim 2s ease-in-out 2s forwards;
  opacity: 0;
}

.swipe-hint svg {
  width: 24px;
  height: 24px;
  animation: swipe-arrow 1.5s ease-in-out infinite;
}

@keyframes swipe-hint-anim {
  0%   { opacity: 0; transform: translateX(-50%) translateY(10px); }
  20%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

@keyframes swipe-arrow {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

/* === DESKTOP LAYOUT === */
@media (min-width: 768px) {
  .reels-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--c-bg);
  }

  .reels-feed-wrapper {
    position: relative;
    width: 400px;
    height: calc(100vh - 32px);
    max-height: 800px;
    border-radius: var(--r-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.05);
  }

  .reels-feed {
    border-radius: var(--r-xl);
  }

  .reel-item {
    border-radius: var(--r-xl);
  }
}

@media (max-width: 767px) {
  .reels-feed-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
  }
}
