/* =============================================================================
   ARCHIVE — category + CPT archive component styles
   Conditionally loaded on is_archive() via inc/setup.php
   All values reference tokens from style.css :root
   ============================================================================= */


/* =============================================================================
   ARCHIVE HEADER
   ============================================================================= */

.archive-header {
  padding-top: var(--mfc-space-10);
  padding-bottom: var(--mfc-space-10);
  background: var(--mfc-bg-secondary);
  border-bottom: 0.5px solid var(--mfc-border);
}

.archive-header__inner {
  display: flex;
  flex-direction: column;
  gap: var(--mfc-space-2);
}

.archive-header__text {
  display: flex;
  flex-direction: column;
  gap: var(--mfc-space-2);
}

.archive-header__title {
  font-size: var(--mfc-text-4xl);
  font-weight: 800;
  color: var(--mfc-text);
  letter-spacing: -0.025em;
  line-height: 1.05;
  margin: 0;
}

.archive-header__description {
  font-size: var(--mfc-text-lg);
  color: var(--mfc-text-secondary);
  max-width: 560px;
  line-height: 1.55;
  margin: 0;
}


/* =============================================================================
   FILTER BAR
   ============================================================================= */

.archive-filters {
  background: var(--mfc-bg);
  border-bottom: 0.5px solid var(--mfc-border);
  padding: var(--mfc-space-4) 0;
  position: sticky;
  top: 64px; /* height of site-header */
  z-index: 10;
}

/* Toggle row */
.archive-filters__bar {
  display: flex;
  align-items: center;
  gap: var(--mfc-space-4);
}

/* Toggle button */
.archive-filters__toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--mfc-space-2);
  padding: 8px var(--mfc-space-5);
  font-size: var(--mfc-text-sm);
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--mfc-text-secondary);
  background: var(--mfc-bg);
  border: 1.5px solid var(--mfc-border-strong);
  border-radius: var(--mfc-radius-full);
  cursor: pointer;
  transition:
    color var(--mfc-transition),
    border-color var(--mfc-transition),
    background-color var(--mfc-transition);
}

.archive-filters__toggle:hover,
.archive-filters.is-open .archive-filters__toggle {
  border-color: var(--mfc-electric);
  color: var(--mfc-electric-dark);
  background: var(--mfc-electric-surface);
}

/* Chevron */
.archive-filters__toggle-icon {
  flex-shrink: 0;
  transition: transform 0.22s ease;
}

.archive-filters.is-open .archive-filters__toggle-icon {
  transform: rotate(180deg);
}

/* Active-filter count badge */
.archive-filters__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--mfc-electric);
  color: var(--mfc-deep);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  border-radius: var(--mfc-radius-full);
}

/* Clear all link */
.archive-filters__clear {
  font-size: var(--mfc-text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--mfc-text-muted);
  text-decoration: none;
  padding: 6px 0;
  flex-shrink: 0;
  transition: color var(--mfc-transition);
}

.archive-filters__clear:hover {
  color: var(--mfc-pop);
}

/* Collapsible panel */
.archive-filters__panel {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.28s ease, padding-top 0.28s ease;
  padding-top: 0;
}

.archive-filters.is-open .archive-filters__panel {
  max-height: 320px;
  padding-top: var(--mfc-space-5);
}

/* Filter groups inside panel */
.archive-filters__groups {
  display: flex;
  align-items: flex-start;
  gap: var(--mfc-space-8);
  flex-wrap: wrap;
  padding-bottom: var(--mfc-space-4);
}

.archive-filters__group {
  display: flex;
  flex-direction: column;
  gap: var(--mfc-space-2);
}

.archive-filters__label {
  font-size: var(--mfc-text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mfc-text-tertiary);
}

.archive-filters__pills {
  display: flex;
  gap: var(--mfc-space-2);
  flex-wrap: wrap;
}

/* Individual filter pill */
.archive-filter-pill {
  display: inline-flex;
  align-items: center;
  font-size: var(--mfc-text-sm);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-decoration: none;
  padding: 8px 18px;
  border-radius: var(--mfc-radius-full);
  border: 1.5px solid var(--mfc-border-strong);
  color: var(--mfc-text-secondary);
  background: var(--mfc-bg);
  transition:
    background-color var(--mfc-transition),
    border-color var(--mfc-transition),
    color var(--mfc-transition),
    transform var(--mfc-transition);
  white-space: nowrap;
}

.archive-filter-pill:hover {
  border-color: var(--mfc-forest);
  color: var(--mfc-forest);
  transform: translateY(-1px);
}

.archive-filter-pill.is-active {
  background: var(--mfc-electric);
  border-color: var(--mfc-electric);
  color: var(--mfc-deep);
}

.archive-filter-pill.is-active:hover {
  background: var(--mfc-electric-dark);
  border-color: var(--mfc-electric-dark);
  color: var(--mfc-deep);
  transform: translateY(-1px);
}

/* Bottom-sheet chrome — mobile only; hidden on desktop inline panel */
.archive-filters__overlay,
.archive-filters__sheet-header,
.archive-filters__sheet-footer {
  display: none;
}


/* =============================================================================
   PAGINATION
   ============================================================================= */

.navigation.pagination {
  margin-top: var(--mfc-space-12);
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--mfc-space-2);
  flex-wrap: wrap;
}

.page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 var(--mfc-space-3);
  border-radius: var(--mfc-radius-md);
  font-size: var(--mfc-text-sm);
  font-weight: 600;
  text-decoration: none;
  color: var(--mfc-text-secondary);
  border: 1px solid transparent;
  transition:
    background-color var(--mfc-transition),
    border-color var(--mfc-transition),
    color var(--mfc-transition);
}

.page-numbers:hover {
  background: var(--mfc-bg-secondary);
  border-color: var(--mfc-border);
  color: var(--mfc-text);
}

.page-numbers.current {
  background: var(--mfc-electric);
  color: var(--mfc-deep);
  font-weight: 700;
  border-color: var(--mfc-electric);
}

.page-numbers.prev,
.page-numbers.next {
  font-size: var(--mfc-text-sm);
  font-weight: 700;
  padding: 0 var(--mfc-space-4);
  color: var(--mfc-forest);
  border-color: var(--mfc-border-strong);
}

.page-numbers.prev:hover,
.page-numbers.next:hover {
  background: var(--mfc-electric-surface);
  border-color: var(--mfc-electric);
  color: var(--mfc-electric-dark);
}

.page-numbers.dots {
  color: var(--mfc-text-muted);
  border: none;
  pointer-events: none;
}


/* =============================================================================
   EMPTY STATE
   ============================================================================= */

.archive-empty {
  text-align: center;
  padding: var(--mfc-space-20) var(--mfc-space-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--mfc-space-6);
}

.archive-empty p {
  font-size: var(--mfc-text-lg);
  color: var(--mfc-text-secondary);
  max-width: 400px;
  margin: 0;
}


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

@media (max-width: 768px) {
  .archive-header__title {
    font-size: var(--mfc-text-3xl);
  }

  .archive-filters {
    position: static; /* Unstick on mobile — too cramped */
  }

  /* ── Backdrop ──────────────────────────────────────────────────────────── */
  .archive-filters__overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(28, 43, 30, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 290;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .archive-filters.is-open .archive-filters__overlay {
    opacity: 1;
    pointer-events: auto;
  }

  /* ── Panel becomes a bottom sheet ──────────────────────────────────────── */
  .archive-filters__panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 291;
    max-height: 85vh;
    max-height: 85dvh;
    display: flex;
    flex-direction: column;
    background: var(--mfc-bg);
    border-top-left-radius: var(--mfc-radius-lg);
    border-top-right-radius: var(--mfc-radius-lg);
    box-shadow: 0 -8px 32px rgba(28, 43, 30, 0.16);
    /* Reset the desktop collapse mechanics */
    overflow: visible;
    padding-top: 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }

  .archive-filters.is-open .archive-filters__panel {
    max-height: 85vh;
    max-height: 85dvh; /* override desktop is-open value */
    padding-top: 0;
    transform: translateY(0);
  }

  /* ── Sheet header (title + close) ──────────────────────────────────────── */
  .archive-filters__sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--mfc-space-4) var(--mfc-padding-x);
    border-bottom: 0.5px solid var(--mfc-border);
    flex-shrink: 0;
  }

  .archive-filters__sheet-title {
    font-size: var(--mfc-text-base);
    font-weight: 800;
    letter-spacing: -0.015em;
    color: var(--mfc-text);
  }

  .archive-filters__sheet-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: var(--mfc-bg-secondary);
    border: none;
    border-radius: var(--mfc-radius-md);
    color: var(--mfc-text);
    cursor: pointer;
    transition: background-color 0.15s;
  }

  .archive-filters__sheet-close:hover {
    background: var(--mfc-bg-tertiary);
  }

  /* ── Scrollable groups area ────────────────────────────────────────────── */
  .archive-filters__groups {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0;
    padding: 0 var(--mfc-padding-x);
  }

  .archive-filters__group {
    gap: var(--mfc-space-3);
    padding: var(--mfc-space-5) 0;
    border-bottom: 0.5px solid var(--mfc-border);
  }

  .archive-filters__group:last-child {
    border-bottom: none;
  }

  /* Touch-friendly pills that fill the row */
  .archive-filter-pill {
    padding: 10px 20px;
    min-height: 44px;
  }

  /* ── Sheet footer (clear + done) ───────────────────────────────────────── */
  .archive-filters__sheet-footer {
    display: flex;
    align-items: center;
    gap: var(--mfc-space-3);
    padding: var(--mfc-space-4) var(--mfc-padding-x);
    /* Raptive's anchor ad overlays bottom-fixed UI at a near-max z-index —
       reserve its height so Clear/Done stay reachable while it shows. */
    padding-bottom: calc(var(--mfc-space-4) + var(--mfc-raptive-anchor) + env(safe-area-inset-bottom));
    border-top: 0.5px solid var(--mfc-border);
    flex-shrink: 0;
  }

  .archive-filters__sheet-clear {
    font-size: var(--mfc-text-sm);
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--mfc-text-muted);
    text-decoration: none;
    padding: 12px var(--mfc-space-4);
    border-radius: var(--mfc-radius-full);
    border: 1.5px solid var(--mfc-border-strong);
    flex-shrink: 0;
  }

  .archive-filters__sheet-done {
    flex: 1 1 auto;
    min-height: 48px;
    font-family: inherit;
    font-size: var(--mfc-text-sm);
    font-weight: 800;
    letter-spacing: 0.03em;
    color: var(--mfc-deep);
    background: var(--mfc-electric);
    border: none;
    border-radius: var(--mfc-radius-full);
    cursor: pointer;
    transition: background-color var(--mfc-transition);
  }

  .archive-filters__sheet-done:hover {
    background: var(--mfc-electric-dark);
  }

  /* Recipe grid — 2-col on mobile (homepage + archive, overrides global 1-col collapse) */
  .mfc-recipe-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--mfc-space-3);
  }
}
