/* ============================================================
   Paletto – style.css
   Sections:
   1.  Tokens
   2.  Reset & Base
   3.  Background Orbs
   4.  Header
   5.  Main Layout
   6.  Hero
   7.  Controls bar
   8.  Segmented control
   9.  Action buttons
   10. Palette display & swatches
   11. Add custom color button
   12. History section
   13. Divider
   14. Ad Slots
   15. Toast
   16. Animations & Keyframes
   17. Responsive
   ============================================================ */


/* ── 1. Tokens ── */
:root {
  --red:        #e34949;
  --red-dim:    #c93c3c;
  --red-glow:   rgba(227,73,73,0.25);
  --logo-glow: rgb(202, 121, 0);

  --bg:           #f5f5f7;
  --surface:      #ffffff;
  --surface-2:    #fafafa;
  --border:       rgba(0,0,0,0.08);
  --text:         #1d1d1f;
  --text-2:       #6e6e73;
  --text-3:       #aeaeb2;
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.06);
  --shadow-md:    0 8px 32px rgba(0,0,0,0.10);
  --shadow-lg:    0 24px 64px rgba(0,0,0,0.12);
  --glass:        rgba(255,255,255,0.72);
  --glass-border: rgba(255,255,255,0.5);
}

[data-theme="dark"] {
  --bg:           #000000;
  --surface:      #1c1c1e;
  --surface-2:    #2c2c2e;
  --border:       rgba(255,255,255,0.08);
  --text:         #f5f5f7;
  --text-2:       #aeaeb2;
  --text-3:       #636366;
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:    0 8px 32px rgba(0,0,0,0.5);
  --shadow-lg:    0 24px 64px rgba(0,0,0,0.6);
  --glass:        rgba(28,28,30,0.8);
  --glass-border: rgba(255,255,255,0.08);
}


/* ── 2. Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.35s ease, color 0.35s ease;
}


/* ── 3. Background Orbs ── */
.bg-orbs {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0; overflow: hidden;
}

.orb {
  position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: 0.18;
  animation: orb-drift 18s ease-in-out infinite alternate;
}

.orb-1 { width: 500px; height: 500px; background: var(--red); top: -120px; right: -100px; }
.orb-2 { width: 350px; height: 350px; background: #1d1d1f; bottom: 100px; left: -80px; animation-delay: -6s; }
[data-theme="dark"] .orb-2 { background: #555; }


/* ── 4. Header ── */
header {
  position: sticky; top: 0; z-index: 100;
  height: 60px; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: var(--glass);
  border-bottom: 1px solid var(--glass-border);
  transition: background 0.35s ease, border-color 0.35s ease;
}

.logo-wrap {
  display: flex; align-items: center; gap: 10px;
  animation: fade-down 0.5s ease both;
}

.logo-icon {
  /* width: 34px; height: 34px; */
  /* background: var(--red); */
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px var(--red-glow);
  overflow: hidden;
  transition: transform 0.2s ease;
  cursor: pointer; flex-shrink: 0;
}

.logo-icon:hover { transform: rotate(-6deg) scale(1.08); }

.logo-icon img { width: 34px; height: 34px; object-fit: contain; display: block; }

.logo-name { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; color: var(--text); }
.logo-name span { color: var(--red); }

.theme-toggle {
  position: relative;
  width: 44px; height: 26px;
  border-radius: 13px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: background 0.3s ease, border-color 0.3s ease;
  animation: fade-down 0.5s 0.1s ease both;
}

.theme-toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), background 0.3s ease;
}

[data-theme="dark"] .theme-toggle::after {
  transform: translateX(18px);
  background: var(--red);
}

.toggle-icons {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 5px;
  pointer-events: none;
  font-size: 9px; color: var(--text-3);
}


/* ── 5. Main Layout ── */
main {
  position: relative; z-index: 1;
  max-width: 1100px; margin: 0 auto;
  padding: 48px 24px 32px;
}


/* ── 6. Hero ── */
.hero {
  text-align: center; margin-bottom: 36px;
  animation: fade-up 0.6s ease both;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 700; letter-spacing: -0.04em; line-height: 1.1;
}

.hero h1 em { font-style: normal; color: var(--red); }

.hero p { margin-top: 12px; font-size: 0.95rem; color: var(--text-2); }


/* ── 7. Controls bar ── */
.controls-bar {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  animation: fade-up 0.6s 0.08s ease both;
  transition: background 0.35s ease, border-color 0.35s ease;
}

.control-group {
  display: flex; flex-direction: column; gap: 8px;
}

.control-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* Base color picker row */
.color-pick-wrap {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.color-pick-wrap:hover { border-color: var(--red); }

.color-preview {
  width: 24px; height: 24px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
  transition: background 0.2s ease;
}

/* Hide the native color input — clicking the preview triggers it */
input[type="color"] {
  position: absolute;
  opacity: 0; width: 0; height: 0;
  pointer-events: none;
}

.hex-display {
  font-family: 'DM Mono', monospace;
  font-size: 0.82rem;
  color: var(--text-2);
  letter-spacing: 0.02em;
}

.control-actions {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}


/* ── 8. Segmented Control ── */
.seg-control {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px; gap: 2px;
}

.seg-btn {
  flex: 1;
  text-align: center;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 0.78rem; font-weight: 500;
  color: var(--text-2);
  cursor: pointer; border: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease;
}

.seg-btn.active {
  background: var(--red); color: #fff;
  box-shadow: 0 2px 8px var(--red-glow);
}


/* ── 9. Action Buttons ── */
.btn-action {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, color 0.2s ease;
}

.btn-action:hover { border-color: var(--red); color: var(--red); transform: translateY(-1px); }
.btn-action:active { transform: translateY(0); }

.btn-action.primary {
  background: var(--red); color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px var(--red-glow);
}

.btn-action.primary:hover { background: var(--red-dim); color: #fff; }

.btn-action.primary i { transition: transform 0.4s ease; }
.btn-action.primary:hover i { transform: rotate(180deg); }

.btn-text {
  background: none; border: none;
  color: var(--text-3); font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem; font-weight: 500;
  cursor: pointer;
  transition: color 0.2s ease;
}

.btn-text:hover { color: var(--red); }


/* ── 10. Palette display & swatches ── */
.palette-wrap {
  display: flex; align-items: stretch; gap: 8px;
  animation: fade-up 0.6s 0.16s ease both;
}

.palette {
  display: flex; flex: 1; gap: 8px;
  min-height: 220px;
}

.swatch {
  flex: 1;
  border-radius: 16px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: flex 0.35s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.2s ease,
              border-radius 0.2s ease;
  animation: swatch-pop 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
  min-width: 0;
}

.swatch:hover {
  flex: 1.6;
  box-shadow: var(--shadow-md);
  border-radius: 20px;
}

/* Hex label at bottom of swatch */
.swatch-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 10px 12px;
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  font-weight: 500;
  background: linear-gradient(to top, rgba(0,0,0,0.35), transparent);
  color: #fff;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  display: flex; align-items: center; justify-content: space-between;
}

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

.swatch-copy-icon { font-size: 0.7rem; opacity: 0.8; }

/* "Copied!" flash */
.swatch.copied::after {
  content: 'Copied!';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem; font-weight: 600;
  color: #fff;
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(4px);
  animation: flash-in 0.3s ease forwards;
}

/* Remove swatch button (×) */
.swatch-remove {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.3);
  color: #fff; border: none;
  font-size: 0.7rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
}

.swatch:hover .swatch-remove { opacity: 1; }
.swatch-remove:hover { background: rgba(227,73,73,0.8); }


/* ── 11. Add custom color button ── */
.add-color-wrap {
  display: flex; align-items: center;
}

.add-color-btn {
  width: 48px; height: 48px;
  border-radius: 14px;
  border: 2px dashed var(--border);
  background: var(--surface);
  color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1.1rem;
  align-self: center;
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.15s ease, background 0.2s ease;
}

.add-color-btn:hover {
  border-color: var(--red); color: var(--red);
  transform: scale(1.08);
  background: var(--surface-2);
}


/* ── 12. History section ── */
.history-section {
  margin-top: 28px;
  animation: fade-up 0.6s 0.2s ease both;
}

.history-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}

.card-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.history-list {
  display: flex; flex-direction: column; gap: 10px;
}

.history-empty {
  font-size: 0.82rem; color: var(--text-3);
  padding: 8px 0;
}

.history-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  animation: fade-up 0.3s ease both;
}

.history-item:hover {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-glow);
  transform: translateY(-1px);
}

.history-swatches {
  display: flex; gap: 5px;
}

.history-dot {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
}

.history-meta {
  font-size: 0.78rem; color: var(--text-3);
}

.history-restore {
  margin-left: auto;
  font-size: 0.75rem; color: var(--red);
  font-weight: 500;
}


/* ── 13. Divider ── */
.divider { height: 1px; background: var(--border); margin: 18px 0; }


/* ── 14. Ad Slots ── */
.ads-row {
  margin-top: 28px; display: flex; gap: 16px;
  animation: fade-up 0.6s 0.24s ease both;
}

.ad-slot {
  flex: 1; height: 90px;
  border-radius: 14px;
  border: 1.5px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  font-size: 0.75rem; letter-spacing: 0.05em;
  text-transform: uppercase; font-weight: 500;
  background: var(--surface);
}


/* ── 15. Toast ── */
.toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text); color: var(--bg);
  padding: 12px 22px; border-radius: 30px;
  font-size: 0.85rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0; z-index: 999;
  white-space: nowrap; pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), opacity 0.35s ease;
}

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


/* ── 16. Animations ── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0);    }
}

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

@keyframes orb-drift {
  from { transform: translate(0,0) scale(1); }
  to   { transform: translate(30px,40px) scale(1.1); }
}

@keyframes swatch-pop {
  from { opacity: 0; transform: scaleY(0.85); }
  to   { opacity: 1; transform: scaleY(1);    }
}

@keyframes flash-in {
  from { opacity: 0; } to { opacity: 1; }
}


/* ── 17. Responsive ── */
@media (max-width: 820px) {
  .controls-bar { flex-direction: column; align-items: stretch; }
  .control-actions { flex-direction: row; margin-left: 0; }
  .palette { min-height: 160px; }
}

@media (max-width: 520px) {
  header { padding: 0 16px; }
  main { padding: 32px 16px 24px; }
  .palette { gap: 5px; min-height: 130px; }
  .swatch { border-radius: 12px; }
  .ads-row { flex-direction: column; }
  .ad-slot { height: 60px; }
  .hero h1 { font-size: 1.9rem; }
  .seg-btn { padding: 7px 6px; font-size: 0.72rem; }
}

@media (max-width: 380px) {
  .hero h1  { font-size: 1.55rem; }
  .hero p   { font-size: 0.82rem; }
  .controls-bar { padding: 14px 14px; gap: 14px; border-radius: 16px; }
  .control-actions { flex-wrap: wrap; }
  .btn-action { padding: 9px 12px; font-size: 0.78rem; }
  .palette { min-height: 110px; gap: 4px; }
  .swatch  { border-radius: 10px; }
  .swatch-label { font-size: 0.65rem; padding: 7px 8px; }
  .history-item { padding: 8px 10px; }
  .history-dot  { width: 18px; height: 18px; border-radius: 5px; }
  .logo-name    { font-size: 0.95rem; }
  /* .logo-icon    { width: 28px; height: 28px; } */
  .logo-icon img { width: 28px; height: 28px; }
  .seg-btn { padding: 6px 5px; font-size: 0.68rem; }
}

@media (max-width: 300px) {
  header { padding: 0 10px; height: 52px; }
  main   { padding: 20px 10px 16px; }
  .hero h1 { font-size: 1.3rem; letter-spacing: -0.02em; }
  .hero p  { font-size: 0.75rem; }
  .controls-bar { padding: 12px 10px; gap: 10px; border-radius: 14px; }
  .control-label { font-size: 0.6rem; }
  .color-pick-wrap { padding: 6px 8px; border-radius: 10px; }
  .hex-display { font-size: 0.7rem; }
  .color-preview { width: 18px; height: 18px; border-radius: 5px; }
  .seg-control { border-radius: 8px; padding: 2px; }
  .seg-btn { padding: 5px 3px; font-size: 0.62rem; border-radius: 5px; }
  .btn-action { padding: 8px 9px; font-size: 0.72rem; gap: 4px; border-radius: 10px; }
  .palette { min-height: 90px; gap: 3px; }
  .swatch  { border-radius: 8px; }
  .swatch-label { font-size: 0.6rem; padding: 5px 6px; }
  .swatch-remove { width: 18px; height: 18px; font-size: 0.6rem; top: 5px; right: 5px; }
  .add-color-btn { width: 36px; height: 36px; border-radius: 10px; font-size: 0.9rem; }
  .history-item  { padding: 7px 8px; border-radius: 11px; }
  .history-dot   { width: 16px; height: 16px; border-radius: 4px; }
  .history-meta  { font-size: 0.68rem; }
  .history-restore { font-size: 0.65rem; }
  .logo-name    { font-size: 0.85rem; }
  /* .logo-icon    { border-radius: 7px; } */
  .logo-icon img { width: 28px; height: 28px; border-radius:7px }
  .theme-toggle { width: 38px; height: 22px; }
  .theme-toggle::after { width: 15px; height: 15px; }
  [data-theme="dark"] .theme-toggle::after { transform: translateX(13px); }
  .card-label { font-size: 0.6rem; }
  .toast { font-size: 0.72rem; padding: 9px 14px; border-radius: 20px; white-space: normal; text-align: center; max-width: 90vw; }
  .ad-slot { display: none; }
  .ads-row { margin-top: 12px; }
}