/* ============================================================
   ZenTech - 主要樣式表
   色彩系統：
     --accent-1: #F14E23 (橘紅主色)
     --accent-2: #F14E55 (深紅輔色)
   ============================================================ */

/* ---------- CSS 自訂屬性 ---------- */
:root {
  --accent-1:   #F14E23;
  --accent-2:   #F14E55;
  --border:     #DBDBDB;
  --divider:    #E8E8E8;
  --text-muted: #9E9E9E;
  --text-main:  #1a1a1a;
  --text-body:  #333333;
  --bg-page:    #F5F5F5;
  --bg-card:    #ffffff;
  --bg-header:  #ffffff;
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  20px;
  --shadow-card: 0 0 6px 0 hsla(0,0%,45%,.22);
  --shadow-hover: 0 4px 16px 0 hsla(0,0%,35%,.18);
  --transition: 0.25s ease;
  --container: 1200px;
  --header-h:  60px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-body);
  background: var(--bg-page);
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent-1); }
img { display: block; max-width: 100%; height: auto; }
ul, ol { list-style: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }

/* ---------- 容器 ---------- */
.container {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 20px;
}

.section-gap { padding-block: 40px; }

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  border-bottom: 2px solid var(--accent-1);
  box-shadow: 0 2px 8px hsla(0,0%,0%,.08);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--header-h);
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-weight: 900;
  letter-spacing: -0.5px;
}
.logo-img {
  height: 28px;
  width: auto;
  margin-right: 8px;
  border-radius: 4px;
}
.logo-k {
  font-size: 22px;
  color: var(--accent-1);
}
.logo-sub {
  font-size: 22px;
  color: var(--accent-1);
  letter-spacing: 1px;
}

/* 主要導覽 */
.main-nav { margin-inline: auto; }
.main-nav ul {
  display: flex;
  gap: 4px;
}
.main-nav a {
  display: block;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  transition: color var(--transition), background var(--transition);
}
.main-nav a:hover,
.main-nav a.active {
  color: var(--accent-1);
  background: hsla(241, 82%, 55%, 0.06);
}
.main-nav a.active {
  background: hsla(16, 88%, 55%, 0.08);
}

/* Header 右側操作 */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* 漢堡選單按鈕 */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px; height: 36px;
  padding: 6px;
  border-radius: var(--radius-sm);
}
.hamburger span {
  display: block;
  height: 2px;
  background: var(--text-main);
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================================
   NEWS HERO
   ============================================================ */
.news-hero-section {
  background: #080a10;
  border-bottom: 1px solid var(--border);
}

.news-hero-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-wrap: wrap;
}

.news-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f87171;
  flex-shrink: 0;
  animation: pulse-red 1.8s ease-in-out infinite;
}
@keyframes pulse-red {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(248,113,113,.5); }
  50%       { opacity: .7; box-shadow: 0 0 0 5px rgba(248,113,113,0); }
}

.news-hero-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .8px;
  color: #f87171;
  text-transform: uppercase;
}

.news-source-tags {
  margin-left: auto;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.news-stag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
}

.news-list {
  list-style: none;
  padding: 2px 0 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 32px;
}

.news-item {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
  min-width: 0;
}
.news-item:last-child,
.news-item:nth-last-child(2):nth-child(odd) { border-bottom: none; }

.news-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.news-item a {
  font-size: 13px;
  color: #ffffff;
  text-decoration: none;
  line-height: 1.4;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  display: block;
}
.news-item a:hover { color: var(--accent-1); }

.news-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.news-error {
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 0;
  text-align: center;
}

/* ============================================================
   MAGAZINE LAYOUT
   ============================================================ */
.magazine-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 32px;
  align-items: start;
}

/* 區塊標題列 */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent-1);
}
.section-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  position: relative;
}
.see-all {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-1);
  transition: opacity var(--transition);
}
.see-all:hover { opacity: .75; }

/* ============================================================
   CARD 元件
   ============================================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-img-wrap {
  display: block;
  position: relative;
  overflow: hidden;
  aspect-ratio: 16/9;
  background: var(--divider);
}
.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.card:hover .card-img-wrap img { transform: scale(1.04); }

.card-tag {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--accent-1);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 4px;
  z-index: 2;
}

.card-body { padding: 18px 20px 20px; }
.card-body h3 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--text-main);
  margin-bottom: 8px;
}
.card-body h3 a:hover { color: var(--accent-1); }

.card-excerpt {
  font-size: 13.5px;
  color: var(--text-body);
  line-height: 1.65;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.card-author { font-weight: 600; }

/* 精選大卡 */
.featured-card { margin-bottom: 24px; }
.featured-card .card-img-wrap { aspect-ratio: 16/9; }
.featured-card .card-body h3 { font-size: 18px; }
.featured-card .card-excerpt { -webkit-line-clamp: 4; }

/* 小卡 Grid（3欄） */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar { display: flex; flex-direction: column; gap: 24px; }

.widget {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 20px;
}
.widget-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent-1);
}

/* 熱門文章列表 */
.popular-list { display: flex; flex-direction: column; gap: 14px; }
.popular-list li a {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.popular-list li a:hover .popular-title { color: var(--accent-1); }
.popular-num {
  font-size: 22px;
  font-weight: 900;
  color: var(--divider);
  line-height: 1;
  flex-shrink: 0;
  width: 28px;
}
.popular-list li:first-child .popular-num { color: var(--accent-1); }
.popular-list li:nth-child(2) .popular-num { color: var(--accent-2); }
.popular-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-main);
  margin-bottom: 4px;
  transition: color var(--transition);
}
.popular-list time {
  font-size: 11.5px;
  color: var(--text-muted);
}


/* 標籤雲 */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tag-item {
  display: inline-block;
  padding: 4px 12px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12.5px;
  color: var(--text-body);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.tag-item:hover {
  background: var(--accent-1);
  color: #fff;
  border-color: var(--accent-1);
}

/* ============================================================
   第二內容區（3欄 Grid）
   ============================================================ */
.content-section { background: var(--bg-card); }

.cards-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}


/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  background: var(--text-main);
  color: rgba(255,255,255,.75);
  padding-top: 48px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
  padding-bottom: 40px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.footer-brand .logo { margin-bottom: 12px; }
.footer-brand .logo-k { color: var(--accent-1); }
.footer-brand .logo-sub { color: var(--accent-1); }
.footer-brand p {
  font-size: 13.5px;
  line-height: 1.7;
  margin-bottom: 20px;
  color: rgba(255,255,255,.6);
}

.social-links { display: flex; gap: 10px; }
.social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.8);
  transition: background var(--transition), color var(--transition);
}
.social-link:hover { background: var(--accent-1); color: #fff; }

.footer-col h4 {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.footer-col ul { display: flex; flex-direction: column; gap: 10px; }
.footer-col a {
  font-size: 13.5px;
  color: rgba(255,255,255,.6);
  transition: color var(--transition);
}
.footer-col a:hover { color: var(--accent-1); }

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-block: 20px;
  font-size: 12.5px;
  color: rgba(255,255,255,.4);
}

/* ============================================================
   RESPONSIVE — 平板 (768px ~ 1024px)
   ============================================================ */
@media (max-width: 1024px) {
  .magazine-layout {
    grid-template-columns: 1fr 260px;
    gap: 24px;
  }
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .cards-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}

/* ============================================================
   RESPONSIVE — 手機 (< 768px)
   ============================================================ */
@media (max-width: 768px) {

  /* Header */
  .hamburger { display: flex; }
  .main-nav {
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: var(--bg-header);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    z-index: 99;
    margin: 0;
  }
  .main-nav.open { transform: translateX(0); }
  .main-nav ul {
    flex-direction: column;
    gap: 0;
    padding: 12px 0;
  }
  .main-nav a {
    padding: 14px 24px;
    font-size: 16px;
    border-radius: 0;
    border-bottom: 1px solid var(--divider);
  }

  /* News hero */
  .news-list { grid-template-columns: 1fr; }

  /* Magazine layout → stacked */
  .magazine-layout { grid-template-columns: 1fr; gap: 24px; }
  .sidebar { order: -1; }

  /* Cards */
  .cards-grid { grid-template-columns: 1fr; }
  .cards-grid-3 { grid-template-columns: 1fr; }
  .featured-card .card-img-wrap { aspect-ratio: 16/9; }
  .featured-card .card-body h3 { font-size: 16px; }

  /* Footer */
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
  .footer-brand { grid-column: auto; }
  .footer-bottom { flex-direction: column; text-align: center; }
}

@media (max-width: 480px) {
  .slide-content { padding: 16px; }
  .slide-content .tag { font-size: 10px; margin-bottom: 8px; }
  .slide-content h2 { font-size: 14px; }
}

/* ============================================================
   尊重使用者動態偏好
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .news-live-dot { animation: none; }
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--divider);
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: all var(--transition);
}
.page-btn:hover:not(.disabled) { border-color: var(--accent-1); color: var(--accent-1); }
.page-btn.active { background: var(--accent-1); color: #fff; border-color: var(--accent-1); pointer-events: none; }
.page-btn.disabled { opacity: .35; pointer-events: none; }
.page-ellipsis { color: var(--text-muted); font-size: 13px; padding: 0 2px; }

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--divider);
  border-top-color: var(--accent-1);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   YouTube 頻道卡片（側邊欄 Widget）
   ============================================================ */
.yt-channel-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 4px 0;
}
.yt-icon { line-height: 0; }
.yt-logo {
  max-width: 140px;
  max-height: 60px;
  object-fit: contain;
}
.yt-subscribe-btn {
  display: inline-block;
  background: #FF0000;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 20px;
  border-radius: var(--radius-lg);
  transition: background var(--transition);
}
.yt-subscribe-btn:hover { background: #cc0000; color: #fff; }

/* ============================================================
   文章頁版面
   ============================================================ */
.article-container { padding-block: 32px; }

.article-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 32px;
  align-items: start;
}

/* 麵包屑 */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.breadcrumb a { color: var(--text-muted); transition: color var(--transition); }
.breadcrumb a:hover { color: var(--accent-1); }
.breadcrumb .sep {
  font-size: 10px;
  opacity: .5;
}
.breadcrumb .current { color: var(--text-body); }

/* 文章 meta（類別 + 日期）*/
.article-meta-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.article-cat-tag {
  display: inline-block;
  background: var(--accent-1);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  padding: 4px 12px;
  border-radius: 4px;
}
.article-date {
  font-size: 13px;
  color: var(--text-muted);
}

/* 文章標題 */
.article-title {
  font-size: clamp(20px, 3vw, 30px);
  font-weight: 900;
  line-height: 1.35;
  color: var(--text-main);
  margin-bottom: 8px;
}

/* 文章摘要 */
.article-excerpt {
  font-size: 15.5px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--divider);
}

/* YouTube 嵌入容器（響應式 16:9）*/
.yt-embed-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  margin-bottom: 32px;
  box-shadow: var(--shadow-hover);
}
.yt-embed-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* 文章內文 */
.article-body {
  font-size: 16px;
  line-height: 1.85;
  color: var(--text-body);
}
.article-body p {
  margin-bottom: 1.4em;
  text-align: justify;
}
.article-body p:last-child { margin-bottom: 0; }

.article-figure {
  margin: 1.8em 0;
}
.article-figure img {
  width: 100%;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.article-figure figcaption {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* 標籤列 */
.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--divider);
}
.article-tags .tag-item {
  font-size: 12px;
}

/* 文章頁分享列 */
.article-share {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
}
.share-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  transition: opacity var(--transition);
}
.share-btn:hover { opacity: .85; color: #fff; }
.share-btn.fb { background: #1877F2; }
.share-btn.yt { background: #FF0000; }
.share-btn.line { background: #06C755; }

/* 404 / 錯誤訊息 */
.article-not-found {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.article-not-found h2 {
  font-size: 22px;
  color: var(--text-main);
  margin-bottom: 12px;
}
.article-not-found a {
  color: var(--accent-1);
  font-weight: 600;
}

/* ============================================================
   RWD — 文章頁
   ============================================================ */
@media (max-width: 1024px) {
  .article-layout { grid-template-columns: 1fr 260px; }
}

@media (max-width: 768px) {
  .article-layout { grid-template-columns: 1fr; }
  .article-sidebar { order: -1; }
.article-title { font-size: 20px; }
  .article-body { font-size: 15px; }
}
