/* ============================================
   CHROMATIC NEBULA — Color Picker
   A cosmic journey through color space
   ============================================ */

:root {
  --font-display: 'Cormorant Garamond', serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --hud-bg: rgba(4, 4, 12, 0.65);
  --hud-border: rgba(255, 255, 255, 0.07);
  --hud-text: rgba(220, 220, 240, 0.8);
  --hud-dim: rgba(160, 160, 200, 0.4);
  --hud-accent: rgba(180, 160, 255, 0.9);
  --hud-radius: 12px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #020208;
  cursor: none;
}

/* ---- Canvases ---- */
#nebula {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

#bloom {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.5;
}

/* ---- Vignette ---- */
.vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(
    ellipse 70% 70% at 50% 50%,
    transparent 30%,
    rgba(2, 2, 8, 0.6) 70%,
    rgba(2, 2, 8, 0.95) 100%
  );
}

/* ---- Custom Cursor ---- */
.cursor-glow {
  position: fixed;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  pointer-events: none;
  z-index: 100;
  transform: translate(-50%, -50%);
  transition: width 0.3s, height 0.3s, border-color 0.3s, box-shadow 0.3s;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.1), inset 0 0 10px rgba(255, 255, 255, 0.05);
}

.cursor-glow::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.cursor-glow.capturing {
  width: 48px;
  height: 48px;
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 40px rgba(255, 255, 255, 0.4), inset 0 0 20px rgba(255, 255, 255, 0.2);
}

/* ---- Title Overlay ---- */
.title-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(8, 6, 20, 0.9) 0%, rgba(2, 2, 8, 0.98) 100%);
  transition: opacity 1.2s cubic-bezier(0.4, 0, 0, 1);
  cursor: none;
}

.title-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.title-content {
  text-align: center;
  animation: titleFadeIn 2s ease-out;
}

@keyframes titleFadeIn {
  from { opacity: 0; transform: translateY(30px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.title-pre {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: rgba(180, 160, 255, 0.5);
  margin-bottom: 12px;
}

.title-main {
  font-family: var(--font-display);
  font-size: clamp(42px, 8vw, 96px);
  font-weight: 300;
  font-style: italic;
  letter-spacing: -0.02em;
  line-height: 1;
  color: rgba(240, 235, 255, 0.95);
  margin-bottom: 24px;
  background: linear-gradient(
    135deg,
    rgba(255, 200, 200, 0.9) 0%,
    rgba(200, 200, 255, 0.95) 35%,
    rgba(200, 255, 220, 0.9) 65%,
    rgba(255, 200, 240, 0.9) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.title-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 300;
  color: rgba(180, 180, 210, 0.45);
  letter-spacing: 0.05em;
  margin-bottom: 48px;
}

.title-enter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 14px 36px;
  cursor: none;
  transition: transform 0.3s;
}

.title-enter:hover {
  transform: scale(1.05);
}

.title-enter:hover .enter-ring {
  border-color: rgba(200, 180, 255, 0.5);
  box-shadow: 0 0 30px rgba(180, 160, 255, 0.2);
}

.enter-ring {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(200, 180, 255, 0.25);
  border-radius: 100px;
  transition: border-color 0.4s, box-shadow 0.4s;
  animation: ringPulse 3s ease-in-out infinite;
}

@keyframes ringPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.04); opacity: 0.7; }
}

.enter-text {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(220, 210, 255, 0.8);
  position: relative;
  z-index: 1;
}

/* ---- HUD Base ---- */
.hud {
  position: fixed;
  z-index: 50;
  background: var(--hud-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--hud-border);
  border-radius: var(--hud-radius);
  padding: 16px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.8s ease, transform 0.8s ease;
  user-select: none;
}

.hud.visible {
  opacity: 1;
  transform: translateY(0);
}

.hud-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--hud-dim);
  margin-bottom: 12px;
}

/* ---- HUD: Coordinates ---- */
.hud-coords {
  top: 24px;
  left: 24px;
  min-width: 130px;
  transition-delay: 0.1s;
}

.hud-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}

.hud-row:last-child {
  margin-bottom: 0;
}

.hud-key {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--hud-accent);
  width: 16px;
}

.hud-val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 400;
  color: var(--hud-text);
  text-align: right;
  min-width: 60px;
  transition: color 0.3s;
}

/* ---- HUD: Captured Color ---- */
.hud-capture {
  top: 24px;
  right: 24px;
  min-width: 180px;
  transition-delay: 0.2s;
}

.capture-swatch-wrap {
  position: relative;
  margin-bottom: 12px;
}

.capture-swatch {
  width: 100%;
  height: 48px;
  border-radius: 8px;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background-color 0.4s, box-shadow 0.4s;
}

.capture-ripple {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  opacity: 0;
  transform: scale(1);
  pointer-events: none;
}

.capture-ripple.active {
  animation: captureRipple 0.8s ease-out;
}

@keyframes captureRipple {
  0% { opacity: 0.8; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.15); }
}

.capture-values {
  margin-bottom: 10px;
}

.capture-hex {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
  color: var(--hud-text);
  margin-bottom: 4px;
  letter-spacing: 0.05em;
}

.capture-detail {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--hud-dim);
  margin-bottom: 2px;
}

.copy-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: var(--hud-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: none;
  transition: all 0.3s;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--hud-text);
  border-color: rgba(255, 255, 255, 0.15);
}

/* ---- HUD: Constellation ---- */
.hud-constellation {
  bottom: 24px;
  left: 24px;
  min-width: 180px;
  transition-delay: 0.3s;
}

.constellation-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}

.constellation-star {
  aspect-ratio: 1;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: none;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}

.constellation-star:hover {
  transform: scale(1.2);
  z-index: 2;
  box-shadow: 0 0 12px currentColor;
}

.constellation-star.removing {
  animation: starRemove 0.3s ease-out forwards;
}

@keyframes starRemove {
  to { transform: scale(0); opacity: 0; }
}

.constellation-empty {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--hud-dim);
  text-align: center;
  padding: 8px 0;
}

/* ---- HUD: Luminance Slider ---- */
.hud-luminance {
  bottom: 24px;
  right: 24px;
  width: 200px;
  transition-delay: 0.4s;
}

.luminance-track {
  position: relative;
  height: 8px;
  background: linear-gradient(to right, #000, #888, #fff);
  border-radius: 4px;
  margin-bottom: 8px;
  cursor: none;
}

.luminance-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 50%;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  pointer-events: none;
}

.luminance-thumb {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  border: 2px solid rgba(0, 0, 0, 0.3);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: box-shadow 0.3s;
}

.luminance-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--hud-dim);
  letter-spacing: 0.05em;
}

.luminance-value {
  color: var(--hud-text);
  font-weight: 500;
}

/* ---- Back Link ---- */
.back-link {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--hud-dim);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--hud-bg);
  backdrop-filter: blur(12px);
  cursor: none;
  opacity: 0;
  transition: opacity 0.6s, color 0.3s, border-color 0.3s;
}

.back-link.visible {
  opacity: 1;
}

.back-link:hover {
  color: var(--hud-text);
  border-color: rgba(255, 255, 255, 0.15);
}

/* ---- Notification ---- */
.notification {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-60px);
  z-index: 300;
  font-family: var(--font-mono);
  font-size: 12px;
  color: rgba(220, 255, 220, 0.9);
  background: rgba(20, 40, 20, 0.8);
  border: 1px solid rgba(100, 255, 100, 0.2);
  border-radius: 100px;
  padding: 10px 24px;
  backdrop-filter: blur(12px);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s;
  pointer-events: none;
}

.notification.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .hud-coords {
    top: 12px;
    left: 12px;
    padding: 10px;
  }

  .hud-capture {
    top: 12px;
    right: 12px;
    min-width: 150px;
    padding: 10px;
  }

  .hud-constellation {
    bottom: 60px;
    left: 12px;
    min-width: 140px;
    padding: 10px;
  }

  .hud-luminance {
    bottom: 60px;
    right: 12px;
    width: 140px;
    padding: 10px;
  }

  .title-main {
    font-size: 36px;
  }
}
