/* umuzika-saas — vintage cassette design system (docs/DESIGN_PALETTE.md).
   All colours come from the theme tokens in themes.css; the design language
   (chunky borders, offset hard shadows, marker headings) stays constant across
   themes. Cassette-deck specifics live in cassette.css; fonts in fonts.css;
   theme tokens in themes.css — all are linked by stylesheet_link_tag :app. */

:root {
  --player-height: 72px;
  --titlebar-height: 80px; /* sticky-column math must clear it at scroll 0 */
  --font-marker: "Permanent Marker", "Comic Sans MS", cursive;
  --wash-accent: color-mix(in srgb, var(--accent) 10%, transparent);
  --wash-strong: color-mix(in srgb, var(--accent-strong) 12%, transparent);
  /* Soft app-chrome neutrals (ADR-016 deck vocabulary, shared since ADR-017). */
  --line: color-mix(in srgb, var(--text) 12%, transparent);
  --soft: color-mix(in srgb, var(--text) 5%, transparent);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 30%, color-mix(in srgb, var(--accent) 8%, transparent) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, color-mix(in srgb, var(--accent-2) 8%, transparent) 0%, transparent 40%),
    repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(0, 0, 0, 0.02) 2px, rgba(0, 0, 0, 0.02) 3px),
    var(--bg);
  color: var(--text);
  font-family: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-weight: 400; font-family: var(--font-marker); }
h1 {
  font-size: 1.9rem;
  letter-spacing: 0.05em;
  color: var(--accent-strong);
  text-shadow: 2px 2px 0 var(--shadow);
}
h2 {
  font-size: 1.15rem;
  margin-top: 2rem;
  text-decoration: underline;
  text-decoration-style: wavy;
  text-decoration-color: var(--accent-strong);
  text-underline-offset: 0.3em;
}
.dim { color: var(--text-dim); }

button, input[type="submit"] {
  font: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem calc(var(--player-height) + 2rem);
}
.page--cassette { max-width: 1400px; }

/* --- title bar (shared chrome, mirrors the cassette deck header) --------- */
.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1rem 1.5rem;
  border-bottom: 3px solid var(--accent);
  flex-wrap: wrap;
}
.titlebar__brand {
  font-family: var(--font-marker);
  font-size: 1.9rem;
  letter-spacing: 0.08em;
  color: var(--accent-strong);
  text-shadow: 3px 3px 0 var(--shadow);
}
.titlebar__brand:hover { text-decoration: none; }
.titlebar__center {
  flex: 1;
  display: flex;
  justify-content: center;
}
.titlebar__center form { width: 100%; max-width: 320px; }
.titlebar__search {
  width: 100%;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font: inherit;
  color: var(--text);
  outline: none;
  transition: all 0.15s ease;
}
.titlebar__search::placeholder { color: var(--text-dim); }
.titlebar__search:focus {
  background: var(--bg-raised);
  border-color: var(--accent-strong);
}
.titlebar__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* --- avatar + user menu --------------------------------------------------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--paper);
  font-weight: 700;
  font-size: 0.85rem;
  border: 2px solid var(--accent-strong);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--shadow);
  transition: all 0.15s ease;
}
.avatar--button { padding: 0; }
.avatar:hover { background: var(--accent-strong); transform: translate(-1px, -1px); }

.user-menu { position: relative; }
.user-menu > summary { list-style: none; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu__panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--bg-raised);
  border: 2px solid var(--accent);
  border-radius: 10px;
  padding: 0.5rem;
  box-shadow: 4px 4px 0 var(--shadow);
  z-index: 100;
}
.user-menu__name {
  padding: 0.5rem 0.75rem;
  font-weight: 700;
  color: var(--text);
  border-bottom: 2px solid var(--accent);
  margin-bottom: 0.25rem;
}
.user-menu__item {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  text-align: left;
  background: transparent;
  border: none;
  font: inherit;
  cursor: pointer;
}
.user-menu__item:hover { background: var(--wash-accent); text-decoration: none; }
.user-menu__item--button { color: var(--accent-strong); }
.user-menu__switch { padding: 0.25rem 0.75rem 0.5rem; }

/* --- flash ------------------------------------------------------------ */
.flash {
  margin: 0.75rem auto; max-width: 1100px;
  padding: 0.6rem 1rem; border-radius: 8px;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-left: 5px solid var(--ok);
  box-shadow: 3px 3px 0 var(--shadow);
}
.flash--alert { border-left-color: var(--danger); }

/* --- buttons ----------------------------------------------------------- */
.button {
  display: inline-block;
  background: var(--accent);
  color: var(--paper);
  border: 2px solid var(--accent-strong);
  border-radius: 999px;
  padding: 0.5rem 1.2rem;
  font-weight: 700;
  box-shadow: 3px 3px 0 var(--shadow);
  transition: all 0.15s ease;
}
.button:hover {
  background: var(--accent-strong);
  text-decoration: none;
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--shadow);
}
.button:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--shadow); }
.button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--accent);
  transform: none;
}
.button--ghost { background: var(--surface); border-color: var(--accent); color: var(--text); }
.button--ghost:hover { background: var(--wash-accent); color: var(--text); }
.button--ghost:disabled { background: var(--surface); }
.button--danger { background: var(--danger); border-color: var(--accent-strong); }
.button--danger:hover { background: color-mix(in srgb, var(--danger) 85%, black); }
.danger-title { color: var(--danger); }

/* --- library chrome (tabs + filter, mirrors the deck source panel) ------- */
.library-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.5rem 0 1.5rem;
  flex-wrap: wrap;
}
.library-tabs { display: flex; gap: 0.3rem; }
.library-tab {
  padding: 0.45rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.12s ease;
}
.library-tab:hover { color: var(--text); text-decoration: none; }
.library-tab.active { background: var(--accent); border-color: var(--accent-strong); color: var(--paper); }
.library-tab--deck { border-style: dashed; }
.library-tab--deck:hover { border-color: var(--accent); color: var(--accent-strong); }

.library-filter {
  flex: 0 1 260px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}
.library-filter::placeholder { color: var(--text-dim); }
.library-filter:focus { border-color: var(--accent); }

/* --- grids and cards ---------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}
.card {
  display: block; color: var(--text);
  padding: 0.75rem;
  border: 1px solid transparent;
  border-radius: 14px;
  transition: all 0.12s ease;
}
.card:hover {
  text-decoration: none;
  background: var(--soft);
  border-color: var(--accent);
}
.card__cover {
  /* height:auto beats the img's height attribute so aspect-ratio can apply */
  width: 100%; height: auto; aspect-ratio: 1; object-fit: cover;
  border-radius: 10px; background: var(--accent-3);
  border: 1px solid var(--line);
  display: block;
}
.card__cover--empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; color: var(--accent-strong);
  aspect-ratio: 1; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-3) 0%, color-mix(in srgb, var(--accent-2) 30%, var(--accent-3)) 100%);
  border: 1px solid var(--line);
}
.card__title {
  display: block; margin-top: 0.6rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card__subtitle {
  display: block; color: var(--text-dim); font-size: 0.85rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* --- lists --------------------------------------------------------------- */
.index-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.index-list__row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.6rem 0.75rem; border-radius: 10px; color: var(--text);
  border: 1px solid transparent;
  transition: all 0.12s ease;
}
.index-list__row:hover {
  background: var(--soft);
  border-color: var(--accent);
  text-decoration: none;
}

.tracklist { list-style: none; margin: 1rem 0 0; padding: 0; }
.tracklist__row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.45rem 0.75rem; border-radius: 8px;
  border: 2px solid transparent;
  transition: all 0.15s ease;
}
.tracklist__row:hover { background: var(--wash-accent); border-color: var(--accent); }
.tracklist__row--missing { color: var(--text-dim); }
.tracklist__no { width: 1.5rem; text-align: right; color: var(--accent-strong); font-weight: 700; font-variant-numeric: tabular-nums; }
.tracklist__play {
  background: var(--accent-3); border: 2px solid var(--accent-strong); color: var(--text);
  width: 2rem; height: 2rem; border-radius: 50%;
  box-shadow: 2px 2px 0 var(--shadow);
  transition: all 0.15s ease;
}
.tracklist__play:hover { background: var(--accent); color: var(--paper); transform: translate(-1px, -1px); }
.tracklist__title { flex: 1; }
.tracklist__sub { color: var(--text-dim); font-size: 0.85rem; }
.tracklist__time { color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.tracklist__reorder { display: flex; gap: 0.15rem; }

.badge { font-size: 0.7rem; font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 999px; border: 2px solid var(--accent); }
.badge--danger { color: var(--danger); border-color: var(--danger); }

/* --- album header -------------------------------------------------------- */
.album-header { display: flex; gap: 1.5rem; align-items: flex-end; flex-wrap: wrap; }
.album-header__cover {
  width: 200px; height: 200px; border-radius: 14px; object-fit: cover;
  background: var(--accent-3);
  border: 1px solid var(--line);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--shadow) 45%, transparent);
}
.album-header div[data-controller="play"] { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }

/* --- detail pages: content left · speaker right (ADR-017) ----------------- */
.page--detail { max-width: 1280px; }
.detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 2rem;
  align-items: start;
}
/* The speaker fills the visible column height and rides along on scroll.
   The titlebar is subtracted too: detail pages are often shorter than the
   viewport, so the column sits at scroll 0 forever — without it the VU
   panel hides behind the player bar (ADR-020 fix). */
.detail-side {
  position: sticky;
  top: 1rem;
  height: calc(100vh - var(--player-height) - var(--titlebar-height) - 2rem);
  min-height: 480px;
}
@media (max-width: 1023px) {
  .detail { grid-template-columns: minmax(0, 1fr); }
  .detail-side { display: none; }
}

/* --- empty states ---------------------------------------------------------- */
.empty { text-align: center; padding: 4rem 1rem; color: var(--text-dim); font-style: italic; }

/* --- search ------------------------------------------------------------ */
.search-input {
  width: 100%; max-width: 480px;
  background: var(--surface); border: 2px solid var(--accent);
  color: var(--text); border-radius: 10px; padding: 0.6rem 0.9rem; font: inherit;
}
.search-input::placeholder { color: var(--text-dim); }
.search-input:focus { outline: none; border-color: var(--accent-strong); background: var(--bg-raised); }
.search-input--small { max-width: 220px; padding: 0.35rem 0.7rem; }

/* --- auth pages ----------------------------------------------------------- */
.auth { max-width: 380px; margin: 15vh auto 0; text-align: center; }
.auth input[type="email"] {
  width: 100%; background: var(--surface); border: 2px solid var(--accent);
  color: var(--text); border-radius: 10px; padding: 0.7rem 0.9rem; font: inherit;
  margin-bottom: 0.75rem;
}
.auth input[type="submit"] {
  width: 100%; background: var(--accent); color: var(--paper);
  border: 2px solid var(--accent-strong);
  border-radius: 10px; padding: 0.7rem; font-weight: 700;
  box-shadow: 3px 3px 0 var(--shadow);
}
.auth input[type="submit"]:hover { background: var(--accent-strong); }
.auth__hint { color: var(--accent); text-align: left; margin-top: 0.75rem; }

/* --- tables (uploads) ---------------------------------------------------- */
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); }
th { color: var(--accent-strong); font-weight: 700; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* --- player --------------------------------------------------------------- */
.player__bar[hidden] { display: none; }
.player__bar {
  position: fixed; inset: auto 0 0 0; z-index: 50;
  height: var(--player-height);
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0 1rem;
  background: var(--bg-raised);
  border-top: 3px solid var(--accent);
}
.player__cover { border-radius: 6px; background: var(--accent-3); border: 2px solid var(--accent-strong); }
.player__meta { display: flex; flex-direction: column; min-width: 0; width: 180px; }
.player__title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player__artist { color: var(--text-dim); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player__controls { display: flex; align-items: center; gap: 0.25rem; }
.player__controls button {
  background: none; border: none; color: var(--text);
  width: 2.4rem; height: 2.4rem; border-radius: 50%; font-size: 1rem;
  transition: all 0.15s ease;
}
.player__controls button:hover { background: var(--wash-accent); }
.player__controls button.active { color: var(--accent-strong); }
.player__play {
  background: var(--accent-2) !important; color: var(--paper) !important;
  border: 2px solid var(--accent-strong) !important;
  box-shadow: 2px 2px 0 var(--shadow);
}
.player__play:hover { background: var(--accent) !important; }
.player__seek { flex: 1; display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.player__seek span { color: var(--text-dim); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.player__seek input[type="range"] { flex: 1; accent-color: var(--accent); min-width: 0; }
.player__volume { width: 90px; accent-color: var(--accent); }
.player__queue {
  position: fixed; right: 0; bottom: var(--player-height); z-index: 49;
  width: min(360px, 100vw); max-height: 50vh; overflow-y: auto;
  background: var(--bg-raised); border: 2px solid var(--accent);
  border-radius: 10px 0 0 0; padding: 0.75rem 1rem;
  box-shadow: -4px -4px 0 var(--shadow);
}
.player__queue header { display: flex; align-items: center; gap: 0.5rem; }
.player__queue h2 { flex: 1; margin: 0; font-size: 1rem; text-decoration: none; }
.player__queue header button {
  background: none; border: 2px solid var(--accent); color: var(--text-dim);
  border-radius: 6px; padding: 0.2rem 0.6rem;
}
.player__queue ol { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.player__queue li { display: flex; align-items: center; }
.player__queue li button:first-child {
  flex: 1; text-align: left; background: none; border: none; color: var(--text);
  padding: 0.4rem 0.5rem; border-radius: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player__queue li button:first-child:hover { background: var(--wash-accent); }
.player__queue li.current button:first-child { color: var(--accent-strong); font-weight: 700; }
.player__queue li button:last-child {
  background: none; border: none; color: var(--text-dim); border-radius: 6px;
  width: 1.8rem; height: 1.8rem;
}
.player__queue li button:last-child:hover { color: var(--danger); }

/* --- inline forms, icon buttons, selects ---------------------------------- */
.inline { display: inline; }
.inline-form { display: flex; gap: 0.5rem; margin: 1rem 0; flex-wrap: wrap; }
.icon-button {
  background: none; border: none; color: var(--text-dim);
  width: 1.9rem; height: 1.9rem; border-radius: 6px;
  transition: all 0.15s ease;
}
.icon-button:hover { background: var(--wash-accent); color: var(--text); }
.icon-button--danger:hover { color: var(--danger); }
.icon-button--active { color: var(--accent-strong); }
.playlist-select,
.theme-select {
  background: var(--surface); color: var(--text);
  border: 2px solid var(--accent); border-radius: 8px;
  padding: 0.2rem 0.4rem; font-size: 0.8rem; max-width: 8.5rem;
}
.playlist-header .playlist-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* --- upload dropzone ------------------------------------------------------ */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
.dropzone {
  border: 3px dashed var(--accent);
  border-radius: 12px;
  background: var(--surface);
  padding: 2.5rem 1rem;
  text-align: center;
  margin: 1rem 0;
  transition: all 0.15s ease;
}
.dropzone--active { border-color: var(--accent-strong); background: var(--wash-accent); }
.dropzone p { margin: 0.4rem 0; }
.upload-list { list-style: none; margin: 0.5rem 0 1rem; padding: 0; max-height: 40vh; overflow-y: auto; }
.upload-list li {
  display: grid; grid-template-columns: 1fr 120px auto; align-items: center; gap: 0.75rem;
  padding: 0.35rem 0.6rem; border-radius: 6px; font-size: 0.9rem;
}
.upload-list li:hover { background: var(--wash-accent); }
.upload-list__meta { display: flex; gap: 0.6rem; align-items: baseline; min-width: 0; }
.upload-list__meta span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-list__status { color: var(--text-dim); font-size: 0.8rem; white-space: nowrap; }
.upload-list__status--ok { color: var(--ok); }
.upload-list__status--failed { color: var(--danger); }
.upload-list li button {
  background: none; border: none; color: var(--text-dim);
  width: 1.7rem; height: 1.7rem; border-radius: 6px;
}
.upload-list li button:hover { color: var(--danger); background: var(--wash-accent); }

.progress {
  height: 8px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--accent); overflow: hidden;
}
.progress__bar {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  transition: width 0.2s ease;
}
.progress__bar--failed { background: var(--danger); }

/* --- mobile ------------------------------------------------------------ */
@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.75rem; }
  .album-header__cover { width: 140px; height: 140px; }
  .player__meta { width: auto; flex: 1; }
  .player__seek { display: none; }
  .player__volume { display: none; }
  .tracklist__sub { display: none; }
  .titlebar { padding: 0.75rem 1rem; gap: 0.75rem; }
  .titlebar__brand { font-size: 1.5rem; }
}
