/* SongLens colours. Dark is the default; the light theme is switched on with data-theme="light". */
:root,
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #17130f;
  --card: #231d17;
  --primary: #6a4ecf;
  --primary-hover: #5740b5;
  --text: #fbf5ec;
  --muted: #c2b8aa;
  --border: #3a3128;
  --input: #2e261f;
  --accent-text: #c9bbff; /* links and small coloured text: purple is too dim on dark */
  --shadow: none;
  --error: #ff6a3d; /* error text and outlines */

  /* genre colours: only for genre tags and small dots */
  --genre-gospel: #ffb800;
  --genre-lofi: #00c2a8;
  --genre-pop: #4da8ff;
  --genre-afrobeats: #ff6b1a;
  --genre-hiphop: var(--primary);
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #efe3d3;
  --card: #fffcf7;
  --primary: #6a4ecf;
  --primary-hover: #5740b5;
  --text: #2a211a;
  --muted: #6b5e52;
  --border: #d9c8b2;
  --input: #fffcf7;
  --accent-text: #5b3fb0;
  --shadow: 0 4px 16px rgba(42, 33, 26, 0.1);
  --error: #b91c1c;

  --genre-gospel: #e6a800;
  --genre-lofi: #009b87;
  --genre-pop: #1b6ec2;
  --genre-afrobeats: #ff5a00;
  --genre-hiphop: var(--primary);
}

:root {
  --on-primary: #ffffff;
  --danger: #dc2626; /* fill of delete buttons */
  --on-danger: #ffffff;
  --piano-white: #fffbf3;
  --piano-black: #2a211a;

  /* The names the pages already use, now pointing at the new colours. */
  --midnight: var(--bg);
  --surface: var(--card);
  --ivory: var(--text);
  --soft-grey: var(--muted);
  --teal: var(--primary);
  --coral: var(--primary-hover);
  --indigo: var(--primary-hover);
  --white: var(--on-primary);
  --warning: var(--genre-gospel);
  --success: var(--genre-lofi);
}

/* Cards */
.card,
.song-card,
.player-card,
.upload-card {
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* Theme switch in the navbar: the knob slides and the track fills with purple in light mode */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.theme-toggle:focus-visible {
  outline: 3px solid var(--text);
  outline-offset: 2px;
}

.theme-track {
  position: relative;
  display: block;
  width: 56px;
  height: 30px;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--input);
}

.theme-fill {
  position: absolute;
  inset: 0;
  background: var(--primary);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.4s ease;
}

.theme-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  color: #2a211a;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-knob svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-knob .icon-sun {
  display: none;
}

.theme-toggle[aria-checked='true'] .theme-fill {
  transform: scaleX(1);
}

.theme-toggle[aria-checked='true'] .theme-knob {
  transform: translateX(26px);
}

.theme-toggle[aria-checked='true'] .icon-moon {
  display: none;
}

.theme-toggle[aria-checked='true'] .icon-sun {
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  .theme-fill,
  .theme-knob {
    transition: none;
  }
}

/* The whole page changes in one step: the new theme is drawn over the old one, so nothing changes late */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-old(root) {
  z-index: 1;
}

::view-transition-new(root) {
  z-index: 2;
}

/* Light mode: the navbar and footer sit on the page colour so everything blends */
:root[data-theme='light'] .site-header,
:root[data-theme='light'] .site-footer {
  background: var(--bg);
}
