:root {
    --primary-color: #191970;       /* links, buttons, and highlights */
    --accent-color: #5EA1D7;        /* Hover States, Active States */
    --background-color: #f5f7fa;
    --code-block: #e8edf3;          /* Code Blocks */
    --text-color: #1a1a1a;
}

main.content {
    max-width: 760px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 2rem; /* Keep space for navbar */
}

main.content h1:first-of-type, main.content h2:first-of-type, main.content h3:first-of-type {     /* Remove margin only on the first heading */
    margin-top: 0;
}
  
img {
    max-width: 100%;    /* 圖片最大寬度為容器寬度 */
    height: auto;
    display: block;
    margin: 1rem auto;
}

body {
  margin: 0;
  font-family: 'Segoe UI', 'Arial', sans-serif;
  font-size: 16px;
  line-height: 1.6; /* 行高增大，提升可讀性 */
  color: var(--text-color);
  background-color: var(--background-color);
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600; /* 標題加粗 */
    line-height: 1.4;
    color: var(--text-color); /* 標題顏色 */
    margin-top: 2rem;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.6rem;
}

h3 {
    font-size: 1.3rem;
}

h4 {
    font-size: 1rem;
}
  
p, ul, ol {     /* 讓段落、列表（有序 ol 與無序 ul）底下有一點空間，讓文字區塊之間更清楚分隔 */
    margin-bottom: 1.2rem; /* 段落間距 */
}

a {     /* 連結 */
    color: var(--primary-color);               /* 設定連結顏色 */
    text-decoration: none;          /* 移除預設的底線 */
    transition: color 0.3s ease;
}

a:hover {   /* 連結 - 滑鼠 hover 效果 */
    color: var(--accent-color);
} 

pre {   /* code - Style for code blocks (surrounded by triple backticks ```) */
    background: var(--code-block);       /* Light gray background */
    border: 1px solid var(--text-color);    /* Gray border */
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;          /* Enable horizontal scroll for overflow */
    font-family: Consolas, Monaco, 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.5;
}

code {  /* code - Additional styling for code content */
    font-family: Consolas, Monaco, 'Courier New', monospace;
    font-size: 0.95rem;
    color: var(--text-color);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

p code, li code {   /* code - Inline code styling (e.g. `example`) */
    background-color: var(--background-color);
    color: var(--text-color);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
}

/* jump-top-btn - main.js */
.jump-top-btn {
    position: fixed;
    bottom: 2rem;
    right: 1rem;
    background: var(--primary-color);
    color: var(--background-color);
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    display: none;
    z-index: 999;
    font-size: 0.9rem;
}

.jump-top-btn:hover {
    background: var(--accent-color);
}

/* navbar - default.html */
.navbar {
    display: flex;
    justify-content: space-between;  /* 中置連結群 */
    align-items: center;
    flex-wrap: wrap;          /* 可自動換行 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: var(--background-color);
    border-bottom: 1px solid var(--primary-color);
    padding: 0.5rem 1.5rem;
    z-index: 1000;
    font-family: "Segoe UI", 'Arial',sans-serif;
}

.nav-left {     /* 左側 TOC 按鈕容器 */
    flex-shrink: 0;     /* 避免被壓縮 */
}

.nav-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-grow: 1;
}

.nav-links a {
    text-decoration: none;                  /* 移除底線 */
    color: var(--background-color);         /* 連結字體顏色 */
    background-color: var(--primary-color); /* 背景色（可自定） */
    padding: 0.1rem 0.2rem;                 /* 內距讓按鈕更有空間 */
    border-radius: 4px;                     /* 圓角 */
    margin-right: 1rem;                     /* 連結之間的間距 */
    transition: background-color 0.3s;
}

.nav-links a:hover {
    background-color: var(--accent-color);
}

.navbar-controls {
    display: flex;
    align-items: center;
    gap: 0.5em;
    margin-left: auto;
    padding-right: 1.5rem; /* ✅ 讓整組靠右但和邊界留空 */
}

.navbar-controls select{
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    text-decoration: none;
    color: var(--background-color);
    background-color: var(--primary-color);
    padding: 0.1rem 0.2rem;
    border-radius: 4px;
    margin-right: 1rem;
    transition: background-color 0.3s;
    border: none;
    font-size: 1em;
    cursor: pointer;
    font-family: "Segoe UI", 'Arial', sans-serif;
    text-align: center;          /* 文字置中 */
    text-align-last: center;     /* 最後一行文字（選項顯示區）置中，針對部分瀏覽器 */
}

.navbar-controls select:hover {
    background-color: var(--accent-color);
}

/* sidebar - default.html */
.container {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.sidebar-wrapper {
    top: 3rem;
    margin-right: 2rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    align-self: flex-start;
}

.sidebar {
    top: 3rem;
    width: 250px;
    position: sticky;
    align-self: flex-start;
    background: transparent; 
    border: 1px solid transparent;
    padding: 1rem;
    margin-right: 2rem;
    height: max-content;
}

.sidebar.collapsed {    /* 收合狀態下隱藏 TOC */
    display: none;
}

.content {
    flex: 1;
    min-width: 0;
}

/* sidbar - main.js */
#toggle-sidebar {   /* TOC 切換按鈕 */
    background: var(--primary-color);
    color: var(--background-color);
    padding: 0.3rem 1rem;                 /* 內距讓按鈕更有空間 */
    border-radius: 4px;
    transition: background-color 0.3s;
    border: none;
    font-size: 16px; 
}

#toggle-sidebar.expanded {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    font-weight: bold;
    background-color: var(--accent-color); /* 選配：讓顏色也改變 */
    transition: all 0.3s ease;
}

#toggle-sidebar:hover {
    background: var(--accent-color);
}

/* Responsive */
@media (max-width: 768px) { 
    .container {
        flex-direction: column;
        padding: 0.5rem;
    }

    .sidebar-wrapper {
        width: 100%;
        margin-right: 0;
        position: relative;
    }

    .sidebar {
        width: 100%;
        max-height: 60vh;
        overflow-y: auto;
        background: #fff;
        border: 1px solid #ccc;
        border-radius: 6px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.1);
        margin-bottom: 1rem;
        padding: 1rem;
        z-index: 1;
    }

    .sidebar.collapsed {
        max-height: 0;
        overflow: hidden;
        padding: 0;
        border: none;
        box-shadow: none;
    }

    #toggle-sidebar {
        width: 100%;
        margin-bottom: 0.5rem;
        position: relative;
        z-index: 2;
        background: #f9f9f9;
        font-weight: bold;
    }

    .content {
        z-index: 0;
        position: relative;
    }

    .back-home-link {
        position: relative;
        top: auto;
        left: auto;
    }
}