/* ==========================================
   RESPONSIVE DESIGN & MEDIA QUERIES
   ========================================== */

/* ===== MOBILE (320px - 639px) ===== */
/* Default styles are mobile-first */

/* ===== SMALL DEVICES (640px+) ===== */
@media (min-width: 640px) {
  /* Increase container padding */
  .container {
    padding: 0 var(--space-lg);
  }

  /* Hero adjustments */
  .hero-title {
    font-size: var(--font-3xl);
  }

  /* Larger cards on tablets */
  .subject-card {
    min-height: 220px;
  }
}

/* ===== TABLETS (768px+) ===== */
@media (min-width: 768px) {
  /* Typography scales up */
  html {
    font-size: 18px;
  }

  /* Header improvements */
  .logo-text {
    display: block;
  }

  /* Grid layouts activate */
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Chapter items get more spacing */
  .chapter-item {
    padding: var(--space-xl);
  }

  /* Content gets more breathing room */
  .content-body {
    font-size: var(--font-lg);
  }
}

/* ===== DESKTOP (1024px+) ===== */
@media (min-width: 1024px) {
  /* 3-column grids activate */
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Bilingual content side-by-side */
  .bilingual-content {
    grid-template-columns: 1fr 1fr;
  }

  /* Larger hero sections */
  .hero {
    padding: var(--space-3xl) 0;
  }

  .subject-header {
    padding: var(--space-3xl) 0;
  }

  /* Resources grid - 3 columns */
  .resources-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ===== LARGE DESKTOP (1280px+) ===== */
@media (min-width: 1280px) {
  /* Container reaches max width */
  .container {
    max-width: var(--container-max-width);
  }

  /* 4-column grids for resource cards */
  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Optimal reading width for content */
  .content-body {
    max-width: 900px;
  }
}

/* ===== MOBILE-SPECIFIC OPTIMIZATIONS ===== */
@media (max-width: 767px) {
  /* Reduce font sizes slightly on very small screens */
  .hero-title {
    font-size: var(--font-2xl);
  }

  .subject-title {
    font-size: var(--font-2xl);
  }

  /* Stack navigation items */
  .nav-list {
    flex-direction: column;
    width: 100%;
  }

  /* Full-width buttons on mobile */
  .btn {
    width: 100%;
  }

  /* Reduce card padding on mobile */
  .card {
    padding: var(--space-md);
  }

  /* Smaller chapter numbers */
  .chapter-number {
    width: 50px;
    height: 50px;
    font-size: var(--font-lg);
  }

  /* Ensure bilingual content stacks */
  .bilingual-content {
    grid-template-columns: 1fr;
  }

  /* Mobile-friendly toggle buttons */
  .toggle-group {
    width: 100%;
  }

  .toggle-btn {
    flex: 1;
    text-align: center;
  }

  /* Floating audio player adjustment */
  .floating-audio {
    left: var(--space-md);
    right: var(--space-md);
    bottom: var(--space-md);
    min-width: auto;
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  /* Hide navigation elements */
  .header,
  .footer,
  .breadcrumbs,
  .back-btn,
  .menu-toggle,
  .floating-audio {
    display: none;
  }

  /* Reset backgrounds for printing */
  body {
    background: white;
    color: black;
  }

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

  /* Better page breaks */
  .card,
  .question-card,
  .chapter-item {
    page-break-inside: avoid;
  }

  h1, h2, h3 {
    page-break-after: avoid;
  }

  /* Show links for reference */
  a::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }
}

/* ===== ACCESSIBILITY ===== */

/* Focus styles for keyboard navigation */
a:focus,
button:focus,
.card:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .card {
    border: var(--border-width-thick) solid var(--color-text-primary);
  }

  .btn-outline {
    border-width: 3px;
  }
}

/* Dark mode preparation (for future) */
@media (prefers-color-scheme: dark) {
  /* Will be implemented in Phase 2 */
}
