/* Casa-Cleo Panomax-inspired UI
   Overlay for the current main player.css. No streaming, overlay-editor,
   statistics or camera-profile behaviour is replaced here. */

:root {
    --panorama-topbar-height: 58px;
    --panorama-bottombar-height: 50px;
    --panorama-bar-bg: rgba(24, 26, 28, .97);
    --panorama-bar-border: rgba(255,255,255,.10);
    --panorama-muted: rgba(255,255,255,.68);
    --panorama-accent: #a4cf12;
    --panorama-control-bg: rgba(24,26,28,.76);
}

html,
body {
    background: #34383b;
}

.player.panorama-layout {
    display: grid;
    grid-template-rows:
        var(--panorama-topbar-height)
        minmax(0, 1fr)
        var(--panorama-bottombar-height);
    width: 100%;
    height: 100dvh;
    background: #3b3f42;
}

/* The central change: the viewport is a stable grid row.
   Window-width changes no longer change its height. */
.panorama-layout .viewport {
    position: relative;
    inset: auto;
    grid-row: 2;
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    background: #3b3f42;
    overflow: hidden;
}

/* Fixed top status bar */
.panorama-layout .topbar {
    position: relative;
    inset: auto;
    grid-row: 1;
    z-index: 30;
    min-width: 0;
    height: var(--panorama-topbar-height);
    padding:
        max(8px, env(safe-area-inset-top))
        max(14px, env(safe-area-inset-right))
        8px
        max(14px, env(safe-area-inset-left));
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
    align-items: center;
    gap: 14px;
    background: var(--panorama-bar-bg);
    border-bottom: 1px solid var(--panorama-bar-border);
    pointer-events: auto;
}

.panorama-layout .brand-block {
    align-items: center;
    gap: 10px;
}

.panorama-layout .logo {
    width: 52px;
    max-height: 40px;
    filter: none;
}

.panorama-layout .live-line {
    font-size: 11px;
    text-shadow: none;
}

.panorama-layout .location-label {
    margin-top: 3px;
    font-size: 12px;
    color: var(--panorama-muted);
    text-shadow: none;
}

.panorama-layout .topbar-center {
    justify-self: center;
    min-width: 0;
}

.panorama-layout .topbar-title {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    color: rgba(255,255,255,.92);
}

.panorama-layout .status-block {
    justify-self: end;
    align-self: center;
    text-align: right;
    text-shadow: none;
}

.panorama-layout .clock {
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.panorama-layout .status {
    margin-top: 2px;
    font-size: 10px;
    color: var(--panorama-muted);
}

/* Fixed bottom status / extension bar */
.panorama-layout .controls {
    position: relative;
    inset: auto;
    left: auto;
    bottom: auto;
    grid-row: 3;
    transform: none;
    z-index: 30;
    width: 100%;
    max-width: none;
    height: var(--panorama-bottombar-height);
    padding:
        6px
        max(12px, env(safe-area-inset-right))
        max(6px, env(safe-area-inset-bottom))
        max(12px, env(safe-area-inset-left));
    border: 0;
    border-top: 1px solid var(--panorama-bar-border);
    border-radius: 0;
    background: var(--panorama-bar-bg);
    backdrop-filter: none;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
}

.panorama-layout .bottom-status,
.panorama-layout .bottom-center,
.panorama-layout .bottom-actions {
    display: flex;
    align-items: center;
}

.panorama-layout .bottom-status {
    justify-self: start;
    gap: 7px;
    color: var(--panorama-muted);
    font-size: 11px;
    font-weight: 700;
}

.panorama-layout .bottom-center {
    justify-self: center;
    font-size: 11px;
    font-weight: 700;
    color: rgba(255,255,255,.88);
}

.panorama-layout .bottom-actions {
    justify-self: end;
    gap: 5px;
}

.panorama-layout .bottom-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--panorama-accent);
    box-shadow: 0 0 0 4px rgba(164,207,18,.09);
}

.panorama-layout .controls button {
    min-height: 32px;
    padding: 5px 9px;
    border-color: transparent;
    background: transparent;
    font-size: 11px;
}

.panorama-layout .controls button:hover {
    border-color: rgba(255,255,255,.08);
    background: rgba(255,255,255,.07);
}

.panorama-layout .legacy-zoom-control {
    display: none;
}

/* Existing auto-hide remains installed, but bars intentionally stay fixed. */
.panorama-layout.chrome-hidden .topbar,
.panorama-layout.chrome-hidden .controls {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

/* Direction indicator */
.panorama-fixed-ui {
    user-select: none;
    z-index: 24;
}

.direction-indicator {
    position: absolute;
    top: 18px;
    right: 22px;
    width: 70px;
    height: 78px;
    display: grid;
    justify-items: center;
    pointer-events: none;
    /* bessere Lesbarkeit auf dunklem Hintergrund */
    filter: drop-shadow(0 0 8px rgba(255,255,255,.38)) drop-shadow(0 0 18px rgba(255,255,255,.20)) drop-shadow(0 2px 5px rgba(0,0,0,.42));
}

.direction-north {
    position: relative;
    z-index: 2;
    margin-bottom: -6px;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(24,26,28,.76);
    color: #fff;
    font-size: 10px;
    font-weight: 900;
}

.direction-ring {
    --compass-heading: 270deg;
    --compass-fov-start: -45deg;
    --compass-fov-size: 90deg;

    position: relative;
    width: 62px;
    height: 62px;
    border: 2px solid rgba(20,22,24,.55);
    border-radius: 50%;
    background: rgba(255,255,255,.10);
    display: grid;
    place-items: center;
    overflow: hidden;
}

/* Current visible horizontal field of view. */
.direction-ring::before {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background:
        conic-gradient(
            from var(--compass-fov-start),
            rgba(255,255,255,.23) 0deg var(--compass-fov-size),
            transparent var(--compass-fov-size) 360deg
        );
    transform: rotate(var(--compass-heading));
    transform-origin: 50% 50%;
    pointer-events: none;
}

/* Bright outer arc: same visible angle, Panomax-style. */
.direction-ring::after {
    content: "";
    position: absolute;
    inset: 1px;
    border-radius: 50%;
    background:
        conic-gradient(
            from var(--compass-fov-start),
            rgba(255,255,255,.88) 0deg var(--compass-fov-size),
            transparent var(--compass-fov-size) 360deg
        );
    transform: rotate(var(--compass-heading));
    transform-origin: 50% 50%;
    -webkit-mask:
        radial-gradient(
            farthest-side,
            transparent calc(100% - 4px),
            #000 calc(100% - 3px)
        );
    mask:
        radial-gradient(
            farthest-side,
            transparent calc(100% - 4px),
            #000 calc(100% - 3px)
        );
    pointer-events: none;
}

/* Fine compass needle. The existing text content is visually replaced. */
.direction-arrow {
    position: relative;
    z-index: 3;
    display: block;
    width: 34px;
    height: 34px;
    font-size: 0;
    color: transparent;
    transform-origin: 50% 50%;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.75));
}

.direction-arrow::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 3px;
    width: 15px;
    height: 28px;
    transform: translateX(-50%);
    background: rgba(255,255,255,.94);
    clip-path: polygon(
        50% 0%,
        58% 72%,
        50% 64%,
        42% 72%
    );
}

.direction-arrow::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 4px;
    height: 4px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(32,34,36,.95);
    box-shadow: 0 0 0 1px rgba(255,255,255,.75);
}

.side-zoom {
    position: absolute;
    top: 112px;
    right: 29px;
    width: 48px;
    /* vorher 255px: +/- näher an den Slider */
    height: 200px;
    display: grid;
    grid-template-rows: 32px minmax(100px, 1fr) 32px;
    justify-items: center;
    align-items: center;
    /* leichte weisse Wolke hinter der kompletten Zoomsteuerung */
    filter: drop-shadow(0 0 8px rgba(255,255,255,.35)) drop-shadow(0 0 16px rgba(255,255,255,.18));
}

.side-zoom-button {
    width: 29px;
    height: 29px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 50%;
    color: #fff;
    background: var(--panorama-control-bg);
    box-shadow: 0 2px 5px rgba(0,0,0,.30);
    cursor: pointer;
    font-size: 19px;
    line-height: 1;
}

.side-zoom-button:hover {
    background: rgba(35,38,41,.94);
}

.side-zoom-track {
    position: relative;
    width: 34px;
    height: 145px;
    display: block;
    cursor: pointer;
    touch-action: none;
    outline: none;
}

.side-zoom-track:focus-visible {
    outline: 2px solid rgba(255,255,255,.72);
    outline-offset: 3px;
    border-radius: 12px;
}

.side-zoom-rail {
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: 50%;
    width: 3px;
    transform: translateX(-50%);
    border-radius: 3px;
    background: rgba(20,22,24,.62);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.10);
    pointer-events: none;
}

.side-zoom-thumb {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255,255,255,.84);
    border-radius: 50%;
    background: #2e3235;
    box-shadow: 0 1px 5px rgba(0,0,0,.58);
    pointer-events: none;
    will-change: top;
}

/* Admin remains available without occupying the panorama controls. */
.panorama-layout .admin-login {
    right: 190px;
    bottom: 7px;
    z-index: 36;
    height: 34px;
    min-width: 34px;
    padding: 0 10px;
    border-radius: 7px;
    font-size: 11px;
}

/* Keep editor above the fixed bars. */
.panorama-layout .editor-panel {
    top: calc(var(--panorama-topbar-height) + 8px);
    right: 8px;
    max-height: calc(
        100% -
        var(--panorama-topbar-height) -
        var(--panorama-bottombar-height) -
        16px
    );
}

/* The splash/offline layer covers the viewport area visually while the fixed
   status bars remain structurally stable. */
.panorama-layout .splash-screen,
.panorama-layout .message-layer {
    top: var(--panorama-topbar-height);
    bottom: var(--panorama-bottombar-height);
    height: auto;
}

@media (max-width: 720px) {
    :root {
        --panorama-topbar-height: 52px;
        --panorama-bottombar-height: 46px;
    }

    .panorama-layout .topbar {
        grid-template-columns: 1fr auto;
        padding-left: 10px;
        padding-right: 10px;
    }

    .panorama-layout .topbar-center {
        display: none;
    }

    .panorama-layout .logo {
        width: 44px;
        max-height: 34px;
    }

    .panorama-layout .location-label {
        font-size: 10px;
    }

    .panorama-layout .status {
        display: none;
    }

    .panorama-layout .bottom-center {
        display: none;
    }

    .panorama-layout .controls {
        grid-template-columns: 1fr auto;
    }

    .panorama-layout .bottom-actions {
        grid-column: 2;
    }

    .panorama-layout .controls button {
        padding: 5px 7px;
    }

    .direction-indicator {
        top: 10px;
        right: 8px;
        transform: scale(.82);
        transform-origin: top right;
    }

    .side-zoom {
        top: 86px;
        right: 10px;
        transform: scale(.88);
        transform-origin: top right;
    }

    .panorama-layout .admin-login {
        right: auto;
        left: 8px;
        bottom: 6px;
    }
}

@media (max-height: 600px) {
    .direction-indicator {
        transform: scale(.78);
        transform-origin: top right;
    }

    .side-zoom {
        top: 82px;
        height: 205px;
        transform: scale(.82);
        transform-origin: top right;
    }

    .side-zoom-track {
        height: 110px;
    }
}


/* v9: Mobile / touch UI
   On phones the panorama is operated by touch gestures. The desktop compass
   and zoom controls only consume valuable image area, so hide them entirely. */
@media (max-width: 720px), (pointer: coarse) and (max-width: 1024px) {
    .direction-indicator,
    .side-zoom {
        display: none !important;
    }

    .panorama-layout .topbar {
        grid-template-columns: 1fr auto;
        min-height: var(--panorama-topbar-height);
    }

    .panorama-layout .topbar-center {
        display: none !important;
    }

    .panorama-layout .status-block {
        display: none !important;
    }

    .panorama-layout .controls {
        grid-template-columns: 1fr auto;
    }

    .panorama-layout .bottom-center {
        display: none !important;
    }

    .panorama-layout .bottom-actions {
        grid-column: 2;
    }

    .panorama-layout .bottom-actions #zoom-reset {
        display: none !important;
    }

    /* Let the viewer own the full middle area without extra overlays. */
    .panorama-layout .viewport {
        width: 100%;
        min-width: 0;
        overflow: hidden;
    }
}

/* Portrait phones: keep chrome compact and maximise panorama space. */
@media (max-width: 720px) and (orientation: portrait) {
    :root {
        --panorama-topbar-height: 58px;
        --panorama-bottombar-height: 48px;
    }

    .panorama-layout .topbar {
        padding-left: 10px;
        padding-right: 10px;
    }

    .panorama-layout .brand-block {
        gap: 8px;
    }

    .panorama-layout .logo {
        width: 52px;
        max-height: 38px;
    }

    .panorama-layout .live-line {
        font-size: 11px;
    }

    .panorama-layout .location-label {
        font-size: 10px;
        white-space: nowrap;
    }

    .panorama-layout .bottom-status {
        font-size: 10px;
    }

    .panorama-layout .controls button {
        min-height: 32px;
        padding: 5px 8px;
    }
}


/* v10: keep mobile preview/video aspect ratio even during startup.
   Once PanZoomController has calculated the media-layer size this is neutral,
   but it prevents the startup snapshot from being stretched to portrait. */
@media (max-width: 720px), (pointer: coarse) and (max-width: 1024px) {
    .panorama-layout video,
    .panorama-layout .startup-snapshot {
        object-fit: contain !important;
    }

    .panorama-layout .viewport {
        touch-action: none !important;
        -webkit-user-select: none;
        user-select: none;
    }
}
