/* === CSS Variables === */
:root {
    --bg: #0a0a0f;
    --bg-card: #12121a;
    --bg-card-hover: #1a1a25;
    --bg-input: #1a1a28;
    --text: #e8e8ed;
    --text-muted: #8888a0;
    --text-dim: #5a5a72;
    --accent: #a78bfa;
    --accent-glow: #c4b5fd;
    --accent-dim: #7c3aed;
    --danger: #f87171;
    --danger-hover: #ef4444;
    --border: #1e1e2e;
    --radius: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 4px 20px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 8px rgba(0,0,0,0.5), 0 8px 40px rgba(0,0,0,0.4);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* === Background Effects === */
.bg-gradient {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(167, 139, 250, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(167, 139, 250, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(124, 58, 237, 0.04) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
}

.bg-particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--accent);
    border-radius: 50%;
    opacity: 0;
    animation: particleFloat 6s ease-in-out infinite;
}

@keyframes particleFloat {
    0% { opacity: 0; transform: translateY(0) scale(1); }
    20% { opacity: 0.8; }
    50% { opacity: 0.3; transform: translateY(-40px) scale(1.5); }
    80% { opacity: 0.6; }
    100% { opacity: 0; transform: translateY(20px) scale(0.5); }
}

/* === Container === */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.container-sm { max-width: 780px; }

/* === Header === */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    background: rgba(10, 10, 15, 0.75);
    border-bottom: 1px solid var(--border);
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.logo-dot {
    color: var(--accent);
    text-shadow: 0 0 20px var(--accent-glow);
}

.nav { display: flex; align-items: center; gap: 4px; }

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    transition: all var(--transition);
}

.nav-link:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-link.active { color: var(--accent); background: rgba(167, 139, 250, 0.1); }

.nav-login {
    color: var(--accent);
    border: 1px solid rgba(167, 139, 250, 0.3);
}

.nav-login:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.nav-new {
    background: var(--accent);
    color: #fff !important;
}

.nav-new:hover { background: var(--accent-dim); }

.nav-logout { color: var(--danger); }
.nav-logout:hover { background: rgba(248, 113, 113, 0.1); }

/* Mobile menu toggle */
.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-muted);
    border-radius: 2px;
    transition: var(--transition);
}

/* === Main === */
.main { position: relative; z-index: 1; min-height: calc(100vh - 64px - 80px); }

/* === Hero === */
.hero {
    text-align: center;
    padding: 80px 0 60px;
}

.hero-tag {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent);
    background: rgba(167, 139, 250, 0.08);
    padding: 6px 16px;
    border-radius: var(--radius-full);
    margin-bottom: 24px;
}

/* === 3D Animated Hero Tag === */
.hero-tag-3d {
    font-family: 'Playfair Display', serif;
    font-size: 3.5rem;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0.08em;
    background: none;
    padding: 8px 0;
    position: relative;
    display: inline-block;
    color: transparent;
    background-clip: text;
    -webkit-background-clip: text;
    background-image: linear-gradient(
        135deg,
        #c4b5fd 0%,
        #ffffff 25%,
        #a78bfa 50%,
        #e9d5ff 75%,
        #c4b5fd 100%
    );
    background-size: 300% 300%;
    animation: shimmer3d 3s ease-in-out infinite, floatIdle 4s ease-in-out infinite;
    cursor: default;
    user-select: none;
    transform-style: preserve-3d;
    filter: drop-shadow(0 0 20px rgba(167, 139, 250, 0.5))
            drop-shadow(0 0 40px rgba(167, 139, 250, 0.25));
}

.hero-tag-3d::before {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #e9d5ff 0%, #7c3aed 50%, #4c1d95 100%);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    transform: translateZ(-15px) scale(0.92);
    opacity: 0.4;
    filter: blur(4px);
    animation: shadowFloat 4s ease-in-out infinite;
}

.hero-tag-3d::after {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #a78bfa 0%, #5b21b6 100%);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    transform: translateZ(-8px) scale(0.95);
    opacity: 0.3;
    filter: blur(2px);
    animation: shadowFloat 4s ease-in-out infinite 0.5s;
}

@keyframes floatIdle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

@keyframes shadowFloat {
    0%, 100% {
        transform: translateY(0) scale(0.92);
        opacity: 0.3;
    }
    50% {
        transform: translateY(12px) scale(0.88);
        opacity: 0.15;
    }
}

@keyframes shimmer3d {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.hero-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -1px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--text) 30%, var(--accent-glow) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-sub {
    font-size: 1.1rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* === Posts Section === */
.posts-section { padding-bottom: 80px; }

.posts-header { margin-bottom: 40px; }

.posts-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.posts-divider {
    width: 60px;
    height: 3px;
    background: var(--accent);
    border-radius: var(--radius-full);
}

.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 24px;
}

/* === Post Card === */
.post-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition);
}

.post-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(167, 139, 250, 0.2);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.post-card-link { text-decoration: none; color: inherit; display: block; }

.post-card-image { height: 180px; overflow: hidden; }

.post-card-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(167,139,250,0.2) 0%, rgba(124,58,237,0.1) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.post-card-placeholder span {
    font-family: 'Playfair Display', serif;
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--accent);
    opacity: 0.7;
}

.post-card-body { padding: 24px; }

.post-card-date {
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 500;
}

.post-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 8px 0;
    line-height: 1.3;
    color: var(--text);
}

.post-card-excerpt {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 16px;
}

.post-card-more {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    transition: var(--transition);
}

.post-card:hover .post-card-more { color: var(--accent-glow); }

/* === Empty State === */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 24px;
}

/* === Single Post === */
.single-post { padding: 60px 0 80px; }

.single-post-header { margin-bottom: 40px; }

.back-link {
    display: inline-block;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 16px;
    transition: color var(--transition);
}

.back-link:hover { color: var(--accent); }

.single-post-date {
    display: inline-block;
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 500;
    margin-bottom: 8px;
}

.single-post-updated {
    display: inline-block;
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-left: 12px;
    margin-bottom: 8px;
}

.single-post-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.75rem, 4vw, 2.75rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.single-post-content {
    font-size: 1.05rem;
    line-height: 1.9;
    color: var(--text);
}

.single-post-actions {
    display: flex;
    gap: 12px;
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

/* === Auth === */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 64px - 80px);
    padding: 40px 0;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow);
}

.auth-header { text-align: center; margin-bottom: 32px; }

.auth-header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.auth-header p { color: var(--text-muted); font-size: 0.95rem; }

.auth-footer { text-align: center; margin-top: 24px; }

.auth-footer a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color var(--transition);
}

.auth-footer a:hover { color: var(--accent); }

/* === Forms === */
.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15);
}

.form-input-lg { font-size: 1.1rem; padding: 14px 18px; }

.form-input::placeholder { color: var(--text-dim); }

.form-textarea {
    width: 100%;
    padding: 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.8;
    resize: vertical;
    transition: all var(--transition);
    outline: none;
}

.form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15);
}

.form-textarea::placeholder { color: var(--text-dim); }

.password-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
    transition: color var(--transition);
}

.password-toggle:hover { color: var(--text-muted); }

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-dim);
    box-shadow: 0 4px 20px rgba(167, 139, 250, 0.3);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(167, 139, 250, 0.1);
    color: var(--accent);
    border: 1px solid rgba(167, 139, 250, 0.2);
}

.btn-secondary:hover {
    background: rgba(167, 139, 250, 0.18);
    border-color: var(--accent);
}

.btn-danger {
    background: rgba(248, 113, 113, 0.1);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.btn-danger:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover { background: rgba(255,255,255,0.04); color: var(--text); }

.btn-block { width: 100%; }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

/* === Alert === */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.alert-error {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.25);
    color: var(--danger);
}

/* === Admin === */
.admin-section { padding: 60px 0 80px; }

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}

.admin-header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 1.75rem;
    font-weight: 700;
}

.admin-list { display: flex; flex-direction: column; gap: 8px; }

.admin-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
    gap: 16px;
}

.admin-item:hover { border-color: rgba(167, 139, 250, 0.2); }

.admin-item-info { flex: 1; min-width: 0; }

.admin-item-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-item-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.admin-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* === Editor === */
.editor-header { margin-bottom: 32px; }

.editor-header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 1.75rem;
    font-weight: 700;
    margin-top: 8px;
}

.editor-form { margin-bottom: 40px; }

.editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* === Footer === */
.footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 32px 0;
    border-top: 1px solid var(--border);
}

.footer p { color: var(--text-dim); font-size: 0.85rem; }

/* === Toast === */
.toast {
    position: fixed;
    bottom: 32px;
    right: 32px;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 14px 24px;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 200;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
}

.toast.show { opacity: 1; transform: translateY(0); }

/* === Music Player === */
.music-player {
    position: fixed;
    bottom: 32px;
    left: 32px;
    z-index: 150;
}

.music-toggle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: all var(--transition);
    box-shadow: var(--shadow);
    position: relative;
}

.music-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 20px rgba(167, 139, 250, 0.2);
    transform: scale(1.05);
}

.music-icon {
    display: inline-block;
    line-height: 1;
    transition: transform 0.4s ease;
}

.music-player.playing .music-toggle {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 24px rgba(167, 139, 250, 0.35);
}

.music-player.playing .music-icon {
    animation: musicBounce 0.6s ease-in-out infinite;
}

@keyframes musicBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.music-player.playing .music-toggle::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(167, 139, 250, 0.3);
    animation: musicRing 1.5s ease-out infinite;
}

@keyframes musicRing {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.6); opacity: 0; }
}

@media (max-width: 768px) {
    .music-player {
        bottom: 20px;
        left: 20px;
    }
}

/* === Responsive === */
@media (max-width: 768px) {
    .header .container { height: 56px; }

    .menu-toggle { display: flex; }

    .nav {
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        background: rgba(10, 10, 15, 0.95);
        backdrop-filter: blur(20px);
        flex-direction: column;
        padding: 16px;
        gap: 2px;
        border-bottom: 1px solid var(--border);
        transform: translateY(-100%);
        opacity: 0;
        pointer-events: none;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .nav.open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .nav-link {
        display: block;
        padding: 12px 16px;
        border-radius: var(--radius);
    }

    .posts-grid {
        grid-template-columns: 1fr;
    }

    .hero { padding: 60px 0 40px; }

    .auth-card { padding: 32px 24px; }

    .admin-item { flex-direction: column; align-items: flex-start; gap: 12px; }
    .admin-item-actions { width: 100%; }
}
