/* ==========================================================================
   KlassIT — sign-in / first-run screen
   Standalone: this page does not load Bootstrap, so everything here is
   self-contained on top of the tokens in style.css.
   ========================================================================== */

.auth-body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--brand-900);
    overflow-x: hidden;
}

.auth {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Grid items default to min-width:auto, so their min-content size can push the
   column wider than the viewport — which pushed the card and the legal line off
   the right edge on narrow screens. */
.auth__brand,
.auth__panel {
    min-width: 0;
}

/* --------------------------------------------------------------------------
   Brand panel
   -------------------------------------------------------------------------- */

.auth__brand {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(2rem, 4vw, 3.75rem);
    overflow: hidden;
    background: linear-gradient(155deg, #2b4f31 0%, #1d3522 48%, #16281a 100%);
    isolation: isolate;
}

/* Drifting aurora blobs */
.aurora {
    position: absolute;
    inset: -20%;
    z-index: -2;
    filter: blur(64px);
    opacity: 0.95;
    /* Eases the pointer parallax in login.js, and the glide back on pointerleave */
    transition: transform 700ms var(--ease-out);
}

.aurora__blob {
    position: absolute;
    display: block;
    border-radius: 50%;
    mix-blend-mode: screen;
    will-change: transform;
}

.aurora__blob--1 {
    width: 46%;
    padding-bottom: 46%;
    left: 4%;
    top: 8%;
    background: radial-gradient(circle, rgba(122, 196, 134, 0.95), transparent 66%);
    animation: drift1 19s var(--ease) infinite alternate;
}

.aurora__blob--2 {
    width: 40%;
    padding-bottom: 40%;
    right: 2%;
    top: 34%;
    background: radial-gradient(circle, rgba(214, 178, 126, 0.8), transparent 66%);
    animation: drift2 24s var(--ease) infinite alternate;
}

.aurora__blob--3 {
    width: 52%;
    padding-bottom: 52%;
    left: 22%;
    bottom: -8%;
    background: radial-gradient(circle, rgba(78, 140, 88, 1), transparent 68%);
    animation: drift3 21s var(--ease) infinite alternate;
}

@keyframes drift1 {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to   { transform: translate3d(16%, 12%, 0) scale(1.18); }
}

@keyframes drift2 {
    from { transform: translate3d(0, 0, 0) scale(1.1); }
    to   { transform: translate3d(-14%, -16%, 0) scale(0.92); }
}

@keyframes drift3 {
    from { transform: translate3d(0, 0, 0) scale(0.95); }
    to   { transform: translate3d(10%, -12%, 0) scale(1.2); }
}

/* Faint engraved grid over the gradient */
.auth__grid {
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
    background-size: 62px 62px;
    -webkit-mask-image: radial-gradient(ellipse 78% 62% at 40% 42%, #000 35%, transparent 78%);
    mask-image: radial-gradient(ellipse 78% 62% at 40% 42%, #000 35%, transparent 78%);
}

.auth__brand-inner {
    position: relative;
    max-width: 34rem;
    margin-block: auto;
}

/* Drifting motes over the gradient — slow, low-contrast, never crossing into the
   text. Positions come from fixed inline custom properties in login.php. */
.motes {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.motes span {
    position: absolute;
    left: var(--left);
    bottom: -6%;
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.9), rgba(212, 190, 150, 0.35) 60%, transparent 70%);
    opacity: 0;
    animation: moteRise var(--duration) linear var(--delay) infinite;
    will-change: transform, opacity;
}

@keyframes moteRise {
    0%   { transform: translate3d(0, 0, 0) scale(0.5); opacity: 0; }
    12%  { opacity: 0.55; }
    88%  { opacity: 0.5; }
    100% { transform: translate3d(var(--drift), -108vh, 0) scale(1.1); opacity: 0; }
}

.auth__tagline {
    font-size: clamp(1.9rem, 1.1rem + 2.3vw, 3.05rem);
    line-height: 1.12;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: #fff;
    margin: 0 0 2.25rem;
    animation: authIn 900ms var(--ease-out) 120ms both;
}

/* Slow highlight travelling across the gold half of the headline */
.auth__tagline em {
    font-style: normal;
    background: linear-gradient(100deg, var(--gold-400) 0%, var(--gold-300) 25%, #fff6e6 45%, var(--gold-300) 62%, var(--gold-400) 100%);
    background-size: 220% 100%;
    background-position: 120% 0;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: taglineSheen 9s var(--ease) 1.2s infinite;
}

@keyframes taglineSheen {
    0%   { background-position: 120% 0; }
    55%  { background-position: -60% 0; }
    100% { background-position: -60% 0; }
}

.auth__subtitle {
    max-width: 30rem;
    margin: -1.35rem 0 2.15rem;
    font-size: 1.02rem;
    line-height: 1.6;
    color: #fff;
    animation: authIn 900ms var(--ease-out) 200ms both;
}

.auth__features {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 1.05rem;
}

.auth__features li {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
    animation: authIn 800ms var(--ease-out) both;
}

.auth__features li:nth-child(1) { animation-delay: 280ms; }
.auth__features li:nth-child(2) { animation-delay: 380ms; }
.auth__features li:nth-child(3) { animation-delay: 480ms; }

.auth__feature-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    color: var(--gold-300);
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: transform var(--dur) var(--ease-spring), background-color var(--dur) var(--ease);
}

.auth__features li:hover .auth__feature-icon {
    transform: translateY(-2px) scale(1.06);
    background: rgba(255, 255, 255, 0.12);
}

.auth__feature-icon svg {
    width: 18px;
    height: 18px;
}

.auth__features div {
    display: flex;
    flex-direction: column;
    line-height: 1.35;
}

.auth__features strong {
    font-size: 0.945rem;
    font-weight: 650;
    color: #fff;
}

.auth__features span {
    font-size: 0.845rem;
    color: rgba(255, 255, 255, 0.58);
}

.auth__brand-footer {
    position: relative;
    margin: 0;
    max-width: 34rem;
    font-size: 0.79rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.5);
    animation: fadeIn 1s var(--ease) 700ms both;
}

.auth__brand-footer strong {
    font-weight: 650;
    color: rgba(255, 255, 255, 0.78);
}

.auth__brand-version {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.15em 0.55em;
    border-radius: 99px;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.09);
    border: 1px solid rgba(255, 255, 255, 0.14);
}

@keyframes authIn {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Form panel
   -------------------------------------------------------------------------- */

.auth__panel {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    padding: clamp(1.75rem, 4vw, 3.5rem);
    background: var(--page);
    background-image:
        radial-gradient(40rem 30rem at 90% 0%, rgba(60, 107, 65, 0.09), transparent 60%),
        radial-gradient(34rem 26rem at 0% 100%, rgba(176, 141, 87, 0.10), transparent 62%);
}

/* The halo is positioned, so these need a stacking position of their own to stay
   in front of it. */
.auth__logo,
.auth__card,
.auth__legal {
    position: relative;
    z-index: 1;
}

/* Sits on the light panel, so it keeps its own colours with nothing behind it. */
.auth__logo {
    display: block;
    height: clamp(64px, 7.5vw, 96px);
    width: auto;
    animation:
        authIn 900ms var(--ease-out) both,
        logoFloat 7s ease-in-out 1s infinite;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-7px); }
}

.auth__card {
    position: relative;
    width: min(26.5rem, 100%);
    background: rgba(255, 255, 255, 0.86);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    backdrop-filter: blur(18px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: clamp(1.6rem, 3vw, 2.35rem);
    animation: authIn 800ms var(--ease-out) 100ms both;
}

/* Slow breathing halo behind the sign-in card.
   This is a sibling element rather than .auth__card::before because the card uses
   backdrop-filter, which creates a stacking context — a z-index:-1 pseudo-element
   would be trapped inside it and paint over the card's own background. */
.auth__halo {
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(34rem, 92%);
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(60, 107, 65, 0.16), transparent 66%);
    filter: blur(30px);
    pointer-events: none;
    z-index: 0;
    animation: haloBreathe 11s ease-in-out infinite;
}

@keyframes haloBreathe {
    0%, 100% { transform: translate(-50%, -50%) scale(0.94); opacity: 0.5; }
    50%      { transform: translate(-50%, -50%) scale(1.06); opacity: 0.85; }
}

/* Card shudders once when the server rejects the submission */
[data-shake="1"] .auth__card {
    animation: authIn 800ms var(--ease-out) 100ms both, shake 520ms var(--ease) 160ms;
}

@keyframes shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-7px); }
    40%, 60% { transform: translateX(7px); }
}

.auth__head {
    margin-bottom: 1.5rem;
}

.auth__pill {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--brand-700);
    background: var(--brand-50);
    border: 1px solid var(--brand-200);
    border-radius: 99px;
    padding: 0.3em 0.75em;
    margin-bottom: 0.85rem;
}

.auth__head h2 {
    font-size: 1.72rem;
    font-weight: 800;
    letter-spacing: -0.032em;
    margin: 0 0 0.35rem;
    color: var(--ink-900);
}

.auth__head p {
    margin: 0;
    font-size: 0.925rem;
    line-height: 1.5;
    color: var(--ink-500);
}

.auth__alert {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.45;
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
    margin-bottom: 1.15rem;
    border: 1px solid transparent;
    animation: slideDown 380ms var(--ease-out) both;
}

.auth__alert svg {
    width: 17px;
    height: 17px;
    flex: none;
    margin-top: 1px;
}

.auth__alert--error {
    background: #fdecec;
    border-color: #f5c9c7;
    color: #9d2b28;
}

.auth__alert--ok {
    background: #e9f6ec;
    border-color: #bfe6ca;
    color: #1c6b30;
}

.auth__form {
    display: grid;
    gap: 1rem;
}

/* --- Floating-label field --- */

.field {
    position: relative;
    animation: authIn 700ms var(--ease-out) both;
    animation-delay: calc(var(--i, 1) * 70ms + 180ms);
}

.field__input {
    width: 100%;
    font: inherit;
    font-size: 0.945rem;
    color: var(--ink-900);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 1.45rem 0.95rem 0.6rem;
    outline: none;
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.field--with-toggle .field__input {
    padding-right: 3rem;
}

.field__input:hover:not(:focus) {
    border-color: var(--brand-200);
}

.field__input:focus {
    background: var(--surface);
    border-color: var(--brand-400);
    box-shadow: 0 0 0 4px rgba(60, 107, 65, 0.13);
}

.field__label {
    position: absolute;
    left: 0.98rem;
    top: 1.02rem;
    font-size: 0.945rem;
    color: var(--ink-400);
    pointer-events: none;
    transform-origin: left top;
    transition: transform 200ms var(--ease-out), color 200ms var(--ease);
}

/* Float the label when focused or filled (placeholder=" " makes :placeholder-shown work) */
.field__input:focus + .field__label,
.field__input:not(:placeholder-shown) + .field__label {
    transform: translateY(-0.72rem) scale(0.76);
    color: var(--brand-600);
}

.field__toggle {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--ink-400);
    cursor: pointer;
    transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.field__toggle:hover {
    color: var(--brand-600);
    background: var(--brand-50);
}

.field__toggle svg {
    width: 18px;
    height: 18px;
}

.field__toggle.is-off svg {
    opacity: 0.55;
}

.auth__hint {
    margin: -0.25rem 0 0;
    font-size: 0.815rem;
    line-height: 1.45;
    color: var(--ink-400);
    animation: authIn 700ms var(--ease-out) both;
    animation-delay: calc(var(--i, 1) * 70ms + 180ms);
}

/* --- Submit --- */

.auth__submit {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    width: 100%;
    margin-top: 0.35rem;
    font: inherit;
    font-size: 0.965rem;
    font-weight: 700;
    letter-spacing: -0.005em;
    color: #fff;
    background: linear-gradient(180deg, var(--brand-500), var(--brand-700));
    border: 0;
    border-radius: 13px;
    padding: 0.88rem 1.25rem;
    cursor: pointer;
    overflow: hidden;
    box-shadow: var(--shadow-brand);
    transition: transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease), filter var(--dur) var(--ease);
    animation: authIn 700ms var(--ease-out) both;
    animation-delay: calc(var(--i, 1) * 70ms + 180ms);
}

/* Sheen that sweeps across on hover */
.auth__submit::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.3) 50%, transparent 80%);
    transform: translateX(-100%);
    transition: transform 700ms var(--ease-out);
}

.auth__submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(60, 107, 65, 0.3), 0 20px 44px rgba(60, 107, 65, 0.24);
}

.auth__submit:hover::after {
    transform: translateX(100%);
}

.auth__submit:active {
    transform: translateY(0) scale(0.99);
}

.auth__submit:disabled {
    cursor: progress;
    filter: saturate(0.75);
}

.auth__spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 620ms linear infinite;
}

.auth__submit.is-loading .auth__spinner {
    display: block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.auth__legal {
    margin: 0;
    font-size: 0.8rem;
    color: var(--ink-400);
    animation: fadeIn 900ms var(--ease) 600ms both;
}

/* --------------------------------------------------------------------------
   Responsive — brand panel becomes a compact header above the form
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
    .auth {
        grid-template-columns: 1fr;
    }

    .auth__brand {
        padding: 2rem 1.5rem 2.25rem;
        min-height: 12rem;
    }

    .auth__brand-inner {
        margin-block: 0;
    }

    .auth__logo {
        height: 52px;
    }

    .auth__features,
    .auth__brand-footer,
    .auth__subtitle {
        display: none;
    }

    .auth__tagline {
        margin-bottom: 0;
    }

    .auth__panel {
        padding: 2rem 1.25rem 3rem;
    }
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .aurora__blob,
    .auth__halo {
        animation: none !important;
    }

    .auth__halo {
        transform: translate(-50%, -50%);
    }

    /* Motes are pure decoration — remove them rather than freezing them mid-rise. */
    .motes {
        display: none !important;
    }

    .auth__tagline em {
        animation: none !important;
        background-position: 0 0;
    }

    .auth__logo,
    .auth__tagline,
    .auth__subtitle,
    .auth__features li,
    .auth__card,
    .field,
    .auth__hint,
    .auth__submit,
    .auth__legal,
    .auth__alert {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }

    .auth__submit:hover,
    .auth__feature-icon {
        transform: none !important;
    }
}
