/* =========================================
   D2C Prime — Responsive Stylesheet (responsive.css)
   ========================================= */

/* ===== GLOBAL OVERFLOW PREVENTION ===== */
html, body {
  width: 100%;
  overflow-x: hidden;
}

.features-section,
.analytics-section {
  overflow: hidden;
}

/* ===== TABLETS & SMALL LAPTOPS (max-width: 1100px) ===== */
@media (max-width: 1100px) {
  .why-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 32px 40px;
  }
  .analytics-frame {
    flex-direction: column;
  }
  .af-sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 16px 20px;
    gap: 0;
  }
  .af-nav {
    flex-direction: row;
    overflow-x: auto;
    flex: 1;
    gap: 2px;
    padding: 0 12px;
  }
  .af-kpi-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Prevent analytics badges overflow on medium screens */
  .af-1 {
    left: 10px;
    bottom: -10px;
  }
  .af-2 {
    right: 10px;
    top: -10px;
  }
}

/* ===== TABLETS & PHONES IN LANDSCAPE (max-width: 900px) ===== */
@media (max-width: 900px) {
  .hero-inner {
    grid-template-columns: 1fr;
    gap: 60px;
    padding-top: 60px;
  }
  .hero-visual {
    overflow: visible;
    padding: 20px 0;
  }
  .float-card {
    padding: 8px 12px;
    border-radius: 12px;
    gap: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  }
  .fc-icon {
    font-size: 16px;
  }
  .fc-label {
    font-size: 8px;
  }
  .fc-value {
    font-size: 10px;
  }
  .float-card-1 {
    display: flex;
    top: -15px;
    left: -15px;
  }
  .float-card-2 {
    display: flex;
    bottom: 30px;
    left: -15px;
  }
  .float-card-3 {
    display: flex;
    top: 15px;
    right: -15px;
  }
  .feature-block-inner {
    grid-template-columns: 1fr;
    gap: 40px;
    direction: ltr !important;
  }
  .contact-inner {
    grid-template-columns: 1fr;
    gap: 48px;
  }
  .timeline-left {
    padding-right: calc(50% + 20px);
  }
  .timeline-right {
    padding-left: calc(50% + 20px);
  }
  .timeline-content {
    padding: 20px;
  }
  .footer-inner {
    grid-template-columns: 1fr;
    gap: 48px;
  }
  .footer-links {
    grid-template-columns: repeat(2, 1fr);
  }
  .testimonial-card {
    flex: 0 0 80%;
  }

  /* Pricing split */
  .pricing-split {
    grid-template-columns: 1fr;
    gap: 48px;
  }
  .pricing-split::before {
    display: none;
  }
  .pricing-left {
    padding-right: 0;
  }
  .pricing-tiles {
    padding-left: 0;
  }
  .pricing-cta {
    align-self: stretch;
    justify-content: center;
  }

  /* Hide analytics float cards to prevent overflow */
  .analytics-float {
    display: none;
  }
}

/* ===== PHONES (max-width: 640px) ===== */
@media (max-width: 640px) {
  /* Header Adjustments to prevent overflow */
  .site-header {
    height: 64px; /* Slightly shorter on mobile */
  }
  .header-inner {
    gap: 16px; /* Decrease gap */
  }
  .logo-img {
    height: 36px; /* Smaller logo */
  }
  .header-cta .btn-primary {
    font-size: 13px;
    padding: 8px 14px; /* More compact CTA */
  }
  .site-header .header-nav, 
  .site-header .header-cta .btn-ghost {
    display: none;
  }
  .mobile-toggle {
    display: flex;
    margin-left: 0; /* Let flex alignment handle placement */
  }
  .header-cta {
    margin-left: auto;
  }
  .container {
    padding: 0 16px; /* Thinner padding */
  }
  
  /* Trusted Brands Mobile Header Override */
  .trusted-line {
    display: none;
  }
  .trusted-title-wrap {
    justify-content: center;
  }
  .trusted-title {
    white-space: normal;
    text-align: center;
  }

  /* Hero & Content */
  .hero-actions {
    flex-direction: column;
    align-items: flex-start;
  }
  .hero-actions .btn {
    width: 100%;
    justify-content: center;
  }
  .kpi-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .dash-bottom-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .why-grid {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Footer links layout */
  .footer-links {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
  /* Span newsletter full width on 2-col mobile footer */
  .footer-links .footer-col:last-child {
    grid-column: span 2;
  }
  .footer-bottom-inner {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }

  /* Timeline */
  .timeline-line {
    display: none;
  }
  .timeline-item {
    display: block;
    padding: 0;
    margin-bottom: 24px;
  }
  .timeline-dot {
    display: none;
  }
  .timeline-content {
    max-width: 100%;
  }

  /* Dashboard and Testimonials */
  .testimonial-card {
    flex: 0 0 90%;
  }
  .dashboard-shell {
    font-size: 11px;
    border-radius: var(--radius-md);
  }
  .dashboard-header {
    padding: 8px 12px;
  }
  .dash-dots .dot {
    width: 8px;
    height: 8px;
  }
  .dash-title {
    font-size: 10px;
  }
  .dash-live {
    font-size: 9px;
  }
  .dashboard-body {
    padding: 12px;
    gap: 10px;
  }
  .kpi-card {
    padding: 8px 6px;
    border-radius: 8px;
    gap: 2px;
    align-items: center;
    text-align: center;
  }
  .kpi-label {
    font-size: 8px;
    letter-spacing: 0.02em;
  }
  .kpi-value {
    font-size: 12px;
    font-weight: 700;
  }
  .kpi-delta {
    font-size: 8px;
  }
  .chart-area {
    padding: 10px;
    border-radius: 10px;
  }
  .chart-label {
    font-size: 8px;
    margin-bottom: 6px;
  }
  .mini-chart {
    height: 55px;
  }
  .channel-card, .funnel-card {
    padding: 10px;
    border-radius: 10px;
  }
  .channel-title, .funnel-title {
    font-size: 8px;
    margin-bottom: 8px;
  }
  .channel-bars {
    gap: 6px;
  }
  .channel-bar-item {
    font-size: 10px;
    gap: 6px;
  }
  .channel-bar-item span:first-child {
    width: 45px;
  }
  .channel-bar-item span:last-child {
    width: 32px;
  }
  .funnel-steps {
    gap: 4px;
  }
  .funnel-step {
    font-size: 10px;
  }

  /* Analytics Frame mobile adjustments */
  .af-sidebar {
    padding: 12px 16px;
  }
  .af-main {
    padding: 16px;
    gap: 16px;
  }
  .af-topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .af-kpi-strip {
    grid-template-columns: 1fr;
  }
}

/* ===== SMALL PHONES (max-width: 480px) ===== */
@media (max-width: 480px) {
  /* Smaller float cards spacing */
  .float-card-1 {
    left: -8px;
    top: -10px;
  }
  .float-card-2 {
    left: -8px;
    bottom: 12px;
  }
  .float-card-3 {
    right: -8px;
    top: 10px;
  }
  /* Pricing */
  .pricing-tiles {
    grid-template-columns: 1fr;
  }
  .ptile {
    padding: 22px 20px;
  }

  /* Cohort grid responsiveness to prevent overflow */
  .cohort-cells {
    gap: 2px;
  }
  .cohort-cell {
    width: clamp(34px, 10vw, 44px);
    height: 24px;
    font-size: 9px;
  }

  /* Form & Card Paddings */
  .cf-form {
    padding: 20px;
  }
  .testimonial-card {
    padding: 24px 20px;
  }

  /* Stack footer in single column on extra small screens */
  .footer-links {
    grid-template-columns: 1fr;
  }
  .footer-links .footer-col:last-child {
    grid-column: span 1;
  }
}

/* ===== EXTRA EXTRA SMALL PHONES (max-width: 400px) ===== */
@media (max-width: 400px) {
  .header-inner {
    gap: 10px; /* Even tighter gap */
  }
  .logo-img {
    height: 30px; /* Smallest logo size */
  }
  .header-cta .btn-primary {
    font-size: 12px;
    padding: 6px 10px;
  }
  .container {
    padding: 0 12px;
  }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  .float-card, 
  .hero-scroll-hint, 
  .live-dot, 
  .badge-dot, 
  .marquee-track {
    animation: none !important;
  }
}
