/*
 * Écrans de connexion (/login, /login/magic-link, /login/totp).
 * Feuille autonome, chargée par l’entrée `auth` : panneau de marque (logo 3D en verre)
 * à gauche, formulaire à droite ; sur mobile, bandeau de marque en haut et feuille par-dessus.
 * Les composants du kit (Input, Button, Alert, InputOtp…) sont restylés ici :
 * ces règles ne sont pas dans un @layer, elles passent donc devant les utilitaires Tailwind.
 */

/* ------------------------------------------------------------------ Tokens */
.aky-auth {
    --aky-ink: #0b0c10;
    --aky-paper: #f3f2ef;
    --aky-night: #060b33;
    --aky-navy: #000f9f;
    --aky-blue: #3d6bff;
    --aky-violet: #b13dff;
    --aky-pink: #ff2d8a;
    --aky-orange: #ff9a3d;
    --aky-danger: #b3124f;
    --aky-muted: rgba(11, 12, 16, .62);
    --aky-line: rgba(11, 12, 16, .14);
    --aky-display: 'Bricolage Grotesque', 'Manrope', ui-sans-serif, system-ui, sans-serif;
    --aky-ease: cubic-bezier(.16, 1, .3, 1);
    --aky-field-h: 54px;
    --aky-gutter: 16px;

    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
    min-height: 100dvh;
    padding: var(--aky-gutter);
    background: var(--aky-paper);
    color: var(--aky-ink);
    font-family: 'Manrope', ui-sans-serif, system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.aky-auth *,
.aky-auth *::before,
.aky-auth *::after {
    box-sizing: border-box;
}

.aky-auth :where(h1, h2, p, ol, ul) {
    margin: 0;
}

.aky-auth :where(ol, ul) {
    padding: 0;
    list-style: none;
}

.aky-auth :where(h1, h2) {
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    letter-spacing: inherit;
}

.aky-auth :where(a) {
    color: inherit;
    text-decoration: none;
}

.aky-auth ::selection {
    background: var(--aky-violet);
    color: #ffffff;
}

.aky-auth :where(a, button, input):focus-visible {
    outline: 2px solid var(--aky-blue);
    outline-offset: 3px;
}

/* ------------------------------------------------------------ Brand panel */
.aky-auth__brand {
    position: sticky;
    top: var(--aky-gutter);
    height: calc(100dvh - var(--aky-gutter) * 2);
    min-height: 560px;
    overflow: hidden;
    isolation: isolate;
    border-radius: 32px;
    background:
        radial-gradient(60% 50% at 15% 85%, #1c3dff 0%, transparent 70%),
        radial-gradient(50% 45% at 55% 95%, #b13dff 0%, transparent 70%),
        radial-gradient(45% 40% at 90% 70%, #ff2d8a 0%, transparent 70%),
        radial-gradient(60% 45% at 30% 0%, #000f9f 0%, transparent 70%),
        var(--aky-night);
    color: #ffffff;
    animation: aky-auth-in .8s var(--aky-ease) both;
}

.aky-auth__scene {
    position: absolute;
    inset: 0;
    z-index: -2;
    display: block;
    width: 100%;
    height: 100%;
}

.aky-auth__veil {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(6, 11, 51, .5) 0%, rgba(6, 11, 51, 0) 32%, rgba(6, 11, 51, 0) 55%, rgba(6, 11, 51, .55) 100%);
}

.aky-auth__cap {
    position: absolute;
    top: 28px;
    left: 28px;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    height: 48px;
    padding: 0 18px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 24px;
    background: rgba(255, 255, 255, .08);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    font-size: 14px;
    font-weight: 700;
    transition: background-color .25s;
}

.aky-auth__cap:hover {
    background: rgba(255, 255, 255, .16);
}

.aky-auth__logo {
    width: 66px;
}

.aky-auth__sep {
    width: 1px;
    height: 14px;
    background: rgba(255, 255, 255, .32);
}

.aky-auth__statement {
    position: absolute;
    right: 48px;
    bottom: 48px;
    left: 48px;
    font-family: var(--aky-display);
    font-size: clamp(40px, 4.45vw, 76px);
    font-weight: 750;
    font-variation-settings: 'opsz' 96;
    line-height: 1;
    letter-spacing: -.045em;
}

.aky-auth__statement > span {
    display: block;
}

.aky-auth__words {
    height: 1em;
    overflow: hidden;
}

.aky-auth__reel {
    display: flex;
    flex-direction: column;
    animation: aky-auth-words 10s cubic-bezier(.7, 0, .3, 1) infinite;
}

.aky-auth__word {
    height: 1em;
    white-space: nowrap;
}

.aky-auth__word--blue { color: #b9c9ff; }
.aky-auth__word--violet { color: #dcb0ff; }
.aky-auth__word--pink { color: #ffa8cd; }
.aky-auth__word--orange { color: #ffc999; }

.aky-auth__light {
    font-weight: 300;
    color: rgba(255, 255, 255, .78);
}

/* ------------------------------------------------------------ Form column */
.aky-auth__main {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-width: 0;
    padding: 24px clamp(24px, 5vw, 96px) 16px;
}

.aky-auth__top {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    font-size: 14px;
    color: var(--aky-muted);
    animation: aky-auth-in .7s var(--aky-ease) .1s both;
}

.aky-auth__ghost {
    display: inline-flex;
    align-items: center;
    height: 40px;
    padding: 0 16px;
    border: 1px solid var(--aky-line);
    border-radius: 20px;
    font-weight: 700;
    color: var(--aky-ink);
    transition: background-color .2s, border-color .2s;
}

.aky-auth__ghost:hover {
    border-color: rgba(11, 12, 16, .3);
    background: #ffffff;
}

.aky-auth__panel {
    align-self: center;
    justify-self: center;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 420px;
    padding: 40px 0;
    animation: aky-auth-view .6s var(--aky-ease) .15s both;
}

.aky-auth__badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin-bottom: 28px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--aky-blue), var(--aky-violet) 55%, var(--aky-pink));
    color: #ffffff;
    box-shadow: 0 18px 36px -18px rgba(11, 12, 16, .45);
    animation: aky-auth-pop .5s cubic-bezier(.3, 1.5, .5, 1) .25s both;
}

.aky-auth__badge svg {
    width: 28px;
    height: 28px;
}

.aky-auth__title {
    font-family: var(--aky-display);
    font-size: clamp(40px, 3.9vw, 56px);
    font-weight: 750;
    font-variation-settings: 'opsz' 96;
    line-height: 1.02;
    letter-spacing: -.045em;
    text-wrap: balance;
}

.aky-auth__subtitle {
    margin-top: 14px;
    font-size: 17px;
    line-height: 1.55;
    color: var(--aky-muted);
    text-wrap: pretty;
}

.aky-auth__subtitle strong {
    font-weight: 700;
    color: var(--aky-ink);
    overflow-wrap: anywhere;
}

.aky-auth__body {
    display: flex;
    flex-direction: column;
    margin-top: 32px;
}

.aky-auth__form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.aky-auth__footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    font-size: 12.5px;
    color: rgba(11, 12, 16, .45);
}

/* ---------------------------------------------------------------- Fields */
.aky-auth [data-slot='field'] {
    gap: 8px;
    color: inherit;
}

.aky-auth [data-slot='field-label'] {
    font-size: 13px;
    font-weight: 700;
    color: rgba(11, 12, 16, .75);
}

.aky-auth__control {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--aky-field-h);
    padding: 0 16px;
    border: 1.5px solid var(--aky-line);
    border-radius: 14px;
    background: #ffffff;
    transition: border-color .2s, box-shadow .2s;
}

.aky-auth__control:hover {
    border-color: rgba(11, 12, 16, .28);
}

.aky-auth__control:focus-within {
    border-color: var(--aky-ink);
    box-shadow: 0 0 0 4px rgba(61, 107, 255, .16);
}

.aky-auth__control:has([aria-invalid='true']) {
    border-color: var(--aky-danger);
    box-shadow: 0 0 0 4px rgba(179, 18, 79, .1);
    animation: aky-auth-shake .4s ease;
}

.aky-auth__control:has(.aky-password-input) {
    padding-right: 5px;
}

.aky-auth__lead {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: rgba(11, 12, 16, .4);
}

.aky-auth__control [data-slot='input'] {
    flex: 1;
    height: 100%;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    outline: 0;
    color: var(--aky-ink);
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    caret-color: var(--aky-pink);
}

.aky-auth__control [data-slot='input']::placeholder {
    color: rgba(11, 12, 16, .36);
    font-weight: 500;
}

.aky-auth__control [data-slot='input']:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 40px #ffffff inset;
    -webkit-text-fill-color: var(--aky-ink);
}

/* Le bouton œil du kit est positionné en absolu dans son conteneur. */
.aky-auth__control [data-controller='password-toggle'] {
    display: flex;
    flex: 1;
    align-self: stretch;
    min-width: 0;
}

.aky-auth__control .aky-password-input {
    padding-inline-end: 48px;
}

.aky-auth__control [data-password-toggle-target='button'] {
    top: 50%;
    right: 0;
    bottom: auto;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: rgba(11, 12, 16, .55);
    cursor: pointer;
    transform: translateY(-50%);
    transition: background-color .2s, color .2s;
}

.aky-auth__control [data-password-toggle-target='button']:hover {
    background: rgba(11, 12, 16, .06);
    color: var(--aky-ink);
}

.aky-auth__control [data-password-toggle-target='button'] svg {
    width: 18px;
    height: 18px;
}

.aky-auth [data-slot='field-error'] {
    font-size: 13px;
    font-weight: 600;
    color: var(--aky-danger);
}

/* --------------------------------------------------------------- Buttons */
.aky-auth .aky-auth__submit,
.aky-auth .aky-auth__alt {
    width: 100%;
    height: var(--aky-field-h);
    gap: 10px;
    border-radius: 14px;
    font-family: inherit;
    transition: background-color .25s, border-color .2s, transform .2s, opacity .2s;
}

.aky-auth .aky-auth__submit {
    margin-top: 4px;
    border: 0;
    background: var(--aky-ink);
    color: #ffffff;
    font-size: 16px;
    font-weight: 800;
}

.aky-auth .aky-auth__submit:hover {
    background: var(--aky-navy);
}

.aky-auth .aky-auth__submit:active,
.aky-auth .aky-auth__alt:active {
    transform: scale(.99);
}

.aky-auth .aky-auth__submit svg,
.aky-auth .aky-auth__alt svg {
    width: 18px;
    height: 18px;
}

.aky-auth .aky-auth__alt {
    border: 1.5px solid var(--aky-line);
    background: rgba(255, 255, 255, .55);
    color: var(--aky-ink);
    font-size: 15px;
    font-weight: 700;
}

.aky-auth .aky-auth__alt:hover {
    border-color: rgba(11, 12, 16, .3);
    background: #ffffff;
}

.aky-auth .aky-auth__alt:disabled {
    opacity: .55;
}

.aky-auth__alt-icon {
    color: var(--aky-violet);
}

.aky-auth__divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 22px 0;
    font-size: 13px;
    font-weight: 600;
    color: rgba(11, 12, 16, .45);
}

.aky-auth__divider::before,
.aky-auth__divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(11, 12, 16, .1);
}

.aky-auth__hint {
    margin-top: 14px;
    font-size: 13px;
    line-height: 1.5;
    color: rgba(11, 12, 16, .55);
}

.aky-auth__links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 22px;
    margin-top: 22px;
}

.aky-auth__links a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: rgba(11, 12, 16, .65);
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 3px;
    transition: color .2s, text-decoration-color .2s;
}

.aky-auth__links a:hover {
    color: var(--aky-ink);
    text-decoration-color: currentColor;
}

.aky-auth__links svg {
    width: 15px;
    height: 15px;
}

/* ----------------------------------------------------------------- Alert */
.aky-auth .aky-auth__alert {
    margin-bottom: 22px;
    padding: 12px 14px;
    border: 0;
    border-radius: 12px;
    background: #ffe6ef;
    color: #8f0f40;
    font-size: 14px;
    line-height: 1.45;
    animation: aky-auth-view .45s var(--aky-ease) both;
}

.aky-auth .aky-auth__alert > svg {
    width: 18px;
    height: 18px;
}

.aky-auth .aky-auth__alert [data-slot='alert-title'] {
    font-weight: 800;
}

.aky-auth .aky-auth__alert [data-slot='alert-description'] {
    color: #8f0f40;
    font-weight: 600;
}

/* -------------------------------------------------------- Magic link sent */
.aky-auth__steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
    padding: 16px;
    border: 1px solid rgba(11, 12, 16, .08);
    border-radius: 16px;
    background: #ffffff;
}

.aky-auth__steps li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.45;
    color: rgba(11, 12, 16, .75);
}

.aky-auth__step {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 800;
}

.aky-auth__step--blue { background: #e6ecff; color: #2342c9; }
.aky-auth__step--violet { background: #f3e6ff; color: #7a22c2; }

/* ------------------------------------------------------------------ TOTP */
.aky-auth__setup {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 26px;
    padding: 16px;
    border: 1px solid rgba(11, 12, 16, .08);
    border-radius: 18px;
    background: #ffffff;
}

.aky-auth__qr {
    flex-shrink: 0;
    width: 132px;
    height: 132px;
    padding: 6px;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(11, 12, 16, .08);
}

.aky-auth__setup-text {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    font-size: 13.5px;
    line-height: 1.5;
    color: rgba(11, 12, 16, .72);
}

.aky-auth__setup-text strong {
    color: var(--aky-ink);
    font-weight: 800;
}

.aky-auth__key {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 4px 4px 12px;
    border-radius: 10px;
    background: var(--aky-paper);
}

.aky-auth__key code {
    flex: 1;
    min-width: 0;
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--aky-ink);
    overflow-wrap: anywhere;
}

.aky-auth__copy {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    background: #ffffff;
    color: var(--aky-ink);
    font: inherit;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color .2s;
}

.aky-auth__copy:hover {
    background: rgba(255, 255, 255, .6);
}

.aky-auth__copy svg {
    width: 15px;
    height: 15px;
}

.aky-auth .aky-auth__otp [data-slot='input-otp-group'] {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 56px));
    gap: 10px;
}

.aky-auth .aky-auth__otp [data-slot='input-otp-slot'] {
    width: 100%;
    height: auto;
    aspect-ratio: 56 / 66;
    border: 1.5px solid var(--aky-line);
    border-radius: 16px;
    background: #ffffff;
    box-shadow: none;
    color: var(--aky-ink);
    font-family: inherit;
    font-size: 28px;
    font-weight: 800;
    caret-color: var(--aky-pink);
    transition: border-color .2s, box-shadow .2s;
}

.aky-auth .aky-auth__otp [data-slot='input-otp-slot']:focus {
    border-color: var(--aky-ink);
    box-shadow: 0 0 0 4px rgba(177, 61, 255, .16);
    outline: 0;
}

.aky-auth .aky-auth__otp [data-slot='input-otp-slot'][aria-invalid='true'] {
    border-color: var(--aky-danger);
}

/* ------------------------------------------------------- Fallback & motion */
.aky-auth.is-nogl .aky-auth__scene {
    display: none;
}

.aky-auth.is-nogl .aky-auth__brand::after {
    content: '';
    position: absolute;
    top: 14%;
    left: 20%;
    z-index: -1;
    width: 92%;
    aspect-ratio: 150 / 38;
    background: linear-gradient(160deg, rgba(255, 255, 255, .32), rgba(255, 255, 255, .06) 55%, rgba(255, 255, 255, .16));
    -webkit-mask: var(--aky-auth-logo) center / contain no-repeat;
    mask: var(--aky-auth-logo) center / contain no-repeat;
    transform: rotate(-8deg);
}

@keyframes aky-auth-words {
    0%, 20% { transform: translateY(0); }
    25%, 45% { transform: translateY(-25%); }
    50%, 70% { transform: translateY(-50%); }
    75%, 95% { transform: translateY(-75%); }
    100% { transform: translateY(0); }
}

@keyframes aky-auth-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

@keyframes aky-auth-view {
    from { opacity: 0; transform: translateY(10px); filter: blur(4px); }
    to { opacity: 1; transform: none; filter: none; }
}

@keyframes aky-auth-pop {
    from { opacity: 0; transform: scale(.6); }
    to { opacity: 1; transform: none; }
}

@keyframes aky-auth-shake {
    0%, 100% { transform: none; }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

@media (prefers-reduced-motion: reduce) {
    .aky-auth *,
    .aky-auth *::before,
    .aky-auth *::after {
        animation: none !important;
        transition-duration: .01ms !important;
    }
}

/* ------------------------------------------------------------ Responsive */
@media (min-width: 1800px) {
    .aky-auth {
        --aky-gutter: 20px;
    }

    .aky-auth__panel {
        max-width: 460px;
    }
}

@media (max-width: 1023.98px) {
    .aky-auth {
        display: flex;
        flex-direction: column;
        padding: 0;
    }

    .aky-auth__brand {
        position: relative;
        top: 0;
        flex-shrink: 0;
        height: clamp(240px, 38svh, 380px);
        min-height: 0;
        border-radius: 0;
    }

    .aky-auth__cap {
        top: max(18px, env(safe-area-inset-top));
        left: 20px;
        height: 40px;
        padding: 0 14px;
        font-size: 13px;
    }

    .aky-auth__logo {
        width: 56px;
    }

    .aky-auth__statement {
        right: 24px;
        bottom: 52px;
        left: 24px;
        font-size: clamp(28px, 7.4vw, 48px);
    }

    .aky-auth__main {
        position: relative;
        z-index: 1;
        flex: 1;
        display: flex;
        flex-direction: column;
        margin-top: -28px;
        padding: 8px 24px max(20px, env(safe-area-inset-bottom));
        border-radius: 28px 28px 0 0;
        background: var(--aky-paper);
    }

    .aky-auth__panel {
        flex: 1;
        justify-content: flex-start;
        padding: 28px 0 32px;
    }

    .aky-auth__top {
        order: 2;
        justify-content: center;
        padding-bottom: 20px;
    }

    .aky-auth__footer {
        order: 3;
        justify-content: center;
    }

    .aky-auth__title {
        font-size: clamp(34px, 9.6vw, 48px);
    }

    .aky-auth__subtitle {
        margin-top: 10px;
        font-size: 16px;
    }

    .aky-auth__body {
        margin-top: 26px;
    }

    .aky-auth__badge {
        width: 56px;
        height: 56px;
        margin-bottom: 20px;
        border-radius: 18px;
    }
}

@media (max-width: 479.98px) {
    .aky-auth__main {
        padding-right: 20px;
        padding-left: 20px;
    }

    .aky-auth__setup {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .aky-auth .aky-auth__otp [data-slot='input-otp-group'] {
        gap: 8px;
    }

    .aky-auth .aky-auth__otp [data-slot='input-otp-slot'] {
        border-radius: 14px;
        font-size: 24px;
    }

    .aky-auth__top {
        flex-direction: column;
        gap: 10px;
    }
}
