/* =========================================================
   Sound Traces — Main Stylesheet (v3.0.0)
   立方計劃空間 TheCube Project Space
   橫向年表設計 — 桌面/平板橫向捲動，手機直向堆疊
   ========================================================= */

/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── A. 紙本 Paper（預設） ─────────────────────────── */
:root {
  --bg: #f6f3ee;
  --ink: #1a1a1a;
  --ink-soft: #3a3a3a;
  --muted: #7a7065;
  --line: #c9c1ae;
  --accent: #9a2e1f;
  --year-marker-bg: #9a2e1f;
  --year-marker-text: #ffffff;
}

/* ── B. 深夜 Dark Studio ───────────────────────────── */
body[data-theme="dark"] {
  --bg: #131311;
  --ink: #e8e3d6;
  --ink-soft: #c4bfb1;
  --muted: #8b8578;
  --line: #3a3833;
  --accent: #d4a544;
  --year-marker-bg: #d63a2e;
  --year-marker-text: #ffffff;
}

/* ── C. 檔案 Cool Archive ──────────────────────────── */
body[data-theme="archive"] {
  --bg: #ebe9e2;
  --ink: #1a1a1a;
  --ink-soft: #3a3a3a;
  --muted: #6b6b6b;
  --line: #b8b3a3;
  --accent: #2c4a5e;
  --year-marker-bg: #2c4a5e;
  --year-marker-text: #ffffff;
}

/* Dark theme：時間軸線改用低彩度琥珀色 */
body[data-theme="dark"] .timeline-track::before,
body[data-theme="dark"] .event-card::before {
  background: rgba(212, 165, 68, 0.6);
}
body[data-theme="dark"] .card-image {
  box-shadow: 0 0 0 1px rgba(212, 165, 68, 0.35);
}

/* 雙語切換：依 body[data-lang] 顯示對應語言 */
body[data-lang="zh"] .t-en { display: none; }
body[data-lang="en"] .t-zh { display: none; }

html {
  height: 100%;
  height: -webkit-fill-available; /* Safari：排除瀏覽器 UI 佔用高度 */
}
body {
  height: 100vh;
  height: -webkit-fill-available; /* Safari fix */
}

/* WP admin bar 高度補償（登入狀態下 html 有 margin-top: 32px，body 須扣除） */
html.admin-bar body { height: calc(100vh - 32px); }
@media screen and (max-width: 782px) {
  html.admin-bar body { height: calc(100vh - 46px); }
}

body {
  font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease, color 0.4s ease;
}

/* WP screen-reader text */
.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  -webkit-clip-path: inset(50%);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute !important;
  width: 1px;
  word-wrap: normal !important;
}
.screen-reader-text:focus {
  background-color: var(--bg);
  border-radius: 3px;
  box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
  clip: auto !important;
  clip-path: none;
  color: var(--ink);
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
  height: auto;
  left: 5px;
  line-height: normal;
  padding: 15px 23px 14px;
  text-decoration: none;
  top: 5px;
  width: auto;
  z-index: 100000;
}

/* ── Header ───────────────────────────────────────── */
.site-header {
  padding: 18px 48px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 28px;
  background: var(--bg);
  position: relative;
  z-index: 10;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-right: auto;
}

.header-link {
  font-family: 'Noto Serif TC', serif;
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.05em;
  padding: 4px 2px;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.header-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Language switcher */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: 'Noto Serif TC', serif;
}

.lang-btn {
  background: none;
  border: none;
  font: inherit;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 6px;
  letter-spacing: 0.05em;
  transition: color 0.2s;
  text-decoration: none;
}

.lang-btn:hover { color: var(--ink); }

.lang-btn.active {
  color: var(--ink);
  font-weight: 500;
}

.lang-divider {
  color: var(--muted);
  font-size: 12px;
  opacity: 0.5;
}

/* Palette switcher */
.palette-switcher {
  display: flex;
  gap: 10px;
  align-items: center;
}

.palette-label {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-right: 2px;
}

.palette-btn {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: transform 0.2s;
}

.palette-btn:hover { transform: scale(1.08); }

.palette-btn .swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: block;
  box-shadow: 0 0 0 1px var(--line);
}

.palette-btn.active {
  box-shadow: 0 0 0 1.5px var(--ink);
}

/* ── Site main wrapper ─────────────────────────────── */
.site-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ── Category filter（多選開關）─────────────────── */
.category-filter {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 48px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.category-filter::-webkit-scrollbar { display: none; }

.filter-label {
  font-family: 'Noto Serif TC', serif;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-right: 6px;
  white-space: nowrap;
}

.filter-btn {
  font-family: 'Noto Serif TC', serif;
  font-size: 12.5px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 100px;
  cursor: pointer;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: all 0.2s;
}

.filter-btn:hover {
  border-color: var(--ink);
}

.filter-btn.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.filter-btn:not(.active) {
  opacity: 0.45;
}

.filter-reset {
  font-family: 'Noto Serif TC', serif;
  font-size: 11px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: 0.06em;
  padding: 4px 6px;
  margin-left: auto;
  transition: color 0.2s;
}

.filter-reset:hover { color: var(--accent); }

/* ── Year index nav（只留十年）─────────────────── */
.year-index {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 14px 48px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.year-index::-webkit-scrollbar { display: none; }

.decade-label {
  font-family: 'Noto Serif TC', serif;
  font-size: 15px;
  color: var(--ink);
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.04em;
  background: none;
  border: none;
  padding: 2px 0;
  transition: color 0.2s;
  position: relative;
}

.decade-label::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
}

.decade-label:hover { color: var(--accent); }
.decade-label.active { color: var(--accent); }
.decade-label.active::after { opacity: 1; }

.year-list { display: flex; gap: 10px; }

.year-link {
  font-family: 'Noto Serif TC', serif;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: 0.05em;
  background: none;
  border: none;
  padding: 2px 4px;
  transition: color 0.2s;
}

.year-link:hover { color: var(--accent); }
.year-link.active { color: var(--accent); font-weight: 500; }

/* ── Timeline ──────────────────────────────────────── */
.timeline-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  min-height: 0;
}

.timeline-scroll {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.timeline-scroll::-webkit-scrollbar { display: none; }

.timeline-track {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  height: 100%;
  padding: 60px 80px;
  gap: 72px; /* 跨年距離（year-group 之間） */
  min-width: max-content;
  position: relative;
}

/* 主時間軸線 ─ 從第一個 year-group 起算（intro gap 由 ::after 蓋住） */
.timeline-track::before {
  content: '';
  position: absolute;
  top: 140px;
  left: 80px;
  right: 80px;
  height: 1px;
  background: var(--line);
  z-index: 0;
}

/* ── Timeline intro：年表開頭的封面 ───────────────── */
.timeline-intro {
  flex: 0 0 540px;
  position: relative;
  z-index: 2;
  background-color: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 40px;
}

.intro-content {
  text-align: center;
  max-width: 460px;
}

.intro-logo-link {
  display: block;
  margin: 0 auto 32px;
  line-height: 0;
}

.intro-logo {
  display: block;
  max-width: 380px;
  width: 100%;
  height: auto;
  margin: 0 auto;
  transition: filter 0.4s ease;
}

body[data-theme="dark"] .intro-logo { filter: invert(1); }

.intro-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 28px;
  letter-spacing: 0.05em;
}

/* Mission statement（後台 Customizer 可編輯） */
.intro-statement {
  text-align: left;
  font-size: 13.5px;
  line-height: 1.95;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

.intro-statement p { margin: 0; }

.intro-more {
  color: var(--accent);
  text-decoration: none;
  margin-left: 6px;
  font-weight: 500;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.intro-more:hover { opacity: 0.7; text-decoration: underline; }

/* ── Tag 頁 intro ──────────────────────────────────── */
.timeline-intro--tag .intro-content { text-align: left; }

.intro-tag-header { margin-top: 28px; }

.tag-label {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.tag-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 26px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.4;
  letter-spacing: 0.04em;
  margin-bottom: 20px;
}

.tag-back-link {
  display: inline-block;
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: opacity 0.2s;
}
.tag-back-link:hover { opacity: 0.7; text-decoration: underline; }

/* ── Year-group / year-events ──────────────────────── */
.year-group {
  position: relative;
}

/* 蓋住橫線直到 1910 圓圈右緣（gap + 圓圈左半都蓋掉） */
.timeline-intro + .year-group::before,
.year-group.first-visible-year::before {
  content: '';
  position: absolute;
  top: 0;
  right: calc(100% - 80px); /* 右邊對齊圓圈右緣（圓圈寬 80px，從 year-group 左邊算起） */
  width: 9999px;
  height: 100%;
  background: var(--bg);
  z-index: 1;
}

.year-events {
  display: flex;
  flex-direction: row;
  gap: 20px; /* 同年內 marker→card / card→card 距離 */
  align-items: flex-start;
}

/* ── Year marker ───────────────────────────────────── */
/* marker 容器寬度 = 圓寬度，讓圓沒有左右留白，跨年距離更緊湊 */
.year-marker {
  flex: 0 0 160px;
  min-width: 0;
  max-width: 160px;
  width: 160px;
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;  /* 讓縮小的圓垂直置中，維持與事件卡片的軸線對齊 */
  height: 160px;
}

.year-marker-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background-color: var(--year-marker-bg);
  color: var(--year-marker-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Noto Serif TC', serif;
  font-size: 16px;
  font-weight: 700;
  margin: 0 auto;
  letter-spacing: 0.02em;
}

/* ── Event card ────────────────────────────────────── */
/* 卡片寬度 = 圖寬度，整個 card 是一個與圓對齊的視覺單元
   min-width: 0 + max-width: 160px：避免 Safari 把卡片自動撐寬 */
.event-card {
  flex: 0 0 240px;
  min-width: 0;
  max-width: 240px;
  width: 240px;
  position: relative;
  z-index: 1;
  background: transparent;
  transition: transform 0.35s ease;
}

.event-card:hover { transform: translateY(-4px); }

.event-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.card-image {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto;
  filter: grayscale(35%) contrast(1.02);
  border: 5px solid var(--bg);
  background-color: var(--muted);
  position: relative;
  z-index: 1;
  box-shadow: 0 0 0 1px var(--line);
  transition: border-color 0.4s ease, filter 0.35s ease;
}

.event-card:hover .card-image { filter: grayscale(0%) contrast(1.05); }

.card-content {
  padding: 22px 4px 0;
  text-align: left;
  min-width: 0;
  width: 100%;
}

.card-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
  margin-bottom: 10px;
  color: var(--ink);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.card-description {
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink-soft);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ── Empty state ──────────────────────────────────── */
.timeline-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 80px;
  color: var(--muted);
  font-family: 'Noto Serif TC', serif;
  font-size: 16px;
}

/* ── Bottom controls ──────────────────────────────── */
.controls {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 18px 48px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  background: var(--bg);
}

.arrow-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 20px;
  color: var(--ink);
  font-family: 'Noto Serif TC', serif;
  line-height: 1;
  border-radius: 50%;
}

.arrow-btn:hover:not(:disabled) {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.arrow-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.progress-track {
  flex: 1;
  height: 2px;
  background: var(--line);
  position: relative;
  cursor: pointer;
  opacity: 0.6;
}

.progress-fill {
  height: 100%;
  background: var(--ink);
  width: 0%;
  transition: width 0.15s ease;
}

.progress-info {
  font-family: 'Noto Serif TC', serif;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.06em;
  min-width: 70px;
  text-align: right;
}

/* ── Site footer（首頁隱藏，內頁顯示）─────────────── */
.site-footer {
  display: none;
}

/* ── Single event page（事件詳情）保留樣式 ────────── */
body.single-post,
body.page {
  overflow: auto;
  height: auto;
  display: block;
}

body.single-post .site-main,
body.page .site-main {
  overflow: visible;
  flex: 0 1 auto;
  display: block;
}

body.single-post .site-footer,
body.page .site-footer {
  display: block;
  padding: 40px 48px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  font-family: 'Noto Serif TC', serif;
  line-height: 1.8;
}

body.single-post .site-footer a,
body.page .site-footer a {
  color: var(--accent);
  text-decoration: none;
}

.event-single {
  max-width: 760px;
  margin: 0 auto;
  padding: 60px 32px 80px;
}

.back-link {
  display: inline-block;
  font-family: 'Noto Serif TC', serif;
  font-size: 1rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 40px;
  letter-spacing: 0.05em;
  transition: color 0.2s;
}

.back-link:hover { color: var(--accent); }

.event-header {
  margin-bottom: 32px;
  text-align: center;
}

/* 年份紅圓（同首頁 year-marker 尺寸） */
.single-year-marker {
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
}

.single-year-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background-color: var(--year-marker-bg);
  color: var(--year-marker-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Noto Serif TC', serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.event-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 32px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink);
  margin-bottom: 8px;
}

.event-title-alt {
  font-size: 16px;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 16px;
}

.event-featured-figure {
  margin: 28px 0 0;
  text-align: center;
}

.event-featured-image {
  max-width: 480px;
  width: 100%;
  height: auto;
  margin: 0 auto 8px;
  border-radius: 4px;
  display: block;
}

.event-image-credit {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 32px;
}

.event-content {
  font-size: 16px;
  line-height: 1.95;
  color: var(--ink-soft);
}

.event-content p { margin: 0 0 1.2em; }

.event-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.event-content h2, .event-content h3 {
  font-family: 'Noto Serif TC', serif;
  color: var(--ink);
  margin: 1.6em 0 0.6em;
  font-weight: 500;
}

.event-content h2 { font-size: 22px; }
.event-content h3 { font-size: 18px; }

.event-content ul, .event-content ol {
  margin: 0 0 1.2em 1.6em;
}

.str-related .str-related__heading,
.event-single .str-related__heading {
  font-family: 'Noto Serif TC', serif !important;
  color: var(--ink) !important;
  font-size: 18px !important;
  font-weight: 500 !important;
  margin: 1.6em 0 0.6em !important;
  text-transform: none !important;
  letter-spacing: normal !important;
}

.str-tags-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 24px 0;
}

.card-tag {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
}

.card-tag:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.str-link-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.str-link-list li {
  padding: 6px 0;
  border-bottom: 1px dotted var(--line);
}

/* ── Mobile（≤ 767px） ──────────────────────────── */
@media (max-width: 767px) {
  body {
    overflow: auto;
    height: auto;
    display: block;
  }

  .site-main {
    overflow: visible;
    display: block;
    flex: 0 1 auto;
  }

  .site-header {
    padding: 14px 22px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
  }

  .header-nav { margin-right: auto; }
  .header-link { font-size: 13px; }

  .category-filter {
    padding: 12px 22px;
    gap: 8px;
  }
  .filter-btn { font-size: 11.5px; padding: 4px 10px; }
  .filter-reset { font-size: 10.5px; }

  .year-index {
    padding: 12px 22px;
    gap: 18px;
  }

  .decade-label { font-size: 14px; }

  .timeline-wrapper { overflow: visible; }
  .timeline-scroll { overflow: visible; }

  .timeline-track {
    flex-direction: column;
    padding: 0 22px 56px;
    gap: 48px;
    min-width: 0;
    align-items: stretch;
  }

  .timeline-track::before { display: none; }

  .timeline-intro {
    flex: 0 0 auto;
    width: 100%;
    padding: 36px 22px 40px;
    border-right: none;
    border-bottom: 1px dashed var(--line);
    margin: 0 -22px 8px;
  }

  .intro-content { max-width: 100%; }
  .intro-logo { max-width: 260px; margin-bottom: 26px; }
  .intro-statement { font-size: 13px; line-height: 1.9; }

  .year-group { width: 100%; }

  .year-events {
    flex-direction: column;
    gap: 36px;
    align-items: center;
    width: 100%;
  }

  .year-marker { flex: 0 0 auto; }

  .year-marker-circle {
    width: 120px;
    height: 120px;
    font-size: 26px;
  }

  .event-card {
    flex: 0 0 auto;
    width: 100%;
    max-width: 380px;
  }

  /* 同年份內：事件之間的短連接線 */
  .event-card::before {
    content: '';
    position: absolute;
    top: -36px;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 36px;
    background: var(--line);
  }

  .card-image { width: 140px; height: 140px; }
  .card-content { padding-top: 20px; text-align: center; }
  .card-description { text-align: left; }

  .controls { display: none; }

  .event-single { padding: 40px 22px 60px; }
  .event-title { font-size: 24px; }
}

/* ── Tablet（768–1024px） ──────────────────────────── */
@media (min-width: 768px) and (max-width: 1024px) {
  .event-card { flex: 0 0 190px; max-width: 190px; width: 190px; }
  .card-image { width: 140px; height: 140px; }
  .year-marker { flex: 0 0 140px; height: 140px; }
  .year-marker-circle { width: 70px; height: 70px; font-size: 14px; }
  .timeline-track { gap: 56px; padding: 50px 60px; }
  .year-events { gap: 16px; }
  .timeline-track::before { top: 120px; }
  .site-header { padding: 14px 30px; }
  .category-filter { padding: 12px 30px; }
  .year-index { padding: 12px 30px; }
  .controls { padding: 16px 30px; }
  .timeline-intro { flex: 0 0 460px; padding: 32px 30px; }
}
