/* ==========================================================================
   設計系統與基礎樣式 (Design System & Base Styles)
   ========================================================================== */
:root {
  --color-bg-main: #FDFBF7;
  --color-bg-sidebar: #FEF9E7;
  --color-bg-card: #FFFFFF;
  --color-text-main: #2C3E50;
  --color-text-light: #566573;
  --color-accent: #E67E22; /* 橘金色，象徵溫暖工廠與齒輪 */
  --color-accent-hover: #D35400;
  --color-active-bg: #F9EBEA;
  --color-border: #F5CBA7;
  
  --font-ui: 'Outfit', 'Noto Sans TC', sans-serif;
  --font-novel: 'Noto Serif TC', Georgia, serif;
  
  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --shadow-subtle: 0 4px 20px rgba(126, 81, 9, 0.05);
  --shadow-medium: 0 10px 30px rgba(126, 81, 9, 0.08);
}

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

html {
  scroll-behavior: smooth;
  background-color: var(--color-bg-main);
  color: var(--color-text-main);
  font-family: var(--font-ui);
}

/* ==========================================================================
   排版與架構 (Layout Grid)
   ========================================================================== */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* 側邊導覽列 */
.sidebar {
  width: 320px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  background: var(--color-bg-sidebar);
  border-right: 1px solid rgba(230, 126, 34, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 2px 0 15px rgba(0, 0, 0, 0.02);
}

/* 內容展示區 */
.content-area {
  margin-left: 320px;
  padding: 60px;
  max-width: 1100px;
  width: 100%;
}

/* ==========================================================================
   側邊欄組件 (Sidebar Components)
   ========================================================================== */
.sidebar-header {
  padding: 30px 24px;
  border-bottom: 1px solid rgba(230, 126, 34, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 2rem;
  background: var(--color-accent);
  padding: 8px;
  border-radius: 12px;
  color: white;
  box-shadow: 0 4px 10px rgba(230, 126, 34, 0.3);
}

.logo-title h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #5D4037;
  letter-spacing: 0.05em;
}

.logo-title p {
  font-size: 0.75rem;
  color: var(--color-text-light);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* 側邊導航清單 */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 20px 12px;
}

/* 客製化滾動條 */
.sidebar-nav::-webkit-scrollbar {
  width: 5px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(230, 126, 34, 0.2);
  border-radius: 4px;
}

.sidebar-nav ul {
  list-style: none;
}

.sidebar-nav li {
  margin-bottom: 8px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: #5D4037;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 10px;
  transition: var(--transition-smooth);
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: rgba(230, 126, 34, 0.06);
  color: var(--color-accent-hover);
  transform: translateX(4px);
}

/* Active 啟用狀態 */
.sidebar-nav a.active {
  background: rgba(230, 126, 34, 0.1);
  color: var(--color-accent-hover);
  font-weight: 700;
  border-left: 4px solid var(--color-accent);
}

/* 章節小徽章 */
.chapter-badge {
  font-size: 0.75rem;
  padding: 4px 8px;
  background: rgba(93, 64, 55, 0.08);
  border-radius: 6px;
  color: #5D4037;
  font-weight: 600;
  transition: var(--transition-smooth);
}

.sidebar-nav a.active .chapter-badge {
  background: var(--color-accent);
  color: white;
}

.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid rgba(230, 126, 34, 0.08);
  font-size: 0.75rem;
  color: var(--color-text-light);
  text-align: center;
}

/* ==========================================================================
   主要內容組件 (Main Content Components)
   ========================================================================== */
/* 歡迎橫幅 */
.hero-card {
  background: linear-gradient(135deg, #FFFDF9 0%, #FAF3E0 100%);
  border: 1px solid rgba(230, 126, 34, 0.15);
  border-radius: 20px;
  padding: 40px;
  margin-bottom: 50px;
  box-shadow: var(--shadow-subtle);
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 150px;
  height: 150px;
  background: rgba(230, 126, 34, 0.03);
  border-radius: 50%;
}

.hero-badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-accent);
  background: rgba(230, 126, 34, 0.08);
  padding: 6px 12px;
  border-radius: 30px;
  margin-bottom: 16px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.hero-card h2 {
  font-size: 2rem;
  font-weight: 700;
  color: #3E2723;
  margin-bottom: 16px;
  line-height: 1.3;
}

.hero-card p {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--color-text-light);
}

/* 小說章節區段卡片 */
.novel-section {
  margin-bottom: 80px;
  scroll-margin-top: 40px; /* 平滑滾動時的頂部餘裕 */
}

.section-card {
  background: var(--color-bg-card);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 24px;
  padding: 50px;
  box-shadow: var(--shadow-subtle);
  transition: var(--transition-smooth);
}

.section-card:hover {
  box-shadow: var(--shadow-medium);
  transform: translateY(-2px);
}

/* 章節頂部標頭 */
.section-header {
  margin-bottom: 30px;
  border-bottom: 2px dashed rgba(230, 126, 34, 0.12);
  padding-bottom: 24px;
}

.chapter-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: 0.15em;
  margin-bottom: 8px;
}

.section-title {
  font-family: var(--font-novel);
  font-size: 2rem;
  font-weight: 700;
  color: #271E1C;
  line-height: 1.4;
  margin-bottom: 16px;
}

/* 標記徽章 */
.meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.meta-badge {
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: 30px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.theme-badge {
  background: #EBF5FB;
  color: #2980B9;
}

.char-badge {
  background: #FEF9E7;
  color: #D35400;
}

/* 插圖容器 */
.illustration-container {
  width: 100%;
  margin: 30px 0;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  aspect-ratio: 16 / 9; /* 統一圖片比例，更整齊 */
  background: #F2F4F4;
}

.novel-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.1, 0.8, 0.2, 1);
  display: block;
}

.illustration-container:hover .novel-image {
  transform: scale(1.03);
}

.image-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  padding: 15px 20px;
  color: white;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: center;
}

.illustration-container:hover .image-overlay {
  opacity: 1;
}

/* 小說本文排版 (Premium Novel Reading Layout) */
.novel-body {
  font-family: var(--font-novel);
  font-size: 1.18rem;
  line-height: 1.95;
  color: #2F3E46;
  letter-spacing: 0.06em;
  text-align: justify;
}

.novel-p {
  margin-bottom: 2em;
  text-indent: 2em; /* 首行縮排兩字 */
}

/* ==========================================================================
   Lightbox 燈箱放大效果
   ========================================================================== */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(28, 20, 16, 0.92);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: fadeIn 0.25s ease-out;
}

.lightbox-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  animation: scaleUp 0.3s cubic-bezier(0.1, 0.8, 0.2, 1);
}

.lightbox-content img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: 12px;
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.5);
  display: block;
}

.lightbox-close {
  position: absolute;
  top: -50px;
  right: 0;
  background: none;
  border: none;
  color: white;
  font-size: 2.5rem;
  cursor: pointer;
  outline: none;
}

/* 簡單動畫 */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleUp {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   響應式設計 (Responsive Media Queries)
   ========================================================================== */
@media (max-width: 900px) {
  .app-container {
    flex-direction: column;
  }

  /* 側邊欄變為頂部固定/滾動目錄 */
  .sidebar {
    width: 100%;
    position: sticky;
    top: 0;
    bottom: auto;
    left: auto;
    height: auto;
    border-right: none;
    border-bottom: 1px solid rgba(230, 126, 34, 0.12);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    background: #FFF;
  }

  .sidebar-header {
    padding: 16px 20px;
  }
  
  .logo-icon {
    font-size: 1.5rem;
    padding: 6px;
  }

  .logo-title h1 {
    font-size: 1.15rem;
  }

  .logo-title p {
    font-size: 0.65rem;
  }

  /* 橫向滑動的目錄選單 */
  .sidebar-nav {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 15px;
    white-space: nowrap;
    scrollbar-width: none; /* Firefox */
  }
  
  .sidebar-nav::-webkit-scrollbar {
    display: none; /* Safari & Chrome */
  }

  .sidebar-nav ul {
    display: flex;
    gap: 12px;
  }

  .sidebar-nav li {
    margin-bottom: 0;
    display: inline-block;
  }

  .sidebar-nav a {
    padding: 8px 14px;
    font-size: 0.85rem;
    border-left: none;
    border-bottom: 3px solid transparent;
    display: inline-flex;
    align-items: center;
    background: #F8F9FA;
  }

  .sidebar-nav a:hover {
    transform: none;
  }

  .sidebar-nav a.active {
    border-left: none;
    border-bottom: 3px solid var(--color-accent);
    background: rgba(230, 126, 34, 0.08);
  }

  .sidebar-footer {
    display: none; /* 行動端隱藏頁尾 */
  }

  /* 內容區重置 */
  .content-area {
    margin-left: 0;
    padding: 30px 20px;
  }

  .hero-card {
    padding: 24px;
    margin-bottom: 30px;
  }

  .hero-card h2 {
    font-size: 1.5rem;
  }

  .section-card {
    padding: 24px;
    border-radius: 16px;
  }

  .section-title {
    font-size: 1.5rem;
  }

  .novel-body {
    font-size: 1.05rem;
    line-height: 1.85;
  }

  .meta-badge {
    font-size: 0.8rem;
    padding: 4px 10px;
  }
}

/* ==========================================================================
   語言切換器 (Language Switcher in Sidebar)
   ========================================================================== */
.sidebar-lang-switcher {
  padding: 12px 24px;
  border-bottom: 1px solid rgba(230, 126, 34, 0.08);
  display: flex;
  gap: 8px;
  justify-content: center;
  background: rgba(230, 126, 34, 0.02);
}

.sidebar-lang-switcher a {
  font-size: 0.8rem;
  padding: 6px 12px;
  text-decoration: none;
  color: #5D4037;
  border-radius: 6px;
  border: 1px solid rgba(230, 126, 34, 0.2);
  background: white;
  font-weight: 600;
  transition: var(--transition-smooth);
}

.sidebar-lang-switcher a:hover {
  background: rgba(230, 126, 34, 0.06);
  color: var(--color-accent-hover);
}

.sidebar-lang-switcher a.active {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}
