/* ================================================================
   Valax Gate CSS — Sci-Fi / Dark Premium Design
   GPU-accelerated animations, Glassmorphism, Neon effects
   ================================================================ */

/* ── Design Tokens ──────────────────────────────────────────── */
:root {
    --clr-bg:            #000000;
    --clr-bg-2:          #030712;
    --clr-surface:       rgba(255, 255, 255, 0.03);
    --clr-surface-hover: rgba(255, 255, 255, 0.06);
    --clr-border:        rgba(255, 255, 255, 0.08);
    --clr-border-accent: rgba(59, 130, 246, 0.35);

    --clr-blue:          #3B82F6;
    --clr-blue-dim:      rgba(59, 130, 246, 0.15);
    --clr-blue-glow:     rgba(59, 130, 246, 0.4);
    --clr-violet:        #8B5CF6;
    --clr-violet-dim:    rgba(139, 92, 246, 0.12);
    --clr-cyan:          #06B6D4;
    --clr-green:         #10B981;
    --clr-green-dim:     rgba(16, 185, 129, 0.15);
    --clr-red:           #EF4444;
    --clr-red-dim:       rgba(239, 68, 68, 0.15);
    --clr-yellow:        #F59E0B;

    --clr-text-primary:  #F9FAFB;
    --clr-text-secondary:#9CA3AF;
    --clr-text-dim:      #6B7280;

    --font-sans:         'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono:         'JetBrains Mono', 'Fira Code', monospace;

    --radius-sm:         8px;
    --radius-md:         12px;
    --radius-lg:         16px;
    --radius-xl:         24px;
    --radius-full:       9999px;

    --ease-spring:       cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-out:          cubic-bezier(0.22, 1, 0.36, 1);
    --ease-in:           cubic-bezier(0.76, 0, 0.24, 1);

    --shadow-glow-blue:  0 0 40px rgba(59, 130, 246, 0.25), 0 0 80px rgba(59, 130, 246, 0.1);
    --shadow-glass:      0 8px 32px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.06);
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    background-color: var(--clr-bg);
    color: var(--clr-text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* ── Animated Background ─────────────────────────────────────── */
.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 0%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    pointer-events: none;
    z-index: 0;
    will-change: transform;
    animation: glowFloat 8s ease-in-out infinite alternate;
}

.bg-glow--blue {
    width: 600px;
    height: 400px;
    background: radial-gradient(ellipse, rgba(59, 130, 246, 0.3) 0%, transparent 70%);
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    animation-delay: 0s;
}

.bg-glow--purple {
    width: 500px;
    height: 300px;
    background: radial-gradient(ellipse, rgba(139, 92, 246, 0.2) 0%, transparent 70%);
    bottom: -50px;
    right: 10%;
    animation-delay: -4s;
}

@keyframes glowFloat {
    0%   { transform: translateX(-50%) translateY(0px) scale(1); }
    100% { transform: translateX(-50%) translateY(-30px) scale(1.05); }
}

/* Particle canvas */
#particleCanvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
}

/* ── Gate Container ──────────────────────────────────────────── */
.gate-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 480px;
    padding: 0 1.5rem;
}

/* ── Phase visibility ─────────────────────────────────────────── */
.phase {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
    animation: phaseIn 0.6s var(--ease-out) both;
}

.phase--hidden {
    display: none !important;
}

@keyframes phaseIn {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes phaseOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(-20px) scale(0.98); }
}

/* ── Phase 1: Loading ─────────────────────────────────────────── */
.logo-wrapper {
    position: relative;
    width: 96px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-ring {
    position: absolute;
    inset: 0;
}

.logo-ring__inner {
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(59,130,246,0.1) 0%, transparent 70%);
    animation: pulse 2s ease-in-out infinite;
}

.logo-ring__svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.logo-ring__track {
    stroke: rgba(255,255,255,0.06);
    stroke-width: 2;
    fill: none;
}

.logo-ring__progress {
    stroke: url(#ringGradient);
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 0.4s var(--ease-out);
}

.logo-icon {
    position: relative;
    z-index: 1;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    backdrop-filter: blur(8px);
}

.logo-icon img {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.logo-fallback {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--clr-blue), var(--clr-violet));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    align-items: center;
    justify-content: center;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50%       { opacity: 1;   transform: scale(1.05); }
}

.loading-title {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
    background: linear-gradient(135deg, #ffffff 0%, rgba(255,255,255,0.7) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.loading-subtitle {
    font-size: 0.875rem;
    color: var(--clr-text-secondary);
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
    min-height: 1.4em;
}

/* Animated dots */
.dots::after {
    content: '...';
    animation: dotCycle 1.5s infinite;
}
@keyframes dotCycle {
    0%   { content: '.'; }
    33%  { content: '..'; }
    66%  { content: '...'; }
    100% { content: '.'; }
}

.loading-bar-wrapper {
    width: 100%;
    max-width: 300px;
}

.loading-bar {
    position: relative;
    height: 2px;
    background: rgba(255,255,255,0.06);
    border-radius: var(--radius-full);
    overflow: visible;
}

.loading-bar__fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--clr-blue), var(--clr-violet));
    border-radius: var(--radius-full);
    transition: width 0.3s var(--ease-out);
    position: relative;
}

.loading-bar__fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 8px 2px var(--clr-blue);
}

.loading-bar__glow {
    position: absolute;
    inset: -4px -2px;
    background: linear-gradient(90deg, transparent, var(--clr-blue-glow), transparent);
    border-radius: var(--radius-full);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

/* ── Phase 2: Analysis ─────────────────────────────────────────── */
.analysis-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.analysis-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--clr-blue-dim);
    border: 1px solid var(--clr-border-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--clr-blue);
}

.analysis-icon svg { width: 24px; height: 24px; }

.analysis-title {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.analysis-subtitle {
    font-size: 0.8125rem;
    color: var(--clr-text-secondary);
}

/* Checklist */
.checklist {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-glass);
    list-style: none;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--clr-border);
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.35s var(--ease-out), transform 0.35s var(--ease-out);
    font-size: 0.8125rem;
}

.checklist-item:last-child { border-bottom: none; }

.checklist-item--visible {
    opacity: 1;
    transform: translateX(0);
}

.checklist-item__icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s var(--ease-out);
}

/* States */
.checklist-item__icon--pending {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
}

.checklist-item__icon--running {
    background: var(--clr-blue-dim);
    border: 1px solid var(--clr-border-accent);
}

.checklist-item__icon--pass {
    background: var(--clr-green-dim);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: var(--clr-green);
}

.checklist-item__icon--fail {
    background: var(--clr-red-dim);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: var(--clr-red);
}

.checklist-item__icon--warn {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: var(--clr-yellow);
}

.checklist-item__icon svg { width: 12px; height: 12px; }

/* Spinner for running state */
.spinner {
    width: 10px;
    height: 10px;
    border: 1.5px solid var(--clr-blue-dim);
    border-top-color: var(--clr-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.checklist-item__label {
    flex: 1;
    color: var(--clr-text-secondary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    transition: color 0.3s;
}

.checklist-item--visible .checklist-item__label { color: var(--clr-text-primary); }

.checklist-item__badge {
    font-size: 0.65rem;
    font-family: var(--font-mono);
    padding: 0.15em 0.5em;
    border-radius: var(--radius-full);
    font-weight: 500;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.3s, transform 0.3s var(--ease-spring);
}

.checklist-item__badge--visible {
    opacity: 1;
    transform: scale(1);
}

.checklist-item__badge--pass  { background: var(--clr-green-dim);  color: var(--clr-green); border: 1px solid rgba(16,185,129,0.3); }
.checklist-item__badge--fail  { background: var(--clr-red-dim);    color: var(--clr-red);   border: 1px solid rgba(239,68,68,0.3); }
.checklist-item__badge--warn  { background: rgba(245,158,11,0.12); color: var(--clr-yellow);border: 1px solid rgba(245,158,11,0.3); }

/* Analysis progress bar */
.analysis-progress {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.analysis-progress__bar {
    flex: 1;
    height: 3px;
    background: rgba(255,255,255,0.06);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.analysis-progress__fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--clr-blue), var(--clr-cyan));
    border-radius: var(--radius-full);
    transition: width 0.4s var(--ease-out);
}

.analysis-progress__label {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--clr-text-dim);
    min-width: 2.5rem;
    text-align: right;
}

/* ── Phase 3: Turnstile ─────────────────────────────────────── */
.turnstile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.turnstile-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--clr-violet);
}

.turnstile-icon svg { width: 24px; height: 24px; }

.turnstile-title {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.turnstile-subtitle {
    font-size: 0.8125rem;
    color: var(--clr-text-secondary);
}

.turnstile-widget-wrapper {
    display: flex;
    justify-content: center;
    padding: 1.5rem;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    width: 100%;
    min-height: 72px;
    align-items: center;
}

.turnstile-note {
    font-size: 0.75rem;
    color: var(--clr-text-dim);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.turnstile-error {
    color: var(--clr-red);
    font-size: 0.8125rem;
    background: var(--clr-red-dim);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    width: 100%;
    text-align: center;
}

/* ── Phase 4: Success ─────────────────────────────────────────── */
.success-animation {
    position: relative;
}

.success-circle {
    width: 80px;
    height: 80px;
}

.success-check {
    width: 100%;
    height: 100%;
}

.success-check__circle {
    stroke: var(--clr-green);
    stroke-width: 2;
    stroke-dasharray: 157;
    stroke-dashoffset: 157;
    animation: drawCircle 0.6s var(--ease-out) 0.2s forwards;
}

.success-check__path {
    stroke: var(--clr-green);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 60;
    stroke-dashoffset: 60;
    animation: drawCheck 0.4s var(--ease-out) 0.7s forwards;
}

@keyframes drawCircle {
    to { stroke-dashoffset: 0; }
}
@keyframes drawCheck {
    to { stroke-dashoffset: 0; }
}

.success-title {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--clr-green);
}

.success-subtitle {
    font-size: 0.8125rem;
    color: var(--clr-text-secondary);
    font-family: var(--font-mono);
}

/* ── Phase 5: Blocked ─────────────────────────────────────────── */
.blocked-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--clr-red-dim);
    border: 1px solid rgba(239, 68, 68, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--clr-red);
    animation: blockedPulse 2s ease-in-out infinite;
}

.blocked-icon svg { width: 28px; height: 28px; }

@keyframes blockedPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
    50%       { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
}

.blocked-title {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--clr-red);
}

.blocked-subtitle {
    font-size: 0.875rem;
    color: var(--clr-text-secondary);
}

.blocked-detail {
    font-size: 0.75rem;
    color: var(--clr-text-dim);
    max-width: 280px;
}

/* ── Gate Footer ─────────────────────────────────────────────── */
.gate-footer {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.6875rem;
    color: var(--clr-text-dim);
    font-family: var(--font-mono);
    z-index: 10;
    white-space: nowrap;
}

.gate-footer__sep { color: rgba(255,255,255,0.15); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 480px) {
    .gate-container { padding: 0 1rem; }
    .loading-title  { font-size: 1.875rem; }
    .checklist      { padding: 0.75rem; }
}

/* ── Reduced Motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ── SVG Gradient defs (injected inline via JS) ─────────────── */
/* Handled by JS to avoid SVG namespace issues */
