@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&family=Inter:wght@300;400;500;600&display=swap');

/* ─── Variables ──────────────────────────────────────────────────────── */
:root {
  --bg:          #f0f4f8;
  --surface:     #ffffff;
  --surface-2:   #f1f5f9;
  --text:        #0f172a;
  --text-2:      #475569;
  --muted:       #94a3b8;
  --border:      rgba(0,0,0,0.08);
  --border-2:    rgba(0,0,0,0.05);
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow:      0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg:   0 12px 28px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.06);
  --shadow-xl:   0 24px 48px rgba(0,0,0,0.14), 0 8px 16px rgba(0,0,0,0.08);
  --shadow-2xl:  0 32px 64px rgba(0,0,0,0.20);
  --r-sm:   8px;
  --r:      16px;
  --r-lg:   24px;
  --r-xl:   32px;
  --r-full: 9999px;
  --ease:   cubic-bezier(0.4, 0, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="dark"] {
  --bg:        #080e1a;
  --surface:   #111827;
  --surface-2: #1a2234;
  --text:      #f1f5f9;
  --text-2:    #cbd5e1;
  --muted:     #64748b;
  --border:    rgba(255,255,255,0.07);
  --border-2:  rgba(255,255,255,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow:    0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 28px rgba(0,0,0,0.5);
  --shadow-xl: 0 24px 48px rgba(0,0,0,0.6);
  --shadow-2xl:0 32px 64px rgba(0,0,0,0.7);
}

/* ─── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.85s var(--ease), color 0.3s var(--ease);
}

/* ─── Theme Toggle ───────────────────────────────────────────────────── */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.3s var(--ease);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.theme-toggle:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(139,92,246,0.4);
}

.theme-toggle:active { transform: scale(0.96); }

.toggle-icon { font-size: 15px; line-height: 1; }

/* ─── Hero ───────────────────────────────────────────────────────────── */
.hero {
  position: relative;
  padding: 110px 24px 90px;
  text-align: center;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    -45deg,
    rgba(102,126,234,0.87),
    rgba(118, 75,162,0.87),
    rgba(240,147,251,0.86),
    rgba(245, 87,108,0.87),
    rgba( 79,172,254,0.86),
    rgba(  0,242,254,0.84),
    rgba( 67,233,123,0.85),
    rgba( 56,249,215,0.84)
  );
  background-size: 400% 400%;
  animation: heroShift 16s ease infinite;
}

.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 40%, rgba(255,255,255,0.18) 0%, transparent 70%);
  pointer-events: none;
}

@keyframes heroShift {
  0%   { background-position:   0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position:   0% 50%; }
}

.hero-content {
  position: relative;
  z-index: 1;
}

.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,0.22);
  border: 1px solid rgba(255,255,255,0.35);
  color: rgba(255,255,255,0.95);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 6px 18px;
  border-radius: var(--r-full);
  margin-bottom: 22px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeUp 0.7s var(--ease) both;
}

.hero-title {
  font-family: 'Poppins', sans-serif;
  font-size: clamp(2.6rem, 7vw, 5rem);
  font-weight: 800;
  color: #fff;
  line-height: 1.05;
  letter-spacing: -0.025em;
  text-shadow: 0 2px 24px rgba(0,0,0,0.18);
  margin-bottom: 18px;
  animation: fadeUp 0.7s var(--ease) 0.1s both;
}

.hero-subtitle {
  font-size: clamp(0.95rem, 2.2vw, 1.2rem);
  color: rgba(255,255,255,0.82);
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.65;
  text-shadow: 0 1px 8px rgba(0,0,0,0.12);
  animation: fadeUp 0.7s var(--ease) 0.2s both;
}

/* ─── Container ──────────────────────────────────────────────────────── */
.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 28px 100px;
}

/* ─── Search ─────────────────────────────────────────────────────────── */
.search-wrapper {
  padding: 44px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.search-box {
  position: relative;
  width: 100%;
  max-width: 580px;
}

.search-icon {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 19px;
  height: 19px;
  color: var(--muted);
  pointer-events: none;
  transition: color 0.2s;
}

.search-input {
  width: 100%;
  padding: 17px 50px 17px 52px;
  font-family: 'Inter', sans-serif;
  font-size: 15.5px;
  font-weight: 400;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--r-full);
  box-shadow: var(--shadow);
  outline: none;
  transition: all 0.25s var(--ease);
}

.search-input::placeholder { color: var(--muted); }

.search-input:focus {
  border-color: #8B5CF6;
  box-shadow: var(--shadow-lg), 0 0 0 4px rgba(139,92,246,0.14);
}

.search-input:focus + .search-icon,
.search-box:focus-within .search-icon { color: #8B5CF6; }

.clear-btn {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--muted);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s var(--ease);
}

.clear-btn svg { width: 13px; height: 13px; }

.clear-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

.clear-btn:hover {
  background: var(--border);
  color: var(--text);
  transform: translateY(-50%) scale(1.1);
}

.result-count {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ─── Colors Section ─────────────────────────────────────────────────── */
.colors-section {
  padding-top: 28px;
  margin-bottom: 64px;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 22px;
}

/* ─── Color Card ─────────────────────────────────────────────────────── */
.color-card {
  position: relative;
  height: 230px;
  border-radius: var(--r-lg);
  cursor: pointer;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transition:
    transform  0.35s var(--spring),
    box-shadow 0.35s var(--ease);
  animation: cardIn 0.45s var(--ease) both;
}

.color-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0,0,0,0.78)  0%,
    rgba(0,0,0,0.28)  45%,
    rgba(0,0,0,0.06)  75%,
    transparent      100%
  );
  z-index: 1;
  transition: opacity 0.3s var(--ease);
}

.color-card:hover {
  transform: scale(1.045) translateY(-5px);
  box-shadow:
    0 32px 64px -12px rgba(0,0,0,0.32),
    0 16px 32px -16px rgba(0,0,0,0.26);
}

.color-card:hover::before { opacity: 0.95; }

.color-card:active { transform: scale(1.015) translateY(-2px); }

.card-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px 22px;
  z-index: 2;
  color: #fff;
}

.color-name {
  font-family: 'Poppins', sans-serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 5px;
  text-shadow: 0 1px 10px rgba(0,0,0,0.3);
  letter-spacing: -0.01em;
}

.color-hex {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  opacity: 0.92;
  font-variant-numeric: tabular-nums;
  margin-bottom: 7px;
}

.color-codes {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.color-codes span {
  font-size: 11.5px;
  opacity: 0.68;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.copy-hint {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 13px;
  border-radius: var(--r-full);
  color: #fff;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  pointer-events: none;
}

.color-card:hover .copy-hint {
  opacity: 1;
  transform: translateY(0);
}

/* ─── No Results ─────────────────────────────────────────────────────── */
.no-results {
  text-align: center;
  padding: 80px 20px;
}

.no-results-icon {
  font-size: 52px;
  display: block;
  margin-bottom: 18px;
  animation: pulse 2s ease infinite;
}

.no-results p {
  font-family: 'Poppins', sans-serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 8px;
}

.no-results small {
  font-size: 14px;
  color: var(--muted);
}

.hidden { display: none !important; }

/* ─── Recently Viewed ────────────────────────────────────────────────── */
.recent-section {
  padding: 44px 0 16px;
  border-top: 1px solid var(--border);
}

.recent-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 24px;
}

.section-title {
  font-family: 'Poppins', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.recent-hint {
  font-size: 13px;
  color: var(--muted);
}

.recent-swatches {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.swatch {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow);
  border: 3px solid var(--surface);
  outline: 2px solid var(--border);
  transition: transform 0.3s var(--spring), box-shadow 0.3s var(--ease);
  animation: swatchIn 0.35s var(--spring) both;
}

.swatch:hover {
  transform: scale(1.22) translateY(-3px);
  box-shadow: var(--shadow-xl);
}

.swatch:active { transform: scale(1.05); }

.swatch-tip {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 9px 14px;
  min-width: 130px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  box-shadow: var(--shadow-lg);
  z-index: 100;
}

.swatch:hover .swatch-tip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.tip-name {
  display: block;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.tip-hex {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.tip-time {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 4px;
  opacity: 0.8;
}

/* ─── Toast ──────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%) translateY(110px);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 13px 22px;
  box-shadow: var(--shadow-2xl);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.45s var(--spring),
    opacity   0.35s var(--ease);
  white-space: nowrap;
}

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

.toast-check {
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #10B981, #059669);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toast-check svg { width: 13px; height: 13px; }

.toast-msg {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text);
}

.toast-hex {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: var(--r-sm);
  letter-spacing: 0.04em;
}

/* ─── Animations ─────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes swatchIn {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.1); }
}

/* ─── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .color-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
  }
}

@media (max-width: 640px) {
  .hero { padding: 90px 20px 72px; }
  .container { padding: 0 16px 80px; }

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

  .color-card { height: 190px; }
  .color-name { font-size: 17px; }
  .color-hex  { font-size: 13px; }
  .color-codes { display: none; }

  .theme-toggle {
    top: 14px;
    right: 14px;
    padding: 8px 14px;
    font-size: 12.5px;
  }

  .swatch { width: 50px; height: 50px; }
  .swatch-tip { display: none; }
}

@media (max-width: 380px) {
  .color-grid { gap: 10px; }
  .color-card { height: 165px; }
}
