/**
 * DaysAndDates.com - Comprehensive Responsive Design & Performance System
 * Flawless responsive hierarchy from 320px (foldables/iPhone SE) to 4K displays
 * Hardware-accelerated 60/120fps scrolling, content-visibility optimization,
 * zero layout shift, and touch target protection (WCAG 2.2 AA).
 */

/* ==========================================================================
   Smooth Anchor Scroll Padding & Universal Overflow Containment
   ========================================================================== */
html {
  scroll-padding-top: clamp(65px, 8vh, 85px);
  overflow-x: clip;
}

body {
  overflow-x: clip;
  width: 100%;
}

/* Content-Visibility Optimization for Below-the-Fold Heavy Sections */
@supports (content-visibility: auto) {
  #around-the-world,
  #shape-of-today,
  #reasons-to-look-ahead,
  #timeline-milestones,
  #calculators-suite,
  #birthdays-deck,
  #collections-preview,
  #faq-section,
  .site-footer {
    content-visibility: auto;
    contain-intrinsic-size: 1px 600px;
  }
}

/* ==========================================================================
   Ultra-Narrow Mobile Screens (< 380px, e.g. iPhone SE, Galaxy Fold 320-360px)
   ========================================================================== */
@media (max-width: 379.98px) {
  .site-container {
    padding-inline: 0.75rem !important;
  }

  /* Header adjustments for narrow width */
  .brand-name {
    font-size: 1.05rem !important;
  }

  .logo-img {
    width: 28px !important;
    height: 28px !important;
  }

  .header-actions {
    gap: 0.25rem !important;
  }

  .action-icon-btn {
    width: 34px !important;
    height: 34px !important;
    font-size: 0.9rem !important;
  }

  .today-badge-pill {
    padding: 0.3rem 0.5rem !important;
    font-size: 0.7rem !important;
  }

  /* Hero Typography & Spacing */
  .hero-title-eyebrow {
    font-size: 0.75rem !important;
  }

  .hero-title-day {
    font-size: 2rem !important;
    letter-spacing: -0.03em !important;
  }

  .hero-title-date {
    font-size: 1.45rem !important;
  }

  .hero-editorial-lead {
    font-size: 0.875rem !important;
    line-height: 1.45 !important;
  }

  /* Quick Chip Pills stack cleanly */
  .quick-chip-pill {
    flex: 1 1 100% !important;
    justify-content: center;
    font-size: 0.75rem !important;
  }

  /* Spotlight Card Compact Mode (for non-slider cards) */
  .hero-spotlight-card.is-photo-mode:not(.hero-story-slider *) {
    min-height: 280px !important;
    padding: 1rem !important;
  }

  .hero-spotlight-card.is-photo-mode:not(.hero-story-slider *) .spotlight-title {
    font-size: 1.25rem !important;
  }

  /* Footer Social Cluster */
  .footer-social-cluster {
    gap: 0.35rem !important;
  }

  .footer-social-btn {
    width: 34px !important;
    height: 34px !important;
    font-size: 0.85rem !important;
  }
}

/* ==========================================================================
   Standard Mobile Devices (< 576px)
   ========================================================================== */
@media (max-width: 575.98px) {
  .site-container {
    padding-inline: 1rem;
  }

  .site-header {
    padding-block: 0.5rem;
  }

  /* Hero Showcase Row: Stack cleanly */
  .hero-showcase-row {
    grid-template-columns: 1fr;
    gap: 1.35rem;
    margin-bottom: 1.5rem;
  }

  .hero-editorial-title {
    margin-bottom: 0.65rem;
  }

  .hero-title-day {
    font-size: clamp(2.15rem, 8.5vw, 2.65rem);
    line-height: 1.05;
  }

  .hero-title-date {
    font-size: clamp(1.55rem, 6.2vw, 1.95rem);
    line-height: 1.1;
  }

  .live-time-pill {
    width: 100%;
    justify-content: center;
    padding: 0.45rem 0.85rem;
  }

  /* Spotlight Card (for non-slider cards) */
  .hero-spotlight-card.is-photo-mode:not(.hero-story-slider *) {
    min-height: 310px;
    padding: 1.25rem;
    border-radius: var(--radius-xl, 22px);
  }

  .spotlight-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .spotlight-footer {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.75rem;
  }

  .spotlight-footer .btn-modern,
  .spotlight-footer a {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  /* Bento Grids on Mobile */
  .hero-bento-subgrid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .bento-facts-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .bento-fact-card {
    padding: 0.85rem;
  }

  .bento-fact-icon {
    width: 34px;
    height: 34px;
    font-size: 1rem;
  }

  /* Date Card List on Mobile */
  .date-card-list {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .date-card {
    min-height: 270px;
    border-radius: var(--radius-lg, 18px);
    padding: 1rem;
  }

  /* Story Cards Grid */
  .story-card-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .story-card-grid > * {
    grid-column: span 12 !important;
  }

  .story-card {
    min-height: 290px;
    padding: 1.35rem;
  }

  /* Precision Calculators Suite on Mobile */
  .calc-hero-stat {
    font-size: 2.2rem;
  }

  .calc-tabs-wrapper {
    flex-wrap: wrap;
    padding: 4px;
    border-radius: var(--radius-lg, 16px) !important;
  }

  .calc-tab-btn {
    flex: 1 1 calc(50% - 4px);
    text-align: center;
    padding: 0.55rem 0.5rem;
    font-size: 0.78rem;
    border-radius: var(--radius-md, 10px) !important;
  }

  .calc-form-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Timeline */
  .timeline-entry {
    gap: 0.85rem;
  }

  .timeline-marker {
    width: 16px;
  }

  .timeline-dot {
    width: 12px;
    height: 12px;
  }

  .timeline-card {
    padding: 1rem 1.15rem;
    border-radius: var(--radius-lg, 16px);
  }

  /* World Map on Mobile */
  .world-map-wrapper {
    aspect-ratio: 4 / 3;
    min-height: 320px;
  }

  .world-map-preview-card {
    position: static;
    width: 100%;
    margin-top: 0.75rem;
    box-shadow: var(--shadow-sm);
  }

  .world-country-cards {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* Footer Responsiveness */
  .site-footer {
    padding-top: 3rem;
    padding-bottom: 2rem;
    margin-top: 3rem;
  }


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

  .footer-legal-links {
    justify-content: center;
  }

  .footer-timezone-box {
    margin-top: 1rem;
  }

  /* Compact Mobile UX: Suppress bottom-left floating widget to prevent screen obstruction */
  .floating-today-widget {
    display: none !important;
  }

  /* Compact Back-to-Top Button on Mobile */
  .back-to-top-btn {
    width: 42px;
    height: 42px;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    right: calc(1rem + env(safe-area-inset-right, 0px));
  }
}

/* ==========================================================================
   Small Tablets & Large Phones (576px - 767.98px)
   ========================================================================== */
@media (min-width: 576px) and (max-width: 767.98px) {
  .site-container {
    padding-inline: 1.25rem;
  }

  .hero-showcase-row {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .hero-spotlight-card.is-photo-mode:not(.hero-story-slider *) {
    min-height: 400px;
  }

  .date-card-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .bento-facts-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .story-card-grid > * {
    grid-column: span 12 !important;
  }

  .world-country-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   Tablets / iPads (768px - 1099.98px)
   ========================================================================== */
@media (min-width: 768px) and (max-width: 1099.98px) {
  .site-container {
    padding-inline: 1.5rem;
  }

  .header-actions {
    gap: 0.45rem;
  }

  .search-command-btn {
    display: none;
  }

  .hero-showcase-row {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .hero-bento-subgrid {
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
  }

  .date-card-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
  }

  .bento-facts-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
  }

  .world-map-wrapper {
    aspect-ratio: 16 / 9;
    min-height: 420px;
  }

  .world-country-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   Desktop & Laptops (1100px - 1439.98px)
   ========================================================================== */
@media (min-width: 1100px) {
  .desktop-nav {
    display: block !important;
  }

  .mobile-menu-trigger {
    display: none !important;
  }

  .search-command-btn {
    display: inline-flex !important;
  }

  .hero-showcase-row {
    grid-template-columns: 4.6fr 7.4fr;
    gap: clamp(1.75rem, 2vw, 2.5rem);
  }

  .date-card-list {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
  }
}

/* ==========================================================================
   Widescreen & 4K Displays (1440px+)
   ========================================================================== */
@media (min-width: 1440px) {
  .site-container {
    max-width: 1420px;
    padding-inline: 2rem;
  }

  .site-container-narrow {
    max-width: 980px;
  }

  .hero-showcase-row {
    grid-template-columns: 4.3fr 7.7fr;
    gap: 2.75rem;
  }

  .date-card-list {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
  }
}

/* ==========================================================================
   Touch Device Performance & Pointer Hover Discipline
   ========================================================================== */
@media (pointer: coarse) {
  /* Generous 44px Touch Targets */
  button,
  .btn-modern,
  .nav-link,
  .quick-chip-pill,
  .calc-tab-btn,
  .footer-links a,
  .mobile-nav-item {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .action-icon-btn {
    width: 44px;
    height: 44px;
  }

  .date-card__btn {
    width: 40px;
    height: 40px;
  }

  /* Disable sticky hover animations on touch screens */
  .card-tilt-3d:hover {
    transform: none !important;
  }

  .card-tilt-3d:active {
    transform: scale(0.99) !important;
  }
}

@media (hover: hover) and (pointer: fine) {
  /* Enhanced Desktop Hover Transitions */
  .date-card:hover {
    transform: translateY(-6px) scale(1.01);
  }

  .glass-card:hover {
    border-color: var(--glass-border-hover);
  }
}

/* ==========================================================================
   High Contrast & Accessibility Modes (WCAG 2.2 AAA)
   ========================================================================== */
@media (forced-colors: active) {
  .glass-card,
  .glass-panel,
  .btn-modern,
  .date-card,
  .hero-spotlight-card {
    border: 2px solid ButtonText !important;
  }
}
