/* ==========================================================================
   NimLearn - Mobile-First & Multi-Tier Responsive Stylesheet
   Tagline: "Learn. Explore. Understand."
   Categories: Artificial Intelligence, Computer Science, Psychology, History of World
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Base Responsive Foundations (Zero Horizontal Scroll & Fluid Media)
   -------------------------------------------------------------------------- */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

img, video, iframe, svg {
  max-width: 100%;
  height: auto;
}

/* Touch-friendly interactive minimum sizes */
button, 
a.btn, 
.category-pill, 
.theme-toggle-btn, 
.search-trigger-btn, 
.mobile-menu-btn {
  touch-action: manipulation;
}

.theme-toggle-btn,
.search-trigger-btn,
.mobile-menu-btn {
  min-width: 44px;
  min-height: 44px;
}

/* --------------------------------------------------------------------------
   2. Large Desktop & High-Res Screens (1200px and above)
   -------------------------------------------------------------------------- */
@media (min-width: 1200px) {
  .container {
    padding-left: 2rem;
    padding-right: 2rem;
  }

  .hero-title {
    font-size: 3.5rem;
  }
}

/* --------------------------------------------------------------------------
   3. Laptop / Medium Desktop (992px to 1199px)
   -------------------------------------------------------------------------- */
@media (max-width: 1199px) {
  .container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .hero-grid {
    gap: 2.5rem;
  }

  .hero-title {
    font-size: 2.75rem;
  }

  .category-cards-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
  }

  .category-card {
    padding: 1.25rem;
  }

  .article-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
  }

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

/* --------------------------------------------------------------------------
   4. Tablet Devices (768px to 991px)
   -------------------------------------------------------------------------- */
@media (max-width: 991px) {
  :root {
    --header-height: 68px;
  }

  .section {
    padding-top: 3rem;
    padding-bottom: 3rem;
  }

  /* Navigation Drawer for Tablet/Mobile */
  .nav-links {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100%;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    flex-direction: column;
    align-items: stretch;
    padding: 1.5rem 2rem;
    gap: 0.5rem;
    box-shadow: var(--shadow-xl);
    transform: translateY(-120%);
    opacity: 0;
    pointer-events: none;
    transition: transform var(--transition-normal), opacity var(--transition-normal);
    z-index: 99;
  }

  .nav-links.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .nav-link {
    padding: 0.75rem 1rem;
    font-size: 1.05rem;
    border-radius: var(--radius-md);
  }

  .nav-link:hover, .nav-link.active {
    background-color: var(--bg-subtle);
  }

  .nav-link.active::after {
    display: none;
  }

  .mobile-menu-btn {
    display: flex;
  }

  /* Hero Section */
  .hero {
    padding-top: 3.5rem;
    padding-bottom: 3.5rem;
  }

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

  .hero-subtitle {
    margin-left: auto;
    margin-right: auto;
  }

  .hero-buttons {
    justify-content: center;
  }

  .hero-card-float-1, 
  .hero-card-float-2 {
    display: none;
  }

  /* Category Cards: 2 Columns on Tablet */
  .category-cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  /* Article Cards: 2 Columns on Tablet */
  .article-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  /* Featured Hero Card Stacked */
  .featured-hero-card {
    grid-template-columns: 1fr;
  }

  .featured-hero-media {
    min-height: 260px;
    max-height: 320px;
  }

  .featured-hero-content {
    padding: 2rem;
  }

  .featured-hero-title {
    font-size: 1.6rem;
  }

  /* Footer */
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2.5rem;
  }
}

/* --------------------------------------------------------------------------
   5. Mobile Devices (481px to 767px)
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  :root {
    --header-height: 64px;
  }

  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .section {
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
  }

  .section-title {
    font-size: 1.65rem;
  }

  .section-desc {
    font-size: 0.98rem;
  }

  .section-header {
    margin-bottom: 1.75rem;
  }

  /* Hero Mobile */
  .hero {
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
  }

  .hero-title {
    font-size: 2.15rem;
  }

  .hero-subtitle {
    font-size: 1.05rem;
    margin-bottom: 1.5rem;
  }

  .hero-buttons {
    flex-direction: column;
    width: 100%;
    gap: 0.75rem;
  }

  .hero-buttons .btn {
    width: 100%;
    padding: 0.85rem;
  }

  /* Category Cards: 1 Column on Mobile */
  .category-cards-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .category-card {
    padding: 1.5rem;
  }

  /* Articles Grid: 1 Column on Mobile */
  .article-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .article-card-body {
    padding: 1.25rem;
  }

  .article-card-title {
    font-size: 1.15rem;
  }

  /* Category Filter Pills Mobile Horizontal Scroll */
  .category-pill-list {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
    margin-left: -1rem;
    margin-right: -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
    scroll-snap-type: x mandatory;
  }

  .category-pill {
    flex-shrink: 0;
    scroll-snap-align: start;
    white-space: nowrap;
    padding: 0.55rem 1.1rem;
    font-size: 0.85rem;
  }

  /* Article Reader Page */
  .article-single-view {
    padding: 1.75rem 1rem 3.5rem 1rem;
  }

  .article-main-title {
    font-size: 1.85rem;
    line-height: 1.25;
  }

  .article-subtitle {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
  }

  .article-author-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .article-body-wrapper {
    font-size: 1.02rem;
    line-height: 1.7;
  }

  .article-body-wrapper h2 {
    font-size: 1.45rem;
    margin-top: 2rem;
  }

  .callout-box {
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.25rem;
  }

  /* Search Modal Mobile */
  .search-modal-backdrop {
    padding-top: 5vh;
  }

  .search-modal {
    width: calc(100% - 1.5rem);
    margin: 0 auto;
  }

  .search-modal-header {
    padding: 0.85rem 1rem;
  }

  .search-modal-input {
    font-size: 1rem;
  }

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

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

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

/* --------------------------------------------------------------------------
   6. Small Mobile Screens (480px and below)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .brand-name {
    font-size: 1.2rem;
  }

  .brand-tagline {
    display: none;
  }

  .hero-title {
    font-size: 1.8rem;
  }

  .hero-tag {
    font-size: 0.78rem;
  }

  .article-main-title {
    font-size: 1.65rem;
  }

  .featured-hero-content {
    padding: 1.25rem;
  }

  .featured-hero-title {
    font-size: 1.35rem;
  }

  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }

  .toast {
    width: 100%;
  }
}
