/* ============================================================================
   Login page

   Consumes shared/css/tokens.css. Keeps the brand identity — the warm canvas,
   the gold radial tint, and one deliberate flourish: a gold arc travelling the
   panel border.

   Toned down from the previous version, matching the app-wide decision: the
   cursor-follow glow, the scanline sweep, the two floating zone rings and the
   drifting grid are gone. What remains is a single faint static grid. Their
   markup has been removed from login.php too, so no dead DOM is left behind.
   ========================================================================== */

@property --border-angle {
    syntax: "<angle>";
    inherits: false;
    initial-value: 0deg;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    min-height: 100%;
    background: var(--canvas);
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    color: var(--ink-900);
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: var(--lh-base);
    background: var(--canvas-bg);
}

/* ---------------------------------------------------------------- backdrop */

.login-background,
.login-grid {
    position: fixed;
    inset: 0;
    pointer-events: none;
}

.login-background {
    z-index: var(--z-ambient);
    overflow: hidden;
}

.login-grid {
    background-image:
        linear-gradient(var(--ambient-grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--ambient-grid-line) 1px, transparent 1px);
    background-size: var(--ambient-grid-size) var(--ambient-grid-size);
    mask-image: radial-gradient(circle at center, black 0%, black 58%, transparent 92%);
}

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

.login-shell {
    position: relative;
    z-index: var(--z-base);
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: clamp(1rem, 3vw, 2.5rem);
}

.login-container {
    position: relative;
    --border-angle: 0deg;
    width: min(100%, 27rem);
    padding: clamp(1.75rem, 4vw, 2.5rem) clamp(1.25rem, 3.5vw, 2.25rem) clamp(1.25rem, 3vw, 1.75rem);
    overflow: hidden;
    border: 1px solid var(--ink-100);
    border-radius: var(--r-xl);
    background: var(--surface);
    box-shadow: var(--sh-lg);
    animation: panelEnter 600ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* the one flourish: a gold arc travelling the border */
.login-container::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    padding: 2px;
    border-radius: inherit;
    background:
        conic-gradient(
            from var(--border-angle),
            rgba(252, 196, 12, 0) 0deg,
            rgba(252, 196, 12, 0) 54deg,
            rgba(252, 196, 12, 0.92) 78deg,
            rgba(44, 44, 44, 0.42) 98deg,
            rgba(252, 196, 12, 0) 128deg,
            rgba(252, 196, 12, 0) 360deg
        );
    mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    mask-composite: exclude;
    pointer-events: none;
    animation: borderOrbit 7s linear infinite;
}

.login-container > * {
    position: relative;
    z-index: var(--z-base);
}

/* ------------------------------------------------------------------ header */

.login-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: clamp(1.25rem, 3vw, 1.75rem);
}

.login-logo-tilt {
    position: relative;
    display: block;
    width: min(100%, 18rem);
    border-radius: var(--r-lg);
}

.login-logo-media {
    position: relative;
    z-index: var(--z-base);
    display: block;
    width: 100%;
    height: auto;
    border-radius: inherit;
    object-fit: contain;
}

/* the mark carries the wordmark; the text duplicates would be redundant */
.login-title,
.login-subtitle {
    display: none;
}

/* ------------------------------------------------------------------- form */

.login-form {
    display: flex;
    flex-direction: column;
    gap: var(--s5);
}

.login-error {
    display: none;
    margin-bottom: var(--s6);
    padding: var(--s5) var(--s6);
    border: 1px solid var(--bad-bd);
    border-radius: var(--r-lg);
    color: var(--bad-700);
    background: var(--bad-bg);
    font-size: var(--fs-body);
    line-height: var(--lh-base);
}

.login-error.show {
    display: block;
}

.ms-button {
    display: flex;
    width: 100%;
    min-height: 2.75rem;
    align-items: center;
    justify-content: center;
    gap: var(--s4);
    border: 1px solid var(--ink-900);
    border-radius: var(--r-lg);
    color: var(--surface);
    background: var(--ink-800);
    cursor: pointer;
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
    text-decoration: none;
    transition:
        background var(--dur-base) var(--ease),
        box-shadow var(--dur-base) var(--ease),
        transform var(--dur-base) var(--ease);
}

.ms-button:hover {
    background: var(--ink-900);
    box-shadow: var(--sh-md), inset 0 0 0 1px var(--gold-400);
    transform: translateY(-1px);
}

.ms-button:active {
    transform: translateY(0) scale(0.99);
}

.ms-button:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

.ms-button.disabled {
    color: var(--ink-400);
    background: var(--ink-100);
    border-color: var(--ink-200);
    box-shadow: none;
    cursor: not-allowed;
    pointer-events: none;
}

.ms-icon {
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
}

.login-footer {
    margin-top: clamp(1.25rem, 3vw, 1.75rem);
    color: var(--ink-500);
    font-size: var(--fs-micro);
    line-height: var(--lh-base);
    text-align: center;
}

/* -------------------------------------------------------------- animation */

@keyframes panelEnter {
    from {
        opacity: 0;
        transform: translateY(1rem) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes borderOrbit {
    to {
        --border-angle: 360deg;
    }
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 560px) {
    .login-shell {
        align-items: stretch;
        padding: var(--s6);
    }

    .login-container {
        display: flex;
        min-height: calc(100vh - 2rem);
        flex-direction: column;
        justify-content: center;
    }

    .login-logo-tilt {
        width: min(100%, 15rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }

    .login-container::before {
        animation: none !important;
        background: linear-gradient(90deg, transparent, var(--gold-400), transparent);
    }
}
