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

.episode-grid {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  display: grid;
  gap: 1.5rem;
}

.loading-msg {
  color: var(--muted-gray);
  text-align: center;
}

/* ---------- search + sort controls ---------- */

.controls {
  display: flex;
  gap: 0.75rem;
  box-sizing: border-box;
  width: calc(100% - 3rem);
  max-width: 960px;
  margin: 2rem auto 0;
}

#search {
  display: block;
  box-sizing: border-box;
  flex: 1;
  min-width: 0;
  padding: 0.75rem 1.25rem;
  font: inherit;
  color: var(--ink);
  background-color: var(--card-bg);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  transition:
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}

#search::placeholder {
  color: var(--muted-gray);
}

#search:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(116, 78, 150, 0.2);
}

.sort-toggle {
  flex-shrink: 0;
  box-sizing: border-box;
  min-width: 9.5rem;
  padding: 0.75rem 1.25rem;
  font: inherit;
  color: var(--text-gray);
  background-color: var(--card-bg);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  cursor: pointer;
  transition:
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}

.sort-toggle:hover {
  color: var(--ink);
}

.sort-toggle:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(116, 78, 150, 0.2);
}

@media (max-width: 480px) {
  .controls {
    flex-direction: column;
  }
}

/* ---------- episode card ---------- */

.episode-card {
  background: var(--card-bg);
  color: var(--ink);
  border-radius: 10px;
  padding: 1.5rem;
  position: relative;
  min-width: 0; /* grid items default to min-width:auto, which ignores nowrap text truncation */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.episode-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

.episode-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--purple);
  margin-bottom: 0.5rem;
}

.episode-card-summary {
  list-style: none; /* removes default marker in most browsers */
  cursor: pointer;
  position: relative;
}
.episode-card-summary::-webkit-details-marker {
  display: none; /* removes it in Chrome/Safari */
}

.episode-card-summary::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0.1rem;
  width: 0.55em;
  height: 0.55em;
  margin-top: -0.3em;
  border-right: 2px solid var(--purple);
  border-bottom: 2px solid var(--purple);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.episode-card[open] .episode-card-summary::after {
  transform: rotate(225deg);
}

.episode-number {
  font-weight: 700;
}

.episode-title {
  font-size: 1.4rem;
  font-weight: bold;
  margin: 0 0 1.25rem;
  line-height: 1.2;
  padding-right: 1.25rem;
}

.episode-description {
  color: var(--text-gray);
  font-size: 0.9rem;
  line-height: 1.4;
  margin: -0.75rem 0 1.25rem;
}

/* ---------- tracklist ---------- */

.tracklist {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.track-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 0.9rem;
}

.track-index {
  color: var(--purple);
  font-weight: bold;
  width: 1.5rem;
  flex-shrink: 0;
}

.track-art {
  width: 36px;
  height: 36px;
  object-fit: cover;
  background: var(--muted-gray);
  border-radius: 6px;
  flex-shrink: 0;
}

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

.track-name {
  font-weight: 700;
  color: var(--purple);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  color: var(--text-gray);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
