/* =========================================================================
   Auth Modern — shared design system for login / register / redeem
   Mobile-first glass-card surface with mesh-gradient backdrop, IBM Plex Sans
   Thai typography, floating-label inputs, theme-aware (dark + light).
   Tokens from index.php (--mu-*, --main, --sub) + frontend-pro.css (--fp-*).
   ========================================================================= */

.auth-shell{
    --auth-card-w: 440px;
    --auth-radius: 22px;
    --auth-input-h: 48px;
    --auth-pad: 28px;

    position: relative;
    min-height: calc(100vh - 60px);
    min-height: calc(100dvh - 60px);
    display: grid;
    place-items: center;
    padding: 32px 18px 96px;
    isolation: isolate;
    font-family: 'IBM Plex Sans Thai', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--mu-text, #0f172a);
}

/* Mesh-gradient backdrop — uses brand colors so each shop's --main / --sub
   automatically tints the page. */
/* Orbs removed - use plain theme background */
.auth-shell::before,
.auth-shell::after{
    display: none !important;
}
@keyframes authDrift{
    0%   { transform: translate3d(0,0,0) scale(1); }
    100% { transform: translate3d(2%, -1.5%, 0) scale(1.05); }
}
@media (prefers-reduced-motion: reduce){
    .auth-shell::before{ animation: none; }
}

/* Card */
.auth-card{
    width: 100%;
    max-width: var(--auth-card-w);
    padding: var(--auth-pad);
    background: var(--mu-surface, #ffffff);
    border: 1px solid var(--mu-border, #e6e8ec);
    border-radius: var(--auth-radius);
    box-shadow:
        0 24px 60px -20px rgba(15, 23, 42, 0.18),
        0 8px 24px -12px rgba(15, 23, 42, 0.10);
    backdrop-filter: blur(18px) saturate(1.15);
    -webkit-backdrop-filter: blur(18px) saturate(1.15);
    animation: authRise .7s cubic-bezier(.2,.8,.2,1) both;
}
:root[data-theme="dark"] .auth-card{
    background: color-mix(in srgb, var(--mu-surface, #111827) 88%, transparent);
    border-color: var(--mu-border, #1f2a3a);
    box-shadow:
        0 30px 70px -20px rgba(0, 0, 0, 0.55),
        0 10px 30px -15px rgba(0, 0, 0, 0.4);
}
@keyframes authRise{
    from { opacity: 0; transform: translateY(14px) scale(.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header (logo + eyebrow + title) */
.auth-head{
    text-align: center;
    margin-bottom: 22px;
}
.auth-logo{
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 72px; height: 72px;
    margin-bottom: 14px;
    border-radius: 18px;
    background: var(--mu-surface, #fff);
    border: 1px solid var(--mu-border, #e6e8ec);
    box-shadow: 0 10px 24px -14px rgba(0,0,0,.35);
}
.auth-logo::before{
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: 20px;
    background: conic-gradient(from 140deg, var(--main, #4f46e5), var(--sub, #06b6d4), var(--main, #4f46e5));
    filter: blur(10px);
    opacity: .35;
    z-index: -1;
}
.auth-logo img{
    width: 50px; height: 50px;
    object-fit: contain;
    border-radius: 12px;
}
.auth-eyebrow{
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--mu-text-muted, #64748b);
    margin-bottom: 8px;
}
.auth-eyebrow::before{
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--main, #4f46e5);
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--main, #4f46e5) 22%, transparent);
}
.auth-title{
    font-size: clamp(20px, 4.6vw, 24px);
    font-weight: 700;
    letter-spacing: -.01em;
    line-height: 1.25;
    color: var(--mu-text, #0f172a);
    margin: 0 0 4px;
}
.auth-sub{
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--mu-text-muted, #64748b);
    margin: 0 auto;
    max-width: 32ch;
}

/* Form fields — floating-label */
.auth-form{ margin-top: 22px; }
.auth-field{
    position: relative;
    margin-bottom: 14px;
}
.auth-input{
    width: 100%;
    height: var(--auth-input-h);
    padding: 18px 16px 6px;
    font-family: inherit;
    font-size: 15px;
    color: var(--mu-text, #0f172a);
    background: var(--mu-surface-2, #f6f7f9);
    border: 1.5px solid var(--mu-border, #e6e8ec);
    border-radius: 12px;
    outline: none;
    transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
    -webkit-appearance: none;
    appearance: none;
}
.auth-input::placeholder{ color: transparent; }
.auth-input:focus{
    border-color: var(--main, #4f46e5);
    background: var(--mu-surface, #fff);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--main, #4f46e5) 18%, transparent);
}
:root[data-theme="dark"] .auth-input{
    background: var(--mu-surface-2, #0f1624);
    color: var(--mu-text, #f1f5f9);
}
:root[data-theme="dark"] .auth-input:focus{
    background: var(--mu-surface, #111827);
}

.auth-label{
    position: absolute;
    left: 16px; top: 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--mu-text-muted, #64748b);
    background: transparent;
    pointer-events: none;
    transition: transform .2s ease, font-size .2s ease, color .2s ease;
    transform-origin: 0 0;
}
.auth-input:focus + .auth-label,
.auth-input:not(:placeholder-shown) + .auth-label{
    transform: translateY(-9px) scale(.78);
    color: var(--main, #4f46e5);
    font-weight: 600;
}

/* Show/hide password toggle */
.auth-pass-wrap{ position: relative; }
.auth-pass-toggle{
    position: absolute;
    right: 8px; top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: 0;
    width: 36px; height: 36px;
    border-radius: 10px;
    color: var(--mu-text-muted, #64748b);
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background .15s ease, color .15s ease;
    z-index: 1;
}
.auth-pass-toggle:hover{
    background: var(--mu-surface-3, #eef0f3);
    color: var(--mu-text, #0f172a);
}
:root[data-theme="dark"] .auth-pass-toggle:hover{
    background: var(--mu-surface-3, #1a2234);
    color: var(--mu-text, #f1f5f9);
}

/* Field error */
.auth-error{
    display: none;
    margin-top: 6px;
    font-size: 12.5px;
    color: #ef4444;
    padding-left: 4px;
}
.auth-field.has-error .auth-input{
    border-color: #ef4444;
    background: color-mix(in srgb, #ef4444 6%, transparent);
}
.auth-field.has-error .auth-error{ display: block; }
.auth-field.has-error .auth-label{ color: #ef4444; }

/* CTA */
.auth-cta{
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 50px;
    margin-top: 8px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--main, #4f46e5) 0%, var(--sub, #06b6d4) 100%);
    border: 0;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--main, #4f46e5) 50%, transparent);
    transition: transform .2s ease, box-shadow .2s ease, filter .2s ease, opacity .2s ease;
    overflow: hidden;
    isolation: isolate;
}
.auth-cta::after{
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255,255,255,.18), transparent 45%);
    pointer-events: none;
}
.auth-cta:hover{
    transform: translateY(-1px);
    filter: brightness(1.04);
    box-shadow: 0 14px 30px -10px color-mix(in srgb, var(--main, #4f46e5) 55%, transparent);
}
.auth-cta:active{ transform: translateY(0) scale(.98); }
.auth-cta:focus-visible{ outline: 2px solid var(--main, #4f46e5); outline-offset: 3px; }
.auth-cta:disabled{ opacity: .65; cursor: not-allowed; transform: none; filter: grayscale(.2); }
.auth-cta .auth-cta-spin{
    display: none;
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: authSpin .8s linear infinite;
}
.auth-cta.is-loading .auth-cta-spin{ display: inline-block; }
.auth-cta.is-loading .auth-cta-text,
.auth-cta.is-loading .auth-cta-icon{ display: none; }
@keyframes authSpin{ to{ transform: rotate(360deg); } }

/* Helper / divider */
.auth-helper{
    text-align: center;
    margin-top: 18px;
    font-size: 13px;
    color: var(--mu-text-muted, #64748b);
}
.auth-helper a{
    color: var(--main, #4f46e5);
    font-weight: 700;
    text-decoration: none;
    border-bottom: 1px dashed transparent;
    transition: border-color .15s ease;
}
.auth-helper a:hover{
    border-bottom-color: var(--main, #4f46e5);
}

.auth-divider{
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    color: var(--mu-text-subtle, #94a3b8);
    font-size: 12px;
    letter-spacing: .04em;
}
.auth-divider::before,
.auth-divider::after{
    content: "";
    flex: 1;
    height: 1px;
    background: var(--mu-border, #e6e8ec);
}

/* Footer caption (legal / disclaimer) */
.auth-foot{
    text-align: center;
    margin-top: 16px;
    font-size: 11.5px;
    line-height: 1.55;
    color: var(--mu-text-subtle, #94a3b8);
}

/* Single-input variant (redeem) */
.auth-single .auth-cta{ margin-top: 14px; }
.auth-illu{
    display: block;
    margin: 0 auto 14px;
    max-width: 160px;
    height: auto;
    user-select: none;
    pointer-events: none;
}

/* Mobile tightening */
@media (max-width: 480px){
    .auth-shell{
        padding: 22px 14px 96px;
    }
    .auth-card{
        padding: 24px 20px 22px;
        border-radius: 18px;
    }
    .auth-logo{ width: 64px; height: 64px; }
    .auth-logo img{ width: 44px; height: 44px; }
}

/* ============================================================
   OAUTH SECTION — Google / Discord / Line
   ============================================================ */
.auth-divider{
    display: flex; align-items: center; gap: 12px;
    margin: 18px 0 14px;
    color: var(--auth-muted, #64748b);
    font-size: .78rem; font-weight: 600;
    letter-spacing: .04em; text-transform: uppercase;
}
.auth-divider::before, .auth-divider::after{
    content:""; flex:1; height:1px;
    background: linear-gradient(90deg, transparent, var(--auth-border, #e6e8ec), transparent);
}
:root[data-theme="dark"] .auth-divider::before,
:root[data-theme="dark"] .auth-divider::after{
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.12), transparent);
}

.auth-oauth{
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}
.auth-oauth-btn{
    flex: 1 1 0;
    min-width: 130px;
    max-width: 220px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    height: 48px; padding: 0 14px;
    border-radius: 12px;
    border: 1.5px solid var(--auth-border, #e6e8ec);
    background: var(--auth-surface, #ffffff);
    color: var(--auth-text, #0f172a);
    font-weight: 700; font-size: .9rem;
    text-decoration: none; cursor: pointer;
    transition: transform .14s, border-color .18s, box-shadow .2s, background .15s;
    position: relative; overflow: hidden;
}
.auth-oauth-btn i, .auth-oauth-btn svg{ font-size: 1.15rem; flex-shrink: 0; }
.auth-oauth-btn .auth-oauth-label{
    display: inline;
    font-weight: 700;
    letter-spacing: .005em;
}
/* When only 1 provider — emphasize as a single centered CTA */
.auth-oauth:has(> .auth-oauth-btn:only-child) .auth-oauth-btn,
.auth-oauth.is-single .auth-oauth-btn{
    flex: 0 1 auto;
    min-width: 240px;
    max-width: 100%;
    height: 52px;
    font-size: .95rem;
    padding: 0 22px;
    box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--main, #7c5cff) 40%, rgba(15,23,42,.2));
}
/* When 2 providers — center both, even widths, comfortable spacing */
.auth-oauth.is-pair .auth-oauth-btn{
    flex: 0 1 220px;
    height: 50px;
}
.auth-oauth-btn:hover{
    transform: translateY(-2px);
    box-shadow: 0 10px 22px -10px rgba(15,23,42,.18);
}
.auth-oauth-btn:active{ transform: translateY(0); }
:root[data-theme="dark"] .auth-oauth-btn{
    background: var(--auth-surface, #11141b);
    border-color: rgba(255,255,255,.08);
    color: var(--auth-text, #f1f5f9);
}

/* Brand colors on hover */
.auth-oauth-btn.is-google:hover  { border-color: #ea4335; color: #ea4335; }
.auth-oauth-btn.is-discord:hover { border-color: #5865f2; color: #5865f2; }
.auth-oauth-btn.is-line:hover    { border-color: #06c755; color: #06c755; }

/* Icon background */
.auth-oauth-btn .auth-oauth-ic{
    width: 22px; height: 22px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.05rem;
}
.auth-oauth-btn.is-google .auth-oauth-ic   { color: #ea4335; }
.auth-oauth-btn.is-discord .auth-oauth-ic  { color: #5865f2; }
.auth-oauth-btn.is-line .auth-oauth-ic     { color: #06c755; }

@media (min-width: 481px){
    .auth-oauth-btn .auth-oauth-label{ display: inline; }
}
@media (max-width: 480px){
    .auth-oauth{ gap: 8px; }
    .auth-oauth-btn{ padding: 0; }
}

/* Mesh background enhancement */
.auth-shell{ position: relative; overflow-x: hidden; }
.auth-mesh{
    position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
}
/* Mesh orbs removed */
.auth-mesh > span{
    display: none !important;
}
:root[data-theme="dark"] .auth-mesh > span{ opacity: .35; }
@keyframes authMesh1 { 0%,100%{ transform: translate(0,0) scale(1); } 50%{ transform: translate(40px, 30px) scale(1.12); } }
@keyframes authMesh2 { 0%,100%{ transform: translate(0,0) scale(1); } 50%{ transform: translate(-30px, -20px) scale(1.15); } }
@keyframes authMesh3 { 0%,100%{ transform: translate(-50%,-50%) scale(1); } 50%{ transform: translate(-45%,-55%) scale(1.1); } }
@media (prefers-reduced-motion: reduce){
    .auth-mesh > span{ animation: none !important; }
}

/* Auth card refinements */
.auth-card{ position: relative; z-index: 1; backdrop-filter: blur(14px); }
.auth-card-shimmer{
    position: absolute; inset: 0; border-radius: inherit;
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--main, #6366f1) 8%, transparent) 0%,
        transparent 40%);
    pointer-events: none;
    border-radius: inherit;
}

/* Welcome chip animation */
.auth-eyebrow{
    animation: authEyebrow .6s cubic-bezier(.2,.8,.2,1) backwards;
}
@keyframes authEyebrow { from{ opacity: 0; transform: translateY(-6px); } }
.auth-title{ animation: authTitle .65s cubic-bezier(.2,.8,.2,1) .08s backwards; }
@keyframes authTitle { from{ opacity: 0; transform: translateY(-8px); } }
.auth-sub  { animation: authSub .7s cubic-bezier(.2,.8,.2,1) .14s backwards; }
@keyframes authSub  { from{ opacity: 0; transform: translateY(-4px); } }
.auth-form .auth-field,
.auth-form .auth-cta,
.auth-helper,
.auth-divider,
.auth-oauth{
    animation: authField .55s cubic-bezier(.2,.8,.2,1) backwards;
}
.auth-form .auth-field:nth-child(1){ animation-delay: .18s; }
.auth-form .auth-field:nth-child(2){ animation-delay: .22s; }
.auth-form .auth-field:nth-child(3){ animation-delay: .26s; }
.auth-form .auth-field:nth-child(4){ animation-delay: .30s; }
.auth-form .auth-cta{ animation-delay: .34s; }
.auth-divider{ animation-delay: .38s; }
.auth-oauth{ animation-delay: .42s; }
.auth-helper{ animation-delay: .46s; }
@keyframes authField { from{ opacity: 0; transform: translateY(6px); } }

/* OAuth status flash messages (from URL ?oauth_err=...) */
.auth-flash{
    margin: -4px 0 14px;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: .86rem; font-weight: 600;
    display: flex; align-items: center; gap: 8px;
    border: 1px solid;
    animation: authField .5s cubic-bezier(.2,.8,.2,1);
}
.auth-flash.is-error{
    background: color-mix(in srgb, #ef4444 12%, transparent);
    border-color: color-mix(in srgb, #ef4444 35%, transparent);
    color: #b91c1c;
}
.auth-flash.is-info{
    background: color-mix(in srgb, var(--main, #6366f1) 10%, transparent);
    border-color: color-mix(in srgb, var(--main, #6366f1) 32%, transparent);
    color: var(--main, #6366f1);
}
:root[data-theme="dark"] .auth-flash.is-error{ color: #fca5a5; }
