/* ========================================
   ZianTT Live Page
   Special Thanks to @HydrogenE7
   ======================================== */

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/jetbrains-mono-400.ttf) format('truetype');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(fonts/jetbrains-mono-500.ttf) format('truetype');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(fonts/jetbrains-mono-600.ttf) format('truetype');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url(fonts/space-grotesk-300.ttf) format('truetype');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/space-grotesk-400.ttf) format('truetype');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(fonts/space-grotesk-500.ttf) format('truetype');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(fonts/space-grotesk-600.ttf) format('truetype');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(fonts/space-grotesk-700.ttf) format('truetype');
}

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

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-tertiary: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-tertiary: #666666;
    --accent: #00d9ff;
    --accent-hover: #00b8d9;
    --primary: #6366f1;
    --secondary: #8b5cf6;
    --border: rgba(255, 255, 255, 0.1);
    --shadow: rgba(0, 0, 0, 0.5);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.live-text {
    color: var(--text-primary);
    font-weight: 500;
}

/* Stream Modal */
.stream-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.stream-modal-container {
    /* Approx fixed vertical cost: header + content paddings, used to keep 16:9 without scroll */
    --stream-modal-fixed: 160px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    max-width: 1200px;
    /* Auto-size modal to player (no blank area), but never exceed viewport */
    width: min(90vw, 1200px, calc(max(0px, 90vh - var(--stream-modal-fixed)) * 1.77778));
    height: auto;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalFadeIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

.stream-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.stream-modal-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Space Grotesk', sans-serif;
    margin: 0;
}

.stream-modal-content {
    position: relative;
    width: 100%;
    padding: 24px;
    background: var(--bg-primary);
    overflow: hidden; /* no scrolling; modal fits to player */
}

.stream-player-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9; /* keep 16:9 for both WebRTC + FLV */
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.stream-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    outline: none;
    object-fit: contain;
    display: block; /* avoid baseline gaps / sizing quirks */
}


.stream-source-selector {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    display: flex;
    gap: 8px;
}

.source-select {
    background: rgba(10, 10, 10, 0.9);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    min-width: 120px;
}

.source-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 217, 255, 0.2);
}

.source-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 8px;
}

/* xgplayer FLV container: keep 16:9 and fill modal width */
#flvPlayerContainer {
    /* inherits absolute fill from .stream-video */
    width: 100% !important;
    height: 100%;
    line-height: 0; /* prevent inline baseline gaps affecting layout */
}

#flvPlayerContainer.xgplayer,
#flvPlayerContainer.xgplayer-container {
    width: 100% !important;
    max-width: 100% !important;
}

#flvPlayerContainer > .xgplayer,
#flvPlayerContainer > .xgplayer-container,
#flvPlayerContainer .xgplayer,
#flvPlayerContainer .xgplayer-container {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
}

/* If xgplayer mounts directly onto #flvPlayerContainer, ensure its internal root fills */
#flvPlayerContainer.xgplayer > .xgplayer-container,
#flvPlayerContainer.xgplayer > .xgplayer-inner,
#flvPlayerContainer.xgplayer-container > .xgplayer-inner {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
}

#flvPlayerContainer .xgplayer video,
#flvPlayerContainer.xgplayer video,
#flvPlayerContainer.xgplayer-container video,
#flvPlayerContainer video,
#flvPlayerContainer .xgplayer-video {
    display: block;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

.stream-status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 16px 44px 16px 24px; /* extra space for the close button */
    background: rgba(10, 10, 10, 0.9);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    font-weight: 500;
    z-index: 10;
}

.stream-status-text {
    color: var(--text-secondary);
}

.stream-status-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.stream-status-close:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border);
    color: var(--text-primary);
}

/* Responsive adjustments for stream player */
@media (max-width: 768px) {
    .stream-modal-container {
        --stream-modal-fixed: 140px;
        width: min(95vw, 1200px, calc(max(0px, 90vh - var(--stream-modal-fixed)) * 1.77778));
        max-width: 100%;
        margin: 10px;
    }

    .stream-modal-header {
        padding: 16px 20px;
    }

    .stream-modal-content {
        padding: 16px;
    }

    /* Keep 16:9 on mobile too (container drives sizing) */

    .live-indicator {
        font-size: 12px;
        padding: 6px 12px;
    }

    .live-dot {
        width: 6px;
        height: 6px;
    }

    .stream-source-btn {
        min-width: 70px;
        padding: 8px 12px !important;
        font-size: 13px;
    }

    .stream-source-text {
        font-size: 12px;
    }

    .source-select {
        min-width: 100px;
        font-size: 13px;
        padding: 6px 10px;
    }
}
