/*
Theme Name: Endoscopy WebGL
Theme URI: https://example.com/endoscopy-webgl
Author: StartSmart
Description: Dedicated full-screen WordPress theme for the Endoscopy WebGL spectator app.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 7.4
Text Domain: endoscopy-webgl
*/

:root {
    --bg-deep: #071a23;
    --bg-mid: #0c2b36;
    --panel: rgba(4, 18, 24, 0.76);
    --line: rgba(234, 247, 252, 0.2);
    --text-main: #edf7fb;
    --text-muted: #a9c2cb;
    --accent: #1ec8a2;
    --accent-warm: #f3b64d;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body.endoscopy-webgl-theme {
    font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
    color: var(--text-main);
    overflow: hidden;
    background:
        radial-gradient(1000px circle at 8% -12%, rgba(30, 200, 162, 0.27), transparent 56%),
        radial-gradient(880px circle at 92% 110%, rgba(243, 182, 77, 0.22), transparent 58%),
        linear-gradient(135deg, var(--bg-deep), var(--bg-mid));
}

.webgl-shell {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 12px;
    width: 100%;
    height: 100%;
    padding:
        calc(14px + env(safe-area-inset-top))
        calc(14px + env(safe-area-inset-right))
        calc(14px + env(safe-area-inset-bottom))
        calc(14px + env(safe-area-inset-left));
}

.webgl-header {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: baseline;
    justify-content: space-between;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    backdrop-filter: blur(4px);
}

.webgl-title {
    margin: 0;
    font-size: clamp(1.15rem, 2vw, 1.65rem);
    letter-spacing: 0.02em;
}

.webgl-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: clamp(0.84rem, 1.5vw, 1rem);
}

.webgl-stage {
    position: relative;
    min-height: 0;
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    background: #040f14;
}

#unity-canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.webgl-stage-ui {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 15;
    display: flex;
    gap: 8px;
}

.webgl-fullscreen-toggle {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    padding: 9px 14px;
    color: var(--text-main);
    background: rgba(4, 18, 24, 0.78);
    backdrop-filter: blur(5px);
    font: inherit;
    font-size: 0.84rem;
    cursor: pointer;
}

.webgl-fullscreen-toggle:hover,
.webgl-fullscreen-toggle:focus {
    border-color: rgba(30, 200, 162, 0.7);
    outline: none;
}

.webgl-fullscreen-toggle[hidden] {
    display: none;
}

.webgl-stage:fullscreen,
.webgl-stage:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    border: none;
    border-radius: 0;
}

.webgl-stage:fullscreen .webgl-stage-ui,
.webgl-stage:-webkit-full-screen .webgl-stage-ui {
    top: calc(12px + env(safe-area-inset-top));
    right: calc(12px + env(safe-area-inset-right));
}

.unity-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    gap: 10px;
    padding: 24px;
    background: linear-gradient(to bottom, rgba(3, 11, 15, 0.82), rgba(3, 11, 15, 0.93));
    text-align: center;
}

.unity-overlay.is-hidden {
    display: none;
}

.unity-status {
    margin: 0;
    color: var(--text-main);
    font-size: 0.95rem;
}

.unity-progress {
    width: min(360px, 76vw);
    height: 8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.unity-progress-fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-warm));
    transition: width 120ms linear;
}

.unity-warning {
    margin: 0;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 150, 150, 0.45);
    color: #ffd9d9;
    background: rgba(80, 17, 17, 0.5);
    font-size: 0.9rem;
}

.unity-warning[hidden] {
    display: none;
}

.webgl-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 0 4px;
}

.webgl-footer-copy {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}

.webgl-controls {
    color: var(--text-main);
}

.webgl-footer a {
    color: var(--accent);
    text-decoration: none;
}

.webgl-footer a:hover,
.webgl-footer a:focus {
    text-decoration: underline;
}

@media (max-width: 840px) {
    .webgl-shell {
        padding:
            calc(8px + env(safe-area-inset-top))
            calc(8px + env(safe-area-inset-right))
            calc(8px + env(safe-area-inset-bottom))
            calc(8px + env(safe-area-inset-left));
    }

    .webgl-header {
        padding: 12px;
    }

    .webgl-stage-ui {
        top: 8px;
        right: 8px;
    }

    .webgl-fullscreen-toggle {
        padding: 8px 12px;
        font-size: 0.78rem;
    }
}

@media (max-width: 840px) and (orientation: landscape) {
    body.endoscopy-webgl-theme.is-mobile-device {
        background: #040f14;
    }

    body.endoscopy-webgl-theme.is-mobile-device .webgl-shell {
        grid-template-rows: 1fr auto;
        gap: 0;
        padding: 0;
    }

    body.endoscopy-webgl-theme.is-mobile-device .webgl-header,
    body.endoscopy-webgl-theme.is-mobile-device .webgl-footer {
        display: none;
    }

    body.endoscopy-webgl-theme.is-mobile-device .webgl-stage {
        border: none;
        border-radius: 0;
    }

    body.endoscopy-webgl-theme.is-mobile-device .unity-warning {
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
    }
}
