/**
 * HW Gallery — Redesigned gallery page styles
 * Replaces hw-gallery-scroll.css
 *
 * @package fwbase
 * @since   2026-04
 */

/* =========================================================================
 * 1. FILTER BAR
 * ========================================================================= */

.hw-gallery-filters {
	position: -webkit-sticky;
	position: sticky;
	top: 80px;                          /* below the sticky site header */
	z-index: 200;                       /* below header (z-index 9000) but above content */
	background: rgba(255, 255, 255, 0.97);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	border-bottom: 1px solid #ede6df;
	padding: 10px 20px;
	margin: 0 -20px 24px;
	transition: box-shadow 0.3s ease;
	box-sizing: border-box;
}

/* Admin-bar offset (logged-in WP users see 32px admin bar above header) */
.admin-bar .hw-gallery-filters {
	top: 112px; /* 80px header + 32px admin bar */
}
@media screen and (max-width: 782px) {
	.admin-bar .hw-gallery-filters {
		top: 126px; /* 80px header + 46px mobile admin bar */
	}
}

.hw-gallery-filters.hw-filters-scrolled {
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

/* --- Auto-collapse: hide filter rows when user scrolls down --- */
.hw-gallery-filters.hw-filters-compact .hw-filter-rows {
	display: none !important;
}

/* ---- Scrollable filter rows ---- */

/*
 * SCROLL ARCHITECTURE:
 * .hw-filter-row-wrap is the scroll container (overflow-x: auto).
 * .hw-filter-row is a flex row with width: max-content so it extends
 * beyond the wrapper when there are many pills, enabling horizontal scroll.
 *
 * CRITICAL: Do NOT put overflow: hidden on the wrapper — it clips the
 * scrollable area. The wrapper must use overflow-x: auto.
 */
.hw-filter-row-wrap {
	position: relative;
	display: block;
	width: 100%;
	min-width: 0;
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;              /* Firefox: thin scrollbar */
	scrollbar-color: #c9b99a transparent; /* Firefox: subtle gold scrollbar */
	cursor: grab;                       /* Hint that row is draggable */
}

.hw-filter-row-wrap::-webkit-scrollbar {
	height: 4px;                        /* Chrome/Safari: thin scrollbar */
}
.hw-filter-row-wrap::-webkit-scrollbar-track {
	background: transparent;
}
.hw-filter-row-wrap::-webkit-scrollbar-thumb {
	background: #c9b99a;
	border-radius: 4px;
}
.hw-filter-row-wrap::-webkit-scrollbar-thumb:hover {
	background: #a89070;
}

/* Drag-to-scroll active state */
.hw-filter-row-wrap.hw-dragging {
	cursor: grabbing;
	user-select: none;
	-webkit-user-select: none;
}

.hw-filter-row {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: nowrap;
	width: max-content;             /* extend beyond wrapper to enable scroll */
	min-width: 100%;                /* at minimum, fill the wrapper */
	padding: 4px 0;
}

.hw-filter-row-wrap::after {
	content: '';
	position: absolute;
	top: 0;
	right: 0;
	width: 40px;
	height: 100%;
	background: linear-gradient(to right, transparent, rgba(255,255,255,0.95));
	pointer-events: none;
	opacity: 1;
	transition: opacity 0.2s;
	z-index: 2;
}

/* Hide fade when scrolled to end (toggled by JS) */
.hw-filter-row-wrap.hw-scrolled-end::after {
	opacity: 0;
}

.hw-filter-row-wrap + .hw-filter-row-wrap {
	margin-top: 6px;
}

.hw-filter-label {
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: #6b6058;
	white-space: nowrap;
	min-width: 60px;
	flex-shrink: 0;
}

/* --- Filter bar top row: toggle + search side by side --- */
.hw-filter-bar-top {
	display: flex;
	align-items: center;
	gap: 12px;
	max-width: 100%;
	box-sizing: border-box;
}

/* --- Gallery search field --- */
.hw-gallery-search {
	position: relative;
	flex: 1;
	max-width: 300px;
	min-width: 0;
	margin-left: auto;
	box-sizing: border-box;
}

.hw-gallery-search-input {
	width: 100%;
	padding: 7px 12px 7px 32px;
	border: 1px solid #ddd;
	border-radius: 20px;
	font-family: 'Lato', sans-serif;
	font-size: 0.78rem;
	color: #5a5149;
	background: #fff;
	outline: none;
	transition: border-color 0.2s;
	-webkit-appearance: none;
	appearance: none;
}

.hw-gallery-search-input:focus {
	border-color: #c8956c;
}

.hw-gallery-search-input::placeholder {
	color: #82756a;
}

.hw-gallery-search-icon {
	position: absolute;
	left: 10px;
	top: 50%;
	transform: translateY(-50%);
	color: #82756a;
	pointer-events: none;
	line-height: 1;
}

/* Clear "x" button in search field (WebKit/Blink) */
.hw-gallery-search-input::-webkit-search-cancel-button {
	-webkit-appearance: none;
	appearance: none;
	height: 14px;
	width: 14px;
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E") center/contain no-repeat;
	cursor: pointer;
}

/* --- Search dropdown suggestions --- */
.hw-search-dropdown {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	margin-top: 4px;
	background: #fff;
	border: 1px solid #ede6df;
	border-radius: 12px;
	box-shadow: 0 6px 20px rgba(0,0,0,0.08);
	z-index: 300;
	overflow: hidden;
}

.hw-search-suggestion {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 14px;
	cursor: pointer;
	transition: background 0.15s;
	font-size: 0.8rem;
	color: #5a5149;
}

.hw-search-suggestion:hover,
.hw-search-suggestion.hw-search-suggestion-active {
	background: #fdf8f5;
}

.hw-search-suggestion-icon {
	flex-shrink: 0;
	color: #c8956c;
	line-height: 1;
}

.hw-search-suggestion-label {
	flex: 1;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.hw-search-suggestion-type {
	flex-shrink: 0;
	font-size: 0.65rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #82756a;
}

@media (max-width: 768px) {
	.hw-filter-bar-top {
		flex-direction: column;
		align-items: stretch;
		gap: 8px;
	}
	.hw-gallery-search {
		max-width: none;
		order: 1;           /* Search below the toggle button */
		width: 100%;
		margin-left: 0;
	}
	.hw-filter-toggle {
		order: 0;           /* Toggle button first */
		width: 100%;
	}
}

/* --- Color swatches --- */
.hw-color-swatch {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 4px 10px 4px 6px;
	border: 1.5px solid #ede6df;
	border-radius: 20px;
	font-size: 0.78rem;
	color: #5a5149;
	cursor: pointer;
	transition: all 0.2s ease;
	white-space: nowrap;
	flex-shrink: 0;
	background: #fff;
	text-decoration: none;
}

.hw-color-swatch:hover {
	border-color: #c8956c;
	color: #3a3633;
	text-decoration: none;
}

.hw-color-swatch.active {
	border-color: #c8956c;
	background: #fdf8f5;
	color: #3a3633;
	font-weight: 600;
}

.hw-color-dot {
	display: inline-block;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	border: 1px solid rgba(0, 0, 0, 0.1);
	flex-shrink: 0;
}

/* --- Pill filters (categories, seasons, styles) --- */
.hw-filter-pill {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 5px 12px;
	border: 1.5px solid #ede6df;
	border-radius: 20px;
	font-size: 0.78rem;
	color: #5a5149;
	cursor: pointer;
	transition: all 0.2s ease;
	white-space: nowrap;
	flex-shrink: 0;
	background: #fff;
	text-decoration: none;
}

.hw-filter-pill:hover {
	border-color: #c8956c;
	color: #3a3633;
	text-decoration: none;
}

.hw-filter-pill.active {
	border-color: #c8956c;
	background: #c8956c;
	color: #fff;
}

.hw-filter-pill .hw-filter-count {
	font-size: 0.65rem;
	opacity: 0.75;
	margin-left: 2px;
}

.hw-filter-pill.active .hw-filter-count {
	opacity: 0.9;
}

/* --- Season icons --- */
.hw-season-icon {
	font-size: 0.9em;
}

/* --- Active filters bar --- */
.hw-active-filters {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 8px;
	padding-top: 8px;
	border-top: 1px solid #f0e9e2;
}

.hw-active-filter-tag {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 3px 8px;
	background: #fdf8f5;
	border: 1px solid #ecc3ad;
	border-radius: 4px;
	font-size: 0.72rem;
	color: #8a5e3c;
}

.hw-active-filter-remove {
	cursor: pointer;
	font-weight: 700;
	opacity: 0.6;
	transition: opacity 0.2s;
	text-decoration: none;
	color: inherit;
}

.hw-active-filter-remove:hover {
	opacity: 1;
	text-decoration: none;
	color: inherit;
}

.hw-clear-all-filters {
	font-size: 0.72rem;
	color: #96663e;
	text-decoration: none;
	white-space: nowrap;
	margin-left: auto;
}

.hw-clear-all-filters:hover {
	color: #a06f48;
	text-decoration: underline;
}

/* --- Filter toggle button — matches vendor page style --- */
.hw-filter-toggle {
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	gap: 6px;
	-webkit-appearance: none !important;
	appearance: none !important;
	background: transparent !important;
	border: 1px solid #d87d54 !important;
	border-radius: 20px !important;
	padding: 7px 18px !important;
	font-family: 'Lato', sans-serif !important;
	font-weight: 400 !important;
	font-size: 0.75rem !important;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #d87d54 !important;
	cursor: pointer;
	margin: 0 auto 1em !important;
	box-shadow: none !important;
	outline: none;
	transition: all 0.2s;
	position: static !important;
	z-index: auto !important;
	line-height: normal !important;
	vertical-align: baseline !important;
	text-align: center !important;
	width: auto !important;
}

.hw-filter-toggle::before,
.hw-filter-toggle::after {
	display: none !important;
	content: none !important;
}

.hw-filter-toggle:hover {
	border-color: #c06a40 !important;
	color: #c06a40 !important;
}

.hw-filter-toggle[aria-expanded="true"] {
	background: #d87d54 !important;
	border-color: #d87d54 !important;
	color: #fff !important;
}

.hw-filter-toggle-icon {
	font-size: 0.6em;
	transition: transform 0.2s;
}

.hw-filter-toggle[aria-expanded="true"] .hw-filter-toggle-icon {
	transform: rotate(180deg);
}

.hw-filter-rows {
	display: none;
	margin-top: 6px;
}

.hw-filter-rows.hw-filters-open {
	display: block;
}

@media (max-width: 767px) {
	.hw-gallery-filters {
		padding: 8px 12px;
		margin: 0 -12px 16px;
		top: 60px;                  /* mobile header is typically shorter */
	}
	.hw-filter-label {
		min-width: 50px;
		font-size: 0.68rem;
	}
}

/* =========================================================================
 * 2. GALLERY GRID
 * ========================================================================= */

.hw-gallery-grid {
	columns: 2;
	column-gap: 6px;
	margin-bottom: 40px;
}

@media (min-width: 640px) {
	.hw-gallery-grid {
		columns: 3;
	}
}

@media (min-width: 1024px) {
	.hw-gallery-grid {
		columns: 4;
	}
}

/* --- Gallery item (link wrapper) --- */
a.hw-gallery-item,
.hw-gallery-item {
	position: relative;
	overflow: hidden;
	background: #f5f0eb;
	break-inside: avoid;
	margin-bottom: 6px;
	display: block;
	text-decoration: none;
	color: inherit;
}

.hw-gallery-item img {
	display: block;
	width: 100%;
	height: auto;
	transition: transform 0.4s ease, opacity 0.3s ease;
}

/* "Zum Beitrag" call-to-action in overlay */
.hw-gallery-cta {
	color: #fff;
	font-size: 0.72rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	opacity: 0.85;
}

.hw-gallery-item:hover img {
	transform: scale(1.03);
}

/* --- Hover overlay --- */
.hw-gallery-overlay {
	position: absolute;
	inset: 0;
	background: linear-gradient(0deg, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0) 50%);
	opacity: 0;
	transition: opacity 0.3s ease;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	padding: 12px;
	cursor: pointer;
}

.hw-gallery-item:hover .hw-gallery-overlay {
	opacity: 1;
}

.hw-gallery-overlay-info {
	color: #fff;
	font-size: 0.8rem;
	line-height: 1.4;
}

.hw-gallery-overlay-photographer {
	font-weight: 600;
	font-size: 0.75rem;
	opacity: 0.9;
}

.hw-gallery-overlay-actions {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 6px;
}

.hw-gallery-overlay-actions a {
	color: #fff;
	text-decoration: none;
	font-size: 0.72rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	opacity: 0.85;
	transition: opacity 0.2s;
}

.hw-gallery-overlay-actions a:hover {
	opacity: 1;
	color: #fff;
	text-decoration: none;
}

.hw-gallery-overlay-actions svg {
	vertical-align: middle;
	margin-right: 3px;
}

/* Heart/bookmark button in overlay */
.hw-gallery-heart {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	color: #fff !important;
	background: none;
	border: none;
	padding: 0;
	cursor: pointer;
}

.hw-gallery-heart.hw-bm-active svg {
	fill: #e27a5f;
	stroke: #e27a5f;
}

/* =========================================================================
 * 3. LIGHTBOX — disabled (images link to post instead)
 * ========================================================================= */

/* =========================================================================
 * 4. LOADING STATES
 * ========================================================================= */

.hw-gallery-loading {
	text-align: center;
	padding: 40px 20px;
	color: #8a7e75;
	font-size: 0.85rem;
}

.hw-gallery-spinner {
	display: inline-block;
	width: 24px;
	height: 24px;
	border: 2px solid #ede6df;
	border-top-color: #c8956c;
	border-radius: 50%;
	animation: hw-spin 0.7s linear infinite;
	margin-bottom: 8px;
}

@keyframes hw-spin {
	to { transform: rotate(360deg); }
}

.hw-gallery-end {
	text-align: center;
	padding: 32px 20px;
	color: #82756a;
	font-size: 0.8rem;
	font-style: italic;
}

/* =========================================================================
 * 5. EMPTY STATE
 * ========================================================================= */

.hw-gallery-empty {
	text-align: center;
	padding: 60px 20px;
	color: #8a7e75;
}

.hw-gallery-empty-icon {
	font-size: 3rem;
	margin-bottom: 12px;
	opacity: 0.4;
}

.hw-gallery-empty h3 {
	margin: 0 0 8px;
	font-size: 1.1rem;
	color: #5a5149;
}

.hw-gallery-empty p {
	font-size: 0.88rem;
	margin: 0;
}

/* =========================================================================
 * 6. PAGE HEADER OVERRIDE
 * ========================================================================= */

.page-template-template-gallery-scroll .page-header {
	margin-bottom: 0;
}

.page-template-template-gallery-scroll .page-title {
	font-size: 1.8rem;
	margin-bottom: 8px;
}

.hw-gallery-subtitle {
	font-size: 0.88rem;
	color: #6b6058;
	font-style: italic;
	margin-bottom: 16px;
}

/* =========================================================================
 * 7. SKELETON LOADING (initial page load)
 * ========================================================================= */

.hw-gallery-skeleton {
	columns: 2;
	column-gap: 6px;
}

@media (min-width: 640px) {
	.hw-gallery-skeleton { columns: 3; }
}

@media (min-width: 1024px) {
	.hw-gallery-skeleton { columns: 4; }
}

.hw-skeleton-item {
	aspect-ratio: 3 / 4;
	background: linear-gradient(110deg, #f5f0eb 30%, #ede6df 50%, #f5f0eb 70%);
	background-size: 200% 100%;
	animation: hw-shimmer 1.5s ease-in-out infinite;
	border-radius: 2px;
	break-inside: avoid;
	margin-bottom: 6px;
}

@keyframes hw-shimmer {
	0% { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}

/* =========================================================================
 * 8. RESPONSIVE FIXES
 * ========================================================================= */

@media (max-width: 480px) {
	.hw-gallery-grid {
		column-gap: 4px;
	}

	.hw-gallery-item {
		margin-bottom: 4px;
	}

	.hw-gallery-overlay {
		padding: 8px;
	}

	.hw-gallery-overlay-info {
		font-size: 0.7rem;
	}
}
