/* ===== CSS Variables ===== */
/* Demo page uses same balanced gray + orange color scheme as main site */

:root {
  /* Balanced gray tones */
  --background: hsl(220, 8%, 28%);
  --foreground: hsl(220, 10%, 95%);
  --card: hsl(220, 10%, 32%);
  --primary: hsl(25, 85%, 55%);
  --primary-foreground: hsl(220, 10%, 12%);
  --secondary: hsl(220, 8%, 35%);
  --muted-foreground: hsl(220, 8%, 70%);
  --border: hsl(220, 8%, 40%);
  --shadow-card: 0 8px 30px hsla(220, 10%, 5%, 0.4);
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --radius: 12px;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--background);
  color: var(--foreground);
  overflow-x: hidden;
  min-height: 100vh;
}

/* ===== Layout ===== */
.demo-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== Header Controls ===== */
.demo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  z-index: 100;
}

.demo-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
}

.demo-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* View Toggle */
.view-toggle {
  display: flex;
  gap: 8px;
  background: var(--secondary);
  border-radius: 8px;
  padding: 4px;
}

.view-btn {
  padding: 10px 20px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9375rem;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: all 0.3s ease;
}

.view-btn.active {
  background: var(--primary);
  color: var(--primary-foreground);
}

.view-btn:hover:not(.active) {
  background: var(--border);
}

/* Back Button */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: var(--font-body);
  font-weight: 600;
  background: var(--secondary);
  border: none;
  border-radius: 8px;
  color: var(--foreground);
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}

.back-btn:hover {
  background: var(--primary);
  color: var(--primary-foreground);
}

.back-btn svg {
  width: 20px;
  height: 20px;
}

/* ===== Slider Content ===== */
.slider-content {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px;
  overflow: visible;
}

.slider-wrapper {
  width: 100%;
  max-width: 1400px;
  position: relative;
}

/* Labels */
.slider-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 0 16px;
}

.slider-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  background: transparent;
}

.slider-label:hover {
  color: var(--foreground);
  background: var(--secondary);
}

.slider-label.active {
  color: var(--primary);
  border-color: var(--primary);
  background: hsla(270, 70%, 60%, 0.1);
}

/* Before/After Slider */
.before-after-slider {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--background);
  box-shadow: var(--shadow-card);
  width: 100%;
}

.slider-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.slider-image img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

.slider-image.before {
  position: relative;
}

.slider-image.after {
  clip-path: inset(0 0 0 50%);
}

.slider-handle {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 4px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
}

.slider-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  background: white;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.slider-handle-wrapper {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  pointer-events: none;
  z-index: 10;
}

.slider-button {
  position: relative;
  width: 64px;
  height: 64px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 11;
}

.slider-button svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

.slider-range {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: ew-resize;
  z-index: 20;
}

/* Mobile view adjustments */
.slider-wrapper.mobile-view .before-after-slider {
  max-width: 420px;
  margin: 0 auto;
}

/* Loading state */
.before-after-slider.loading {
  min-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.demo-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--muted-foreground);
  font-size: 0.9rem;
  padding: 48px 0;
}

.demo-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.before-after-slider:not(.loading) #sliderLoading { display: none !important; }
#singleLoading { display: none; }

/* Keyboard hint */
.keyboard-hint {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: hsla(0, 0%, 0%, 0.85);
  color: white;
  border-radius: 8px;
  font-size: 0.875rem;
  opacity: 0;
  pointer-events: none;
  z-index: 200;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.keyboard-hint.visible {
  opacity: 0.9;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .demo-header {
    flex-direction: column;
    gap: 16px;
    padding: 16px;
  }

  .demo-title {
    font-size: 1.25rem;
  }

  .demo-controls {
    width: 100%;
    justify-content: space-between;
  }

  .view-toggle {
    flex: 1;
  }

  .view-btn {
    flex: 1;
    padding: 8px 12px;
    font-size: 0.875rem;
  }

  .slider-content {
    padding: 16px;
  }

  .slider-labels {
    padding: 0 8px;
  }

  .slider-label {
    font-size: 1rem;
    padding: 6px 12px;
  }

  .keyboard-hint {
    display: none;
  }
}

/* Single Image Content (for new builds) */
.single-image-content {
  width: 100%;
  min-height: calc(100vh - 120px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 32px;
}

.single-image-wrapper {
  max-width: 1200px;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  margin: 0 auto;
}

.single-image-wrapper img {
  width: 100%;
  height: auto;
  display: block;
}

.single-image-wrapper.mobile-view {
  max-width: 400px;
}
