/* Auth Gate Styles */
#auth-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-dark);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Padding per safe area iPhone */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    animation: fadeIn 0.5s ease-out;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#auth-screen.hidden { display: none !important; }

.auth-container {
    width: 90%;
    max-width: 440px;
    text-align: center;
    padding: 1rem 0;
}

.auth-logo { margin-bottom: 2.5rem; }

.auth-logo-img {
    width: 80px;
    height: auto;
    margin: 0 auto 1rem;
    display: block;
}

.auth-logo p {
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

.auth-card {
    background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface-1) 100%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: 0 40px 80px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #d70926, transparent);
    opacity: 0.7;
}

.auth-step h2 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.auth-step .auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1.75rem;
}

.auth-input-group { margin-bottom: 1.25rem; }

.auth-input {
    width: 100%;
    padding: 0.9rem 1.1rem;
    background: var(--surface-3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    /* min 16px per evitare zoom automatico su iOS */
    font-size: 16px;
    font-family: var(--font-body);
    transition: all 0.2s;
    /* Impedisce zoom su doppio tap */
    touch-action: manipulation;
}

.auth-input:focus {
    border-color: #d70926;
    box-shadow: 0 0 0 3px rgba(215, 9, 38, 0.15);
}

.auth-input::placeholder { color: var(--text-tertiary); }

.auth-input.token-input {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    font-family: monospace;
    text-transform: uppercase;
    padding: 1rem;
}

.auth-btn-primary {
    width: 100%;
    padding: 1rem;
    border-radius: 100px;
    border: none;
    background: var(--text-primary);
    color: var(--bg-dark);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    font-family: var(--font-body);
    /* Target touch iOS minimo 44px */
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.auth-btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(255,255,255,0.2); }
.auth-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.auth-link-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    /* Area touch minima 44px */
    padding: 0.75rem 0.5rem;
    transition: color 0.2s;
    font-family: var(--font-body);
    text-decoration: underline;
    text-underline-offset: 3px;
    touch-action: manipulation;
}

.auth-link-btn:hover { color: #d70926; }

.auth-footer-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1.25rem;
}

.auth-error {
    background: rgba(255,68,68,0.1);
    border: 1px solid rgba(255,68,68,0.3);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    color: var(--danger);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    text-align: left;
    line-height: 1.4;
}

.auth-error.hidden { display: none !important; }

.auth-email-badge {
    display: inline-block;
    background: rgba(215, 9, 38, 0.08);
    border: 1px solid rgba(215, 9, 38, 0.25);
    color: #d70926;
    padding: 0.4rem 1rem;
    border-radius: 100px;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
    word-break: break-all;
    max-width: 100%;
}

.auth-success-icon {
    font-size: 2.2rem;
    color: #d70926;
    margin-bottom: 0.75rem;
    filter: drop-shadow(0 0 15px rgba(215,9,38,0.3));
}

.auth-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(0,0,0,0.3);
    border-top-color: var(--bg-dark);
    border-radius: 50%;
    animation: authSpin 0.6s linear infinite;
}

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

.auth-bg-glow {
    position: fixed;
    width: 350px;
    height: 350px;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.07;
    pointer-events: none;
    z-index: -1;
}

.auth-bg-glow-1 { top: -80px; right: -80px; background: #d70926; }
.auth-bg-glow-2 { bottom: -80px; left: -80px; background: #4444ff; }


/* =====================
   RESPONSIVE AUTH
   ===================== */
@media (max-width: 480px) {
    .auth-container { width: 94%; }
    .auth-card { padding: 1.5rem; border-radius: var(--radius-md); }
    .auth-logo { margin-bottom: 2rem; }
    .auth-logo-img { width: 64px; }
    .auth-step h2 { font-size: 1.2rem; }
    .auth-step .auth-subtitle { font-size: 0.85rem; margin-bottom: 1.5rem; }
    .auth-input.token-input { font-size: 1.6rem; letter-spacing: 0.25em; }
}

@media (max-height: 600px) {
    .auth-logo { margin-bottom: 1.5rem; }
    .auth-logo-img { width: 52px; }
    .auth-step .auth-subtitle { margin-bottom: 1.25rem; }
    .auth-bg-glow { display: none; }
}
