/* Testing-phase gate (scripts/gate.js): an 8-digit code before any page shows */

/* Nothing but the gate shows until the visitor is in, including the moment
   before gate.js has run */
body:not(.unlocked) > :not(.gate) {
    visibility: hidden !important;
}

.gate {
    --box: min(44px, calc((100vw - 32px - 7 * 8px - 16px) / 8));
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: #000;
    color: #fff;
    text-align: center;
    transition: opacity 400ms var(--ease-out);
}

.gate.out {
    opacity: 0;
    pointer-events: none;
}

.gate-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: 100%;
    margin-bottom: 56px;
}

.gate-logo {
    height: 44px;
    min-width: 0;
}

.gate-tag {
    flex: none;
    padding: 4px 10px 5px;
    border: 1px solid var(--ink-3);
    border-radius: 999px;
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.08em;
    line-height: 1;
    text-transform: uppercase;
}

/* Eight boxes in two groups of four; the real input covers them all */
.gate-field {
    position: relative;
    display: flex;
    gap: 8px;
    cursor: text;
}

.gate-input {
    position: absolute;
    inset: 0;
    z-index: 3;
    width: 100%;
    border: 0;
    outline: none;
    background: none;
    color: transparent;
    caret-color: transparent;
    font-size: 16px; /* stops iOS zooming in on focus */
    opacity: 0;
}

.gate-box {
    position: relative;
    width: var(--box);
    height: calc(var(--box) * 1.3);
}

.gate-box:nth-of-type(4) {
    margin-right: 16px;
}

.gate-digit {
    position: relative;
    z-index: 2;
    display: block;
    font-size: calc(var(--box) * 0.75);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    line-height: calc(var(--box) * 1.1);
}

.gate-glow {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--line-glow);
    opacity: 0.18;
    transition: opacity 160ms var(--ease-out);
}

.gate-box.filled .gate-glow {
    opacity: 0.55;
}

.gate-box.caret .gate-glow {
    animation: gate-caret 1.1s ease-in-out infinite;
}

@keyframes gate-caret {
    50% { opacity: 0.6; }
}

.gate.busy .gate-field {
    opacity: 0.48;
    cursor: progress;
}

.gate-msg {
    min-height: 1.4em;
    margin-top: 24px;
    color: var(--ink-2);
    font-size: 15px;
    line-height: 1.4;
}

.gate-msg.warn {
    color: var(--warn);
}

.gate.shake .gate-field {
    animation: gate-shake 360ms var(--ease-out);
}

@keyframes gate-shake {
    20% { transform: translateX(-10px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
    .gate.shake .gate-field,
    .gate-box.caret .gate-glow {
        animation: none;
    }
}
