/**
 * Recipe archive — filter bar + grid layout.
 * Mobile: filter button → bottom sheet (all dimensions). Desktop: מטבח + expand.
 *
 * @package Recipefy
 */

/* ─────────────────────────────────────────────
   Archive hero — compact on mobile
   ───────────────────────────────────────────── */
.rfy-archive-hero {
	padding: 20px 0 12px;
	background: var(--rfy-background);
	text-align: start;
}

.rfy-archive-hero__eyebrow {
	display: none;
}

.rfy-archive-hero__title {
	font-size: clamp(24px, 5vw, 44px);
	color: var(--rfy-foreground);
	margin: 0 0 6px;
	line-height: 1.15;
}

.rfy-archive-hero__desc {
	font-size: 1.125rem;
	color: var(--rfy-muted);
	margin: 0;
	max-width: 520px;
}

/* ─────────────────────────────────────────────
   Filter bar — sticky
   ───────────────────────────────────────────── */
.rfy-filter-bar {
	position: sticky;
	top: var(--rfy-header-height);
	z-index: 90;
	background: rgba(247, 240, 230, 0.94);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	border-bottom: 1px solid var(--rfy-border);
}

body.admin-bar .rfy-filter-bar {
	top: calc(var(--rfy-header-height) + var(--wp-admin--admin-bar--height, 32px));
}

/* Mobile vs desktop visibility */
.rfy-filter-bar__desktop {
	display: none;
}

.rfy-filter-bar__mobile {
	display: block;
}

/* Hidden unless JS disabled — critical style also inlined in filters.php */
.rfy-filter-details {
	display: none !important;
}

.rfy-js .rfy-filter-details {
	display: none !important;
}

/* ─────────────────────────────────────────────
   Labeled filter section (shared)
   ───────────────────────────────────────────── */
.rfy-filter-bar__section {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 6px;
	min-width: 0;
}

.rfy-filter-bar__section-label {
	flex-shrink: 0;
	font-size: 0.8125rem;
	font-weight: 700;
	color: var(--rfy-foreground);
	letter-spacing: 0.02em;
	text-align: start;
	line-height: 1.2;
}

/* ─────────────────────────────────────────────
   Mobile — filter button only
   ───────────────────────────────────────────── */
.rfy-filter-bar__mobile-actions {
	display: flex;
	justify-content: flex-start;
	padding: 10px 0 8px;
}

.rfy-filter-bar__open--mobile {
	width: 100%;
	justify-content: center;
}

/* ─────────────────────────────────────────────
   Desktop primary row — מטבח + more btn
   ───────────────────────────────────────────── */
.rfy-filter-bar__desktop-primary {
	display: flex;
	flex-direction: row;
	align-items: flex-end;
	gap: 14px;
	padding: 12px 0 8px;
}

.rfy-filter-bar__section--primary {
	flex: 1;
	min-width: 0;
	padding: 10px 12px;
	border-radius: var(--rfy-radius-md);
	background: var(--rfy-surface);
	border: 1px solid var(--rfy-border);
}

.rfy-filter-bar__section--primary .rfy-filter-bar__track {
	flex-wrap: wrap;
	overflow-x: visible;
}

.rfy-filter-bar__open--desktop {
	flex-shrink: 0;
	align-self: flex-end;
}

.rfy-filter-bar__desktop-more {
	padding-bottom: 8px;
}

.rfy-filter-bar__open {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-width: 44px;
	min-height: 44px;
	padding: 8px 12px;
	border-radius: var(--rfy-radius-md);
	border: 1.5px solid var(--rfy-border);
	background: var(--rfy-surface);
	color: var(--rfy-foreground);
	font-family: var(--rfy-font);
	cursor: pointer;
	position: relative;
	box-shadow: var(--rfy-shadow-sm);
}

.rfy-filter-bar__open-text {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 2px;
	text-align: start;
}

.rfy-filter-bar__open-label {
	font-size: 0.875rem;
	font-weight: 700;
	line-height: 1.2;
	color: var(--rfy-foreground);
}

.rfy-filter-bar__open-hint {
	font-size: 0.6875rem;
	font-weight: 500;
	line-height: 1.2;
	color: var(--rfy-muted);
	white-space: nowrap;
}

.rfy-filter-bar__open-icon {
	flex-shrink: 0;
	color: var(--rfy-secondary);
}

.rfy-filter-bar__open-badge {
	position: absolute;
	top: -4px;
	inset-inline-start: -4px;
	min-width: 18px;
	height: 18px;
	padding: 0 4px;
	border-radius: 999px;
	background: var(--rfy-primary);
	color: #fff;
	font-size: 0.6875rem;
	font-weight: 700;
	line-height: 18px;
	text-align: center;
}

/* Active filter summary */
.rfy-filter-bar__summary {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	padding-bottom: 10px;
}

.rfy-filter-bar__summary-title {
	flex-shrink: 0;
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--rfy-muted);
}

.rfy-filter-bar__summary-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.rfy-filter-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 34px;
	padding-block: 0;
	padding-inline: 12px 10px;
	border-radius: var(--rfy-radius-pill);
	background: var(--rfy-surface);
	border: 1.5px solid var(--rfy-secondary);
	color: var(--rfy-foreground);
	font-size: 0.8125rem;
	font-weight: 500;
	text-decoration: none;
}

.rfy-filter-chip__group {
	color: var(--rfy-muted);
	font-weight: 600;
}

.rfy-filter-chip__group::after {
	content: ':';
	margin-inline-start: 2px;
}

.rfy-filter-chip__value {
	color: var(--rfy-secondary);
	font-weight: 700;
}

.rfy-filter-chip__x {
	font-size: 1.125rem;
	line-height: 1;
	opacity: 0.85;
}

/* No-JS details fallback — only visible via <noscript> override */
.rfy-filter-details {
	border-top: 1px solid var(--rfy-border);
	padding: 8px 0;
	margin-top: 4px;
}

.rfy-filter-details summary {
	cursor: pointer;
	font-size: 1.125rem;
	font-weight: 600;
	color: var(--rfy-foreground);
	padding: 8px 0;
	list-style: none;
}

.rfy-filter-details summary::-webkit-details-marker {
	display: none;
}

.rfy-filter-details__inner {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding-bottom: 12px;
}

/* ─────────────────────────────────────────────
   Shared pill track + pill
   ───────────────────────────────────────────── */
.rfy-filter-bar__track {
	display: flex;
	flex-wrap: nowrap;
	gap: 6px;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	padding-bottom: 2px;
}

.rfy-filter-bar__track::-webkit-scrollbar {
	display: none;
}

.rfy-filter-pill {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	min-height: 36px;
	min-width: 44px;
	padding: 0 12px;
	border-radius: var(--rfy-radius-pill);
	border: 1.5px solid var(--rfy-secondary);
	background: transparent;
	color: var(--rfy-secondary);
	font-size: 0.875rem;
	font-weight: 500;
	font-family: var(--rfy-font);
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
	scroll-snap-align: start;
}

.rfy-filter-pill:hover,
.rfy-filter-pill.is-active {
	background: var(--rfy-secondary);
	color: #fff;
}

.rfy-filter-bar__group {
	display: flex;
	align-items: flex-start;
	flex-direction: column;
	gap: 6px;
}

.rfy-filter-bar__label {
	flex-shrink: 0;
	font-size: 0.8125rem;
	font-weight: 700;
	color: var(--rfy-foreground);
	text-align: start;
}

/* ─────────────────────────────────────────────
   Bottom sheet (mobile)
   ───────────────────────────────────────────── */
.rfy-filter-sheet[hidden] {
	display: none;
}

.rfy-filter-sheet {
	position: fixed;
	inset: 0;
	z-index: 1000;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
}

.rfy-filter-sheet__overlay {
	position: absolute;
	inset: 0;
	background: rgba(43, 26, 16, 0.45);
}

.rfy-filter-sheet__panel {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	max-height: 85vh;
	background: var(--rfy-background);
	border-radius: var(--rfy-radius-lg) var(--rfy-radius-lg) 0 0;
	box-shadow: var(--rfy-shadow-lg);
	animation: rfy-sheet-up 0.28s ease;
}

@keyframes rfy-sheet-up {
	from { transform: translateY(100%); }
	to { transform: translateY(0); }
}

.rfy-filter-sheet__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 20px;
	border-bottom: 1px solid var(--rfy-border);
}

.rfy-filter-sheet__title {
	margin: 0 0 4px;
	font-size: 1.125rem;
	color: var(--rfy-foreground);
}

.rfy-filter-sheet__hint {
	margin: 0;
	font-size: 0.9375rem;
	color: var(--rfy-muted);
	line-height: 1.4;
	max-width: 280px;
}

.rfy-filter-sheet__close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border: none;
	background: transparent;
	font-size: 1.75rem;
	line-height: 1;
	color: var(--rfy-foreground);
	cursor: pointer;
}

.rfy-filter-sheet__body {
	flex: 1;
	overflow-y: auto;
	padding: 12px 20px 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	-webkit-overflow-scrolling: touch;
}

.rfy-filter-bar__section--sheet {
	padding: 12px 14px;
	border-radius: var(--rfy-radius-md);
	background: var(--rfy-surface);
	border: 1px solid var(--rfy-border);
}

.rfy-filter-bar__section--sheet .rfy-filter-bar__section-label {
	font-size: 0.9375rem;
	margin-bottom: 2px;
}

.rfy-filter-sheet__group-label {
	margin: 0 0 8px;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--rfy-muted);
}

.rfy-filter-sheet__group .rfy-filter-bar__track {
	flex-wrap: wrap;
	overflow-x: visible;
}

.rfy-filter-sheet__footer {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
	border-top: 1px solid var(--rfy-border);
	background: var(--rfy-background);
}

.rfy-filter-sheet__clear {
	flex-shrink: 0;
	min-height: 44px;
	padding: 0 12px;
	border: none;
	background: transparent;
	color: var(--rfy-muted);
	font-family: var(--rfy-font);
	font-size: 1rem;
	text-decoration: underline;
	cursor: pointer;
}

.rfy-filter-sheet__apply {
	flex: 1;
}

body.rfy-filter-sheet-open {
	overflow: hidden;
}

/* ─────────────────────────────────────────────
   Archive results
   ───────────────────────────────────────────── */
.rfy-archive {
	padding: 16px 0 48px;
}

.rfy-archive .rfy-container {
	padding-top: 16px;
}

.rfy-archive-results {
	min-height: 200px;
}

.rfy-archive-results--loading {
	opacity: 0.45;
	pointer-events: none;
	transition: opacity 0.2s;
}

.rfy-archive-empty {
	text-align: center;
	color: var(--rfy-muted);
	font-size: 1.125rem;
	padding: 48px 0;
}

.rfy-archive-results .rfy-recipe-grid {
	grid-template-columns: 1fr;
	gap: 16px;
}

.rfy-archive-results .rfy-chef-archive-grid {
	grid-template-columns: 1fr;
	gap: 16px;
}

/* Pagination */
.rfy-pagination {
	display: flex;
	justify-content: center;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 32px;
}

.rfy-pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
	padding: 0 12px;
	border-radius: var(--rfy-radius-sm);
	border: 2px solid var(--rfy-border);
	background: transparent;
	color: var(--rfy-foreground);
	font-size: 1rem;
	text-decoration: none;
	transition: background 0.18s, color 0.18s;
}

.rfy-pagination .page-numbers:hover,
.rfy-pagination .page-numbers.current {
	background: var(--rfy-secondary);
	color: #fff;
	border-color: var(--rfy-secondary);
}

/* ─────────────────────────────────────────────
   Tablet / desktop ≥768px
   ───────────────────────────────────────────── */
@media (min-width: 768px) {
	.rfy-archive-hero {
		padding: 40px 0 20px;
	}

	.rfy-archive-hero__eyebrow {
		display: inline-flex;
		margin: 0 0 8px;
	}

	.rfy-archive-hero__title {
		margin-bottom: 10px;
	}

	.rfy-filter-bar__mobile {
		display: none;
	}

	.rfy-filter-bar__desktop {
		display: block;
	}

	.rfy-filter-bar__desktop-more .rfy-filter-bar__desktop-grid {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 14px 20px;
	}

	.rfy-filter-bar__desktop-grid .rfy-filter-bar__section {
		padding: 10px 12px;
		border-radius: var(--rfy-radius-md);
		background: var(--rfy-surface);
		border: 1px solid var(--rfy-border);
	}

	.rfy-filter-bar__desktop-grid .rfy-filter-bar__section-label {
		font-size: 0.875rem;
	}

	.rfy-filter-bar__desktop-grid .rfy-filter-bar__track {
		flex-wrap: wrap;
		overflow-x: visible;
	}

	.rfy-filter-bar__summary--desktop {
		padding-top: 8px;
		border-top: 1px solid var(--rfy-border);
		margin-top: 4px;
	}

	.rfy-filter-pill {
		min-height: 36px;
		font-size: 0.875rem;
	}

	.rfy-archive-results .rfy-recipe-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 24px;
	}

	.rfy-archive-results .rfy-chef-archive-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 24px;
	}
}

@media (min-width: 1024px) {
	.rfy-archive-hero {
		padding: 48px 0 24px;
	}

	.rfy-archive-results .rfy-recipe-grid {
		grid-template-columns: repeat(3, 1fr);
	}

	.rfy-archive-results .rfy-chef-archive-grid {
		grid-template-columns: repeat(3, 1fr);
	}
}
