/*
 * NutrAnalysis — Auth & Subscription Overlay Styles
 * Follows the design system in style.css exactly.
 * All tokens from :root are reused; no raw hex values introduced.
 */

/* ─── Shared overlay base ────────────────────────────────────────────────── */

.auth-overlay,
.subscription-gate-overlay {
    position: fixed;
    inset: 0;
    z-index: 180;
    display: grid;
    place-items: center;
    padding: 20px;
    background:
        radial-gradient(circle at 10% 0%, #d8efe3 0%, transparent 42%),
        radial-gradient(circle at 92% 12%, #d7ebe0 0%, transparent 30%),
        linear-gradient(160deg, var(--page-bg-1) 0%, var(--page-bg-2) 100%);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.auth-overlay[hidden],
.subscription-gate-overlay[hidden] {
    display: none !important;
}

/* ─── Auth card ──────────────────────────────────────────────────────────── */

.auth-overlay__card {
    width: min(100%, 400px);
    display: grid;
    gap: 24px;
    padding: 32px 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.auth-overlay__logo {
    display: flex;
    justify-content: center;
    margin-bottom: 4px;
}

.auth-overlay__logo-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    display: grid;
    place-items: center;
    box-shadow: 0 8px 18px rgba(15, 122, 83, 0.28);
}

.auth-overlay__logo-mark svg {
    width: 24px;
    height: 24px;
    fill: #f6fff9;
}

.auth-overlay__title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text);
    margin: 0;
    text-align: center;
    letter-spacing: -0.01em;
}

.auth-overlay__subtitle {
    font-size: 0.83rem;
    color: var(--muted);
    margin: -16px 0 0;
    text-align: center;
    line-height: 1.4;
}

/* ─── Auth form ──────────────────────────────────────────────────────────── */

.auth-form {
    display: grid;
    gap: 16px;
}

.auth-form__group {
    display: grid;
    gap: 6px;
}

.auth-form__label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #234b39;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.auth-form__input {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.95rem;
    font-family: var(--font-main);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    appearance: none;
    -webkit-appearance: none;
}

.auth-form__input::placeholder {
    color: var(--muted);
    opacity: 0.75;
}

.auth-form__input:focus {
    outline: none;
    border-color: var(--accent-2);
    box-shadow: 0 0 0 3px rgba(25, 160, 111, 0.15);
}

.auth-form__input[aria-invalid='true'] {
    border-color: #c84040;
    box-shadow: 0 0 0 3px rgba(200, 64, 64, 0.12);
}

/* iOS focus-zoom guard: keep ≥16px on touch devices */
@media (hover: none) and (pointer: coarse) {
    .auth-form__input {
        font-size: 16px !important;
    }
}

/* ─── Auth actions ───────────────────────────────────────────────────────── */

.auth-form__actions {
    display: grid;
    gap: 10px;
    margin-top: 4px;
}

.auth-form__btn {
    width: 100%;
    padding: 13px 18px;
    border: none;
    border-radius: 20px;
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
    letter-spacing: 0.01em;
}

.auth-form__btn:active {
    transform: scale(0.985);
}

.auth-form__btn--primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    color: #f6fff9;
    box-shadow: 0 8px 18px rgba(15, 122, 83, 0.28);
}

.auth-form__btn--primary:hover {
    filter: brightness(1.06);
    box-shadow: 0 10px 22px rgba(15, 122, 83, 0.34);
}

.auth-form__btn--primary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(15, 122, 83, 0.28);
}

.auth-form__btn--primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
    filter: none;
}

.auth-form__btn--secondary {
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--border);
}

.auth-form__btn--secondary:hover {
    background: rgba(15, 122, 83, 0.05);
    border-color: var(--accent-2);
}

.auth-form__btn--secondary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(15, 122, 83, 0.18);
}

/* ─── Auth mode toggle ───────────────────────────────────────────────────── */

.auth-form__toggle-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.81rem;
    color: var(--muted);
    margin-top: 2px;
}

.auth-form__toggle-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--accent);
    font-family: var(--font-main);
    font-size: 0.81rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-form__toggle-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 3px;
}

/* ─── Auth error message ─────────────────────────────────────────────────── */

.auth-form__error {
    font-size: 0.8rem;
    font-weight: 600;
    color: #c84040;
    background: rgba(200, 64, 64, 0.07);
    border: 1px solid rgba(200, 64, 64, 0.22);
    border-radius: 9px;
    padding: 9px 12px;
    line-height: 1.4;
}

.auth-form__error[hidden] {
    display: none !important;
}

/* ─── Auth loading spinner ───────────────────────────────────────────────── */

.auth-form__spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2.5px solid rgba(246, 255, 249, 0.4);
    border-top-color: #f6fff9;
    border-radius: 50%;
    animation: auth-spin 0.65s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

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

/* ─── Auth footer ────────────────────────────────────────────────────────── */

.auth-overlay__footer {
    font-size: 0.74rem;
    color: var(--muted);
    text-align: center;
    line-height: 1.45;
}

.auth-overlay__footer a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ─── Subscription gate card ─────────────────────────────────────────────── */

.subscription-gate-overlay__card {
    width: min(100%, 420px);
    display: grid;
    gap: 20px;
    padding: 32px 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: center;
}

.subscription-gate-overlay__icon {
    display: flex;
    justify-content: center;
}

.subscription-gate-overlay__icon-wrap {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, #fff5d6 0%, #ffe4a0 100%);
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    border: 1px solid rgba(200, 150, 20, 0.2);
}

.subscription-gate-overlay__title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
    margin: 0;
    letter-spacing: -0.01em;
}

.subscription-gate-overlay__description {
    font-size: 0.87rem;
    color: var(--muted);
    margin: 0;
    line-height: 1.5;
}

/* ─── Pricing callout ────────────────────────────────────────────────────── */

.subscription-gate-overlay__pricing {
    display: grid;
    gap: 8px;
    padding: 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
}

.subscription-gate-overlay__price {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.subscription-gate-overlay__price-period {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.subscription-gate-overlay__features {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 7px;
    text-align: left;
}

.subscription-gate-overlay__feature {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.83rem;
    color: var(--text);
    line-height: 1.4;
}

.subscription-gate-overlay__feature::before {
    content: '✓';
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    color: #f6fff9;
    font-size: 0.65rem;
    font-weight: 800;
    margin-top: 1px;
}

/* ─── Subscription gate actions ──────────────────────────────────────────── */

.subscription-gate-overlay__actions {
    display: grid;
    gap: 10px;
}

.subscription-gate-overlay__btn {
    width: 100%;
    padding: 13px 18px;
    border: none;
    border-radius: 20px;
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.subscription-gate-overlay__btn:active {
    transform: scale(0.985);
}

.subscription-gate-overlay__btn--primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    color: #f6fff9;
    box-shadow: 0 8px 18px rgba(15, 122, 83, 0.28);
}

.subscription-gate-overlay__btn--primary:hover {
    filter: brightness(1.06);
}

.subscription-gate-overlay__btn--primary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(15, 122, 83, 0.28);
}

.subscription-gate-overlay__btn--primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
    filter: none;
}

.subscription-gate-overlay__btn--ghost {
    background: transparent;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
    border: none;
    padding: 6px 18px;
}

.subscription-gate-overlay__btn--ghost:hover {
    color: var(--text);
}

.subscription-gate-overlay__btn--ghost:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 8px;
}

/* ─── User pill (shown in main app when signed in) ───────────────────────── */

.auth-user-pill[hidden],
.cloud-sync-indicator[hidden],
.auth-overlay[hidden],
.subscription-gate-overlay[hidden] {
    display: none !important;
}

.auth-user-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px 5px 6px;
    border: 1.5px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    box-shadow: 0 2px 6px rgba(19, 53, 39, 0.07);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-user-pill:hover {
    border-color: var(--accent-2);
    box-shadow: 0 4px 10px rgba(15, 122, 83, 0.12);
}

.auth-user-pill__avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    display: grid;
    place-items: center;
    font-size: 0.68rem;
    font-weight: 800;
    color: #f6fff9;
    flex-shrink: 0;
    text-transform: uppercase;
}

.auth-user-pill__email {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-user-pill__badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.auth-user-pill__badge--active {
    background: rgba(15, 122, 83, 0.1);
    color: var(--accent);
}

.auth-user-pill__badge--inactive {
    background: rgba(200, 64, 64, 0.1);
    color: #c84040;
}

/* ─── Sync status indicator ──────────────────────────────────────────────── */

.cloud-sync-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    transition: color 0.2s ease, border-color 0.2s ease;
}

.cloud-sync-indicator--syncing {
    color: var(--accent);
    border-color: rgba(25, 160, 111, 0.3);
}

.cloud-sync-indicator--error {
    color: #c84040;
    border-color: rgba(200, 64, 64, 0.3);
}

.cloud-sync-indicator__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.cloud-sync-indicator--syncing .cloud-sync-indicator__dot {
    animation: sync-pulse 1.2s ease-in-out infinite;
}

@keyframes sync-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.75); }
}

/* ─── Responsive adjustments ─────────────────────────────────────────────── */

@media (max-width: 480px) {
    .auth-overlay__card,
    .subscription-gate-overlay__card {
        padding: 24px 18px;
        border-radius: 16px;
    }

    .auth-overlay__title {
        font-size: 1.18rem;
    }

    .subscription-gate-overlay__price {
        font-size: 1.7rem;
    }

    .auth-user-pill__email {
        max-width: 110px;
    }
}

@media (max-width: 360px) {
    .auth-overlay__card,
    .subscription-gate-overlay__card {
        padding: 20px 14px;
    }
}
