/*
Theme Name: Talking Drums Radio
Theme URI: https://talkingdrums.tw
Author: TheCube Project Space + Claude
Description: Block Theme for 話鼓電台 Talking Drums Radio — 線上策展與廣播藝術節目資料庫
Version: 0.3.0
Requires at least: 6.5
Tested up to: 6.6
Requires PHP: 8.1
License: GPL v2 or later
Text Domain: talking-drums
Tags: block-theme, full-site-editing, custom-colors, podcast
*/

/* === 通用前台 CSS（補充 theme.json 無法表達的部分）=== */
/* 大部分樣式請寫進 theme.json 或 block patterns，僅 hover/animation 等動態效果寫這裡 */

/* === Contributor card hover === */
.td-contributor-card:hover {
  background: #fafafa !important;
  border-color: #e62019 !important;
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.08);
}

/* === wpautop 解毒劑：讓 WP 自動注入的 <p> / <br> 不破壞 layout === */
.td-archive p,
.td-archive__grid p,
.td-card p,
.td-card-wrap p,
.td-related-grid p,
.td-episode-list p,
.td-ep p,
.td-series-page > p,
.td-series-section > p {
  display: contents !important;
  margin: 0 !important;
}
.td-archive br,
.td-archive__grid br,
.td-card br,
.td-card-wrap br,
.td-related-grid br,
.td-episode-list br,
.td-ep br,
.td-series-section br {
  display: none !important;
}

/* === Reset & Base === */
body {
  margin: 0; padding: 0;
  font-family: 'Inter', 'Noto Sans TC', -apple-system, "PingFang TC", "Helvetica Neue", sans-serif;
  line-height: 1.65;
  font-size: 17px;
  color: #000;
  background: #fff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
* { box-sizing: border-box; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

/* 大標題類用 Noto Sans TC（思源黑體）較粗：中文字會用 900 號重，英文 fallback Inter Black */
h1, h2,
.td-archive__title, .td-series-hero__title, .td-subject-page h1,
.td-contributor-page h1, .td-programs-archive h1, .td-all-episodes h1 {
  font-family: 'Noto Sans TC', 'Inter', sans-serif;
  letter-spacing: -0.02em;
}
h1 { font-weight: 900; }
h2 { font-weight: 700; }

/* === Header === */
.td-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 40px;
  border-bottom: 1px solid #d8d8d6;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}
.td-header__logo img { height: 56px; }
.td-header__nav {
  display: flex;
  gap: 32px;
  align-items: center;
  font-size: 16px;
  font-weight: 500;
}
.td-header__nav a {
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: border-color 0.2s;
}
.td-header__nav a:hover { border-bottom-color: #e62019; }
.td-header__lang { color: #6b6b6b; }
.td-header__search { font-size: 16px; }

/* === Archive Page === */
.td-archive { width: 100%; }
.td-archive__hero {
  padding: 64px 24px;
  border-bottom: 1px solid #d8d8d6;
  background: #f4f4f2;
}
.td-archive__hero-inner { max-width: 1280px; margin: 0 auto; }
.td-archive__title {
  font-size: clamp(48px, 7vw, 88px);
  font-weight: 900;
  letter-spacing: -3px;
  line-height: 1;
  margin: 0 0 8px;
}
.td-archive__title-en {
  font-size: clamp(20px, 2vw, 28px);
  color: #6b6b6b;
  margin-bottom: 16px;
}
.td-archive__lede { font-size: 17px; color: #444; max-width: 760px; }
.td-archive__grid-wrap { padding: 56px 24px; }
.td-archive__grid-inner { max-width: 1280px; margin: 0 auto; }
.td-archive__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px 24px;
}
@media (max-width: 1100px) { .td-archive__grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 800px)  { .td-archive__grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px)  { .td-archive__grid { grid-template-columns: 1fr; } }
.td-card__title {
  font-size: 16px;
  font-weight: 700;
  margin-top: 14px;
  line-height: 1.4;
}
.td-card__meta {
  font-size: 13px;
  color: #6b6b6b;
  margin-top: 4px;
}

/* td-related-grid 強制 3 column (寬螢幕)，響應式縮小 */
.td-related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 24px;
}
@media (max-width: 900px) { .td-related-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .td-related-grid { grid-template-columns: 1fr; } }

/* === Series Page Layout === */
.td-series-page { display: block; width: 100%; }

/* Hero 全寬封面 */
.td-series-hero {
  position: relative;
  width: 100%;
  height: clamp(360px, 56vw, 560px);
  background: #111;
  overflow: hidden;
}
.td-series-hero__img {
  position: absolute; inset: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  object-position: center;
  display: block;
  max-width: none;
}
.td-series-hero__overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 30%, rgba(0,0,0,0.85) 100%);
}
.td-series-hero__inner {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px;
  color: #fff;
}
.td-series-hero__title {
  font-size: clamp(36px, 5vw, 64px);
  font-weight: 900;
  letter-spacing: -2px;
  line-height: 1.05;
  margin: 0 0 12px;
  color: #fff;
}
.td-series-hero__meta {
  font-size: 15px;
  color: rgba(255,255,255,0.85);
}
.td-kicker {
  font-size: 13px;
  letter-spacing: 3px;
  color: #e62019;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 12px;
}

/* 策展論述 (760 易讀寬度) */
.td-series-body {
  background: #f4f4f2;
  padding: 64px 24px;
  border-bottom: 1px solid #d8d8d6;
}
.td-series-body__inner {
  max-width: 760px;
  margin: 0 auto;
}
.td-series-body__label {
  font-size: 13px;
  letter-spacing: 2px;
  color: #e62019;
  font-weight: 600;
  text-transform: uppercase;
  margin: 0 0 24px;
}
.td-series-content { font-size: 17px; line-height: 1.85; }
.td-series-content p { margin: 0 0 1.2em; }
.td-series-content h2, .td-series-content h3, .td-series-content h4 {
  margin: 2em 0 0.6em;
  font-weight: 700;
}
.td-series-content strong { font-weight: 700; }
.td-series-content a { color: #e62019; border-bottom: 1px solid currentColor; }

/* 集數列表與相關系列共用區段 */
.td-series-section {
  padding: 56px 24px;
  border-bottom: 1px solid #d8d8d6;
  background: #fff;
}
.td-series-section__inner {
  max-width: 1280px;
  margin: 0 auto;
}
.td-section-title {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 28px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.td-section-title__en {
  font-size: 16px;
  color: #6b6b6b;
  font-weight: 400;
  letter-spacing: 0.5px;
}

/* === Footer === */
.td-footer {
  background: #000;
  color: #fff;
  padding: 56px 40px 40px;
}
.td-footer__inner { max-width: 1280px; margin: 0 auto; }
.td-footer__brand { font-size: 14px; font-weight: 600; letter-spacing: 1px; margin-bottom: 32px; }
.td-footer__brand .x { color: #e62019; margin: 0 8px; }
.td-footer__links { display: flex; gap: 24px; margin-bottom: 16px; font-size: 13px; color: #aaa; }
.td-footer__links a:hover { color: #fff; }
.td-footer__platforms { font-size: 12px; color: #666; margin-bottom: 32px; }
.td-footer__copyright { font-size: 11px; color: #555; padding-top: 24px; border-top: 1px solid #222; }


/* REC 紅點脈動 */
@keyframes td-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(230, 32, 25, 0.7); transform: scale(1); }
  70%  { box-shadow: 0 0 0 14px rgba(230, 32, 25, 0); transform: scale(1.15); }
  100% { box-shadow: 0 0 0 0 rgba(230, 32, 25, 0); transform: scale(1); }
}
@keyframes td-tape-shake {
  0%   { transform: translateY(0); }
  25%  { transform: translateY(-1px); }
  50%  { transform: translateY(1px); }
  75%  { transform: translateY(-0.5px); }
  100% { transform: translateY(0); }
}
@keyframes td-pulse-white {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* 節目卡 hover — 抬升 + 陰影 + 磁帶橫紋 */
.td-card {
  display: block;
  position: relative;
  overflow: visible;
  transition: transform 0.35s cubic-bezier(.2,.8,.2,1);
}
.td-card:hover { transform: translateY(-10px); }
.td-card__img {
  aspect-ratio: 1 / 1;
  background-size: cover;
  background-position: center;
  background-color: #1a1a1a;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.35s ease, filter 0.35s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.td-card:hover .td-card__img {
  box-shadow: 0 24px 48px rgba(0,0,0,0.25), 0 4px 12px rgba(230,32,25,0.15);
  filter: contrast(1.05);
}
.td-card__img::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    180deg,
    rgba(255,255,255,0)   0,
    rgba(255,255,255,0.55) 1px,
    rgba(255,255,255,0)   3px,
    rgba(0,0,0,0.18)      4px,
    rgba(255,255,255,0)   6px
  );
  opacity: 0;
  mix-blend-mode: overlay;
  transition: opacity 0.25s;
  pointer-events: none;
  animation: td-tape-shake 0.6s steps(8) infinite;
  animation-play-state: paused;
}
.td-card:hover .td-card__img::before {
  opacity: 0.9;
  animation-play-state: running;
}
.td-rec-dot {
  position: absolute;
  top: 14px; left: 14px;
  width: 14px; height: 14px;
  background: var(--wp--preset--color--td-red);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 2;
}
.td-card:hover .td-rec-dot {
  opacity: 1;
  animation: td-pulse 1.3s infinite;
}

/* Subject 卡 (主題網格) */
.td-subject {
  position: relative;
  height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 28px;
  color: #fff;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(.2,.8,.2,1), box-shadow 0.35s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  overflow: hidden;
}
.td-subject:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 30px 60px rgba(0,0,0,0.35), 0 8px 16px rgba(230,32,25,0.2);
}
.td-subject::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.85) 100%);
  z-index: 0;
}
.td-subject::after {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    180deg,
    rgba(255,255,255,0)   0,
    rgba(255,255,255,0.45) 1px,
    rgba(255,255,255,0)   3px,
    rgba(0,0,0,0.25)      4px,
    rgba(255,255,255,0)   6px
  );
  opacity: 0;
  mix-blend-mode: overlay;
  transition: opacity 0.25s;
  z-index: 1;
  animation: td-tape-shake 0.5s steps(8) infinite;
  animation-play-state: paused;
}
.td-subject:hover::after {
  opacity: 0.9;
  animation-play-state: running;
}

/* 集數列表（節目排程表）行 */
.td-episode-list { display: block; }
.td-ep {
  display: grid;
  grid-template-columns: 80px 1fr 110px 70px;
  align-items: center;
  gap: 16px;
  padding: 18px 16px;
  border-bottom: 1px solid #d8d8d6;
  cursor: pointer;
  position: relative;
  transition: background 0.2s, padding 0.2s;
  color: inherit;
  text-decoration: none;
}
.td-ep__no {
  color: #e62019;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.td-ep__no .dot {
  display: inline-block;
  width: 10px; height: 10px;
  background: #e62019;
  border-radius: 50%;
  transition: transform 0.2s;
}
.td-ep:hover .td-ep__no .dot {
  animation: td-pulse 1.3s infinite;
}
.td-ep__title { font-size: 17px; font-weight: 500; line-height: 1.4; }
.td-ep__date { color: #6b6b6b; font-size: 14px; white-space: nowrap; }
.td-ep__duration { color: #6b6b6b; font-size: 14px; text-align: right; white-space: nowrap; }
.td-ep::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    180deg,
    transparent           0,
    rgba(230,32,25,0.18) 1px,
    transparent          3px,
    rgba(0,0,0,0.08)     4px,
    transparent          6px
  );
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  animation: td-tape-shake 0.55s steps(8) infinite;
  animation-play-state: paused;
}
.td-ep:hover { background: rgba(230,32,25,0.08); padding-left: 24px; }
.td-ep:hover::before { opacity: 1; animation-play-state: running; }

/* Nav 訂閱按鈕 dropdown */
.td-subscribe { position: relative; margin-left: 8px; }
.td-subscribe > button {
  background: var(--wp--preset--color--td-red);
  color: #fff;
  border: none;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
}
.td-subscribe > button:hover { background: #000; }
.td-subscribe > button .dot {
  width: 8px; height: 8px; background: #fff; border-radius: 50%;
  animation: td-pulse-white 1.6s infinite;
}
.td-subscribe__menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #fff;
  border: 1px solid #000;
  min-width: 220px;
  padding: 12px 0;
  box-shadow: 0 12px 32px rgba(0,0,0,0.15);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all 0.2s;
  z-index: 200;
}
.td-subscribe:hover .td-subscribe__menu,
.td-subscribe:focus-within .td-subscribe__menu {
  opacity: 1; visibility: visible; transform: translateY(0);
}

/* Dropdown link hover */
.td-subscribe__menu a {
  transition: background 0.15s, color 0.15s;
}
.td-subscribe__menu a:hover {
  background: #f4f4f2 !important;
  color: #e62019 !important;
}

/* Search icon hover */
.td-header__search { color: #000; transition: color 0.2s; }
.td-header__search:hover { color: #e62019; }

/* === Hamburger button（桌面隱藏，手機顯示）=== */
.td-header__burger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  width: 40px;
  height: 40px;
  padding: 10px 8px;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
}
.td-header__burger span {
  display: block;
  height: 2px;
  background: #000;
  transition: transform 0.3s, opacity 0.3s;
  transform-origin: center;
}

/* === Subscribe dropdown：JS-toggled 取代 hover === */
.td-subscribe__menu.is-open {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) !important;
}

/* ============================================================
 * Mobile / 響應式優化（覆蓋 inline style 需用 !important）
 * 斷點：768px tablet 以下｜480px phone 以下
 * ============================================================ */

@media (max-width: 768px) {
  /* === Header + Burger Drawer === */
  .td-header {
    padding: 6px 16px !important;
    position: relative;
    justify-content: space-between !important;
  }
  .td-header__logo img { height: 40px !important; }
  .td-header__burger { display: flex !important; margin-left: auto; }

  /* Hamburger → X 轉換 */
  .td-header__burger[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .td-header__burger[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
  }
  .td-header__burger[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* Nav drawer：從 header 下方滑出 */
  .td-header__nav {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    background: #fff !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0 !important;
    padding: 8px 20px 24px !important;
    border-bottom: 1px solid #d8d8d6 !important;
    box-shadow: 0 12px 24px rgba(0,0,0,0.08);
    transform: translateY(-110%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s ease, opacity 0.25s ease, visibility 0.3s;
    z-index: 99;
  }
  .td-header__nav.is-open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }
  .td-header__nav a {
    padding: 14px 0 !important;
    font-size: 17px !important;
    font-weight: 500 !important;
    border-bottom: 1px solid #f0f0ec !important;
    width: 100%;
    display: block;
  }
  .td-header__nav a:last-of-type { border-bottom: 0 !important; }

  /* 語言切換 / 搜尋 圖示在 drawer 內水平排列 */
  .td-header__lang,
  .td-header__search {
    display: inline-block !important;
    width: auto !important;
    padding: 14px 16px 14px 0 !important;
  }

  /* 訂閱 dropdown 在 drawer 內 */
  .td-subscribe { margin: 14px 0 0 !important; width: 100%; }
  .td-subscribe > button {
    width: 100% !important;
    justify-content: center !important;
    padding: 12px 18px !important;
    font-size: 14px !important;
  }
  .td-subscribe__menu {
    position: static !important;
    width: 100% !important;
    margin-top: 8px !important;
    border: 1px solid #e0e0dc !important;
    box-shadow: none !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: none;
  }
  .td-subscribe__menu.is-open { display: block !important; }

  /* === Hero 標題縮 === */
  .td-archive__title { font-size: 40px !important; line-height: 1.05 !important; }
  .td-section-title { font-size: 22px !important; }
  .td-section-title__en { font-size: 13px !important; }

  /* === Grid 2 col === */
  .td-archive__grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 20px 12px !important;
  }

  /* === Series page hero === */
  .td-series-hero { height: clamp(260px, 50vw, 360px) !important; }
  .td-series-hero__inner { padding: 24px 20px !important; }
  .td-series-hero__title { font-size: clamp(24px, 6vw, 36px) !important; letter-spacing: -1px !important; }
  .td-series-hero__meta { font-size: 13px !important; }

  /* === Section padding 縮 === */
  .td-series-section,
  .td-archive__grid-wrap { padding: 32px 16px !important; }
  .td-series-body { padding: 40px 20px !important; }
  .td-series-content { font-size: 16px !important; line-height: 1.8 !important; }

  /* === Episode list 變垂直，加左側紅色 accent bar 取代 hover 效果 === */
  .td-ep {
    grid-template-columns: 1fr !important;
    padding: 14px 12px 14px 18px !important;
    gap: 4px !important;
    border-left: 3px solid transparent !important;
  }
  .td-ep:active,
  .td-ep:focus {
    background: rgba(230,32,25,0.06) !important;
    border-left-color: #e62019 !important;
  }
  .td-ep:hover { padding-left: 18px !important; }
  .td-ep__no { font-size: 12px !important; flex: none !important; }
  .td-ep__title { font-size: 15px !important; }
  .td-ep__date,
  .td-ep__duration {
    font-size: 12px !important;
    text-align: left !important;
    color: #888 !important;
  }

  /* === 思源黑體 900 在手機降為 700（視覺較輕） === */
  h1, .td-archive__title, .td-series-hero__title {
    font-weight: 700 !important;
  }

  /* === 時間軸視圖手機隱藏（容器寬度不足）=== */
  .td-view[data-view="timeline"] {
    display: none !important;
  }
  .td-view-toggle [data-view="timeline"] {
    display: none !important;
  }
  /* 標出「列表」按鈕為唯一選項 */
  .td-view-toggle [data-view="list"] {
    background: #000 !important;
    color: #fff !important;
  }

  /* === Related grid === */
  .td-related-grid { grid-template-columns: 1fr 1fr !important; gap: 14px !important; }

  /* === Subscribe button === */
  .td-subscribe > button {
    padding: 8px 14px !important;
    font-size: 12px !important;
    letter-spacing: 0.5px !important;
  }
  .td-subscribe__menu { min-width: 180px !important; right: -8px !important; }

  /* === Footer === */
  .td-footer { padding: 32px 16px 24px !important; }
  .td-footer__brand { font-size: 13px !important; margin-bottom: 20px !important; }
  .td-footer__links { gap: 16px !important; font-size: 12px !important; flex-wrap: wrap; }

  /* === Subject grid (主題網格) === */
  .td-subject { height: 180px !important; padding: 20px !important; }

  /* === 主題篩選 chips === */
  .td-filter .td-chip {
    padding: 6px 12px !important;
    font-size: 13px !important;
  }

  /* === Hero kicker（資料庫 · ARCHIVE）字距收 === */
  .td-kicker { letter-spacing: 2px !important; font-size: 12px !important; }

  /* === Subject 內頁 hero === */
  .td-subject-page h1,
  .td-contributor-page h1,
  .td-programs-archive h1,
  .td-all-episodes h1 {
    font-size: 32px !important;
  }
}

@media (max-width: 480px) {
  .td-archive__grid { grid-template-columns: 1fr !important; }
  .td-related-grid { grid-template-columns: 1fr !important; }
  .td-archive__title { font-size: 34px !important; }
  .td-section-title { font-size: 20px !important; }
  .td-header__nav { font-size: 13px !important; gap: 10px !important; }
  .td-header__lang { display: none !important; }
}
