/* ==========================================================================
   Authentication pages
   --------------------------------------------------------------------------
   The pages reuse the existing .login-page / .login-card shell. Everything
   below is additive and scoped to .auth-* (plus a few small enhancements to
   the shared card), so no other screen changes.

   Design notes:
   * One primary action per screen; the alternate route is a quiet link.
   * Errors sit next to the thing that caused them and are announced by
     aria-live, not just by colour.
   * Every control keeps the 44px touch target and the visible focus ring the
     rest of the app already uses.
   ========================================================================== */

.login-card {
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    scrollbar-width: thin;
    background: var(--clay-card-bg);
    border: 1.5px solid var(--clay-card-border);
    border-radius: var(--radius-2xl);
    box-shadow: var(--clay-card-shadow);
}

.auth-card-wide {
    max-width: 560px !important;
}

.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    border: 1.5px solid transparent;
    font-size: 13px;
    line-height: 1.45;
    margin-bottom: 20px;
    box-shadow: inset 1px 1px 2px rgb(255 255 255 / 0.8), 0 2px 6px rgb(37 33 43 / 0.03);
}

.auth-alert svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

.auth-alert-error {
    background: var(--color-danger-light);
    border-color: #fecaca;
    color: var(--color-danger-text);
}

.auth-alert-success {
    background: var(--color-success-light);
    border-color: #a7f3d0;
    color: var(--color-success-text);
}

.auth-alert-info {
    background: var(--color-info-light);
    border-color: #bfdbfe;
    color: var(--color-info-text);
}

.auth-alert-warning {
    background: var(--color-warning-light);
    border-color: #fde68a;
    color: var(--color-warning-text);
}

.auth-field {
    margin-bottom: 18px;
}

.auth-field:last-of-type {
    margin-bottom: 22px;
}

.auth-hint {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--color-text-muted);
}

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

.auth-label-row a {
    font-size: 12px;
    font-weight: 600;
}

.auth-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 22px;
}

.auth-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-height: 18px;
    margin-top: 1px;
    flex-shrink: 0;
    accent-color: var(--color-primary);
}

.auth-check label {
    font-size: 13px;
    line-height: 1.5;
    color: var(--color-text-secondary);
    margin: 0;
    font-weight: 400;
}

.auth-check a {
    font-weight: 600;
}

.auth-submit {
    width: 100%;
    min-height: 48px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--clay-btn-primary-bg);
    border: 1.5px solid var(--clay-btn-primary-border);
    box-shadow: var(--clay-btn-primary-shadow);
    color: #fff;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.auth-submit:hover:not([disabled]) {
    transform: translateY(-2px);
    box-shadow: var(--clay-btn-primary-hover-shadow);
    color: #fff;
}

.auth-submit:active:not([disabled]) {
    transform: translateY(1px);
    box-shadow: var(--clay-btn-primary-active-shadow);
}

.auth-submit[disabled] {
    opacity: 0.7;
    cursor: not-allowed;
}

.auth-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgb(255 255 255 / 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: auth-spin 0.7s linear infinite;
    display: none;
}

.auth-submit.is-loading .auth-spinner {
    display: inline-block;
}

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

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 0;
    color: var(--color-text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

.auth-google-container {
    margin-bottom: 18px;
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 11px 18px;
    border-radius: var(--radius-lg, 14px);
    border: 1.5px solid var(--color-border, #e6e0f0);
    background: #ffffff;
    color: var(--color-text, #25212b);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 12px -2px rgba(37, 33, 43, 0.05), inset 1.5px 1.5px 2px rgba(255, 255, 255, 0.95);
    transition: all 0.2s ease;
    cursor: pointer;
    box-sizing: border-box;
}

.btn-google:hover {
    background: #f8f6fc;
    border-color: #7b2df0;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -2px rgba(123, 45, 240, 0.15);
    color: var(--color-text, #25212b);
}

.btn-google:active {
    transform: translateY(1px);
    box-shadow: 0 2px 6px rgba(37, 33, 43, 0.1);
}

.google-icon {
    flex-shrink: 0;
}

.auth-google {
    min-height: 46px;
    display: flex;
    justify-content: center;
    margin-bottom: 4px;
}

.auth-google > div {
    width: 100% !important;
}

.auth-google iframe {
    margin: 0 auto;
}

.auth-google-fallback {
    display: none;
    width: 100%;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1.5px solid var(--clay-btn-secondary-border);
    border-radius: var(--radius-lg);
    background: var(--clay-btn-secondary-bg);
    box-shadow: var(--clay-btn-secondary-shadow);
    color: var(--color-text);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.auth-google-fallback:hover {
    transform: translateY(-2px);
    box-shadow: var(--clay-btn-secondary-hover-shadow);
    color: var(--color-text);
}

.auth-google-unavailable .auth-google-fallback {
    display: inline-flex;
}

.auth-links {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--color-border);
    text-align: center;
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.8;
}

.auth-links a {
    font-weight: 600;
}

.auth-links .auth-links-muted {
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--color-text-muted);
}

.auth-links .auth-links-muted a {
    font-weight: 500;
    color: var(--color-text-secondary);
}

.auth-code-input {
    text-align: center;
    font-size: 28px;
    letter-spacing: 12px;
    padding: 14px 12px 14px 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-height: 58px;
}

.auth-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-100);
    color: var(--color-primary);
    margin-bottom: 16px;
}

.auth-icon svg {
    width: 26px;
    height: 26px;
}

.auth-icon-danger {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

.auth-icon-success {
    background: var(--color-success-light);
    color: var(--color-success);
}

.auth-inline-form {
    display: inline;
}

.auth-link-button {
    background: none;
    border: 0;
    padding: 0;
    color: var(--color-primary);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.auth-resend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
    font-size: 13px;
    color: var(--color-text-secondary);
    flex-wrap: wrap;
}

.auth-resend button {
    min-height: 36px;
}

.auth-resend button[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

.auth-change-email {
    margin-top: 20px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg-soft);
    padding: 12px 14px;
}

.auth-change-email summary {
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--color-text-secondary);
    list-style: none;
}

.auth-change-email summary::-webkit-details-marker {
    display: none;
}

.auth-change-email[open] summary {
    margin-bottom: 12px;
}

.auth-change-email .auth-field {
    margin-bottom: 12px;
}

/* -- Password strength meter -- */
.pw-meter {
    margin-top: 10px;
}

.pw-meter-bars {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
}

.pw-meter-bars span {
    height: 4px;
    border-radius: 999px;
    background: var(--color-border);
    transition: background 0.2s ease;
}

.pw-meter[data-score="1"] .pw-meter-bars span:nth-child(-n+1) { background: var(--color-danger); }
.pw-meter[data-score="2"] .pw-meter-bars span:nth-child(-n+2) { background: var(--color-warning); }
.pw-meter[data-score="3"] .pw-meter-bars span:nth-child(-n+3) { background: var(--color-success); }
.pw-meter[data-score="4"] .pw-meter-bars span:nth-child(-n+4) { background: var(--color-success); }

.pw-meter-label {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--color-text-muted);
}

.pw-meter-label strong {
    font-weight: 600;
    color: var(--color-text-secondary);
}

.pw-meter-errors {
    margin: 6px 0 0;
    padding-left: 18px;
    font-size: 12px;
    line-height: 1.55;
    color: var(--color-danger-text);
}

.pw-meter-errors:empty {
    display: none;
}

/* -- Mobile -- */
@media (max-width: 640px) {
    .login-page {
        align-items: flex-start;
        padding: 16px;
    }

    .login-card {
        padding: 26px 20px;
        max-height: none;
        border-radius: var(--radius-lg);
    }

    .login-card .login-brand {
        margin-bottom: 24px;
    }

    .auth-code-input {
        letter-spacing: 8px;
        font-size: 24px;
        padding-left: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-spinner { animation: none; }
    .pw-meter-bars span { transition: none; }
}
