/* 1440+ keeps desktop defaults from layout/cards */

@media (max-width: 1439px) {
  :root {
    --shell: min(100% - 2.5rem, 1280px);
  }
}

@media (max-width: 1279px) {
  :root {
    --sidebar-width: 14.5rem;
    --shell: min(100% - 2.25rem, 1120px);
  }

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

@media (max-width: 1023px) {
  :root {
    --sidebar-width: 13.5rem;
  }

  .hero {
    min-height: min(38vh, 400px);
  }

  .collection-hero {
    min-height: min(32vh, 340px);
  }

  .recipe-hero {
    height: min(48vh, 480px);
  }
}

@media (max-width: 767px) {
  :root {
    --shell: calc(100% - 1.5rem);
    --header-offset: 0px;
  }

  html,
  body {
    height: auto;
    overflow: auto;
    overflow-x: clip;
  }

  .site-frame {
    display: block;
    height: auto;
    min-height: 0;
  }

  .site-content {
    height: auto;
    overflow: visible;
  }

  .site-content .shell,
  .site-content .shell.narrow {
    width: var(--shell);
  }

  .site-topbar {
    top: 0.85rem;
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    max-width: none;
    justify-content: space-between;
  }

  .site-topbar__brand {
    display: none;
  }

  .site-sidebar__top {
    display: flex;
  }

  .sidebar-open,
  .sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    padding: 0 0.95rem;
    border: 1px solid rgba(255, 250, 243, 0.55);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--color-surface) 88%, transparent);
    box-shadow: 0 10px 28px rgba(58, 52, 46, 0.18);
    backdrop-filter: blur(10px);
    color: var(--color-ink);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
  }

  .sidebar-close {
    width: 2.5rem;
    padding: 0;
    border-color: var(--color-line);
    box-shadow: none;
    backdrop-filter: none;
    background: var(--color-surface);
  }

  .site-search {
    flex: 1 1 8rem;
    max-width: 16rem;
    width: auto;
    margin-left: 0;
  }

  .site-search__dropdown {
    position: fixed;
    top: 4.1rem;
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
  }

  .site-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 40;
    width: min(20rem, calc(100vw - 2.5rem));
    height: 100vh;
    max-height: none;
    transform: translateX(-105%);
    transition: transform 220ms ease;
    box-shadow: var(--shadow);
  }

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

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: block;
    background: rgba(58, 52, 46, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
  }

  .sidebar-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .hero,
  .collection-hero {
    min-height: 36vh;
  }

  .recipe-hero {
    height: 40vh;
  }

  .recipe__intro {
    margin-top: -2rem;
  }

  .card-grid,
  .category-grid,
  .meta-list {
    grid-template-columns: 1fr;
  }

  .site-footer__inner {
    flex-direction: column;
  }

  .section {
    padding: 2.75rem 0;
  }

  .pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .pagination__pages {
    order: -1;
  }

  .pagination__nav {
    justify-content: center;
  }
}

@media (max-width: 479px) {
  h1 {
    font-size: 2.25rem;
  }

  h2 {
    font-size: 1.85rem;
  }

  .hero__content,
  .collection-hero__content {
    padding: 3rem 0 2rem;
  }

  .card__body,
  .category-card__body,
  .recipe__intro,
  .recipe-panel {
    padding: 1.2rem;
  }

  .meta-list {
    gap: 0.75rem;
  }
}

@media (max-width: 389px) {
  :root {
    --shell: calc(100% - 1.25rem);
  }

  .btn {
    width: 100%;
  }

  .card__body .btn {
    width: 100%;
  }

  .hero__title {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  .card:hover,
  .category-card:hover,
  .card:focus-within,
  .card:hover .card__image,
  .category-card:hover .category-card__image,
  .card:focus-within .card__image {
    transform: none;
  }
}
