/* ==========================================================================
   Russian Clothing Brands Directory - Elegant Design
   ========================================================================== */

/* Custom Fonts
   ========================================================================== */
@font-face {
  font-family: 'Fit';
  src:
    url('/fonts/Fit-Variable-Web.woff2') format('woff2-variations'),
    url('/fonts/Fit-Variable-Web.woff2') format('woff2'),
    url('/fonts/Fit-Variable-Web.woff') format('woff');
  font-weight: 100 900;
  font-stretch: 25% 200%;
  font-style: normal;
  font-display: swap;
}

/* CSS Custom Property Registration
   Fixes Firefox bug with mixed viewport units in trig functions.
   @property converts viewport units to computed pixel lengths.
   ========================================================================== */
@property --100vh {
  syntax: "<length>";
  initial-value: 0px;
  inherits: false;
}

@property --100vw {
  syntax: "<length>";
  initial-value: 0px;
  inherits: false;
}

/* CSS Variables - Zinc Palette
   ========================================================================== */
:root {
  /* Colors - Zinc scale */
  --zinc-50: #fafafa;
  --zinc-100: #f4f4f5;
  --zinc-200: #e4e4e7;
  --zinc-300: #d4d4d8;
  --zinc-400: #a1a1aa;
  --zinc-500: #71717a;
  --zinc-600: #52525b;
  --zinc-700: #3f3f46;
  --zinc-800: #27272a;
  --zinc-900: #18181b;

  /* Semantic colors */
  --color-text: var(--zinc-900);
  --color-text-muted: var(--zinc-500);
  --color-text-light: var(--zinc-400);
  --color-background: #ffffff;
  --color-background-alt: var(--zinc-50);
  --color-border: var(--zinc-100);
  --color-border-hover: var(--zinc-300);

  /* Typography - Manrope: neutral geometric grotesque */
  --font-primary: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing */
  --spacing-1: 0.25rem;
  --spacing-2: 0.5rem;
  --spacing-3: 0.75rem;
  --spacing-4: 1rem;
  --spacing-5: 1.25rem;
  --spacing-6: 1.5rem;
  --spacing-8: 2rem;
  --spacing-10: 2.5rem;
  --spacing-12: 3rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Z-index layers for mobile filter drawer */
  --z-filter-bar: 100;
  --z-filter-backdrop: 150;
  --z-filter-drawer: 200;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
  --transition-slow: 500ms ease;
  --transition-gallery: 600ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --transition-gallery-hover: 80ms ease-out;

  /* Border radius - minimal for gallery frame aesthetic */
  --radius-sm: 0;
  --radius-md: 0;
  --radius-full: 9999px;

  /* Gallery Stack Configuration - these vars control the stacked card layout */
  --gallery-stack-offset: 10px; /* Base offset between stacked cards (X and Y) */
  --gallery-shadow-buffer: 8px; /* Extra padding for drop shadows */
  --gallery-stack-padding: calc(4 * var(--gallery-stack-offset) + var(--gallery-shadow-buffer));
  --gallery-min-height: 200px; /* Fallback min-height before images load */
}

/* Base Styles
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-primary);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-background);
}

/* Typography
   ========================================================================== */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-primary);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast);
}

/* Skip Link
   ========================================================================== */
.skip-link {
  position: absolute;
  top: -50px;
  left: var(--spacing-4);
  background: var(--zinc-900);
  color: white;
  padding: var(--spacing-2) var(--spacing-4);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 1000;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: var(--spacing-4);
  outline: 2px solid var(--zinc-400);
  outline-offset: 2px;
}

/* Visually Hidden
   ========================================================================== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Page Wrapper - enables grid layout for branding + main on desktop
   ========================================================================== */
.page-wrapper {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--spacing-8) var(--spacing-4);
}

/* Site Branding
   ========================================================================== */
.site-branding {
  text-align: center;
  margin-bottom: var(--spacing-6);
  /* Enable container queries for proportional logo scaling */
  container-type: inline-size;
}

.site-title {
  font-family: 'Fit', var(--font-primary);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0;
  line-height: 0.75;
  color: var(--zinc-900);
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-wrap: break-word;

  /* ========================================
     LAYER 1: Base fallback (all browsers)
     ======================================== */
  font-size: clamp(1.5rem, 6vw, 3rem);
  font-stretch: 150%;

  /* ========================================
     LAYER 2: Linear responsive fallback
     Works in all modern browsers (no pow/trig needed).
     Approximates aspect-ratio response using viewport width.
     Range: 150% stretch at 320px → 75% stretch at 768px
     ======================================== */
  --linear-factor: clamp(0, calc((100vw - 320px) / 448px), 1);
  font-stretch: clamp(50%, calc(150% - var(--linear-factor) * 75%), 200%);

  /* Stretch as decimal for inverse font-size scaling */
  --stretch-decimal: max(0.5, calc(1.5 - var(--linear-factor) * 0.75));
  font-size: calc(16.5cqi / var(--stretch-decimal));
}

/* ========================================
   LAYER 3: Enhanced trig-based response
   Responds to actual viewport aspect ratio.
   Safari fix: wrap trig in calc()
   Firefox exclusion: initial-letter not supported, so Firefox
   stays on Layer 2 (avoids atan2 mixed-unit bug without @property)
   ======================================== */
@supports (font-size: calc(1px * pow(2, 2))) and (initial-letter: 1) {
  .site-title {
    /* Set registered properties to capture viewport dimensions */
    --100vh: 100vh;
    --100vw: 100vw;

    /* Calculate aspect angle using registered (computed) lengths
       calc() wrapper fixes Safari bug with nested trig functions */
    --aspect-angle: calc(atan2(var(--100vh), var(--100vw)));

    /* cos() returns 0-1: 1 for wide, ~0.707 for square, 0 for tall
       pow(x, 4) creates steep curve for dramatic response */
    --stretch-factor: calc(pow(cos(var(--aspect-angle)), 4));

    /* Map to font-stretch: 50% (tall/square) to 200% (ultra-wide)
       CORRECTED: Using 50% minimum (CSS spec range is 50-200%) */
    font-stretch: clamp(50%, calc(50% + var(--stretch-factor) * 150%), 200%);

    /* Stretch as decimal for inverse font-size calculation */
    --stretch-decimal: calc(0.5 + var(--stretch-factor) * 1.5);
    font-size: calc(16.5cqi / var(--stretch-decimal));
  }
}

.site-tagline {
  font-size: 0.875rem;
  color: var(--zinc-500);
  margin-top: var(--spacing-2);
}

/* Filter Sidebar - minimal chrome
   ========================================================================== */
.filters-sidebar {
  padding-bottom: var(--spacing-6);
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

.filters-form {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-3);
  align-items: flex-start;
}

.filter-group {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--spacing-2);
  width: 100%;
}

.filter-group fieldset {
  display: contents;
}

.filter-group select {
  width: 100%;
  padding: var(--spacing-2) var(--spacing-3);
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid var(--color-border);
  background-color: var(--color-background);
  transition: border-color var(--transition-fast);
}

.filter-group select:hover {
  border-color: var(--color-border-hover);
}

.filter-group select:focus {
  outline: none;
  border-color: var(--zinc-400);
}

.filter-legend {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--spacing-2);
}

.radio-label {
  display: inline-flex;
  align-items: center;
  padding: var(--spacing-1) var(--spacing-2) var(--spacing-1) 0;
  font-size: 0.8125rem;
  color: var(--zinc-400);
  cursor: pointer;
  transition: color var(--transition-fast);
  user-select: none;
  text-align: left;
}

.radio-label:hover {
  color: var(--zinc-600);
}

.radio-label:has(input:checked) {
  color: var(--zinc-900);
  font-weight: 600;
}

.radio-label input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Mobile Filter Bar & Drawer
   ========================================================================== */

/* Hidden by default on desktop/tablet - only shown on mobile via media query */
.mobile-filter-bar {
  display: none;
}

.filter-drawer-backdrop {
  display: none;
}

.filter-drawer {
  display: none;
}

/* Brands Container
   ========================================================================== */
.brands-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-12);
}

/* Brand Card
   ========================================================================== */
.brand-card {
  display: flex;
  flex-direction: row;
  gap: var(--spacing-8);
  align-items: flex-start;
  /* Create stacking context to isolate gallery z-index from other brand cards */
  isolation: isolate;
  position: relative;
  z-index: 0;
}

/* Image Gallery - Natural Stack
   ========================================================================== */
.image-gallery {
  position: relative;
  width: 45%;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
  isolation: isolate;
  order: 2;
  /* Flex container to vertically center content */
  display: flex;
  align-items: center;
  /* Fallback min-height before JS measures - taller for better portrait support */
  min-height: var(--gallery-min-height);
  /* Bottom padding accounts for back cards' Y offset + shadows (uses CSS var) */
  padding-bottom: var(--gallery-stack-padding);
  margin-bottom: 0;
}

/* Once JS sets explicit height, remove min-height */
.image-gallery[style*='height'] {
  min-height: unset;
}

.gallery-card {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  transition: all var(--transition-gallery);
  /* Base centering transform - combined with position-specific transforms */
  transform: translateY(-50%);
}

/* Faster transitions during hover interaction */
.image-gallery[data-hover-active='true'] .gallery-card {
  transition: all var(--transition-gallery-hover);
}

/* Stacked card positions - transforms include vertical centering
   Offsets use --gallery-stack-offset (1×, 2×, 3×, 4×)
   --gallery-stack-padding auto-calculates from offset, so changing offset "just works" */
.gallery-card[data-index='0'] {
  position: relative;
  top: auto;
  z-index: 5;
  transform: none;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.08));
}

.gallery-card[data-index='1'] {
  z-index: 4;
  transform: translateY(-50%)
    translate3d(var(--gallery-stack-offset), var(--gallery-stack-offset), 0) rotate(1.5deg);
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.06));
}

.gallery-card[data-index='2'] {
  z-index: 3;
  transform: translateY(-50%)
    translate3d(calc(2 * var(--gallery-stack-offset)), calc(2 * var(--gallery-stack-offset)), 0)
    rotate(-1deg);
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.04));
}

.gallery-card[data-index='3'] {
  z-index: 2;
  transform: translateY(-50%)
    translate3d(calc(3 * var(--gallery-stack-offset)), calc(3 * var(--gallery-stack-offset)), 0)
    rotate(0.5deg);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.03));
}

.gallery-card[data-index='4'] {
  z-index: 1;
  transform: translateY(-50%)
    translate3d(calc(4 * var(--gallery-stack-offset)), calc(4 * var(--gallery-stack-offset)), 0)
    rotate(-0.5deg);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.02));
}

/* Exiting card animation */
.gallery-card.exiting {
  position: absolute !important;
  top: 50% !important;
  z-index: 0 !important;
  transform: translateY(-50%) translate3d(0, 20px, 0) scale(0.95) !important;
  opacity: 0 !important;
  filter: none !important;
}

.gallery-card-inner {
  position: relative;
  width: 100%;
}

.gallery-image {
  width: 100%;
  height: auto;
  display: block;
}

.gallery-card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

/* Gallery hover effects - subtle lift */
.image-gallery:hover .gallery-card[data-index='0'] {
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.1));
}

/* Prevent sticky hover states on touch devices */
@media (hover: none) {
  .image-gallery:hover .gallery-card[data-index='0'] {
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.08));
  }
}

/* Gallery empty state */
.gallery-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 3 / 4;
  background: var(--zinc-100);
  color: var(--zinc-400);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Brand Content
   ========================================================================== */
.brand-content {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  order: 1;
  min-width: 0;
}

/* Brand Header */
.brand-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: var(--spacing-3);
  border-bottom: 1px solid var(--zinc-100);
  margin-bottom: var(--spacing-3);
}

.brand-header-left {
  flex: 1;
}

.brand-name {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: var(--spacing-2);
}

.brand-name a {
  color: var(--zinc-900);
}

.brand-name a:hover {
  color: var(--zinc-600);
}

.brand-origin {
  font-weight: 400;
  color: var(--zinc-500);
}

.brand-name a:hover .brand-origin {
  color: var(--zinc-500);
}

.brand-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-3);
  font-size: 0.75rem;
  color: var(--zinc-500);
}

.brand-url {
  color: var(--zinc-400);
  text-decoration: underline;
  word-break: break-all;
  transition: color var(--transition-fast);
}

.brand-url:hover {
  color: var(--zinc-600);
}

.meta-dot {
  width: 3px;
  height: 3px;
  background: var(--zinc-300);
  border-radius: 50%;
}

/* Price Badge - plain text */
.price-badge {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--zinc-400);
}

/* Brand Description */
.brand-description-wrapper {
  flex-grow: 1;
  margin-bottom: var(--spacing-4);
}

.brand-description {
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--zinc-600);
  font-weight: 300;
}

/* Brand Footer */
.brand-footer {
  margin-top: auto;
}

/* Meta Tags - plain text, minimal */
.meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-1);
  font-size: 0.75rem;
  color: var(--zinc-400);
}

.meta-tag {
  color: inherit;
}

.meta-tag:not(:last-child)::after {
  content: ' · ';
}

/* Brand Actions */
.brand-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--spacing-2);
}

/* Social Links */
.social-links {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
}

.social-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--zinc-400);
  padding: var(--spacing-1);
  margin: calc(var(--spacing-1) * -1);
  transition: color var(--transition-fast);
}

.social-icon:hover {
  color: var(--zinc-900);
}

.social-icon--vk span {
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1;
}

/* Brand CTA */
.brand-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-2);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--zinc-900);
  transition: color var(--transition-fast);
}

.brand-cta:hover {
  color: var(--zinc-600);
}

.brand-cta svg {
  transition: transform var(--transition-fast);
}

.brand-cta:hover svg {
  transform: translate(2px, -2px);
}

/* Load More Section
   ========================================================================== */
.load-more-section {
  text-align: center;
  margin-top: var(--spacing-10);
}

.load-more-button {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-2);
  padding: var(--spacing-3) var(--spacing-6);
  font-size: 0.75rem;
  font-weight: 700;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--zinc-900);
  background: transparent;
  border: 1px solid var(--zinc-900);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.load-more-button:hover {
  background: var(--zinc-900);
  color: white;
}

.load-more-button:focus {
  outline: 2px solid var(--zinc-400);
  outline-offset: 2px;
}

.load-more-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.end-message,
.no-results {
  font-size: 0.875rem;
  color: var(--zinc-400);
  padding: var(--spacing-6);
}

/* Empty Filter State
   Editorial/minimal design - typography-focused, no decorative elements
   ========================================================================== */
.filter-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-16) var(--spacing-6);
  text-align: center;
  min-height: 240px;
}

.filter-empty-state__title {
  font-size: 1rem;
  font-weight: 400;
  color: var(--zinc-500);
  margin: 0 0 var(--spacing-6);
  letter-spacing: 0.02em;
}

.filter-empty-state__reset {
  padding: var(--spacing-2) var(--spacing-4);
  background: transparent;
  color: var(--zinc-900);
  border: 1px solid var(--zinc-300);
  border-radius: 2px;
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease;
}

.filter-empty-state__reset:hover {
  border-color: var(--zinc-900);
}

.filter-empty-state__reset:focus-visible {
  outline: 2px solid var(--zinc-400);
  outline-offset: 2px;
}

/* HTMX Indicators
   ========================================================================== */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-flex;
}

#loading-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  padding: var(--spacing-6);
  border: 1px solid var(--zinc-100);
  box-shadow: var(--shadow-xl);
  z-index: 1000;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--zinc-200);
  border-top-color: var(--zinc-900);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.button-spinner {
  width: 14px;
  height: 14px;
}

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

/* Footer
   ========================================================================== */
footer[role='contentinfo'] {
  margin-top: 25rem;
  padding: var(--spacing-8) var(--spacing-4);
  text-align: center;
  border-top: 1px solid var(--color-border);
}

.footer-container {
  max-width: 800px;
  margin: 0 auto;
  font-size: 0.75rem;
  color: var(--zinc-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.footer-container .email-link {
  color: var(--zinc-400);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s ease;
}

.footer-container .email-link:hover {
  color: var(--zinc-300);
}

/* Focus Styles
   ========================================================================== */
*:focus {
  outline: 2px solid var(--zinc-400);
  outline-offset: 2px;
}

*:focus:not(:focus-visible) {
  outline: none;
}

*:focus-visible {
  outline: 2px solid var(--zinc-400);
  outline-offset: 2px;
}

/* Responsive Styles
   ========================================================================== */

/* Tablet */
@media (max-width: 768px) {
  .directory-layout {
    max-width: 100%;
  }

  .brand-name {
    font-size: 1.25rem;
  }

  .brand-card {
    flex-direction: column;
    gap: var(--spacing-6);
  }

  .image-gallery {
    width: 100%;
    order: 1;
    margin-bottom: var(--spacing-4);
  }

  /* Make cards narrower to fit entire stack within container.
     Width reduction = (cardCount - 1) × offset, using data-card-count attribute.
     This is stable during animation and works in all browsers (no :has() needed). */

  /* 3 images: max offset = 2 × 10px = 20px */
  .image-gallery[data-card-count='3'] .gallery-card {
    width: calc(100% - 2 * var(--gallery-stack-offset));
  }

  /* 4 images: max offset = 3 × 10px = 30px */
  .image-gallery[data-card-count='4'] .gallery-card {
    width: calc(100% - 3 * var(--gallery-stack-offset));
  }

  /* 5 images: max offset = 4 × 10px = 40px */
  .image-gallery[data-card-count='5'] .gallery-card {
    width: calc(100% - 4 * var(--gallery-stack-offset));
  }

  .brand-content {
    order: 2;
  }
}

/* Mobile */
@media (max-width: 480px) {
  html {
    font-size: 15px;
  }

  .brand-actions {
    flex-direction: column;
    gap: var(--spacing-4);
    align-items: stretch;
  }

  .social-links {
    justify-content: center;
  }

  .brand-cta {
    justify-content: center;
  }

  /* ========================================================================
     Mobile Filter Drawer System
     ======================================================================== */

  /*
   * Progressive enhancement: sidebar stays visible by default on mobile.
   * JS adds 'js-drawer-enabled' class to html, which hides sidebar.
   * Without JS, mobile users still see filters in sidebar (scrollable).
   * Note: We check html.js-drawer-enabled for FOUC prevention (class added before body renders)
   */
  html.js-drawer-enabled .filters-sidebar {
    display: none;
  }

  /* Mobile Filter Bar - hidden by default, shown only when JS enables drawer */
  .mobile-filter-bar {
    display: none;
  }

  html.js-drawer-enabled .mobile-filter-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-filter-bar);
    height: 52px;
    padding: 0 var(--spacing-4);
    background: var(--color-background);
    border-top: 1px solid var(--color-border);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-filter-bar:active {
    background: var(--zinc-50);
  }

  .mobile-filter-bar:focus-visible {
    outline: 2px solid var(--zinc-400);
    outline-offset: -2px;
  }

  .filter-bar-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--zinc-600);
    text-align: center;
    max-width: 80%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .filter-bar-text--active {
    color: var(--zinc-900);
  }

  /* Filter Drawer Backdrop */
  .filter-drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: var(--z-filter-backdrop);
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
  }

  .filter-drawer-backdrop[data-open="true"] {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* Filter Drawer Panel */
  .filter-drawer {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-filter-drawer);
    background: var(--color-background);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    visibility: hidden;
    pointer-events: none;
    transition: transform var(--transition-normal), visibility var(--transition-normal);
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .filter-drawer[data-open="true"] {
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
  }

  /* Drawer handle indicator */
  .filter-drawer-handle {
    display: flex;
    justify-content: center;
    padding: var(--spacing-3) 0;
    cursor: grab;
  }

  .filter-drawer-handle::before {
    content: '';
    width: 36px;
    height: 4px;
    background: var(--zinc-300);
    border-radius: var(--radius-full);
  }

  /* Drawer content wrapper */
  .filter-drawer-content {
    padding: 0 var(--spacing-4) var(--spacing-6);
  }

  /* Drawer filter chips (above filter form in drawer) */
  .drawer-filter-chips {
    display: flex;
    gap: var(--spacing-2);
    align-items: center;
    padding: var(--spacing-3) var(--spacing-4);
    margin: 0 calc(-1 * var(--spacing-4));
    border-bottom: 1px solid var(--color-border);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .drawer-filter-chips::-webkit-scrollbar {
    display: none;
  }

  .drawer-filter-chips--empty {
    display: none;
  }

  .drawer-filter-chips .filter-chip {
    flex-shrink: 0;
  }

  .drawer-filter-chips .filter-chip--clear {
    margin-left: auto;
  }

  /* Hide desktop active-filters on mobile (chips are in drawer) */
  html.js-drawer-enabled .active-filters {
    display: none;
  }

  /* Filter form styles when inside drawer */
  .filter-drawer .filters-form {
    gap: var(--spacing-4);
  }

  .filter-drawer .filter-group {
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-drawer .filter-legend {
    margin-bottom: var(--spacing-2);
  }

  .filter-drawer .radio-group {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--spacing-2);
  }

  /* Pill-style radio labels in drawer */
  .filter-drawer .radio-label {
    padding: var(--spacing-2) var(--spacing-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
  }

  .filter-drawer .radio-label:has(input:checked) {
    background: var(--zinc-900);
    border-color: var(--zinc-900);
    color: white;
  }

  /* Hide filter bar when drawer is open */
  html.js-drawer-enabled[data-drawer-open="true"] .mobile-filter-bar {
    opacity: 0;
    pointer-events: none;
  }

  /* Prevent body scroll when drawer is open */
  html.js-drawer-enabled[data-drawer-open="true"] body {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }

  /* Add bottom padding only when drawer is enabled (bar is visible) */
  html.js-drawer-enabled .page-wrapper {
    padding-bottom: calc(52px + var(--spacing-4));
  }
}

/* Desktop - Sidebar Layout (1/3 sidebar, 2/3 main)
   ========================================================================== */
@media (min-width: 1024px) {
  .page-wrapper {
    display: grid;
    grid-template-columns: 33.33vw 1fr; /* Sidebar = 1/3 viewport */
    grid-template-rows: auto 1fr;
    gap: var(--spacing-10);
    max-width: none;
    padding: var(--spacing-8) var(--spacing-10);
  }

  .site-branding {
    grid-column: 1;
    grid-row: 1;
    text-align: left;
    margin-bottom: 0;
    max-width: 400px;
    justify-self: center;
    width: 100%;
  }

  .site-title {
    /* ========================================
       LAYER 2: Linear responsive (no pow needed)
       Works in all browsers. Linear interpolation.
       At 1024px: 150% stretch, at 1400px: 50% stretch
       ======================================== */
    --vw-factor: clamp(0, calc((100vw - 1024px) / 376px), 1);
    font-stretch: calc(150% - var(--vw-factor) * 100%);

    /* Stretch decimal (1.5 to 0.5) for inverse font-size scaling */
    --stretch-decimal: calc(1.5 - var(--vw-factor));
    font-size: calc(28cqi / var(--stretch-decimal));

    width: 100%;
  }

  /* ========================================
     LAYER 3: Enhanced with pow() curve
     pow(x, 0.6) creates curve that changes faster at narrow end.
     Firefox excluded via initial-letter check (no @property support)
     ======================================== */
  @supports (font-size: calc(1px * pow(2, 2))) and (initial-letter: 1) {
    .site-branding .site-title {
      --vw-factor: clamp(0, calc((100vw - 1024px) / 376px), 1);

      /* pow(x, 0.6) creates curve - faster changes at narrow end */
      --dramatic-factor: calc(pow(var(--vw-factor), 0.6));

      /* Stretch: 150% at narrow, 50% at wide */
      font-stretch: calc(150% - var(--dramatic-factor) * 100%);
      --stretch-decimal: calc(1.5 - var(--dramatic-factor));
      font-size: calc(28cqi / var(--stretch-decimal));
    }
  }

  .filters-sidebar {
    grid-column: 1;
    grid-row: 2;
    padding-bottom: 0;
    border-bottom: none;
    max-width: 400px;
    justify-self: center;
    width: 100%;
  }

  main[role='main'] {
    grid-column: 2;
    grid-row: 1 / -1;
    max-width: 933px;
    justify-self: center;
    width: 100%;
  }

  /* Desktop: Make cards narrower to fit entire stack within container.
     Same logic as tablet - reduce width by (cardCount - 1) × offset */
  .image-gallery[data-card-count='3'] .gallery-card {
    width: calc(100% - 2 * var(--gallery-stack-offset));
  }

  .image-gallery[data-card-count='4'] .gallery-card {
    width: calc(100% - 3 * var(--gallery-stack-offset));
  }

  .image-gallery[data-card-count='5'] .gallery-card {
    width: calc(100% - 4 * var(--gallery-stack-offset));
  }

}

/* ==========================================================================
   Checkbox Filter Styles (Multiselect)
   ========================================================================== */

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--spacing-2);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-1);
  padding: var(--spacing-1) var(--spacing-2) var(--spacing-1) 0;
  font-size: 0.8125rem;
  color: var(--zinc-400);
  cursor: pointer;
  transition: color var(--transition-fast);
  user-select: none;
}

.checkbox-label:hover {
  color: var(--zinc-600);
}

.checkbox-label:has(input:checked) {
  color: var(--zinc-900);
  font-weight: 600;
}

/* Custom checkbox styling */
.checkbox-label input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 1px solid var(--zinc-300);
  border-radius: 2px;
  margin: 0;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked {
  background: var(--zinc-900);
  border-color: var(--zinc-900);
}

.checkbox-label input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-label input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--zinc-400);
  outline-offset: 2px;
}

/* Progressive disclosure for styles */
.checkbox-group--hidden {
  display: none;
  width: 100%;
}

.checkbox-group--hidden[aria-hidden="false"] {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-2);
  margin-top: var(--spacing-2);
}

.filter-expand-btn {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  font-size: 0.75rem;
  font-family: inherit;
  color: var(--zinc-500);
  cursor: pointer;
  text-decoration: underline;
  transition: color var(--transition-fast);
  width: 100%;
  text-align: left;
  margin-bottom: var(--spacing-2);
}

.filter-expand-btn:hover {
  color: var(--zinc-700);
}

.filter-expand-btn:focus-visible {
  outline: 2px solid var(--zinc-400);
  outline-offset: 2px;
}

/* ==========================================================================
   Active Filter Chips
   ========================================================================== */

.active-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-2);
  padding: var(--spacing-3) 0;
  margin-bottom: var(--spacing-4);
  border-bottom: 1px solid var(--color-border);
}

.active-filters--empty {
  display: none;
}

.active-filters-label {
  font-size: 0.75rem;
  color: var(--zinc-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-1);
  padding: var(--spacing-1) var(--spacing-2);
  font-size: 0.75rem;
  font-family: inherit;
  background: var(--zinc-100);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-chip:hover {
  background: var(--zinc-200);
}

.filter-chip:focus-visible {
  outline: 2px solid var(--zinc-400);
  outline-offset: 2px;
}

.filter-chip-remove {
  font-size: 0.875rem;
  line-height: 1;
  opacity: 0.6;
}

.filter-chip:hover .filter-chip-remove {
  opacity: 1;
}

.filter-chip--clear {
  background: transparent;
  color: var(--zinc-500);
  text-decoration: underline;
}

.filter-chip--clear:hover {
  background: transparent;
  color: var(--zinc-700);
}

/* ==========================================================================
   Mobile Checkbox and Chip Styles
   ========================================================================== */

@media (max-width: 480px) {
  /* Pill-style checkboxes in drawer (matching existing radio style) */
  .filter-drawer .checkbox-label {
    padding: var(--spacing-2) var(--spacing-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
  }

  .filter-drawer .checkbox-label:has(input:checked) {
    background: var(--zinc-900);
    border-color: var(--zinc-900);
    color: white;
  }

  /* Hide the checkbox itself in drawer - full pill is the toggle */
  .filter-drawer .checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }

  /* Active filters chips on mobile */
  .active-filters {
    padding: var(--spacing-2);
    margin: 0 calc(var(--spacing-4) * -1) var(--spacing-4);
    padding-left: var(--spacing-4);
    padding-right: var(--spacing-4);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
    border-bottom: 1px solid var(--color-border);
  }

  .active-filters::-webkit-scrollbar {
    display: none;
  }

  .active-filters-label {
    flex-shrink: 0;
  }

  .filter-chip {
    flex-shrink: 0;
  }
}
