/* RailShot TV — Live Tables page */

.live-page {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.live-main {
    padding: 0.75rem 0 0.75rem;
}

.live-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.live-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}

.live-eyebrow {
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.15rem;
}

.live-title {
    font-size: clamp(1.1rem, 2.5vw, 1.6rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.live-status {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.95rem;
    border-radius: 999px;
    background: rgba(26, 31, 46, 0.9);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.9rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.live-status-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.live-status.is-live .live-status-dot {
    background: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    animation: live-pulse 1.6s infinite;
}

.live-status.is-connecting .live-status-dot {
    background: var(--accent);
    animation: live-pulse 1.2s infinite;
}

.live-status.is-error .live-status-dot {
    background: var(--accent-orange);
}

@keyframes live-pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.live-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: var(--spacing-lg);
    align-items: start;
}

.shadow-pop {
    background: linear-gradient(180deg, rgba(42, 49, 66, 0.85), rgba(26, 31, 46, 0.95));
    border: 1px solid rgba(0, 168, 232, 0.25);
    border-radius: var(--radius-lg);
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(255, 255, 255, 0.03) inset,
        0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

.live-layout.viewer-locked {
    grid-template-columns: minmax(0, 1fr);
}

.live-layout.viewer-locked .table-panel {
    display: none;
}

.video-panel {
    overflow: hidden;
    min-width: 0;
    width: 100%;
}

.video-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    /* Cap height so the controls bar + footer stay visible without scrolling.
       Header ~4.5rem + admin bar ~2.5rem + page padding ~1.5rem + meta bar ~2.5rem + footer ~2rem = ~13rem */
    max-height: calc(100dvh - 13rem);
    background: #000;
    overflow: hidden;
}

.video-wrapper video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center center;
    background: #000;
}

.video-wrapper.is-fit-full video {
    object-fit: contain;
}

.video-view-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: auto;
    padding: 0.2rem;
    border-radius: 999px;
    background: rgba(10, 14, 26, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.video-view-label {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0 0.35rem 0 0.5rem;
}

.video-view-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.video-view-btn:hover {
    color: var(--text);
}

.video-view-btn.active {
    background: rgba(0, 168, 232, 0.22);
    color: var(--primary);
    box-shadow: inset 0 0 0 1px rgba(0, 168, 232, 0.35);
}

.video-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(5, 8, 16, 0.72);
    color: var(--text);
    text-align: center;
    padding: var(--spacing-md);
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.video-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.overlay-spinner {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
}

.overlay-spinner.is-idle {
    animation: none;
    border-top-color: rgba(255, 255, 255, 0.35);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   SCOREBOARD OVERLAY IFRAME
   ============================================================ */

.scoreboard-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    /* Height is intentionally generous so the widget inside isn't clipped.
       Scoreholio widget-a is roughly 120px tall; transparent background
       means the empty space above it is invisible. */
    height: 160px;
    pointer-events: none;   /* let clicks pass through to the video controls */
    background: transparent;
    border: none;
    z-index: 20;
    transition: opacity 0.4s ease;
}

.scoreboard-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    /* keep it in the DOM so the iframe src stays loaded */
    visibility: hidden;
}

/* ============================================================
   Retry button shown when stream is offline */
.overlay-retry-btn {
    margin-top: 0.5rem;
    padding: 0.6rem 1.6rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.03em;
    transition: background 0.2s ease, transform 0.15s ease;
    box-shadow: 0 4px 16px rgba(0, 168, 232, 0.35);
}

.overlay-retry-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.video-meta {
    padding: 0.55rem 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.75rem;
}

.video-meta h2 {
    font-size: 1rem;
    font-weight: 700;
}

.video-meta-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.protocol-badge {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--primary);
    background: rgba(0, 168, 232, 0.12);
    border: 1px solid rgba(0, 168, 232, 0.35);
    border-radius: 999px;
    padding: 0.25rem 0.65rem;
}

.protocol-badge.hidden {
    display: none;
}

.table-panel {
    padding: var(--spacing-md);
    position: sticky;
    top: 5.5rem;
}

.table-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
}

.table-panel-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.table-count {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.table-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    max-height: min(60vh, 520px);
    overflow-y: auto;
    padding-right: 0.15rem;
}

.table-item {
    width: 100%;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(10, 14, 26, 0.55);
    color: var(--text);
    border-radius: var(--radius-md);
    padding: 0.85rem 0.95rem;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.table-item:hover {
    transform: translateY(-1px);
    border-color: rgba(0, 168, 232, 0.45);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.table-item.active {
    background: linear-gradient(135deg, rgba(0, 168, 232, 0.28), rgba(0, 119, 182, 0.18));
    border-color: rgba(0, 168, 232, 0.7);
    box-shadow: 0 12px 28px rgba(0, 168, 232, 0.2);
}

.table-item-name {
    display: block;
    font-weight: 700;
    margin-bottom: 0.15rem;
}

.table-item-desc {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.table-panel-hint {
    margin-top: var(--spacing-md);
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.4;
}

.table-panel-hint code {
    color: var(--accent);
    font-size: 0.72rem;
}

.live-footer {
    margin-top: 0;
    padding: 0 !important;  /* override global .footer padding */
}

.live-footer .footer-bottom {
    border-top: 1px solid var(--border);
    padding: 0.45rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* Live landing page */
.live-landing-page .live-main {
    padding-top: var(--spacing-xl);
}

.live-landing-hero {
    padding: var(--spacing-xl) var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
    text-align: center;
}

.live-landing-subtitle {
    max-width: 42rem;
    margin: 0.75rem auto 0;
    color: var(--text-muted);
    font-size: 1.05rem;
    line-height: 1.65;
}

.live-landing-bullets {
    list-style: none;
    margin: var(--spacing-lg) auto 0;
    padding: 0;
    max-width: 36rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    text-align: left;
}

.live-landing-bullets li {
    position: relative;
    padding-left: 1.35rem;
    color: var(--text);
}

.live-landing-bullets li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.55rem;
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 10px rgba(0, 168, 232, 0.65);
}

.live-venues-section {
    margin-bottom: var(--spacing-2xl);
}

.live-venues-header {
    margin-bottom: var(--spacing-lg);
}

.live-venues-title {
    font-size: clamp(1.35rem, 3vw, 1.85rem);
    font-weight: 800;
    margin-bottom: 0.35rem;
}

.live-venues-desc {
    color: var(--text-muted);
}

.live-venues-empty {
    text-align: center;
    color: var(--text-muted);
    padding: var(--spacing-xl);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
}

.live-venues-empty.hidden {
    display: none;
}

.venue-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--spacing-lg);
}

.venue-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.venue-card:hover {
    transform: translateY(-4px);
    border-color: rgba(0, 168, 232, 0.55);
    box-shadow: 0 28px 64px rgba(0, 168, 232, 0.15);
}

.venue-card-image-wrap {
    position: relative;
    aspect-ratio: 16 / 10;
    background:
        linear-gradient(135deg, rgba(10, 14, 26, 0.9) 0%, rgba(26, 31, 46, 0.95) 100%),
        repeating-linear-gradient(
            45deg,
            rgba(0, 168, 232, 0.04) 0px,
            rgba(0, 168, 232, 0.04) 1px,
            transparent 1px,
            transparent 12px
        );
    overflow: hidden;
}

.venue-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.venue-card-live,
.venue-card-offline {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.venue-card-live {
    background: rgba(239, 68, 68, 0.92);
    color: #fff;
}

.venue-card-live-dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: #fff;
    animation: live-pulse 1.6s infinite;
}

.venue-card-offline {
    background: rgba(26, 31, 46, 0.88);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.venue-card-body {
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
}

.venue-card-name {
    font-size: 1.15rem;
    font-weight: 800;
}

.venue-card-location {
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 600;
}

.venue-card-desc {
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.5;
    flex: 1;
}

.venue-card-meta {
    margin-top: 0.5rem;
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 700;
}

.live-back-link {
    display: inline-block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.live-back-link:hover {
    color: var(--primary);
}

@media (max-width: 900px) {
    .live-layout {
        grid-template-columns: 1fr;
    }

    .table-panel {
        position: static;
        order: 2;
    }

    .table-list {
        max-height: none;
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

@media (max-width: 600px) {
    .live-main {
        padding-top: var(--spacing-md);
    }

    .video-meta {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .protocol-badge {
        margin-left: 0;
    }

    .video-view-controls {
        margin-left: 0;
        width: 100%;
        justify-content: flex-end;
    }
}

/* ── Admin Table Switcher (watch page, admin-only) ─────────────────────────── */
.admin-table-switcher {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: rgba(0, 168, 232, 0.08);
    border: 1px solid rgba(0, 168, 232, 0.35);
    border-radius: 10px;
    padding: 10px 16px;
    margin-bottom: 14px;
}

.admin-table-switcher.hidden {
    display: none !important;
}

.admin-switcher-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #a0b4c0;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
}

.admin-switcher-badge {
    background: #00A8E8;
    color: #000;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-switcher-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-switcher-btn {
    background: rgba(255,255,255,0.06);
    color: #cdd6e0;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.admin-switcher-btn:hover {
    background: rgba(0, 168, 232, 0.18);
    border-color: #00A8E8;
    color: #fff;
}

.admin-switcher-btn.active {
    background: #00A8E8;
    border-color: #00A8E8;
    color: #000;
    font-weight: 600;
}

.admin-switcher-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.admin-switcher-status {
    font-size: 0.78rem;
    color: #7fa8b8;
    margin-left: auto;
}

.admin-switcher-stop {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.45);
    color: #f87171;
}

.admin-switcher-stop:hover {
    background: rgba(239, 68, 68, 0.28);
    border-color: #ef4444;
    color: #fff;
}

.admin-switcher-stop.hidden {
    display: none !important;
}

/* ── YouTube Live iframe player ─────────────────────────────────────────────── */
/* The wrapper is 16/9 aspect-ratio so the iframe fills it exactly.
   We override the wrapper's max-height when a YouTube iframe is present
   so the video never gets letterboxed by a height cap. */
.yt-live-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: #000;
    z-index: 1;
    display: block;
}

/* When a YouTube iframe is active, let the wrapper grow to its natural 16/9
   height instead of being capped — this eliminates the side black bars. */
.video-wrapper:has(.yt-live-iframe) {
    max-height: none;
}

/* ── Fullscreen mode: video-wrapper fills screen, overlay stays on top ─────── */
.video-wrapper:fullscreen,
.video-wrapper:-webkit-full-screen,
.video-wrapper:-moz-full-screen,
.video-wrapper:-ms-fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-wrapper:fullscreen .yt-live-iframe,
.video-wrapper:-webkit-full-screen .yt-live-iframe,
.video-wrapper:-moz-full-screen .yt-live-iframe,
.video-wrapper:-ms-fullscreen .yt-live-iframe {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
}

.video-wrapper:fullscreen .scoreboard-overlay,
.video-wrapper:-webkit-full-screen .scoreboard-overlay,
.video-wrapper:-moz-full-screen .scoreboard-overlay,
.video-wrapper:-ms-fullscreen .scoreboard-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100% !important;
    height: auto;
    z-index: 10;
    pointer-events: none;
}
