/* ---------- favourites page ---------- */

body.fav-page {
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}

.fav {
  width: min(880px, 100%);
  gap: 26px;
}

.fav-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.fav-heading {
  min-width: 0;
}

.fav-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.fav-title {
  font-size: clamp(28px, 5vw, 34px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.015em;
  color: var(--fg);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.fav-count {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid rgba(194, 184, 184, 0.16);
  background: rgba(255, 255, 255, 0.035);
  color: rgba(194, 184, 184, 0.55);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.fav-count[hidden] {
  display: none;
}

.fav-sub {
  margin-top: 6px;
  font-size: 12px;
  color: rgba(194, 184, 184, 0.42);
}

.fav-gear {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(194, 184, 184, 0.12);
  background: rgba(10, 10, 10, 0.45);
  color: rgba(194, 184, 184, 0.42);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease,
    transform 0.3s ease;
}

.fav-gear svg {
  width: 17px;
  height: 17px;
  display: block;
}

.fav-gear:hover {
  color: var(--fg);
  border-color: rgba(194, 184, 184, 0.3);
  background: rgba(22, 22, 22, 0.62);
  transform: rotate(-8deg);
}

.fav-gear:focus-visible {
  outline: 2px solid rgba(194, 184, 184, 0.5);
  outline-offset: 3px;
}

.fav-gear.is-on {
  color: var(--fg);
  border-color: rgba(194, 184, 184, 0.38);
  background: rgba(255, 255, 255, 0.07);
}

/* ---------- grid ---------- */

.fav-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 24px 16px;
  margin: 0;
  padding: 0;
}

.fav-item {
  position: relative;
  min-width: 0;
  animation: favIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--i, 0) * 35ms);
}

.fav-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  color: inherit;
  text-decoration: none;
}

.fav-art {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 13px;
  border: 1px solid rgba(194, 184, 184, 0.1);
  background: linear-gradient(145deg, #1b1b1b, #0b0b0b);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34);
  transition: border-color 0.25s ease, transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.4s ease;
}

.fav-art::before {
  content: "♪";
  position: absolute;
  font-size: 30px;
  color: rgba(194, 184, 184, 0.16);
}

.fav-art img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.fav-art img.is-loaded {
  opacity: 1;
}

.fav-card:hover .fav-art {
  border-color: rgba(194, 184, 184, 0.3);
  transform: translateY(-3px);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.48);
}

.fav-card:hover .fav-art img {
  transform: scale(1.04);
}

.fav-card:focus-visible {
  outline: none;
}

.fav-card:focus-visible .fav-art {
  border-color: rgba(194, 184, 184, 0.55);
  box-shadow: 0 0 0 1px rgba(194, 184, 184, 0.35);
}

.fav-kind {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 2;
  padding: 3px 6px;
  border-radius: 5px;
  background: rgba(6, 6, 6, 0.72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  color: rgba(194, 184, 184, 0.66);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  line-height: 1;
}

.fav-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fav-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--fg);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fav-artist {
  font-size: 11.5px;
  line-height: 1.3;
  color: rgba(194, 184, 184, 0.48);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- edit controls ---------- */

.fav-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  display: none;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(194, 184, 184, 0.18);
  background: rgba(6, 6, 6, 0.78);
  color: rgba(194, 184, 184, 0.72);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.fav-grid.is-editing .fav-remove {
  display: grid;
}

.fav-remove:hover {
  color: #e4796f;
  border-color: rgba(228, 121, 111, 0.5);
}

.fav-remove.is-armed {
  background: #e4796f;
  border-color: #e4796f;
  color: #0a0a0a;
}

.fav-add-wrap {
  display: none;
}

.fav-grid.is-editing .fav-add-wrap {
  display: block;
}

.fav-add {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px;
  border-radius: 13px;
  border: 1px dashed rgba(194, 184, 184, 0.24);
  background: rgba(255, 255, 255, 0.015);
  color: rgba(194, 184, 184, 0.5);
  font: inherit;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.fav-add:hover {
  color: var(--fg);
  border-color: rgba(194, 184, 184, 0.45);
  background: rgba(255, 255, 255, 0.035);
}

.fav-add:focus-visible {
  outline: 2px solid rgba(194, 184, 184, 0.5);
  outline-offset: 3px;
}

.fav-add .plus {
  font-size: 26px;
  font-weight: 300;
  line-height: 1;
}

.fav-add .label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---------- empty ---------- */

.fav-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 64px 20px;
  border-radius: 18px;
  border: 1px dashed rgba(194, 184, 184, 0.1);
  color: rgba(194, 184, 184, 0.34);
  font-size: 12px;
  text-align: center;
}

.fav-empty svg {
  width: 22px;
  height: 22px;
  opacity: 0.6;
}

.fav-empty[hidden] {
  display: none;
}

/* ---------- add modal ---------- */

.fav-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.74);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
}

.fav-modal[hidden] {
  display: none;
}

.fav-panel {
  width: min(520px, 100%);
  max-height: min(660px, calc(100dvh - 40px));
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(194, 184, 184, 0.14);
  background: rgba(10, 10, 10, 0.96);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.62);
}

.fav-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.fav-panel-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(194, 184, 184, 0.55);
}

.fav-close {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(194, 184, 184, 0.55);
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.fav-close:hover {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.06);
}

.fav-kinds {
  display: flex;
  gap: 2px;
  width: max-content;
  padding: 3px;
  border-radius: 9px;
  border: 1px solid rgba(194, 184, 184, 0.1);
  background: rgba(255, 255, 255, 0.02);
}

.fav-kinds button {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(194, 184, 184, 0.5);
  font: inherit;
  font-size: 11px;
  font-weight: 550;
  padding: 6px 11px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.fav-kinds button:hover {
  color: rgba(194, 184, 184, 0.85);
}

.fav-kinds button.is-active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg);
}

.fav-kinds button:focus-visible {
  outline: 1px solid rgba(194, 184, 184, 0.5);
  outline-offset: 1px;
}

.fav-search {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(194, 184, 184, 0.16);
  background: rgba(255, 255, 255, 0.04);
}

.fav-search:focus-within {
  border-color: rgba(194, 184, 184, 0.42);
}

.fav-search svg {
  width: 15px;
  height: 15px;
  flex: none;
  color: rgba(194, 184, 184, 0.42);
}

.fav-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  outline: none;
  appearance: none;
}

.fav-search input::placeholder {
  color: rgba(194, 184, 184, 0.34);
}

.fav-search input::-webkit-search-cancel-button {
  display: none;
}

.fav-results {
  flex: 1;
  min-height: 140px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0 -4px;
  padding: 0 4px;
  scrollbar-width: thin;
}

.fav-result {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease;
}

.fav-result:hover {
  background: rgba(255, 255, 255, 0.05);
}

.fav-result:focus-visible {
  outline: 1px solid rgba(194, 184, 184, 0.5);
  outline-offset: -1px;
}

.fav-result:disabled {
  cursor: default;
  opacity: 0.5;
}

.fav-result-art {
  position: relative;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(145deg, #191919, #0c0c0c);
}

.fav-result-art::before {
  content: "♪";
  position: absolute;
  font-size: 15px;
  color: rgba(194, 184, 184, 0.22);
}

.fav-result-art img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.fav-result-art img.is-loaded {
  opacity: 1;
}

.fav-result-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fav-result-title {
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-result-meta {
  font-size: 11.5px;
  line-height: 1.25;
  color: rgba(194, 184, 184, 0.48);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-result-add {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(194, 184, 184, 0.16);
  color: rgba(194, 184, 184, 0.7);
  font-size: 15px;
  line-height: 1;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.fav-result:hover .fav-result-add {
  border-color: rgba(194, 184, 184, 0.4);
  color: var(--fg);
}

.fav-result.is-saved .fav-result-add {
  border-color: rgba(120, 190, 140, 0.4);
  background: rgba(120, 190, 140, 0.12);
  color: #9cc9a8;
}

.fav-result.is-saving .fav-result-add {
  opacity: 0.5;
}

.fav-hint {
  min-height: 15px;
  font-size: 11px;
  line-height: 1.4;
  color: rgba(194, 184, 184, 0.4);
}

.fav-hint.is-error {
  color: #e4796f;
}

body.is-locked {
  overflow: hidden;
}

.note.is-error {
  color: #e4796f;
}

/* ---------- dev panel text ---------- */

.admin-text {
  font-size: 12px;
  line-height: 1.5;
  color: rgba(194, 184, 184, 0.62);
}

.admin-text[hidden] {
  display: none;
}

/* ---------- motion ---------- */

@keyframes favIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  .fav {
    gap: 22px;
  }

  .fav-grid {
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 20px 12px;
  }

  .fav-title {
    font-size: 28px;
  }

  .fav-head {
    align-items: center;
  }

  .fav-gear {
    width: 34px;
    height: 34px;
  }

  .fav-modal {
    padding: 12px;
  }

  .fav-panel {
    max-height: calc(100dvh - 24px);
    padding: 15px;
    border-radius: 16px;
  }

  .fav-empty {
    padding: 48px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fav-item {
    animation: none;
  }

  .fav-card:hover .fav-art {
    transform: none;
  }
}
