/* SnagTrax Embed Player Styles */

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

:root {
  --bg1: #e65c00;
  --bg2: #b31217;
  --accent: #ff6b35;
  --accent-dim: rgba(255, 107, 53, 0.6);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.65);
  --glass-blur: blur(18px);
  --glass-dark: rgba(0, 0, 0, 0.45);
  --glass-white-start: rgba(255, 255, 255, 0.15);
  --glass-white-end: rgba(255, 255, 255, 0.05);

  /* Refined light glass theme (more transparent) */
  --glass-light-bg: rgba(255, 255, 255, 0.45);
  --glass-light-blur: blur(28px);
  --text-dark-primary: #111111;
  --text-dark-secondary: #555555;
  --text-dark-tertiary: #888888;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Player shell ─────────────────────────────── */

#player {
  position: relative;
  width: 100vmin;
  height: 100vmin;
  margin: 0 auto;
  overflow: hidden;
  background: linear-gradient(135deg, var(--bg1), var(--bg2));
  user-select: none;
  -webkit-user-select: none;
}

#player::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--texture-url, none);
  background-size: cover;
  background-position: center;
  opacity: var(--texture-opacity, 0);
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 1;
}

/* ── Vinyl canvas ─────────────────────────────── */

#vinyl-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  display: block;
}

/* ── Label buffering indicator ─────────────────────────────── */

/* Spinner shown over the cover while the heavy renderer/audio init runs
   (first interaction). Sits above the cover overlay so the user sees a
   responsive UI even though the main thread is briefly busy. The host JS
   awaits the fade-out (transitionend) before triggering the cover slide,
   so the two animations never overlap. */
#cover-loading {
  position: absolute;
  inset: 0;
  z-index: 16;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#cover-loading.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Spinner sized to the vinyl label (innerR diameter = size * 0.47 * 0.38 * 2
   = 35.7vmin, same constant as #label-loading). Starts small and grows to
   full size when the loading state becomes visible — width/height (not
   transform) so it doesn't conflict with the spin rotation animation. */
#cover-loading .spinner {
  width: 24px;
  height: 24px;
  border-width: 2.5px;
  /* Hold small for 0.6s, then ease to label size over 1.5s. */
  transition: width 1.5s cubic-bezier(0.16, 1, 0.3, 1) 0.6s,
              height 1.5s cubic-bezier(0.16, 1, 0.3, 1) 0.6s,
              border-width 1.5s cubic-bezier(0.16, 1, 0.3, 1) 0.6s;
}

#cover-loading.visible .spinner {
  width: 35.7vmin;
  height: 35.7vmin;
  border-width: max(3px, 1vmin);
}

#label-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  /* diameter matches innerR = size * 0.47 * 0.38 * 2 */
  width: 35.7vmin;
  height: 35.7vmin;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#label-loading.visible {
  opacity: 1;
}

#label-loading .spinner {
  width: 22px;
  height: 22px;
  border-width: 2px;
}

/* ── Label hover hint — invisible click zone over center label ── */

#label-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
  background: rgba(0, 0, 0, 0.45);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

#label-hint.visible {
  opacity: 1;
}

/* ── Title bar — dark frosted glass ──────────── */

#title-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 10px 10px 8px;
  background: var(--glass-dark);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.title-bar-spacer {
  width: 44px;
  /* Matches btn-tag width + gap/padding */
}

#title-bar-center {
  flex: 1;
  min-width: 0;
  text-align: center;
}

#track-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow:
    0 0 14px rgba(255, 255, 255, 0.4),
    0 1px 3px rgba(0, 0, 0, 0.8);
}

#track-artist {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

/* Tag icon button in title bar */
#btn-tag {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

#btn-tag:hover {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.95);
}

#btn-tag svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ── Details panel ────────────────────────────── */

#details-panel {
  position: absolute;
  top: 52px; /* Title bar height + border */
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--glass-dark);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  transform: translateY(1001%); /* Extra 1% to hide border shadow */
  transform: translateY(100%);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.4);
  -webkit-overflow-scrolling: touch;
}

#details-panel.open {
  transform: translateY(0);
}

#details-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

#details-artwork {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#details-meta {
  flex: 1;
  min-width: 0;
}

.meta-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 4px;
}

.meta-row:last-child {
  margin-bottom: 0;
}

.meta-label {
  width: 65px;
  flex-shrink: 0;
  text-align: right;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  opacity: 0.5;
}

.meta-value {
  flex: 1;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Specific overrides for main album/artist values in header */
#details-album-name {
  color: var(--text-primary);
  font-weight: 600;
}

#details-close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-dark-secondary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

#details-close:hover {
  background: rgba(0, 0, 0, 0.12);
}

#details-close svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

#details-track-list {
  list-style: none;
  padding: 4px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
}

#details-tracklist-header {
  padding: 14px 20px 8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.4;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#details-footer {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.02);
  padding: 16px 20px 24px;
}

.details-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 0 20px;
  flex-shrink: 0;
}

#details-track-meta {
  margin-bottom: 16px;
}

#details-attribution {
  font-size: 10px;
  color: var(--text-dark-tertiary);
  text-align: center;
  opacity: 0.6;
  line-height: 1.4;
}

.details-track {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.details-track:last-child {
  border-bottom: none;
}

.details-track:hover {
  background: rgba(255, 255, 255, 0.04);
}

.details-track.active {
  background: rgba(255, 255, 255, 0.08);
}

.details-track.active .details-track-name {
  color: var(--accent);
}

.details-track-num {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-secondary);
  width: 20px;
  text-align: right;
  flex-shrink: 0;
  opacity: 0.4;
}

.details-track.active .details-track-num {
  color: var(--accent);
  opacity: 1;
}

.details-track-name {
  flex: 1;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.details-track-dur {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-secondary);
  flex-shrink: 0;
  opacity: 0.5;
}

/* ── Bottom controls — auto-width, centered, anchored to bottom ─ */

#bottom-overlay {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 14px 24px 4px;
  background: linear-gradient(135deg, var(--glass-white-start), var(--glass-white-end));
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  border-left: 1px solid rgba(255, 255, 255, 0.15);
  border-right: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px 16px 0 0;
  white-space: nowrap;
  transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1), opacity 0.3s;
}

/* Slide controls down when tracklist is open */
.details-open #bottom-overlay {
  transform: translateX(-50%) translateY(100%);
  opacity: 0;
  pointer-events: none;
}

#controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

/* Control buttons — square with rounded corners */
.ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  flex-shrink: 0;
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.9);
}

.ctrl-btn:active {
  transform: scale(0.92);
}

.ctrl-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Play button — accent gradient */
#btn-play {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: linear-gradient(315deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #fff));
  color: #fff;
}

#btn-play:hover {
  filter: brightness(1.1);
}

#btn-play svg {
  width: 22px;
  height: 22px;
}

/* ── Footnote — inside controls container ─────── */

#footnote {
  margin-top: 8px;
  text-align: center;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.35);
}

#footnote a {
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
}

#footnote a:hover {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: underline;
}

/* ── Album cover panel ────────────────────────── */

#cover-panel {
  position: absolute;
  inset: 0;
  z-index: 15;
  transform: translateX(0%);
  transition: transform 0.55s cubic-bezier(0.65, 0, 0.35, 1);
  will-change: transform;
}

#cover-panel.revealed {
  transform: translateX(-100%);
  pointer-events: none;
}

#cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#cover-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0);
  transition: background 0.25s ease;
  cursor: pointer;
}

#cover-panel:hover #cover-overlay {
  background: rgba(0, 0, 0, 0.52);
}

#cover-play-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.25s ease, transform 0.25s ease;
  flex-shrink: 0;
}

#cover-play-icon svg {
  width: 26px;
  height: 26px;
  fill: #111;
  margin-left: 3px;
}

#cover-play-hint {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s ease 0.05s, transform 0.25s ease 0.05s;
}

#cover-panel:hover #cover-play-icon {
  opacity: 1;
  transform: scale(1);
}

#cover-panel:hover #cover-play-hint {
  opacity: 1;
  transform: translateY(0);
}

/* ── Loading state ───────────────────────────── */

#loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  z-index: 20;
  transition: opacity 0.3s;
}

#loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 2.5px solid rgba(255, 255, 255, 0.15);
  border-top-color: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Error state ─────────────────────────────── */

#error {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: #111;
  z-index: 20;
  padding: 20px;
  text-align: center;
}

#error.visible {
  display: flex;
}

#error-message {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
}