/* ==========================================================
   Picsin v2 — Atelier Auth Modal + Save toast
   Phase J.3 (2026-04-28)

   Used by /create-print when a guest clicks "Save Project".
   Modal offers Google + Facebook + email/password sign-in;
   on success the modal closes and the original save fires.

   Token vocabulary identical to atelier-print-create.css
   (--bg, --bg-card, --ink, --accent, --serif, --sans, etc.).
   ========================================================== */

/* ─────────── Overlay ─────────── */
.atl-auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(31, 26, 20, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s, visibility 0s linear .2s;
    padding: 24px;
}
.atl-auth-overlay.is-open {
    opacity: 1;
    visibility: visible;
    transition: opacity .2s, visibility 0s linear 0s;
}

/* ─────────── Dialog ─────────── */
.atl-auth-dialog {
    background: var(--bg-card);
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transform: translateY(8px) scale(.98);
    opacity: 0;
    transition: transform .25s ease, opacity .2s ease;
}
.atl-auth-overlay.is-open .atl-auth-dialog {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.atl-auth-head {
    padding: 22px 24px 14px;
    border-bottom: 1px solid var(--line);
    position: relative;
}
.atl-auth-eyebrow {
    color: var(--ink-3);
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
    margin: 0 0 4px;
}
.atl-auth-title {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 400;
    font-size: 28px;
    line-height: 1.1;
    color: var(--ink);
    margin: 0;
}
.atl-auth-subtitle {
    color: var(--ink-2);
    font-size: 13px;
    line-height: 1.5;
    margin: 6px 0 0;
}
.atl-auth-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    color: var(--ink-3);
    transition: background .12s, color .12s;
    background: none;
    border: none;
    cursor: pointer;
}
.atl-auth-close:hover {
    background: var(--bg-sunk);
    color: var(--ink);
}

.atl-auth-body {
    padding: 22px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ─────────── OAuth buttons ─────────── */
.atl-oauth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 11px 16px;
    border: 1px solid var(--line-2);
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .12s, border-color .12s;
}
.atl-oauth-btn:hover {
    background: var(--bg-sunk);
    border-color: var(--ink-3);
}
.atl-oauth-btn svg { flex-shrink: 0; }

/* ─────────── Divider ─────────── */
.atl-auth-or {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink-3);
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    margin: 6px 0 2px;
}
.atl-auth-or::before,
.atl-auth-or::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
}

/* ─────────── Email/password collapse panel ─────────── */
.atl-auth-emailpw {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg);
    overflow: hidden;
}
.atl-auth-emailpw-toggle {
    width: 100%;
    padding: 11px 16px;
    background: transparent;
    border: none;
    text-align: left;
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.atl-auth-emailpw-toggle .atl-auth-chevron {
    transition: transform .2s;
    opacity: .7;
}
.atl-auth-emailpw.is-expanded .atl-auth-chevron {
    transform: rotate(180deg);
    opacity: 1;
}
.atl-auth-emailpw-form {
    display: none;
    padding: 0 16px 16px;
    flex-direction: column;
    gap: 12px;
    border-top: 1px solid var(--line);
}
.atl-auth-emailpw.is-expanded .atl-auth-emailpw-form {
    display: flex;
    padding-top: 14px;
}
.atl-auth-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.atl-auth-label {
    font-size: 11px;
    color: var(--ink-3);
    letter-spacing: .04em;
    text-transform: uppercase;
    font-weight: 500;
}
.atl-auth-input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    background: var(--bg-card);
    border: 1px solid var(--line-2);
    border-radius: var(--radius);
    font-family: var(--sans);
    font-size: 14px;
    color: var(--ink);
}
.atl-auth-input:focus {
    outline: none;
    border-color: var(--accent);
}
.atl-auth-submit {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 11px 18px;
    border-radius: var(--radius);
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s;
}
.atl-auth-submit:hover { background: #634626; }
.atl-auth-submit:disabled { opacity: .5; cursor: not-allowed; }

.atl-auth-error {
    color: var(--danger);
    font-size: 12.5px;
    margin: 0;
    padding: 8px 10px;
    background: #f5e7e3;
    border: 1px solid #e6c8c2;
    border-radius: var(--radius);
}

.atl-auth-foot {
    text-align: center;
    color: var(--ink-3);
    font-size: 12px;
    margin-top: 4px;
}
.atl-auth-foot a {
    color: var(--accent);
    border-bottom: 1px solid currentColor;
}

/* ─────────── Quota warning (sessionStorage too big) ─────────── */
.atl-auth-quota-warn {
    color: var(--ink-2);
    font-size: 12px;
    background: #f5efdf;
    border: 1px solid #e8dcb6;
    border-radius: var(--radius);
    padding: 8px 12px;
    margin: 0 0 4px;
    line-height: 1.4;
    display: none;
}
.atl-auth-quota-warn.is-visible { display: block; }

/* ─────────── Save toast (bottom-right) ─────────── */
.atl-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--ink);
    color: #fbf8f2;
    padding: 14px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    font-family: var(--sans);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity .25s, transform .25s;
    z-index: 8500;
    max-width: 360px;
}
.atl-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}
.atl-toast-message { line-height: 1.4; }
.atl-toast a {
    color: #f5d68d;
    border-bottom: 1px solid currentColor;
    white-space: nowrap;
}
.atl-toast-close {
    background: none;
    border: none;
    color: #c7bfb1;
    cursor: pointer;
    padding: 0 0 0 6px;
}
.atl-toast-close:hover { color: #fbf8f2; }

/* ─────────── Spinner inside submit button ─────────── */
.atl-auth-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: atl-spin 700ms linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}
@keyframes atl-spin { to { transform: rotate(360deg); } }

/* ─────────── Mobile (≤480px) ─────────── */
@media (max-width: 480px) {
    .atl-auth-overlay { padding: 12px; }
    .atl-auth-dialog { max-width: 100%; }
    .atl-auth-head { padding: 18px 20px 12px; }
    .atl-auth-body { padding: 18px 20px 20px; }
    .atl-auth-title { font-size: 24px; }
    .atl-toast {
        bottom: 12px; right: 12px; left: 12px;
        max-width: none;
    }
}
