/**
 * 角色介紹區域樣式
 * 全高 100vh 背景設計
 * 支援語言管理器動態更新
 * 參考影片輪播專案邏輯
 */

/* ==================== 角色區域容器（參考專案結構）==================== */
.type-role {
  position: relative;
  width: 100%;
  background-image: url("../img/role/background/role_bg.webp");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  overflow: hidden;
  height: 100vh;
}

/* 標題樣式 - 靠上顯示（參考專案）*/
.type-role .c-headline {
  color: #fff;
  text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.8);
  padding-top: 60px;
  padding-bottom: 20px;
  margin: 0 auto;
  z-index: 2;
}

/* ==================== Swiper 輪播容器 ==================== */
/* 外層包裝器 - 確保左右預覽可見（參考專案）*/
.role-swiper-wrapper {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 60px 0;
  overflow: hidden; /* 只在外層隱藏超出部分 */
}

.role-character-swiper {
  width: 100%;
  max-width: 1400px;
  height: auto;
  position: relative;
  overflow: visible !important; /* 讓左右預覽可見 */
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 !important;
  margin: 0 auto;
}

/* Swiper Wrapper - 確保預覽可見 */
.role-character-swiper .swiper-wrapper {
  align-items: center;
}

/* Swiper Slide - 使用 16:9 比例 */
.role-character-swiper .swiper-slide {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.4s ease;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

/* 非活動的 slide（左右預覽）- 可點擊 */
.role-character-swiper .swiper-slide:not(.swiper-slide-active) {
  cursor: pointer;
}

/* 非活動 slide 懸停效果 */
.role-character-swiper .swiper-slide:not(.swiper-slide-active):hover {
  transform: scale(0.88) !important;
  opacity: 0.75 !important;
}

/* 活動的 slide */
.role-character-swiper .swiper-slide-active {
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.5);
  cursor: default;
}

/* 角色布局 - 左右分割 50/50 */
.slide-layout {
  display: flex;
  width: 100%;
  height: 100%;
  padding: 2rem;
  gap: 2rem;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

/* 左側：角色圖 50% */
.character-image-container {
  width: 50%;
  height: 100%;
  position: relative;
}

.character-image {
  width: 100%;
  height: 100%;
  background-size: contain; /* 完整顯示角色圖 */
  background-position: center center; /* 完全置中 */
  background-repeat: no-repeat;
  transition: transform 0.3s ease;
}

.role-character-swiper .swiper-slide-active .character-image {
  transform: scale(1.05);
}

/* 右側：角色資訊 50% */
.character-text-container {
  width: 50%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 3rem 0;
  color: #fff;
}

/* 角色名稱區 20% */
.character-name-section {
  height: 20%;
  display: flex;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
}

.character-name {
  font-size: 3rem;
  font-weight: 900;
  text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.9);
  color: #fff9dc;
  letter-spacing: 1px;
  margin: 0 auto;
}

/* 角色描述區 80% */
.character-description-section {
  height: 80%;
  overflow-y: auto;
  padding-right: 1rem;
  display: flex;
  align-items: flex-start;
}

.character-description {
  font-size: 1.5rem;
  line-height: 1.9;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9);
  color: rgba(255, 255, 255, 0.95);
}

/* 捲軸樣式 - 更美觀 */
.character-description-section::-webkit-scrollbar {
  width: 10px;
}

.character-description-section::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
}

.character-description-section::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.4);
  border-radius: 5px;
  transition: background 0.3s ease;
}

.character-description-section::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.6);
}

/* Swiper 導航箭頭 - 完全參考影片輪播樣式 */
.role-character-swiper .swiper-button-prev,
.role-character-swiper .swiper-button-next {
  width: 60px !important;
  height: 60px !important;
  background: rgba(255, 255, 255, 0.5) !important;
  background-image: none !important; /* 移除 lp.css 的背景圖 */
  border-radius: 50% !important;
  color: #000 !important;
  transition: all 0.3s ease !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important;
  z-index: 999 !important;
  position: absolute !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  margin: 0 !important;
  padding: 0 !important;
}

.role-character-swiper .swiper-button-prev {
  left: 12% !important;
  right: auto !important;
}

.role-character-swiper .swiper-button-next {
  right: 12% !important;
  left: auto !important;
}

.role-character-swiper .swiper-button-prev:hover,
.role-character-swiper .swiper-button-next:hover {
  background: rgba(255, 255, 255, 0.7) !important;
  transform: translateY(-50%) scale(1.05) !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* 自定義箭頭符號 - 粉色，參考專案樣式 */
.role-character-swiper .swiper-button-prev::after,
.role-character-swiper .swiper-button-next::after {
  content: "" !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: 0 !important;
  height: 0 !important;
  border: none !important;
  font-size: 0 !important;
}

/* 左箭頭 - 單箭頭向左 */
.role-character-swiper .swiper-button-prev::after {
  content: "‹" !important;
  font-size: 64px !important;
  font-weight: bold !important;
  color: #fff !important;
  font-family: Arial, sans-serif !important;
  line-height: 1 !important;
  text-align: center !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  height: 100% !important;
  transform: none !important;
  position: absolute !important;
  top: -10px !important;
  left: -2px !important;
}

/* 右箭頭 - 單箭頭向右 */
.role-character-swiper .swiper-button-next::after {
  content: "›" !important;
  font-size: 64px !important;
  font-weight: bold !important;
  color: #fff !important;
  font-family: Arial, sans-serif !important;
  line-height: 1 !important;
  text-align: center !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  height: 100% !important;
  transform: none !important;
  position: absolute !important;
  top: -10px !important;
  left: 2px !important;
}

/* 確保箭頭不被隱藏 */
.role-character-swiper .swiper-button-prev.swiper-button-disabled,
.role-character-swiper .swiper-button-next.swiper-button-disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* 調試：確保左箭頭可見 */
.role-character-swiper .swiper-button-prev {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* 調試：確保右箭頭可見 */
.role-character-swiper .swiper-button-next {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* Swiper 分頁器 */
.role-character-swiper .swiper-pagination {
  bottom: -40px !important;
}

.role-character-swiper .swiper-pagination-bullet {
  background: rgba(255, 255, 255, 0.6);
  opacity: 1;
  width: 14px;
  height: 14px;
  transition: all 0.3s ease;
}

.role-character-swiper .swiper-pagination-bullet-active {
  background: #fff;
  transform: scale(1.3);
}

/* ==================== 響應式設計 ==================== */

/* 1500px 以下 - 箭頭位置調整（參考專案） */
@media (max-width: 1500px) {
  .role-character-swiper .swiper-button-prev {
    left: 10% !important;
  }

  .role-character-swiper .swiper-button-next {
    right: 10% !important;
  }
}

/* 大螢幕 */
@media (max-width: 1600px) {
  .type-role .c-headline {
    padding-top: 50px;
  }

  .character-text-container {
    padding: 2.5rem;
  }

  .character-name {
    font-size: 2.8rem;
    margin: 0 auto;
  }

  .character-description {
    font-size: 1.5rem;
  }
}

/* 平板 */
@media (max-width: 1024px) {
  .type-role {
    height: auto;
    min-height: 100vh;
  }

  .type-role .c-headline {
    padding-top: 40px;
    padding-bottom: 15px;
  }

  .character-text-container {
    padding: 2rem;
  }

  .character-name {
    font-size: 2.5rem;
    margin: 0 auto;
  }

  .character-description {
    font-size: 1rem;
    line-height: 1.7;
  }

  .role-character-swiper .swiper-button-prev,
  .role-character-swiper .swiper-button-next {
    width: 40px !important;
    height: 40px !important;
  }

  .role-character-swiper .swiper-button-prev::after,
  .role-character-swiper .swiper-button-next::after {
    font-size: 48px !important;
    top: -8px !important;
  }
}

/* 手機 - 改為上下排列（優化版）*/
@media (max-width: 768px) {
  .type-role {
    height: auto;
    min-height: 100vh;
  }

  .type-role .c-headline {
    padding-top: 20px;
    padding-bottom: 15px;
    font-size: 2rem;
  }

  .role-swiper-wrapper {
    padding: 0 0 40px 0;
  }

  .role-character-swiper {
    max-width: 100%;
  }

  .role-character-swiper .swiper-slide {
    border-radius: 0; /* 手機上移除圓角（參考專案）*/
    aspect-ratio: 9 / 16; /* 手機使用豎屏比例 */
  }

  /* 手機改為垂直排列 */
  .slide-layout {
    flex-direction: column;
    padding: 0;
    gap: 0;
  }

  /* 角色圖在上 60% */
  .character-image-container {
    width: 100%;
    height: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .character-image {
    background-position: center center;
    margin: 2rem;
  }

  /* 文字在下 40% */
  .character-text-container {
    width: 100%;
    height: 50%;
    padding: 1rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow: hidden; /* 確保不超出容器 */
  }

  /* 名稱區域 - 自適應高度 */
  .character-name-section {
    height: auto;
    max-height: 25%; /* 最多佔文字區域的 25% */
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    flex-shrink: 0; /* 不縮小 */
    overflow: hidden;
  }

  .character-name {
    font-size: clamp(1.2rem, 4vw, 1.8rem); /* 自適應：最小1.2rem，最大1.8rem */
    text-align: center;
    line-height: 1.3;
    word-break: break-word; /* 長文字自動換行 */
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 auto;
  }

  /* 描述區域 - 自適應高度 */
  .character-description-section {
    flex: 1; /* 佔用剩餘空間 */
    min-height: 0; /* 重要：允許 flex 子元素縮小 */
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.5rem; /* 給滾動條留空間 */
  }

  .character-description {
    font-size: clamp(0.85rem, 2.5vw, 1rem); /* 自適應：最小0.85rem，最大1rem */
    line-height: 1.65;
    text-align: left;
    word-break: break-word;
    overflow-wrap: break-word; /* 確保長單詞換行 */
  }

  /* 箭頭位置調整 */
  .role-character-swiper .swiper-button-prev,
  .role-character-swiper .swiper-button-next {
    width: 40px !important;
    height: 40px !important;
    top: 35% !important; /* 放在圖片區域中央 */
  }

  .role-character-swiper .swiper-button-prev::after,
  .role-character-swiper .swiper-button-next::after {
    font-size: 44px !important;
    top: -8px !important;
  }

  .role-character-swiper .swiper-button-prev {
    left: 10px !important;
  }

  .role-character-swiper .swiper-button-next {
    right: 10px !important;
  }

  /* 分頁器位置 */
  .role-character-swiper .swiper-pagination {
    bottom: 10px !important;
  }

  .role-character-swiper .swiper-pagination-bullet {
    width: 10px;
    height: 10px;
    margin: 0 5px;
  }

  .role-character-swiper .swiper-pagination-bullet-active {
    transform: scale(1.2);
  }

  /* 手機版滾動條樣式優化 */
  .character-description-section::-webkit-scrollbar {
    width: 6px;
  }

  .character-description-section::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
  }

  .character-description-section::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
  }
}

/* 小手機（優化版 - 376px-480px）*/
@media (min-width: 376px) and (max-width: 480px) {
  .type-role {
    min-height: 100vh;
  }

  .type-role .c-headline {
    padding-top: 15px;
    padding-bottom: 10px;
    font-size: 1.75rem;
  }

  .role-swiper-wrapper {
    padding: 0 0 30px 0;
  }

  .character-image-container {
    height: 50%;
  }

  .character-image {
    margin: 2rem;
  }

  .character-text-container {
    height: 50%;
    padding: 0;
  }

  .character-name-section {
    max-height: 30%;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
  }

  .character-name {
    font-size: 2.6rem;
    line-height: 1.2;
    margin: 0 auto;
  }

  .character-description-section {
    padding-right: 0.25rem;
  }

  .character-description {
    font-size: 1.6rem;
    line-height: 1.6;
    padding: 0.85rem;
  }

  .role-character-swiper .swiper-button-prev {
    left: 8px !important;
    top: 53% !important;
  }

  .role-character-swiper .swiper-button-next {
    right: 8px !important;
    top: 53% !important;
  }

  .role-character-swiper .swiper-pagination {
    bottom: -2% !important;
  }

  .role-character-swiper .swiper-button-prev,
  .role-character-swiper .swiper-button-next {
    width: 35px !important;
    height: 35px !important;
  }

  .role-character-swiper .swiper-button-prev::after,
  .role-character-swiper .swiper-button-next::after {
    font-size: 38px !important;
  }

  .role-character-swiper .swiper-pagination-bullet {
    width: 8px;
    height: 8px;
    margin: 0 4px;
  }
}

/* 極小螢幕優化 (320px-375px) */
@media (max-width: 375px) {
  .type-role .c-headline {
    font-size: clamp(1.25rem, 6vw, 1.5rem);
    padding-top: 10px;
    padding-bottom: 8px;
  }

  .character-image-container {
    height: 50%;
  }

  .character-image {
    margin: 2rem;
  }

  .character-text-container {
    height: 50%;
    padding: 0;
  }

  .character-name-section {
    max-height: 35%;
    padding-bottom: 0.4rem;
    margin-bottom: 0.4rem;
    border-bottom-width: 1px;
  }

  .character-name {
    font-size: 2.5rem;
    line-height: 1.2;
    margin: 0 auto;
  }

  .character-description {
    font-size: 1.5rem;
    line-height: 1.55;
    padding: 1rem;
  }

  .role-character-swiper .swiper-button-prev,
  .role-character-swiper .swiper-button-next {
    width: 30px !important;
    height: 30px !important;
  }

  .role-character-swiper .swiper-button-prev::after,
  .role-character-swiper .swiper-button-next::after {
    font-size: 32px !important;
  }

  .role-character-swiper .swiper-button-prev {
    left: 8px !important;
    top: 53% !important;
  }

  .role-character-swiper .swiper-button-next {
    right: 8px !important;
    top: 53% !important;
  }

  .role-character-swiper .swiper-pagination {
    bottom: -2% !important;
  }
}

/* 中等手機優化 (481px-640px) */
@media (min-width: 481px) and (max-width: 640px) {
  .character-image-container {
    height: 50%;
  }

  .character-image {
    margin: 2rem;
  }

  .character-text-container {
    height: 50%;
    padding: 0.75rem 1.5rem 1.25rem;
  }

  .character-name-section {
    padding-bottom: 0.6rem;
    margin-bottom: 0.6rem;
  }

  .character-name {
    font-size: 2.8rem;
    line-height: 1.25;
    margin: 0 auto;
  }

  .character-description {
    font-size: 1.7rem;
    line-height: 1.6;
    padding: 0.75rem;
  }

  .role-character-swiper .swiper-button-prev {
    left: 8px !important;
    top: 52% !important;
  }

  .role-character-swiper .swiper-button-next {
    right: 8px !important;
    top: 52% !important;
  }

  .role-character-swiper .swiper-pagination {
    bottom: 2px !important;
  }
}

/* 大手機優化 (641px-768px) */
@media (min-width: 641px) and (max-width: 768px) {
  .character-image-container {
    height: 50%;
  }

  .character-image {
    margin: 2rem;
  }

  .character-text-container {
    height: 50%;
    padding: 1rem 2rem 1.5rem;
  }

  .character-name-section {
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
  }

  .character-name {
    font-size: 3rem;
    line-height: 1.25;
    margin: 0 auto;
  }

  .character-description {
    font-size: 1.8rem;
    line-height: 1.65;
    padding: 0.5rem;
  }

  .role-character-swiper .swiper-button-prev,
  .role-character-swiper .swiper-button-next {
    top: 53% !important;
  }

  .role-character-swiper .swiper-pagination {
    bottom: 5px !important;
  }
}
