/**
 * S. Parthasarathy Author Site — Responsive Strategy & Viewport Hardening
 * Rigorously checked for: 280, 320, 360, 390, 430, 600, 768, 820, 1024, 1280, 1440, 1920, 2560
 */

/* Safe Area Insets for Mobile Notches & Edge Gestures */
html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

body {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ==========================================================================
   Ultrawide Displays (1440px to 2560px+)
   ========================================================================== */
@media (min-width: 1440px) {
  :root {
    --container-max: 1320px;
  }
}

/* ==========================================================================
   Desktops & Laptops (1024px to 1439px)
   ========================================================================== */
@media (min-width: 1024px) {
  .poem-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ==========================================================================
   Tablets (768px to 1023px)
   ========================================================================== */
@media (min-width: 768px) and (max-width: 1023px) {
  .verses-asymmetric-grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }
}

@media (max-width: 1023px) {
  .hero__grid {
    grid-template-columns: 1.1fr 0.9fr;
    gap: 2rem;
  }

  .verses-featured-card {
    grid-row: auto;
  }

  .lab-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .footer-grid {
    grid-template-columns: 1.2fr 1fr;
    gap: 2.5rem;
  }
}

/* ==========================================================================
   Tablets & Phablets (600px to 767px)
   ========================================================================== */
@media (max-width: 767px) {
  .hero__grid {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 2.5rem;
  }

  .hero .eyebrow {
    margin-inline: auto;
  }

  .hero h1 {
    margin-inline: auto;
  }

  .hero__lede {
    margin-inline: auto;
  }

  .hero__actions {
    justify-content: center;
  }

  .hero__portrait {
    order: -1;
    width: min(72%, 280px);
  }

  .book-grid {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 2.5rem;
  }

  .book-cover-mockup {
    max-width: 260px;
    margin: 0 auto;
    transform: none;
  }

  .book-details-dl {
    justify-content: center;
  }

  .about-teaser-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .about-teaser-grid .pull-quote {
    text-align: left;
  }

  .events-timeline {
    grid-template-columns: 1fr;
  }

  .newsletter-form {
    flex-direction: column;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: 0.75rem;
  }
}

/* ==========================================================================
   Smartphones & Carousels (390px to 599px)
   ========================================================================== */
@media (max-width: 639.98px) {
  .btn,
  .btn--primary,
  .btn--outline,
  .btn-primary,
  .btn-hero-oxblood {
    width: 100%;
    min-height: 52px;
    padding-inline: 24px;
    border-radius: 10px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .hm-featured-book__actions,
  .hm-actions,
  .filter-toolbar__actions {
    flex-direction: column;
    width: 100%;
    gap: 12px;
  }
}

@media (max-width: 599px) {
  .hero__actions .btn {
    width: 100%;
  }

  .lab-session-grid {
    grid-template-columns: 1fr;
  }

  .lab-session-card .btn {
    width: 100% !important;
    max-width: none !important;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }
}

/* ==========================================================================
   Folded Phones & Compact Mobile (280px to 389px)
   ========================================================================== */
@media (max-width: 389px) {
  :root {
    --gutter: 1rem;
  }

  .announcement-bar {
    padding: 0.5rem 0.75rem;
  }

  .announcement-text {
    max-width: 80%;
    font-size: 0.72rem;
  }

  .hero {
    min-height: auto;
    padding-top: 2rem;
    padding-bottom: 3.5rem;
  }

  .hero__portrait {
    width: 70%;
    max-width: 220px;
  }

  .hero h1 {
    font-size: 2.2rem;
  }

  .hero__actions {
    flex-direction: column;
    width: 100%;
  }

  .evidence-number {
    font-size: 1.85rem;
  }

  .evidence-label {
    font-size: 0.65rem;
    letter-spacing: 0.05em;
  }

  .book-cover-mockup {
    max-width: 220px;
    padding: 2rem 1.5rem;
  }

  .book-mockup-title {
    font-size: 1.65rem;
  }

  .book-details-dl {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .footer-grid {
    grid-template-columns: 1fr;
  }
}

/* Landscape Phone Safety */
@media (max-height: 520px) and (orientation: landscape) {
  .hero {
    min-height: auto !important;
    padding-block: 3rem;
  }

  .hero__portrait {
    max-width: 200px;
  }
}

/* Motion & Touch Safety */
@media (hover: none) {
  .poem-card:hover,
  .btn-primary-literary:hover,
  .btn--primary:hover,
  .btn-outline-literary:hover,
  .book-cover-mockup:hover,
  .event-card:hover {
    transform: none !important;
    box-shadow: none !important;
  }
}

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