/* =========================================================
   auth.css — reusable authentication shell (login, forgot
   password, activation, ...). Pair with <x-auth-layout>.

   THEME
   Neutral dark surfaces + ONE accent. The accent is read from
   --accent (public/css/theme-project.css); every gold shade
   below is derived from it with color-mix(), so changing the
   theme changes this page — nothing here is hard-coded gold.

   LAYOUT
   >= 1025px : split screen — photo/brand panel + form panel.
   <= 1024px : full-bleed photo with a centered form card
               (phones and tablets, portrait and landscape).
   ========================================================= */

:root {
    /* accent (from the project theme) */
    --auth-accent: var(--accent, #b8860b);
    --auth-accent-light: color-mix(in srgb, var(--auth-accent) 68%, white);
    --auth-accent-soft: color-mix(in srgb, var(--auth-accent) 22%, transparent);
    --auth-accent-glow: color-mix(in srgb, var(--auth-accent) 40%, transparent);
    --auth-on-accent: #15120a;

    /* neutral surfaces */
    --auth-bg: #0c0c0c;
    --auth-surface: rgba(18, 18, 18, 0.8);
    --auth-field: #181818;
    --auth-field-focus: #1d1d1d;

    /* lines + text */
    --auth-border: rgba(255, 255, 255, 0.11);
    --auth-border-strong: rgba(255, 255, 255, 0.24);
    --auth-text: #f4f4f5;
    --auth-text-2: rgba(255, 255, 255, 0.7);
    --auth-text-3: rgba(255, 255, 255, 0.46);

    --auth-danger: #f87171;
    --auth-danger-soft: rgba(248, 113, 113, 0.12);

    --auth-radius: 14px;
    --auth-font: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- base ---------- */
.auth-body {
    margin: 0;
    background: var(--auth-bg);
    color: var(--auth-text);
    font-family: var(--auth-font);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

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

.auth-body button,
.auth-body input {
    font-family: inherit;
}

/* ---------- shell: split layout (desktop) ---------- */
.auth-shell {
    min-height: calc(100dvh - var(--env-banner-h, 0px));
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(420px, 1fr);
}

/* photo / brand panel */
.auth-hero {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: clamp(32px, 4vw, 56px);
}

.auth-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -2;
    background: var(--auth-bg-large) center / cover no-repeat;
}

/* the photo fades into the form panel's exact color: no seam */
.auth-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background:
        linear-gradient(
            90deg,
            rgba(12, 12, 12, 0.3) 0%,
            rgba(12, 12, 12, 0.55) 60%,
            var(--auth-bg) 100%
        ),
        linear-gradient(
            180deg,
            color-mix(in srgb, var(--auth-accent) 32%, transparent) 0%,
            transparent 45%,
            rgba(12, 12, 12, 0.8) 100%
        );
}

.auth-hero-logo {
    width: clamp(56px, 5vw, 76px);
    height: auto;
    display: block;
    margin-bottom: 20px;
}

.auth-hero-line {
    display: block;
    width: 48px;
    height: 4px;
    margin-bottom: 20px;
    border-radius: 4px;
    background: var(--auth-accent);
}

.auth-hero-title {
    margin: 0;
    max-width: 14ch;
    font-size: clamp(2rem, 3.6vw, 3.25rem);
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.5px;
    color: #fff;
    text-wrap: balance;
}

/* ---------- hidden desktop interaction: hover the logo / app name ----------
   The logo lifts and glows, the accent line stretches, a soft accent
   light blooms behind the group and a highlight sweeps across the name.
   Only on real hover devices with the split layout; skipped when the
   user prefers reduced motion. */
@media (hover: hover) and (pointer: fine) and (min-width: 1025px) and (prefers-reduced-motion: no-preference) {
    .auth-hero-brand {
        position: relative;
        isolation: isolate;
        width: fit-content;
        cursor: default;
    }

    /* soft light behind the group */
    .auth-hero-brand::before {
        content: "";
        position: absolute;
        inset: -48px -72px -32px -56px;
        z-index: -1;
        background: radial-gradient(
            closest-side,
            color-mix(in srgb, var(--auth-accent) 38%, transparent),
            transparent
        );
        opacity: 0;
        transform: scale(0.85);
        transition:
            opacity 0.5s ease,
            transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
        pointer-events: none;
    }

    .auth-hero-logo {
        transition:
            transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
            filter 0.5s ease;
    }

    .auth-hero-line {
        transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1);
    }

    /* name: white text with a highlight band parked off to the side */
    .auth-hero-title {
        color: transparent;
        background-image: linear-gradient(
            100deg,
            #fff 0%,
            #fff 38%,
            var(--auth-accent-light) 50%,
            #fff 62%,
            #fff 100%
        );
        background-size: 260% 100%;
        background-position: 100% 0;
        -webkit-background-clip: text;
        background-clip: text;
        transition: background-position 0.9s cubic-bezier(0.22, 1, 0.36, 1);
    }

    .auth-hero-brand:hover::before {
        opacity: 1;
        transform: scale(1);
    }

    .auth-hero-brand:hover .auth-hero-logo {
        transform: translateY(-6px) rotate(-4deg) scale(1.08);
        filter: drop-shadow(0 10px 18px var(--auth-accent-glow));
    }

    .auth-hero-brand:hover .auth-hero-line {
        width: 132px;
    }

    .auth-hero-brand:hover .auth-hero-title {
        background-position: 0 0;
    }
}

/* form panel */
.auth-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(24px, 4vw, 56px);
    background: var(--auth-bg);
}

.auth-card {
    width: 100%;
    max-width: 400px;
}

/* Brand lockup shown above the card on phones/tablets only:
   [ logo | NAME ] in one dark-glass badge (same material as the card),
   so the whole brand stays legible on any photo. Long names wrap
   inside the badge instead of widening it. */
.auth-brand {
    display: none;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    width: 100%;
    max-width: var(--auth-col-w, 440px);
    padding: 10px 22px 10px 14px;
    border: 1px solid var(--auth-border-strong);
    border-radius: 16px;
    background: rgba(12, 12, 12, 0.62);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 28px -12px rgba(0, 0, 0, 0.8);
}

.auth-brand-logo {
    flex: 0 0 auto;
    width: auto;
    height: 44px;
    max-width: 96px;
    object-fit: contain;
    display: block;
}

.auth-brand-name {
    position: relative;
    min-width: 0;
    margin: 0;
    padding-left: 15px;
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-align: left;
    text-wrap: balance;
    color: #fff;
}

/* accent divider between the logo and the name */
.auth-brand-name::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 3px;
    height: 100%;
    max-height: 34px;
    transform: translateY(-50%);
    border-radius: 3px;
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--auth-accent) 70%, white),
        var(--auth-accent)
    );
}

.auth-heading {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.3px;
}

.auth-subheading {
    margin: 6px 0 28px;
    font-size: 0.95rem;
    color: var(--auth-text-2);
}

/* ---------- form parts ---------- */
.auth-field {
    margin-bottom: 18px;
}

.auth-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: var(--auth-text-2);
}

.auth-input {
    display: flex;
    align-items: center;
    height: 50px;
    background: var(--auth-field);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    transition:
        border-color 0.2s ease,
        background-color 0.2s ease,
        box-shadow 0.2s ease;
}

.auth-input:hover {
    border-color: var(--auth-border-strong);
}

.auth-input:focus-within {
    background: var(--auth-field-focus);
    border-color: var(--auth-accent);
    box-shadow: 0 0 0 4px var(--auth-accent-soft);
}

.auth-input-icon {
    flex: 0 0 46px;
    text-align: center;
    font-size: 1.05rem;
    color: var(--auth-text-3);
    transition: color 0.2s ease;
}

.auth-input:focus-within .auth-input-icon {
    color: var(--auth-accent-light);
}

.auth-input input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0 14px 0 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--auth-text);
    caret-color: var(--auth-accent-light);
    font-size: 1rem; /* 16px: prevents iOS zoom-on-focus */
    font-weight: 500;
}

.auth-input input::placeholder {
    color: var(--auth-text-3);
    font-weight: 400;
}

/* autofill paints the same solid color as the field */
.auth-input input:-webkit-autofill,
.auth-input input:-webkit-autofill:hover,
.auth-input input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--auth-text);
    -webkit-box-shadow: 0 0 0 1000px var(--auth-field) inset;
    box-shadow: 0 0 0 1000px var(--auth-field) inset;
    caret-color: var(--auth-accent-light);
    transition: background-color 9999s ease-in-out 0s;
}

.auth-input:focus-within input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px var(--auth-field-focus) inset;
    box-shadow: 0 0 0 1000px var(--auth-field-focus) inset;
}

.auth-input-action {
    flex: 0 0 38px;
    height: 36px;
    margin-right: 6px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--auth-text-3);
    font-size: 1.05rem;
    cursor: pointer;
    transition:
        background-color 0.2s ease,
        color 0.2s ease;
}

.auth-input-action:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.auth-input-action:focus-visible,
.auth-btn:focus-visible,
.auth-link:focus-visible {
    outline: 2px solid var(--auth-accent-light);
    outline-offset: 2px;
}

.auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 4px 0 24px;
}

.auth-link {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--auth-accent-light);
    text-decoration: none;
    white-space: nowrap;
}

.auth-link:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* the shared remember-me component, tuned to the neutral surfaces */
.auth-card .remember-me-custom-check {
    border-color: var(--auth-border-strong);
    background: var(--auth-field);
}

.auth-card .remember-me-text {
    font-size: 0.85rem;
    color: var(--auth-text-2);
}

/* primary button */
.auth-btn {
    position: relative;
    width: 100%;
    height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 20px;
    border: 0;
    border-radius: var(--auth-radius);
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--auth-accent) 78%, white),
        var(--auth-accent)
    );
    color: var(--auth-on-accent);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    cursor: pointer;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.28),
        0 10px 24px -10px var(--auth-accent-glow);
    transition:
        transform 0.2s ease,
        filter 0.2s ease,
        box-shadow 0.2s ease;
}

.auth-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.07);
}

.auth-btn:active {
    transform: translateY(0);
    filter: brightness(0.97);
}

.auth-btn-icon {
    transition: transform 0.2s ease;
}

.auth-btn:hover .auth-btn-icon {
    transform: translateX(3px);
}

.auth-btn.is-loading {
    pointer-events: none;
    filter: saturate(0.8) brightness(0.95);
}

.auth-btn.is-loading .auth-btn-icon {
    animation: auth-spin 0.8s linear infinite;
}

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

/* hints */
.auth-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: -10px 0 18px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--auth-accent-light);
}

.auth-hint[hidden] {
    display: none;
}

.auth-version {
    position: absolute;
    right: 20px;
    bottom: max(14px, env(safe-area-inset-bottom, 14px));
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.4px;
    color: var(--auth-text-3);
    pointer-events: none;
    user-select: none;
}

/* dev/staging banner */
.auth-env-banner {
    position: relative;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px;
    background: #e11d48;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.auth-env-banner__host {
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.25);
    font-family: ui-monospace, monospace;
    font-size: 10px;
}

.auth-env-banner__close {
    padding: 2px 8px;
    border: 0;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

/* =========================================================
   PHONES + TABLETS (<= 1024px): photo background, centered card
   ========================================================= */
@media (max-width: 1024px) {
    .auth-shell {
        display: block;
        position: relative;
    }

    /* photo becomes a fixed full-screen backdrop */
    .auth-hero {
        position: fixed;
        inset: 0;
        padding: 0;
        z-index: 0;
    }

    .auth-hero::before {
        background-image: var(--auth-bg-mobile);
    }

    .auth-hero::after {
        background: linear-gradient(
            180deg,
            color-mix(in srgb, var(--auth-accent) 30%, transparent) 0%,
            rgba(12, 12, 12, 0.62) 32%,
            rgba(12, 12, 12, 0.92) 70%,
            var(--auth-bg) 100%
        );
    }

    .auth-hero-brand {
        display: none;
    }

    .auth-panel {
        z-index: 1;
        min-height: calc(100dvh - var(--env-banner-h, 0px));
        gap: 24px;
        padding:
            max(28px, env(safe-area-inset-top, 0px))
            clamp(20px, 6vw, 48px)
            max(56px, env(safe-area-inset-bottom, 0px));
        background: transparent;
    }

    .auth-brand {
        display: flex;
    }

    /* badge and card share this exact width */
    .auth-panel {
        --auth-col-w: 440px;
    }

    .auth-card {
        max-width: var(--auth-col-w);
        padding: clamp(22px, 5vw, 32px);
        border: 1px solid var(--auth-border);
        border-radius: 22px;
        background: var(--auth-surface);
        -webkit-backdrop-filter: blur(16px);
        backdrop-filter: blur(16px);
        box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.75);
    }

    .auth-heading {
        font-size: 1.5rem;
    }

    .auth-subheading {
        margin-bottom: 24px;
    }
}

/* tablets get a little more room */
@media (min-width: 768px) and (max-width: 1024px) {
    .auth-brand {
        gap: 18px;
        padding: 12px 28px 12px 18px;
    }

    .auth-brand-logo {
        width: 56px;
    }

    .auth-brand-name {
        padding-left: 18px;
        font-size: 1.1rem;
    }

    .auth-panel {
        --auth-col-w: 480px;
    }

    .auth-card {
        padding: 36px;
    }
}

/* short landscape phones: tighten */
@media (max-width: 1024px) and (max-height: 520px) {
    .auth-panel {
        justify-content: flex-start;
        gap: 14px;
        padding-top: 20px;
    }

    .auth-brand {
        gap: 10px;
        padding: 6px 16px 6px 10px;
    }

    .auth-brand-logo {
        width: 32px;
    }

    .auth-brand-name {
        padding-left: 12px;
        font-size: 0.8rem;
    }
}

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