/* =========================================
   阿鹿小站 v2.0 - 漫畫閱讀器專屬樣式 (read.css) - 翻頁模式
   ========================================= */
/* 🌟 補上色彩變數，讓按鈕和轉圈圈能抓到顏色 */
:root {
  --primary-color: #007bff; /* 科技藍 */
  --accent-color: #ff4081; /* 動漫粉 */
}
body {
  margin: 0;
  padding: 0;
  font-family: "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  background-color: #0d0d12; /* 超深色背景 */
  color: #ffffff;
}

a {
  text-decoration: none;
}

/* --- 頂部浮動導覽列 --- */
.reader-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 50px;
  background-color: rgba(13, 13, 18, 0.95);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  box-sizing: border-box;
  z-index: 1000;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.header-left,
.header-right {
  flex: 1;
}
.header-right {
  text-align: right;
}

.back-btn {
  color: #ffffff; /* 🌟 改成純白，確保清晰可見 */
  font-size: 0.95rem;
  font-weight: bold;
  display: inline-block;
  transition: all 0.3s ease;
}
.back-btn:hover {
  color: var(--accent-color);
  transform: translateX(-5px); /* 🌟 滑鼠碰到時微微向左移，有「返回」的動態暗示 */
}

.header-title {
  flex: 2;
  text-align: center;
  font-size: 1.1rem;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unit-name {
  color: #00bcd4;
  font-size: 0.9rem;
  margin-left: 5px;
}

.page-indicator {
  background-color: rgba(255, 255, 255, 0.1);
  padding: 5px 12px;
  border-radius: 15px;
  font-size: 0.9rem;
  font-weight: bold;
  color: #00bcd4;
}

/* --- 漫畫主要閱讀區 --- */
.reader-container {
  max-width: 1000px; /* 寬度稍微放寬 */
  margin: 15px auto 0 auto;
  background-color: #0d0d12;
  min-height: 100vh;
}

/* 🌟 切齊圖左方的漫畫名稱與話數頁數資訊 (仿圖2紅色醒目樣式) */
.manga-meta-bar {
  width: 100%;
  max-width: 1000px;
  margin: 12px auto 14px;
  padding: 0 10px;
  box-sizing: border-box;
  font-size: 1.45rem;
  font-weight: 900;
  font-family: "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  color: #ff0000; /* 亮紅色 */
  text-align: left;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  letter-spacing: 0.5px;
}

.manga-meta-bar .meta-title {
  color: #ff0000;
  font-size: 1.65rem;
  font-weight: 900;
}

.manga-meta-bar .meta-divider {
  color: #00bcd4; /* 分隔線青色 */
  margin: 0 4px;
  font-size: 0.85rem; /* "/" 斜線很小字 */
  font-weight: bold;
}

.manga-meta-bar .meta-unit {
  color: #ff0000;
  font-size: 1.15rem; /* 第 1 話比名稱還小 */
  font-weight: 900;
}

.manga-meta-bar .meta-pages {
  display: inline-flex;
  align-items: baseline;
  margin-left: 2px;
}

.manga-meta-bar .meta-paren {
  color: #00bcd4;
  font-size: 0.85rem; /* "()" 括號很小字 */
  font-weight: bold;
}

.manga-meta-bar .meta-curr {
  color: #ff0000; /* 當前頁數紅色 */
  font-size: 1.15rem;
  font-weight: 900;
}

.manga-meta-bar .meta-slash {
  color: #00bcd4;
  font-size: 0.85rem; /* "/" 頁數中的斜線很小字 */
  font-weight: bold;
  margin: 0 1px;
}

.manga-meta-bar .meta-total {
  color: #00bcd4;
  font-size: 0.8rem; /* 最大頁數很小字 */
  font-weight: normal;
}

.manga-viewer {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
}

.manga-viewer img {
  max-width: 100%;
  height: auto;
  object-fit: contain;
  user-select: none; /* 防止使用者不小心把圖片反白 */
}

/* 🌟 點擊圖片熱區：覆蓋全圖，點擊只會下一頁 */
.click-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  cursor: pointer;
  z-index: 10;
}
.zone-full-next {
  left: 0;
  right: 0;
  width: 100%;
  height: 100%;
}

/* --- 底部控制列 --- */
.reader-controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr; /* 三欄網格：左側(上一話/目錄) | 中間(翻頁) | 右側(下一話) */
  align-items: center;
  padding: 15px 20px;
  margin-top: 20px;
  margin-bottom: 30px;
  background-color: #1a1a2e;
  border-radius: 8px;
  box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.5);
  gap: 15px;
  box-sizing: border-box;
}

.controls-left-group {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

.controls-center-group {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
}

.controls-right-group {
  grid-column: 3;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.page-counter {
  font-size: 1.05rem;
  font-weight: bold;
  color: #fff;
  white-space: nowrap;
}
#bottom-current-page {
  color: #00bcd4;
  font-size: 1.5rem;
}

/* --- 按鈕樣式 --- */
.acg-btn {
  display: inline-block;
  padding: 9px 20px;
  background-color: transparent;
  color: #fff;
  border: 2px solid var(--accent-color);
  border-radius: 30px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 0.95rem;
  white-space: nowrap;
  text-align: center;
  box-sizing: border-box;
}

.btn-nav {
  background-color: rgba(255, 64, 129, 0.1);
  min-width: 68px;
}

.btn-catalog {
  border-color: #4a90e2;
  color: #e0e8f5;
  background-color: rgba(74, 144, 226, 0.15);
  border-radius: 6px; /* 方正微圓角，好與翻頁圓形藥丸按鈕做區隔 */
}
.btn-catalog:hover {
  background-color: #4a90e2;
  color: #fff;
  box-shadow: 0 4px 15px rgba(74, 144, 226, 0.4);
}

.btn-chapter-nav,
.btn-next-chapter {
  border-color: #00bcd4;
  color: #e0f7fa;
  background-color: rgba(0, 188, 212, 0.15);
  border-radius: 6px; /* 方正微圓角，好與翻頁圓形藥丸按鈕做區隔 */
}
.btn-chapter-nav:hover,
.btn-next-chapter:hover {
  background-color: #00bcd4;
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 188, 212, 0.4);
}

.acg-btn:hover {
  background-color: var(--accent-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 64, 129, 0.4);
}

/* 🌟 手機版直式 (寬度 <= 768px)：中間群組在第一行，目錄與話數按鈕在第二行 */
@media (max-width: 768px) {
  .reader-controls {
    display: flex;
    flex-direction: column;
    padding: 15px 10px;
    gap: 15px;
  }

  /* 第一行：中間群組 (上頁、下拉選單、下頁) */
  .controls-center-group {
    width: 100%;
    justify-content: center;
    gap: 10px;
  }

  /* 第二行容器包裹區：回目錄 上一話 下一話 */
  .controls-left-group,
  .controls-right-group {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* 讓第二行的三顆按鈕在手機上整齊排成一行 */
  .reader-controls {
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    justify-content: center;
  }

  .controls-center-group {
    width: 100%;
    margin-bottom: 5px;
  }

  .controls-left-group {
    margin-right: 8px;
  }

  .controls-right-group {
    margin-left: 0;
  }

  /* 🌟 手機版去除 min-height: 600px 造成的底部大片留黑空白 */
  .manga-viewer {
    min-height: auto;
  }

  .adsense-container {
    margin: 8px 0;
  }
}

/* --- 底部結束區域 --- */
.reader-footer {
  padding: 60px 20px;
  text-align: center;
  background-color: #0d0d12;
}

.end-text {
  color: #666;
  margin-bottom: 30px;
  letter-spacing: 2px;
}

.btn-finish {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}
.btn-finish:hover {
  background-color: #0056b3;
}

.error-msg {
  text-align: center;
  padding: 100px 20px;
}
/* --- 頂部右上角的按鈕排版 --- */
.header-right {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-sm {
  padding: 6px 15px;
  font-size: 0.85rem;
  border-radius: 20px;
  background-color: rgba(255, 64, 129, 0.2);
  border: 1px solid var(--accent-color);
}
.btn-sm:hover {
  background-color: var(--accent-color);
  box-shadow: 0 0 10px rgba(255, 64, 129, 0.5);
}

/* --- 下拉選單樣式 --- */
#page-select {
  background-color: #1a1a2e;
  color: #00bcd4;
  border: 1px solid #00bcd4;
  border-radius: 5px;
  padding: 5px 10px;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  outline: none;
  transition: all 0.3s;
}

#page-select:hover {
  background-color: rgba(0, 188, 212, 0.1);
}

/* --- 底部章節切換按鈕區 --- */
.chapter-nav-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.btn-secondary {
  background-color: transparent;
  color: #a0aab2;
  border: 2px solid #a0aab2;
}

.btn-secondary:hover {
  background-color: #a0aab2;
  color: #111;
}
/* --- 廣告區塊與區隔線 --- */
.ad-divider-wrapper {
  width: 100%;
  max-width: 1000px;
  margin: 30px auto 25px;
  box-sizing: border-box;
  padding: 0 10px;
}

.ad-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.ad-divider::before,
.ad-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.15), transparent);
}

.ad-divider-text {
  padding: 0 16px;
  font-size: 0.8rem;
  color: #777;
  letter-spacing: 2px;
  font-weight: normal;
  user-select: none;
}

/* 雙廣告網格容器 */
.bottom-ads-grid {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 20px;
  width: 100%;
}

.bottom-ads-grid .adsense-container {
  flex: 1;
  min-width: 280px;
  max-width: 480px;
  margin: 10px 0;
}

/* 🌟 手機版直式：雙廣告轉為垂直上下排列 */
@media (max-width: 768px) {
  .bottom-ads-grid {
    flex-direction: column;
    align-items: center;
    gap: 15px;
  }

  .bottom-ads-grid .adsense-container {
    width: 100%;
    max-width: 100%;
    margin: 5px 0;
  }
}

.adsense-placeholder {
  width: 100%;
  max-width: 728px; /* 經典橫幅廣告尺寸 */
  height: 90px;
  background-color: #1a1a2e;
  border: 1px dashed #444;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 0.8rem;
  text-align: center;
}
/* =========================================
   圖片載入 Loading 特效 (高質感雷達掃描 + 呼吸波紋)
   ========================================= */

#manga-image {
  opacity: 0;
  transition: opacity 0.4s ease-in-out;
  position: relative;
  z-index: 1;
}

/* 🌟 基礎容器：加上內發光，增加儀表板的玻璃精密感 */
.spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  z-index: 5;
  border: 2px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 15px rgba(0, 123, 255, 0.2); /* 內部微微發出藍光 */
  border-radius: 50%;
}

/* 🌟 升級版時針：雷達掃描光束 (取代單調直線) */
.spinner::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  /* 使用圓錐漸層，做出前方明亮、後方帶有半透明拖尾的光束效果 */
  background: conic-gradient(from 0deg, transparent 65%, rgba(0, 123, 255, 0.4) 98%, var(--primary-color) 100%);
  animation: spinClock 1.2s linear infinite;
  z-index: 2;
}

/* 🌟 中心發射核心與呼吸波紋 (動漫粉) */
.spinner::after {
  content: "";
  position: absolute;
  /* 將波紋起點縮小到正中心 */
  top: 25px;
  left: 25px;
  right: 25px;
  bottom: 25px;
  border-radius: 50%;
  background-color: var(--accent-color);
  box-shadow: 0 0 10px var(--accent-color); /* 中心點自帶發光 */
  animation: pulseRipple 1.5s infinite ease-out;
  z-index: 1;
}

/* 旋轉與波紋動畫 */
@keyframes spinClock {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes pulseRipple {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    /* 讓粉紅波紋剛好擴散到外框邊緣就完美消散 */
    transform: scale(6);
    opacity: 0;
  }
}
