@layer base, layout, components, theme;

@layer base {
    :root {
        /* Dark Mode (Default) */
        --bg-color: oklch(15% 0.02 240);
        --bg-primary: oklch(15% 0.02 240);
        --text-color: oklch(95% 0.01 240);
        --accent-color: oklch(70% 0.15 40);
        --header-bg: oklch(20% 0.03 240 / 0.8);
        --card-bg: rgba(255, 255, 255, 0.05);
        --filter-bg: oklch(15% 0.02 240 / 0.8);
        --border-color: rgba(255, 255, 255, 0.1);
        --btn-grad: linear-gradient(45deg, #444, #222);
        --font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
        --shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    }

    :root.light-mode {
        /* Light Mode */
        --bg-color: oklch(98% 0.01 240);
        --bg-primary: oklch(98% 0.01 240);
        --text-color: oklch(20% 0.02 240);
        --accent-color: oklch(60% 0.18 40);
        --header-bg: oklch(95% 0.02 240 / 0.8);
        --card-bg: rgba(0, 0, 0, 0.05);
        --filter-bg: oklch(98% 0.01 240 / 0.8);
        --border-color: rgba(0, 0, 0, 0.1);
        --btn-grad: linear-gradient(45deg, #eee, #ddd);
        --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    }

    * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
    }

    body {
        background-color: var(--bg-color);
        color: var(--text-color);
        font-family: var(--font-family);
        line-height: 1.6;
        background-image: 
            radial-gradient(circle at 50% 0%, var(--header-bg) 0%, transparent 50%),
            url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3%3Ffilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
        background-attachment: fixed;
        transition: background-color 0.3s ease, color 0.3s ease;
    }

    .container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 20px;
    }
}

@layer layout {
    /* Global Navigation */
    .global-nav {
        background: var(--bg-primary);
        border-bottom: 1px solid var(--border-color);
        padding: 1rem 0;
        position: sticky;
        top: 0;
        z-index: 2000;
        backdrop-filter: blur(15px);
    }
    .nav-flex {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .logo {
        font-size: 1.4rem;
        font-weight: 900;
        text-decoration: none;
        color: var(--text-color);
        letter-spacing: -1.5px;
    }
    .nav-links {
        list-style: none;
        display: flex;
        gap: 1.5rem;
    }
    .nav-links a {
        text-decoration: none;
        color: var(--text-color);
        font-weight: 600;
        font-size: 0.95rem;
        opacity: 0.6;
        transition: all 0.3s;
    }
    .nav-links a:hover, .nav-links a.active {
        opacity: 1;
        color: var(--accent-color);
    }

    header {
        padding: 60px 0 60px;
        text-align: center;
        background: linear-gradient(to bottom, var(--header-bg), transparent);
        position: relative;
    }

    .header-controls {
        position: absolute;
        top: 30px;
        right: 30px;
        display: flex;
        align-items: center;
        gap: 15px;
        z-index: 1000;
    }

    header h1 {
        font-size: clamp(2.5rem, 5vw, 4rem);
        font-weight: 800;
        letter-spacing: -1px;
        margin-bottom: 10px;
        background: linear-gradient(45deg, var(--accent-color), oklch(80% 0.1 60));
        background-clip: text;
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
    }

    .subtitle {
        font-size: 1.2rem;
        color: var(--text-color);
        opacity: 0.7;
        font-weight: 300;
    }

    .lang-selector {
        display: flex;
        background: var(--card-bg);
        padding: 4px;
        border-radius: 12px;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .lang-btn {
        background: transparent;
        border: none;
        color: var(--text-color);
        padding: 6px 12px;
        border-radius: 8px;
        cursor: pointer;
        font-size: 0.8rem;
        font-weight: 600;
        transition: all 0.2s ease;
        opacity: 0.6;
    }

    .lang-btn:hover {
        opacity: 1;
    }

    .lang-btn.active {
        background: var(--accent-color);
        color: white;
        opacity: 1;
    }

    .theme-toggle {
        background: var(--card-bg);
        border: 1px solid rgba(255, 255, 255, 0.1);
        padding: 10px;
        border-radius: 50%;
        cursor: pointer;
        width: 40px;
        height: 40px;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 1.1rem;
        transition: all 0.3s ease;
    }

    .theme-toggle:hover {
        transform: scale(1.1);
    }

    .filter-bar {
        position: sticky;
        top: 0;
        z-index: 100;
        background: var(--filter-bg);
        backdrop-filter: blur(20px);
        padding: 20px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        margin-bottom: 60px;
    }

    .filter-bar .container {
        display: flex;
        justify-content: center;
        gap: 10px;
        flex-wrap: wrap;
    }

    .market-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
        gap: 40px;
        padding-bottom: 60px;
    }

    .contact-section {
        padding: 100px 0;
        background: radial-gradient(circle at 50% 100%, var(--header-bg), transparent);
    }

    .contact-card {
        max-width: 800px;
        margin: 0 auto;
        padding: 60px;
        background: var(--card-bg);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 30px;
        text-align: center;
    }

    .contact-card h2 {
        font-size: 2.5rem;
        font-weight: 800;
        margin-bottom: 10px;
        background: linear-gradient(45deg, var(--accent-color), #888);
        background-clip: text;
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
    }

    .contact-card p {
        font-size: 1.1rem;
        opacity: 0.7;
        margin-bottom: 40px;
    }

    .contact-form {
        text-align: left;
    }

    .form-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        margin-bottom: 20px;
    }

    .form-group {
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin-bottom: 20px;
    }

    .form-group label {
        font-size: 0.9rem;
        font-weight: 600;
        opacity: 0.8;
        padding-left: 5px;
    }

    .form-group input, 
    .form-group textarea {
        padding: 15px 20px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 12px;
        color: var(--text-color);
        font-family: inherit;
        font-size: 1rem;
        transition: all 0.3s ease;
    }

    .light-mode .form-group input,
    .light-mode .form-group textarea {
        background: rgba(0, 0, 0, 0.03);
        border-color: rgba(0, 0, 0, 0.1);
    }

    .form-group input:focus, 
    .form-group textarea:focus {
        outline: none;
        border-color: var(--accent-color);
        background: rgba(255, 255, 255, 0.08);
        box-shadow: 0 0 15px var(--accent-color);
    }

    .submit-btn {
        width: 100%;
        padding: 18px;
        background: var(--accent-color);
        color: white;
        border: none;
        border-radius: 15px;
        font-size: 1.1rem;
        font-weight: 700;
        cursor: pointer;
        transition: all 0.3s ease;
        box-shadow: 0 10px 30px var(--accent-color);
    }

    .submit-btn:hover {
        transform: translateY(-3px);
        filter: brightness(1.1);
        box-shadow: 0 15px 40px var(--accent-color);
    }

.comments-section {
    padding: 100px 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

#disqus_thread {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.light-mode #disqus_thread {
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.05);
}

/* Guide Section */
.guide-section {
    padding: 100px 0;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
}
.guide-content h2 {
    text-align: center;
    margin-bottom: 50px;
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 800;
    background: linear-gradient(45deg, var(--accent-color), oklch(80% 0.1 60));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
}
.guide-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease;
}
.guide-card:hover {
    transform: translateY(-5px);
}
.guide-card h3 {
    margin-bottom: 20px;
    color: var(--accent-color);
    font-size: 1.3rem;
}
.guide-card p {
    color: var(--text-color);
    opacity: 0.8;
    line-height: 1.8;
}

footer {
    padding: 60px 0;
    border-top: 1px solid var(--border-color);
    margin-top: 100px;
    background: var(--bg-primary);
}
.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}
.footer-links {
    display: flex;
    gap: 30px;
}
.footer-links a {
    text-decoration: none;
    color: var(--text-color);
    opacity: 0.6;
    font-size: 0.9rem;
    transition: opacity 0.3s;
}
.footer-links a:hover {
    opacity: 1;
    color: var(--accent-color);
}
}
@layer components {
    .filter-btn {
        background: var(--card-bg);
        border: 1px solid rgba(255, 255, 255, 0.1);
        color: var(--text-color);
        padding: 10px 24px;
        border-radius: 30px;
        cursor: pointer;
        transition: all 0.3s ease;
        font-size: 0.95rem;
        font-weight: 500;
    }

    .filter-btn:hover {
        background: rgba(255, 255, 255, 0.15);
    }

    .filter-btn.active {
        background: var(--accent-color);
        color: white;
        border-color: var(--accent-color);
        box-shadow: 0 0 20px var(--accent-color);
    }

    .light-mode .filter-btn.active {
        color: white;
    }
}

@layer theme {
    body.dark .global-nav {
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

@media (max-width: 768px) {
    .nav-flex {
        flex-direction: column;
        gap: 1rem;
    }
    .nav-links {
        gap: 1rem;
        font-size: 0.9rem;
    }
}
        header {
            padding: 100px 0 30px;
        }
        .header-controls {
            top: 15px;
            right: 15px;
            flex-direction: row;
            width: calc(100% - 30px);
            justify-content: space-between;
        }
        .market-grid {
            grid-template-columns: 1fr;
        }
    }
}
