/*
 * Indie Crates Embed Player Styles
 */

:root {
  --embed-bg: #14213d;
  --embed-text: #ffffff;
  --embed-accent: #fca311;
  --embed-muted: rgba(255, 255, 255, 0.6);
  --embed-border: rgba(255, 255, 255, 0.1);
  --embed-radius: 8px;
  --embed-font: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
}

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

.embed-body {
  font-family: var(--embed-font);
  background: transparent;
  -webkit-font-smoothing: antialiased;
}

.embed-player {
  display: flex;
  align-items: stretch;
  background: var(--embed-bg);
  border-radius: var(--embed-radius);
  overflow: hidden;
  height: 152px;
  max-width: 100%;
}

/* Artwork */
.embed-artwork {
  display: block;
  width: 152px;
  height: 152px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.05);
  text-decoration: none;

  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

.embed-artwork-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--embed-muted);
}

/* Content */
.embed-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 16px;
  min-width: 0;
}

/* Track Info */
.embed-track-info {
  min-width: 0;
}

.embed-track-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--embed-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.embed-title-link {
  display: block;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.embed-track-artist {
  font-size: 12px;
  color: var(--embed-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.embed-playlist-name {
  font-size: 10px;
  font-weight: 500;
  color: var(--embed-accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

/* Progress */
.embed-progress-container {
  cursor: pointer;
}

.embed-progress {
  height: 4px;
  background: var(--embed-border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 4px;
}

.embed-progress-bar {
  height: 100%;
  background: var(--embed-accent);
  width: 0%;
  transition: width 0.1s linear;
}

.embed-times {
  display: flex;
  justify-content: space-between;
}

.embed-time {
  font-size: 10px;
  color: var(--embed-muted);
  font-variant-numeric: tabular-nums;
}

/* Controls */
.embed-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.embed-controls-main {
  display: flex;
  align-items: center;
  gap: 4px;
}

.embed-btn {
  background: none;
  border: none;
  color: var(--embed-text);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;

  &:hover {
    background: rgba(255, 255, 255, 0.1);
  }

  &:active {
    transform: scale(0.95);
  }
}

.embed-btn-play {
  width: 36px;
  height: 36px;
  background: var(--embed-accent);
  color: var(--embed-bg);

  &:hover {
    background: oklch(from var(--embed-accent) calc(l * 0.9) c h);
  }
}

.embed-icon {
  font-size: 14px;
  line-height: 1;
}

.embed-btn-play .embed-icon {
  font-size: 16px;
}

/* Volume */
.embed-volume {
  display: flex;
  align-items: center;
  gap: 4px;
}

.embed-btn-volume {
  padding: 4px;
}

.embed-volume-slider {
  width: 60px;
  height: 4px;
  appearance: none;
  background: var(--embed-border);
  border-radius: 2px;
  cursor: pointer;

  &::-webkit-slider-thumb {
    appearance: none;
    width: 10px;
    height: 10px;
    background: var(--embed-text);
    border-radius: 50%;
    cursor: pointer;
  }

  &::-moz-range-thumb {
    width: 10px;
    height: 10px;
    background: var(--embed-text);
    border-radius: 50%;
    cursor: pointer;
    border: none;
  }
}

/* Actions (Buy/GetMusic) */
.embed-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.embed-btn-buy,
.embed-btn-getmusic,
.embed-btn-open-site {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--embed-text);
  opacity: 0.7;
  text-decoration: none;
  transition: opacity 0.15s ease;

  &:hover {
    opacity: 1;
  }
}

.embed-btn-open-site {
  border-radius: 4px;
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
}

.embed-btn-buy .fa-bandcamp {
  font-size: 1.125rem;
}

.embed-getmusic-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

/* Branding */
.embed-branding {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  background: rgba(0, 0, 0, 0.2);
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;

  &:hover {
    background: rgba(0, 0, 0, 0.4);
    width: 140px;

    .embed-logo {
      display: none;
    }

    .embed-cta {
      opacity: 1;
    }
  }
}

.embed-logo {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 11px;
  font-weight: 700;
  color: var(--embed-accent);
  letter-spacing: 0.05em;
}

.embed-cta {
  font-size: 10px;
  font-weight: 500;
  color: var(--embed-text);
  text-align: center;
  padding: 8px 6px;
  line-height: 1.3;
  opacity: 0;
  position: absolute;
  transition: opacity 0.2s ease;
}

/* Responsive - Tablet/Narrow Desktop */
@media (max-width: 600px) {
  .embed-volume-slider {
    width: 40px;
  }

  .embed-branding {
    width: 28px;
  }

  .embed-branding:hover {
    width: 120px;
  }
}

/* Responsive - Mobile (portrait phones) */
@media (max-width: 480px) {
  .embed-player {
    height: auto;
    flex-direction: column;
  }

  .embed-artwork {
    width: 100%;
    height: 180px;
    position: relative;
  }

  .embed-content {
    padding: 14px 16px;
    gap: 10px;
  }

  .embed-track-info {
    text-align: center;
  }

  .embed-playlist-name {
    font-size: 11px;
  }

  .embed-track-title {
    font-size: 15px;
  }

  .embed-track-artist {
    font-size: 13px;
  }

  /* Controls - stack vertically on mobile */
  .embed-controls {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .embed-controls-main {
    order: 1;
    gap: 8px;
  }

  /* Larger touch targets on mobile */
  .embed-btn {
    padding: 10px;
    min-width: 44px;
    min-height: 44px;
  }

  .embed-btn-play {
    width: 52px;
    height: 52px;
  }

  .embed-btn-play .embed-icon {
    font-size: 20px;
  }

  .embed-icon {
    font-size: 18px;
  }

  .embed-actions {
    order: 2;
    gap: 8px;
  }

  .embed-btn-buy .fa-bandcamp {
    font-size: 1.25rem;
  }

  .embed-getmusic-icon {
    width: 24px;
    height: 24px;
  }

  /* Hide volume on mobile - use device volume */
  .embed-volume {
    display: none;
  }

  /* Branding - horizontal bar on mobile */
  .embed-branding {
    width: 100%;
    height: 32px;
    writing-mode: horizontal-tb;
    flex-direction: row;
    gap: 6px;

    /* No hover effect on touch - always show CTA */
    &:hover {
      width: 100%;
      background: rgba(0, 0, 0, 0.2);
    }
  }

  .embed-logo {
    writing-mode: horizontal-tb;
    font-size: 12px;
  }

  .embed-cta {
    position: static;
    opacity: 1;
    font-size: 11px;
    padding: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Progress bar - larger hit area on mobile */
  .embed-progress {
    height: 6px;
    margin-bottom: 6px;
  }

  .embed-times {
    font-size: 11px;
  }
}

/* Responsive - Very small screens */
@media (max-width: 320px) {
  .embed-artwork {
    height: 140px;
  }

  .embed-content {
    padding: 12px;
  }

  .embed-track-title {
    font-size: 14px;
  }

  .embed-track-artist {
    font-size: 12px;
  }

  .embed-btn-play {
    width: 48px;
    height: 48px;
  }

  .embed-cta {
    font-size: 10px;
  }
}

/* Full player keeps the compact controls intact and adds a scrollable track list below them. */
.embed-player--full {
  height: 480px;
  flex-direction: column;
}

.embed-player--full .embed-player-main {
  display: flex;
  align-items: stretch;
  width: 100%;
  height: 152px;
  min-height: 152px;
}

.embed-player--full .embed-artwork {
  width: 152px;
  height: 152px;
}

.embed-player--full .embed-content {
  padding: 12px 16px;
  gap: 0;
  text-align: left;
}

.embed-player--full .embed-controls {
  flex-wrap: nowrap;
  justify-content: space-between;
}

.embed-player--full .embed-btn {
  min-width: 0;
  min-height: 0;
  padding: 6px;
}

.embed-player--full .embed-btn-play {
  width: 36px;
  height: 36px;
}

.embed-player--full .embed-volume {
  display: flex;
}

.embed-player--full .embed-branding {
  width: 32px;
  height: auto;
  flex-direction: column;
}

.embed-player--full .embed-branding:hover {
  width: 140px;
}

.embed-player--full .embed-logo {
  writing-mode: vertical-rl;
}

.embed-player--full .embed-cta {
  position: absolute;
  opacity: 0;
  white-space: normal;
}

.embed-player--full .embed-branding:hover .embed-cta {
  opacity: 1;
}

.embed-track-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  list-style: none;
  border-top: 1px solid var(--embed-border);
}

.embed-track-row {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--embed-border);
}

.embed-track-play {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px;
  color: var(--embed-text);
  background: none;
  border: 0;
  border-radius: 4px;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.embed-track-play:hover,
.embed-track-play:focus-visible {
  background: rgba(255, 255, 255, 0.08);
}

.embed-track-position {
  width: 24px;
  color: var(--embed-muted);
  font-size: 12px;
  text-align: center;
}

.embed-track-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.embed-track-row-title,
.embed-track-row-artist {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.embed-track-row-title {
  color: var(--embed-text);
  font-size: 14px;
  font-weight: 600;
}

.embed-track-row-artist {
  color: var(--embed-muted);
  font-size: 12px;
}

.embed-track-bandcamp {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 12px;
  color: var(--embed-bg);
  background: var(--embed-accent);
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.embed-track-bandcamp:hover,
.embed-track-bandcamp:focus-visible {
  filter: brightness(0.9);
}

@media (max-width: 480px) {
  .embed-player--full .embed-player-main {
    height: 152px;
    min-height: 152px;
  }

  .embed-player--full .embed-track-bandcamp span {
    display: none;
  }
}
