/**
 * CYBER ARENA — CTF Platform Common Styles
 * Shared across all CTF pages
 */

/* ==================== CSS Variables ==================== */
:root {
    --primary: #00ff9d;
    --secondary: #ff006e;
    --accent: #00d4ff;
    --warning: #ffea00;
    --danger: #ff4444;
    --bg-dark: #0a0a0f;
    --bg-card: #12121a;
    --bg-card-hover: #1a1a25;
    --text: #e0e0e0;
    --text-dim: #6a6a7a;
    --grid-color: rgba(0, 255, 157, 0.03);
    --glow: 0 0 20px rgba(0, 255, 157, 0.3);
    --glow-strong: 0 0 30px rgba(0, 255, 157, 0.5), 0 0 60px rgba(0, 255, 157, 0.3);
}

/* ==================== Reset ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Noto Sans SC', 'JetBrains Mono', sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==================== Grid Background ==================== */
.grid-bg {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: -2;
    pointer-events: none;
    will-change: transform;
    transform: translateZ(0);
}

.grid-bg.animated {
    animation: gridMove 30s linear infinite;
}

@keyframes gridMove {
    0% { transform: perspective(500px) rotateX(60deg) translateY(0) translateZ(0); }
    100% { transform: perspective(500px) rotateX(60deg) translateY(50px) translateZ(0); }
}

/* ==================== Blog-style Background Layers ==================== */
.particles {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--primary);
    border-radius: 50%;
    opacity: 0.35;
    animation: floatParticle 20s infinite linear;
    will-change: transform, opacity;
}

@keyframes floatParticle {
    0% {
        transform: translateY(100vh) rotate(0deg) translateZ(0);
        opacity: 0;
    }
    10% { opacity: 0.5; }
    90% { opacity: 0.5; }
    100% {
        transform: translateY(-100vh) rotate(720deg) translateZ(0);
        opacity: 0;
    }
}

.orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    animation: orbFloat 20s ease-in-out infinite;
    pointer-events: none;
    will-change: transform;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: var(--primary);
    top: -200px;
    right: -100px;
    opacity: 0.08;
}

.orb-2 {
    width: 300px;
    height: 300px;
    background: var(--secondary);
    bottom: 10%;
    left: -100px;
    opacity: 0.06;
    animation-delay: -7s;
}

.orb-3 {
    width: 250px;
    height: 250px;
    background: var(--accent);
    top: 50%;
    left: 60%;
    opacity: 0.05;
    animation-delay: -12s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1) translateZ(0); }
    25% { transform: translate(30px, -30px) scale(1.05) translateZ(0); }
    50% { transform: translate(-20px, 20px) scale(0.95) translateZ(0); }
    75% { transform: translate(20px, 30px) scale(1.02) translateZ(0); }
}

/* ==================== Navigation ==================== */
nav {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    padding: 1rem 3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 255, 157, 0.1);
    transition: all 0.3s;
}

nav.scrolled {
    padding: 0.8rem 3rem;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 255, 157, 0.1);
}

nav.transparent-top {
    background: linear-gradient(180deg, var(--bg-dark) 0%, transparent 100%);
    border-bottom: none;
}

nav.transparent-top.scrolled {
    background: rgba(10, 10, 15, 0.95);
    border-bottom: 1px solid rgba(0, 255, 157, 0.1);
}

/* 左上角品牌区：Logo · 博客，同一行不抢眼 */
.nav-brand {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.nav-brand-sep {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.25);
    user-select: none;
}

.nav-blog {
    font-family: 'Noto Sans SC', sans-serif;
    font-size: 0.8rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.45);
    text-decoration: none;
    letter-spacing: 0.02em;
    transition: color 0.2s ease;
}

.nav-blog:hover {
    color: var(--primary);
}

.logo {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--primary);
    text-shadow: var(--glow);
    letter-spacing: 3px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.logo::before { content: '⚔️'; }

.nav-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.25rem;
    list-style: none;
}

.nav-center a {
    font-family: 'Noto Sans SC', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
    letter-spacing: 0.03em;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.nav-center a:hover,
.nav-center a.active {
    color: var(--primary);
    background: rgba(0, 255, 157, 0.06);
    border-bottom-color: rgba(0, 255, 157, 0.4);
}

/* Nav links for simple pages (admin, etc.) */
.nav-links {
    display: flex;
    gap: 2rem;
    list-style: none;
}
.nav-links a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s;
}
.nav-links a:hover { color: var(--primary); }

.hidden { display: none !important; }

/* Nav Right Area */
.nav-right, .user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-writeups {
    padding: 0.5rem 1rem;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s;
}
.nav-writeups:hover { color: var(--primary); }

.nav-points {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--warning);
}

.nav-logout {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 6px 10px;
    border-radius: 8px;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
}
.nav-logout:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.nav-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--bg-dark);
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.3s;
}
.nav-avatar:hover { transform: scale(1.1); }

/* Auth Buttons */
.auth-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    font-family: 'Noto Sans SC', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s;
}
.login-btn {
    background: transparent;
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.login-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.register-btn {
    background: var(--primary);
    color: var(--bg-dark);
    font-weight: 700;
}
.register-btn:hover {
    box-shadow: var(--glow);
}

/* ==================== Auth Modal ==================== */
.auth-modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}
.auth-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.auth-modal {
    background: var(--bg-card);
    border: 1px solid rgba(0, 255, 157, 0.2);
    border-radius: 20px;
    padding: 40px;
    width: 90%;
    max-width: 440px;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s;
}
.auth-modal-overlay.active .auth-modal {
    transform: translateY(0);
}

.auth-modal-close {
    position: absolute;
    top: 16px; right: 20px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s;
}
.auth-modal-close:hover { color: var(--text); }

.auth-modal-header {
    text-align: center;
    margin-bottom: 30px;
}
.auth-modal-header h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.3rem;
    color: var(--primary);
    margin-bottom: 8px;
}
.auth-modal-header p {
    color: var(--text-dim);
    font-size: 0.9rem;
}

.auth-field {
    margin-bottom: 20px;
}
.auth-field label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 8px;
    font-family: 'JetBrains Mono', monospace;
}
.auth-field input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s;
}
.auth-field input:focus {
    border-color: var(--primary);
}

.auth-error {
    background: rgba(255, 68, 68, 0.1);
    border: 1px solid rgba(255, 68, 68, 0.3);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--danger);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.auth-submit {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    border: none;
    border-radius: 10px;
    color: var(--bg-dark);
    font-weight: 700;
    font-size: 1rem;
    font-family: 'Orbitron', sans-serif;
    cursor: pointer;
    transition: all 0.3s;
}
.auth-submit:hover {
    box-shadow: var(--glow-strong);
}
.auth-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    font-size: 0.85rem;
    color: var(--text-dim);
}
.auth-switch button {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
}
.auth-switch button:hover {
    text-decoration: underline;
}

/* ==================== Toast Notifications ==================== */
.ctf-toast {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 0.9rem;
    z-index: 3000;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    max-width: 400px;
    backdrop-filter: blur(10px);
}
.ctf-toast.show {
    transform: translateX(0);
}
.ctf-toast-info {
    background: rgba(0, 212, 255, 0.15);
    border: 1px solid rgba(0, 212, 255, 0.3);
    color: var(--accent);
}
.ctf-toast-success {
    background: rgba(0, 255, 157, 0.15);
    border: 1px solid rgba(0, 255, 157, 0.3);
    color: var(--primary);
}
.ctf-toast-warning {
    background: rgba(255, 234, 0, 0.15);
    border: 1px solid rgba(255, 234, 0, 0.3);
    color: var(--warning);
}
.ctf-toast-error {
    background: rgba(255, 68, 68, 0.15);
    border: 1px solid rgba(255, 68, 68, 0.3);
    color: var(--danger);
}

/* ==================== Loading / Spinner ==================== */
.ctf-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 80px 0;
}
.ctf-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 255, 157, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== Empty State ==================== */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-dim);
}
.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 16px;
}
.empty-state h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    color: var(--text);
    margin-bottom: 8px;
}

/* ==================== Footer ==================== */
footer {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding: 40px 3rem;
    text-align: center;
}
.footer-logo {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--primary);
    text-shadow: var(--glow);
    margin-bottom: 8px;
}
.footer-desc {
    color: var(--text-dim);
    max-width: 500px;
    margin: 0 auto 20px;
    line-height: 1.6;
    font-size: 0.9rem;
}
.footer-links {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
}
.footer-links a {
    color: var(--text-dim);
    text-decoration: none;
    transition: color 0.3s;
}
.footer-links a:hover { color: var(--primary); }
.footer-copyright {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.3);
}

/* ==================== Scrollbar ==================== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}
::selection {
    background: var(--primary);
    color: var(--bg-dark);
}

/* ==================== Breadcrumb ==================== */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 32px;
}
.breadcrumb a {
    color: var(--text-dim);
    text-decoration: none;
    transition: color 0.3s;
}
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { opacity: 0.4; }
.breadcrumb .current { color: var(--primary); }

/* ==================== Back Button ==================== */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(0, 255, 157, 0.08);
    border: 1px solid rgba(0, 255, 157, 0.2);
    border-radius: 10px;
    color: var(--primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 16px;
}
.back-btn:hover {
    background: rgba(0, 255, 157, 0.15);
    border-color: var(--primary);
    transform: translateX(-4px);
}

/* ==================== Challenge Card (shared) ==================== */
.challenge-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 24px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    display: block;
}
.challenge-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px; height: 100%;
    background: var(--primary);
    opacity: 0;
    transition: opacity 0.3s;
}
.challenge-card:hover {
    transform: translateX(8px);
    border-color: rgba(0, 255, 157, 0.2);
    background: var(--bg-card-hover);
}
.challenge-card:hover::before { opacity: 1; }

.challenge-card.solved {
    border-color: rgba(0, 255, 157, 0.3);
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(0, 255, 157, 0.05) 100%);
}
.challenge-card.solved::after {
    content: '✓';
    position: absolute;
    top: 16px; right: 16px;
    width: 28px; height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: var(--bg-dark);
    border-radius: 50%;
    font-weight: 700;
}

.challenge-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}
.challenge-category {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    padding: 4px 12px;
    background: rgba(0, 255, 157, 0.1);
    color: var(--primary);
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.challenge-difficulty { display: flex; gap: 4px; }
.diff-dot {
    width: 8px; height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}
.diff-dot.active {
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
}

.challenge-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.05rem;
    margin-bottom: 10px;
    color: var(--text);
}
.challenge-desc {
    font-size: 0.85rem;
    color: var(--text-dim);
    line-height: 1.6;
    margin-bottom: 20px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.challenge-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-dim);
}
.challenge-points {
    color: var(--accent);
    font-weight: 700;
}
.challenge-solves {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ==================== Difficulty Labels ==================== */
.diff-easy { color: var(--primary); }
.diff-medium { color: var(--accent); }
.diff-hard { color: var(--warning); }
.diff-expert { color: #ff6b35; }
.diff-insane { color: var(--danger); }

/* ==================== Pagination ==================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 40px;
    padding-bottom: 40px;
}
.page-btn {
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s;
}
.page-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}
.page-btn.active {
    background: rgba(0, 255, 157, 0.15);
    border-color: var(--primary);
    color: var(--primary);
}
.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.page-info {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-dim);
    padding: 0 8px;
}

/* ==================== Responsive Base ==================== */
@media (max-width: 768px) {
    nav { padding: 0.8rem 1.2rem; }
    .nav-center { display: none; }
    footer { padding: 30px 1.5rem; }
    .particles { display: none; }
    .orb {
        filter: blur(60px);
        opacity: 0.04;
    }
}

@media (prefers-reduced-motion: reduce) {
    .grid-bg,
    .particle,
    .orb {
        animation: none !important;
    }
}
