/**
 * Media Modal Styles
 * Video/Audio player with transcript segments
 * Clean white theme matching the main app
 */

/* Overlay */
.media-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.media-modal-overlay.open {
  display: flex;
}

/* Modal container */
.media-modal {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 1200px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

/* Header */
.media-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e3dfd5;
  flex-shrink: 0;
  background: #faf9f6;
}

.media-modal-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  padding-right: 1rem;
}

.media-modal-current {
  flex-shrink: 0;
  border: 1px solid #e3dfd5;
  border-radius: 999px;
  background: transparent;
  color: #777;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.42rem 0.65rem;
  transition: background 0.15s, color 0.15s;
}

.media-modal-current:hover {
  background: #f0ede6;
  color: #1a1a1a;
}

.media-modal-close {
  background: none;
  border: 1px solid #e3dfd5;
  color: #555;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  border-radius: 6px;
  transition: background 0.15s;
}

.media-modal-close:hover {
  background: #f0ede6;
  color: #1a1a1a;
}

/* Content area - split view */
.media-modal-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Player container */
.media-player-container {
  flex: 1;
  min-width: 0;
  background: #000;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.media-player-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: block;
}

.media-player-frame > div,
.media-player-frame video,
.media-player-frame iframe {
  width: 100%;
  height: 100%;
}

.native-wistia-player {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: #000;
}

.native-wistia-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.native-wistia-audio {
  width: min(720px, 100%);
  height: 48px;
}

.media-player-container iframe,
.media-player-container .wistia_embed {
  width: 100%;
  height: 100%;
}

/* Wistia official responsive wrapper support */
.media-player-container .wistia_responsive_padding {
  width: 100%;
  height: auto;
  max-width: 100%;
  box-sizing: border-box;
}

.media-player-frame > .wistia_responsive_padding {
  height: auto;
}

.media-player-container .wistia_responsive_wrapper {
  width: 100%;
  height: 100%;
}

.media-player-container .wistia_responsive_wrapper iframe.wistia_embed {
  width: 100%;
  height: 100%;
  border: 0;
}

.media-player-container.audio-media {
  flex: 0 0 auto;
  min-height: 0;
}

.media-player-container.audio-media .media-player-frame {
  flex: 0 0 260px;
}

.media-player-container.audio-media .wistia_responsive_padding {
  height: 100%;
  padding: 0 !important;
}

.media-player-container.audio-media .wistia_responsive_wrapper {
  position: static !important;
  height: 100% !important;
}

.media-player-container.audio-media iframe.wistia_embed {
  min-height: 220px;
}

.media-modal-content:has(.media-player-container.audio-media) {
  flex-direction: column;
}

.media-modal-content:has(.media-player-container.audio-media) .transcript-panel {
  width: 100%;
  min-height: 0;
  flex: 1;
  border-left: none;
  border-top: 1px solid #e3dfd5;
}

.media-caption-strip {
  position: relative;
  flex-shrink: 0;
  width: 100%;
  min-height: 68px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  background: #111;
  color: #fff;
  font-size: 1rem;
  line-height: 1.45;
  text-align: center;
  pointer-events: none;
}

.media-caption-strip.visible {
  display: flex;
}

.media-caption-strip-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.media-caption-token.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 3px;
}

/* Transcript panel (scoped to modal only — avoid leaking into SourcePage) */
.media-modal .transcript-panel {
  width: 360px;
  flex-shrink: 0;
  overflow-y: auto;
  border-left: 1px solid #e3dfd5;
  background: #fff;
}

/* Transcript segment */
.transcript-segment {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid #f0ede6;
  cursor: pointer;
  transition: background 0.15s;
}

.transcript-segment:hover {
  background: #faf9f6;
}

.transcript-segment.active {
  background: #f5f3ee;
  border-left: 3px solid #1a1a1a;
  padding-left: calc(1rem - 3px);
}

.transcript-segment:focus {
  outline: 2px solid #1a1a1a;
  outline-offset: -2px;
}

.transcript-segment-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.375rem;
}

.transcript-segment-title {
  font-weight: 600;
  font-size: 0.8125rem;
  color: #1a1a1a;
  flex: 1;
  line-height: 1.4;
}

.transcript-segment-time {
  font-size: 0.7rem;
  font-family: monospace;
  color: #555;
  background: #f0ede6;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
}

.transcript-segment-text {
  font-size: 0.75rem;
  color: #666;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.transcript-segment-summary {
  margin-bottom: 0.35rem;
  color: #444;
  font-size: 0.76rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.transcript-segment.active .transcript-segment-text {
  -webkit-line-clamp: 6;
}

.transcript-segment.active .transcript-segment-summary {
  -webkit-line-clamp: 3;
}

.segment-transcript-rows {
  display: none;
  margin-top: 0.6rem;
  border-top: 1px solid #f0ede6;
}

.transcript-segment.active .segment-transcript-rows {
  display: block;
}

.segment-transcript-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 0.65rem;
  width: 100%;
  padding: 0.5rem 0;
  border: 0;
  border-bottom: 1px solid #f5f3ee;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.segment-transcript-row:hover {
  background: #faf9f6;
}

.segment-transcript-row.active {
  background: #f0ede6;
  border-radius: 4px;
}

.segment-transcript-row.active .segment-transcript-row-time {
  color: #1a1a1a;
  font-weight: 600;
}

.segment-transcript-row.active .segment-transcript-row-text {
  color: #1a1a1a;
}

.segment-transcript-row-time {
  color: #777;
  font-family: monospace;
  font-size: 0.68rem;
  line-height: 1.5;
}

.segment-transcript-row-text {
  color: #333;
  font-size: 0.76rem;
  line-height: 1.5;
}

.transcript-source-note {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid #e3dfd5;
  background: #faf9f6;
  color: #555;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.source-transcript-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f0ede6;
  cursor: pointer;
  transition: background 0.15s;
}

.source-transcript-row:hover {
  background: #faf9f6;
}

.source-transcript-row.active {
  background: #f5f3ee;
  border-left: 3px solid #1a1a1a;
  padding-left: calc(1rem - 3px);
}

.source-transcript-row:focus {
  outline: 2px solid #1a1a1a;
  outline-offset: -2px;
}

.source-transcript-time {
  color: #777;
  font-family: monospace;
  font-size: 0.7rem;
  line-height: 1.5;
}

.source-transcript-text {
  color: #333;
  font-size: 0.78rem;
  line-height: 1.55;
}

/* Loading and error states */
.media-loading,
.media-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  color: #888;
  font-size: 0.875rem;
}

.media-error {
  color: #d44;
}

.transcript-empty {
  padding: 2rem;
  text-align: center;
  color: #888;
  font-size: 0.8125rem;
}

/* View Source button on cards */
.view-source-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.72rem;
  color: #555;
  background: #f0ede6;
  border: 1px solid #e3dfd5;
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  font-family: inherit;
}

.view-source-btn:hover {
  background: #e3dfd5;
  border-color: #ccc8be;
  color: #1a1a1a;
}

.view-source-btn svg {
  width: 12px;
  height: 12px;
}

/* Panel view source button - more prominent */
.panel-view-source {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #eee;
}

.panel-view-source-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  background: #2c2c2c;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.panel-view-source-btn:hover {
  background: #444;
}

.panel-view-source-btn::before {
  content: '▶';
  font-size: 0.75rem;
}

/* Mobile responsive */
@media (max-width: 900px) {
  .media-modal-content {
    flex-direction: column;
  }

  .media-player-container {
    flex: none;
    width: 100%;
    aspect-ratio: 16 / 9;
  }

  .media-player-container.audio-media {
    flex: none;
    aspect-ratio: auto;
  }

  .media-player-container.audio-media .media-player-frame {
    flex: 0 0 220px;
  }

  .media-caption-strip {
    min-height: 48px;
    padding: 0.55rem 0.8rem;
    font-size: 0.8rem;
  }

  .media-modal .transcript-panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid #e3dfd5;
    flex: 1;
    min-height: 200px;
  }
}

@media (max-width: 600px) {
  .media-modal-overlay {
    padding: 0;
  }

  .media-modal {
    max-width: 100%;
    max-height: 100%;
    height: 100%;
    border-radius: 0;
  }

  .media-modal-header {
    padding: 0.75rem 0.8rem;
    gap: 0.5rem;
  }

  .media-modal-header h2 {
    font-size: 0.9rem;
  }

  .media-modal-current {
    font-size: 0.68rem;
    padding: 0.38rem 0.55rem;
  }

  .transcript-segment {
    padding: 0.75rem 1rem;
  }

  .transcript-segment-title {
    font-size: 0.78rem;
  }

  .transcript-segment-text {
    font-size: 0.72rem;
    -webkit-line-clamp: 2;
  }

  .transcript-segment.active .transcript-segment-text {
    -webkit-line-clamp: 5;
  }
}
