/* =====================================================
   BLURR – Wallpaper Blur Studio
   Design System & Styles
   ===================================================== */

/* Ensure [hidden] always wins over any display rule */
[hidden] { display: none !important; }

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

:root {
  --bg:          #08080f;
  --bg2:         #0f0f1a;
  --surface:     rgba(255 255 255 / 0.04);
  --surface-hov: rgba(255 255 255 / 0.07);
  --border:      rgba(255 255 255 / 0.08);
  --border-hov:  rgba(255 255 255 / 0.16);
  --text:        #f0f0ff;
  --text-sub:    rgba(240 240 255 / 0.45);
  --text-muted:  rgba(240 240 255 / 0.28);
  --purple:      #a78bfa;
  --blue:        #38bdf8;
  --purple-dk:   #7c3aed;
  --blue-dk:     #0284c7;
  --grad:        linear-gradient(135deg, #a78bfa, #38bdf8);
  --grad-btn:    linear-gradient(135deg, #7c3aed 0%, #0ea5e9 100%);
  --radius-sm:   8px;
  --radius-md:   14px;
  --radius-lg:   22px;
  --radius-xl:   32px;
  --shadow:      0 8px 32px rgba(0 0 0 / 0.5);
  --shadow-lg:   0 20px 60px rgba(0 0 0 / 0.6);
  --trans:       0.2s ease;
  --trans-slow:  0.4s cubic-bezier(.4,0,.2,1);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* ── Ambient Background ───────────────────────────── */
.ambient {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  overflow: hidden;
}
.ambient__blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.18;
  animation: drift 18s ease-in-out infinite alternate;
}
.ambient__blob--1 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, #7c3aed, transparent 70%);
  top: -200px; left: -100px;
  animation-duration: 20s;
}
.ambient__blob--2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #0284c7, transparent 70%);
  bottom: -150px; right: -80px;
  animation-duration: 15s; animation-delay: -5s;
}
.ambient__blob--3 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, #059669, transparent 70%);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation-duration: 25s; animation-delay: -10s;
  opacity: 0.10;
}
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(40px, 30px) scale(1.08); }
}

/* ── Header ───────────────────────────────────────── */
.header {
  position: relative; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.header__logo {
  display: flex; align-items: center; gap: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header__tagline {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ── Main Layout ──────────────────────────────────── */
.app {
  position: relative; z-index: 5;
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ── Upload Zone ──────────────────────────────────── */
.upload-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 420px;
  animation: fadeIn 0.5s ease;
}
.upload-zone__inner {
  width: 100%;
  max-width: 560px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  backdrop-filter: blur(12px);
  padding: 64px 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--trans), background var(--trans), transform var(--trans-slow);
  position: relative;
  overflow: hidden;
}
.upload-zone__inner::before {
  content: '';
  position: absolute; inset: 0;
  background: var(--grad);
  opacity: 0;
  transition: opacity var(--trans);
}
.upload-zone__inner:hover,
.upload-zone__inner.drag-over {
  border-color: var(--purple);
  background: rgba(167 139 250 / 0.06);
  transform: scale(1.01);
}
.upload-zone__inner:hover::before,
.upload-zone__inner.drag-over::before { opacity: 0.03; }

.upload-zone__icon {
  display: flex; justify-content: center;
  margin-bottom: 20px;
  position: relative; z-index: 1;
}
.upload-zone__icon svg {
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

.upload-zone__title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
  position: relative; z-index: 1;
}
.upload-zone__sub {
  color: var(--text-sub);
  font-size: 0.95rem;
  margin-bottom: 12px;
  position: relative; z-index: 1;
}
.upload-zone__btn {
  background: none;
  border: none;
  color: var(--purple);
  font-family: inherit;
  font-size: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--trans);
}
.upload-zone__btn:hover { color: var(--blue); }
.upload-zone__hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  position: relative; z-index: 1;
}

/* ── Editor Layout ────────────────────────────────── */
.editor {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 32px;
  align-items: start;
  animation: fadeIn 0.5s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Preview ──────────────────────────────────────── */
.preview-wrap {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.preview-frame {
  position: relative;
  width: 100%;
  /* Fixed height so every image shows at the same size */
  height: 520px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #111;
  box-shadow: var(--shadow-lg);
  transition: border-radius var(--trans-slow);
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-frame--phone {
  max-width: 300px;
  height: 560px;
  border-radius: 40px;
  border: 8px solid rgba(255,255,255,0.1);
}

#previewCanvas {
  /* Fit inside the fixed frame — never overflow, always centered */
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  border-radius: var(--radius-md);
  object-fit: contain;
}

.preview-overlay {
  position: absolute; inset: 0;
  pointer-events: none;
  border-radius: inherit;
  transition: background var(--trans-slow);
}

.phone-mockup {
  position: absolute; inset: 0;
  pointer-events: none;
  display: none;
  border-radius: inherit;
}
.phone-mockup--visible { display: block; }
.phone-mockup__notch {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  width: 100px; height: 28px;
  background: rgba(0,0,0,0.85);
  border-radius: 20px;
  z-index: 10;
}
.phone-mockup__home {
  position: absolute;
  bottom: 10px; left: 50%;
  transform: translateX(-50%);
  width: 100px; height: 5px;
  background: rgba(255,255,255,0.4);
  border-radius: 10px;
  z-index: 10;
}

.preview-labels {
  display: flex;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
}
.preview-label-btn {
  padding: 6px 20px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--trans), color var(--trans);
}
.preview-label-btn.active {
  background: var(--surface-hov);
  color: var(--text);
}

/* ── Controls Panel ───────────────────────────────── */
.controls {
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: rgba(255 255 255 / 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  backdrop-filter: blur(16px);
}

.controls__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.controls__imginfo {
  display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0;
}
.controls__thumb {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
}
.controls__thumb img {
  width: 100%; height: 100%; object-fit: cover;
}
.controls__filename {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 180px;
}
.controls__filesize {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.btn-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-sub);
  cursor: pointer;
  transition: background var(--trans), color var(--trans), border-color var(--trans);
  flex-shrink: 0;
}
.btn-icon:hover {
  background: rgba(244 63 94 / 0.15);
  border-color: rgba(244 63 94 / 0.3);
  color: #fb7185;
}

/* ── Control Groups ───────────────────────────────── */
.control-group { display: flex; flex-direction: column; gap: 10px; }

.control-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.control-value {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--purple);
  letter-spacing: 0;
  text-transform: none;
}

/* ── Blur Style Cards ─────────────────────────────── */
.style-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.style-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-sub);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--trans);
}
.style-card:hover {
  border-color: var(--border-hov);
  color: var(--text);
  background: var(--surface-hov);
}
.style-card.active {
  border-color: var(--purple);
  background: rgba(167 139 250 / 0.12);
  color: var(--purple);
}

.style-card__preview {
  width: 40px; height: 28px;
  border-radius: 6px;
  display: block;
  overflow: hidden;
}
.style-card__preview--gaussian {
  background: linear-gradient(135deg, #a78bfa, #38bdf8);
  filter: blur(5px) brightness(1.1);
}
.style-card__preview--frosted {
  background: linear-gradient(135deg, #a78bfa, #38bdf8);
  filter: blur(3px) saturate(0.6) brightness(1.3);
}
.style-card__preview--radial {
  background: radial-gradient(circle at center, transparent 20%, rgba(0,0,0,0.7) 70%, transparent 100%),
              linear-gradient(135deg, #a78bfa, #38bdf8);
}
.style-card__preview--tilt {
  background: linear-gradient(to bottom,
    rgba(0,0,0,0) 0%,
    rgba(10,10,30,0.5) 40%,
    rgba(10,10,30,0.5) 60%,
    rgba(0,0,0,0) 100%),
    linear-gradient(135deg, #a78bfa, #38bdf8);
  filter: blur(2px);
}

/* ── Sliders ──────────────────────────────────────── */
.slider-wrap {
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
}
.slider-wrap input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255 255 255 / 0.08);
  outline: none;
  cursor: pointer;
  position: relative;
  z-index: 2;
}
.slider-track-fill {
  position: absolute;
  left: 0; top: 50%; transform: translateY(-50%);
  height: 6px;
  border-radius: 999px;
  background: var(--grad);
  pointer-events: none;
  z-index: 1;
  transition: width 0.05s;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(167 139 250 / 0.35), 0 2px 8px rgba(0 0 0 / 0.4);
  cursor: grab;
  transition: transform var(--trans), box-shadow var(--trans);
}
input[type="range"]::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.15);
  box-shadow: 0 0 0 6px rgba(167 139 250 / 0.4), 0 4px 16px rgba(0 0 0 / 0.5);
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 0 0 4px rgba(167 139 250 / 0.35), 0 2px 8px rgba(0 0 0 / 0.4);
  cursor: grab;
}

/* ── Color Presets ────────────────────────────────── */
.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.color-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}
.color-preset {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--trans), border-color var(--trans), box-shadow var(--trans);
}
.color-preset:hover { transform: scale(1.15); }
.color-preset.active {
  border-color: white;
  box-shadow: 0 0 0 2px rgba(255 255 255 / 0.3);
  transform: scale(1.1);
}

#customColor {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  background: none;
  padding: 2px;
  transition: border-color var(--trans);
}
#customColor:hover { border-color: var(--purple); }

/* ── Resolution Buttons ───────────────────────────── */
.resolution-row {
  display: flex; gap: 8px;
}
.res-btn {
  flex: 1;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-sub);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--trans);
  white-space: nowrap;
}
.res-btn:hover {
  border-color: var(--border-hov);
  color: var(--text);
  background: var(--surface-hov);
}
.res-btn.active {
  border-color: var(--purple);
  background: rgba(167 139 250 / 0.12);
  color: var(--purple);
}

/* ── Download Button ──────────────────────────────── */
.btn-download {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 28px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--grad-btn);
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: -0.01em;
  box-shadow: 0 4px 24px rgba(124 58 237 / 0.4);
  transition: transform var(--trans), box-shadow var(--trans), filter var(--trans);
  position: relative;
  overflow: hidden;
}
.btn-download::before {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255 255 255 / 0);
  transition: background var(--trans);
}
.btn-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 36px rgba(124 58 237 / 0.55);
  filter: brightness(1.08);
}
.btn-download:hover::before { background: rgba(255 255 255 / 0.06); }
.btn-download:active { transform: translateY(0); }

/* ── Toast Notification ───────────────────────────── */
.toast {
  position: fixed;
  bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20 20 35 / 0.95);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 24px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 100;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 900px) {
  .editor {
    grid-template-columns: 1fr;
  }
  .preview-wrap { position: static; }
  .preview-frame--phone { max-width: 220px; }
}
@media (max-width: 600px) {
  .header { padding: 16px 20px; }
  .app { padding: 24px 16px 60px; }
  .controls { padding: 20px; }
  .style-grid { grid-template-columns: repeat(2, 1fr); }
  .resolution-row { flex-direction: column; }
  .header__tagline { display: none; }
}
