/* ========================================
   ITプロジェクト入門 - レイアウト
   アカデミックスタイル（数学入門と統一）
   ======================================== */

/* ========================================
   全体コンテナ
   ======================================== */

.container-with-sidebar {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    gap: 2rem;
}

/* ========================================
   左サイドバー
   ======================================== */

.sidebar {
    width: 260px;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    background-color: #fff;
    border-right: 1px solid #d4c5a9;
    z-index: 1000;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid #d4c5a9;
    background: #1a365d;
}

.site-title {
    font-family: "Noto Serif JP", serif;
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
    text-decoration: none;
    display: block;
}

.site-title:hover {
    opacity: 0.9;
}

/* 検索ボックス */
.search-box {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eee;
}

.search-box input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d4c5a9;
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: inherit;
    background: #fdfcf9;
    color: #333;
}

.search-box input:focus {
    outline: none;
    border-color: #1a365d;
    box-shadow: 0 0 0 2px rgba(26, 54, 93, 0.1);
}

/* ナビゲーション */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.chapter-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chapter-item {
    margin-bottom: 0.25rem;
}

.chapter-link {
    display: block;
    padding: 0.6rem 1rem;
    color: #333;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.85rem;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
}

.chapter-link:hover {
    background-color: #f8f6f1;
    color: #1a365d;
}

.chapter-link.current,
.chapter-item.active .chapter-link {
    background-color: #f8f6f1;
    border-left-color: #1a365d;
    color: #1a365d;
}

/* セクションリスト */
.section-list {
    list-style: none;
    padding: 0;
    margin: 0.25rem 0 0.5rem 0;
    background-color: #fdfcf9;
}

.section-item {
    margin: 0;
}

.section-link {
    display: block;
    padding: 0.45rem 1rem 0.45rem 1.5rem;
    color: #666;
    text-decoration: none;
    font-size: 0.8rem;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
}

.section-link:hover {
    background-color: #f8f6f1;
    color: #333;
}

.section-link.current {
    background-color: #f0f4f8;
    border-left-color: #1a365d;
    color: #1a365d;
}

/* ユーティリティリンク */
.nav-utilities {
    padding: 1rem;
    border-top: 1px solid #d4c5a9;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.utility-link {
    display: block;
    padding: 0.5rem 0.75rem;
    color: #666;
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.utility-link:hover {
    background-color: #f8f6f1;
    color: #1a365d;
}

/* 外部リンク（hatohato.jpトップ） */
.nav-external {
    padding: 0.75rem 1rem;
    border-top: 1px solid #d4c5a9;
}

.external-link {
    display: block;
    padding: 0.5rem 0.75rem;
    color: #1a365d;
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.external-link:hover {
    background-color: #f8f6f1;
    text-decoration: underline;
}

/* ========================================
   メインコンテンツ
   ======================================== */

.main-content {
    margin-left: 260px;
    padding: 2rem 3rem;
    flex: 1;
    min-width: 0;
    background-color: #fdfcf9;
    min-height: 100vh;
    max-width: 800px;
}

/* セクション */
section {
    padding-bottom: 2rem;
    margin-bottom: 1rem;
}

/* ========================================
   モバイルメニュートグル
   ======================================== */

.menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1100;
    width: 44px;
    height: 44px;
    background: #fff;
    border: 1px solid #d4c5a9;
    border-radius: 8px;
    cursor: pointer;
    padding: 10px;
    flex-direction: column;
    justify-content: space-around;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.menu-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: #333;
    border-radius: 1px;
    transition: all 0.3s ease;
}

.menu-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.menu-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.menu-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 999;
}

.menu-overlay.active {
    display: block;
}

/* ========================================
   レスポンシブ対応
   ======================================== */

@media (max-width: 1024px) {
    .main-content {
        padding: 2rem;
    }
}

@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 260px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 4rem 1.5rem 2rem;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 4rem 1rem 2rem;
    }
}

/* ========================================
   印刷対応
   ======================================== */

@media print {
    .sidebar,
    .menu-toggle,
    .menu-overlay {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
        padding: 0;
    }
    
    body {
        background: white;
        color: black;
    }
}
