/* ============================================================
   Liner Notes — Editorial Dark Theme
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg:       #0a0a0a;
  --bg-card:  #111111;
  --bg-input: #141414;
  --text:     #f5f0e8;
  --text-dim: #8a8478;
  --text-mid: #b8b0a2;
  --gold:     #c9a959;
  --gold-dim: rgba(201, 169, 89, 0.25);
  --border:   #222;
  --radius:   6px;
}

html {
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Roboto', sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

/* --- Layout --- */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px;
}

/* --- Typography --- */
h1, h2, h3 {
  font-family: 'Calistoga', 'Georgia', serif;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

a {
  color: var(--gold);
  text-decoration: none;
  transition: color 0.2s ease, opacity 0.2s ease;
}
a:hover {
  color: #dfc274;
}

/* --- Utility --- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ============================================================
   HOME / HERO
   ============================================================ */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 60px 24px;
}

.hero__title {
  font-size: 4.5rem;
  color: var(--text);
  margin-bottom: 0.2em;
  letter-spacing: -0.03em;
}

.hero__tagline {
  font-family: 'Roboto', sans-serif;
  font-style: italic;
  font-size: 1.35rem;
  color: var(--text-mid);
  margin-bottom: 3rem;
  font-weight: 400;
}

.hero__form {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 560px;
  margin-bottom: 1rem;
}

.hero__input {
  flex: 1;
  padding: 14px 18px;
  font-family: 'Roboto', sans-serif;
  font-size: 1rem;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.hero__input::placeholder {
  color: var(--text-dim);
}
.hero__input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

.hero__btn {
  padding: 14px 28px;
  font-family: 'Calistoga', serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--gold);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.25s ease, transform 0.15s ease;
  white-space: nowrap;
}
.hero__btn:hover {
  background: #dfc274;
}
.hero__btn:active {
  transform: scale(0.97);
}

.hero__error {
  color: #d9735b;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  max-width: 560px;
}

.hero__about {
  max-width: 480px;
  margin-top: 2.5rem;
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.7;
}
.hero__about p + p {
  margin-top: 0.8em;
}

.hero__setup {
  max-width: 560px;
  margin-bottom: 1.5rem;
  padding: 16px 20px;
  background: rgba(201, 169, 89, 0.08);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-mid);
  text-align: left;
  line-height: 1.6;
}
.hero__setup code {
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.8rem;
}
.hero__setup p + p {
  margin-top: 0.5em;
}

.hero__divider {
  display: block;
  width: 40px;
  height: 1px;
  background: var(--gold);
  opacity: 0.4;
  margin: 2.5rem auto;
  border: none;
}

/* ============================================================
   NOTEBOOK — HEADER
   ============================================================ */
.nb-header {
  padding: 60px 0 40px;
  text-align: center;
}

.nb-header__img-wrap {
  display: inline-block;
  margin-bottom: 28px;
}

.nb-header__img {
  width: 240px;
  height: 240px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.6);
}

.nb-header__title {
  font-size: 2.6rem;
  margin-bottom: 0.3em;
}

.nb-header__meta {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-family: 'Roboto', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.nb-header__meta a {
  font-size: 0.8rem;
}

/* Copy link button */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-family: 'Roboto', sans-serif;
  font-size: 0.78rem;
  color: var(--gold);
  background: transparent;
  border: 1px solid var(--gold-dim);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.25s ease;
  letter-spacing: 0.02em;
}
.copy-btn:hover {
  background: var(--gold-dim);
  border-color: var(--gold);
}
.copy-btn.copied {
  color: #7aba6b;
  border-color: rgba(122, 186, 107, 0.3);
}

/* ============================================================
   SPOTIFY PLAYER EMBED
   ============================================================ */
.spotify-player {
  margin: 0 0 32px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.spotify-player iframe {
  display: block;
  width: 100%;
  border: none;
  border-radius: 12px;
}

/* ============================================================
   PUBLISH CONTROLS
   ============================================================ */
.publish-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 18px;
  font-family: 'Roboto', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--gold);
  background: transparent;
  border: 1px solid var(--gold-dim);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.publish-btn:hover {
  background: var(--gold-dim);
  border-color: var(--gold);
}
.publish-btn--active {
  color: #7aba6b;
  border-color: rgba(122, 186, 107, 0.3);
}
.publish-btn--active:hover {
  background: rgba(122, 186, 107, 0.1);
  border-color: rgba(122, 186, 107, 0.5);
}
.publish-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.publish-banner {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.35s ease, opacity 0.35s ease;
  opacity: 0;
  background: rgba(201, 169, 89, 0.06);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  margin-bottom: 0;
}
.publish-banner.visible {
  max-height: 120px;
  opacity: 1;
  padding: 16px 20px;
  margin-bottom: 24px;
}

.publish-banner__content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.publish-banner__label {
  font-family: 'Roboto', sans-serif;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.publish-banner__url-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.publish-banner__url {
  flex: 1;
  padding: 8px 12px;
  font-family: 'Roboto', monospace;
  font-size: 0.85rem;
  background: var(--bg-input);
  color: var(--gold);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  cursor: pointer;
}
.publish-banner__url:focus {
  border-color: var(--gold);
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Refresh button */
.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 18px;
  font-family: 'Roboto', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--text-mid);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.refresh-btn:hover {
  color: var(--gold);
  border-color: var(--gold);
  background: var(--gold-dim);
}
.refresh-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* ============================================================
   TRACK LIST
   ============================================================ */
.track-list {
  padding-bottom: 80px;
}

.track-list__heading {
  font-size: 0.75rem;
  font-family: 'Roboto', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 4px;
}

/* --- Single Track --- */
.track {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease;
}
.track:last-child {
  border-bottom: none;
}

.track__row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.track__num {
  flex-shrink: 0;
  width: 28px;
  font-family: 'Calistoga', serif;
  font-size: 0.85rem;
  color: var(--text-dim);
  text-align: right;
}

.track__info {
  flex: 1;
  min-width: 0;
}

.track__name {
  font-family: 'Calistoga', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}

.track__detail {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 1px;
}

.track__detail span + span::before,
.track__detail .artist-link + span::before,
.track__detail span + .artist-link::before {
  content: '·';
  margin: 0 6px;
  color: var(--border);
}

.track__actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.track__duration {
  font-family: 'Roboto', sans-serif;
  font-size: 0.8rem;
  color: var(--text-dim);
  min-width: 36px;
  text-align: right;
}

.play-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-dim);
  transition: all 0.25s ease;
  font-size: 0.7rem;
  padding-left: 2px;
  text-decoration: none;
}
.play-btn:hover {
  color: var(--gold);
  border-color: var(--gold);
  background: var(--gold-dim);
}

/* --- Liner Notes (read view) --- */
.track__notes {
  margin: 8px 0 0 44px;
  padding: 6px 0 6px 20px;
  border-left: 2px solid var(--gold);
  font-family: 'Caveat', cursive;
  font-style: normal;
  font-size: 1.5rem;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Track without notes — subdued & compact */
.track--empty {
  padding: 8px 0;
}
.track--empty .track__name {
  color: var(--text-mid);
}
.track--empty .track__detail {
  color: #5a554d;
}

/* ============================================================
   EDIT VIEW
   ============================================================ */
.edit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-family: 'Roboto', sans-serif;
  font-size: 0.82rem;
}

.edit-bar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.edit-bar__link {
  font-size: 0.82rem;
}

.track__textarea-wrap {
  margin: 12px 0 0 44px;
  position: relative;
}

.track__textarea {
  width: 100%;
  min-height: 56px;
  padding: 14px 16px;
  font-family: 'Caveat', cursive;
  font-size: 1.2rem;
  line-height: 1.65;
  color: var(--text);
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: var(--radius);
  resize: vertical;
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.track__textarea::placeholder {
  color: #555;
  font-style: normal;
}
.track__textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

.save-status {
  position: absolute;
  top: 10px;
  right: 12px;
  font-family: 'Roboto', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.save-status.visible {
  opacity: 1;
}
.save-status.saved {
  color: #7aba6b;
}
.save-status.saving {
  color: var(--gold);
}
.save-status.error {
  color: #d9735b;
}

/* ============================================================
   FOOTER
   ============================================================ */
.nb-footer {
  padding: 40px 0;
  text-align: center;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

.nb-footer a {
  font-family: 'Roboto', sans-serif;
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color 0.2s ease;
}
.nb-footer a:hover {
  color: var(--gold);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
  html {
    font-size: 15px;
  }
  .hero__title {
    font-size: 3rem;
  }
  .hero__form {
    flex-direction: column;
  }
  .nb-header {
    padding: 40px 0 28px;
  }
  .nb-header__img {
    width: 180px;
    height: 180px;
  }
  .nb-header__title {
    font-size: 1.8rem;
  }
  .track__notes {
    margin-left: 0;
    font-size: 1.4rem;
  }
  .track__textarea-wrap {
    margin-left: 0;
  }
  .track__row {
    gap: 10px;
  }
  .track__num {
    width: 22px;
  }
  .spotify-player iframe {
    height: 252px;
  }
  .publish-banner__url-row {
    flex-direction: column;
  }
  .publish-banner__url {
    width: 100%;
  }
  .edit-bar {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }
}

/* ============================================================
   ARTIST DISCOVERY POPOVER
   ============================================================ */
.artist-link {
  cursor: pointer;
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 1px dotted var(--text-dim);
  transition: color 0.2s ease, border-color 0.2s ease;
}
.artist-link:hover {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.discovery-popover {
  position: fixed;
  z-index: 1000;
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.65), 0 0 0 1px rgba(255,255,255,0.04);
  padding: 0;
  width: 340px;
  max-height: 480px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: popoverIn 0.18s ease-out;
}

@keyframes popoverIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.discovery-popover__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.discovery-popover__title {
  font-family: 'Calistoga', serif;
  font-size: 0.95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 8px;
}

.discovery-popover__close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s ease, color 0.2s ease;
}
.discovery-popover__close:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}

.discovery-popover__subtitle {
  padding: 8px 16px 4px;
  font-family: 'Roboto', sans-serif;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.discovery-popover__list {
  list-style: none;
  padding: 4px 8px 12px;
  overflow-y: auto;
  flex: 1;
}

.discovery-popover__item {
  margin: 0;
}

.discovery-popover__item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-mid);
  font-family: 'Roboto', sans-serif;
  font-size: 0.85rem;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.discovery-popover__item a:hover {
  background: rgba(201, 169, 89, 0.1);
  color: var(--gold);
}

.discovery-popover__icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.discovery-popover__label {
  flex: 1;
  min-width: 0;
}

.discovery-popover__label-name {
  display: block;
  font-weight: 500;
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.25;
}

.discovery-popover__label-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.3;
}

.discovery-popover__arrow {
  flex-shrink: 0;
  color: var(--text-dim);
  font-size: 0.7rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.discovery-popover__item a:hover .discovery-popover__arrow {
  opacity: 1;
}

/* Backdrop overlay */
.discovery-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0,0,0,0.3);
  animation: backdropIn 0.15s ease-out;
}
@keyframes backdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.discovery-popover__body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.discovery-popover__loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 16px;
  font-family: 'Roboto', sans-serif;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.discovery-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.discovery-popover__empty {
  padding: 24px 16px;
  font-family: 'Roboto', sans-serif;
  font-size: 0.85rem;
  color: var(--text-dim);
  text-align: center;
}

@media (max-width: 600px) {
  .discovery-popover {
    width: calc(100vw - 32px);
    left: 16px !important;
    right: 16px !important;
    max-height: 60vh;
  }
}
