/* Login modal — HouseSwapp-style overlay for TipTapp PL */

body.modal-open {
    overflow: hidden;
}

.modal-layer {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: max(1rem, var(--safe-top)) 1rem max(1rem, var(--safe-bottom));
}

.modal-layer.is-open {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
}

.auth-modal {
    position: relative;
    width: min(100%, 460px);
    max-height: calc(100dvh - 2rem - var(--safe-top) - var(--safe-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow:
        0 4px 6px -1px rgba(15, 23, 42, 0.04),
        0 20px 50px -8px rgba(15, 23, 42, 0.22),
        0 0 0 1px rgba(255, 255, 255, 0.06) inset;
    padding: 1.75rem 1.75rem max(1.75rem, var(--safe-bottom));
    margin: auto;
    transition: transform 0.2s cubic-bezier(0.32, 1.5, 0.56, 1), opacity 0.18s;
}

.dark .auth-modal {
    box-shadow:
        0 20px 60px -10px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
}

.modal-soft {
    position: absolute;
    width: 160px;
    height: 160px;
    border-radius: 999px;
    filter: blur(32px);
    opacity: 0.45;
    pointer-events: none;
}

.modal-soft.one {
    left: -40px;
    top: -40px;
    background: color-mix(in srgb, var(--brand) 35%, transparent);
}

.modal-soft.two {
    right: -40px;
    bottom: -40px;
    background: color-mix(in srgb, var(--brand-2) 28%, transparent);
}

.modal-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    position: relative;
}

.modal-brand-lockup .tippl-brand-name {
    font-size: 0.95rem;
}

.modal-close {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--muted);
    padding: 0.38rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.modal-close:hover {
    background: var(--line);
    color: var(--text);
}

.modal-head {
    position: relative;
    margin-bottom: 1.25rem;
}

.modal-head h2 {
    margin: 0 0 0.2rem;
    font-size: 1.75rem;
    line-height: 1.06;
    font-weight: 900;
    letter-spacing: -0.035em;
    color: var(--text);
}

.modal-head .meta {
    margin: 0;
    color: var(--muted);
    font-size: 0.875rem;
}

.auth-modal-error {
    border-radius: 12px;
    padding: 0.7rem 0.9rem;
    margin-bottom: 0.85rem;
    background: color-mix(in srgb, #dc2626 8%, var(--surface));
    border: 1px solid color-mix(in srgb, #dc2626 28%, transparent);
    color: #dc2626;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.4;
}

.modal-form {
    display: grid;
    gap: 0.75rem;
}

.auth-modal .field {
    display: grid;
    gap: 0.4rem;
    margin-bottom: 0;
}

.auth-modal .field label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
}

.auth-modal .field input:not([type="checkbox"]):not([type="radio"]) {
    width: 100%;
    min-height: var(--touch-min);
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--bg) 55%, var(--surface));
    color: var(--text);
    font: inherit;
    font-size: 1rem;
}

.auth-modal .field input:not([type="checkbox"]):not([type="radio"]):focus {
    outline: none;
    border-color: var(--brand-mid);
    background: var(--surface);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

/* Remember me — HouseSwapp check-row */
.auth-modal .check-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    margin: 0.1rem 0 0.15rem;
}

.auth-modal .check-row input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1.125rem;
    height: 1.125rem;
    min-height: 0;
    padding: 0;
    margin: 0;
    flex: 0 0 1.125rem;
    border: 1.5px solid var(--line);
    border-radius: 0.4rem;
    background: color-mix(in srgb, var(--bg) 55%, var(--surface));
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    display: grid;
    place-content: center;
}

.auth-modal .check-row input[type="checkbox"]::after {
    content: '';
    width: 0.3rem;
    height: 0.55rem;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(45deg) scale(0);
    margin-top: -0.1rem;
    transition: transform 0.12s ease;
}

.auth-modal .check-row input[type="checkbox"]:checked {
    background: var(--brand);
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

.auth-modal .check-row input[type="checkbox"]:checked::after {
    transform: rotate(45deg) scale(1);
}

.auth-modal .check-row input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}

.auth-modal .google-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    border: 1.5px solid var(--line);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-weight: 700;
    text-decoration: none;
    min-height: var(--touch-min);
    transition: border-color 0.15s, background 0.15s;
}

.auth-modal .google-button:hover {
    border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
    background: var(--surface-soft);
}

.auth-modal .google-button svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.auth-modal .auth-divider {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.75rem;
    align-items: center;
    color: var(--muted);
    font-size: 0.8rem;
    margin: 0.15rem 0 0.25rem;
}

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

.auth-modal .button.full {
    width: 100%;
    margin-top: 0.15rem;
}

.mobile-drawer-login {
    width: 100%;
    margin-top: 0.75rem;
    justify-content: center;
}

@media (max-width: 480px) {
    .auth-modal {
        border-radius: 22px;
        padding: 1.35rem 1.25rem max(1.35rem, var(--safe-bottom));
    }

    .modal-head h2 {
        font-size: 1.55rem;
    }
}

/* Tabs */
.auth-modal .modal-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
    background: color-mix(in srgb, var(--bg) 70%, var(--line));
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 3px;
    margin-bottom: 1.25rem;
}

.auth-modal .modal-tabs button {
    border: 0;
    background: transparent;
    color: var(--muted);
    border-radius: 13px;
    padding: 0.55rem 0.35rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth-modal .modal-tabs button.is-active {
    background: var(--surface);
    color: var(--brand);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
}

.auth-modal .tab-panel { display: none; }
.auth-modal .tab-panel.is-active { display: block; }

.auth-modal .center { text-align: center; }
.auth-modal .pin-hint { margin: 0 0 0.75rem; }

.auth-modal .pin-alert {
    border-radius: 12px;
    padding: 0.7rem 0.9rem;
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.auth-modal .pin-alert.is-error {
    background: color-mix(in srgb, #dc2626 8%, var(--surface));
    border: 1px solid color-mix(in srgb, #dc2626 28%, transparent);
    color: #dc2626;
}

.auth-modal .pin-sent-note {
    border-radius: 12px;
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.75rem;
    background: color-mix(in srgb, var(--brand) 8%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
    color: var(--brand);
    font-size: 0.8125rem;
    font-weight: 600;
}

.auth-modal .pin-box-row {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.auth-modal .pin-box {
    width: 2.8rem;
    height: 3.4rem;
    text-align: center;
    font-size: 1.45rem;
    font-weight: 800;
    border-radius: 14px;
    border: 2px solid var(--line);
    background: color-mix(in srgb, var(--bg) 60%, var(--surface));
    color: var(--text);
}

.auth-modal .pin-box:focus {
    outline: none;
    border-color: var(--brand-mid);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent);
}

.auth-modal .pin-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.65rem;
    font-size: 0.8125rem;
    font-weight: 700;
}

.auth-modal .pin-actions .linkish {
    background: none;
    border: 0;
    padding: 0;
    color: var(--brand);
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    font-weight: 700;
}

.auth-modal .pin-actions .linkish:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.auth-modal .qr-box {
    min-height: 260px;
    display: grid;
    place-items: center;
    gap: 0.65rem;
    margin: 0.5rem 0;
}

.auth-modal .qr-status {
    color: var(--brand);
    font-weight: 800;
    font-size: 0.8rem;
}

.auth-modal #login-qr-canvas {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
}
