/* ── Reset & base ──────────────────────────────────────────────── */

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

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

body {
  font-family: 'Space Grotesk', sans-serif;
  background: #0a0a0c;
  color: #e0ddd5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* ── Atmospheric background ────────────────────────────────────── */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(180, 120, 60, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 85% 80%, rgba(60, 90, 140, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse 50% 50% at 50% 50%, rgba(20, 20, 25, 0.8) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

/* Subtle film grain texture via SVG noise */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  pointer-events: none;
  z-index: 0;
}

body > * {
  position: relative;
  z-index: 1;
}

/* ── Selection color ───────────────────────────────────────────── */

::selection {
  background: rgba(200, 164, 110, 0.3);
  color: #f5f2eb;
}

/* ── Header ────────────────────────────────────────────────────── */

.site-header {
  text-align: center;
  padding: 4rem 1.5rem 1.5rem;
}

.site-title {
  font-family: 'Instrument Serif', serif;
  font-size: 3.2rem;
  font-weight: 400;
  letter-spacing: -0.03em;
  color: #f5f2eb;
  line-height: 1.1;
  background: linear-gradient(135deg, #f5f2eb 0%, #c8a46e 50%, #f5f2eb 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: title-shimmer 8s ease-in-out infinite;
}

@keyframes title-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.site-subtitle {
  font-size: 1.05rem;
  color: #6a665e;
  margin-top: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* ── App container ─────────────────────────────────────────────── */

.app-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 1.5rem 4rem;
}

/* ── Upload section ────────────────────────────────────────────── */

.upload-section {
  width: 100%;
  max-width: 560px;
  margin: 2rem auto;
  animation: section-fade-in 0.6s ease;
}

@keyframes section-fade-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.drop-zone {
  position: relative;
  border: 2px solid transparent;
  border-radius: 20px;
  padding: 5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  background:
    linear-gradient(#13131a, #13131a) padding-box,
    linear-gradient(135deg, #2a2825 0%, #1e1d1b 50%, #2a2825 100%) border-box;
  overflow: hidden;
}

/* Inner glow ring on hover */
.drop-zone::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 20px;
  padding: 2px;
  background: linear-gradient(135deg, transparent, rgba(200, 164, 110, 0.3), transparent);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.drop-zone:hover::before,
.drop-zone.drag-over::before {
  opacity: 1;
}

/* Ambient glow underneath */
.drop-zone::after {
  content: '';
  position: absolute;
  bottom: -40px;
  left: 20%;
  right: 20%;
  height: 80px;
  background: radial-gradient(ellipse, rgba(200, 164, 110, 0.08) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.drop-zone:hover::after,
.drop-zone.drag-over::after {
  opacity: 1;
}

.drop-zone:hover {
  background:
    linear-gradient(#15151e, #15151e) padding-box,
    linear-gradient(135deg, #c8a46e44, #2a282500, #c8a46e44) border-box;
  transform: translateY(-2px);
}

.drop-zone.drag-over {
  background:
    linear-gradient(#181822, #181822) padding-box,
    linear-gradient(135deg, #c8a46e88, #c8a46e44, #c8a46e88) border-box;
  transform: scale(1.02);
}

.drop-zone-inner {
  position: relative;
  z-index: 1;
}

.drop-zone-icon {
  color: #4a4640;
  margin-bottom: 1.5rem;
  transition: all 0.4s ease;
}

.drop-zone:hover .drop-zone-icon {
  color: #c8a46e;
  transform: translateY(-4px);
}

.drop-zone.drag-over .drop-zone-icon {
  color: #d4b07a;
  transform: translateY(-8px) scale(1.1);
}

.drop-zone-text {
  font-size: 1.2rem;
  color: #b5b0a8;
  font-weight: 500;
  margin-bottom: 0.4rem;
  transition: color 0.3s ease;
}

.drop-zone:hover .drop-zone-text {
  color: #e0ddd5;
}

.drop-zone-hint {
  font-size: 0.82rem;
  color: #5a5650;
  letter-spacing: 0.03em;
  transition: color 0.3s ease;
}

.drop-zone:hover .drop-zone-hint {
  color: #7a756e;
}

/* ── Result section ────────────────────────────────────────────── */

.result-section {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  animation: result-reveal 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes result-reveal {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 3.5rem;
  align-items: start;
}

/* ── Preview frame ─────────────────────────────────────────────── */

.preview-column {
  position: sticky;
  top: 2rem;
}

.preview-frame {
  border-radius: 14px;
  overflow: hidden;
  background: #111114;
  border: 1px solid #222228;
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.3),
    0 1px 2px rgba(0, 0, 0, 0.2);
  position: relative;
}

/* Subtle inner highlight along top edge */
.preview-frame::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  z-index: 2;
}

.preview-frame img {
  display: block;
  width: 100%;
  height: auto;
}

/* ── Reset button ──────────────────────────────────────────────── */

.reset-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
  background: transparent;
  border: 1px solid #2a2828;
  color: #6a665e;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.65rem 1.25rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  letter-spacing: 0.02em;
  position: relative;
  overflow: hidden;
}

.reset-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(200, 164, 110, 0.05), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.reset-btn:hover {
  color: #c8a46e;
  border-color: rgba(200, 164, 110, 0.3);
  transform: translateY(-1px);
}

.reset-btn:hover::before {
  opacity: 1;
}

.reset-btn:active {
  transform: translateY(0);
}

/* ── Palette ───────────────────────────────────────────────────── */

.palette-heading {
  font-family: 'Instrument Serif', serif;
  font-size: 1.65rem;
  font-weight: 400;
  color: #f5f2eb;
  margin-bottom: 1.5rem;
  letter-spacing: -0.01em;
}

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

/* ── Swatch cards ──────────────────────────────────────────────── */

.swatch {
  cursor: pointer;
  border-radius: 12px;
  overflow: hidden;
  animation: swatch-appear 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.3s ease;
  position: relative;
}

.swatch:hover {
  transform: translateY(-6px) scale(1.03);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.4),
    0 4px 12px rgba(0, 0, 0, 0.2);
}

.swatch:active {
  transform: translateY(-2px) scale(1.01);
  transition-duration: 0.1s;
}

@keyframes swatch-appear {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.swatch-color {
  position: relative;
  aspect-ratio: 3 / 4.5;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 14px;
  border-radius: 12px;
  overflow: hidden;
}

/* Glass-like shine across top of swatch */
.swatch-color::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.08) 0%,
    rgba(255, 255, 255, 0.02) 40%,
    transparent 100%
  );
  pointer-events: none;
  border-radius: 12px 12px 0 0;
}

/* Subtle inner border to separate from dark bg */
.swatch-color::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  pointer-events: none;
}

.swatch-hex {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  transform: translateY(4px);
  position: relative;
  z-index: 2;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.swatch:hover .swatch-hex {
  opacity: 1;
  transform: translateY(0);
}

/* On touch devices, always show hex label */
.swatch.touch .swatch-hex {
  opacity: 0.85;
  transform: translateY(0);
}

.swatch-copied {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 2;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.swatch.copied .swatch-hex {
  opacity: 0 !important;
  transform: translateY(4px);
}

.swatch.copied .swatch-copied {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Pulse ring on copy */
.swatch.copied .swatch-color::before {
  animation: copy-pulse 0.6s ease-out;
}

@keyframes copy-pulse {
  0% { opacity: 0; height: 100%; }
  30% { opacity: 0.2; }
  100% { opacity: 0; height: 100%; }
}

/* ── Hidden state ──────────────────────────────────────────────── */

.hidden {
  display: none !important;
}

/* ── Footer ────────────────────────────────────────────────────── */

.site-footer {
  text-align: center;
  padding: 3rem 1.5rem 2.5rem;
  color: #8a857d;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  border-top: 1px solid #18181c;
}

/* ── Responsive ────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .site-header {
    padding: 3rem 1.5rem 1rem;
  }

  .site-title {
    font-size: 2.4rem;
  }

  .result-layout {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .preview-column {
    position: static;
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
  }

  .palette-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }

  .swatch-color {
    aspect-ratio: 3 / 4;
  }
}

@media (max-width: 480px) {
  .site-header {
    padding: 2rem 1rem 0.75rem;
  }

  .site-title {
    font-size: 1.9rem;
  }

  .site-subtitle {
    font-size: 0.92rem;
  }

  .app-container {
    padding: 0.75rem 1rem 3rem;
  }

  .drop-zone {
    padding: 3.5rem 1.5rem;
    border-radius: 16px;
  }

  .palette-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .palette-heading {
    font-size: 1.35rem;
  }

  .result-layout {
    gap: 2rem;
  }
}

/* ── Print ─────────────────────────────────────────────────────── */

@media print {
  body {
    background: #fff;
    color: #111;
  }

  body::before,
  body::after {
    display: none;
  }

  .upload-section,
  .reset-btn,
  .site-footer {
    display: none;
  }

  .swatch-hex {
    opacity: 1 !important;
    color: #111 !important;
  }
}
