/* RoadShield — Video Wall (big-screen tiled view) */

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: #000;
    color: #fff;
    font-family: 'Inter', system-ui, sans-serif;
}

body.vw-idle { cursor: none; }

/* Touch screen: no text selection, callouts or browser pan/zoom gestures */
.vw {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.vw-stage, .vw-ptz { touch-action: none; }

.vw {
    position: relative;
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* Faint logo behind everything — visible wherever no video is playing */
.vw::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('../images/roadshield-logo.png') center / min(40vw, 60vh) no-repeat;
    opacity: .07;
    pointer-events: none;
}

/* ── Tiles grid ─────────────────────────────────────────────── */
.vw-grid {
    position: relative;
    flex: 1 1 100%;
    display: grid;
    /* columns/rows (and the stage's span when open) are set by wall.js */
    grid-template-columns: repeat(var(--cols, 1), 1fr);
    grid-template-rows: repeat(var(--rows, 1), 1fr);
    min-width: 0;
}

.vw-tile {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    animation: vw-in .5s ease-out both;
    animation-delay: calc(var(--i) * 40ms);
}

.vw-tile video,
.vw-stage video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.vw-tile video { transition: transform .4s ease; }
@media (hover: hover) {
    .vw-tile:hover video { transform: scale(1.03); }
}

/* The opened camera lives in the stage, so its tile steps out of the grid */
.vw-tile.active { display: none; }

/* ── Expanded view (top center; tiles flow left, right, then below) ── */
.vw-stage {
    position: relative;
    display: none;
    overflow: hidden;
    cursor: pointer;
    grid-column: var(--stage-col) / span var(--stage-cols);
    grid-row: 1 / span var(--stage-rows);
}

.vw.open .vw-stage { display: block; }

.vw-stage video { object-fit: contain; }

/* ── PTZ controls on the big view ───────────────────────────── */
.vw-stage.ptz { cursor: crosshair; }

.vw-ptz {
    --u: clamp(10px, .75vw, 26px);
    position: absolute;
    right: calc(var(--u) * 1.6);
    bottom: calc(var(--u) * 1.6);
    display: none;
    align-items: flex-end;
    gap: calc(var(--u) * 1.2);
    cursor: default;
    transition: opacity .25s ease, transform .25s ease;
}

.vw-stage.ptz .vw-ptz { display: flex; }
.vw-stage.controls-off .vw-ptz { opacity: 0; transform: translateY(8px); pointer-events: none; }

.vw-pad,
.vw-zoom {
    background: rgba(12, 12, 12, .38);
    border: 1px solid rgba(255, 255, 255, .16);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
}

.vw-ptz button {
    appearance: none;
    border: 0;
    padding: 0;
    background: none;
    color: rgba(255, 255, 255, .85);
    cursor: pointer;
    font: inherit;
}

/* Round direction pad */
.vw-pad {
    position: relative;
    width: calc(var(--u) * 11);
    height: calc(var(--u) * 11);
    border-radius: 50%;
}

.vw-pad-btn {
    position: absolute;
    width: 34%;
    height: 34%;
    border-radius: 50%;
    transition: background .15s ease;
}

.vw-pad-btn::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 26%;
    height: 26%;
    border: solid currentColor;
    border-width: 2px 2px 0 0;
    transform: translate(-50%, -30%) rotate(-45deg);
}

.vw-pad-btn.up    { top: 2%;    left: 33%; }
.vw-pad-btn.down  { bottom: 2%; left: 33%; }
.vw-pad-btn.left  { left: 2%;   top: 33%; }
.vw-pad-btn.right { right: 2%;  top: 33%; }
.vw-pad-btn.right::before { transform: translate(-70%, -50%) rotate(45deg); }
.vw-pad-btn.down::before  { transform: translate(-50%, -70%) rotate(135deg); }
.vw-pad-btn.left::before  { transform: translate(-30%, -50%) rotate(-135deg); }

.vw-pad-btn:hover,
.vw-pad-btn.pressed { background: rgba(255, 255, 255, .14); }

.vw-pad-home {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 22%;
    height: 22%;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 1.5px solid rgba(255, 255, 255, .5) !important;
    transition: background .15s ease;
}
.vw-pad-home:hover { background: rgba(255, 255, 255, .14); }

/* Zoom 1–25×: number buttons beside a vertical slider */
.vw-zoom {
    display: flex;
    align-items: stretch;
    gap: calc(var(--u) * .4);
    padding: calc(var(--u) * .6);
    border-radius: calc(var(--u) * 1.6);
}

.vw-zoom-presets,
.vw-zoom-slider {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(var(--u) * .35);
}

.vw-zoom-preset {
    min-width: calc(var(--u) * 3.6);
    height: calc(var(--u) * 2.8);
    padding: 0 calc(var(--u) * .5) !important;
    border-radius: calc(var(--u) * 1.4);
    font-size: var(--u) !important;
    font-weight: 500 !important;
    font-variant-numeric: tabular-nums;
    transition: background .15s ease, color .15s ease;
}
.vw-zoom-preset:hover { background: rgba(255, 255, 255, .14) !important; }
.vw-zoom-preset.active { background: rgba(255, 255, 255, .9) !important; color: #000 !important; }

.vw-zoom-step {
    width: calc(var(--u) * 2.6);
    height: calc(var(--u) * 2.6);
    border-radius: 50%;
    font-size: calc(var(--u) * 1.6) !important;
    line-height: 1;
    transition: background .15s ease;
}
.vw-zoom-step:hover { background: rgba(255, 255, 255, .14) !important; }

.vw-zoom-range {
    writing-mode: vertical-lr;
    direction: rtl;          /* max (25×) at the top */
    flex: 1;
    width: calc(var(--u) * 1.6);
    min-height: calc(var(--u) * 8);
    margin: 0;
    accent-color: #fff;
    cursor: pointer;
}

.vw-zoom-value {
    min-width: calc(var(--u) * 2.8);
    text-align: center;
    font-size: var(--u);
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, .8);
}

/* Box drawn to zoom into an area */
.vw-box {
    position: absolute;
    border: 1.5px dashed rgba(255, 255, 255, .9);
    background: rgba(255, 255, 255, .08);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, .25);
    pointer-events: none;
}

/* ── The one label per video ────────────────────────────────── */
.vw-label {
    position: absolute;
    top: .6em;
    left: .8em;
    font-size: clamp(11px, .7vw, 22px);
    font-weight: 500;
    letter-spacing: .02em;
    color: rgba(255, 255, 255, .78);
    text-shadow: 0 1px 3px rgba(0, 0, 0, .9);
    pointer-events: none;
    white-space: nowrap;
}

.vw-stage .vw-label { font-size: clamp(13px, .95vw, 28px); }

/* Faint shimmer while a stream is connecting */
.vw-tile.loading::before,
.vw-stage.loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .05) 50%, transparent 70%);
    background-size: 200% 100%;
    animation: vw-shimmer 1.6s linear infinite;
    pointer-events: none;
}

@keyframes vw-in {
    from { opacity: 0; transform: scale(.96); }
    to   { opacity: 1; transform: none; }
}

@keyframes vw-shimmer {
    from { background-position: 150% 0; }
    to   { background-position: -50% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .vw-tile, .vw-tile video { animation: none; transition: none; }
}
