/* 
  ========================================================================
  PEACE WORLD - MEDIA GALLERY STYLING (media.css)
  ========================================================================
*/

/* Media Type Badges */
.media-type-icon-wrapper {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
}

[dir="rtl"] .media-type-icon-wrapper {
  right: auto;
  left: 12px;
}

/* Audio Waveform Simulator Graphic */
.waveform-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 40px;
  padding: 0 10px;
}

.waveform-bar {
  width: 3px;
  background-color: var(--color-teal);
  border-radius: 9999px;
  animation: wavePulse 1.2s ease-in-out infinite alternate;
}

@keyframes wavePulse {
  0% { height: 10%; }
  100% { height: 100%; }
}

/* Stagger animation delays for realistic movement */
.waveform-bar:nth-child(2n) { animation-delay: 0.15s; }
.waveform-bar:nth-child(3n) { animation-delay: 0.3s; }
.waveform-bar:nth-child(4n) { animation-delay: 0.45s; }

/* Clean styling for standard video players */
video {
  width: 100%;
  border-radius: 8px;
  background-color: #000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

audio {
  width: 100%;
  border-radius: 8px;
  filter: sepia(0.1) saturate(0.8) hue-rotate(120deg) contrast(0.9);
}

/* Hide download button in browsers that ignore controlsList */
audio::-internal-media-controls-download-button,
video::-internal-media-controls-download-button,
audio::-webkit-media-controls-download-button,
video::-webkit-media-controls-download-button {
    display: none !important;
}

/* Also hide the overflow menu if it contains download */
audio::-webkit-media-controls-enclosure,
video::-webkit-media-controls-enclosure {
    overflow: hidden;
}

/* ==========================================================================
   UNIFIED MEDIA PLAYER SHELL — new layout styles (additive only)
   ==========================================================================

   The thumbnail/cover graphic and the native HTML5 <audio>/<video> element
   are now merged into one unified .media-player-shell container so there is
   no more duplicated stacked visual (thumbnail above + player below).

   - .media-duration-badge     : small chip in the bottom-right corner
   - .media-play-overlay       : centered circular play/pause button overlay
   - .video-play-overlay       : variant tuned for video (16:9) covers
   - .audio-play-overlay       : variant tuned for audio (1:1) covers
   - .audio-controls-bar       : slim bar that hosts the native <audio> element
                                  directly under the audio cover, so it feels
                                  attached (SoundCloud-style) rather than a
                                  separate stacked block.
   - :has(:not(:paused)) rule  : hides the overlay + duration chip automatically
                                  whenever the underlying media is playing.
                                  Uses modern CSS :has() (supported in all
                                  evergreen browsers since late 2023).
   ========================================================================== */

/* ==========================================================================
   VIDEO ORIENTATION HANDLING — REMOVED
   --------------------------------------------------------------------------
   Videos are no longer embedded as <video> files — they are YouTube link
   cards (see the YOUTUBE LINK CARD section below), so the portrait-video
   letterbox rules that used to live here have been deleted with them.
   ========================================================================== */

/* --- Duration chip (bottom-right corner of the cover / thumbnail) --- */
.media-duration-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 11;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.78);
    color: #ffffff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.02em;
    pointer-events: none;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: opacity 0.25s ease;
}

[dir="rtl"] .media-duration-badge {
    right: auto;
    left: 10px;
}

/* --- Unified media player shell --- */
.media-player-shell {
    position: relative;
}

/* Make sure the inner cover container inherits the shell's rounded corners */
.media-player-shell .card-thumbnail-container {
    border-radius: 0;
}

/* --- Centered circular play overlay button --- */
.media-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0.18) 55%,
        rgba(0, 0, 0, 0.42) 100%
    );
    border: none;
    cursor: pointer;
    z-index: 9;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.media-play-overlay .play-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--color-teal-dark, #33625a);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
                background-color 0.25s ease,
                color 0.25s ease;
}

.media-play-overlay:hover .play-circle {
    transform: scale(1.1);
    background: var(--color-clay, #c87a53);
    color: #ffffff;
}

.media-play-overlay:focus-visible {
    outline: 2px solid var(--color-clay, #c87a53);
    outline-offset: 2px;
}

/* Audio variant: slightly smaller circle to match the square album cover */
.audio-play-overlay .play-circle {
    width: 60px;
    height: 60px;
}

/* Video variant: slightly larger circle to match the 16:9 cinematic frame */
.video-play-overlay .play-circle {
    width: 64px;
    height: 64px;
}

/* --- Audio controls bar (slim bar attached to the cover) ---
   Hosts the native <audio> element directly below the gradient cover,
   inside the SAME .media-player-shell container — no separate stacked
   block with a title between them anymore. */
.audio-controls-bar {
    background: #1e293b; /* slate-800 — matches the shell bg */
    padding: 6px 8px 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.audio-controls-bar audio {
    width: 100%;
    /* Use a neutral filter so the default browser audio bar sits harmoniously
       on the dark slate bar instead of clashing with the gradient cover. */
    filter: none;
    border-radius: 6px;
}

/* ==========================================================================
   AUTO-HIDE OVERLAY WHEN MEDIA IS PLAYING
   --------------------------------------------------------------------------
   We use the modern :has() selector so the overlay fades out as soon as the
   underlying <audio>/<video> starts playing, and reappears when paused.
   No JavaScript state syncing required — keeping media-player.js untouched.
   ========================================================================== */
.media-player-shell:has(video:not(:paused)) .video-play-overlay,
.media-player-shell:has(audio:not(:paused)) .audio-play-overlay {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Hide the duration chip on the video cover while it is playing (the native
   video controls already show the elapsed / total time). The audio bar keeps
   its chip because the dark cover obscures the native audio time. */
.media-player-shell:has(video:not(:paused)) .media-duration-badge {
    opacity: 0;
}

/* ==========================================================================
   RESPONSIVE TWEAKS — keep the unified shell tidy on small screens
   ========================================================================== */
@media (max-width: 640px) {
    .media-play-overlay .play-circle,
    .audio-play-overlay .play-circle,
    .video-play-overlay .play-circle {
        width: 50px;
        height: 50px;
    }

    .media-play-overlay .play-circle svg {
        width: 22px;
        height: 22px;
    }

    .media-duration-badge {
        bottom: 8px;
        right: 8px;
        font-size: 10px;
        padding: 2px 7px;
    }

    [dir="rtl"] .media-duration-badge {
        right: auto;
        left: 8px;
    }
}

/* ==========================================================================
   REDUCED MOTION — stop the waveform animation when the user prefers
   reduced motion. (The existing animation is preserved for default users;
   this only adds a respect-rule for accessibility.)
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .media-play-overlay,
    .media-play-overlay .play-circle,
    .media-duration-badge {
        transition: none;
    }
}

/* ==========================================================================
   YOUTUBE LINK CARD — video entries (WhatsApp/Telegram-style link preview)
   --------------------------------------------------------------------------
   Videos are shared as YouTube LINKS, not files. The card shows:
     - YouTube's own thumbnail (hqdefault + object-cover = clean 16:9, the
       4:3 letterbox bars are cropped off) over a dark fallback gradient, so
       the card still looks intentional if the thumbnail fails to load;
     - a red YouTube-style play badge centered on top;
     - a light "link meta" strip underneath: favicon + youtube.com, the
       video title and the URL — the same trio a shared link shows in a
       WhatsApp/Telegram message.
   The whole card is one <a> to the exact YouTube URL (new tab), as is the
   "Watch on YouTube" button in the card footer.
   ========================================================================== */
.yt-link-card {
    display: block;
    text-decoration: none;
    color: inherit;
}

/* Fallback behind the <img>: a dark cinematic gradient, so a failed
   thumbnail reveals a pleasant placeholder instead of a broken image. */
.yt-thumb-wrap {
    overflow: hidden;
    background:
        linear-gradient(135deg, #1f2937 0%, #0f172a 55%, #4c1d1d 100%);
}

.yt-thumb {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* crops hqdefault's letterbox bars → clean 16:9 */
    transition: transform 0.35s ease;
}

.yt-link-card:hover .yt-thumb {
    transform: scale(1.04);
}

/* Red rounded-rect play badge (the YouTube logo shape, not a circle) */
.yt-play-badge {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 62px;
    height: 44px;
    border-radius: 10px;
    background: rgba(224, 30, 30, 0.92);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    z-index: 5;
    pointer-events: none;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
                background-color 0.25s ease;
}

.yt-play-badge svg {
    width: 26px;
    height: 26px;
    margin-left: 3px; /* optical centering of the triangle */
}

.yt-link-card:hover .yt-play-badge {
    transform: scale(1.08);
    background: #e01e1e;
}

/* Chat-style link meta strip under the thumbnail */
.yt-link-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 12px 12px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.yt-link-favicon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.02em;
    color: #64748b;
}

.yt-link-favicon svg {
    width: 14px;
    height: 14px;
    color: #f0281e; /* YouTube red */
    flex-shrink: 0;
}

.yt-link-title {
    display: block;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    color: #0f172a;
    transition: color 0.2s ease;
}

.yt-link-url {
    font-size: 10px;
    color: #94a3b8;
    word-break: break-all;
}

.yt-link-card:hover .yt-link-title {
    color: var(--color-teal-dark, #33625a);
}

.yt-link-card:focus-visible {
    outline: 2px solid var(--color-clay, #c87a53);
    outline-offset: 2px;
    border-radius: 12px;
}

/* Keep the duration chip legible above the thumbnail */
.yt-thumb-wrap .media-duration-badge {
    z-index: 6;
}

[dir="rtl"] .yt-link-meta {
    text-align: right;
}

/* Respect reduced motion for the link-card hover effects too */
@media (prefers-reduced-motion: reduce) {
    .yt-thumb,
    .yt-play-badge {
        transition: none;
    }
}