/*BODY*/

/* Sign in / Sign up share this look (styled after the Profile page) */
.sign-in {
    --a-brown: #2A1608;
    --a-cream: #FFFBD8;
    --a-card: #FFFDF2;
    --a-yellow: #F2DE7A;

    background-color: var(--cream);
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

/* the card */
.sign-in-box {
    max-width: 440px;
    width: 100%;
    padding: 36px 36px 30px;
    background: var(--a-card);
    border: 2px solid var(--a-brown);
    border-radius: 14px;
    text-align: left;
}

/* round cookie badge, like the avatar on the profile page */
.auth-badge {
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: var(--a-brown);
    color: var(--a-cream);
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sign-in h1 {
    font-family: 'Baloo 2', cursive;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-align: center;
    color: var(--a-brown);
    margin-bottom: 4px;
}

.sign-in-subtext {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-align: center;
    color: var(--a-brown);
    opacity: 0.75;
    margin-bottom: 28px;
}

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

input[type="password"]::-ms-reveal {
    display: none;
}

.input-group {
    position: relative;
}

.input-group label {
    position: absolute;
    top: 9px;
    left: 15px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--a-brown);
    opacity: 0.7;
    pointer-events: none;
}

.input-group input {
    width: 100%;
    padding: 28px 46px 10px 14px;
    border: 2px solid var(--a-brown);
    border-radius: 10px;
    background: var(--white);
    color: var(--a-brown);
    font-family: 'Quicksand', var(--font);
    font-size: 1.05rem;
    font-weight: 600;
    transition: box-shadow 0.15s ease;
}

.input-group input:focus {
    outline: none;
    box-shadow: 0 0 0 4px var(--a-yellow);
}

.signin-link {
    display: block;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-top: 22px;
    text-decoration: underline;
    color: var(--a-brown);
}

.signin-link:hover {
    opacity: 0.7;
}

/*SIGN UP FORM*/

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

.form-step.active {
    display: flex;
}

.progress-row{
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 28px;
    position: relative;
}

.progress-dots {
    display: flex;
    gap: 10px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50px;
    border: 2px solid var(--a-brown);
    background: transparent;
    transition: width 0.2s ease, background 0.2s ease;
}

.dot.completed {
    background: #F2DE7A;
    border-color: #2A1608;
}

.dot.current {
    width: 30px;
    background: var(--a-yellow);
}

.next-btn {
    position: absolute;
    right: 0;
    background: none;
    border: none;
    color: var(--a-brown);
    cursor: pointer;
    display: flex;
    transition: opacity 0.15s ease;
}

.prev-btn {
    position: absolute;
    left: 0;
    background: none;
    border: none;
    color: var(--a-brown);
    cursor: pointer;
    display: flex;
    transition: opacity 0.15s ease;
}

.next-btn:hover,
.prev-btn:hover {
    opacity: 0.65;
}

/* main button: dark brown, turns yellow on hover (like Sign Out on the profile page) */
.create-account-btn {
    width: 100%;
    padding: 14px;
    background: var(--a-brown);
    color: var(--a-cream);
    border: 2px solid var(--a-brown);
    border-radius: 12px;
    font-family: 'Baloo 2', cursive;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.create-account-btn:hover {
    background: var(--a-yellow);
    color: var(--a-brown);
}

.create-account-btn:active {
    transform: translateY(1px);
}

.toggle-password {
    position: absolute;
    top: 14px;
    right: 12px;
    background: none;
    border: none;
    color: var(--a-brown);
    cursor: pointer;
}

.error-message {
    display: none;
    color: #D66853;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-top: 6px;
}

.input-group.invalid input {
    border-color: #D66853;
    box-shadow: 0 0 0 3px rgba(214, 104, 83, 0.2);
}

.input-group.invalid .error-message {
    display: block;
}

/* PROFILE */

.profile-info {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 30px;
}

.profile-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--brown);
    padding-bottom: 8px;
    font-size: 0.95rem;
}

.profile-label {
    font-size: 0.7rem;
    letter-spacing: 1px;
    opacity: 0.7;
}

/* TERMS OF SERVICE MODAL */

.terms-text {
    margin-top: 12px;
    font-size: 0.65rem;
    letter-spacing: 0.5px;
    text-align: center;
}

.terms-text a {
    text-decoration: underline;
    cursor: pointer;
}

.modal-overlay {
    --m-brown: #2A1608;
    --m-card: #FFFDF2;
    --m-yellow: #F2DE7A;

    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);          /* 20% dark */
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);              /* blur */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    padding: 24px 28px;
    background: var(--m-card);
    border-radius: 14px;
    transform: translateY(12px) scale(0.98);
    transition: transform 0.25s ease;
}

.modal-overlay.open .modal-box {
    transform: translateY(0) scale(1);
}

.modal-title {
    flex: none;
    margin-bottom: 16px;
    font-family: 'Baloo 2', cursive;
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--m-brown);
}

.modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 6px;
    font-family: 'Quicksand', var(--font);
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--m-brown);
}

/* each numbered section title = yellow pill, like the receipt headers */
.modal-body h3 {
    margin: 18px 0 8px;
    padding: 8px 14px;
    background: var(--m-yellow);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.modal-body h3:first-of-type {
    margin-top: 10px;
}

.modal-body p,
.modal-body ul {
    padding: 0 8px;
}

.modal-body ul {
    margin: 6px 0 6px 20px;
}

.terms-updated {
    font-size: 0.75rem;
    letter-spacing: 1px;
    opacity: 0.65;
}

.modal-footer {
    flex: none;
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}

.modal-close-btn {
    padding: 8px 26px;
    background: var(--m-yellow);
    border: none;
    border-radius: 8px;
    font-family: 'Baloo 2', cursive;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--m-brown);
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.modal-close-btn:hover {
    opacity: 0.85;
}

@media (prefers-reduced-motion: reduce) {
    .modal-overlay,
    .modal-box {
        transition: none;
    }
}


/* =========================================================
   MOBILE VIEW  (keep this block at the very bottom)
   Sign in / Sign up: form starts near the top (so the
   on-screen keyboard doesn't push it out of view), fields
   are 16px+ (no iOS zoom), every tap target is 44px+.
========================================================= */
@media (max-width: 768px) {

    .sign-in {
        justify-content: flex-start;
        min-height: 0;
        padding: 28px 16px 56px;
    }

    .sign-in-box {
        max-width: 480px;
        padding: 28px 20px 24px;
    }

    .auth-badge {
        width: 56px;
        height: 56px;
        font-size: 1.4rem;
    }

    .sign-in h1 {
        font-size: 1.6rem;
    }

    .sign-in-subtext {
        line-height: 1.5;
        margin-bottom: 22px;
    }

    .auth-form,
    .form-step {
        gap: 16px;
    }

    /* ---------- Fields ---------- */
    .input-group label {
        top: 9px;
        left: 13px;
        font-size: 0.66rem;
    }

    .input-group input {
        padding: 26px 52px 10px 13px;
        border-radius: 10px;
        font-size: 1.05rem;   /* 16px+ so iPhones don't zoom on focus */
        -webkit-appearance: none;
        appearance: none;
    }

    .toggle-password {
        top: 10px;
        right: 2px;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .error-message {
        font-size: 0.75rem;
        line-height: 1.35;
    }

    /* ---------- Sign-up steps ---------- */
    .progress-row {
        margin-top: 24px;
        min-height: 48px;
    }

    .next-btn,
    .prev-btn {
        width: 48px;
        height: 48px;
        align-items: center;
        justify-content: center;
    }

    .create-account-btn {
        min-height: 56px;
        padding: 12px;
    }

    .terms-text {
        font-size: 0.7rem;
        line-height: 1.4;
        text-align: center;
    }

    .signin-link {
        padding: 14px 0 4px;
        margin-top: 8px;
    }

    /* ---------- Terms modal -> bottom sheet ---------- */
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal-box {
        max-width: 100%;
        max-height: 90vh;
        max-height: 90dvh;
        border-radius: 20px 20px 0 0;
        padding: 22px 18px calc(18px + env(safe-area-inset-bottom, 0px));
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }

    .modal-overlay.open .modal-box {
        transform: translateY(0);
    }

    .modal-body {
        font-size: 0.95rem;
    }

    .modal-close-btn {
        width: 100%;
        min-height: 48px;
        font-size: 0.95rem;
    }

    /* ---------- Profile rows: label on top, value below ---------- */
    .profile-row {
        flex-direction: column;
        gap: 4px;
        word-break: break-word;
    }
}