/* === PANDACK RESPONSIVE === */

/* --- Tablet (768px+) --- */
@media (min-width: 768px) {
  .mobile-bottom-bar {
    display: none !important;
  }
}

/* --- Desktop (1024px+) --- */
@media (min-width: 1024px) {
  .site-header {
    display: flex;
  }

  .mobile-header {
    display: none !important;
  }
}

/* --- Below desktop (< 1024px) --- */
@media (max-width: 1023px) {
  .site-header {
    display: none !important;
  }

  .mobile-header {
    display: flex;
  }

  /* On mobile the sidebar is an overlay, fixed to the left edge, hidden by default. */
  body.has-sidebar {
    display: block;
  }

  body.has-sidebar .site-sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: calc(100vh - var(--header-h));
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    border-right: 1px solid var(--border);
  }

  body.sidebar-open .site-sidebar {
    transform: translateX(0);
  }

  body.sidebar-open::after {
    content: '';
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
  }
}

/* --- Below tablet (< 768px) --- */
@media (max-width: 767px) {
  .mobile-bottom-bar {
    display: flex;
  }

  .site-main {
    padding-bottom: 70px;
  }

  /* Container padding */
  .container {
    padding: 0 16px;
  }

  /* Footer stacks */
  .site-footer {
    flex-direction: column;
    gap: 12px;
    text-align: center;
    padding: 20px 16px;
  }

  .site-footer-links {
    gap: 14px;
  }

  /* Grids go single column */
  .cat-grid {
    grid-template-columns: 1fr;
  }

  .expl-tiles {
    grid-template-columns: 1fr;
  }

  /* Font sizes mobile */
  .hero-title {
    font-size: clamp(28px, 8vw, 36px);
  }

  /* About section stacks */
  .about {
    grid-template-columns: 1fr;
  }

  .article-h-title {
    font-size: 24px;
  }

  .article-body h2 {
    font-size: 18px;
  }

  .article-body p {
    font-size: 14px;
  }

  .article-body pre,
  .article-body code {
    font-size: 12px;
  }

  /* Fiches grid */
  .fiches {
    grid-template-columns: 1fr;
  }

  /* Filters become accordion */
  .explf-layout {
    grid-template-columns: 1fr;
  }

  .filters-panel {
    position: static;
    max-height: none;
  }
}

/* --- Overflow / width safety for content on every page --- */
.article-body img,
.page-content img,
.portfolio-layout img {
  max-width: 100%;
  height: auto;
}

.article-body pre,
.article-body .code-block-wrapper {
  overflow-x: auto;
  max-width: 100%;
}

.article-body table {
  display: block;
  overflow-x: auto;
  max-width: 100%;
}

/* --- Tablet only (768px - 1023px) --- */
@media (min-width: 768px) and (max-width: 1023px) {
  .cat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

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

  .site-search {
    max-width: 250px;
  }

  .container {
    padding: 0 24px;
  }
}

/* --- Touch targets --- */
@media (pointer: coarse) {
  .filter-opt,
  .chip,
  .btn,
  .mb-item,
  .cat-item > a,
  .cat-row,
  .main-nav a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}
