/* ========================================================================
 * REELS FEED — Instagram-style square grid with hover overlay
 * Light theme. Square thumbnails with object-fit cover.
 * Card body appears as gradient overlay on hover.
 * Modal styled as Instagram/TikTok reel viewer.
 * ======================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ── Scoped tokens ──────────────────────────────────────────────────────── */
.ag-social {
  --rf-font: 'Plus Jakarta Sans', var(--ag-font-sans, 'Poppins', system-ui, sans-serif);
  --rf-bg: #fafafa;
  --rf-surface: #ffffff;
  --rf-surface-hover: #f5f5f5;
  --rf-border: #dbdbdb;
  --rf-border-light: #efefef;
  --rf-text: #262626;
  --rf-text-secondary: #555555;
  --rf-text-muted: #8e8e8e;
  --rf-accent: #0095f6;
  --rf-accent-soft: rgba(0,149,246,0.08);
  --rf-gradient: linear-gradient(145deg, #2563eb, #4f46e5);
  --rf-danger: #ed4956;
  --rf-radius: 4px;
  --rf-radius-md: 8px;
  --rf-radius-lg: 12px;

  font-family: var(--rf-font);
  color: var(--rf-text);
  background: var(--rf-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Hero header ────────────────────────────────────────────────────────── */
.ag-social .ag-hero {
  background: var(--rf-surface);
  border: 1px solid var(--rf-border-light);
  border-radius: var(--rf-radius-lg);
  padding: 20px 24px;
}
.ag-social .ag-hero h1 {
  font-family: var(--rf-font);
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -0.02em;
  color: var(--rf-text);
}
.ag-social .ag-hero .sub {
  color: var(--rf-text-muted);
  font-size: 14px;
}

/* Buttons */
.ag-social .btn {
  font-family: var(--rf-font);
  font-weight: 600;
  font-size: 13px;
  border-radius: var(--rf-radius-md);
  transition: all 0.18s ease;
}
.ag-social .btn-outline-secondary {
  background: transparent;
  border-color: var(--rf-border);
  color: var(--rf-text);
}
.ag-social .btn-outline-secondary:hover {
  background: var(--rf-surface-hover);
  border-color: #bbb;
  color: var(--rf-text);
}
.ag-social .btn-primary {
  background: var(--button-gradient, linear-gradient(145deg, #2E74B8, #F1C9AE));
  border: none;
  color: #fff;
}
.ag-social .btn-primary:hover {
  background: #1877f2;
}
.ag-social .text-muted {
  color: var(--rf-text-muted) !important;
}

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.reels-feed-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 16px 0;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.reels-tab {
  padding: 7px 20px;
  border: 1px solid var(--rf-border);
  border-radius: 999px;
  background: var(--rf-surface);
  color: var(--rf-text-muted);
  font-family: var(--rf-font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  line-height: 1.5;
}
.reels-tab:hover {
  background: var(--rf-surface-hover);
  color: var(--rf-text);
  border-color: #bbb;
}
.reels-tab:focus-visible {
  outline: 2px solid var(--rf-accent);
  outline-offset: 2px;
}
.reels-tab.active {
  background: var(--button-gradient, linear-gradient(145deg, #2E74B8, #F1C9AE));
  color: #fff;
  border-color: #ffc107;
}

/* ── Search bar ──────────────────────────────────────────────────────────── */
.reels-search-bar .input-group {
  background: var(--rf-surface);
  border: 1px solid var(--rf-border-light);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.18s;
}
.reels-search-bar .input-group:focus-within {
  border-color: var(--rf-border);
}
.reels-search-bar .input-group-text {
  background: transparent;
  border: none;
  color: var(--rf-text-muted);
  padding-left: 14px;
}
.reels-search-bar .form-control {
  background: transparent;
  border: none;
  color: var(--rf-text);
  font-family: var(--rf-font);
  font-size: 14px;
  box-shadow: none !important;
}
.reels-search-bar .form-control::placeholder {
  color: var(--rf-text-muted);
}

/* ── Audio/Vibe filter pills ──────────────────────────────────────────── */
.ag-vibe-filters {
  display: flex;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0;
}
.ag-vibe-filters::-webkit-scrollbar { display: none; }
.ag-vibe-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--rf-text-muted);
  white-space: nowrap;
  margin-right: 4px;
}
.ag-vibe-pill {
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--rf-border-light);
  background: var(--rf-surface);
  color: var(--rf-text-muted);
  font-family: var(--rf-font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.ag-vibe-pill:hover {
  background: var(--rf-surface-hover);
  color: var(--rf-text);
  border-color: var(--rf-border);
}
.ag-vibe-pill.active {
  background: var(--button-gradient, linear-gradient(145deg, #2E74B8, #F1C9AE));
  color: #fff;
  border-color: #ffc107;
}

/* ── Mobile horizontal-scroll overrides for tabs & pills ─────────────── */
@media (max-width: 767px) {
  .reels-feed-tabs {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-left: 4px;
    padding-right: 24px; /* space for fade indicator */
  }
  .reels-feed-tabs::-webkit-scrollbar {
    display: none;
  }
  .reels-tab {
    white-space: nowrap;
    flex-shrink: 0;
  }
  .ag-vibe-pill {
    flex-shrink: 0;
  }
}


/* ════════════════════════════════════════════════════════════════════════
 * SQUARE GRID — CSS Grid overriding Bootstrap row
 * ════════════════════════════════════════════════════════════════════════ */
.ag-social .ag-stagger {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 0 !important;
}
/* Override Bootstrap col padding and sizing */
.ag-social .ag-stagger > [role="listitem"],
.ag-social .ag-stagger > .col-12,
.ag-social .ag-stagger > [class*="col-"] {
  width: auto !important;
  max-width: none !important;
  padding: 0 !important;
  margin: 0 !important;
  flex: none !important;
}
@media (max-width: 767.98px) {
  .ag-social .ag-stagger {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 479px) {
  .ag-social .ag-stagger {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}


/* ════════════════════════════════════════════════════════════════════════
 * CARD — square thumbnail with hover overlay
 * ════════════════════════════════════════════════════════════════════════ */
.ag-social .ag-card {
  position: relative;
  overflow: hidden;
  border: none;
  border-radius: var(--rf-radius);
  background: #1a1a1a;
  cursor: pointer;
}
.ag-social .ag-card.h-100 {
  height: auto !important;
}

/* Media thumbnail — square, object-fit cover */
.ag-social .ag-media {
  position: relative;
  background: #1a1a1a;
  overflow: hidden;
  border-radius: 0;
}
.ag-social .ag-media img,
.ag-social .ag-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
  display: block;
  transition: transform 0.3s ease;
}
.ag-social .ag-card:hover .ag-media img,
.ag-social .ag-card:hover .ag-media video {
  transform: scale(1.015);
}

/* Play overlay — small, bottom-right */
.ag-play-overlay {
  position: absolute;
  bottom: 8px;
  right: 8px;
  z-index: 2;
  pointer-events: none;
  opacity: 0.85;
}
.ag-play-overlay svg {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
}

/* ── Reset global .ag-card leaks ───────────────────────────────────────── */
.ag-social .ag-card::after { display: none; }

/* ── Card body — hover overlay ──────────────────────────────────────────── */
.ag-social .ag-card__body {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 4;
  background: linear-gradient(to top, rgba(0,0,0,0.82) 0%, rgba(0,0,0,0.4) 65%, transparent 100%);
  padding: 48px 12px 10px;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: none;
  opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: none;
}
.ag-social .ag-card:hover .ag-card__body {
  opacity: 1;
}

/* Owner row — white text for overlay (reset global absolute/size/border) */
.ag-social .ag-card__owner {
  position: static;
  width: auto;
  height: auto;
  border-radius: 0;
  border: none;
  background: none;
  box-shadow: none;
  overflow: visible;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.ag-card__owner-name {
  font-weight: 700;
  color: #fff;
}
.ag-card__owner-date {
  color: rgba(255,255,255,0.6);
  font-size: 11px;
}

/* Avatar */
.ag-social .ag-card__owner img,
.ag-social .ag-card-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.5);
}

/* Title & caption — truncated overlay text */
.ag-social .ag-title {
  font-weight: 700;
  color: #fff;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ag-social .ag-caption {
  color: rgba(255,255,255,0.8);
  font-size: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}
.ag-social .ag-card__body .ag-caption a[data-hashtag] {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  pointer-events: auto;
}
.ag-social .ag-card__body .ag-caption a[data-hashtag]:hover {
  text-decoration: underline;
}

/* Hashtag pills — hidden in overlay to keep it clean */
.ag-social .ag-card__body .ag-hashtag-pills {
  display: none;
}
/* Standalone hashtag styles (used in modal and elsewhere) */
.ag-hashtag-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.ag-hashtag-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
a.ag-hashtag-pill--link {
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

/* Footer stats — overlay style */
.ag-social .ag-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: none;
  padding: 2px 0 0;
}
.ag-card__stats {
  display: flex;
  gap: 12px;
}
.ag-stat {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 13px;
  color: rgba(255,255,255,0.95);
  font-weight: 600;
}
.ag-stat svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  flex-shrink: 0;
}

/* Kebab menu — hidden on feed cards (actions live inside the reel player) */
.ag-social .ag-card__body .ag-card__menu {
  display: none;
}

/* Quick actions — share & bookmark on hover overlay (reset global padding/border) */
.ag-social .ag-card__actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  padding: 0;
  border-top: none;
  justify-content: flex-start;
}
.ag-social .ag-card__action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.15s, transform 0.15s;
  padding: 0;
}
.ag-social .ag-card__action-btn:hover {
  background: rgba(255,255,255,0.3);
  transform: scale(1.1);
}
.ag-social .ag-card__action-btn.is-active svg {
  fill: #fff;
}

/* Pinned badge */
.ag-pinned-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--rf-font);
  background: rgba(0,0,0,0.6);
  color: #fff;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Location badge */
.ag-location-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--rf-font);
  background: rgba(0,0,0,0.55);
  color: #fff;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Empty state */
.ag-social .ag-empty {
  border: 1px dashed var(--rf-border);
  border-radius: var(--rf-radius-lg);
  padding: 40px 24px;
  background: var(--rf-surface);
  color: var(--rf-text-muted);
  grid-column: 1 / -1;
}
.ag-social .ag-empty .fw-semibold { color: var(--rf-text); }

/* Pagination */
.ag-social .pagination .page-link {
  border-radius: var(--rf-radius-md);
  background: var(--rf-surface);
  border-color: var(--rf-border-light);
  color: var(--rf-text);
  font-family: var(--rf-font);
}
.ag-social .pagination .page-link:hover {
  background: var(--rf-surface-hover);
  border-color: var(--rf-border);
}
.ag-social .pagination .active .page-link {
  background: var(--rf-accent);
  border-color: var(--rf-accent);
  color: #fff;
}

/* Focus */
.ag-social .ag-card a:focus-visible {
  outline: 2px solid var(--rf-accent);
  outline-offset: 2px;
  border-radius: var(--rf-radius);
}

/* Stagger entrance */
.ag-stagger > [role="listitem"] {
  opacity: 0;
  transform: scale(0.96);
  animation: rf-in 0.3s ease forwards;
}
.ag-stagger > [role="listitem"]:nth-child(1) { animation-delay: 0.02s; }
.ag-stagger > [role="listitem"]:nth-child(2) { animation-delay: 0.04s; }
.ag-stagger > [role="listitem"]:nth-child(3) { animation-delay: 0.06s; }
.ag-stagger > [role="listitem"]:nth-child(4) { animation-delay: 0.08s; }
.ag-stagger > [role="listitem"]:nth-child(5) { animation-delay: 0.10s; }
.ag-stagger > [role="listitem"]:nth-child(6) { animation-delay: 0.12s; }
.ag-stagger > [role="listitem"]:nth-child(n+7) { animation-delay: 0.14s; }
@keyframes rf-in {
  to { opacity: 1; transform: scale(1); }
}


/* ════════════════════════════════════════════════════════════════════════
 * FULLSCREEN VERTICAL FEED
 * ════════════════════════════════════════════════════════════════════════ */
.ag-fullscreen-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--rf-border);
  background: var(--rf-surface);
  cursor: pointer;
  color: var(--rf-text-muted);
  transition: background 0.15s, color 0.15s;
}
.ag-fullscreen-toggle:hover {
  background: var(--rf-surface-hover);
  color: var(--rf-text);
}
.ag-fullscreen-toggle.active {
  background: var(--rf-accent);
  color: #fff;
  border-color: var(--rf-accent);
}

.ag-social.ag-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
  overflow: hidden;
}
.ag-social.ag-fullscreen .container {
  max-width: 100%;
  padding: 0;
  height: 100vh;
}
.ag-social.ag-fullscreen .ag-hero {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: none;
  border-radius: 0;
  padding: 10px 20px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
}
.ag-social.ag-fullscreen .ag-hero .sub { color: rgba(255,255,255,0.5); }
.ag-social.ag-fullscreen .ag-hero h1 { color: #fff; font-size: 18px; }
.ag-social.ag-fullscreen .ag-hero .btn { border-color: rgba(255,255,255,0.2); color: #fff; }

.ag-social.ag-fullscreen .ag-stagger {
  display: flex !important;
  flex-direction: column;
  height: 100vh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0;
  padding: 0;
  gap: 0;
}
.ag-social.ag-fullscreen .ag-stagger::-webkit-scrollbar { display: none; }

.ag-social.ag-fullscreen .ag-fs-slide {
  flex: 0 0 100vh;
  max-width: 100%;
  width: 100%;
  scroll-snap-align: start;
  position: relative;
  padding: 0;
}

.ag-social.ag-fullscreen .ag-card {
  border: none;
  border-radius: 0;
  background: #000;
  height: 100vh !important;
  display: flex;
  flex-direction: column;
}
.ag-social.ag-fullscreen .ag-card:hover {
  opacity: 1;
}
.ag-social.ag-fullscreen .ag-card:hover .ag-media img,
.ag-social.ag-fullscreen .ag-card:hover .ag-media video {
  transform: none;
}
.ag-social.ag-fullscreen .ag-media {
  flex: 1;
  border-radius: 0;
  --bs-aspect-ratio: unset !important;
}
.ag-social.ag-fullscreen .ag-media img,
.ag-social.ag-fullscreen .ag-media video {
  object-fit: contain;
}

/* In fullscreen, always show the overlay */
.ag-social.ag-fullscreen .ag-card__body {
  opacity: 1;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  padding: 40px 20px 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  pointer-events: auto;
}
.ag-social.ag-fullscreen .ag-play-overlay { display: none; }

/* Stagger reset in fullscreen */
.ag-social.ag-fullscreen .ag-stagger > [role="listitem"] {
  opacity: 1;
  transform: none;
  animation: none;
}

/* Fullscreen tabs */
.ag-social.ag-fullscreen .reels-feed-tabs {
  padding: 0.5rem 0;
  margin-bottom: 0;
}
.ag-social.ag-fullscreen .reels-tab {
  border-color: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.5);
  background: transparent;
}
.ag-social.ag-fullscreen .reels-tab:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
}
.ag-social.ag-fullscreen .reels-tab.active {
  background: var(--button-gradient, linear-gradient(145deg, #2E74B8, #F1C9AE));
  color: #fff;
  border-color: #ffc107;
}


/* ════════════════════════════════════════════════════════════════════════
 * CC / CAPTION TOGGLE
 * ════════════════════════════════════════════════════════════════════════ */
.ag-modal-cc-btn {
  position: absolute;
  bottom: 60px;
  right: 16px;
  z-index: 20;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1.5px solid rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  letter-spacing: 0.5px;
}
.ag-modal-cc-btn:hover { background: rgba(0,0,0,0.7); }
.ag-modal-cc-btn.active {
  background: rgba(0,149,246,0.85);
  border-color: rgba(0,149,246,0.85);
}

video::cue {
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  padding: 2px 6px;
  border-radius: 4px;
}


/* ════════════════════════════════════════════════════════════════════════
 * REEL MODAL — Instagram/TikTok style single-column viewer
 * Full portrait video · Overlay info · Action bar on right
 * Comments open as a separate popup modal on top
 * Scoped to .ag-reel-modal to not affect photo modals
 *
 * NOTE: The modal lives OUTSIDE .ag-social in the DOM, so we must
 * re-declare the --rf-* custom properties here.
 * ════════════════════════════════════════════════════════════════════════ */
.ag-reel-modal {
  --rf-font: 'Plus Jakarta Sans', var(--ag-font-sans, 'Poppins', system-ui, sans-serif);
  --rf-bg: #fafafa;
  --rf-surface: #ffffff;
  --rf-surface-hover: #f5f5f5;
  --rf-border: #dbdbdb;
  --rf-border-light: #efefef;
  --rf-text: #262626;
  --rf-text-secondary: #555555;
  --rf-text-muted: #8e8e8e;
  --rf-accent: #0095f6;
  --rf-accent-soft: rgba(0,149,246,0.08);
  --rf-danger: #ed4956;
  --rf-radius: 4px;
  --rf-radius-md: 8px;
  --rf-radius-lg: 12px;
}

/* Backdrop — dark */
.ag-reel-modal .ag-modal__backdrop {
  background: rgba(0,0,0,0.85);
}

/* Dialog — tall portrait, centered */
.ag-reel-modal.ag-media-modal .ag-modal__dialog {
  background: #000;
  border: none;
  border-radius: var(--rf-radius-lg);
  box-shadow: 0 25px 60px rgba(0,0,0,0.6);
  overflow: hidden;
  height: min(95vh, 920px);
  width: min(calc(min(95vh, 920px) * 0.5625), 92vw);
  max-width: none;
}

/* Grid — single column, no side panel */
.ag-reel-modal .ag-modal__grid {
  grid-template-columns: 1fr !important;
}

/* Close button — top-right over video */
.ag-reel-modal.ag-media-modal .ag-modal__close {
  background: rgba(255,255,255,0.15);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  z-index: 9500;
  pointer-events: auto;
  transition: background 0.15s;
  top: 14px;
  right: 14px;
}
.ag-reel-modal.ag-media-modal .ag-modal__close:hover {
  background: rgba(255,255,255,0.3);
}

/* Media pane — full portrait video */
.ag-reel-modal .ag-modal__media {
  background: #000;
  border-radius: var(--rf-radius-lg);
  min-height: 0;
  position: relative;
}
.ag-reel-modal .ag-modal__media video {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: cover;
}
.ag-reel-modal .ag-modal__media video::-webkit-media-controls {
  display: none !important;
}
/* Bottom gradient for readability of overlay text */
.ag-reel-modal .ag-modal__media::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 45%;
  background: linear-gradient(transparent, rgba(0,0,0,0.65));
  pointer-events: none;
  border-radius: 0 0 var(--rf-radius-lg) var(--rf-radius-lg);
  z-index: 1;
}
/* Hide photo img in reel mode */
.ag-reel-modal #photoModalImg { display: none !important; }

/* Nav arrows — outside the video on left/right, or hidden */
.ag-reel-modal .ag-modal__nav {
  background: rgba(255,255,255,0.15) !important;
  border: none !important;
  z-index: 5;
}
.ag-reel-modal .ag-modal__nav:hover {
  background: rgba(255,255,255,0.3) !important;
}
/* Vertical navigation — up/down instead of left/right */
.ag-reel-modal .ag-modal__nav--prev {
  left: 16px !important;
  right: auto !important;
  top: 35% !important;
  transform: translateY(-50%) !important;
}
.ag-reel-modal .ag-modal__nav--next {
  left: 16px !important;
  right: auto !important;
  top: auto !important;
  bottom: 45% !important;
  transform: translateY(50%) !important;
}
/* SVG icons swapped to up/down by inline JS — no CSS rotation needed */

/* ── Reel Info Overlay — bottom-left on the video ────────────────────── */
.ag-reel-overlay {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 80px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #fff;
  font-family: var(--rf-font);
}
.ag-reel-overlay__user a {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}
.ag-reel-overlay__user img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.5);
  flex-shrink: 0;
}
.ag-reel-overlay__username {
  font-weight: 700;
  font-size: 14px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.ag-reel-overlay__caption {
  font-size: 13px;
  line-height: 1.4;
  color: rgba(255,255,255,0.95);
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ag-reel-overlay__caption a[data-hashtag] {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.55);
  pointer-events: auto;
}
.ag-reel-overlay__caption a[data-hashtag]:hover {
  color: #dbeafe;
  border-bottom-color: rgba(219,234,254,0.9);
}
.ag-reel-overlay__audio {
  font-size: 12px;
  color: rgba(255,255,255,0.75);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  display: none;
}

/* ── Action Bar — right side, vertical, Instagram-style ──────────────── */
.ag-reel-modal .ag-action-bar,
.ag-reel-modal .ag-action-bar[hidden] {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  position: absolute;
  right: 12px;
  bottom: 20px;
  z-index: 5;
  padding: 0;
  background: none;
  border: none;
}
/* Hide original like button — replaced by reaction picker */
.ag-reel-modal #actionBarLike {
  display: none !important;
}
.ag-reel-modal .ag-action-bar__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0;
  font-size: 0;
  transition: transform 0.15s;
}
.ag-reel-modal .ag-action-bar__btn:hover {
  transform: scale(1.12);
}
.ag-reel-modal .ag-action-bar__btn:active {
  transform: scale(0.92);
}
.ag-reel-modal .ag-action-bar__btn svg {
  width: 28px;
  height: 28px;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
}
.ag-reel-modal .ag-action-bar__btn.is-active svg {
  fill: #ed4956;
  stroke: #ed4956;
}
.ag-reel-modal .ag-action-bar__count {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
  font-family: var(--rf-font);
}

/* ── Reaction picker in action bar ───────────────────────────────────── */
.ag-reel-modal .ag-action-bar__react-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
}
.ag-reel-modal .ag-action-bar__react-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4) !important;
  background: rgba(255,255,255,0.1) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.ag-reel-modal .ag-action-bar__react-btn:hover {
  border-color: rgba(255,255,255,0.7) !important;
  background: rgba(255,255,255,0.2) !important;
  transform: scale(1.1);
}
.ag-reel-modal .ag-action-bar__react-btn.is-active {
  border-color: rgba(0,149,246,0.8) !important;
  background: rgba(0,149,246,0.2) !important;
  box-shadow: 0 0 0 3px rgba(0,149,246,0.2);
}
.ag-reel-modal .ag-action-bar__react-btn .ag-react-icons {
  position: relative;
  width: 28px;
  height: 28px;
}
.ag-reel-modal .ag-action-bar__react-btn .ag-react-icons span {
  position: absolute;
  font-size: 0.65rem;
  line-height: 1;
}
.ag-reel-modal .ag-action-bar__react-btn .ag-react-icons span:nth-child(1) { top: 0; left: 5px; }
.ag-reel-modal .ag-action-bar__react-btn .ag-react-icons span:nth-child(2) { top: 3px; right: 0; }
.ag-reel-modal .ag-action-bar__react-btn .ag-react-icons span:nth-child(3) { bottom: 0; left: 1px; }
.ag-reel-modal .ag-action-bar__react-btn .ag-react-icons span:nth-child(4) { bottom: 2px; right: 1px; }
.ag-reel-modal .ag-action-bar__react-btn .ag-react-icons span:nth-child(5) { top: 9px; left: 9px; }
/* Reaction popup — appears to the left of the trigger */
.ag-reel-modal .ag-react-picker--action .ag-react-pop {
  position: absolute;
  bottom: 0;
  right: calc(100% + 10px);
  left: auto;
  display: none;
  flex-direction: row;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  z-index: 20;
  white-space: nowrap;
}
.ag-reel-modal .ag-react-picker--action .ag-react-pop button {
  border: 0;
  background: #f8fafc;
  border-radius: 999px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}
.ag-reel-modal .ag-react-picker--action .ag-react-pop button:hover {
  transform: scale(1.2);
  background: #eef2ff;
}
.ag-reel-modal .ag-react-picker--action .ag-react-pop .ag-react-more {
  background: #eef2ff;
  color: #4f46e5;
  font-weight: 600;
}
.ag-reel-modal #reelReactCount {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
  font-family: var(--rf-font);
}

/* ── Side Panel — hidden, becomes comments popup modal ───────────────── */
/* NOTE: position: absolute (not fixed) because dialog has transform,
   which makes fixed-positioned descendants relative to the dialog anyway. */
.ag-reel-modal .ag-modal__side {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) scale(0.95);
  width: min(500px, 92vw);
  max-height: min(80vh, 700px);
  z-index: 9200;
  background: var(--rf-surface);
  border-radius: 16px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.5);
  padding: 0 !important;
  gap: 0 !important;
  flex-direction: column;
  overflow: hidden auto !important;
  min-width: 0 !important;
  border: none;
  /* Hidden by default */
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s 0.2s;
}
/* When comments are open */
.ag-reel-modal.is-comments-open .ag-modal__side {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
  transition-delay: 0s;
}
/* Hide non-comment content in comments modal */
.ag-reel-modal .ag-modal__side .ag-modal__user-row,
.ag-reel-modal .ag-modal__side .ag-modal__info,
.ag-reel-modal .ag-modal__side .ag-modal__share-btn,
.ag-reel-modal .ag-modal__side .ag-modal__divider {
  display: none !important;
}
/* Hide the reactions section (generic div wrapping .ag-react-area) */
.ag-reel-modal .ag-modal__side .ag-react-area {
  display: none !important;
}
.ag-reel-modal .ag-modal__side > div:has(.ag-react-area) {
  display: none !important;
}
/* Fallback for browsers without :has() */
.ag-reel-modal .ag-modal__side > div > .text-muted.small {
  display: none !important;
}

/* Comments header */
.ag-reel-comments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rf-border-light);
  flex-shrink: 0;
  background: var(--rf-surface);
}
.ag-reel-comments-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--rf-text);
  font-family: var(--rf-font);
}
.ag-reel-comments-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--rf-surface-hover);
  color: var(--rf-text-muted);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.ag-reel-comments-close:hover {
  background: #e0e0e0;
  color: var(--rf-text);
}

/* Comments backdrop — covers the dialog area (not viewport, since dialog has transform) */
.ag-reel-comments-backdrop {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 9100;
}
.ag-reel-modal.is-comments-open .ag-reel-comments-backdrop {
  display: block;
}

/* Comments section inside modal */
.ag-reel-modal .ag-comments {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-top: 0;
  overflow: visible;
  padding: 0 20px;
}
.ag-reel-modal .ag-comments > .text-muted.small {
  display: none !important;
}
.ag-reel-modal .ag-comments__list {
  flex: 1;
  overflow-y: auto;
  border: none !important;
  background: transparent !important;
  padding: 12px 0;
  margin-top: 0;
  min-height: 0;
  max-height: none;
  font-size: 14px;
  color: var(--rf-text-muted);
  scrollbar-width: thin;
  scrollbar-color: var(--rf-border) transparent;
}
.ag-reel-modal .ag-comments__list::-webkit-scrollbar { width: 4px; }
.ag-reel-modal .ag-comments__list::-webkit-scrollbar-thumb { background: var(--rf-border); border-radius: 4px; }
.ag-reel-modal .ag-comments__list::-webkit-scrollbar-track { background: transparent; }

.ag-reel-modal .ag-cmt-bubble,
.ag-reel-modal .ag-cmt-body { background: var(--rf-surface-hover) !important; border-radius: 12px !important; }
.ag-reel-modal .ag-cmt-name { color: var(--rf-text) !important; }
.ag-reel-modal .ag-cmt-name a { color: var(--rf-text) !important; }
.ag-reel-modal .ag-cmt-name .handle { color: var(--rf-text-muted) !important; }
.ag-reel-modal .ag-cmt-text { color: var(--rf-text-secondary) !important; }
.ag-reel-modal .ag-cmt-close { background: var(--rf-surface-hover) !important; color: var(--rf-text-muted) !important; }
.ag-reel-modal .ag-cmt-close:hover { background: #e8e8e8 !important; }
.ag-reel-modal .ag-cmt-actions { color: var(--rf-text-muted) !important; }
.ag-reel-modal .ag-cmt-actions .action-link { color: var(--rf-text-muted) !important; }
.ag-reel-modal .ag-cmt-actions .action-link:hover { color: var(--rf-accent) !important; }
.ag-reel-modal .ag-cmt-children { border-left-color: var(--rf-border-light) !important; }
.ag-reel-modal .ag-cmt-reply textarea {
  background: var(--rf-surface) !important;
  border-color: var(--rf-border-light) !important;
  color: var(--rf-text) !important;
}
.ag-reel-modal .ag-cmt-reply textarea:focus { border-color: var(--rf-border) !important; outline: none; }

/* Comment form — pinned at bottom of comments modal */
.ag-reel-modal .ag-comment-form {
  border-top: 1px solid var(--rf-border-light);
  padding: 12px 20px;
  margin: 0 -20px;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.ag-reel-modal .ag-comment-form textarea {
  background: var(--rf-surface);
  border: 1px solid var(--rf-border-light);
  border-radius: 20px;
  color: var(--rf-text);
  font-family: var(--rf-font);
  font-size: 14px;
  min-height: 40px;
  padding: 9px 14px;
  resize: none;
}
.ag-reel-modal .ag-comment-form textarea::placeholder { color: var(--rf-text-muted); }
.ag-reel-modal .ag-comment-form textarea:focus { border-color: var(--rf-border); box-shadow: none; outline: none; }
.ag-reel-modal .ag-comment-form .btn-primary {
  background: transparent;
  border: none;
  color: var(--rf-accent);
  font-family: var(--rf-font);
  font-weight: 700;
  font-size: 14px;
  padding: 0 8px;
  height: auto;
  min-height: 0;
}
.ag-reel-modal .ag-comment-form .btn-primary:hover { color: #1877f2; }
.ag-reel-modal .ag-emoji-trigger { color: var(--rf-text-muted); background: none; border: none; cursor: pointer; }
.ag-reel-modal .ag-emoji-trigger:hover { color: var(--rf-text); }

/* Sign-in alert */
.ag-reel-modal .alert-light {
  background: var(--rf-surface-hover) !important;
  border-color: var(--rf-border-light) !important;
  color: var(--rf-text-muted) !important;
}

/* Mention autocomplete */
.ag-reel-modal .ag-mention-list {
  background: var(--rf-surface) !important;
  border: 1px solid var(--rf-border-light) !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08) !important;
}
.ag-reel-modal .ag-mention-item:hover { background: var(--rf-surface-hover) !important; }

/* CC button — repositioned for single-column mode */
.ag-reel-modal .ag-modal-cc-btn {
  top: 14px;
  left: 16px;
  right: auto;
  bottom: auto;
  z-index: 9300;
  backdrop-filter: blur(2px);
}

/* Video progress bar */
.ag-reel-modal .ag-video-progress {
  z-index: 6;
}

/* ── Mobile — smaller dialog ── */
@media (max-width: 600px) {
  .ag-reel-modal.ag-media-modal .ag-modal__dialog {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
  .ag-reel-modal .ag-modal__media {
    border-radius: 0;
  }
  .ag-reel-modal .ag-modal__media::after {
    border-radius: 0;
  }
  .ag-reel-modal.ag-media-modal .ag-modal__close {
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
  }
  .ag-reel-modal .ag-modal-cc-btn {
    top: 10px;
    left: 10px;
  }
  .ag-reel-modal .ag-reel-overlay {
    bottom: 12px;
    left: 12px;
    right: 64px;
  }
  .ag-reel-modal .ag-action-bar {
    right: 8px !important;
    bottom: 14px !important;
    gap: 12px !important;
  }
  .ag-reel-modal .ag-modal__side {
    width: min(500px, 95vw);
    max-height: 85vh;
  }
  .ag-reel-modal .ag-comments {
    overflow: visible;
    flex: 1;
    min-height: 0;
  }
  .ag-reel-modal .ag-comments__list {
    max-height: 50vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .ag-reel-modal .ag-comment-form,
  .ag-comment-form {
    flex-shrink: 0;
    margin: 0;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid var(--rf-border, #e5e7eb);
  }
  .ag-reel-modal .ag-comment-form .btn,
  .ag-reel-modal .ag-comment-form button[type="submit"],
  .ag-comment-form .btn,
  .ag-comment-form button[type="submit"] {
    flex-shrink: 0;
    min-width: auto;
    padding: 6px 12px;
  }
}


/* ════════════════════════════════════════════════════════════════════════
 * MOBILE VERTICAL SCROLL FEED — Full-screen swipe (< 768px)
 * ════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767.98px) {
  .ag-social.ag-mobile-feed .container { max-width: 100%; padding: 0; }
  .ag-social.ag-mobile-feed .ag-hero { display: none; }
  .ag-social.ag-mobile-feed .reels-feed-tabs { display: none; }
  .ag-social.ag-mobile-feed .reels-search-bar { display: none; }
  .ag-social.ag-mobile-feed #activeHashtagBadge { display: none; }
  .ag-social.ag-mobile-feed .ag-vibe-filters { display: none; }
  .ag-social.ag-mobile-feed .pagination { display: none; }

  .ag-social.ag-mobile-feed .ag-stagger {
    display: block !important;
    height: 100vh;
    height: 100dvh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0;
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: #000;
  }
  .ag-social.ag-mobile-feed .ag-stagger::-webkit-scrollbar { display: none; }

  .ag-social.ag-mobile-feed .ag-stagger > [role="listitem"] {
    flex: 0 0 100vh;
    flex: 0 0 100dvh;
    scroll-snap-align: start;
    opacity: 1;
    transform: none;
    animation: none;
  }

  .ag-social.ag-mobile-feed .ag-card {
    border-radius: 0;
    height: 100vh !important;
    height: 100dvh !important;
    background: #000;
  }
  .ag-social.ag-mobile-feed .ag-media {
    --bs-aspect-ratio: unset !important;
    height: 100%;
    border-radius: 0;
  }
  .ag-social.ag-mobile-feed .ag-media img,
  .ag-social.ag-mobile-feed .ag-media video {
    object-fit: cover;
    height: 100%;
  }

  /* Always show overlay in mobile feed */
  .ag-social.ag-mobile-feed .ag-card__body {
    opacity: 1;
    pointer-events: auto;
    padding: 60px 16px 24px 16px;
    padding-right: 72px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .ag-social.ag-mobile-feed .ag-play-overlay { display: none; }

  /* Right-side action bar */
  .ag-mobile-actions {
    position: absolute;
    right: 12px;
    bottom: 120px;
    bottom: calc(120px + env(safe-area-inset-bottom, 0px));
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
  }
  .ag-mobile-actions__btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 0;
  }
  .ag-mobile-actions__btn svg {
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 1px 4px rgba(0,0,0,0.5));
  }
  .ag-mobile-actions__count {
    font-size: 12px;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  }

  /* Back button for mobile feed */
  .ag-mobile-feed-back {
    position: fixed;
    top: 16px;
    top: calc(16px + env(safe-area-inset-top, 0px));
    left: 16px;
    left: calc(16px + env(safe-area-inset-left, 0px));
    z-index: 9999;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
  }
  .ag-social.ag-mobile-feed .ag-mobile-feed-back { display: flex; }
}

/* Hide mobile-only elements on desktop */
@media (min-width: 768px) {
  .ag-mobile-actions { display: none !important; }
  .ag-mobile-feed-back { display: none !important; }
  .ag-mobile-feed-enter { display: none !important; }
}


/* ════════════════════════════════════════════════════════════════════════
 * REDUCED MOTION
 * ════════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .ag-social .ag-media img,
  .ag-social .ag-media video,
  .ag-play-overlay,
  .ag-social .ag-card,
  .ag-card__body,
  .reels-tab {
    transition: none;
  }
  .ag-stagger > [role="listitem"] {
    opacity: 1;
    transform: none;
    animation: none;
  }
  .ag-social.ag-fullscreen .ag-stagger {
    scroll-snap-type: none;
  }
}

/* ========================================
 * MOBILE CARD SIZING FIXES
 * ======================================== */
@media (max-width: 767px) {
  .ag-card__body {
    padding: 32px 8px 8px;
  }
  .ag-card__footer {
    gap: 4px;
  }
  .ag-card__actions {
    gap: 4px;
  }
  .ag-card__actions .ag-card__action-btn {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }
}
