/* 폰트 및 핵심 색상 변수 (메인 페이지와 완벽 일치) */
@import url('https://googleapis.com');

:root {
    --bg-dark: #0B0C10;       /* 깊은 밤, 심연의 색 */
    --bg-surface: #151922;    /* 차분한 카드/박스용 서페이스 */
    --bg-content: #1B212C;      /* 명언 페이지 */
    --gold-bright: #C5A059;   /* 신비로운 골드 포인트 */
    --gold-dim: #9A7B43;      /* 묵직한 다크 골드 */
    --text-light: #E5E7EB;    /* 가독성을 높인 연한 그레이 */
    --text-muted: #9A9EAB;    /* 차분한 서브 텍스트 */
    --border-color: rgba(197, 160, 89, 0.15);
    --point-blue: #D4ECFC;
    --card-bg: #1a1a24;
    --accent-color: #bb86fc;
    --correct-color: #03dac6;
    --wrong-color: #cf6679;
    --text-color: #e1e1e6;
}

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

/* 💡 1. 모바일에서 화면 축소 시 우측 메뉴가 절대 보이지 않도록 가로 스크롤 원천 차단 */
html, body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    max-width: 100%; /* 💡 화면 너비가 뷰포트를 절대 넘지 못하도록 강제 */
    overflow-x: hidden; /* 💡 1차 가로 스크롤 잠금 */
    position: relative;
}

/* 2. 가로 스크롤 방지는 전체 페이지를 감싸는 별도의 메인 래퍼 세션을 사용하는 것이 가장 안전합니다 */
.page-wrapper {
    width: 100%;
    overflow-x: hidden;     
    position: relative;
}

h1, h2, h3, h4, .logo-txt, .section-title {
    font-family: 'Noto Serif KR', serif;
    font-weight: 600;
}

.en-font {
    font-family: 'Cinzel', serif;
    letter-spacing: 0.1em;
}

/* 네비게이션 헤더 */
header {
    background-color: rgba(11, 12, 16, 0.95);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 9999;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
}

.navbar {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    /* position: relative; */
}

/* 로고 디자인 */
.logo {
    text-decoration: none;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    z-index: 1002; /* 햄버거 메뉴판보다 항상 위에 표시 */
}

.logo-txt {
    font-family: 'Noto Serif KR', serif;
    font-size: 1.4rem;
    color: var(--gold-bright);
    letter-spacing: 0.05em;
    font-weight: 600;
}

.logo-sub {
    font-family: 'Cinzel', serif;
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.2em;
}

/* PC 버전 메뉴 디자인 */
.nav-menu {
    display: flex;
    list-style: none;
    gap: 10px;
}

.nav-item {
    position: relative;
}

.nav-item > a {
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-light);
    padding: 10px 20px;
    display: block;
    transition: all 0.3s ease;
}

.nav-item > a:hover {
    color: var(--gold-bright);
}

/* PC 버전 드롭다운 서브메뉴 */
.submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #151922;
    border: 1px solid var(--gold-dim);
    padding: 10px 0;
    min-width: 180px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    list-style: none;
}

.submenu a {
    font-size: 0.9rem;
    padding: 10px 20px;
    display: block;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
    text-align: center;
}

.submenu a:hover {
    background-color: rgba(197, 160, 89, 0.1);
    color: var(--gold-bright);
}

.nav-item:hover .submenu {
    display: block;
}

/* 햄버거 버튼 토글러 (기본 숨김) */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 25px;
    height: 18px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 10001; /* 메뉴판보다 위에 오도록 인덱스 상향 */
}

.menu-toggle span {
    width: 100%;
    height: 2px;
    background-color: var(--gold-bright);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 햄버거 버튼 클릭 시 X자로 변하는 애니메이션 효과 */
.menu-toggle.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}
.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}
.menu-toggle.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* 서브페이지 배너 섹션 */
.page-header {
    padding: 60px 20px;
    text-align: center;
    background: linear-gradient(180deg, #121620 0%, var(--bg-dark) 100%);
    border-bottom: 1px solid var(--border-color);
}

.page-meta {
    font-family: 'Cinzel', serif;
    color: var(--gold-bright);
    font-size: 0.85rem;
    letter-spacing: 0.2em;
    margin-bottom: 10px;
}

.page-header h2 {
    font-size: 2.4rem;
    color: var(--text-light);
    letter-spacing: 0.02em;
}

/* 메인 서브 레이아웃 (본문 + 사이드바 구조) */
.sub-container {
    max-width: 1200px;
    margin: 50px auto;
    padding: 0 20px;
    display: flex;
    gap: 50px;
}

/* 본문 아카이브 영역 */
.content-area {
    flex: 3;
}

/* 서두 인트로 문단 */
.intro-quote {
    font-family: 'Noto Serif KR', serif;
    font-size: 1.1rem;
    color: var(--text-muted);
    border-left: 2px solid var(--gold-bright);
    padding-left: 20px;
    margin-bottom: 50px;
    line-height: 2;
    font-weight: 300;
}

/* 고풍스러운 타임라인 연대기 구조 */
.chronology {
    display: flex;
    flex-direction: column;
    gap: 50px;
}

.chrono-node {
    background-color: var(--bg-surface);
    border: 1px solid rgba(197, 160, 89, 0.1);
    padding: 40px;
    position: relative;
    transition: border-color 0.3s ease;
}

.chrono-node:hover {
    border-color: rgba(197, 160, 89, 0.4);
}

.chrono-era {
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    color: var(--gold-bright);
    letter-spacing: 0.15em;
    display: block;
    margin-bottom: 15px;
    font-weight: bold;
}

.chrono-node h3 {
    font-size: 1.5rem;
    color: var(--text-light);
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 10px;
}

.chrono-node p {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 300;
    text-align: justify;
}

/* 사이드바 영역 */
.sidebar {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* 사이드바 위젯 공통 */
.side-widget {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 30px 25px;
}

.widget-title {
    font-size: 1.1rem;
    color: var(--gold-bright);
    letter-spacing: 0.05em;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(197, 160, 89, 0.2);
    padding-bottom: 10px;
}

/* 사이드 서브메뉴 */
.side-menu-list {
    list-style: none;
}

.side-menu-list li {
    margin-bottom: 5px;
}

.side-menu-list li a {
    display: block;
    padding: 10px 15px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    border-left: 2px solid transparent;
}

.side-menu-list li a:hover {
    color: var(--gold-bright);
    background-color: rgba(197, 160, 89, 0.03);
}

.side-menu-list li.active a {
    color: var(--gold-bright);
    font-weight: 600;
    border-left-color: var(--gold-bright);
    background-color: rgba(197, 160, 89, 0.05);
}

/* 우측 하단 묵직한 링크 카드 */
.ritual-card {
    text-align: center;
    background: linear-gradient(135deg, #1b1f29 0%, #0d1017 100%);
}

.ritual-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 25px;
    font-weight: 300;
}

.ritual-btn {
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    color: var(--bg-dark);
    background-color: var(--gold-bright);
    padding: 10px 20px;
    text-decoration: none;
    display: inline-block;
    font-weight: bold;
    transition: all 0.3s ease;
}

.ritual-btn:hover {
    background-color: #e0b869;
    box-shadow: 0 5px 15px rgba(197, 160, 89, 0.2);
}

/* 푸터 */
footer {
    background-color: #060709;
    text-align: center;
    padding: 50px 20px;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: rgba(154, 158, 171, 0.4);
    margin-top: 100px;
}


/* 반응형 웹 설계 */
@media (max-width: 900px) {
    .sub-container {
        flex-direction: column;
        gap: 40px;
    }
    .sidebar {
        order: 2;
    }
    .content-area {
        order: 1;
    }
}

/* ==========================================================================
    모바일 반응형 레이아웃 처리 (화면 폭 768px 이하 기준)
    ========================================================================== */
@media (max-width: 768px) {

    .menu-toggle {
        display: flex; /* 모바일에서 햄버거 버튼 표시 */
        padding: 0px;
    }

    /* 전체 메뉴를 전체 화면 우측에서 슬라이딩되는 서랍 형태로 변환 */
    .nav-menu {
        position: fixed;
        top: 0;
        right: 0; /* 기본적으로 화면 우측 밖에 숨김 */
        /* width: 70%; */
        height: 100vh;
        background-color: #0D1117;
        border-left: 1px solid var(--border-color);
        flex-direction: column;
        padding: 100px 30px;
        /* gap: 20px; */

        /* 초기 상태: 화면 오른쪽 바깥에 완벽하게 대기 (축소해도 안 보임) */
        transform: translate3d(100%, 0, 0); 

        /* 💡 왼쪽으로 부드럽게 밀려 나오는 모던 트랜지션 곡선 설정 */
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: -10px 0 40px rgba(0,0,0,0.8);
        z-index: 10000;

        /* 스크롤바가 생기지 않도록 리스트 스타일 정돈 */
            list-style: none;

        /* 💡 [버그 완치 핵심 1] 평소에는 뷰포트 우측 밖에 완전히 숨기고 밀어두기 */
        transform: translate3d(100%, 0, 0); 
        
        /* 💡 [버그 완치 핵심 2] 닫혀있을 땐 브라우저 렌더링 영역에서 삭제하여 횡스크롤 발생 원인 원천 차단 */
        visibility: hidden; 
        
        /* 가속도 모션을 위한 트랜지션 확장 (visibility 옵션 동시 적용) */
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.4s ease;
    }

    /* 자바스크립트로 active 클래스가 붙으면 슬라이드 인 */
    .nav-menu.active {
        /* right: 0; */
        transform: translate3d(0, 0, 0);
        visibility: visible; /* 렌더링 영역에 노출 */
    }

    .nav-item > a {
        font-size: 1.0rem;
        padding: 5px 0;
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }

    /* 모바일 환경에서의 드롭다운 서브메뉴 스타일 조정 */
    .submenu {
        display: block; /* 모바일은 호버가 없으므로 항상 펼침 구조 또는 목록 형태로 노출 */
        position: static;
        transform: none;
        background-color: transparent;
        border: none;
        box-shadow: none;
        padding: 5px 0 5px 15px;
        min-width: unset;
    }

    .submenu a {
        text-align: left;
        padding: 8px 0;
        font-size: 0.95rem;
        color: var(--text-muted);
    }
}

/* 💡 PC 환경(769px 이상)에서만 작동하는 고급스러운 툴팁 메커니즘 */
    @media (min-width: 769px) {
        
        /* 1. [기본 설정] 서브메뉴가 없는 일반 메뉴는 글자 아래에 표시 */
        .tooltip-trigger::after {
            content: attr(data-tooltip);
            position: absolute;
            top: 100%;
            left: 50%;
            transform: translate(-50%, 10px);
            
            /* 다크 골드 무드 인테리어 마감 */
            background-color: #151922;
            color: #C5A059;
            border: 1px solid rgba(197, 160, 89, 0.4);
            padding: 6px 14px;
            font-family: 'Noto Sans KR', sans-serif;
            font-size: 0.75rem;
            font-weight: 400;
            letter-spacing: -0.01em;
            white-space: nowrap;
            pointer-events: none;
            
            /* 투명 상태로 대기 및 서서히 나타나는 모션 셋업 */
            opacity: 0;
            visibility: hidden;
            transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.6);
            z-index: 10005;
        }

        .tooltip-trigger:hover::after {
            opacity: 1;
            visibility: visible;
            transform: translate(-50%, 15px); /* 위에서 아래로 스르륵 내려오는 모션 */
            text-shadow: 0 0 5px rgba(197, 160, 89, 0.4);
            background: linear-gradient(180deg, #1A212C 0%, #151922 100%);
            border-color: #C5A059;
        }

        /* ==========================================================================
        ⭐ [오류 해결 핵심] 서브메뉴 간섭 차단 특화 레이어 정의
        ========================================================================== */
        
        /* 타로(TAROT)와 운명(DESTINY)처럼 서브메뉴판이 하단으로 내려오는 항목 타겟팅 */
        .nav-item:has(.submenu) .tooltip-trigger::after {
            top: auto; /* 기존 아래쪽 고정 초기화 */
            bottom: 100%; /* 💡 글자의 머리 위쪽(Top) 영역으로 좌표계 축 변경 */
            transform: translate(-50%, -10px); /* 위쪽 대기 상태 */
        }

        /* 마우스를 올렸을 때 위 방향으로 스르륵 떠오르는 신비로운 모션 구현 */
        .nav-item:has(.submenu) .tooltip-trigger:hover::after {
            transform: translate(-50%, -15px);
            background: linear-gradient(0deg, #1A212C 0%, #151922 100%); /* 그라데이션 방향 상향 조정 */
        }
    }

    @media (max-width: 480px) {
        .footer-legal-nav {
            gap: 10px !important;
            font-size: 0.78rem !important;
        }
    }