/* ============================================================
   Video interview recorder (video_interview_recorder.js)
   Branded styling — uses :root vars from /assets/css/branding/.
   ============================================================ */

.vi-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(30, 30, 35, 0.55);
    backdrop-filter: blur(6px);
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vi-modal {
    background: #fff;
    color: #2d2d2d;
    width: 90vw;
    max-width: 720px;
    max-height: 95vh;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    font-family: var(--primary-font, inherit);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.18),
                0 0 0 1px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
}

/* Branded header strip with title + close */
.vi-header {
    flex: 0 0 auto;
    background: var(--primary-color, #ff0025);
    color: #fff;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 500;
}
.vi-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: 0.01em;
}
.vi-header-title svg {
    width: 18px;
    height: 18px;
}

.vi-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    border: none;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    display: grid;
    place-items: center;
    cursor: pointer;
    padding: 0;
    transition: background 150ms;
}
.vi-close:hover {
    background: rgba(255, 255, 255, 0.26);
}

/* Video frame */
.vi-video-wrap {
    position: relative;
    background: #0f0d0c;
    aspect-ratio: 16/9;
    overflow: hidden;
}
.vi-video-wrap video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    /* Flip horizontally so the live feed reads naturally (text in the background
       appears the right way round). The uploaded file is NOT modified — this is
       display-only. Playback of the recorded blob (review state) removes the
       flip so the user sees the true camera output (same as admins will), and
       so the native <video controls> UI isn't mirrored. */
    transform: scaleX(-1);
}
.vi-video-wrap video.vi-video--playback {
    transform: none;
}

/* Film grain overlay */
.vi-grain {
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.6'/></svg>");
    opacity: 0.07;
    pointer-events: none;
    mix-blend-mode: overlay;
    z-index: 1;
}

/* Viewfinder corner brackets — hardcoded red (signal / recording colour),
   not tied to tenant branding so the cue reads consistently across sites. */
.vi-video-wrap::before,
.vi-video-wrap::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border: 1.5px solid #e53935;
    opacity: 0.9;
    z-index: 2;
    pointer-events: none;
}
.vi-video-wrap::before {
    top: 14px;
    left: 14px;
    border-right: none;
    border-bottom: none;
}
.vi-video-wrap::after {
    bottom: 14px;
    right: 14px;
    border-left: none;
    border-top: none;
}

/* REC pill at top-center of the video */
.vi-timer {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(15, 13, 12, 0.75);
    backdrop-filter: blur(6px);
    padding: 7px 14px 7px 12px;
    border-radius: 100px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 3;
}
.vi-rec-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color, #ff0025);
    box-shadow: 0 0 10px var(--primary-color, #ff0025);
    animation: viPulse 1.6s ease-in-out infinite;
    flex: 0 0 auto;
}
@keyframes viPulse {
    0%, 100% { opacity: 1;   box-shadow: 0 0 10px var(--primary-color, #ff0025); }
    50%      { opacity: 0.3; box-shadow: 0 0 3px  var(--primary-color, #ff0025); }
}
.vi-on-air {
    font-family: var(--primary-font, inherit);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.22em;
    color: #fff;
}
.vi-time {
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    padding-left: 10px;
    margin-left: 2px;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
}

/* Pre-countdown */
.vi-pre-countdown {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at center, rgba(255, 0, 37, 0.22), transparent 55%),
        rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 160px;
    line-height: 1;
    font-weight: 400;
    font-style: italic;
    color: #fff;
    z-index: 4;
    animation: viZoom 900ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes viZoom {
    from { transform: scale(0.75); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

/* Processing / error overlay (shown between stop-recording and preview ready) */
.vi-processing {
    position: absolute;
    inset: 0;
    background: rgba(15, 13, 12, 0.85);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: #fff;
    z-index: 5;
    padding: 0 24px;
    text-align: center;
}
.vi-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 255, 255, 0.12);
    border-top-color: var(--primary-color, #ff0025);
    border-radius: 50%;
    animation: viSpin 0.9s linear infinite;
    flex: 0 0 auto;
}
@keyframes viSpin {
    to { transform: rotate(360deg); }
}
.vi-processing-text {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.01em;
    margin: 0;
}
.vi-processing-sub {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    max-width: 420px;
    line-height: 1.5;
    margin: 0;
}
.vi-processing-retry {
    margin-top: 4px;
    padding: 9px 22px;
    background: var(--primary-color, #ff0025);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 150ms;
}
.vi-processing-retry:hover {
    background: var(--primary-color-gradient-darker, #c0001c);
}
.vi-processing.vi-processing-error .vi-spinner { display: none; }
.vi-processing.vi-processing-error::before {
    content: '!';
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-color, #ff0025);
    color: #fff;
    font-size: 24px;
    font-weight: 600;
    font-family: Georgia, serif;
    display: grid;
    place-items: center;
}

/* Body — flex column with a min-height so the modal doesn't jump
   when content/buttons change between states */
.vi-body {
    flex: 0 0 auto;
    padding: 22px 24px 20px;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

.vi-question-num {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--primary-color, #ff0025);
    margin-bottom: 8px;
}

.vi-question {
    font-size: 18px;
    line-height: 1.4;
    font-weight: 500;
    color: #1f2937;
    margin: 0 0 8px;
}
.vi-question-sub {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}

.vi-status {
    font-size: 12px;
    color: #6b7280;
    min-height: 14px;
    margin-top: 10px;
}
.vi-status:empty {
    min-height: 0;
    margin: 0;
}
.vi-status.vi-error { color: var(--primary-color, #ff0025); }

.vi-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: auto;
    padding-top: 22px;
    min-height: 62px; /* button height + padding-top; reserves space during transitions */
}
.vi-actions button {
    font-family: inherit;
    font-size: var(--primary-font-size, 13px);
    font-weight: 500;
    padding: 10px 18px;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 150ms;
}
.vi-btn-primary {
    background: var(--primary-color, #ff0025);
    color: #fff;
    border-color: var(--primary-color, #ff0025);
}
.vi-btn-primary:hover {
    background: var(--primary-color-gradient-darker, #c0001c);
    border-color: var(--primary-color-gradient-darker, #c0001c);
}
.vi-btn-primary:disabled {
    background: #d1d5db;
    border-color: #d1d5db;
    color: #fff;
    cursor: not-allowed;
}
.vi-btn-secondary {
    background: #fff;
    color: #374151;
    border-color: #d1d5db;
}
.vi-btn-secondary:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

/* Mobile — full-screen, no scroll, flex layout */
@media (max-width: 640px) {
    .vi-backdrop {
        backdrop-filter: none;
        background: #fff;
    }
    .vi-modal {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        box-shadow: none;
    }
    .vi-header { padding: 12px 16px; font-size: 14px; }
    .vi-video-wrap {
        flex: 1 1 auto;
        aspect-ratio: auto;
        min-height: 0;
    }
    .vi-video-wrap::before,
    .vi-video-wrap::after {
        width: 26px;
        height: 26px;
        border-width: 2px;
    }
    .vi-timer { top: 12px; padding: 6px 12px; }
    .vi-pre-countdown { font-size: 140px; }
    .vi-body {
        min-height: 0;
        padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    }
    .vi-question-num { margin-bottom: 6px; font-size: 10px; }
    .vi-question { font-size: 16px; line-height: 1.3; margin-bottom: 4px; }
    .vi-question-sub { font-size: 12px; margin-top: 2px; }
    .vi-status { margin-top: 8px; }
    .vi-status:empty { display: none; margin: 0; }
    .vi-actions { padding-top: 16px; gap: 8px; min-height: 56px; }
    .vi-actions button { flex: 1; padding: 12px 10px; font-size: 14px; }
}
