/* ============================================================
   Welfare World (福利天地) - 左右交錯圖文 + 左側固定目錄（與幸福職場同風格）
   basic-style token 已由 base.html 載入的 basic-style.css 提供
   ============================================================ */

/* 頁面背景與間距沿用 basic-style.css，與幸福職場一致，不再另外對 .background-color-primary 加 padding
   （頂部 Banner 外層也有此 class，加了會讓 Banner 變高、手機版露出白縫） */

/* 頂部簡介段落 */
.welfare-intro-desc {
  font-size: 1.15rem;
  line-height: 1.8;
  color: #334155;
  margin-top: 0.5rem;
  margin-bottom: 2.5rem;
}

/* ── 版面：目錄 | 內容 ─────────────────────────────────── */
.welfare-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 3rem;
  align-items: start;
  margin-bottom: 4.5rem;
}

/* ── 左側固定目錄 ─────────────────────────────────────── */
.welfare-toc {
  position: sticky;
  top: 104px;
  align-self: start;
}

.welfare-toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
  border-left: 2px solid #dbe3ee;
}

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

.welfare-toc__link {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.85rem 1rem 0.85rem 1.25rem;
  margin-left: -2px;
  border-left: 2px solid transparent;
  text-decoration: none !important;
  color: #64748b !important;
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.4;
  transition: color 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}

.welfare-toc__num {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  color: #94a3b8;
  transition: color 0.25s ease;
}

.welfare-toc__link:hover {
  color: var(--color-primary, #0c2340) !important;
  background: rgba(29, 143, 224, 0.05);
}

.welfare-toc__link:focus-visible {
  outline: 2px solid var(--color-accent, #1d8fe0);
  outline-offset: -2px;
}

.welfare-toc__link.active {
  color: var(--color-primary, #0c2340) !important;
  border-left-color: var(--color-accent, #1d8fe0);
  background: linear-gradient(90deg, rgba(29, 143, 224, 0.1) 0%, rgba(29, 143, 224, 0) 100%);
}

.welfare-toc__link.active .welfare-toc__num {
  color: var(--color-accent, #1d8fe0);
}

/* ── 右側：交錯列清單 ─────────────────────────────────── */
.welfare-list {
  display: flex;
  flex-direction: column;
  gap: 5rem;
  min-width: 0;
}

/* ── 單列：圖片 | 文字（偶數列左右對調）──────────────────── */
.welfare-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  grid-template-areas: "media text";
  gap: 3rem;
  align-items: center;
  scroll-margin-top: 104px;
}

.welfare-row--reverse {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  grid-template-areas: "text media";
}

/* 沒有實景照的項目：只顯示文字區（序號、標題、描述、小圖示），不加卡片外框、背景與左側色條，
   讓文字直接置於頁面，與前 5 項的文字區質感一致；小圖示放在文字右側並垂直置中 */
.welfare-row--solo,
.welfare-row--solo.welfare-row--reverse {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "text";
}

/* 上下各一列 1fr，讓文字在小圖示高度內垂直置中；小圖示固定在文字右側（不左右交錯） */
.welfare-row--solo .welfare-row__text {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: 1fr auto auto auto 1fr;
  column-gap: 3rem;
  align-items: start;
}

.welfare-row--solo .welfare-row__index,
.welfare-row--solo .welfare-row__title,
.welfare-row--solo .welfare-row__desc {
  grid-column: 1;
}

.welfare-row--solo .welfare-row__index {
  grid-row: 2;
  justify-self: start;
}

.welfare-row--solo .welfare-row__title {
  grid-row: 3;
}

.welfare-row--solo .welfare-row__desc {
  grid-row: 4;
}

.welfare-row--solo .welfare-row__feature {
  grid-column: 2;
  grid-row: 1 / -1;
  align-self: center;
  margin-top: 0;
}

/* 窄螢幕：小圖示改回文字下方 */
@media (max-width: 700px) {
  .welfare-row--solo .welfare-row__text {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
  }

  .welfare-row--solo .welfare-row__index,
  .welfare-row--solo .welfare-row__title,
  .welfare-row--solo .welfare-row__desc,
  .welfare-row--solo .welfare-row__feature {
    grid-column: 1;
    grid-row: auto;
  }

  .welfare-row--solo .welfare-row__feature {
    align-self: auto;
    margin-top: 1.75rem;
  }
}

/* 進場動畫（僅在 JS 啟用時生效，避免無 JS 時內容隱藏）*/
.welfare-list.is-reveal-ready .welfare-row {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.welfare-list.is-reveal-ready .welfare-row.is-visible {
  opacity: 1;
  transform: none;
}

/* ── 圖片區 ───────────────────────────────────────────── */
.welfare-row__media {
  grid-area: media;
  position: relative;
}

/* 錯位色塊：營造層次感，偏移方向朝外側 */
.welfare-row__media::before {
  content: '';
  position: absolute;
  inset: 18px -16px -18px 16px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(29, 143, 224, 0.16) 0%, rgba(12, 35, 64, 0.08) 100%);
  z-index: 0;
}

.welfare-row--reverse .welfare-row__media::before {
  inset: 18px 16px -18px -16px;
}

.welfare-swiper {
  position: relative;
  z-index: 1;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 18px;
  overflow: hidden;
  background: #e2e8f0;
  box-shadow: 0 18px 40px rgba(12, 35, 64, 0.14);
}

.welfare-swiper .swiper-slide {
  cursor: zoom-in;
}

.welfare-swiper .swiper-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.welfare-swiper .swiper-slide:hover img {
  transform: scale(1.04);
}

/* 分頁圓點 */
.welfare-swiper .swiper-pagination {
  bottom: 14px !important;
}

.welfare-swiper .swiper-pagination-bullet {
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.75);
  opacity: 1;
  margin: 0 4px !important;
  transition: all 0.3s ease;
}

.welfare-swiper .swiper-pagination-bullet-active {
  background: #ffffff;
  width: 24px;
  border-radius: 4px;
}

/* 左右切換按鈕：hover 時浮現 */
.welfare-swiper__btn {
  position: absolute;
  top: 50%;
  z-index: 5;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  color: var(--color-primary, #0c2340);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(12, 35, 64, 0.2);
  opacity: 0;
  transform: translateY(-50%) scale(0.9);
  transition: opacity 0.25s ease, transform 0.25s ease, color 0.2s ease;
}

.welfare-swiper__btn--prev {
  left: 14px;
}

.welfare-swiper__btn--next {
  right: 14px;
}

.welfare-swiper:hover .welfare-swiper__btn,
.welfare-swiper__btn:focus-visible {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

.welfare-swiper__btn:hover {
  color: var(--color-accent, #1d8fe0);
}

/* ── 文字區 ───────────────────────────────────────────── */
.welfare-row__text {
  grid-area: text;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* 大號序號 + 短飾線 */
.welfare-row__index {
  display: inline-flex;
  align-items: center;
  gap: 0.875rem;
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--color-accent, #1d8fe0);
  margin-bottom: 1rem;
  font-variant-numeric: tabular-nums;
}

.welfare-row__index::after {
  content: '';
  width: 48px;
  height: 3px;
  border-radius: 2px;
  background: var(--color-accent, #1d8fe0);
}

.welfare-row__title {
  color: var(--color-primary, #0c2340);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 1rem 0;
  letter-spacing: 0.02em;
}

.welfare-row__desc {
  color: #334155;
  font-size: 1.05rem;
  line-height: 1.9;
  margin: 0;
}

/* 小圖（圖標）：可點擊放大，提示常駐（觸控裝置也看得到）*/
.welfare-row__feature {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 220px;
  height: 190px;
  margin-top: 1.75rem;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  box-shadow: 0 6px 18px rgba(12, 35, 64, 0.07);
  cursor: zoom-in;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.welfare-row__feature:hover {
  transform: translateY(-3px);
  border-color: #cbd5e1;
  box-shadow: 0 12px 26px rgba(12, 35, 64, 0.12);
}

.welfare-row__feature:focus-visible {
  outline: 2px solid var(--color-accent, #1d8fe0);
  outline-offset: 3px;
}

.welfare-row__feature img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.welfare-row__feature-hint {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  background: rgba(12, 35, 64, 0.82);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 500;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
}

/* ── 圖片燈箱 Modal ────────────────────────────────────── */
.image-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.image-modal.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.image-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 35, 64, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.image-modal__dialog {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  background: #ffffff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  transform: scale(0.92);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.image-modal.is-active .image-modal__dialog {
  transform: scale(1);
}

.image-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.7);
  color: #ffffff;
  border: none;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: background 0.2s ease, transform 0.2s ease;
  line-height: 1;
}

.image-modal__close:hover {
  background: #000000;
  transform: scale(1.1);
}

.image-modal__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.25rem;
  overflow: hidden;
}

.image-modal__img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 8px;
}

.image-modal__caption {
  margin-top: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: #334155;
  text-align: center;
}

/* ── 英文版微調 (html[lang="en"]) ─────────────────────────── */
html[lang="en"] .welfare-row__title {
  font-size: 1.55rem;
  letter-spacing: 0;
}

html[lang="en"] .welfare-row__desc {
  font-size: 1rem;
  line-height: 1.7;
}

html[lang="en"] .welfare-toc__link {
  font-size: 0.98rem;
}

/* ── 響應式佈局 (RWD) ─────────────────────────────────── */
@media (max-width: 1200px) {
  .welfare-layout {
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 2.25rem;
  }

  .welfare-row,
  .welfare-row--reverse {
    gap: 2.25rem;
  }

  .welfare-row__index {
    font-size: 2.5rem;
  }

  .welfare-row__title {
    font-size: 1.5rem;
  }

  .welfare-row__feature {
    width: 190px;
    height: 160px;
  }
}

/* 平板以下：目錄改為頂部橫向捲動列（固定在畫面上方），圖文一律上圖下文 */
@media (max-width: 900px) {
  .welfare-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }

  .welfare-toc {
    top: 70px;
    z-index: 90;
    margin: 0 -0.25rem;
    padding: 0.375rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--color-border, #dce3ed);
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(12, 35, 64, 0.06);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .welfare-toc::-webkit-scrollbar {
    display: none;
  }

  .welfare-toc__list {
    display: flex;
    gap: 0.375rem;
    border-left: none;
    width: max-content;
  }

  .welfare-toc__link {
    margin-left: 0;
    padding: 0.5rem 1rem;
    border-left: none;
    border-radius: 10px;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  .welfare-toc__num {
    display: none;
  }

  .welfare-toc__link.active {
    background: var(--color-accent, #1d8fe0);
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(29, 143, 224, 0.3);
  }

  .welfare-list {
    gap: 4rem;
  }

  .welfare-row,
  .welfare-row--reverse {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "media"
      "text";
    gap: 2.25rem;
    scroll-margin-top: 140px;
  }

  .welfare-row--solo,
  .welfare-row--solo.welfare-row--reverse {
    grid-template-areas: "text";
  }

  .welfare-row__media::before,
  .welfare-row--reverse .welfare-row__media::before {
    inset: 12px -8px -12px 8px;
  }

  /* 觸控裝置：切換按鈕常駐 */
  .welfare-swiper__btn {
    opacity: 1;
    transform: translateY(-50%) scale(1);
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 600px) {
  .welfare-intro-desc {
    margin-bottom: 1.5rem;
  }

  .welfare-list {
    gap: 3.25rem;
  }

  .welfare-row__index {
    font-size: 2.25rem;
    margin-bottom: 0.75rem;
  }

  .welfare-row__feature {
    width: 100%;
    max-width: 280px;
    height: 200px;
  }

  .welfare-row__title {
    font-size: 1.35rem;
  }

  .welfare-row__desc {
    font-size: 1rem;
    line-height: 1.8;
  }

  html[lang="en"] .welfare-row__title {
    font-size: 1.25rem;
  }
}