/* ================================
   RESPONSIVE DESIGN OVERRIDES
   Mobile-First Approach
   ================================ */

/* Base Mobile Styles (320px+) */
@media (max-width: 767px) {
  /* Mobile body adjustments */
  body {
    background-color: var(--bg);
    --bg-parallax: scroll;
    width: 100%;
    overflow-x: hidden;
  }

  /* Keep html fallback solid for safe rendering */
  html {
    background: var(--bg);
    width: 100%;
    overflow-x: hidden;
  }

  /* Ensure navbar is visible and not cut off */
  .nav {
    width: 100% !important;
    max-width: 100vw !important;
    overflow: visible !important;
  }

  .nav-inner {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
  }
  
  /* Force solid backgrounds on all elements that might have gradients */
  .hero-card {
    background: var(--card) !important;
    background-image: none !important;
  }
  
  .btn.primary {
    background: var(--brand) !important;
    background-image: none !important;
  }
  
  .badge {
    background: var(--brand-2) !important;
    background-image: none !important;
  }

  /* Container adjustments */
  .container {
    padding: 16px;
    max-width: 100%;
  }

  /* Navigation Mobile Improvements */
  .nav-inner {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 12px 16px !important;
    gap: 12px !important;
    width: 100% !important;
    flex-wrap: nowrap !important;
  }

  .nav .brand {
    display: flex !important;
    justify-content: flex-start;
    text-align: left;
    flex-shrink: 0;
    white-space: nowrap;
  }

  .nav .brand .logo {
    flex-shrink: 0;
  }

  .nav .spacer {
    display: none;
  }

  .nav a:not(.btn):not(.brand) {
    display: none; /* Hide regular nav links on mobile but keep brand */
  }

  .nav .btn {
    display: none; /* Hide login/register buttons on mobile */
  }

  /* Mobile Navigation Drawer */
  .mobile-nav-toggle {
    display: flex !important;
    flex-shrink: 0;
    margin-left: auto;
  }

  .mobile-nav-drawer {
    padding: 88px 24px 28px;
    gap: 12px;
    min-height: 60vh;
    background: var(--bg-soft) !important;
    overflow: visible !important;
  }

  .mobile-nav-drawer a {
    display: block !important;
    padding: 14px 16px !important;
    border-radius: 10px;
    background: var(--input-bg);
    border: 1px solid var(--nav-border);
    color: var(--text) !important;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
  }

  .mobile-nav-drawer a:hover,
  .mobile-nav-drawer a:active {
    background: rgba(215,169,79,0.16);
    border-color: rgba(215,169,79,0.4);
    transform: translateX(-4px);
  }

  /* Hero Section Mobile */
  .hero {
    padding: 32px 16px 24px;
  }

  .hero .wrap {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .hero h1 {
    font-size: 1.8rem;
    line-height: 1.2;
  }

  .hero .lead {
    font-size: 1rem;
    max-width: 100%;
  }

  .hero .cta {
    flex-direction: column;
    gap: 12px;
  }

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

  .hero-list {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .hero-list .chip {
    text-align: center;
    padding: 12px;
  }

  /* Cards and Grid Mobile */
  .grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .card {
    padding: 16px;
    margin: 0;
  }

  .card .btn {
    width: 100%;
    justify-content: center;
  }

  /* Forms Mobile */
  .card {
    max-width: 100%;
    margin: 20px auto;
    padding: 24px 20px;
  }

  input, textarea, select {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 14px 12px;
  }

  button:not(.plyr__control) {
    padding: 16px;
    font-size: 1rem;
  }

  /* Split layouts become stacked */
  .split {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  /* Panel adjustments */
  .panel {
    padding: 16px;
  }

  /* Embedded media sizing */
  iframe {
    max-height: 50vh !important;
    border-radius: 8px !important;
  }

  /* Footer mobile */
  .foot {
    flex-direction: column;
    text-align: center;
    gap: 8px;
  }

  .foot .right {
    margin-left: 0;
  }

  /* Typography adjustments */
  section h2 {
    font-size: 1.5rem;
  }

  section h3 {
    font-size: 1.3rem;
  }

  /* Flash messages mobile */
  .flash-messages {
    margin: 16px;
    max-width: calc(100% - 32px);
  }

  .flash {
    padding: 12px;
    font-size: 0.9rem;
  }

  /* Filters mobile */
  .filters {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .filters input,
  .filters select {
    width: 100%;
  }
}

/* Desktop Styles - Hide mobile elements */
@media (min-width: 768px) {
  .mobile-nav-toggle {
    display: none;
  }

  .mobile-nav-backdrop,
  .mobile-nav-drawer {
    display: none !important;
  }
}

/* Tablet Styles (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  .container {
    padding: 20px;
  }

  .nav-inner {
    padding: 12px 20px;
  }

  .hero .wrap {
    grid-template-columns: 1fr 1fr;
    gap: 28px;
  }

  .hero-list {
    grid-template-columns: repeat(2, 1fr);
  }

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

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

/* Very Small Phones (320px - 479px) */
@media (max-width: 479px) {
  .nav .brand {
    font-size: 0.9rem;
    gap: 8px;
  }

  .nav .logo {
    width: 28px;
    height: 28px;
  }

  .mobile-nav-toggle {
    font-size: 1.3rem;
    padding: 6px 10px;
    min-width: 40px;
    min-height: 40px;
  }
}

/* Large Mobile/Small Tablet (480px - 767px) */
@media (min-width: 480px) and (max-width: 767px) {
  .hero h1 {
    font-size: 2rem;
  }

  .hero-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .cta {
    flex-direction: row;
    gap: 12px;
  }

  .cta .btn {
    flex: 1;
  }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
  .btn, button, input, select, textarea {
    min-height: 44px; /* Apple's recommended touch target size */
  }

  .nav a, .mobile-nav-drawer a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .logo, .logo-big {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Landscape phone orientation */
@media (max-width: 767px) and (orientation: landscape) {
  .hero {
    padding: 24px 16px;
  }

  iframe {
    max-height: 60vh !important;
  }
}

/* Print styles */
@media print {
  .nav, .mobile-nav-drawer, .cta, .btn {
    display: outside !important;
  }

  body {
    background: white !important;
    color: black !important;
  }

  .card, .panel {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }
}
