/* ============================================
   GoLove AI Review — Extra utility styles
   Loaded after style.css
   ============================================ */

/* ===== MOVE TOC SIDEBAR TO THE RIGHT ===== */
/* Article first, TOC second — but keep source order (TOC first in HTML)
   by reordering grid columns. */
@media (min-width: 1101px) {
  .page-layout {
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 56px;
  }
  /* TOC appears in column 2 (right) */
  .toc-sidebar {
    order: 2;
    grid-column: 2;
    padding-right: 0;
    padding-left: 8px;
    border-left: 1px solid var(--border);
  }
  /* Article appears in column 1 (left) */
  .article {
    order: 1;
    grid-column: 1;
    max-width: 880px;
    margin-left: auto;
    margin-right: 0;
  }
  /* Flip active indicator to the right edge so it points toward the content */
  .toc-link {
    border-left: 2px solid transparent;
    border-right: 2px solid transparent;
    padding-left: 16px;
  }
  .toc-link.active {
    border-left-color: transparent;
    border-right-color: var(--pink, #ff3ea5);
  }
}

/* Ordered step list (used on How to Use page) */
.step-list {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 1.5rem 0;
}
.step-list li {
  counter-increment: step;
  position: relative;
  padding: 1rem 1rem 1rem 3.5rem;
  margin-bottom: 0.75rem;
  background: rgba(255, 77, 109, 0.06);
  border-left: 3px solid #ff4d6d;
  border-radius: 8px;
  color: #e6e6f0;
  line-height: 1.6;
}
.step-list li::before {
  content: counter(step);
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff4d6d, #c9184a);
  color: #fff;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  box-shadow: 0 4px 12px rgba(255, 77, 109, 0.35);
}

/* Small color helpers if missing */
.green { color: #4ade80 !important; }
.red   { color: #ff4d6d !important; }
.pink  { color: #ff4d6d; }

/* ===== MEDIA: HERO BANNER ===== */
.media-hero-banner {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  margin: 24px 0;
  border: 1px solid rgba(255,62,165,0.2);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.media-hero-banner img,
.media-hero-banner video {
  width: 100%;
  display: block;
  max-height: 420px;
  object-fit: cover;
}

/* ===== MEDIA: VIDEO PLAYER ===== */
.media-video {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  margin: 20px 0;
  background: #000;
  border: 1px solid rgba(255,62,165,0.2);
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
}
.media-video video {
  width: 100%;
  display: block;
  max-height: 480px;
  object-fit: cover;
}
.media-video-caption {
  background: rgba(255,62,165,0.07);
  border-top: 1px solid rgba(255,62,165,0.15);
  padding: 8px 14px;
  font-size: .82rem;
  color: #b5a8c9;
  display: flex;
  align-items: center;
  gap: 7px;
}
.media-video-caption i { color: #ff4d6d; }

/* ===== MEDIA: SCREENSHOT (single image) ===== */
.media-screenshot {
  margin: 22px 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
}
.media-screenshot img {
  width: 100%;
  display: block;
}
.media-screenshot figcaption {
  background: rgba(255,255,255,0.04);
  padding: 8px 14px;
  font-size: .82rem;
  color: #8c7fa3;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ===== MEDIA: 2-COL IMAGE SPLIT ===== */
.media-split-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 22px 0;
}
.media-split-2 figure,
.media-split-3 figure {
  border-radius: 12px;
  overflow: hidden;
  margin: 0;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}
.media-split-2 img,
.media-split-3 img {
  width: 100%;
  display: block;
  height: 220px;
  object-fit: cover;
}
.media-split-2 figcaption,
.media-split-3 figcaption {
  padding: 7px 12px;
  font-size: .78rem;
  color: #8c7fa3;
  background: rgba(255,255,255,0.03);
}

/* ===== MEDIA: 3-COL IMAGE GRID ===== */
.media-split-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 22px 0;
}
.media-split-3 img {
  height: 190px;
}

/* ===== MEDIA: COMPANION GALLERY GRID ===== */
.companion-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 24px 0;
}
.companion-card {
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255,62,165,0.15);
  box-shadow: 0 4px 18px rgba(0,0,0,0.4);
  background: #120a1f;
  transition: transform .2s, box-shadow .2s;
  cursor: pointer;
}
.companion-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 28px rgba(255,62,165,0.25);
}
.companion-card img,
.companion-card video {
  width: 100%;
  height: 240px;
  object-fit: cover;
  display: block;
}
.companion-card-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 28px 12px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,0.82));
  color: #fff;
  font-size: .88rem;
  font-weight: 600;
}

/* ===== MEDIA: VIDEO COMPANION GRID ===== */
.video-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 24px 0;
}
.video-card {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255,62,165,0.15);
  box-shadow: 0 4px 18px rgba(0,0,0,0.4);
  background: #000;
  position: relative;
  transition: transform .2s, box-shadow .2s;
}
.video-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 28px rgba(255,62,165,0.25);
}
.video-card video {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}
.video-card-label {
  padding: 8px 12px;
  background: rgba(18,10,31,0.95);
  color: #e6e6f0;
  font-size: .82rem;
  font-weight: 500;
  border-top: 1px solid rgba(255,62,165,0.12);
  display: flex;
  align-items: center;
  gap: 6px;
}
.video-card-label i { color: #ff4d6d; font-size: .75rem; }

/* ===== MEDIA: INLINE SIDE-BY-SIDE (image + text) ===== */
.media-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: center;
  margin: 24px 0;
}
.media-inline.reverse { direction: rtl; }
.media-inline.reverse > * { direction: ltr; }
.media-inline img,
.media-inline video {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 6px 22px rgba(0,0,0,0.45);
  display: block;
}
.media-inline-text h3 { margin-bottom: 10px; }

/* ===== MEDIA: USER REVIEW SCREENSHOTS ===== */
.review-screenshots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 22px 0;
}
.review-screenshots img {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  display: block;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .companion-grid { grid-template-columns: repeat(2, 1fr); }
  .video-grid     { grid-template-columns: repeat(2, 1fr); }
  .media-split-3  { grid-template-columns: 1fr 1fr; }
  .media-inline   { grid-template-columns: 1fr; }
  .media-inline.reverse { direction: ltr; }
}
@media (max-width: 600px) {
  .companion-grid  { grid-template-columns: repeat(2, 1fr); }
  .video-grid      { grid-template-columns: 1fr 1fr; }
  .media-split-2   { grid-template-columns: 1fr; }
  .review-screenshots { grid-template-columns: 1fr; }
  .companion-card img, .companion-card video { height: 180px; }
  .video-card video { height: 160px; }
}

/* ============================================================
   PERFORMANCE OPTIMIZATIONS
   - content-visibility lets the browser skip rendering of
     off-screen sections until needed (huge perf win on long pages).
   - contain-intrinsic-size reserves space so the scrollbar
     doesn't jump as sections render in.
   - Smooth scrolling + GPU promotion for media cards.
   ============================================================ */
html { scroll-behavior: smooth; }

/* Defer painting of off-screen IMAGE-ONLY sections (NOT
   video grids — content-visibility forces a re-render when a
   video re-enters viewport, which causes scroll jank). */
.article-section,
.review-screenshots,
.faq-item,
.comp-table {
  content-visibility: auto;
  contain-intrinsic-size: auto 600px;
}

/* === VIDEO PERFORMANCE ===
   `contain: strict` confines layout/paint/style work to the
   card boundary — so a video repainting its frame never
   invalidates anything outside the card.
   `isolation: isolate` forces a separate compositing layer
   without `will-change` (which leaks memory if applied
   permanently to many elements).
   `translate3d(0,0,0)` promotes the layer to the GPU. */
.companion-card,
.video-card {
  contain: layout paint style;
  isolation: isolate;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
}

/* Prevent layout shift while video metadata loads */
.media-video video,
.companion-card video,
.video-card video,
.media-inline video,
.media-split-2 video,
.media-split-3 video {
  aspect-ratio: 9 / 16;
  background: #1a0c2e;
  /* Each video gets its own compositor layer so its repaints
     don't ripple into neighbouring elements. */
  transform: translateZ(0);
  will-change: auto; /* don't lock layers permanently */
  pointer-events: none; /* videos are decorative; skip hit-test */
}
.media-hero-banner video {
  aspect-ratio: 16 / 9;
  transform: translateZ(0);
}

/* Cap how big any individual video can ever paint. Smaller
   surface = faster decode + composite per frame. */
.companion-card video,
.video-card video {
  max-height: 360px;
  object-fit: cover;
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
