﻿/* ========================================
   Gate Design
   ======================================== */

/* ---------- Design tokens (Light) ---------- */
:root {
    --bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-overlay: rgba(248, 250, 252, 0.95);
    --card: rgba(255, 255, 255, 0.98);
    --text: #1e293b;
    --muted: #64748b;
    --border: rgba(226, 232, 240, 0.5);
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-contrast: #ffffff;
    --warning: #dc2626;
    --danger: #ef4444;
    --success: #10b981;
    --info: #0ea5e9;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 20px 60px rgba(99, 102, 241, 0.15);
}

/* ---------- Dark theme ---------- */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
        --bg-overlay: rgba(15, 23, 42, 0.95);
        --card: rgba(30, 41, 59, 0.98);
        --text: #f1f5f9;
        --muted: #94a3b8;
        --border: rgba(51, 65, 85, 0.5);
        --primary: #818cf8;
        --primary-hover: #a5b4fc;
        --primary-contrast: #1e1b4b;
        --warning: #f59e0b;
        --danger: #ef4444;
        --success: #34d399;
        --info: #38bdf8;
        --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
        --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.4);
        --shadow-xl: 0 20px 60px rgba(129, 140, 248, 0.1);
    }
}

/* ---------- Base styles ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
    background: var(--bg);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

    /* Background pattern overlay */
    body::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-image: radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.05) 0%, transparent 50%), radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
        pointer-events: none;
        z-index: 0;
    }

/* ---------- Layout ---------- */
.viewport {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    z-index: 1;
    padding-bottom: 10vh;
}

@supports (min-height: 100dvh) {
    .viewport {
        min-height: 100dvh;
    }
}

.gate {
    width: min(480px, 100%);
    background: var(--card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 40px 36px;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.4s ease-out;
    position: relative;
    overflow: hidden;
}

    /* Decorative gradient border effect */
    .gate::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 3px;
        background: linear-gradient(90deg, var(--primary), #ec4899, var(--primary));
        background-size: 200% 100%;
        animation: shimmer 3s ease-in-out infinite;
    }

    /* Rate limit variant */
    .gate.gate--rate-limit::before {
        background: linear-gradient(90deg, var(--warning), var(--danger), var(--warning));
    }

/* ---------- Animations ---------- */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shimmer {
    0%, 100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

/* ---------- Typography ---------- */
.icon {
    font-size: 48px;
    margin-bottom: 16px;
    display: inline-block;
    animation: bounce 0.6s ease-out 0.2s;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
}

.icon--warning {
    color: var(--warning);
    animation: pulse 2s ease-in-out infinite;
}

.icon--danger {
    color: var(--danger);
}

.icon--svg {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    padding: 12px;
    border-radius: 16px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

h1 {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 8px;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sub {
    color: var(--muted);
    margin: 0 0 32px;
    font-size: 15px;
}

/* ---------- Forms ---------- */
.password-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    transition: all 0.2s ease;
    font-weight: 500;
}

    .input::placeholder {
        color: var(--muted);
        opacity: 0.7;
    }

    .input:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
        transform: translateY(-1px);
    }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 24px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    border: none;
}

    .btn::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.2);
        transform: translate(-50%, -50%);
        transition: width 0.6s, height 0.6s;
    }

    .btn:active::before {
        width: 300px;
        height: 300px;
    }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: var(--primary-contrast);
    box-shadow: var(--shadow-md);
}

    .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-lg);
    }

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 2px solid var(--border);
}

    .btn-secondary:hover {
        background: var(--bg-overlay);
        border-color: var(--primary);
        color: var(--primary);
    }

.btn-link {
    background: transparent;
    color: var(--primary);
    padding: 12px 16px;
    font-size: 14px;
}

    .btn-link:hover {
        color: var(--primary-hover);
        text-decoration: underline;
    }

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 2px solid transparent;
    padding: 10px 20px;
    font-size: 14px;
}

    .btn-ghost:hover {
        color: var(--text);
        background: rgba(0, 0, 0, 0.05);
    }

/* ---------- Helpers ---------- */
.divider {
    margin: 24px 0;
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

    .divider::before,
    .divider::after {
        content: "";
        height: 1px;
        flex: 1;
        background: linear-gradient(90deg, transparent, var(--border), transparent);
    }

.warning {
    color: var(--warning);
    font-size: 14px;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
    border-left: 3px solid var(--warning);
    animation: shake 0.5s ease-in-out;
}

.info-box {
    padding: 16px;
    background: rgba(14, 165, 233, 0.1);
    border-radius: 12px;
    border-left: 3px solid var(--info);
    color: var(--text);
    font-size: 14px;
    margin: 20px 0;
}

.hint {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 16px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 24px;
}

.captcha {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    justify-content: center;
    background: var(--bg-overlay);
}

.countdown {
    display: inline-block;
    font-weight: 700;
    color: var(--danger);
    font-size: 18px;
    padding: 4px 8px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 6px;
    margin: 0 4px;
}

/* ---------- Loading state ---------- */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    margin: auto;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ---------- Mobile optimizations ---------- */
@media (max-width: 480px) {
    .gate {
        padding: 32px 24px;
        border-radius: 20px;
    }

    h1 {
        font-size: 24px;
    }

    .btn {
        width: 100%;
    }

    .actions {
        flex-direction: column;
    }

        .actions .btn {
            width: 100%;
        }
}
