/* Media item detail modal — mobile-first core content */

body.midm-modal-open {
  overflow: hidden;
}

.midm-overlay {
  -webkit-tap-highlight-color: transparent;
}

.midm-backdrop {
  background: rgb(0 0 0 / 0.5);
}

.dark .midm-backdrop {
  background: rgb(0 0 0 / 0.6);
}

.midm-panel {
  background: rgb(var(--card));
  border: 1px solid rgb(var(--border));
  color: rgb(var(--foreground));
  max-height: min(94vh, 94dvh);
}

@media (min-width: 640px) {
  .midm-panel {
    max-width: 36rem;
    max-height: min(88vh, 88dvh);
  }
}

.midm-handle {
  width: 2.5rem;
  height: 0.25rem;
  border-radius: 999px;
  background: rgb(var(--muted-foreground) / 0.45);
  margin: 0.5rem auto 0;
  flex-shrink: 0;
}

.midm-header {
  border-bottom: 1px solid rgb(var(--border));
}

.midm-header-title {
  color: rgb(var(--foreground));
}

.midm-close {
  border: 1px solid rgb(var(--border));
  color: rgb(var(--foreground));
  background: rgb(var(--card));
}

.midm-close:hover,
.midm-close:focus-visible {
  background: rgb(var(--muted));
}

.midm-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.midm-body {
  padding: 1rem 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.midm-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
}

.midm-poster-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
}

.midm-poster {
  display: block;
  max-width: 100%;
  border-radius: 0.625rem;
  border: 1px solid rgb(var(--border));
  object-fit: cover;
  background: rgb(var(--muted));
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.12);
}

.midm-poster--tall {
  width: min(52vw, 11rem);
  aspect-ratio: 2 / 3;
}

/* Movie/TV hero — larger footprint to match square-type modal visual weight */
.midm-poster--tall-hero {
  width: min(68vw, 14rem);
  aspect-ratio: 2 / 3;
}

.midm-poster--square {
  width: min(72vw, 16rem);
  aspect-ratio: 1 / 1;
}

.midm-poster--wide {
  width: 100%;
  max-width: 20rem;
  aspect-ratio: 2 / 1;
}

@media (min-width: 640px) {
  .midm-poster--tall {
    width: min(40vw, 12rem);
  }

  .midm-poster--tall-hero {
    width: min(48vw, 15rem);
  }

  .midm-poster--square {
    width: min(50vw, 17rem);
  }
}

.midm-panel--movie-tv {
  min-height: min(72vh, 72dvh);
}

.midm-movie-tv-details {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  text-align: center;
}

.midm-movie-tv-details.hidden {
  display: none;
}

.midm-year {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: rgb(var(--muted-foreground));
  line-height: 1.35;
}

.midm-year.hidden {
  display: none;
}

.midm-fact-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.midm-fact-row.hidden {
  display: none;
}

.midm-fact-label {
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgb(var(--muted-foreground));
}

.midm-fact-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: rgb(var(--foreground));
  line-height: 1.35;
}

.midm-section-label {
  margin: 0 0 0.35rem;
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgb(var(--muted-foreground));
}

.midm-cast-section.hidden,
.midm-genres-section.hidden {
  display: none;
}

.midm-cast-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.midm-cast-item {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: rgb(var(--foreground));
}

.midm-cast-name {
  font-weight: 700;
}

.midm-cast-role {
  font-weight: 500;
  color: rgb(var(--muted-foreground));
}

.midm-genre-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  justify-content: center;
}

.midm-genre-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.25;
}

.midm-genre-pill--movie {
  color: #fff;
  background: rgb(229 9 20 / 0.92);
  border: 1px solid rgb(229 9 20 / 0.35);
}

.midm-genre-pill--tv {
  color: #fff;
  background: rgb(106 13 173 / 0.92);
  border: 1px solid rgb(106 13 173 / 0.35);
}

.dark .midm-genre-pill--movie {
  background: rgb(229 9 20 / 0.85);
}

.dark .midm-genre-pill--tv {
  background: rgb(106 13 173 / 0.85);
}

.midm-loading {
  margin: 0;
  font-size: 0.8125rem;
  font-style: italic;
  color: rgb(var(--muted-foreground));
}

.midm-hero-copy {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.midm-type-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #fff;
  text-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
}

.midm-hero-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.25;
  color: rgb(var(--foreground));
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.midm-hero-subline {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgb(var(--muted-foreground));
  line-height: 1.35;
}

.midm-hero-subline.hidden {
  display: none;
}

.midm-synopsis {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.55;
  color: rgb(var(--foreground));
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}

.midm-synopsis--empty {
  font-style: italic;
  color: rgb(var(--muted-foreground));
}

.midm-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  justify-content: center;
}

.midm-pills.hidden {
  display: none;
}

.midm-meta-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgb(var(--border));
  background: rgb(var(--muted));
  color: rgb(var(--foreground));
  padding: 0.2rem 0.55rem;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.25;
}

.midm-links-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.midm-links-section-heading {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 800;
  color: rgb(var(--foreground));
}

.midm-links-empty {
  margin: 0;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: rgb(var(--muted-foreground));
}

.midm-full-detail-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 0.625rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid rgb(var(--border));
  background: rgb(var(--muted));
  color: rgb(var(--foreground));
  font-size: 0.9375rem;
  font-weight: 800;
  text-decoration: none;
  text-align: center;
  transition: background 0.15s ease;
}

.midm-full-detail-btn:hover,
.midm-full-detail-btn:focus-visible {
  background: rgb(var(--accent));
  outline: 2px solid rgb(var(--ring));
  outline-offset: 2px;
}

.midm-full-detail-btn--disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.midm-footer {
  flex-shrink: 0;
  border-top: 1px solid rgb(var(--border));
  padding: 0.75rem 1rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  background: rgb(var(--card));
}

.midm-status {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  text-align: center;
  color: rgb(var(--muted-foreground));
}

.midm-status.hidden {
  display: none;
}

.midm-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.midm-action-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.5rem 0.625rem;
  border-radius: 0.5rem;
  border: 1px solid rgb(var(--border));
  background: rgb(var(--card));
  color: rgb(var(--foreground));
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.06);
  transition: background 0.15s ease;
}

.midm-action-chip:hover,
.midm-action-chip:focus-visible {
  background: rgb(var(--muted));
  outline: 2px solid rgb(var(--ring));
  outline-offset: 2px;
}

.midm-action-chip--primary {
  width: 100%;
  min-height: 48px;
  font-size: 0.9375rem;
  border-color: transparent;
  background: rgb(var(--primary));
  color: rgb(var(--primary-foreground));
}

.midm-action-chip--primary:hover,
.midm-action-chip--primary:focus-visible {
  background: rgb(var(--primary) / 0.9);
}

.midm-action-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.midm-action-chip--save {
  font-size: 0.625rem;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

.midm-links :is(a, button) {
  min-height: 44px;
}

/* Thumbnail affordances on cards */
.media-item-thumb--detail {
  cursor: pointer;
}

.media-item-thumb--detail:focus-visible {
  outline: 2px solid rgb(var(--ring));
  outline-offset: 2px;
}

.media-item-thumb-info {
  position: absolute;
  right: 0.35rem;
  bottom: 0.35rem;
  z-index: 2;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 800;
  font-style: italic;
  font-family: Georgia, 'Times New Roman', serif;
  color: rgb(255 255 255);
  background: rgb(0 0 0 / 0.45);
  border: 1px solid rgb(255 255 255 / 0.35);
  pointer-events: none;
  line-height: 1;
}

.media-item-quick-add {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  z-index: 3;
  width: 1.75rem;
  height: 1.75rem;
  min-width: 1.75rem;
  min-height: 1.75rem;
  border-radius: 999px;
  border: 1px solid rgb(var(--border));
  background: rgb(var(--card) / 0.95);
  color: rgb(var(--foreground));
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
  cursor: pointer;
}

.media-item-quick-add:hover,
.media-item-quick-add:focus-visible {
  background: rgb(var(--muted));
}

.profile-collection-row__cover.media-item-thumb--detail {
  cursor: pointer;
}

.midm-featured-episode {
  margin: 0 1rem 1rem;
  padding: 0.875rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid rgb(var(--border));
  background: rgb(var(--muted) / 0.35);
}

.midm-featured-episode-head {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  margin-bottom: 0.75rem;
}

.midm-featured-episode-poster-wrap {
  flex: 0 0 auto;
  width: 5.5rem;
  aspect-ratio: 1;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid rgb(var(--border));
  background: rgb(var(--muted));
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}

.midm-featured-episode-poster {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.midm-featured-episode-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.midm-panel--has-featured-episode .midm-scroll {
  scroll-padding-top: 0.5rem;
}

.midm-featured-episode-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgb(var(--muted-foreground));
}

.midm-featured-episode-match {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: rgb(var(--muted-foreground));
}

.midm-featured-episode-title {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  color: rgb(var(--foreground));
}

.midm-featured-episode-show {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  color: rgb(var(--muted-foreground));
}

.midm-featured-episode-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.midm-featured-episode-desc {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  line-height: 1.45;
  color: rgb(var(--foreground));
}

.midm-featured-episode-links {
  margin-bottom: 0.75rem;
}

.midm-featured-episode-links .playlists-right-drawer-section-title {
  margin: 0 0 0.5rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgb(var(--muted-foreground));
}

.midm-featured-episode-links .playlists-right-drawer-row {
  margin-bottom: 0.5rem;
}

.midm-episode-full-detail-btn {
  display: inline-flex;
  margin-bottom: 0.75rem;
}

.midm-featured-episode-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (min-width: 480px) {
  .midm-featured-episode-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
}
