/* ==========================================================================
   CHAOS — BOOK ONE: COMPREHENSIVE RESPONSIVE DESIGN & MOBILE EDGE FIXES
   Guarantees zero text touching edges, zero content overlap, zero bottom obstruction
   ========================================================================== */

/* Prevent page horizontal overflow */
html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden !important;
  box-sizing: border-box;
}

*, *::before, *::after {
  box-sizing: border-box;
}

/* Base Container Safety Padding */
.section-container {
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 28px;
  width: 100%;
  box-sizing: border-box;
}

.section {
  padding: 80px 0;
  box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   1. Laptop & Small Desktop (961px - 1240px)
   -------------------------------------------------------------------------- */
@media (max-width: 1240px) {
  .hero-container {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }
  .hero-title {
    font-size: 3.5rem;
  }
  .book-showcase-grid {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }
}

/* --------------------------------------------------------------------------
   2. Tablet & Mobile View Breakpoint (<= 960px)
   -------------------------------------------------------------------------- */
@media (max-width: 960px) {
  /* Keep accessibility and atmosphere controls reachable on every device. */
  .hud-fixed-bar {
    left: 8px;
    right: 8px;
    bottom: 8px;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    width: auto;
    max-width: none;
    padding: 6px !important;
    border-radius: 16px;
    overflow: visible;
  }

  .hud-fixed-bar button {
    justify-content: center;
    min-width: 0;
    padding: 8px 6px;
    font-size: 0.62rem;
    letter-spacing: 0.04em;
    white-space: nowrap;
  }

  body {
    padding-bottom: 64px;
  }

  .site-header {
    top: 8px;
    width: calc(100% - 16px);
    height: 64px;
  }

  .header-container {
    padding: 0 16px;
  }

  .main-nav, 
  .header-actions {
    display: none !important;
  }

  .mobile-menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  .hero-section {
    padding-top: calc(var(--header-height) + 30px);
    padding-bottom: 40px;
  }

  .hero-container {
    grid-template-columns: 1fr;
    gap: 32px;
    text-align: center;
  }

  .hero-text-col {
    align-items: center;
    text-align: center;
  }

  .hero-pretitle {
    justify-content: center;
    flex-wrap: wrap;
  }

  .hero-cta-group {
    justify-content: center;
    width: 100%;
  }

  .hero-artwork-col {
    order: -1;
  }

  .cover-wrapper {
    max-width: 280px;
  }

  .timeline-motif {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .timeline-arrow {
    transform: rotate(90deg);
    margin: 4px 0;
  }

  .book-showcase-grid {
    grid-template-columns: 1fr;
    gap: 32px;
    text-align: center;
  }

  .book-specs-panel {
    padding: 24px;
    align-items: center;
  }

  .author-summary-panel {
    grid-template-columns: 1fr;
    gap: 24px;
    text-align: center;
    padding: 24px;
  }

  .author-portrait-container {
    max-width: 240px;
    margin: 0 auto;
  }

  .footer-container {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }
}

/* --------------------------------------------------------------------------
   3. Mobile Phone View (375px - 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .site-header {
    top: 8px;
    width: calc(100% - 16px);
    height: 60px;
  }

  .header-container {
    padding: 0 12px;
  }

  .brand-symbol {
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
  }

  .brand-title {
    font-size: 1.05rem;
  }

  .brand-subtitle {
    display: none;
  }

  .section-container {
    padding: 0 16px;
  }

  .section {
    padding: 36px 0;
  }

  .section-header {
    margin-bottom: 24px;
  }

  .section-title {
    font-size: 1.65rem;
    letter-spacing: 0.04em;
  }

  .section-subtitle {
    font-size: 0.92rem;
  }

  .hero-title {
    font-size: 2.1rem;
    letter-spacing: 0.04em;
  }

  .hero-tagline {
    font-size: 0.82rem;
    letter-spacing: 0.06em;
  }

  .hero-lead {
    font-size: 0.95rem;
    margin-bottom: 20px;
  }

  .hero-cta-group {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }

  .hero-cta-group .btn {
    width: 100%;
  }

  .hero-metrics-bar {
    flex-direction: column;
    gap: 12px;
    padding: 16px;
  }

  .metric-divider {
    width: 80%;
    height: 1px;
    margin: 4px 0;
  }

  /* Cards Padding on Mobile (Zero Edge Collisions) */
  .card, 
  .threat-card, 
  .dossier-card, 
  .glass,
  .premise-text-panel,
  .newsletter-hub {
    padding: 20px 16px !important;
    border-radius: var(--radius-md);
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    word-break: break-word;
  }

  .hud-fixed-bar.glass {
    width: auto;
    padding: 6px !important;
    border-radius: 16px;
    overflow: visible;
  }

  .threat-grid, 
  .dossier-grid,
  .press-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    width: 100%;
  }

  .retailer-links-grid {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .retailer-card {
    width: 100%;
    align-items: center;
    text-align: center;
    padding: 14px;
  }

  /* Newsletter Form Mobile */
  .newsletter-row {
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }

  .newsletter-row .btn {
    width: 100%;
  }

  /* Footer Mobile */
  .footer-container {
    grid-template-columns: 1fr;
    gap: 24px;
    text-align: center;
  }

  .footer-brand-col {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 10px;
    text-align: center;
    padding: 20px 16px 0;
  }
}

/* --------------------------------------------------------------------------
   4. Extra Small Mobile Phones (375px & below)
   -------------------------------------------------------------------------- */
@media (max-width: 400px) {
  .hero-title {
    font-size: 1.9rem;
  }
  
  .brand-title {
    font-size: 1rem;
  }

  .header-container {
    padding: 0 10px;
  }

  .cover-wrapper {
    max-width: 220px;
  }

  .btn-lg {
    padding: 12px 18px;
    font-size: 0.88rem;
  }

  .card, .dossier-card {
    padding: 18px 12px !important;
  }
}
