/* ============================================================
   GoLove AI Review — Comprehensive Responsive Patch
   Loads AFTER style.css, extras.css and offer-popup.css so
   these rules can override them on small screens.

   Strategy:
     • Tablet  ≤ 1024px
     • Phone   ≤ 768px
     • Small   ≤ 560px
     • Tiny    ≤ 380px (iPhone SE etc.)
     • Landscape phone (max-height: 480px and landscape)

   Focus areas:
     1. Tables — never overflow, always horizontally scrollable
        with a visible affordance.
     2. Images & video — never overflow viewport, never crop
        important content; use object-fit and max-width.
     3. Long text (URLs, code) — wrap with word-break.
     4. Section padding — tighter on mobile so content uses
        the full readable width.
     5. Touch targets — minimum 44×44 px.
     6. Safe-area padding for notched phones.
     7. Floating offer FAB — shrink + reposition on small screens.
   ============================================================ */


/* ============================================================
   CORE WEB VITALS — CLS (Cumulative Layout Shift) PREVENTION
   ------------------------------------------------------------
   Reserve layout space for images BEFORE they load so content
   doesn't jump as images stream in. We do this with aspect-ratio
   on every article image container instead of width/height
   attributes (cleaner, responsive, same CLS benefit).
   CLS is a direct Google ranking signal (Page Experience).
   ============================================================ */

/* Standalone article screenshots (figure > img) */
.media-screenshot img,
figure.media-screenshot img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 12px;
}

/* Two-up / three-up media splits */
.media-split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 20px 0; }
.media-split-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0; }
.media-split-2 figure img,
.media-split-3 figure img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}
.media-split-2 figcaption,
.media-split-3 figcaption {
  font-size: .8rem;
  color: var(--text-mute, #8c7fa3);
  text-align: center;
  padding-top: 6px;
}

/* Hero banner image wrapper — reserve 1200×630 (1.9:1) box */
.media-hero-banner {
  width: 100%;
  aspect-ratio: 1200 / 630;
  border-radius: 14px;
  overflow: hidden;
  margin-top: 20px;
  background: #1a0c2e;
}
.media-hero-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Hero banner video & inline media — reserve 16:9 / portrait box */
.media-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  background: #1a0c2e;
  position: relative;
}
.media-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-video-caption {
  position: absolute;
  left: 12px; bottom: 10px;
  font-size: .82rem;
  color: #fff;
  background: rgba(0,0,0,.45);
  padding: 4px 10px;
  border-radius: 8px;
  backdrop-filter: blur(6px);
}

/* Any article image without an explicit aspect-ratio gets a
   sensible default so it still reserves space. (Low specificity
   so the specific rules above win.) */
.article-section figure img,
.article-section > img {
  height: auto;
}

/* ========== GLOBAL SAFETY NETS ========== */

/* Stop everything from blowing past viewport width.
   This is the single most important rule for mobile. */
html, body {
  max-width: 100%;
  overflow-x: hidden;
  /* Safe-area on notched devices */
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

/* Every block element should respect viewport width */
*, *::before, *::after {
  max-width: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Images & video — universal containment */
img, video, iframe, svg, embed, object {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Long-word/URL/code wrap */
p, li, dd, dt, td, th, blockquote, summary, figcaption,
.article-section p, .article-section li,
.faq-q, .faq-a p, .callout-box, .callout-box div {
  overflow-wrap: anywhere;
  word-wrap: break-word;
  -webkit-hyphens: auto;
  hyphens: auto;
}

code, pre, kbd, samp {
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
}

/* Pre/code blocks with horizontal scroll instead of squishing */
pre {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}


/* ========== TABLES: bullet-proof horizontal scroll ==========
   Existing CSS already wraps tables in .table-wrap with
   overflow-x:auto + comp-table min-width:600px. We enhance with
   a visible scroll affordance (gradient edge fade) and reduce
   table min-width on small screens for tighter fit. */

.table-wrap {
  position: relative;
  margin: 18px 0;
  /* Soft inner shadow on the right edge hints "scroll me" */
  background:
    linear-gradient(90deg, transparent 0%, transparent 95%, rgba(255,62,165,0.08) 100%);
  border-radius: 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,62,165,0.4) transparent;
}
.table-wrap::-webkit-scrollbar { height: 6px; }
.table-wrap::-webkit-scrollbar-thumb {
  background: rgba(255,62,165,0.4);
  border-radius: 3px;
}
.table-wrap::-webkit-scrollbar-track { background: transparent; }

/* "Scroll to see more →" hint shown only on touch + when table overflows.
   Positioned absolute over the right edge of the wrap. */
.table-wrap::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 8px;
  width: 30px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(10,6,19,0.85));
  border-radius: 0 12px 12px 0;
  opacity: 0;
  transition: opacity .2s;
}
@media (max-width: 768px) {
  .table-wrap::after { opacity: 1; }
  /* Reduce table min-width slightly on phone so it fits more naturally */
  .comp-table { min-width: 520px; }
  .comp-table th, .comp-table td {
    padding: 10px 12px;
    font-size: .85rem;
  }
  .comp-table th { font-size: .72rem; }
}
@media (max-width: 480px) {
  .comp-table { min-width: 460px; }
  .comp-table th, .comp-table td {
    padding: 9px 10px;
    font-size: .82rem;
  }
}


/* ========== IMAGES & MEDIA — never get cut off ========== */

/* Article images: cap height on mobile so vertical posters
   don't push content off-screen. */
.media-inline img,
.media-inline video,
.review-screenshots img,
.feature-img,
.article-section img,
.media-video video {
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: cover;
}

/* Hero preview row — DON'T hide images on mobile (bad SEO).
   Instead, allow horizontal scroll. */
.hero-preview-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 12px;
}
@media (max-width: 768px) {
  .hero-preview-row {
    display: flex !important;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding-bottom: 6px;
    scrollbar-width: thin;
  }
  .hero-preview-row img {
    flex: 0 0 38vw;
    min-width: 130px;
    max-width: 180px;
    aspect-ratio: 3/4;
    height: auto;
    scroll-snap-align: start;
    display: block !important;        /* override the old "hide" rule */
  }
  /* Override the legacy rule that hid images 4 and 5 on mobile */
  .hero-preview-row img:nth-child(n+4) {
    display: block !important;
  }
}
@media (max-width: 480px) {
  .hero-preview-row img {
    flex: 0 0 44vw;
    min-width: 120px;
  }
}

/* Screenshot grid — at narrow widths force 1 col so faces aren't squished */
@media (max-width: 480px) {
  .screenshot-grid {
    grid-template-columns: 1fr !important;
  }
  .screenshot-grid img {
    aspect-ratio: 16/10;
    max-height: 240px;
  }
}

/* Companion preview cards — tighter grid on phones */
@media (max-width: 600px) {
  .char-preview-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px;
  }
  .cp-card span {
    font-size: .72rem;
    padding: 6px 4px;
  }
}
@media (max-width: 380px) {
  .char-preview-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}


/* ========== LAYOUT & TYPOGRAPHY TIGHTENING ========== */

/* Tablet (≤1024px): slightly narrower outer padding so content
   isn't pushed into thin column. */
@media (max-width: 1024px) {
  .page-layout { padding: 28px 22px 50px; }
  .header-container { padding: 14px 22px; }
  .site-footer { padding: 40px 22px 18px; }
  .footer-inner { gap: 24px; }
}

/* Phone (≤768px) */
@media (max-width: 768px) {
  /* Tighter horizontal padding so content uses more width */
  .page-layout { padding: 18px 14px 36px !important; }
  .header-container { padding: 10px 14px !important; gap: 10px !important; }
  .site-footer { padding: 36px 14px 16px !important; }

  /* Headings */
  .article-h1 {
    font-size: clamp(1.5rem, 6vw, 1.85rem) !important;
    line-height: 1.18;
    letter-spacing: -.015em;
  }
  .article-lead {
    font-size: 1rem !important;
    line-height: 1.6;
  }
  .article-section h2 {
    font-size: clamp(1.2rem, 5vw, 1.5rem) !important;
    line-height: 1.25;
  }
  .article-section h3 {
    font-size: clamp(1.05rem, 4.5vw, 1.15rem) !important;
  }
  .article-section { margin-top: 32px; }

  /* Article body slightly tighter */
  .article-section p,
  .article-section li {
    font-size: .96rem;
    line-height: 1.6;
  }

  /* CTA buttons full-width on mobile so they're easy to tap */
  .article-cta-row { gap: 10px; }
  .btn-pink, .btn-outline-pink, .btn-pink.btn-lg {
    width: 100%;
    justify-content: center;
    padding: 14px 18px;
    font-size: 1rem;
  }
  .btn-pink.btn-lg { padding: 16px 22px; font-size: 1.02rem; }

  /* Strip CTA: stack and breathe */
  .strip-cta {
    padding: 14px 16px;
    text-align: left;
    gap: 12px;
  }
  .strip-text { font-size: .92rem; line-height: 1.4; }

  /* Callout box: stack icon above text on tiny widths */
  .callout-box { padding: 14px 16px; gap: 10px; }
  .callout-box > div { font-size: .92rem; }

  /* Step header on how-to pages */
  .step-header { gap: 10px; flex-wrap: wrap; }
  .step-num { min-width: 38px; height: 38px; font-size: 1.05rem; border-radius: 10px; }

  /* Verdict card score ring — slightly smaller */
  .vc-ring { width: 120px; height: 120px; }
  .vc-num { font-size: 2.2rem; }
  .verdict-card { padding: 20px 16px; gap: 18px; }

  /* Coupon box: tighter so it doesn't dominate */
  .coupon-box { padding: 24px 16px; }
  .coupon-amount { font-size: clamp(2.5rem, 12vw, 3.2rem); }
  .coupon-amount span { font-size: 1.8rem; }
  .coupon-code-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .coupon-code-box {
    font-size: 1.05rem;
    padding: 12px 14px;
    text-align: center;
    word-break: break-all;
  }
  .copy-code-btn {
    justify-content: center;
    padding: 12px 16px;
  }
  .claim-btn {
    padding: 14px 20px;
    font-size: .98rem;
    text-align: left;
  }

  /* Article final CTA */
  .article-final-cta {
    padding: 28px 18px;
    margin: 36px 0 16px;
  }
  .article-final-cta h2 { font-size: 1.4rem !important; }
  .article-final-cta p { font-size: .95rem; }
  .cta-row { gap: 10px; }

  /* Footer */
  .footer-inner {
    grid-template-columns: 1fr 1fr !important;
    gap: 22px;
  }
  .footer-brand { grid-column: 1 / -1; }

  /* Article meta row: don't let it wrap onto 4 cramped lines */
  .article-meta { gap: 10px 16px; font-size: .78rem; }

  /* Breadcrumb on mobile */
  .breadcrumb {
    font-size: .78rem;
    flex-wrap: wrap;
    gap: 6px;
  }

  /* FAQ items */
  .faq-q {
    padding: 14px 16px;
    font-size: .92rem;
    gap: 10px;
  }
  .faq-a { padding: 0 16px; }
  .faq-a p { font-size: .9rem; }

  /* Pricing cards — single column with full breath */
  .price-card { padding: 22px 18px; }
  .price-amount { font-size: 2.1rem; }
  .price-amount .strike { font-size: 1.1rem; }

  /* Pros/Cons */
  .pros-box, .cons-box { padding: 18px 16px; }

  /* Free features grid — 2 col on phone */
  .free-features-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }
  .ff-card { padding: 16px 12px; }
  .ff-card i { font-size: 1.4rem; }
  .ff-card h4 { font-size: .92rem; }
  .ff-card p { font-size: .82rem; }
}

/* Small (≤560px) — finer tuning */
@media (max-width: 560px) {
  .article-section h2 {
    font-size: 1.25rem !important;
    padding-bottom: 10px;
  }
  .verdict-card {
    grid-template-columns: 1fr !important;
  }
  .vc-row {
    grid-template-columns: 1fr !important;
    gap: 4px;
  }
  .vc-val { text-align: left; }
}

/* Tiny screens (≤380px) — iPhone SE, Galaxy Fold closed, etc. */
@media (max-width: 380px) {
  .header-container { padding: 8px 10px !important; gap: 8px !important; }
  .page-layout { padding: 14px 10px 30px !important; }
  .article-h1 { font-size: 1.4rem !important; }
  .article-section h2 { font-size: 1.15rem !important; }
  .article-lead { font-size: .94rem !important; }

  /* Free features 1-col so cards aren't cramped */
  .free-features-grid {
    grid-template-columns: 1fr !important;
  }

  /* Footer: stack everything */
  .footer-inner {
    grid-template-columns: 1fr !important;
  }

  /* Coupon amount even smaller */
  .coupon-amount { font-size: 2.2rem; }
  .coupon-amount span { font-size: 1.4rem; }

  /* Brand text was already hidden — also shrink icon */
  .brand-icon { font-size: 1.2rem; }
  .mobile-toggle { padding: 8px 10px; font-size: 1rem; }
}

/* Landscape phones — keep header compact, prevent over-tall heros */
@media (max-height: 500px) and (orientation: landscape) {
  .site-header { position: relative; }   /* no sticky stealing vertical space */
  .article-h1 { font-size: 1.7rem !important; }
  .article-section { margin-top: 24px !important; }
  .vc-ring { width: 100px; height: 100px; }
}


/* ========== TOUCH-TARGET MINIMUMS (a11y + mobile-friendly) ========== */
@media (max-width: 768px) and (pointer: coarse) {
  .nav-tab,
  .toc-link,
  .faq-q,
  .header-cta,
  .footer-col a,
  .price-btn,
  .claim-btn,
  .btn-pink,
  .btn-outline-pink,
  .copy-code-btn {
    min-height: 44px;
  }
  /* Visible focus ring for keyboard users */
  a:focus-visible,
  button:focus-visible {
    outline: 2px solid var(--pink, #ff3ea5);
    outline-offset: 3px;
  }
}


/* ========== FLOATING OFFER FAB — reposition on small screens ========== */
@media (max-width: 600px) {
  .offer-fab {
    right: 12px !important;
    bottom: 12px !important;
    padding: 10px 14px !important;
    font-size: .82rem !important;
  }
  .offer-fab .offer-fab-badge { display: none !important; }

  /* Modal: tighter on tiny screens */
  .offer-modal-card {
    width: calc(100% - 24px) !important;
    max-width: none !important;
    margin: 12px !important;
    max-height: calc(100vh - 24px) !important;
    overflow-y: auto;
  }
}


/* ========== ACCESSIBILITY: reduce 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;
  }
}


/* ========== PRINT (because some users do print reviews) ========== */
@media print {
  .site-header,
  .toc-sidebar,
  .offer-fab,
  .offer-modal,
  .strip-cta,
  .article-cta-row,
  .article-final-cta {
    display: none !important;
  }
  body {
    background: #fff !important;
    color: #111 !important;
  }
  .article-section p,
  .article-section li,
  .article-section h2,
  .article-section h3,
  .article-h1 {
    color: #111 !important;
  }
  a { color: #c9184a !important; text-decoration: underline; }
  .comp-table { min-width: 0 !important; }
  .comp-table th, .comp-table td {
    background: #fff !important;
    color: #111 !important;
    border-bottom: 1px solid #ddd !important;
  }
}
