/* 會員條款、隱私權政策與退款說明（中英文六頁）的長文版面，排在 home.css 後面載入：
   頁首、頁尾、色彩代號與字級沿用 home.css，這裡只加三頁的切換、標題、目錄、內文與表格。
   頁的 HTML 由 npm_scripts/MarkuHome/gen-legal-pages.mjs 從法務的正本產生，不直接改頁。
   手機一欄（目錄收在可展開的一塊）；1024px 以上目錄在左邊、捲動時停在畫面上；表格比畫面寬時在框裡橫向捲動。 */

:root {
  --scroll-shadow: rgb(0 0 0 / 16%);
  --fs-doc: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --scroll-shadow: rgb(0 0 0 / 60%);
  }
}

/* 跳到內文：用鍵盤時才出現 */
.skip {
  position: absolute;
  left: 16px;
  top: -64px;
  z-index: 10;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  text-decoration: none;
}

.skip:focus {
  top: 12px;
}

/* 頁首右邊的語言切換 */
.lang-switch {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-strong);
  font-size: var(--fs-small);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

@media (hover: hover) {
  .lang-switch:hover {
    border-color: var(--control);
  }
}

.legal {
  padding-block: 12px 64px;
}

/* 三頁的切換 */
.doc-tabs ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.doc-tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding-inline: 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-small);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.doc-tabs a[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

@media (hover: hover) {
  .doc-tabs a:not([aria-current]):hover {
    border-color: var(--control);
    color: var(--text-strong);
  }
}

.doc-head {
  display: grid;
  gap: 8px;
  margin-top: 28px;
}

.doc-head h1 {
  margin: 0;
  color: var(--text-strong);
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 1.4rem + 1.5vw, 2.5rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.doc-date {
  color: var(--muted);
  font-size: var(--fs-small);
}

.doc-layout {
  display: grid;
  gap: 24px;
  margin-top: 24px;
}

/* 目錄：手機收在一塊，桌機在左欄 */
.toc ol {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc a {
  display: block;
  padding-block: 7px;
  color: var(--text);
  font-size: var(--fs-small);
  line-height: 1.45;
  text-decoration: none;
}

@media (hover: hover) {
  .toc a:hover {
    color: var(--text-strong);
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

.toc--side {
  display: none;
}

.toc--fold {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.toc--fold summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding-inline: 16px;
  color: var(--text-strong);
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}

.toc--fold summary::-webkit-details-marker {
  display: none;
}

.toc--fold summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform var(--dur) var(--ease);
}

.toc--fold[open] summary::after {
  transform: translateY(2px) rotate(-135deg);
}

.toc--fold ol {
  padding: 0 16px 12px;
}

/* 內文 */
.doc {
  min-width: 0;
  max-width: 46rem;
  font-size: var(--fs-doc);
  line-height: 1.8;
}

.doc h2 {
  margin: 48px 0 0;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  color: var(--text-strong);
  font-family: var(--font-display);
  font-size: var(--fs-title);
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: 0.01em;
  scroll-margin-top: 16px;
}

.doc > h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.doc h3 {
  margin: 32px 0 0;
  color: var(--text-strong);
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.4;
  scroll-margin-top: 16px;
}

.doc p,
.doc ul,
.doc ol {
  margin: 12px 0 0;
}

.doc ul,
.doc ol {
  display: grid;
  gap: 8px;
  padding-left: 1.5em;
}

.doc li > ul,
.doc li > ol {
  margin-top: 8px;
}

.doc li::marker {
  color: var(--muted);
}

.doc strong {
  color: var(--text-strong);
}

.doc a {
  color: var(--link);
  text-underline-offset: 3px;
  overflow-wrap: break-word;
}

.nowrap {
  white-space: nowrap;
}

/* 表格：外框裡橫向捲動，左右還有內容時邊緣出現陰影 */
.table-box {
  margin-top: 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) left / 40px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, transparent) right / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--scroll-shadow), transparent) left / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--scroll-shadow), transparent) right / 14px 100% no-repeat scroll,
    var(--surface);
  overscroll-behavior-x: contain;
}

.table-box:focus-visible {
  outline-offset: 2px;
}

.doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-small);
  line-height: 1.65;
}

/* 三、四欄的表在手機上不擠成細條，改成橫向捲動；46rem 寬的內文欄放得下，桌機不必捲 */
.doc table[data-cols="3"] {
  min-width: 34rem;
}

.doc table[data-cols="4"] {
  min-width: 44rem;
}

.doc th,
.doc td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.doc thead th {
  background: var(--surface-sel);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 700;
  white-space: nowrap;
}

.doc tbody th {
  color: var(--text-strong);
  font-weight: 700;
}

.doc table[data-short-keys] tbody th {
  white-space: nowrap;
}

.doc tbody tr:last-child > * {
  border-bottom: 0;
}

@media (min-width: 720px) {
  .legal {
    padding-top: 20px;
  }

  .doc-head {
    margin-top: 40px;
  }
}

@media (min-width: 1024px) {
  .doc-layout {
    grid-template-columns: 15rem minmax(0, 1fr);
    gap: 64px;
    align-items: start;
    margin-top: 40px;
  }

  .toc--fold {
    display: none;
  }

  .toc--side {
    display: block;
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    padding-right: 8px;
  }

  .toc__title {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.08em;
  }

  .toc--side a {
    padding-block: 6px;
    padding-left: 12px;
    border-left: 2px solid var(--line);
  }
}

@media (min-width: 1024px) and (hover: hover) {
  .toc--side a:hover {
    border-left-color: var(--text-strong);
    text-decoration: none;
  }
}

@media print {
  .skip,
  .lang-switch,
  .doc-tabs,
  .toc,
  .site-foot__nav {
    display: none;
  }

  .doc-layout {
    display: block;
  }

  .doc {
    max-width: none;
  }

  .table-box {
    overflow: visible;
    border: 0;
    background: none;
  }

  .doc table[data-cols] {
    min-width: 0;
  }

  .doc h2,
  .doc h3 {
    break-after: avoid;
  }

  .doc tr {
    break-inside: avoid;
  }
}
