/* ═══════════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════════ */
:root {
    --bg:                #ffffff;
    --surface-muted:     #f7f9fc;
    --border:            #e6ebf2;
    --text-1:            #0b2254;
    --text-2:            #5f6f8f;
    --blue:              #165dff;
    --blue-dark:         #0d47c9;
    --green:             #08b85d;
    --green-dark:        #05964b;
    --yellow:            #f6c343;
    --red:               #e33d3d;
    --shadow:            0 10px 30px rgba(11,34,84,.08);
    --shadow-card:       0 6px 20px rgba(11,34,84,.06);
    --radius:            clamp(16px, 2vw, 28px);
    --radius-xl:         28px;
    --radius-lg:         22px;
    --radius-md:         18px;
    --radius-sm:         14px;
}

/* ═══════════════════════════════════════════
   RESET
═══════════════════════════════════════════ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

html, body {
    height: 100%;
    overflow: hidden;           /* hard lock — nothing scrolls */
}

body {
    font-family: "Inter", "Plus Jakarta Sans", "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text-1);
}

button, input, select, textarea { font: inherit; }
button { border: 0; background: none; cursor: pointer; }

/* ═══════════════════════════════════════════
   SCREEN-READER UTILITY
═══════════════════════════════════════════ */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ═══════════════════════════════════════════
   JS SINK — invisible container for all IDs
   the JS binds to but the new UI doesn't show
═══════════════════════════════════════════ */
.js-sink {
    position: fixed;
    top: -9999px; left: -9999px;
    width: 0; height: 0;
    overflow: hidden;
    pointer-events: none;
    visibility: hidden;
}

/* ═══════════════════════════════════════════
   SHELL — fills the entire viewport, never
   overflows. Every child must min-height:0.
═══════════════════════════════════════════ */
.kiosk-shell {
    height: 100vh;          /* fallback for browsers without dvh support (Edge < 108) */
    height: 100dvh;         /* dynamic viewport: avoids mobile address-bar gap when supported */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ═══════════════════════════════════════════
   PAGE WRAPPER — padded flex column inside shell
═══════════════════════════════════════════ */
.page-wrapper {
    flex: 1 1 0;
    min-height: 0;          /* required: allows flex child to shrink below content */
    display: flex;
    flex-direction: column;
    padding: clamp(14px,2vh,32px) clamp(18px,2.5vw,40px) clamp(10px,1.4vh,20px);
    gap: clamp(10px,1.4vh,20px);
    overflow: hidden;
}

/* ═══════════════════════════════════════════
   HEADER
═══════════════════════════════════════════ */
.kiosk-header {
    flex: 0 0 auto;
    overflow: hidden;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: clamp(4px,.6vh,10px);
}

.brand-logo {
    height: clamp(28px,3.6vh,44px);
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.brand-eyebrow {
    font-size: clamp(11px,1.1vw,14px);
    font-weight: 700;
    letter-spacing: .12em;
    color: var(--blue);
    text-transform: uppercase;
    white-space: nowrap;
}

.page-title {
    font-size: clamp(20px,3vw,42px);
    font-weight: 700;
    color: var(--text-1);
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: clamp(2px,.4vh,6px);
}

.page-subtitle {
    font-size: clamp(13px,1.4vw,18px);
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════
   MAIN GRID — two columns, fills remaining space
═══════════════════════════════════════════ */
.main-grid {
    flex: 1 1 0;
    min-height: 0;
    display: grid;
    grid-template-columns: 57fr 43fr;
    grid-template-rows: 1fr;            /* critical: forces row to fill grid height */
    gap: clamp(14px,2vw,32px);
    overflow: hidden;       /* must stay hidden: constrains fr row heights on all browsers */
}

/* ═══════════════════════════════════════════
   LEFT COLUMN — camera
═══════════════════════════════════════════ */
.camera-col {
    min-height: 0;
    min-width: 0;
    display: flex;
    overflow: hidden;
}

.camera-card {
    flex: 1 1 0;
    min-height: 0;
    min-width: 0;
    position: relative;
    overflow: hidden;
    contain: layout paint;              /* hard clip: video can never escape this box */
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #080b12;
    box-shadow: var(--shadow);
}

/* Video fills card */
.camera-card video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);   /* mirror selfie view */
    display: block;
}

/* Canvas overlay for face-guide drawing */
.camera-card canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ── LIVE pill ── */
.live-pill {
    position: absolute;
    top: clamp(12px,1.8vh,22px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: clamp(7px,1vh,12px) clamp(16px,2vw,24px);
    border-radius: 999px;
    background: rgba(255,255,255,.88);
    border: 1px solid rgba(255,255,255,.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 14px rgba(11,34,84,.14);
    color: var(--text-1);
    font-size: clamp(11px,1.1vw,14px);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    pointer-events: none;
    white-space: nowrap;
}

.live-dot {
    width: clamp(7px,.8vw,10px);
    height: clamp(7px,.8vw,10px);
    border-radius: 50%;
    background: #ff3333;
    box-shadow: 0 0 6px rgba(255,51,51,.7);
    flex-shrink: 0;
    animation: liveBlink 1.4s ease-in-out infinite;
}

@keyframes liveBlink {
    0%, 100% { opacity: 1; }
    50%       { opacity: .4; }
}

.kiosk-shell.scanning .live-dot { animation-duration: .75s; }

/* ── Recognition status card (dark + opaque — always readable on dark camera) ── */
.recog-card {
    position: absolute;
    bottom: clamp(14px,2.2vh,26px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    width: clamp(240px, 82%, 480px);
    display: flex;
    align-items: flex-start;
    gap: clamp(10px,1.3vw,18px);
    padding: clamp(14px,1.6vh,20px) clamp(16px,1.8vw,24px);
    border-radius: clamp(16px,1.8vw,24px);
    background: rgba(6, 14, 44, 0.91);
    border: 1px solid rgba(255,255,255,.18);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 8px 28px rgba(0,0,0,.45);
    transition: background .25s, border-color .25s;
}

/* Solid fallback when backdrop-filter unavailable */
@supports not (backdrop-filter: blur(1px)) {
    .recog-card { background: rgba(6, 14, 44, 0.97); }
}

.recog-icon {
    flex-shrink: 0;
    width: clamp(34px,3.8vw,48px);
    height: clamp(34px,3.8vw,48px);
    border-radius: 50%;
    background: var(--blue);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background .25s;
}

.recog-icon svg { width: 55%; height: 55%; }

.recog-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.recog-title {
    font-size: clamp(13px,1.4vw,17px);
    font-weight: 700;
    color: #ffffff;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.3;
}

.recog-detail {
    font-size: clamp(12px,1.1vw,15px);
    color: #a8c4e0;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.45;
}

/* State colours — vivid but still dark enough to keep white text readable */
.recog-card[data-state="working"] {
    background: rgba(14, 60, 200, 0.90);
    border-color: rgba(100,160,255,.35);
}
.recog-card[data-state="working"] .recog-icon { background: #4a8eff; }

.recog-card[data-state="success"] {
    background: rgba(4, 110, 56, 0.91);
    border-color: rgba(80,220,140,.35);
}
.recog-card[data-state="success"] .recog-icon { background: var(--green); }

.recog-card[data-state="error"] {
    background: rgba(170, 28, 28, 0.91);
    border-color: rgba(255,130,130,.30);
}
.recog-card[data-state="error"] .recog-icon { background: #ef5555; }

/* Camera card ring on success/error */
.kiosk-shell.success .camera-card {
    box-shadow: 0 0 0 3px var(--green), var(--shadow);
}
.kiosk-shell.error .camera-card {
    box-shadow: 0 0 0 3px var(--red), var(--shadow);
}

/* ── Recognition title tone helpers — white-based palette on dark card ── */
.recog-title.tone-idle,
.recog-title.tone-working { color: #ffffff; }

.recog-title.tone-good { color: #6effc0; }

.recog-title.tone-bad  { color: #ffaaaa; }

/* ═══════════════════════════════════════════
   RIGHT COLUMN — action panel
═══════════════════════════════════════════ */
.action-col {
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: clamp(12px,1.8vh,26px);
    overflow: hidden;
    border-left: 1px solid var(--border);
    padding-left: clamp(14px,1.6vw,28px);
}

/* ── Time ── */
.time-block {
    flex: 0 0 auto;
    overflow: hidden;
}

.time-row {
    display: flex;
    align-items: flex-start;
    gap: clamp(4px,.5vw,8px);
    line-height: 1;
}

.time-digits {
    font-size: clamp(56px,8.5vw,120px);
    font-weight: 700;
    color: var(--text-1);
    letter-spacing: -.03em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.time-ampm {
    font-size: clamp(22px,3vw,48px);
    font-weight: 700;
    color: var(--blue);
    margin-top: clamp(8px,1.4vh,18px);
    white-space: nowrap;
}

.time-date {
    font-size: clamp(13px,1.5vw,18px);
    font-weight: 500;
    color: var(--text-2);
    margin-top: clamp(3px,.5vh,8px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.time-rule {
    height: 1px;
    background: var(--border);
    margin-top: clamp(12px,1.6vh,20px);
}

/* ── Guidance ── */
.guidance-block {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: clamp(12px,1.4vw,20px);
    overflow: hidden;
}

.guidance-icon {
    flex-shrink: 0;
    width: clamp(38px,4.2vw,56px);
    height: clamp(38px,4.2vw,56px);
    border-radius: 50%;
    background: var(--blue);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.guidance-icon svg { width: 55%; height: 55%; }

.guidance-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    overflow: hidden;
}

.guidance-heading {
    font-size: clamp(15px,1.6vw,20px);
    font-weight: 700;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.guidance-detail {
    font-size: clamp(12px,1.2vw,15px);
    color: var(--text-2);
    line-height: 1.45;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ── START CAMERA panel (idle phase only) ── */
.start-camera-panel {
    display: none;
    flex: 1 1 0;
    min-height: 0;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding-bottom: clamp(28px, 4vh, 48px);
}
.kiosk-shell.idle .start-camera-panel { display: flex; }
.kiosk-shell.idle .action-buttons     { display: none; }

/* Blue dome for the start-camera button */
.action-btn--start .btn-dome {
    background: radial-gradient(ellipse at 40% 28%, #6ab3ff 0%, #3389ff 28%, #165dff 58%, #0c3fb5 100%);
    box-shadow:
        inset 0 5px 12px rgba(255,255,255,.42),
        inset 0 -7px 16px rgba(0,0,0,.28),
        0 10px 0 #0a2d8a,
        0 16px 28px rgba(11,45,138,.36);
}
.action-btn--start:not(:disabled):hover .btn-dome {
    transform: translateY(-4px);
    filter: brightness(1.06);
    box-shadow:
        inset 0 5px 12px rgba(255,255,255,.46),
        inset 0 -7px 16px rgba(0,0,0,.28),
        0 14px 0 #0a2d8a,
        0 20px 32px rgba(11,45,138,.42);
}
.action-btn--start:not(:disabled):active .btn-dome,
.action-btn--start:not(:disabled) .btn-dome--pressed {
    box-shadow:
        inset 0 3px 7px rgba(255,255,255,.24),
        inset 0 -4px 9px rgba(0,0,0,.26),
        0 3px 0 #0a2d8a,
        0 7px 16px rgba(11,45,138,.28) !important;
}

/* ── Circular dome action buttons ── */
.action-buttons {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: clamp(24px, 5vw, 72px);
    overflow: hidden;
    padding-bottom: clamp(28px, 4vh, 48px); /* room for dome shadow inside container */
}

/* Outer button: column stack (dome ↑ label ↓), no visible background */
.action-btn {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(10px, 1.4vh, 18px);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    -webkit-appearance: none;
    appearance: none;
    transition: filter 120ms ease;
}

.action-btn:focus-visible { outline: none; }
.action-btn:focus-visible .btn-dome {
    outline: 4px solid rgba(22, 93, 255, .55);
    outline-offset: 6px;
}

.action-btn:disabled             { opacity: .45; cursor: not-allowed; }
.action-btn:disabled .btn-dome   { pointer-events: none; }

/* ── The dome circle ── */
.btn-dome {
    width: clamp(100px, 12vw, 168px);
    height: clamp(100px, 12vw, 168px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform;
    transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

/* ── Clock In — green dome ── */
.action-btn--in .btn-dome {
    background: radial-gradient(ellipse at 40% 28%, #60fdb8 0%, #19d87a 28%, #08b85d 58%, #047a3f 100%);
    box-shadow:
        inset 0 5px 12px rgba(255,255,255,.42),
        inset 0 -7px 16px rgba(0,0,0,.28),
        0 10px 0 #036232,
        0 16px 28px rgba(11,84,45,.36);
}

/* ── Clock Out — red dome ── */
.action-btn--out .btn-dome {
    background: radial-gradient(ellipse at 40% 28%, #ff8080 0%, #f03a3a 28%, #d42020 58%, #9e1010 100%);
    box-shadow:
        inset 0 5px 12px rgba(255,255,255,.42),
        inset 0 -7px 16px rgba(0,0,0,.28),
        0 10px 0 #7b0d0d,
        0 16px 28px rgba(84,11,11,.38);
}

/* Hover: dome lifts slightly */
.action-btn:not(:disabled):hover .btn-dome {
    transform: translateY(-4px);
    filter: brightness(1.06);
}
.action-btn--in:not(:disabled):hover .btn-dome {
    box-shadow:
        inset 0 5px 12px rgba(255,255,255,.46),
        inset 0 -7px 16px rgba(0,0,0,.28),
        0 14px 0 #036232,
        0 20px 32px rgba(11,84,45,.42);
}
.action-btn--out:not(:disabled):hover .btn-dome {
    box-shadow:
        inset 0 5px 12px rgba(255,255,255,.46),
        inset 0 -7px 16px rgba(0,0,0,.28),
        0 14px 0 #7b0d0d,
        0 20px 32px rgba(84,11,11,.44);
}

/* Active: dome presses onto the slab */
.action-btn:not(:disabled):active .btn-dome,
.action-btn:not(:disabled) .btn-dome--pressed {
    transform: translateY(8px) !important;
    filter: brightness(.93) !important;
}
.action-btn--in:not(:disabled):active .btn-dome,
.action-btn--in:not(:disabled) .btn-dome--pressed {
    box-shadow:
        inset 0 3px 7px rgba(255,255,255,.24),
        inset 0 -4px 9px rgba(0,0,0,.26),
        0 3px 0 #036232,
        0 7px 16px rgba(11,84,45,.28) !important;
}
.action-btn--out:not(:disabled):active .btn-dome,
.action-btn--out:not(:disabled) .btn-dome--pressed {
    box-shadow:
        inset 0 3px 7px rgba(255,255,255,.24),
        inset 0 -4px 9px rgba(0,0,0,.26),
        0 3px 0 #7b0d0d,
        0 7px 16px rgba(84,11,11,.30) !important;
}

/* Suggested: glow ring on the dome */
.action-btn--in.action-btn--suggested .btn-dome {
    box-shadow:
        inset 0 5px 12px rgba(255,255,255,.42),
        inset 0 -7px 16px rgba(0,0,0,.28),
        0 10px 0 #036232,
        0 16px 28px rgba(11,84,45,.36),
        0 0 0 5px rgba(8,184,93,.72);
}
.action-btn--out.action-btn--suggested .btn-dome {
    box-shadow:
        inset 0 5px 12px rgba(255,255,255,.42),
        inset 0 -7px 16px rgba(0,0,0,.28),
        0 10px 0 #7b0d0d,
        0 16px 28px rgba(84,11,11,.38),
        0 0 0 5px rgba(227,61,61,.72);
}

/* ── Icon inside the dome ── */
.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    -webkit-filter: drop-shadow(0 2px 5px rgba(0,0,0,.32));
            filter: drop-shadow(0 2px 5px rgba(0,0,0,.32));
}

.btn-icon svg {
    width: clamp(34px, 4.4vw, 62px);
    height: clamp(34px, 4.4vw, 62px);
    stroke-width: 2.5;
}

/* ── Text label below the dome ── */
.btn-label {
    font-size: clamp(13px, 1.6vw, 21px);
    font-weight: 800;
    color: var(--text-1);
    letter-spacing: .07em;
    text-transform: uppercase;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
}

/* ═══════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════ */
.kiosk-footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: clamp(8px,1vh,16px);
    border-top: 1px solid var(--border);
    font-size: clamp(11px,1.1vw,15px);
    color: var(--text-2);
    overflow: hidden;
    white-space: nowrap;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 7px;
}

.footer-shield {
    width: clamp(13px,1.4vw,17px);
    height: clamp(13px,1.4vw,17px);
    flex-shrink: 0;
    color: var(--blue);
}

.footer-right strong { color: var(--blue); }

/* ═══════════════════════════════════════════
   RESPONSIVE — portrait / narrow (≤ 900px)
   Single column: camera on top, actions below.
═══════════════════════════════════════════ */
@media (max-width: 900px) {
    .main-grid {
        grid-template-columns: 1fr;
        grid-template-rows: 45fr 55fr;
    }

    .action-col {
        border-left: none;
        border-top: 1px solid var(--border);
        padding-left: 0;
        padding-top: clamp(10px, 1.4vh, 18px);
    }

    .time-digits { font-size: clamp(42px, 7vw, 84px); }
    .time-ampm   { font-size: clamp(18px, 2.8vw, 36px); }
    .time-rule   { display: none; }
    .guidance-detail { display: none; }

    .btn-dome {
        width: clamp(82px, 18vw, 130px);
        height: clamp(82px, 18vw, 130px);
    }
    .btn-icon svg {
        width: clamp(28px, 3.8vw, 50px);
        height: clamp(28px, 3.8vw, 50px);
    }
    .btn-label { font-size: clamp(12px, 1.5vw, 17px); }
}

/* ═══════════════════════════════════════════
   SMALL SCREENS — phones (≤ 600px)
   Scrollable layout: camera is fixed height,
   actions section flows naturally below it.
═══════════════════════════════════════════ */
@media (max-width: 600px) {
    /* Remove the viewport height lock so the page can scroll */
    html, body {
        height: auto;
        overflow-y: auto;
    }

    .kiosk-shell {
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .page-wrapper {
        flex: 0 0 auto;
        overflow: visible;
        padding: clamp(10px, 3vw, 16px);
        gap: 12px;
    }

    .main-grid {
        grid-template-rows: auto auto;
        height: auto;
        overflow: visible;
        padding-bottom: 0;
        margin-bottom: 0;
    }

    /* Camera covers nearly half the screen on mobile */
    .camera-col {
        height: 46vh;
        min-height: 240px;
        max-height: 480px;
        flex: none;
    }

    .action-col {
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .time-digits { font-size: clamp(38px, 11.5vw, 64px); }
    .time-ampm   { font-size: clamp(15px, 4.5vw, 26px); }
    .page-subtitle  { display: none; }
    .guidance-block { display: none; }

    .start-camera-panel {
        flex: 0 0 auto;           /* stop collapsing to 0 height in auto-height parent */
        padding-bottom: clamp(20px, 5vw, 32px);
    }
    .action-buttons {
        flex: 0 0 auto;           /* stop collapsing to 0 height in auto-height parent */
        padding-bottom: clamp(20px, 5vw, 32px);
        gap: clamp(16px, 8vw, 44px);
    }
    .btn-dome {
        width: clamp(76px, 23vw, 112px);
        height: clamp(76px, 23vw, 112px);
    }
    .btn-icon svg {
        width: clamp(26px, 7.8vw, 40px);
        height: clamp(26px, 7.8vw, 40px);
    }
    .btn-label { font-size: clamp(11px, 3.5vw, 15px); }

    /* Wider recog card so wrapped employee names don't overflow */
    .recog-card {
        width: clamp(260px, 90%, 480px);
        font-size: clamp(13px, 3.5vw, 16px);
    }
    .recog-title { font-size: clamp(13px, 3.8vw, 17px); }
    .recog-detail { font-size: clamp(12px, 3.3vw, 15px); }
}
