/* ===================================================================
   /webcam-test - the camera viewfinder.

   Every number on the HUD is written by Webcam-test.js from the real
   stream (videoWidth/videoHeight, frames counted as they arrive, a
   histogram of downscaled frames). Scoped under .wc.
   =================================================================== */

.wc {
    --wc-accent: #3d8bff;
    --wc-accent-2: #22d3ee;
    --wc-ok: #34f5a6;
    --wc-warn: #ffb547;
    --wc-bad: #ff5f6d;
    --wc-ink: #10162b;
    --wc-muted: #5b6275;
    --wc-line: #e4e7ef;

    margin: 18px auto 24px;
    padding: 0; /* WebsiteTemplate gives every <section> 60px */
    max-width: 1040px;
    border-radius: 28px;
    background: #fff;
    border: 1px solid var(--wc-line);
    box-shadow: 0 30px 60px -32px rgb(16 22 43 / 45%);
    overflow: hidden;
    text-align: left;
    font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--wc-ink);
}

.wc *, .wc *::before, .wc *::after { box-sizing: border-box; }
.wc button, .wc select { font: inherit; }
.wc svg { display: block; }
.wc [hidden] { display: none !important; }

.wc-visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- top bar ---------- */

.wc-topbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
    padding: 14px 20px;
    background: linear-gradient(180deg, #151b33, #10162b);
    color: #cdd5ee;
}
.wc-detected { display: flex; align-items: center; gap: 8px; margin: 0; font-size: .9rem; font-weight: 500; }
.wc-detected svg { width: 18px; height: 18px; color: var(--wc-accent-2); flex: none; }

.wc-devices { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgb(255 255 255 / 8%); }
.wc-devices button {
    border: 0; border-radius: 999px; padding: 6px 12px; min-height: 32px;
    background: transparent; color: #aeb8d6; font-size: .8rem; font-weight: 600; cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.wc-devices button:hover { color: #fff; }
.wc-devices button[aria-checked="true"] { background: #fff; color: var(--wc-ink); }

/* ---------- stage ---------- */

.wc-stage {
    position: relative;
    padding: clamp(18px, 4vw, 40px) clamp(12px, 4vw, 48px) clamp(18px, 3vw, 28px);
    background:
        radial-gradient(60% 60% at 50% 110%, rgb(61 139 255 / 26%), transparent 70%),
        radial-gradient(40% 50% at 10% 20%, rgb(34 211 238 / 10%), transparent 70%),
        linear-gradient(180deg, #10162b 0%, #1a2142 100%);
    isolation: isolate;
}

.wc-viewfinder {
    position: relative;
    width: min(100%, 820px, calc(64vh * var(--wc-arn, 1.7778)));
    margin: 0 auto;
    aspect-ratio: var(--wc-ar, 16 / 9);
    border-radius: 20px; overflow: hidden;
    background: radial-gradient(circle at 50% 40%, #1b2340, #070a14 75%);
    box-shadow: 0 0 0 1px rgb(255 255 255 / 10%), 0 0 0 10px #0b0f1d, 0 0 0 11px rgb(255 255 255 / 8%), 0 30px 60px -20px rgb(0 0 0 / 70%);
    transition: aspect-ratio .3s ease;
}
.wc-video {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: contain; background: #000;
    opacity: 0; transition: opacity .35s ease;
}
.wc[data-state="live"] .wc-video { opacity: 1; }
.wc[data-mirror="true"] .wc-video { transform: scaleX(-1); }

/* grid + reticle */
.wc-grid { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity .2s ease; pointer-events: none; }
.wc-reticle {
    position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px;
    border: 1.5px solid rgb(255 255 255 / 70%); border-radius: 6px; opacity: 0; pointer-events: none;
    transition: opacity .2s ease, transform .3s ease; transform: scale(1.25);
}
.wc-reticle::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: #fff; opacity: .8; }
.wc[data-state="live"][data-grid="true"] .wc-grid { opacity: 1; }
.wc[data-state="live"][data-grid="true"] .wc-reticle { opacity: 1; transform: scale(1); }

.wc-corner { position: absolute; width: 26px; height: 26px; border: 3px solid rgb(255 255 255 / 55%); pointer-events: none; transition: border-color .3s ease; }
.wc-corner--tl { left: 14px; top: 14px; border-right: 0; border-bottom: 0; border-top-left-radius: 8px; }
.wc-corner--tr { right: 14px; top: 14px; border-left: 0; border-bottom: 0; border-top-right-radius: 8px; }
.wc-corner--bl { left: 14px; bottom: 14px; border-right: 0; border-top: 0; border-bottom-left-radius: 8px; }
.wc-corner--br { right: 14px; bottom: 14px; border-left: 0; border-top: 0; border-bottom-right-radius: 8px; }
.wc[data-state="live"] .wc-corner { border-color: rgb(52 245 166 / 80%); }

/* HUD */
.wc-hud {
    position: absolute; left: 50px; right: 50px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    font-size: .78rem; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums;
    opacity: 0; transition: opacity .3s ease; pointer-events: none;
}
.wc-hud--top { top: 16px; }
.wc-hud--bottom { bottom: 16px; justify-content: space-between; }
.wc[data-state="live"] .wc-hud { opacity: 1; }
.wc-hud > span {
    padding: 4px 9px; border-radius: 8px;
    background: rgb(7 10 20 / 58%); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.wc-hud-fps { margin-left: auto; }
.wc-hud-fps b { font-weight: 800; color: var(--wc-ok); }
.wc-live { display: inline-flex; align-items: center; gap: 6px; letter-spacing: .08em; }
.wc-live i { width: 8px; height: 8px; border-radius: 50%; background: var(--wc-bad); box-shadow: 0 0 8px var(--wc-bad); animation: wc-blink 1.6s ease-in-out infinite; }
@keyframes wc-blink { 50% { opacity: .3; } }
.wc-hud-label { min-width: 0; }

/* shutter flash */
.wc-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.wc-flash.is-firing { animation: wc-flash .45s ease-out; }
@keyframes wc-flash { 0% { opacity: .92; } 100% { opacity: 0; } }
.wc-viewfinder.is-snap { animation: wc-snap .3s ease; }
@keyframes wc-snap { 40% { transform: scale(.985); } }

/* cover: idle / asking / error */
.wc-cover {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    padding: 24px; text-align: center; color: #dfe5f7;
    background: radial-gradient(circle at 50% 35%, rgb(29 36 64 / 92%), rgb(7 10 20 / 96%) 75%);
    transition: opacity .3s ease, visibility .3s;
    overflow-y: auto;
}
.wc[data-state="live"] .wc-cover { opacity: 0; visibility: hidden; pointer-events: none; }
.wc-cover-art { width: 96px; }
.wc-cover-led { fill: #3a4163; }
.wc[data-state="asking"] .wc-cover-led { fill: var(--wc-warn); animation: wc-blink 1s ease-in-out infinite; }
.wc[data-state="error"] .wc-cover-led { fill: var(--wc-bad); }
.wc-cover-title { margin: 4px 0 0; font-size: 1.3rem; font-weight: 700; color: #fff; }
.wc-cover-text { margin: 0; max-width: 460px; font-size: .92rem; line-height: 1.5; color: #b8c2e0; }
.wc-cover-steps { margin: 2px 0 4px; padding: 0 0 0 1.2em; max-width: 460px; text-align: left; font-size: .88rem; line-height: 1.5; color: #cdd5ee; }
.wc-cover-steps li + li { margin-top: 3px; }
.wc[data-state="error"] .wc-cover-title { color: #ffb3ba; }

.wc-start {
    display: inline-flex; align-items: center; gap: 10px;
    margin-top: 8px; min-height: 50px; padding: 0 24px;
    border: 0; border-radius: 999px; cursor: pointer; color: #fff; font-weight: 700; font-size: 1rem;
    background: radial-gradient(circle at 30% 20%, #6aa9ff, var(--wc-accent) 55%, #2254c9);
    box-shadow: 0 14px 30px -10px rgb(61 139 255 / 75%), inset 0 -3px 8px rgb(0 0 0 / 22%), inset 0 2px 6px rgb(255 255 255 / 25%);
    transition: transform .15s ease;
}
.wc-start svg { width: 22px; height: 22px; }
.wc-start:hover { transform: translateY(-2px); }
.wc-start:active { transform: scale(.96); }
.wc-start:disabled { opacity: .6; cursor: progress; transform: none; }
.wc-start:focus-visible { outline: 3px solid var(--wc-accent-2); outline-offset: 4px; }

/* ---------- control deck ---------- */

.wc-deck {
    display: flex; align-items: center; justify-content: center; gap: clamp(8px, 2.5vw, 22px);
    margin-top: clamp(20px, 3vw, 28px);
}
.wc-tool {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    min-width: 64px; min-height: 56px; padding: 7px 8px; border: 0; border-radius: 16px; cursor: pointer;
    background: rgb(255 255 255 / 7%); color: #cdd5ee; font-size: .74rem; font-weight: 600;
    transition: background-color .15s ease, color .15s ease, transform .12s ease, opacity .2s ease;
}
.wc-tool svg { width: 22px; height: 22px; }
.wc-tool:hover:not(:disabled) { background: rgb(255 255 255 / 13%); color: #fff; }
.wc-tool:active:not(:disabled) { transform: scale(.93); }
.wc-tool[aria-pressed="true"] { background: rgb(34 211 238 / 18%); color: var(--wc-accent-2); }
.wc-tool:disabled { opacity: .35; cursor: default; }
.wc-tool:focus-visible, .wc-shutter:focus-visible { outline: 3px solid var(--wc-accent-2); outline-offset: 3px; }
.wc-tool--power:not(:disabled) { color: #ffb3ba; }
.wc-tool--flip { display: none; }
.wc[data-device="phone"] .wc-tool--flip, .wc[data-device="tablet"] .wc-tool--flip { display: flex; }

.wc-shutter {
    position: relative; flex: none;
    width: 76px; height: 76px; border-radius: 50%; cursor: pointer;
    border: 4px solid #fff; background: transparent; padding: 5px;
    box-shadow: 0 10px 26px -8px rgb(0 0 0 / 60%);
    transition: transform .12s ease, opacity .2s ease;
}
.wc-shutter-ring { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .12s ease, background-color .15s ease; }
.wc-shutter:hover:not(:disabled) .wc-shutter-ring { background: #e8f1ff; }
.wc-shutter:active:not(:disabled) .wc-shutter-ring { transform: scale(.82); }
.wc-shutter:disabled { opacity: .35; cursor: default; }

/* ---------- light panel ---------- */

.wc-panel { padding: 24px clamp(16px, 4vw, 36px) 26px; }

.wc-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.wc-stat {
    display: flex; flex-direction: column; gap: 4px; min-width: 0;
    padding: 14px 16px; border-radius: 18px; background: #f6f8fc; border: 1px solid var(--wc-line);
}
.wc-stat-label, .wc-group-label { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--wc-muted); }
.wc-stat-value { font-size: 1.45rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--wc-ink); overflow-wrap: anywhere; }
.wc-stat-value.is-updated { animation: wc-pop .35s ease; }
@keyframes wc-pop { 40% { color: var(--wc-accent); transform: scale(1.04); } }
.wc-stat-value { transform-origin: left center; }
.wc-stat-sub { font-size: .8rem; color: var(--wc-muted); line-height: 1.35; }
.wc-stat-sub.is-warn { color: #b26a00; font-weight: 600; }
.wc-stat-sub.is-good { color: #127a4c; font-weight: 600; }
.wc-histogram { display: block; width: 100%; height: 44px; border-radius: 8px; background: #10162b; }

.wc-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 24px; align-items: end; margin-top: 20px; }
.wc-group { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.wc-select {
    width: 100%; min-height: 48px; padding: 0 40px 0 14px; border-radius: 14px;
    border: 1px solid var(--wc-line); background: #f1f3f8; color: var(--wc-ink); font-weight: 600; font-size: .92rem;
    -webkit-appearance: none; appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%235b6275' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round' d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
    text-overflow: ellipsis;
}
.wc-select:disabled { opacity: .6; cursor: default; }
.wc-select:focus-visible { outline: 3px solid var(--wc-accent); outline-offset: 2px; }

.wc-segmented { display: inline-flex; padding: 4px; gap: 4px; border-radius: 16px; background: #f1f3f8; border: 1px solid var(--wc-line); }
.wc-segmented button {
    min-height: 40px; padding: 0 14px; border: 0; border-radius: 12px; cursor: pointer;
    background: transparent; color: var(--wc-muted); font-weight: 600; font-size: .9rem; white-space: nowrap;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.wc-segmented button:hover { color: var(--wc-ink); }
.wc-segmented button[aria-checked="true"] { background: #fff; color: var(--wc-ink); box-shadow: 0 1px 2px rgb(16 22 43 / 10%), 0 6px 14px -8px rgb(16 22 43 / 35%); }
.wc-segmented button:focus-visible, .wc-devices button:focus-visible { outline: 3px solid var(--wc-accent); outline-offset: 2px; }

.wc-status {
    margin: 18px 0 0; padding: 12px 16px; border-radius: 14px;
    background: #f4f7ff; border: 1px solid #dce6fb; font-weight: 600; color: #1d3a7a;
}
.wc[data-state="error"] .wc-status { background: #fff4f5; border-color: #f8d0d5; color: #9b1c2c; }

.wc-lower { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; margin-top: 18px; }

.wc-shots { min-width: 0; padding: 16px; border-radius: 18px; border: 1px solid var(--wc-line); }
.wc-shots-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.wc-private { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; color: #127a4c; }
.wc-private svg { width: 15px; height: 15px; }
.wc-gallery { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.wc-gallery:empty { display: none; }
.wc-gallery li { position: relative; border-radius: 12px; overflow: hidden; background: #10162b; animation: wc-in .35s cubic-bezier(.2, .8, .3, 1.2); }
@keyframes wc-in { from { opacity: 0; transform: scale(.85) translateY(8px); } }
.wc-gallery img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.wc .wc-gallery a {
    display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px;
    font-size: .8rem; font-weight: 700; color: #fff !important; text-decoration: none; background: #1d2440;
}
.wc .wc-gallery a:hover { background: var(--wc-accent); color: #fff; }
.wc-gallery a:focus-visible { outline: 3px solid var(--wc-accent-2); outline-offset: -3px; }
.wc-gallery a svg { width: 15px; height: 15px; }
.wc-gallery-meta { position: absolute; left: 6px; top: 6px; padding: 2px 6px; border-radius: 6px; background: rgb(7 10 20 / 65%); color: #fff; font-size: .68rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.wc-gallery-empty { margin: 10px 0 0; font-size: .88rem; color: var(--wc-muted); }

.wc-details { margin: 0; padding: 16px; border-radius: 18px; background: #f6f8fc; border: 1px solid var(--wc-line); display: grid; gap: 8px; align-content: start; }
.wc-details div { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 8px; font-size: .86rem; }
.wc-details dt { color: var(--wc-muted); font-weight: 600; }
.wc-details dd { margin: 0; color: var(--wc-ink); font-weight: 600; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.wc-note { margin: 16px 0 0; font-size: .88rem; color: var(--wc-muted); line-height: 1.55; }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
    .wc-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .wc-controls, .wc-lower { grid-template-columns: 1fr; }
}

@media (max-width: 575.98px) {
    .wc { border-radius: 22px; margin-inline: -4px; }
    .wc-topbar { padding: 12px 14px; }
    .wc-devices { width: 100%; }
    .wc-devices button { flex: 1; padding: 6px 4px; }
    .wc-viewfinder { border-radius: 14px; box-shadow: 0 0 0 1px rgb(255 255 255 / 10%), 0 0 0 6px #0b0f1d, 0 20px 40px -18px rgb(0 0 0 / 70%); }
    .wc[data-state="idle"] .wc-viewfinder, .wc[data-state="asking"] .wc-viewfinder, .wc[data-state="error"] .wc-viewfinder { aspect-ratio: auto; min-height: 340px; }
    .wc-cover { position: relative; min-height: 340px; }
    .wc[data-state="live"] .wc-cover { position: absolute; }
    .wc-cover-art { width: 72px; }
    .wc-hud { left: 10px; right: 10px; font-size: .7rem; gap: 5px; }
    .wc-hud--top { top: 10px; } .wc-hud--bottom { bottom: 10px; }
    .wc-corner { display: none; }
    .wc-deck { gap: 6px; }
    .wc-tool { min-width: 52px; padding: 6px 4px; font-size: .68rem; }
    .wc-shutter { width: 64px; height: 64px; }
    .wc-stat { padding: 12px; }
    .wc-stat-value { font-size: 1.15rem; }
    .wc-segmented { display: flex; }
    .wc-segmented button { flex: 1; padding: 0 6px; }
    .wc-details div { grid-template-columns: 100px minmax(0, 1fr); }
}

@media (pointer: coarse) {
    .wc-devices button, .wc-segmented button { min-height: 44px; }
    .wc-tool { min-height: 56px; min-width: 56px; }
    .wc .wc-gallery a { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    .wc *, .wc *::before, .wc *::after { animation: none !important; transition: none !important; }
}
