/* ============================================================
   auth.css — EverAfter authentication pages
   Light mode by default; html.dark-mode overrides for dark.
   ============================================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* Custom alias for inline error text (lighter than --error) */
:root { --error-color: #f08080; }

html, body {
    min-height: 100%;
    font-family: var(--font-body);
    background: var(--bg-body);
    color: var(--dark-text);
    overflow-x: hidden;
}

/* ============================================================
   Top Bar
   ============================================================ */

.auth-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2.5rem;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gold);
    text-decoration: none;
    letter-spacing: -0.3px;
    transition: opacity 0.2s;
}
.back-link:hover { opacity: 0.8; }
.back-link svg { width: 22px; height: 22px; }

html.dark-mode .back-link { color: var(--primary); }

/* ============================================================
   Background
   ============================================================ */

.auth-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}
.auth-bg::before {
    content: '';
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 700px;
    height: 700px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--at-07) 0%, transparent 65%);
}
html.dark-mode .auth-bg::before {
    background: radial-gradient(circle, var(--at-05) 0%, transparent 65%);
}

.deco-ring { position: absolute; }
.deco-ring-1 {
    width: 420px; height: 420px;
    top: -100px; right: -80px;
    animation: slowspin 50s linear infinite;
}
.deco-ring-2 {
    width: 300px; height: 300px;
    bottom: 40px; left: -80px;
    animation: slowspin 65s linear infinite reverse;
}
.deco-ring-1 circle { stroke: var(--at-18); }
.deco-ring-2 circle { stroke: rgba(0, 0, 0, 0.06); }

html.dark-mode .deco-ring-1 circle { stroke: var(--at-15); }
html.dark-mode .deco-ring-2 circle { stroke: rgba(255, 255, 255, 0.06); }

@keyframes slowspin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ============================================================
   Layout
   ============================================================ */

.auth-layout {
    min-height: calc(100vh - 4.5rem); /* subtract navbar height */
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 3rem 1.5rem 4rem;
    position: relative;
    z-index: 1;
}

/* ============================================================
   Card
   ============================================================ */

.auth-card {
    width: 100%;
    max-width: 440px;
    background: rgba(253, 252, 251, 0.97);
    border: 1px solid var(--at-25);
    border-radius: 20px;
    padding: 2.75rem 2.5rem;
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 20px 60px rgba(0, 0, 0, 0.1),
        0 0 40px var(--at-06);
    animation: fadeUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
html.dark-mode .auth-card {
    background: rgba(12, 22, 12, 0.88);
    border-color: var(--at-20);
    box-shadow:
        0 0 0 1px var(--at-04),
        0 40px 100px rgba(0, 0, 0, 0.55),
        0 0 80px var(--at-04);
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Brand row
   ============================================================ */

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    color: var(--primary);
    margin-bottom: 2.25rem;
}
.brand-icon {
    width: 50px; height: 50px;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    object-fit: cover;
    object-position: center 45%;
    -webkit-mask-image: radial-gradient(circle at center, black 52%, transparent 70%);
    mask-image: radial-gradient(circle at center, black 52%, transparent 70%);
}
.auth-brand svg,
.auth-brand img {
    width: 80px; height: 80px;
    display: block;
    object-fit: cover;
    object-position: center 45%;
    -webkit-mask-image: radial-gradient(circle at center, black 52%, transparent 70%);
    mask-image: radial-gradient(circle at center, black 52%, transparent 70%);
}
.auth-brand-name {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.4px;
}

.auth-heading {
    font-family: var(--font-display);
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--dark-text);
    text-align: center;
    margin-bottom: 0.45rem;
    letter-spacing: -0.5px;
}
.auth-subheading {
    font-size: 0.92rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.5;
    margin-bottom: 2rem;
}
.auth-reset {
    font-size: 0.92rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 3;
    padding-top: 1rem;
    margin-bottom: 2rem;
}

/* ============================================================
   Form
   ============================================================ */

.auth-form { display: flex; flex-direction: column; }
.auth-form .form-group { margin-bottom: 1.1rem; }
.auth-form .form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary) !important;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 0.45rem;
}

.auth-form input,
.auth-form select,
.auth-form textarea {
    width: 100%;
    background: #F8F9FA;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    padding: 0.8rem 1rem;
    color: #1a1a1a;
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
    outline: none;
    -webkit-appearance: none;
}
.auth-form input::placeholder { color: rgba(26, 26, 26, 0.4); }
.auth-form input:focus,
.auth-form select:focus,
.auth-form textarea:focus {
    background: var(--input-bg);
    border-color: var(--at-50);
    box-shadow: 0 0 0 3px var(--at-20);
}
.auth-form input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 100px var(--input-bg) inset;
    -webkit-text-fill-color: #1a1a1a;
}

html.dark-mode .auth-form input,
html.dark-mode .auth-form select,
html.dark-mode .auth-form textarea {
    background: rgba(250, 233, 227, 0.05);
    border-color: rgba(255, 255, 255, 0.09);
    color: var(--dark-text);
}
html.dark-mode .auth-form input::placeholder { color: var(--muted-text); }
html.dark-mode .auth-form input:focus,
html.dark-mode .auth-form select:focus,
html.dark-mode .auth-form textarea:focus {
    border-color: var(--primary);
    background: rgba(250, 233, 227, 0.07);
    box-shadow: 0 0 0 3px var(--at-10);
}
html.dark-mode .auth-form input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 100px #0c160c inset;
    -webkit-text-fill-color: var(--dark-text);
}

/* Error states */
.auth-form .form-group-error input,
.auth-form .form-group-error select {
    border-color: rgba(240, 128, 128, 0.5);
    box-shadow: 0 0 0 3px rgba(212, 99, 92, 0.08);
}
.auth-form .form-errors { list-style: none; margin-top: 0.4rem; padding: 0; }
.auth-form .error-item { display: flex; align-items: center; gap: 0.3rem; font-size: 0.8rem; color: var(--error-color); }
.auth-form .form-help-text { font-size: 0.8rem; color: var(--muted-text); margin-top: 0.3rem; display: flex; align-items: center; gap: 0.3rem; }
.required { color: var(--error-color); margin-left: 2px; }

/* Non-field errors */
.form-error-alert {
    padding: 0.85rem 1rem;
    background: rgba(212, 99, 92, 0.08);
    border: 1px solid rgba(212, 99, 92, 0.25);
    border-radius: 10px;
    margin-bottom: 1.25rem;
    font-size: 0.87rem;
    color: var(--error-color);
}
.form-error-alert .error-header {
    display: flex; align-items: center; gap: 0.5rem;
    font-weight: 600; margin-bottom: 0.5rem;
}
.form-error-alert .error-list { list-style: none; padding: 0; }
.form-error-alert .error-list li { padding: 2px 0 2px 0.75rem; position: relative; font-size: 0.85rem; }
.form-error-alert .error-list li::before { content: '•'; position: absolute; left: 0; }

/* ============================================================
   Submit Button
   ============================================================ */

.auth-btn {
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.875rem;
    background: var(--primary);
    color: var(--btn-text);
    border: none;
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 4px 20px var(--glow);
}
.auth-btn:hover {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 6px 28px var(--glow);
}
.auth-btn:active { transform: translateY(0); opacity: 1; }

/* ============================================================
   Footer
   ============================================================ */

.auth-footer {
    margin-top: 1.75rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    text-align: center;
}
html.dark-mode .auth-footer { border-top-color: rgba(255, 255, 255, 0.07); }

.auth-footer p { font-size: 0.9rem; color: var(--text-secondary); }
.auth-footer a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.2s;
}
.auth-footer a:hover { opacity: 0.8; }

/* ============================================================
   Messages / Toast
   ============================================================ */

.msg-toast {
    position: fixed;
    top: 85px;
    left: 50%;
    transform: translateX(-50%);
    min-width: 320px;
    max-width: calc(100% - 4rem);
    max-height: calc(100% - 120px);
    padding: 0.9rem 1.2rem;
    border-radius: 12px;
    background: rgba(250, 233, 227, 0.97);
    border: 1px solid;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.06);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 100;
    animation: msgSlideIn 0.25s ease-out;
    font-size: 0.9rem;
    line-height: 1.4;
    color: #1a1a1a;
}
html.dark-mode .msg-toast {
    background: rgba(12, 22, 12, 0.92);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--at-06);
    color: var(--dark-text);
}

.msg-toast.success { border-color: var(--at-60); }
html.dark-mode .msg-toast.success { border-color: var(--at-50); }

.msg-toast.success .msg-icon { color: var(--primary); }

.msg-toast.error,
.msg-toast.warning,
.msg-toast.info,
.msg-toast.debug { border-color: rgba(212, 99, 92, 0.5); }

.msg-toast.error .msg-icon,
.msg-toast.warning .msg-icon,
.msg-toast.info .msg-icon,
.msg-toast.debug .msg-icon { color: var(--error); }

.msg-toast .msg-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px; height: 24px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.05);
}
html.dark-mode .msg-toast .msg-icon { background: rgba(250, 233, 227, 0.05); }

.msg-toast .msg-icon svg { width: 16px; height: 16px; }

@keyframes msgSlideIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-100%); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.msg-toast--fade { animation: msgSlideOut 0.25s ease-in forwards; }
@keyframes msgSlideOut {
    to { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 480px) {
    .auth-topbar { padding: 1rem 1.25rem; }
    .auth-card { padding: 2rem 1.5rem; }
    .msg-toast {
        top: 75px;
        min-width: auto;
        width: calc(100% - 2rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-form,
    .auth-card,
    .auth-form input,
    .auth-form select,
    .auth-form textarea,
    .auth-form button {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
