/* ==========================================================================
   ASI PRODUCT STUDY DETAIL PAGE  -  MOBILE STYLES
   Max-width: 1024px (Tablets & Phones)
   ========================================================================== */

@media screen and (max-width: 1024px) {

  /* --------------------------------------------------------------------------
     1. LAYOUT GRID OVERRIDES
     -------------------------------------------------------------------------- */
  .study-layout {
    display: block; /* Remove the asymmetric grid */
  }

  .study-container {
    padding: 2rem 1rem;
  }

  .study-main {
    max-width: 100%;
    width: 100%;
  }

  /* --------------------------------------------------------------------------
     2. HERO COMPONENT ADAPTATIONS
     -------------------------------------------------------------------------- */
  .study-hero {
    min-height: 50vh;
    padding: 3rem 1rem 2rem 1rem;
    text-align: center; /* Center align for impact on mobile */
    align-items: center;
  }

  .study-hero h1 {
    font-size: clamp(2rem, 8vw, 2.5rem);
    margin: 0 auto 1.5rem auto;
  }

  .study-breadcrumb {
    text-align: center;
  }

  .study-hud-stats {
    justify-content: center;
    gap: 1rem;
    width: 100%;
  }

  .hud-stat-card {
    min-width: 45%; /* Two per row on mobile */
    flex: 1;
    padding: 1rem;
    text-align: center;
    border-left: none;
    border-top: 3px solid var(--study-accent); /* Top border instead of left */
  }

  .hud-stat-value {
    font-size: 1.5rem;
  }

  /* --------------------------------------------------------------------------
     3. TOC & SIDEBAR -> COLLAPSIBLE OVERLAY
     -------------------------------------------------------------------------- */
  .study-sidebar {
    display: none; /* Hide the natural sidebar */
  }

  /* Sticky Mobile TOC Bar */
  .mobile-toc-bar {
    display: flex !important; /* Script will toggle this if necessary */
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 60px; /* Below mobile header */
    background: var(--study-card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--study-border);
    padding: 1rem;
    z-index: 100;
    cursor: pointer;
    font-family: var(--study-font-heading);
    color: var(--study-text);
  }

  .mobile-toc-bar .current-section {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80%;
  }

  /* Fullscreen TOC Overlay */
  .mobile-toc-overlay {
    display: block !important;
    position: fixed;
    inset: 0;
    background: var(--study-bg);
    z-index: 999;
    padding: 5rem 2rem 2rem 2rem;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
  }

  .mobile-toc-overlay.active {
    transform: translateY(0);
  }

  .mobile-toc-overlay .close-toc {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--study-text);
    cursor: pointer;
  }

  /* The actual imported TOC list styling for overlay */
  .mobile-toc-overlay .sticky-toc {
    margin-bottom: 0;
  }
  .mobile-toc-overlay .sticky-toc ul {
    border-left: none;
  }
  .mobile-toc-overlay .sticky-toc a {
    font-size: 1.25rem;
    padding: 1rem 0;
    border-left: none;
    border-bottom: 1px solid var(--study-border);
  }

  /* --------------------------------------------------------------------------
     4. CONTENT COMPONENTS Overrides
     -------------------------------------------------------------------------- */
  .ai-summary {
    padding: 1.5rem;
    margin-bottom: 2rem;
  }

  .study-content h2 {
    font-size: 1.75rem;
    margin-top: 3rem;
  }

  .figure-card {
    margin: 2rem -1rem; /* Break out of padding on mobile for full width */
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .data-table th, .data-table td {
    padding: 0.75rem;
  }

  /* --------------------------------------------------------------------------
     5. ACTION BAR (Bottom Floating)
     -------------------------------------------------------------------------- */
  .mobile-action-bar {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--study-card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--study-border);
    display: flex;
    justify-content: space-around;
    padding: 0.75rem 1rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    z-index: 100;
  }

  .mobile-action-bar .action-btn {
    flex: 1;
    border: none;
    background: transparent;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.7rem;
    padding: 0.25rem;
  }

  .mobile-action-bar .action-btn i {
    font-size: 1.25rem;
  }

  /* --------------------------------------------------------------------------
     6. LEAD CAPTURE (Moved Inline)
     -------------------------------------------------------------------------- */
  .inline-lead-capture {
    display: block !important;
    margin: 4rem 0 2rem 0;
    padding: 2rem 1.5rem;
  }
}

/* ==========================================================================
   768px - Tablet Portrait & Large Phones
   ========================================================================== */
@media screen and (max-width: 768px) {

  /* Hero - reduce min-height and padding */
  .study-hero {
    min-height: 40vh;
    padding: 2.5rem 1rem 1.5rem 1rem;
  }
  .study-hero h1 {
    font-size: clamp(1.8rem, 7vw, 2.2rem);
  }
  .hud-stat-card {
    min-width: 42%;
    padding: 0.8rem;
  }
  .hud-stat-value {
    font-size: 1.3rem;
  }

  /* Hero full (product-study.css structure) */
  .ps-hero-full {
    padding-top: 7rem;
    padding-bottom: 1rem;
    gap: 2rem;
  }
  .ps-hero-full h1 {
    font-size: clamp(2rem, 6vw, 2.6rem);
  }
  .ps-hero-right {
    min-height: 240px;
  }

  /* Param grid - reduce from 3 to 2 columns */
  .ps-param-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  /* Outcomes items - reduce from 3 cols to 2 */
  .ps-outcomes-items {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Platform cards - stack to single column */
  .ps-scope-plat-row {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .ps-scope-plat-row::after {
    display: none;
  }

  /* Summary grid - already 1-col from 1024px, fine */

  /* Comparison strips */
  .ps-strip {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .ps-strip-label {
    width: 100%;
    font-size: 0.7rem;
  }

  /* Section headings */
  .ps-section h2 {
    font-size: 1.2rem;
  }

  /* Collapsible header - stack title and preview bar at 768px for all phones */
  .ps-collapsible-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 1.2rem 1.5rem;
  }
  .ps-collapsible-body {
    padding: 0 1.5rem 1.5rem 1.5rem;
  }
  .ps-collapsible-card.collapsed .ps-collapsible-body {
    padding: 0 1.5rem;
  }

  /* Slider arrows - ensure 44px touch targets */
  .ps-slider-arrow {
    width: 44px;
    height: 44px;
    opacity: 1;
  }

  /* Lightbox - adjust for smaller screens */
  .ps-lightbox-toolbar {
    padding: 0.4rem 0.6rem;
    gap: 0.15rem;
  }
  .ps-lightbox-btn {
    width: 44px;
    height: 44px;
  }
  .ps-lightbox-nav {
    width: 48px;
    height: 48px;
  }
  .ps-lightbox-nav.prev { left: 1rem; }
  .ps-lightbox-nav.next { right: 1rem; }
  .ps-lightbox-caption {
    top: 1.5rem;
    left: 1.5rem;
    font-size: 0.95rem;
    max-width: 300px;
  }
  .ps-lightbox-close {
    top: 1.5rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
  }

  /* Insight callout */
  .ps-insight {
    padding: 1.2rem 1.5rem;
  }

  /* Platform cards - stack */
  .ps-platforms-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   480px - Phone-specific adjustments
   ========================================================================== */
@media screen and (max-width: 480px) {

  /* Container tighter padding */
  .study-container {
    padding: 1.5rem 0.75rem;
  }
  .ps-container {
    padding: 0 1rem;
  }

  /* Hero */
  .study-hero {
    min-height: auto;
    padding: 2rem 0.75rem 1.5rem;
  }
  .study-hero h1 {
    font-size: clamp(1.5rem, 6.5vw, 1.9rem);
    margin: 0 auto 1rem auto;
  }
  .ps-hero-full {
    padding-top: 5.5rem;
    gap: 1.5rem;
  }
  .ps-hero-full h1 {
    font-size: clamp(1.6rem, 5.5vw, 2.2rem);
  }
  .ps-hero-subtitle {
    font-size: 0.85rem;
  }
  .ps-hero-right {
    min-height: 200px;
  }
  .ps-breadcrumb {
    font-size: 0.6rem;
  }
  .ps-hero-meta {
    font-size: 0.7rem;
    gap: 1rem;
    flex-wrap: wrap;
  }

  /* HUD stat cards - ensure full width */
  .study-hud-stats {
    flex-direction: column;
    gap: 0.75rem;
  }
  .hud-stat-card {
    min-width: 100%;
    flex: 1;
  }

  /* Param grid - 2 columns on phone */
  .ps-param-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
  }
  .ps-param-lbl {
    font-size: 0.5rem;
  }
  .ps-param-val {
    font-size: 0.82rem;
  }

  /* Outcomes items - single column */
  .ps-outcomes-items {
    grid-template-columns: 1fr 1fr;
  }
  .ps-outcome-item {
    padding: 0.6rem 0.75rem;
  }
  .ps-outcome-icon {
    width: 24px;
    height: 24px;
    font-size: 0.55rem;
  }
  .ps-outcome-name {
    font-size: 0.62rem;
  }

  /* Outcomes bar */
  .ps-outcomes-bar {
    flex-direction: column;
  }
  .ps-outcomes-tag {
    border-right: none;
    border-bottom: 1px solid rgba(139,92,246,0.1);
    padding: 0.5rem 1rem;
    text-align: center;
  }

  /* Collapsible header - tighter padding on phones */
  .ps-collapsible-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 1rem 1.2rem;
  }
  .ps-collapsible-body {
    padding: 0 1.2rem 1.2rem 1.2rem;
  }
  .ps-collapsible-card.collapsed .ps-collapsible-body {
    padding: 0 1.2rem;
  }

  /* Summary grid blocks */
  .ps-sum-block {
    padding: 1rem 1.2rem;
    border-right: none !important;
  }
  .ps-sum-text {
    font-size: 0.8rem;
  }

  /* Section spacing */
  .ps-section {
    margin-bottom: 2.5rem;
  }
  .ps-section h2 {
    font-size: 1.1rem;
  }
  .ps-section h3 {
    font-size: 0.95rem;
  }

  /* Figure cards */
  .ps-fig-card {
    padding: 1rem;
  }
  .ps-fig-card img {
    max-height: 240px;
  }

  /* Comparison strips */
  .ps-comparison-strips {
    padding: 1rem;
    border-radius: 12px;
  }
  .ps-strip-value {
    min-width: 60px;
    font-size: 0.78rem;
  }

  /* Stat chips */
  .ps-stat-chips {
    gap: 0.4rem;
  }
  .ps-chip {
    padding: 0.4rem 0.75rem;
    font-size: 0.72rem;
  }

  /* Weight bar */
  .ps-weight-bar {
    height: 28px;
  }

  /* Chart container */
  .ps-chart-container {
    padding: 1rem;
    border-radius: 12px;
  }

  /* Prose readability */
  .ps-prose p {
    font-size: 0.85rem;
  }

  /* Lightbox - phone optimized */
  .ps-lightbox-toolbar {
    bottom: 1.5rem;
    padding: 0.35rem 0.5rem;
    border-radius: 50px;
  }
  .ps-lightbox-btn {
    width: 36px;
    height: 36px;
    font-size: 0.95rem;
  }
  .ps-lightbox-btn.text-btn {
    font-size: 0.75rem;
    padding: 0 0.8rem;
  }
  .ps-lightbox-nav {
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
  }
  .ps-lightbox-nav.prev { left: 0.5rem; }
  .ps-lightbox-nav.next { right: 0.5rem; }
  .ps-lightbox-caption {
    top: 1rem;
    left: 1rem;
    font-size: 0.82rem;
    max-width: 240px;
  }
  .ps-lightbox-close {
    top: 1rem;
    right: 1rem;
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }
  .ps-lightbox-minimap {
    width: 120px;
    bottom: 5rem;
    right: 0.5rem;
  }
  .ps-lightbox img {
    max-width: 95vw;
    max-height: 75vh;
  }

  /* Platform cards */
  .ps-platform-card {
    padding: 1.5rem;
  }

  /* Back to top - smaller on phones */
  .ps-back-top {
    width: 40px;
    height: 40px;
    bottom: 1.5rem;
    right: 1.5rem;
  }

  /* Insight callout */
  .ps-insight {
    padding: 1rem 1.2rem;
    margin: 1.5rem 0;
  }
  .ps-insight p {
    font-size: 0.85rem;
  }

  /* TOC overlay - bigger text for touch */
  .mobile-toc-overlay .sticky-toc a {
    font-size: 1.1rem;
    padding: 0.85rem 0;
    min-height: 44px;
  }

  /* Action bar - bottom safe area already handled */
  .mobile-action-bar .action-btn {
    font-size: 0.65rem;
    min-height: 44px;
  }
  .mobile-action-bar .action-btn i {
    font-size: 1.1rem;
  }

  /* Spec rows - stack on phones */
  .ps-spec-row {
    flex-direction: column;
    gap: 0.25rem;
  }
  .ps-spec-key {
    flex: none;
    width: auto;
  }

  /* Scope platform cards */
  .ps-plat-top {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .ps-plat-ver {
    margin-left: 0;
  }
  .ps-plat-inline-data {
    flex-wrap: wrap;
    gap: 0.8rem;
  }
}

/* ==========================================================================
   360px - Small phones (iPhone SE, Galaxy S)
   ========================================================================== */
@media screen and (max-width: 360px) {

  .ps-hero-full h1 {
    font-size: 1.5rem;
  }
  .ps-hero-subtitle {
    font-size: 0.8rem;
  }

  /* Param grid - single column */
  .ps-param-grid {
    grid-template-columns: 1fr;
  }

  /* Outcomes - single column */
  .ps-outcomes-items {
    grid-template-columns: 1fr;
  }

  /* Section headings */
  .ps-section h2 {
    font-size: 1rem;
  }

  /* Tighter spacing */
  .ps-section {
    margin-bottom: 2rem;
  }
  .ps-fig-card img {
    max-height: 200px;
  }

  /* HUD cards */
  .hud-stat-value {
    font-size: 1.1rem;
  }

  /* Lightbox - minimal */
  .ps-lightbox-toolbar {
    width: calc(100% - 2rem);
    left: 1rem;
    transform: none;
    justify-content: space-around;
  }
  .ps-lightbox-divider {
    display: none;
  }
  .ps-lightbox-minimap {
    display: none;
  }
}
