/* ========================================
   CE DESIGN SYSTEM
   Single source of truth for the Curation Engine UI

   Token block + dark theme + components + utilities.
   Works standalone without Tailwind dependencies.
   ======================================== */

/* ========================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ======================================== */
:root {
  /* Primary Colors */
  --ce-terracotta: #B85C38;
  --ce-terracotta-light: #D4785A;
  --ce-terracotta-dark: #8F4629;

  /* Secondary Colors */
  --ce-charcoal: #2C2C2C;
  --ce-charcoal-light: #454545;
  --ce-slate: #2B3A42;

  /* Accent Colors */
  --ce-gold: #C9A227;
  --ce-gold-light: #DDB94A;
  --ce-gold-dark: #A6851E;

  /* Background Colors */
  --ce-parchment: #F5F0E8;
  --ce-parchment-deep: #EDE6DA;
  --ce-parchment-light: #FAF8F4;

  /* Surface Colors */
  --ce-white: #FFFFFF;
  --ce-black: #1A1A1A;

  /* Gallery Environment Colors */
  --ce-wall-light: #E8E6E1;
  --ce-wall-dark: #3D3D3D;
  --ce-floor-wood: #C4A77D;
  --ce-floor-concrete: #A8A8A8;

  /* Status Colors (Brand Guide v2.0) */
  --ce-success: #22C55E;
  --ce-warning: #F59E0B;
  --ce-error: #EF4444;

  /* Typography */
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Inter', system-ui, sans-serif;

  /* Spacing Scale (8px rhythm) */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

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

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* Semantic Variables (Light mode defaults) */
  --bg-page: #FAF8F4;
  --bg-surface: #FFFFFF;
  --bg-elevated: #FFFFFF;
  --bg-inset: #F5F0E8;
  --bg-inset-deep: #EDE6DA;
  --text-primary: #2C2C2C;
  --text-secondary: #2B3A42;
  --border-default: #EDE6DA;
  --border-subtle: #EDE6DA;

  /* Legacy variable aliases */
  --ce-red: var(--ce-terracotta);
  --ce-red-light: var(--ce-terracotta-light);
  --ce-red-dark: var(--ce-terracotta-dark);
  --ce-navy: var(--ce-charcoal);
  --ce-bg-light: var(--ce-parchment-light);
  --ce-bg-gallery: var(--ce-parchment-deep);
}

/* ========================================
   DARK THEME
   ======================================== */
[data-theme="dark"] {
  --bg-page: #141210;
  --bg-surface: #1C1A17;
  --bg-elevated: #252320;
  --bg-inset: #252320;
  --bg-inset-deep: #2D2B28;
  --text-primary: #E8E6E1;
  --text-secondary: #9B9590;
  --border-default: #3D3A36;
  --border-subtle: #2D2B28;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

/* ========================================
   BASE STYLES
   ======================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-page);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   TYPOGRAPHY UTILITIES
   ======================================== */

.font-display {
  font-family: var(--font-display);
}

.font-body {
  font-family: var(--font-body);
}

/* Cormorant Garamond: display use only, 1.5rem MINIMUM.
   Below 1.5rem the high-contrast serifs become spindly.
   Use .font-body or var(--font-body) for anything smaller. */
.text-display {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.text-display-lg {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.05em;
  line-height: 1.1;
}

.section-number {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ce-terracotta);
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: var(--space-xs);
}

/* ========================================
   COMPONENT: Cards
   ======================================== */
.ce-card {
  position: relative;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: fadeInUp 0.5s ease-out;
  transition: box-shadow var(--transition-base), border-color var(--transition-base);
}

.ce-card:hover {
  box-shadow: var(--shadow-lg);
}

.ce-card-body {
  padding: var(--space-lg);
}

.ce-card-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-default);
}

.ce-card-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-default);
}

.ce-card-static {
  box-shadow: none;
  border-color: var(--border-default);
}

.ce-card-static:hover {
  box-shadow: none;
}

/* Loading placeholder with CE logo - only on cards with comparison sliders */
.ce-card[data-render-gallery-target="card"]::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  aspect-ratio: 16/9;
  background-color: var(--ce-parchment);
  background-image: url(/ce-logo.png);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 4rem;
  animation: ce-logo-pulse 2s ease-in-out infinite;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 0;
}

/* ========================================
   COMPONENT: Buttons
   ======================================== */
.ce-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  text-decoration: none;
}

.ce-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ce-btn-primary {
  background: var(--ce-terracotta);
  color: var(--ce-white);
}

.ce-btn-primary:hover:not(:disabled) {
  background: var(--ce-terracotta-dark);
}

.ce-btn-secondary {
  background: var(--bg-inset);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

.ce-btn-secondary:hover:not(:disabled) {
  background: var(--bg-inset-deep);
  color: var(--text-primary);
}

.ce-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

.ce-btn-ghost:hover:not(:disabled) {
  background: var(--bg-inset);
  color: var(--text-primary);
}

.ce-btn-gold {
  background: var(--ce-gold);
  color: var(--ce-white);
}

.ce-btn-gold:hover:not(:disabled) {
  background: var(--ce-gold-dark);
}

.ce-btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.8125rem;
}

.ce-btn-lg {
  padding: var(--space-md) var(--space-xl);
  font-size: 1rem;
}

.ce-btn-icon {
  padding: var(--space-sm);
  min-width: 2.5rem;
  min-height: 2.5rem;
}

/* ========================================
   COMPONENT: Badges
   ======================================== */
.ce-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  letter-spacing: 0.025em;
}

.ce-badge-terracotta {
  background: rgba(184, 92, 56, 0.1);
  color: var(--ce-terracotta);
  border: 1px solid rgba(184, 92, 56, 0.2);
}

.ce-badge-slate {
  background: var(--ce-parchment);
  color: var(--ce-slate);
  border: 1px solid var(--ce-parchment-deep);
}

.ce-badge-gold {
  background: rgba(201, 162, 39, 0.1);
  color: var(--ce-gold-dark);
  border: 1px solid rgba(201, 162, 39, 0.2);
}

.ce-badge-success {
  background: rgba(34, 197, 94, 0.1);
  color: var(--ce-success);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.ce-badge-red {
  background: rgba(184, 92, 56, 0.1);
  color: var(--ce-terracotta);
  border: 1px solid rgba(184, 92, 56, 0.2);
}

.ce-badge-cinematic {
  background: linear-gradient(135deg, rgba(184, 92, 56, 0.15) 0%, rgba(201, 162, 39, 0.15) 100%);
  color: var(--ce-terracotta-dark);
  border: 1px solid rgba(184, 92, 56, 0.25);
}

.ce-badge-museum {
  background: rgba(43, 58, 66, 0.1);
  color: var(--ce-slate);
  border: 1px solid rgba(43, 58, 66, 0.2);
}

.ce-badge-architectural {
  background: rgba(44, 44, 44, 0.08);
  color: var(--ce-charcoal);
  border: 1px solid rgba(44, 44, 44, 0.15);
}

.ce-badge-natural {
  background: rgba(74, 124, 89, 0.1);
  color: #4A7C59;
  border: 1px solid rgba(74, 124, 89, 0.2);
}

.ce-badge-artistic {
  background: linear-gradient(135deg, rgba(201, 162, 39, 0.12) 0%, rgba(184, 92, 56, 0.12) 100%);
  color: var(--ce-gold-dark);
  border: 1px solid rgba(201, 162, 39, 0.2);
}

.ce-badge-dramatic {
  background: rgba(44, 44, 44, 0.12);
  color: var(--ce-charcoal);
  border: 1px solid rgba(44, 44, 44, 0.2);
}

/* ========================================
   COMPONENT: Forms
   ======================================== */
.ce-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.ce-input:focus {
  outline: none;
  border-color: var(--ce-terracotta);
  box-shadow: 0 0 0 3px rgba(184, 92, 56, 0.1);
}

.ce-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

.ce-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.ce-form-group {
  margin-bottom: var(--space-lg);
}

.ce-form-group:last-child {
  margin-bottom: 0;
}

.ce-select {
  appearance: none;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  padding-right: calc(var(--space-md) * 2 + 12px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--bg-surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%232B3A42' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-md) center;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  cursor: pointer;
}

.ce-select:focus {
  outline: none;
  border-color: var(--ce-terracotta);
  box-shadow: 0 0 0 3px rgba(184, 92, 56, 0.1);
}

.ce-checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
}

.ce-checkbox {
  width: 1.125rem;
  height: 1.125rem;
  margin-top: 2px;
  accent-color: var(--ce-terracotta);
  cursor: pointer;
}

/* Legacy form class aliases */
.form-group { margin-bottom: var(--space-lg); }
.form-group:last-child { margin-bottom: 0; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--text-primary); margin-bottom: var(--space-xs); }
.form-input {
  display: block;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}
.form-input:focus {
  outline: none;
  border-color: var(--ce-terracotta);
  box-shadow: 0 0 0 3px rgba(184, 92, 56, 0.1);
}
.form-hint { font-size: 0.8125rem; color: var(--text-secondary); margin-top: var(--space-xs); }
.form-textarea { min-height: 100px; resize: vertical; }
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%232B3A42' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-md) center;
  padding-right: calc(var(--space-md) * 2 + 12px);
}
.form-section-title { font-family: var(--font-body); font-size: 1rem; font-weight: 600; }
.form-checkbox-group { display: flex; align-items: flex-start; gap: var(--space-sm); }
.form-checkbox { width: 1.125rem; height: 1.125rem; margin-top: 2px; accent-color: var(--ce-terracotta); cursor: pointer; }

/* ========================================
   COMPONENT: Header
   ======================================== */
.ce-header {
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-default);
}

.ce-header-inner {
  max-width: 80rem;
  margin: 0 auto;
  padding: var(--space-md) var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ce-header-logo {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--ce-terracotta);
  text-decoration: none;
  letter-spacing: 0.05em;
}

.ce-header-nav {
  display: flex;
  gap: var(--space-sm);
}

/* ========================================
   COMPONENT: Footer
   ======================================== */
.ce-footer {
  background: var(--bg-inset);
  border-top: 1px solid var(--border-default);
}

.ce-footer-inner {
  max-width: 80rem;
  margin: 0 auto;
  padding: var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ce-footer-brand {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text-primary);
}

.ce-footer-motto {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* ========================================
   COMPONENT: Pagination
   ======================================== */
.ce-pagination {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.ce-pagination a,
.ce-pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2.5rem;
  padding: 0 var(--space-sm);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  text-decoration: none;
}

.ce-pagination a {
  color: var(--ce-slate);
}

.ce-pagination a:hover {
  background: var(--ce-parchment);
  color: var(--ce-charcoal);
}

.ce-pagination .current {
  background: var(--ce-terracotta);
  color: var(--ce-white);
}

.ce-pagination .disabled {
  color: var(--ce-parchment-deep);
  cursor: not-allowed;
}

/* ========================================
   PAGE STRUCTURE
   ======================================== */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: var(--space-xl); flex-wrap: wrap; gap: var(--space-md); }
.page-title { font-family: var(--font-display); font-size: 2rem; font-weight: 400; color: var(--text-primary); letter-spacing: 0.02em; margin: 0; }
.page-subtitle { font-size: 0.9375rem; color: var(--text-secondary); margin: var(--space-sm) 0 0; }
.page-actions { display: flex; gap: var(--space-sm); }

/* ========================================
   COMPONENT: Sidebar Layout
   Reusable sidebar pattern matching ce-collections.
   Use .ce-sidebar-layout as wrapper, .ce-sidebar for the
   fixed nav panel, .ce-sidebar-content for the main area.
   ======================================== */

.ce-sidebar-layout {
  min-height: 100vh;
}

.ce-sidebar {
  background: var(--bg-inset);
  border-right: 1px solid var(--border-default);
  width: 16rem;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  padding: var(--space-lg) 0;
  overflow-y: auto;
  transition: transform var(--transition-slow);
}

.ce-sidebar-header {
  padding: 0 var(--space-lg) var(--space-lg);
  border-bottom: 1px solid var(--border-default);
  margin-bottom: var(--space-md);
}

.ce-sidebar-logo {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--ce-terracotta);
  text-decoration: none;
  letter-spacing: 0.05em;
}

.ce-sidebar-logo:hover {
  color: var(--ce-terracotta-dark);
}

.ce-sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.ce-sidebar-section-label {
  padding: var(--space-md) var(--space-lg) var(--space-xs);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  opacity: 0.7;
}

.ce-sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 400;
  transition: all var(--transition-fast);
  cursor: pointer;
  text-decoration: none;
  border-radius: 0;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  margin: 1px 0;
}

.ce-sidebar-item:hover {
  color: var(--ce-terracotta);
  background: var(--bg-surface);
}

.ce-sidebar-item-active,
.ce-sidebar-item.active {
  color: var(--ce-terracotta);
  background: var(--bg-surface);
  font-weight: 500;
  border-left: 3px solid var(--ce-terracotta);
  padding-left: calc(var(--space-lg) - 3px);
}

.ce-sidebar-item svg,
.ce-sidebar-item .sidebar-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  opacity: 0.7;
}

.ce-sidebar-item:hover svg,
.ce-sidebar-item.active svg {
  opacity: 1;
}

.ce-sidebar-bottom {
  border-top: 1px solid var(--border-default);
  padding: var(--space-sm);
  margin-top: auto;
}

.ce-sidebar-bottom .ce-sidebar-item {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
}

.ce-sidebar-bottom .ce-sidebar-item:hover {
  background: var(--bg-surface);
  color: var(--ce-terracotta);
}

.ce-sidebar-bottom .ce-sidebar-item.active {
  border-left: none;
  padding-left: var(--space-md);
}

/* Handle Rails button_to form wrappers inside sidebar */
.ce-sidebar-bottom form.button_to {
  margin: 0;
  padding: 0;
}

.ce-sidebar-bottom form.button_to .ce-sidebar-item {
  width: 100%;
}

.ce-sidebar-user {
  padding: var(--space-sm) var(--space-md);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ce-sidebar-content {
  margin-left: 16rem;
  min-height: 100vh;
  background: var(--bg-page);
  transition: margin-left var(--transition-slow);
}

/* Mobile hamburger toggle */
.ce-sidebar-toggle {
  display: none;
  position: fixed;
  top: var(--space-md);
  left: var(--space-md);
  z-index: 50;
  width: 2.5rem;
  height: 2.5rem;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.ce-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.3);
}

.ce-sidebar-backdrop.open {
  display: block;
}

@media (max-width: 768px) {
  .ce-sidebar {
    transform: translateX(-100%);
  }

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

  .ce-sidebar-content {
    margin-left: 0;
  }

  .ce-sidebar-toggle {
    display: flex;
  }
}

/* ========================================
   COMPONENT: Flash Messages
   ======================================== */
.ce-flash { padding: var(--space-md); border-radius: var(--radius-md); margin-bottom: var(--space-lg); font-size: 0.875rem; }
.ce-flash-notice { background: rgba(34, 197, 94, 0.1); color: var(--ce-success); border: 1px solid rgba(34, 197, 94, 0.2); }
.ce-flash-alert { background: rgba(239, 68, 68, 0.1); color: var(--ce-error); border: 1px solid rgba(239, 68, 68, 0.2); }

/* ========================================
   COMPONENT: Stats
   ======================================== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-md); }
.stat-card { padding: var(--space-lg); background: var(--bg-inset); border-radius: var(--radius-md); text-align: center; border: 1px solid var(--border-default); }
.stat-value { font-family: var(--font-display); font-size: 2rem; font-weight: 400; color: var(--ce-terracotta); line-height: 1.2; }
.stat-label { font-size: 0.875rem; font-weight: 500; color: var(--text-primary); margin-top: var(--space-xs); }
.stat-detail { font-size: 0.75rem; color: var(--text-secondary); margin-top: var(--space-xs); }

/* ========================================
   FEEDBACK STATES
   ======================================== */

/* Empty State */
.ce-empty-state { text-align: center; padding: var(--space-2xl) var(--space-xl); }
.ce-empty-state h3 { font-family: var(--font-display); font-size: 1.5rem; font-weight: 400; color: var(--text-primary); margin: 0 0 var(--space-sm); }
.ce-empty-state-icon { font-size: 2.5rem; margin-bottom: var(--space-md); opacity: 0.3; }
.ce-empty-state p { font-size: 0.9375rem; color: var(--text-secondary); max-width: 28rem; margin: 0 auto; }

/* Loading */
.ce-loading { display: flex; align-items: center; justify-content: center; gap: var(--space-sm); padding: var(--space-xl); color: var(--text-secondary); font-size: 0.875rem; }
.ce-spinner { width: 1.25rem; height: 1.25rem; border: 2px solid var(--border-default); border-top-color: var(--ce-terracotta); border-radius: 50%; animation: spin 0.8s linear infinite; }

/* Error message */
.ce-error { padding: var(--space-md); border-radius: var(--radius-md); background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.2); color: var(--ce-error); font-size: 0.875rem; }
.ce-success-message { padding: var(--space-md); border-radius: var(--radius-md); background: rgba(34, 197, 94, 0.1); border: 1px solid rgba(34, 197, 94, 0.2); color: var(--ce-success); font-size: 0.875rem; }

/* ========================================
   LAYOUT UTILITIES
   ======================================== */
.ce-container { max-width: 80rem; margin: 0 auto; padding: 0 var(--space-xl); }
.ce-container-sm { max-width: 48rem; margin: 0 auto; padding: 0 var(--space-xl); }
.ce-container-lg { max-width: 96rem; margin: 0 auto; padding: 0 var(--space-xl); }
.ce-grid { display: grid; gap: var(--space-lg); }
.ce-grid-2 { grid-template-columns: repeat(2, 1fr); }
.ce-grid-3 { grid-template-columns: repeat(3, 1fr); }
.ce-grid-4 { grid-template-columns: repeat(4, 1fr); }
.ce-grid-auto { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.ce-stack { display: flex; flex-direction: column; gap: var(--space-md); }
.ce-row { display: flex; align-items: center; gap: var(--space-md); }
.ce-row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); }

/* ========================================
   COMPONENT: Logo
   ======================================== */
.ce-logo-mark { width: 2.5rem; height: 2.5rem; }
.ce-logo-lockup { display: flex; align-items: center; gap: var(--space-sm); text-decoration: none; }
.ce-logo-wordmark { font-family: var(--font-display); font-size: 1.5rem; font-weight: 400; color: var(--ce-terracotta); letter-spacing: 0.05em; }

/* ========================================
   COMPONENT: Theme Toggle
   ======================================== */
.theme-toggle { display: inline-flex; background: var(--bg-inset); border: 1px solid var(--border-default); border-radius: var(--radius-full); padding: 2px; }
.theme-toggle button { display: flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border: none; background: transparent; border-radius: var(--radius-full); cursor: pointer; color: var(--text-secondary); transition: all var(--transition-base); }
.theme-toggle button:hover { color: var(--text-primary); }
.theme-toggle button[aria-pressed="true"] { background: var(--bg-surface); color: var(--ce-terracotta); box-shadow: var(--shadow-sm); }

/* ========================================
   COMPONENT: Links
   ======================================== */
.ce-link { font-size: 0.875rem; color: var(--ce-terracotta); text-decoration: none; transition: color var(--transition-base); }
.ce-link:hover { color: var(--ce-terracotta-dark); text-decoration: underline; }
.ce-link-muted { font-size: 0.875rem; color: var(--text-secondary); text-decoration: none; transition: color var(--transition-base); }
.ce-link-muted:hover { color: var(--text-primary); }

/* ========================================
   COMPONENT: Comparison Slider
   ======================================== */
.comparison-slider {
  position: relative;
  z-index: 1; /* Above .ce-card::before loading placeholder */
  cursor: ew-resize;
  user-select: none;
  background: var(--ce-parchment);
}

.slider-handle {
  background: var(--ce-white);
  border: 2px solid var(--ce-terracotta);
  box-shadow: var(--shadow-xl);
}

.slider-line {
  background: var(--ce-terracotta);
  box-shadow: var(--shadow-lg);
  transition: opacity var(--transition-fast);
}

.slider-label {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--ce-parchment-deep);
  border-radius: var(--radius-sm);
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ce-charcoal);
  transition: opacity 0.3s ease;
}

.comparison-slider img {
  transition: opacity 0.4s ease;
}

.comparison-slider > div[style*="position: absolute"] {
  animation: fadeIn 0.3s ease;
}

.comparison-slider[data-render-gallery-target="container"] {
  transition: opacity 0.4s ease;
}

/* ========================================
   ANIMATIONS & KEYFRAMES
   ======================================== */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* ========================================
   IMAGE LOADING SYSTEM
   ======================================== */

.ce-image-loading {
  opacity: 0;
  background-color: var(--ce-parchment);
  transition: opacity var(--transition-slow) ease-out;
}

.ce-image-loaded {
  opacity: 1;
  background-color: transparent;
}

.ce-image-error {
  opacity: 0.5;
  filter: grayscale(50%);
}

[data-image-loader-background-value="true"].ce-image-loading {
  background-color: var(--ce-parchment);
}

[data-image-loader-background-value="true"].ce-image-loaded {
  background-color: transparent;
}

.ce-image-skeleton {
  background: linear-gradient(
    90deg,
    var(--ce-parchment) 25%,
    var(--ce-parchment-light) 50%,
    var(--ce-parchment) 75%
  );
  background-size: 200% 100%;
  animation: ce-skeleton-shimmer 1.5s ease-in-out infinite;
}

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

/* ========================================
   COMPONENT: Thumbnail Grid
   ======================================== */

.ce-thumb-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  width: 100%;
}

.ce-thumb-grid turbo-frame {
  display: contents;
}

.ce-thumb-grid turbo-frame.ce-grid-loader:not([complete]) {
  display: block;
}

@media (min-width: 600px) {
  .ce-thumb-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 900px) {
  .ce-thumb-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1200px) {
  .ce-thumb-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (min-width: 1600px) {
  .ce-thumb-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.ce-thumb-item {
  position: relative;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: var(--ce-parchment);
}

.ce-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--transition-slow), opacity var(--transition-base);
}

.ce-thumb-item:hover img {
  transform: scale(1.05);
}

.ce-thumb-item:focus-within {
  outline: 2px solid var(--ce-terracotta);
  outline-offset: -2px;
  z-index: 1;
}

.ce-thumb-item--processing::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ce-thumb-item--processing::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.5rem;
  height: 1.5rem;
  margin: -0.75rem 0 0 -0.75rem;
  border: 2px solid var(--ce-terracotta);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 2;
}

.ce-thumb-item--failed::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.ce-thumb-item--failed::before {
  content: "!";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 1.5rem;
  height: 1.5rem;
  background: var(--ce-error);
  color: white;
  font-weight: bold;
  font-size: 0.875rem;
  line-height: 1.5rem;
  text-align: center;
  border-radius: 50%;
  z-index: 2;
}

/* ========================================
   COMPONENT: View Toggle
   ======================================== */

.ce-view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: var(--ce-parchment);
  border: 1px solid var(--ce-parchment-deep);
  border-radius: var(--radius-md);
  padding: 2px;
}

.ce-view-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--ce-slate);
  cursor: pointer;
  transition: all var(--transition-base);
}

.ce-view-toggle-btn:hover:not(.ce-view-toggle-btn--active) {
  background: var(--ce-parchment-deep);
  color: var(--ce-charcoal);
}

.ce-view-toggle-btn--active {
  background: var(--ce-white);
  color: var(--ce-terracotta);
  box-shadow: var(--shadow-sm);
}

.ce-view-toggle-btn svg {
  width: 1rem;
  height: 1rem;
}

.ce-view-container[data-view="grid"] .ce-view-cards {
  display: none;
}

.ce-view-container[data-view="cards"] .ce-view-grid {
  display: none;
}

.ce-view-container[data-view="grid"] {
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}

.ce-view-container[data-view="cards"] {
  max-width: 80rem;
  margin: 0 auto;
}

:root:has(.ce-view-container[data-view="grid"]) .ce-cards-only-control {
  display: none;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */
@media (max-width: 768px) {
  :root {
    --space-xl: 1.5rem;
    --space-2xl: 2rem;
    --space-3xl: 3rem;
  }
}

/* ========================================
   ACCESSIBILITY: Reduced Motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  .ce-card,
  .ce-card[data-render-gallery-target="card"]::before {
    animation: none;
  }

  .comparison-slider img,
  .comparison-slider[data-render-gallery-target="container"],
  .slider-label {
    transition: none;
  }

  .ce-image-loading {
    transition: none;
    animation: none;
  }

  .ce-image-skeleton {
    animation: none;
    background: var(--ce-parchment);
  }

  .ce-spinner {
    animation: none;
  }

  html {
    scroll-behavior: auto;
  }
}

/* ========================================
   COMPONENT: PhotoSwipe Lightbox
   ======================================== */

.pswp {
  --pswp-bg: rgba(26, 26, 26, 0.95);
  --pswp-placeholder-bg: var(--ce-parchment);
  --pswp-icon-color: var(--ce-white);
  --pswp-icon-color-secondary: var(--ce-slate);
  --pswp-icon-stroke-color: var(--ce-white);
  --pswp-icon-stroke-width: 2px;
  --pswp-error-text-color: var(--ce-error);
}

.pswp__top-bar {
  background: linear-gradient(
    to bottom,
    rgba(26, 26, 26, 0.8) 0%,
    rgba(26, 26, 26, 0) 100%
  );
  padding: var(--space-md) var(--space-lg);
  height: auto;
}

.pswp__button {
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  cursor: pointer;
  border: none;
  background: none;
  transition: opacity var(--transition-base);
}

.pswp__button:hover {
  opacity: 1;
}

.pswp__button:focus {
  outline: 2px solid var(--ce-terracotta);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.pswp__button--close {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  backdrop-filter: blur(8px);
}

.pswp__button--close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.pswp__button--arrow {
  width: 56px;
  height: 56px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  backdrop-filter: blur(8px);
  margin-top: -28px;
}

.pswp__button--arrow:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.pswp__button--arrow--prev {
  left: var(--space-md);
}

.pswp__button--arrow--next {
  right: var(--space-md);
}

.pswp__counter {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--ce-white);
  opacity: 0.9;
  padding: var(--space-xs) var(--space-sm);
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
}

.pswp__preloader {
  width: 48px;
  height: 48px;
}

.pswp__preloader__icn {
  width: 48px;
  height: 48px;
  background: none;
}

.pswp__preloader__icn .pswp__preloader__cut {
  width: 24px;
  height: 48px;
}

.pswp__preloader__icn .pswp__preloader__donut {
  border: 3px solid var(--ce-terracotta);
  border-left-color: transparent;
  width: 44px;
  height: 44px;
}

.pswp__error-msg {
  font-family: var(--font-body);
  color: var(--ce-error);
}

.pswp__error-msg a {
  color: var(--ce-terracotta);
  text-decoration: underline;
}

.ce-lightbox-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-lg) var(--space-xl);
  background: linear-gradient(
    to top,
    rgba(26, 26, 26, 0.9) 0%,
    rgba(26, 26, 26, 0.6) 50%,
    rgba(26, 26, 26, 0) 100%
  );
  z-index: 10;
  pointer-events: none;
}

.ce-lightbox-caption-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  gap: var(--space-md);
}

.ce-lightbox-caption-info {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.ce-lightbox-date {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.8);
}

.ce-lightbox-detail-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--ce-white);
  font-size: 0.875rem;
  border-radius: var(--radius-md);
  backdrop-filter: blur(8px);
  transition: all var(--transition-base);
  text-decoration: none;
}

.ce-lightbox-detail-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

.ce-lightbox-detail-btn svg {
  width: 1rem;
  height: 1rem;
  stroke: currentColor;
}

.ce-lightbox-caption .ce-badge {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--ce-white);
  backdrop-filter: blur(8px);
}

.ce-lightbox-caption .ce-badge-cinematic {
  background: rgba(184, 92, 56, 0.4);
  border-color: rgba(184, 92, 56, 0.6);
}

.ce-lightbox-caption .ce-badge-museum {
  background: rgba(43, 58, 66, 0.4);
  border-color: rgba(43, 58, 66, 0.6);
}

.ce-lightbox-caption .ce-badge-architectural {
  background: rgba(44, 44, 44, 0.4);
  border-color: rgba(44, 44, 44, 0.6);
}

.ce-lightbox-caption .ce-badge-natural {
  background: rgba(74, 124, 89, 0.4);
  border-color: rgba(74, 124, 89, 0.6);
}

.ce-lightbox-caption .ce-badge-artistic {
  background: rgba(201, 162, 39, 0.4);
  border-color: rgba(201, 162, 39, 0.6);
}

.ce-lightbox-caption .ce-badge-dramatic {
  background: rgba(44, 44, 44, 0.5);
  border-color: rgba(44, 44, 44, 0.7);
}

.ce-lightbox-caption-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.ce-lightbox-fav-btn {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-md);
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all var(--transition-base);
}

.ce-lightbox-fav-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
  color: var(--ce-white);
}

.ce-lightbox-fav-btn--active {
  background: rgba(184, 92, 56, 0.4);
  border-color: rgba(184, 92, 56, 0.6);
  color: var(--ce-terracotta-light);
}

.ce-lightbox-fav-btn--active:hover {
  background: rgba(184, 92, 56, 0.55);
  border-color: rgba(184, 92, 56, 0.8);
  color: var(--ce-terracotta-light);
}

.ce-thumb-item[data-action*="lightbox#open"] {
  cursor: zoom-in;
}

@media (max-width: 600px) {
  .ce-lightbox-caption {
    padding: var(--space-md) var(--space-lg);
  }

  .ce-lightbox-caption-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .ce-lightbox-detail-btn {
    align-self: flex-end;
  }

  .pswp__button--arrow {
    width: 44px;
    height: 44px;
    margin-top: -22px;
  }

  .pswp__button--arrow--prev {
    left: var(--space-sm);
  }

  .pswp__button--arrow--next {
    right: var(--space-sm);
  }
}

@media (pointer: coarse) {
  .pswp__button--arrow {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pswp__preloader__icn .pswp__preloader__donut {
    animation: none;
  }

  .pswp {
    transition: none !important;
  }

  .pswp__bg {
    transition: none !important;
  }

  .pswp__img {
    transition: none !important;
  }
}
