/*
 * assets/site.css
 *
 * Shared layout and component styles for:
 * - index.php stream directory
 * - watch.php individual player page
 * - error pages
 */

/* ================================================================
   Theme variables and global defaults
   ================================================================ */
:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #18212b;
    --muted: #5f6d7a;
    --line: #d9e0e6;
    --brand: #123f68;
    --brand-dark: #0b2c49;
    --accent: #bd2c36;
    --online: #16834a;
    --offline: #9b2730;
    --shadow: 0 10px 30px rgba(18, 42, 63, .09);
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: light;
}

body {
    margin: 0;
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

a {
    color: inherit;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

[hidden] {
    display: none !important;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin-inline: auto;
}

/* ================================================================
   Main directory-page header
   ================================================================ */
.site-header {
    color: white;
    background: linear-gradient(120deg, var(--brand-dark), var(--brand));
    border-bottom: 5px solid var(--accent);
}

.header-inner {
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    padding-block: 42px;
}

.eyebrow {
    margin: 0 0 8px;
    font-size: .77rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: inherit;
    opacity: .76;
}

h1 {
    margin-bottom: 8px;
    font-size: clamp(2rem, 5vw, 3.7rem);
    line-height: 1.04;
    letter-spacing: -.035em;
}

.subtitle {
    max-width: 690px;
    margin-bottom: 0;
    font-size: clamp(1rem, 2vw, 1.2rem);
    color: #dbe9f4;
}

.live-key {
    display: flex;
    align-items: center;
    gap: 9px;
    flex: none;
    padding: 9px 13px;
    font-weight: 750;
    font-size: .88rem;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 999px;
}

.live-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff5b64;
    box-shadow: 0 0 0 5px rgba(255, 91, 100, .18);
}

/* ================================================================
   Notices and section headings
   ================================================================ */
.notice {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    margin: 28px 0;
    padding: 18px 20px;
    background: #edf4fa;
    border: 1px solid #ccdeec;
    border-left: 5px solid var(--brand);
    border-radius: 8px;
}

.notice strong {
    flex: none;
}

.notice span {
    color: #455868;
}

.notice.compact {
    margin-top: 20px;
}

.stream-section {
    margin: 38px 0 50px;
}

.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.section-heading h2 {
    margin-bottom: 11px;
    font-size: 1.45rem;
}

.section-heading > span {
    font-size: .86rem;
    color: var(--muted);
}

/* ================================================================
   Stream directory cards and thumbnails
   ================================================================ */
.stream-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.stream-card {
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.stream-card.featured {
    grid-column: span 1;
}

.preview {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    color: white;
    text-decoration: none;
    background: linear-gradient(145deg, #203346, #0e1924);
}

.preview.is-disabled {
    cursor: default;
}

.stream-thumbnail {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    opacity: 0;
    object-fit: cover;
    transition: opacity .18s ease, transform .25s ease;
}

.stream-thumbnail.is-loaded {
    opacity: 1;
}

.preview:not(.is-disabled):hover .stream-thumbnail.is-loaded {
    transform: scale(1.025);
}

.stream-card.is-offline .stream-thumbnail {
    filter: grayscale(.45) brightness(.72);
}

.preview-placeholder {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 10px;
    color: #d9e5ee;
}

.preview-placeholder.is-hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.camera-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    padding-left: 4px;
    border: 1px solid rgba(255, 255, 255, .34);
    border-radius: 50%;
    background: rgba(255, 255, 255, .1);
}

.preview-placeholder span:last-child {
    font-size: .87rem;
    font-weight: 700;
}

/* LIVE, OFFLINE, and CONNECTING status pills. */
.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    font-size: .73rem;
    font-weight: 850;
    letter-spacing: .04em;
    text-transform: uppercase;
    border-radius: 999px;
}

.preview > .status {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 3;
    color: white;
    backdrop-filter: blur(5px);
}

.status-checking {
    background: rgba(92, 104, 116, .9);
}

.status-online {
    background: rgba(22, 131, 74, .96);
}

.status-offline {
    background: rgba(155, 39, 48, .96);
}

.preview-label {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 3;
    padding: 5px 8px;
    color: white;
    background: rgba(4, 18, 31, .74);
    border-radius: 5px;
    font-size: .68rem;
    font-weight: 700;
}

.card-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 17px;
}

.card-body h3 {
    margin-bottom: 3px;
    font-size: 1rem;
    line-height: 1.25;
}

.card-body p {
    margin-bottom: 0;
    font-size: .84rem;
    color: var(--muted);
}

.card-body .preview-time {
    margin-top: 5px;
    font-size: .7rem;
}

.watch-link {
    flex: none;
    color: var(--brand);
    font-size: .87rem;
    font-weight: 800;
    text-decoration: none;
}

.offline-label {
    flex: none;
    color: var(--offline);
    font-size: .8rem;
    font-weight: 800;
}

.status-summary {
    color: var(--muted);
}

/* ================================================================
   Shared footer
   ================================================================ */
.site-footer {
    margin-top: 60px;
    color: #cbd9e5;
    background: #13283b;
}

.footer-inner {
    min-height: 90px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    font-size: .85rem;
}

/* ================================================================
   Watch-page heading and navigation
   ================================================================ */
.compact-header {
    color: white;
    background: var(--brand-dark);
    border-bottom: 4px solid var(--accent);
}

.compact-header-inner {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    font-weight: 850;
    text-decoration: none;
}

.back-link {
    color: #d9e7f2;
    font-size: .9rem;
    text-decoration: none;
}

.watch-main {
    padding-block: 34px 60px;
}

.watch-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.watch-heading h1 {
    margin: 0;
    font-size: clamp(1.7rem, 4vw, 2.7rem);
}

.watch-heading .eyebrow {
    color: var(--brand);
    opacity: 1;
}

.player-status {
    color: white;
    margin-bottom: 6px;
}

/* ================================================================
   Video player
   ================================================================ */
.player-shell {
    overflow: hidden;
    background: #071019;
    border: 1px solid #1e3344;
    border-radius: 11px;
    box-shadow: var(--shadow);
}

.video-stage {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 16 / 9;
    background: #05090d;
}

/*
 * The video begins transparent so the CONNECTING panel is the only visible
 * startup state. It fades in after loadeddata/canplay/playing fires.
 */
.video-stage video {
    display: block;
    width: 100%;
    height: 100%;
    opacity: 0;
    background: #05090d;
    object-fit: contain;
    transition: opacity .2s ease;
}

.video-stage video.is-ready {
    opacity: 1;
}

/*
 * Messages fill the video stage. The offline artwork is applied only to the
 * actual offline message, so it cannot flash during normal startup.
 */
.player-message {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 8px;
    padding: 24px;
    text-align: center;
    color: white;
    background: #06111b;
}

.player-message span {
    max-width: 520px;
    color: #bbc9d4;
}

.offline-message {
    background:
        linear-gradient(rgba(4, 10, 15, .88), rgba(4, 10, 15, .88)),
        url('/assets/offline.svg') center / contain no-repeat,
        #06111b;
}

.loading-spinner {
    width: 34px;
    height: 34px;
    margin-bottom: 8px;
    border: 4px solid rgba(255, 255, 255, .25);
    border-top-color: white;
    border-radius: 50%;
    animation: player-spin .85s linear infinite;
}

@keyframes player-spin {
    to {
        transform: rotate(360deg);
    }
}

/*
 * Custom video-only toolbar. Native controls are not used because browsers do
 * not offer a reliable standards-based way to remove only the audio control.
 */
.player-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: #c4d0da;
    background: #10202d;
}

.player-control-note {
    flex: 1;
    font-size: .82rem;
}

button,
.button {
    padding: 9px 14px;
    font: inherit;
    font-weight: 800;
    color: white;
    background: var(--brand);
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
}

.player-controls button {
    padding: 7px 11px;
    font-size: .8rem;
    background: #29455b;
}

/* ================================================================
   Other-stream links and error page
   ================================================================ */
.other-streams {
    margin-top: 38px;
}

.mini-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.mini-grid a {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px;
    color: var(--brand-dark);
    background: white;
    border: 1px solid var(--line);
    border-radius: 7px;
    font-size: .9rem;
    font-weight: 700;
    text-decoration: none;
}

.error-panel {
    max-width: 680px;
    margin: 70px auto;
    padding: 38px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.error-panel .eyebrow {
    color: var(--accent);
    opacity: 1;
}

.error-panel h1 {
    font-size: 2.4rem;
}

/* ================================================================
   Responsive layout
   ================================================================ */
@media (max-width: 900px) {
    .stream-grid,
    .mini-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 620px) {
    .shell {
        width: min(100% - 22px, 1180px);
    }

    .header-inner {
        min-height: 190px;
        align-items: flex-start;
        flex-direction: column;
        justify-content: center;
    }

    .live-key {
        align-self: flex-start;
    }

    .notice {
        flex-direction: column;
        gap: 5px;
    }

    .stream-grid,
    .mini-grid {
        grid-template-columns: 1fr;
    }

    .footer-inner,
    .watch-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .player-controls {
        flex-wrap: wrap;
    }

    .player-control-note {
        order: 3;
        flex-basis: 100%;
    }

    .player-controls button {
        flex: 1;
    }
}
