/* auth full page sign in / sign up */

body.auth-page {
    margin: 0;
    padding: 2rem 1rem;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    font-family: var(--font-main);
    box-sizing: border-box;
}

body.auth-page::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: url("https://grainy-gradients.vercel.app/noise.svg");
    opacity: 0.035;
    pointer-events: none;
    z-index: 999;
}

/* show the shared dock header on tablet + desktop for the auth page;
   the simplified auth-topbar is only used on true mobile (<=768px). */
@media (max-width: 768px) {
    body.auth-page .site-header {
        display: none !important;
    }
}
@media (min-width: 769px) {
    body.auth-page .auth-topbar {
        display: none !important;
    }
}

/* --- top bar --- */
.auth-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.5rem;
}

.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text-color);
}

.auth-brand-img {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.auth-brand-text {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: 0.14em;
}

.auth-back-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.5rem 1.1rem;
    border-radius: 999px;
    border: 1px solid rgba(15, 20, 25, 0.1);
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--ink-2);
    transition: color 0.25s ease, border-color 0.25s ease, transform 0.25s var(--ease-out-expo), box-shadow 0.25s ease;
}

.auth-back-pill:hover {
    color: var(--accent-color);
    border-color: rgba(var(--accent-rgb), 0.4);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(var(--accent-rgb), 0.12);
}

.auth-back-pill svg {
    transition: transform 0.25s var(--ease-out-expo);
}

.auth-back-pill:hover svg {
    transform: translateX(-3px);
}

/* --- card --- */
.auth-container.centered {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 100dvh;
    box-sizing: border-box;
    padding-top: 3rem;
}

.auth-form-card {
    zoom: 0.9;
    position: relative;
    width: 100%;
    max-width: 480px;
    padding: 2.5rem 3rem;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow:
        0 40px 90px rgba(15, 20, 25, 0.10),
        0 12px 30px rgba(var(--accent-rgb), 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
    color: var(--text-color);
    will-change: transform;
    transform-style: preserve-3d;
}

.card-serial {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.58rem;
    color: var(--accent-color);
    opacity: 0.5;
    letter-spacing: 0.22em;
}

/* --- logo orb --- */
.auth-logo-section {
    display: flex;
    justify-content: center;
    margin-bottom: 1.4rem;
}

.logo-orb {
    position: relative;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    box-shadow: 0 10px 25px rgba(15, 20, 25, 0.07);
}

.orb-ring {
    position: absolute;
    inset: -7px;
    border-radius: 50%;
    border: 1.5px solid rgba(var(--accent-rgb), 0.14);
    border-top-color: rgba(var(--accent-rgb), 0.65);
}

@keyframes orbSpin {
    to {
        transform: rotate(360deg);
    }
}

.auth-logo-img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

/* --- header --- */
.auth-header {
    text-align: center;
    margin-bottom: 1.6rem;
}

.auth-eyebrow {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--accent-color);
    margin-bottom: 0.65rem;
}

.auth-header h1 {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 4.5vw, 1.85rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-color);
    margin: 0;
}

.auth-sub {
    margin-top: 0.55rem;
    font-size: 0.85rem;
    color: var(--ink-3);
}

/* --- method tabs (segmented control) --- */
.auth-tabs {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: rgba(15, 20, 25, 0.05);
    border-radius: 999px;
    padding: 4px;
    margin-bottom: 1.5rem;
}

.auth-tab {
    position: relative;
    z-index: 1;
    min-height: 44px;
    border: none;
    background: none;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-3);
    cursor: pointer;
    transition: color 0.3s ease;
}

.auth-tab.active {
    color: var(--text-color);
}

.auth-tab:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

@supports selector(:has(*)) {
    .auth-tabs::before {
        content: '';
        position: absolute;
        top: 4px;
        bottom: 4px;
        left: 4px;
        width: calc(50% - 6px);
        background: #fff;
        border-radius: 999px;
        box-shadow: 0 3px 10px rgba(15, 20, 25, 0.1);
        transition: transform 0.4s var(--ease-out-expo);
    }

    .auth-tabs:has(#tabOTP.active)::before {
        transform: translateX(calc(100% + 4px));
    }
}

@supports not selector(:has(*)) {
    .auth-tab.active {
        background: #fff;
        box-shadow: 0 3px 10px rgba(15, 20, 25, 0.1);
    }
}

/* --- fields: floating labels --- */
.auth-form-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-pill-group {
    display: flex;
    flex-direction: column;
}

/* when auth-flow.js hides only the inner input (otp step), hide its group */
.input-pill-group:has(> .input-pill.hidden) {
    display: none;
}

.field {
    position: relative;
}

.field .input-pill {
    width: 100%;
    height: 58px;
    padding: 1.45rem 1.15rem 0.4rem;
    background: rgba(15, 20, 25, 0.035);
    border: 1.5px solid transparent;
    border-radius: 14px;
    font-family: var(--font-main);
    font-size: 0.95rem;
    color: var(--text-color);
    outline: none;
    box-sizing: border-box;
    transition:
        border-color 0.25s ease,
        background-color 0.25s ease,
        box-shadow 0.3s var(--ease-out-expo),
        transform 0.3s var(--ease-out-expo);
}

.field.has-toggle .input-pill {
    padding-right: 3.25rem;
}

.field .float-label {
    position: absolute;
    left: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    color: var(--ink-3);
    pointer-events: none;
    transform-origin: left top;
    transition: transform 0.25s var(--ease-out-expo), color 0.25s ease;
}

.otp-field .float-label {
    left: 1.2rem;
}

.field .input-pill:focus+.float-label,
.field .input-pill:not(:placeholder-shown)+.float-label {
    transform: translateY(-1.42rem) scale(0.72);
    color: var(--ink-2);
}

.field .input-pill:focus+.float-label {
    color: var(--accent-color);
}

.field .input-pill:focus {
    border-color: var(--accent-color);
    background: #fff;
    box-shadow:
        0 0 0 4px rgba(var(--accent-rgb), 0.12),
        0 10px 28px rgba(var(--accent-rgb), 0.08);
}

.field .input-pill:hover:not(:focus) {
    background: rgba(15, 20, 25, 0.055);
}

/* otp input */
.otp-input {
    font-family: var(--font-mono) !important;
    font-size: 1.25rem !important;
    letter-spacing: 0.45em;
    text-align: center;
    padding-left: 0.6rem !important;
}

.otp-field .input-pill:focus+.float-label,
.otp-field .input-pill:not(:placeholder-shown)+.float-label {
    transform: translateY(-1.42rem) scale(0.72) translateX(0);
}

/* password show / hide */
.pw-toggle {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    border-radius: 10px;
    color: var(--ink-3);
    cursor: pointer;
    transition: color 0.25s ease, background-color 0.25s ease;
}

.pw-toggle:hover,
.pw-toggle:focus-visible {
    color: var(--accent-color);
    background: rgba(var(--accent-rgb), 0.08);
}

.pw-toggle:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 1px;
}

.pw-toggle .eye-closed {
    display: none;
}

.pw-toggle.revealed .eye-open {
    display: none;
}

.pw-toggle.revealed .eye-closed {
    display: block;
}

/* --- admin signup group --- */
.admin-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 48px;
    font-size: 0.85rem;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.65rem 1rem;
    background: rgba(15, 20, 25, 0.035);
    border: 1.5px solid transparent;
    border-radius: 14px;
    transition: border-color 0.25s ease, background-color 0.25s ease;
}

.admin-toggle-label:hover {
    background: rgba(15, 20, 25, 0.055);
}

.admin-toggle-label:has(input:checked) {
    border-color: var(--accent-color);
    background: rgba(var(--accent-rgb), 0.05);
}

.admin-toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-color);
    cursor: pointer;
}

.admin-toggle-label span {
    font-weight: 500;
}

.admin-code-wrap {
    margin-top: 0.75rem;
}

/* --- hints / links / status --- */
.field-hint {
    font-size: 0.74rem;
    color: var(--ink-3);
    margin-top: 0.5rem;
    text-align: center;
}

.auth-links-group {
    text-align: center;
}

.auth-link {
    color: var(--accent-color);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 4px;
    transition: opacity 0.2s ease;
}

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

.auth-link:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 3px;
}

.status-msg {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.04em;
    min-height: 1.2rem;
    color: var(--ink-2);
}

.status-msg.error {
    color: #c62828;
}

.status-msg.success {
    color: #15803d;
}

@keyframes statusShake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-6px);
    }

    40% {
        transform: translateX(5px);
    }

    60% {
        transform: translateX(-3px);
    }

    80% {
        transform: translateX(2px);
    }
}

/* --- privacy note --- */
.auth-privacy-info {
    display: flex;
    align-items: flex-start;
    text-align: left;
    gap: 0.75rem;
    margin-top: 0.25rem;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    background: rgba(15, 20, 25, 0.03);
}

.privacy-icon {
    flex-shrink: 0;
    color: var(--accent-color);
    opacity: 0.75;
    margin-top: 0.1rem;
}

.auth-privacy-info p {
    font-size: 0.72rem;
    color: var(--ink-3);
    line-height: 1.55;
    margin: 0;
}

/* --- submit --- */
.auth-footer-btns {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.25rem;
}

.auth-submit {
    position: relative;
    width: 100%;
    min-height: 54px;
    border: none;
    border-radius: 14px;
    background: var(--accent-color);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 10px 24px rgba(var(--accent-rgb), 0.28);
    transition:
        transform 0.3s var(--ease-out-expo),
        box-shadow 0.3s var(--ease-out-expo),
        opacity 0.2s ease;
}

/* shine sweep */
.auth-submit::before {
    content: '';
    position: absolute;
    top: 0;
    left: -80%;
    width: 50%;
    height: 100%;
    background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    transform: skewX(-20deg);
    transition: left 0.6s var(--ease-out-expo);
    pointer-events: none;
}

.auth-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(var(--accent-rgb), 0.38);
}

.auth-submit:hover::before {
    left: 130%;
}

.auth-submit:active {
    transform: translateY(0) scale(0.985);
}

.auth-submit:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 6px 16px rgba(var(--accent-rgb), 0.18);
}

.auth-submit:focus-visible {
    outline: 2px solid var(--text-color);
    outline-offset: 3px;
}

.resend-btn {
    min-height: 44px;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: center;
    background: none;
    border: none;
    color: var(--accent-color);
    cursor: pointer;
    border-radius: 8px;
}

.resend-btn:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* --- footer --- */
body.auth-page .site-footer.auth-footer {
    display: none;
    bottom: 0;
    left: 0;
    width: 100%;
    text-align: center;
    padding: 1.25rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--ink-3);
    letter-spacing: 0.08em;
    pointer-events: none;
}

/* --- reduced motion --- */
@media (prefers-reduced-motion: reduce) {

    .orb-ring,
    .auth-submit::before {
        animation: none !important;
        transition: none !important;
    }
}

body.reduced-motion .orb-ring {
    animation: none !important;
}

/* --- responsive --- */
@media (max-width: 520px) {
    body.auth-page {
        padding: 2rem 1rem;
    }

    .auth-form-card {
        padding: 2rem 1.4rem;
        border-radius: 22px;
    }

    .card-serial {
        display: none;
    }

    .auth-back-pill {
        font-size: 0.62rem;
        padding: 0.4rem 0.85rem;
    }
}

@media (max-height: 700px) {
    .auth-logo-section {
        margin-bottom: 1rem;
    }
}

/* legacy: split modal styles (kept for older modal markup) */

.modal-box.split-modal {
    display: flex;
    flex-direction: row;
    width: 900px;
    max-width: 95vw;
    height: 600px;
    max-height: 90vh;
    padding: 0;
    border-radius: 16px;
    overflow: hidden;
    background: var(--panel-bg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
}

.close-btn-absolute {
    position: absolute;
    top: 1.5rem;
    left: 2rem;
    z-index: 100;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted-text);
}

.modal-form-side {
    flex: 1;
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    background: var(--panel-bg);
}

.modal-visual-side {
    flex: 1;
    background: linear-gradient(135deg, #e0eafc 0%, #cfdef3 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.visual-content {
    text-align: center;
    position: relative;
    z-index: 2;
}

.visual-logo-large {
    width: 80px;
    margin-bottom: 1rem;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.1));
}

.modal-visual-side h2 {
    font-size: 2.5rem;
    color: var(--accent-color);
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.modal-visual-side p {
    color: #555;
    font-family: var(--font-mono);
}

.visual-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    background: #fff;
    opacity: 0.3;
    border-radius: 50%;
    filter: blur(40px);
    z-index: 1;
}

@media (max-width: 768px) {
    .modal-box.split-modal {
        flex-direction: column;
        height: auto;
        max-height: 85vh;
        width: 90vw;
        border-radius: 8px;
    }

    .modal-form-side {
        padding: 4rem 1.5rem 2.5rem;
        overflow-y: auto;
    }

    .modal-visual-side {
        display: none;
    }

    .close-btn-absolute {
        top: 1rem;
        left: 1.5rem;
    }
}

/* mobile app sign in style (full screen view) */
@media (max-width: 767px) {

    /* full-screen auth container */
    body.auth-page {
        padding: 0 !important;
        background-color: #f8f9fa !important;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
    }

    /* hide background waves on mobile */
    body.auth-page #waves-container {
        display: none !important;
    }

    /* set background grain overlay to super light */
    body.auth-page::before {
        opacity: 0.01;
    }

    /* sticky native-style app top navigation bar */
    .auth-topbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: calc(3.75rem + env(safe-area-inset-top, 0px));
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-bottom: 1px solid rgba(15, 20, 25, 0.06);
        padding: env(safe-area-inset-top, 0px) 1rem 0 !important;
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-direction: row-reverse;
        z-index: 1000;
        box-sizing: border-box;
    }

    /* back arrow link positioned on the left */
    .auth-back-pill {
        background: transparent !important;
        border: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        padding: 0.25rem 0.5rem !important;
        min-height: auto !important;
        box-shadow: none !important;
        font-size: 0.82rem !important;
        font-weight: 700 !important;
        text-transform: none !important;
        color: var(--text-color) !important;
        margin: 0;
        display: inline-flex;
        align-items: center;
        gap: 0.35rem;
    }

    .auth-back-pill:hover,
    .auth-back-pill:active {
        color: var(--accent-color) !important;
        transform: none !important;
        box-shadow: none !important;
    }

    /* brand name/logo positioning */
    .auth-brand {
        position: static;
        transform: none;
        margin: 0;
        pointer-events: auto;
        display: inline-flex;
        align-items: center;
        gap: 0.45rem;
    }

    .auth-brand-text {
        font-size: 0.88rem !important;
        font-weight: 800 !important;
        letter-spacing: 0.08em;
    }

    .auth-brand-img {
        width: 20px !important;
        height: 20px !important;
    }

    /* fullscreen card wrapper */
    .auth-container.centered {
        align-items: stretch;
        justify-content: flex-start;
        flex-grow: 1;
        min-height: 100vh;
    }

    .auth-form-card {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 100vh;
        margin: 0 !important;
        padding: calc(5.5rem + env(safe-area-inset-top, 0px)) 1.25rem 3rem !important;
        /* spacing for topbar and mobile footers */
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: #f8f9fa !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        box-sizing: border-box;
    }

    /* ios native list inputs style */
    .auth-form-container {
        gap: 0.85rem;
    }

    .field .input-pill {
        background: #ffffff !important;
        border: 1px solid rgba(15, 20, 25, 0.06) !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.01) !important;
        border-radius: 16px !important;
        height: 56px !important;
        font-size: 1rem !important;
    }

    .field .input-pill:focus {
        border-color: var(--accent-color) !important;
        box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.04) !important;
    }

    /* segmented controls tab styling */
    .auth-tabs {
        margin-bottom: 1.25rem;
        background: rgba(15, 20, 25, 0.04) !important;
        border-radius: 14px;
        padding: 3px;
    }

    .auth-tab {
        border-radius: 12px;
        font-size: 0.7rem;
        font-weight: 700;
        min-height: 40px;
    }

    @supports selector(:has(*)) {
        .auth-tabs::before {
            border-radius: 12px !important;
        }
    }

    /* submit button (primary native button) */
    .auth-submit {
        width: 100% !important;
        height: 3.1rem !important;
        border-radius: 16px !important;
        font-size: 0.95rem !important;
        font-weight: 600 !important;
        box-shadow: 0 4px 14px rgba(var(--accent-rgb), 0.25) !important;
    }

    .auth-submit:active {
        transform: scale(0.97) !important;
        box-shadow: 0 2px 6px rgba(var(--accent-rgb), 0.15) !important;
    }

    .auth-privacy-info {
        background: rgba(15, 20, 25, 0.02);
        padding: 0.85rem 1rem;
        border-radius: 14px;
        border: 1px solid rgba(15, 20, 25, 0.04);
    }
}