html,
.gate {
    background: #000;
}

html {
    scroll-padding: 0;
}

.gate {
    display: grid;
    place-items: center;
    min-height: 100vh;
    min-height: 100svh;
    padding: max(.75rem, env(safe-area-inset-top, 0px))
        max(1rem, env(safe-area-inset-right, 0px))
        max(.75rem, env(safe-area-inset-bottom, 0px))
        max(1rem, env(safe-area-inset-left, 0px));
}

.gate-content {
    display: grid;
    justify-items: center;
    gap: clamp(.625rem, 2.6svh, 1.25rem);
    width: 100%;
}

.gate-mark {
    display: block;
    width: min(58vw, 340px, 52vh);
    width: min(58vw, 340px, 52svh);
    height: auto;
    overflow: visible;
    fill: var(--accent);
}

.gate-mark__cutout {
    fill: #000;
}

.gate-title {
    margin: 0;
    line-height: 0;
}

.gate-name {
    display: block;
    width: min(58vw, 340px, 52vh);
    width: min(58vw, 340px, 52svh);
    height: auto;
    fill: var(--public-text);
}

.gate-form {
    --gate-error: #ffa5a0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .375rem .625rem;
    width: min(100%, 19.75rem); /* the drawn edges of the symbol at full size */
}

.gate-form label,
.gate-form::after,
.gate-form__error {
    grid-column: 1 / -1;
    font-size: var(--public-text-s);
}

.gate-form label {
    color: var(--public-muted);
}

.gate-form__password {
    min-width: 0;
    min-height: 2.75rem;
    padding: .5rem .75rem;
    border: 1px solid var(--public-field-line);
    border-radius: var(--public-radius-control);
    background: var(--public-card);
    color: var(--public-text);
    font: inherit;
}

.gate-form__submit {
    min-height: 2.75rem;
    padding-inline: 1rem;
}

.gate-form :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.gate-form__password[aria-invalid="true"] {
    border-color: var(--gate-error);
}

.gate-form::after,
.gate-form__error {
    grid-area: 3 / 1 / 4 / -1;
}

.gate-form::after {
    content: attr(data-rate-limit-error);
    visibility: hidden;
}

.gate-form__error {
    margin: 0;
    color: var(--gate-error);
    opacity: 0;
    transition: opacity .18s ease-out;
}

.gate-form__error.is-visible { opacity: 1; }

.gate--intro {
    --gate-travel: 62;
    --gate-fade-ease: cubic-bezier(.33, 1, .68, 1);
    --gate-block-ease: ease-out;
    --gate-rise-ease: ease-out;
}

@supports (animation-timing-function: linear(0, 1)) {
    .gate--intro {
        /* One sample every 5% across 1.5 periods, with damping ratios .86 and 1. */
        --gate-block-ease: linear(
            0, .084753, .259169, .447395, .613641, .745278, .841861, .908429, .951707, .978164, .99319,
            1.000888, 1.004178, 1.005017, 1.00464, 1.003779, 1.002832, 1.001988, 1.001315, 1.00082, 1
        );
        --gate-rise-ease: linear(
            0, .081611, .243092, .412893, .56196, .681899, .773552, .841241, .890034, .924574, .948684,
            .965325, .976705, .984429, .989637, .99313, .995461, .99701, .998036, .998713, 1
        );
    }
}

@media (prefers-reduced-motion: no-preference) {
    .gate-mark__c { --gate-x: -1; --gate-y: -1; --gate-delay: .40s; }
    .gate-mark__l { --gate-x: 1; --gate-y: -1; --gate-delay: .52s; }
    .gate-mark__u { --gate-x: -1; --gate-y: 1; --gate-delay: .64s; }
    .gate-mark__b { --gate-x: 1; --gate-y: 1; --gate-delay: .76s; }

    .gate--intro .gate-mark > :is(path, .gate-mark__b) {
        animation: gate-block .825s var(--gate-block-ease) var(--gate-delay) backwards,
            gate-fade .30s var(--gate-fade-ease) var(--gate-delay) backwards;
    }

    .gate--intro .gate-name {
        --gate-delay: 1.35s;
        --gate-rise: 14px;
        animation: gate-rise .975s var(--gate-rise-ease) var(--gate-delay) backwards,
            gate-fade .50s var(--gate-fade-ease) var(--gate-delay) backwards;
    }

    .gate--intro .gate-form {
        --gate-rise: 10px;
        --gate-delay: 2.08s;
        animation: gate-rise .90s var(--gate-rise-ease) var(--gate-delay) backwards,
            gate-fade .45s var(--gate-fade-ease) var(--gate-delay) backwards,
            gate-ready 0s var(--gate-delay) backwards;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gate--intro .gate-content {
        animation: gate-fade .50s var(--gate-fade-ease) .10s backwards;
    }
}

@media (forced-colors: active) {
    .gate-mark, .gate-name { fill: CanvasText; }
    .gate-mark { forced-color-adjust: none; }
    .gate-mark__cutout { fill: Canvas; }
    .gate-form :focus-visible { outline-color: Highlight; }
}

@keyframes gate-block {
    from {
        transform: translate(
            calc(var(--gate-travel) * var(--gate-x) * 1px),
            calc(var(--gate-travel) * var(--gate-y) * 1px)
        );
    }
    to { transform: translate(0, 0); }
}

@keyframes gate-rise {
    from { transform: translateY(var(--gate-rise)); }
    to { transform: translateY(0); }
}

@keyframes gate-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes gate-ready {
    from { visibility: hidden; }
    to { visibility: visible; }
}

.gate--leaving { contain: paint; }
.gate--leaving .gate-content { pointer-events: none; }

@media (prefers-reduced-motion: no-preference) {
    .gate--leaving .gate-name { animation: none; }

    .gate--leaving :is(.gate-title, .gate-form) {
        animation: gate-hide .19s var(--public-ease-out) .155s both;
    }

    .gate--leaving { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
    .gate--leaving .gate-content { animation: gate-hide .3s ease-out both; }
}

@keyframes gate-hide {
    from { opacity: 1; }
    to { opacity: 0; }
}
