/* Color Palette Generator — recreation of the JSFiddle app */

:root {
  --ui-accent: #E6E6E6;           /* driven by JS: darkest color of the palette */
  --bg: #1E1F1F;
  --surface: #2A2C2C;
  --surface-hover: #333636;
  --border: #3A3D3D;
  --text: #EFEFEF;
  --muted: #8A8F98;
  --ink-on-light: #1E1F1F;        /* swatch text color on light backgrounds */
  --ink-on-dark: #FFFFFF;         /* swatch text color on dark backgrounds  (.lod) */
}

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

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------------------------------- header ---------------------------------- */

header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

header svg {
  flex-shrink: 0;
}

header h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

header h1 a {
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}

header h1 a:hover {
  color: var(--text);
}

/* ---------------------------------- palette --------------------------------- */

#palette {
  flex: 1;
  display: flex;
  flex-direction: column;
  list-style: none;
}

#palette li {
  flex: 1;
  position: relative;
  display: grid;
  place-items: center;
  cursor: pointer;
  overflow: hidden;
  text-align: center;
  user-select: none;
  transition: transform 0.15s ease;
  color: var(--ink-on-light);
}

#palette li.lod {
  color: var(--ink-on-dark);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

#palette li:hover {
  transform: scale(1.015);
}

#palette li h2 {
  font-size: clamp(1.5rem, 4.5vw, 3.25rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

#palette li h3 {
  margin-top: 0.35rem;
  font-size: clamp(0.85rem, 1.6vw, 1.15rem);
  font-weight: 500;
  opacity: 0.85;
}

/* "Copied!" flash overlay */
#palette li::after {
  content: "Copied!";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(1.2rem, 3vw, 2rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

#palette li.copied::after {
  opacity: 1;
}

/* ---------------------------------- footer ---------------------------------- */

footer {
  flex-shrink: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.footerActions {
  padding: 0.9rem 1.5rem 1.25rem;
}

#actions,
#adjustments {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

#actions {
  flex-wrap: wrap;
  row-gap: 0.5rem;
}

#actions a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

#actions a:hover {
  background: var(--surface-hover);
}

#actions a svg {
  flex-shrink: 0;
}

#actions li.separator {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 1.1rem;
  padding-left: 1.1rem;
  border-left: 1px solid var(--border);
}

#actions li.separator span {
  color: var(--muted);
  font-size: 0.82rem;
  margin-right: 0.25rem;
}

#actions a[data-export-format],
#actions a[data-ai-format] {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

#actions a[data-export-format].copied,
#actions a[data-ai-format].copied {
  color: #6ee7a0;
}

/* --------------------------------- adjustments ------------------------------- */

#adjustments {
  margin-top: 0.9rem;
  gap: 2rem;
}

#adjustments li {
  flex: 1;
  min-width: 0;
}

#adjustments strong {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.55rem;
}

#adjustments strong em {
  font-style: normal;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* reset button: hidden until sliders move away from 0 */
#reset-palette {
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#reset-palette.show {
  visibility: visible;
  opacity: 1;
}

/* ----------------------------- accent-from-color ---------------------------- */

#accent-from-color {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}

#accent-from-color label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
}

.accentInputGroup {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
}

/* empty state = checkerboard so the chip reads as "transparent"
   the JS paints a solid color on top once a valid color is typed */
#color-chip {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: repeating-conic-gradient(var(--surface) 0% 25%, var(--surface-hover) 0% 50%) 50% / 8px 8px;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

#color-input {
  flex: 1;
  min-width: 0;
  max-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 0.45rem 0.7rem;
  letter-spacing: 0.01em;
}

#color-input::placeholder {
  color: var(--muted);
  font-weight: 500;
  opacity: 0.7;
}

#color-input:focus {
  outline: none;
  border-color: var(--ui-accent);
}

#color-input.invalid {
  border-color: #ff6b6b;
  animation: cpg-shake 0.35s ease;
}

#color-input-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

#color-input-btn:hover {
  background: var(--surface-hover);
}

#color-input-hint {
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

#color-input-hint.error {
  color: #ff6b6b;
}

@keyframes cpg-shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

/* ------------------------------ nouislider theme ----------------------------- */

.noUi-target {
  background: var(--surface);
  border: none;
  box-shadow: none;
  border-radius: 999px;
  height: 6px;
}

.noUi-connects {
  border-radius: 999px;
}

.noUi-connect {
  background: var(--ui-accent);
  transition: background 0.15s ease;
}

.noUi-handle {
  background: var(--ui-accent);
  border: none;
  border-radius: 50%;
  box-shadow: none;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.noUi-horizontal .noUi-handle {
  width: 20px;
  height: 20px;
  top: -7px;
  right: -10px;
}

.noUi-horizontal .noUi-handle::before,
.noUi-horizontal .noUi-handle::after {
  display: none;
}

.noUi-handle:hover {
  transform: scale(1.15);
}

.noUi-handle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* --------------------------------- responsive -------------------------------- */

@media (max-width: 760px) {
  header {
    padding: 0.75rem 1rem;
  }

  #actions li.separator {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    width: 100%;
  }

  #adjustments {
    flex-direction: column;
    gap: 0.9rem;
  }

  #accent-from-color {
    align-items: stretch;
  }

  #accent-from-color label {
    flex: 1 1 100%;
  }

  .accentInputGroup {
    flex-wrap: wrap;
  }

  #color-input {
    max-width: none;
  }

  #color-input-btn {
    flex-shrink: 0;
  }

  #palette li:hover {
    transform: none;
  }
}
