/* ========================================
   CSS Variables & Base Styles
   ======================================== */

:root {
    --color-background: #111827;
    --color-surface: rgba(12, 20, 40, 0.75);
    --color-surface-strong: #101832;
    --color-primary: #6366f1;
    --color-primary-strong: #4f46e5;
    --color-accent: #a855f7;
    --color-text: #e2e8f0;
    --color-muted: rgba(244, 246, 255, 0.72);
    --color-line: rgba(255, 255, 255, 0.08);
    --max-width: 1200px;
    --transition: 180ms ease;
}

/* Reset body margin for header */
html {
    margin: 0 !important;
    padding: 0 !important;
}

body {
    margin: 0 !important;
    padding: 0 !important;
}

/* Base link styles for header */
.site-header a,
.mobile-nav a {
    text-decoration: none;
}

.site-header a:hover,
.mobile-nav a:hover {
    text-decoration: none;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ========================================
   Header Navigation Styles
   ======================================== */

/* Site Header */
.site-header {
    position: sticky;
    top: 0 !important;
    margin: 0 !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
    backdrop-filter: blur(18px);
    background: rgba(7, 11, 27, 0.85);
    z-index: 20;
    border-bottom: 1px solid var(--color-line);
}

.site-header .container {
    width: min(100% - 3rem, var(--max-width));
    margin-inline: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: 1.25rem 0;
}

/* Brand / Logo */
.brand {
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 1.15rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.brand .logo {
    display: block;
    height: 28px;
    width: auto;
}

/* Show dark logo by default */
.brand .logo-dark { display: block; }
.brand .logo-light { display: none; }

/* If site adopts a light theme via attribute */
html[data-theme="light"] .brand .logo-dark { display: none; }
html[data-theme="light"] .brand .logo-light { display: block; }

/* Respect user OS preference if no explicit theme set */
@media (prefers-color-scheme: light) {
    html:not([data-theme]) .brand .logo-dark { display: none; }
    html:not([data-theme]) .brand .logo-light { display: block; }
}

/* Primary Navigation */
.primary-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-items {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
}

.nav-items li {
    position: relative;
}

.nav-items a {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--color-muted);
    transition: color var(--transition);
}

.nav-items a:hover,
.nav-items a:focus-visible {
    color: var(--color-text);
}

/* Submenu Styles */
.has-submenu > a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.submenu-icon {
    font-size: 0.75rem;
    transition: transform var(--transition);
}

.has-submenu:hover .submenu-icon,
.has-submenu:focus-within .submenu-icon {
    transform: rotate(180deg);
}

.has-submenu.submenu-open .submenu-icon {
    transform: rotate(180deg);
}

.has-submenu {
    position: relative;
}

.has-submenu::after {
    content: '';
    position: absolute;
    top: 100%;
    left: -1rem;
    right: -1rem;
    height: 0.5rem;
    z-index: 14;
}

.submenu {
    list-style: none;
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    display: none;
    min-width: 240px;
    padding: 1rem;
    margin: 0;
    border-radius: 1rem;
    background: rgba(6, 10, 24, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 16px 40px rgba(4, 8, 20, 0.5);
    z-index: 15;
    gap: 0.65rem;
    opacity: 0;
    transform: translateY(-0.5rem);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.has-submenu:hover .submenu,
.has-submenu:focus-within .submenu {
    display: grid;
    opacity: 1;
    transform: translateY(0);
    animation: submenuShow 0.2s ease forwards;
}

@keyframes submenuShow {
    from {
        opacity: 0;
        transform: translateY(-0.5rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.submenu a {
    display: block;
    font-size: 0.9rem;
    color: rgba(244, 246, 255, 0.78);
    padding: 0.35rem 0;
}

.submenu a:hover,
.submenu a:focus-visible {
    color: var(--color-primary);
}

/* Contact Chip */
.contact-chip {
    border: 1px solid var(--color-line);
    padding: 0.6rem 1rem;
    border-radius: 999px;
    font-size: 0.9rem;
    color: var(--color-muted);
    transition: background var(--transition), color var(--transition), border var(--transition);
}

.contact-chip:hover {
    border-color: transparent;
    background: linear-gradient(135deg, #1A2A80, #3B38A0);
    color: #ffffff;
}

/* Mobile Navigation Toggle */
.nav-toggle {
    display: none;
    background: transparent;
    border: 0;
    padding: 0.25rem;
    cursor: pointer;
}

.nav-toggle-bar {
    display: block;
    width: 22px;
    height: 2px;
    background-color: var(--color-text);
    margin: 4px 0;
    transition: transform var(--transition);
}

/* Hamburger -> Close animation */
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
    transform: scaleX(0);
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* Mobile Navigation */
.mobile-nav {
    display: none;
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-nav-close {
    display: none;
}

.mobile-nav-actions {
    display: none;
}

/* Navigation Backdrop */
.nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    opacity: 0;
    transition: opacity 240ms ease;
}

.nav-backdrop.is-active {
    display: block;
    opacity: 1;
}

/* Enhanced Styles */
.site-header {
    background: linear-gradient(180deg, rgba(8, 12, 24, 0.82), rgba(8, 12, 24, 0.68));
    box-shadow: 0 2px 12px rgba(2, 6, 23, 0.25);
}

.submenu {
    background: linear-gradient(180deg, rgba(11, 17, 33, 0.98), rgba(11, 17, 33, 0.92));
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 18px 42px rgba(4, 8, 20, 0.5);
}

.contact-chip {
    background: rgba(255, 255, 255, 0.02);
}
.contact-chip:hover,
.contact-chip:focus-visible {
    background: linear-gradient(135deg, #1A2A80, #3B38A0);
    color: #ffffff;
}

/* ========================================
   Mobile Responsive Styles (max-width: 768px)
   ======================================== */

@media (max-width: 768px) {
    .site-header .container {
        gap: 1rem;
    }

    .nav-toggle {
        display: block;
    }

    /* Hide desktop list when mobile drawer is in use */
    .primary-nav .nav-items {
        display: none;
    }

    /* Mobile off-canvas navigation */
    .mobile-nav {
        display: flex;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(85vw, 360px);
        background: linear-gradient(180deg, rgba(11, 17, 33, 0.98), rgba(11, 17, 33, 0.92));
        border-left: 1px solid var(--color-line);
        flex-direction: column;
        align-items: stretch;
        padding: 1.25rem 1.25rem 2rem;
        gap: 0.25rem;
        font-weight: 500;
        font-size: 0.95rem;
        transform: translateX(100%);
        transition: transform 240ms ease;
        z-index: 1000;
        overflow: hidden;
    }

    .mobile-nav-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.08);
        border: 1px solid rgba(255, 255, 255, 0.15);
        color: rgba(255, 255, 255, 0.9);
        font-size: 1.75rem;
        font-weight: 300;
        cursor: pointer;
        transition: all 0.2s ease;
        align-self: flex-end;
        margin: 0 0 1.2rem 0;
        padding: 0;
        line-height: 1;
        flex-shrink: 0;
    }

    .mobile-nav-close:hover,
    .mobile-nav-close:focus-visible {
        background: rgba(255, 255, 255, 0.15);
        color: #fff;
        border-color: rgba(255, 255, 255, 0.3);
        transform: scale(1.05);
    }

    .mobile-nav-close:active {
        transform: scale(0.95);
    }

    /* Mobile drawer: tweaks for close button and menu spacing */
    .mobile-nav-close {
        border: 0;
        margin: 0 0 0.6rem 0;
        width: 20px;
        height: 20px;
        font-size: 0.9rem;
        border-radius: 6px;
    }

    /* Thin separator under the X, and reset UL margins */
    .mobile-nav-close + .mobile-nav-menu {
        margin: 0;
        padding-top: 0.6rem;
        border-top: 1px solid var(--color-line);
    }

    .mobile-nav-menu {
        margin: 0;
        padding: 0;
        list-style: none;
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Contact buttons: no separators above/below */
    .mobile-nav-actions {
        margin: 1rem 0 0 0;
        padding-top: 0;
        border: 0;
        padding-bottom: 0;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.75rem;
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: 0;
    }

    .mobile-nav li:not(.mobile-nav-actions) a {
        display: block;
        padding: 0.85rem 0.75rem;
        border-radius: 0.75rem;
        color: var(--color-text);
        letter-spacing: 0.03em;
        background: transparent;
        border: 0;
        box-shadow: none;
    }

    .mobile-nav li:not(.mobile-nav-actions) a:hover,
    .mobile-nav li:not(.mobile-nav-actions) a:focus-visible {
        color: #fff;
        background: rgba(255, 255, 255, 0.04);
    }

    .mobile-nav-action {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0.85rem 1rem;
        border-radius: 999px;
        font-size: 0.92rem;
        font-weight: 600;
        text-decoration: none;
        flex: 1 1 auto;
        min-width: 0;
        border: 1px solid transparent;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .mobile-nav-action:active {
        transform: translateY(1px);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    }

    .mobile-nav-action--kakao {
        background: linear-gradient(135deg, #facc15, #f59e0b);
        color: #111827;
    }

    .mobile-nav-action--telegram {
        background: linear-gradient(135deg, #3b82f6, #2563eb);
        color: #f1f5f9;
    }

    .mobile-nav.is-open {
        transform: translateX(0);
    }

    /* Lock scroll when drawer open */
    body.is-nav-open {
        overflow: hidden;
        touch-action: none;
    }

    /* Drawer item aesthetics */
    .mobile-nav a:not(.mobile-nav-action):hover,
    .mobile-nav a:not(.mobile-nav-action):focus-visible {
        color: #fff;
        background: rgba(255, 255, 255, 0.04);
    }

    .mobile-nav .has-submenu > a {
        width: 100%;
        justify-content: space-between;
    }

    .mobile-nav .submenu {
        position: static;
        display: none;
        background: transparent;
        border: 0;
        box-shadow: none;
        padding: 0.25rem 0 0.5rem 0;
        width: 100%;
        gap: 0.25rem;
    }

    .mobile-nav .has-submenu.submenu-open > .submenu {
        display: grid;
    }

    .mobile-nav .submenu a {
        padding: 0.7rem 0.75rem 0.7rem 2.5rem;
        color: rgba(244, 246, 255, 0.85);
        font-size: 0.9rem;
        font-weight: 400;
        position: relative;
    }

    .mobile-nav .submenu a::before {
        content: '∟';
        position: absolute;
        left: 1.5rem;
        color: rgba(244, 246, 255, 0.5);
    }

    .contact-chip {
        display: none;
    }
}
