/* Login and Register. Loaded by Components/Account/Shared/AuthLayout.razor only.
   Static-SSR forms: plain HTML, no MudBlazor. Tokens come from app.css :root.
   Rules from docs/design/forms.md: 6px control radius, 40px+ controls, visible labels,
   error text under the field, primary action shows busy state while submitting. */

.auth {
    --auth-field-h: 48px;
    --auth-focus: color-mix(in srgb, var(--orange) 55%, transparent);
    --auth-error-bg: color-mix(in srgb, var(--loss) 8%, var(--paper));

    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--paper);
    color: var(--ink);
    font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

@media (min-width: 960px) {
    .auth {
        grid-template-columns: minmax(420px, 5fr) minmax(0, 6fr);
    }
}

/* ───────────── Form side ───────────── */

.auth-main {
    display: flex;
    flex-direction: column;
    padding: 24px 16px 40px;
}

@media (min-width: 600px) {
    .auth-main {
        padding: 32px 48px 48px;
    }
}

.auth-brand {
    align-self: flex-start;
    display: inline-flex;
    border-radius: var(--radius);
}

.auth-brand img {
    display: block;
    height: 32px;
    width: auto;
}

.auth-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding-top: 32px;
}

.auth-title {
    margin: 0 0 4px;
    font-family: 'Overpass', 'Inter', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.01em;
    outline: none;
}

.auth-sub {
    margin: 0 0 28px;
    color: var(--ink-muted);
}

.auth-title:not(:has(+ .auth-sub)) {
    margin-bottom: 28px;
}

/* ───────────── Fields ───────────── */

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}

@media (min-width: 440px) {
    .auth-row-2 {
        grid-template-columns: 1fr 1fr;
    }
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.auth-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.auth-label {
    font-size: .875rem;
    font-weight: 600;
}

.auth-input {
    width: 100%;
    height: var(--auth-field-h);
    padding: 0 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--ink);
    font: 400 1rem/1 'Inter', sans-serif;
    transition: border-color .15s, box-shadow .15s;
}

.auth-input::placeholder {
    color: color-mix(in srgb, var(--ink-muted) 65%, var(--paper));
}

.auth-input:hover {
    border-color: color-mix(in srgb, var(--ink) 45%, var(--line));
}

.auth-input:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 4px var(--auth-focus);
}

.auth-input.invalid {
    border-color: var(--loss);
}

.auth-input.invalid:focus {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--loss) 25%, transparent);
}

.auth-error,
.auth .validation-message {
    margin: 0;
    color: var(--loss);
    font-size: .8125rem;
    font-weight: 500;
}

.auth-hint {
    margin: 0;
    color: var(--ink-muted);
    font-size: .8125rem;
}

/* Password field with reveal button. The button only shows once auth.js has run. */
.auth-password {
    position: relative;
}

.auth-password .auth-input {
    padding-right: 52px;
}

.auth-reveal {
    position: absolute;
    top: 0;
    right: 0;
    display: none;
    align-items: center;
    justify-content: center;
    width: var(--auth-field-h);
    height: var(--auth-field-h);
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--ink-muted);
    cursor: pointer;
}

.auth-js .auth-reveal {
    display: inline-flex;
}

.auth-reveal:hover {
    color: var(--ink);
}

.auth-reveal svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-reveal .icon-hide,
.auth-reveal[aria-pressed="true"] .icon-show {
    display: none;
}

.auth-reveal[aria-pressed="true"] .icon-hide {
    display: block;
}

/* Password rules: neutral until typed, then each rule turns green when met. */
.auth-rules {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.auth-rules li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink-muted);
    font-size: .75rem;
    font-weight: 500;
    transition: color .15s, border-color .15s, background-color .15s;
}

.auth-rules li::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .45;
}

.auth-rules li.met {
    border-color: color-mix(in srgb, var(--gain) 40%, var(--paper));
    background: color-mix(in srgb, var(--gain) 9%, var(--paper));
    color: var(--gain);
}

.auth-rules li.met::before {
    opacity: 1;
}

/* Remember me */
.auth-check {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: fit-content;
    font-size: .9375rem;
    cursor: pointer;
    user-select: none;
}

.auth-check input {
    appearance: none;
    flex: none;
    width: 20px;
    height: 20px;
    margin: 0;
    border: 1.5px solid var(--line);
    border-radius: 4px;
    background: var(--paper);
    cursor: pointer;
    transition: background-color .15s, border-color .15s, box-shadow .15s;
}

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

.auth-check input:checked {
    border-color: var(--ink);
    background: var(--ink)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 10.5 3.2 3.2L15 6.8'/%3E%3C/svg%3E")
        center / 100% no-repeat;
}

.auth-check input:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--auth-focus);
}

/* ───────────── Buttons ───────────── */

.auth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 50px;
    padding: 0 24px;
    border: 2px solid transparent;
    border-radius: var(--radius);
    font: 700 1rem/1 'Inter', sans-serif;
    text-decoration: none;
    cursor: pointer;
    transition: transform .2s cubic-bezier(.16, 1, .3, 1), background-color .2s, color .2s, border-color .2s, box-shadow .2s;
}

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

.auth-btn:active {
    transform: translateY(0) scale(.99);
}

.auth-btn:focus-visible,
.auth-link:focus-visible,
.auth-brand:focus-visible,
.auth-reveal:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--auth-focus);
}

.auth-btn-primary {
    background: var(--orange);
    color: var(--ink);
    box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--ink) 20%, transparent);
}

.auth-btn-primary:hover {
    background: color-mix(in srgb, var(--orange) 90%, white);
}

.auth-btn-primary:focus-visible {
    box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--ink) 20%, transparent), 0 0 0 4px var(--auth-focus);
}

.auth-btn-ghost {
    border-color: var(--line);
    background: var(--paper);
    color: var(--ink);
}

.auth-btn-ghost:hover {
    border-color: var(--ink);
}

.auth-btn.busy {
    pointer-events: none;
    opacity: .75;
}

.auth-btn.busy::before {
    content: "";
    width: 16px;
    height: 16px;
    border: 2.5px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: auth-spin .7s linear infinite;
}

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

/* ───────────── Links, divider, alerts ───────────── */

.auth-link {
    color: var(--ink);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: var(--orange);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    border-radius: 2px;
}

.auth-link:hover {
    text-decoration-color: var(--ink);
}

.auth-link-quiet {
    font-size: .875rem;
    text-decoration-thickness: 1px;
    text-decoration-color: var(--line);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 4px 0;
    color: var(--ink-muted);
    font-size: .8125rem;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

.auth-alt {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-switch {
    margin: 28px 0 0;
    color: var(--ink-muted);
    font-size: .9375rem;
}

.auth .alert {
    margin: 0 0 20px;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: .9375rem;
    font-weight: 500;
}

.auth .alert-danger {
    border-color: color-mix(in srgb, var(--loss) 30%, var(--paper));
    background: var(--auth-error-bg);
    color: var(--loss);
}

.auth .alert-success {
    border-color: color-mix(in srgb, var(--gain) 30%, var(--paper));
    background: color-mix(in srgb, var(--gain) 8%, var(--paper));
    color: var(--gain);
}

.auth-summary:empty,
.auth .validation-errors:empty {
    display: none;
}

.auth .validation-errors {
    margin: 0;
    padding: 12px 14px 12px 32px;
    border: 1px solid color-mix(in srgb, var(--loss) 30%, var(--paper));
    border-radius: var(--radius);
    background: var(--auth-error-bg);
    color: var(--loss);
    font-size: .875rem;
    font-weight: 500;
}

/* ───────────── Brand side ───────────── */

.auth-aside {
    display: none;
}

@media (min-width: 960px) {
    .auth-aside {
        position: relative;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 64px;
        overflow: hidden;
        background: var(--ink);
        color: var(--on-ink);
    }
}

.auth-aside-copy {
    position: relative;
    max-width: 30rem;
}

.auth-aside-title {
    margin: 0 0 16px;
    font-family: 'Overpass', 'Inter', sans-serif;
    font-size: clamp(2rem, 3.2vw, 3rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.015em;
    text-wrap: balance;
}

.auth-aside-text {
    margin: 0;
    max-width: 26rem;
    color: var(--on-ink-muted);
    font-size: 1.0625rem;
}

/* Center-line paint running down the panel: the single memorable element. */
.auth-lane {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 56px;
    width: 6px;
    background: repeating-linear-gradient(180deg, var(--amber) 0 28px, transparent 28px 64px);
    opacity: .9;
    animation: auth-roll 2.4s linear infinite;
}

@keyframes auth-roll {
    to { background-position: 0 64px; }
}

.auth-tape {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 14px;
    background: repeating-linear-gradient(90deg, var(--orange) 0 30px, var(--ink-line) 30px 48px);
}

@media (prefers-reduced-motion: reduce) {
    .auth-lane {
        animation: none;
    }

    .auth-btn,
    .auth-btn.busy::before {
        transition: none;
        animation-duration: 1.6s;
    }
}

.auth-divider-after {
    margin-top: 12px;
}
