/* ═══════════════════════════════════════════
   青花瓷設計系統 — USAGIWEB 社群網站
   ═══════════════════════════════════════════ */
:root {
  /* 青花藍色系 */
  --blue-deepest: #1A3A5C;
  --blue-deep: #234B73;
  --blue-mid: #336699;
  --blue-light: #5B8CB8;
  --blue-wash: #B8D0E8;
  --blue-mist: #E4EEF6;
  /* 瓷白 */
  --porcelain: #FAF8F5;
  --porcelain-warm: #F5F0E8;
  /* 金邊 */
  --gold: #C4A35A;
  --gold-light: #D9C48B;
  /* 文字 */
  --text-primary: #2C2416;
  --text-secondary: #6B6255;
  --text-muted: #9B948A;
  --text-on-blue: #FAF8F5;
  /* 功能色 */
  --success: #2D8659;
  --danger: #C44A4A;
  --warning: #C49A3A;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "SF Pro Text", "Noto Sans TC", sans-serif;
  background: var(--porcelain);
  color: var(--text-primary);
  line-height: 1.6;
}

h1, h2, h3, h4, .serif {
  font-family: "Noto Serif TC", "Songti TC", serif;
}

a { color: var(--blue-mid); text-decoration: none; }
a:hover { color: var(--blue-deep); }

/* ─── 導航欄 ─── */
.navbar {
  background: var(--blue-deepest);
  color: var(--text-on-blue);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text-on-blue) !important;
  font-size: 20px;
  font-weight: 700;
}
.navbar-logo .logo-icon {
  width: 32px; height: 32px;
  background: var(--blue-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.navbar-search {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 6px 14px;
  gap: 8px;
  width: 320px;
}
.navbar-search input {
  background: none;
  border: none;
  color: var(--text-on-blue);
  font-size: 14px;
  width: 100%;
  outline: none;
}
.navbar-search input::placeholder { color: rgba(255,255,255,0.5); }
.navbar-search button {
  background: none;
  border: none;
  color: var(--text-on-blue);
  cursor: pointer;
  font-size: 14px;
}
.navbar-links {
  display: flex;
  gap: 16px;
  align-items: center;
}
.navbar-links a {
  color: var(--blue-wash) !important;
  font-size: 14px;
}
.navbar-links a:hover { color: var(--text-on-blue) !important; }
.navbar-links .lang-switcher {
  display: flex;
  gap: 6px;
}
.navbar-links .lang-btn {
  padding: 3px 10px;
  border: 1px solid var(--blue-light);
  border-radius: 12px;
  background: transparent;
  font-size: 11px;
  cursor: pointer;
  color: var(--blue-wash);
  transition: all 0.15s;
  font-family: inherit;
}
.navbar-links .lang-btn:hover { border-color: #fff; color: #fff; }
.navbar-links .lang-btn.active { background: rgba(255,255,255,0.2); color: #fff; border-color: #fff; }

/* ─── Hero ─── */
.hero {
  background: linear-gradient(135deg, var(--blue-deepest) 0%, var(--blue-deep) 100%);
  color: var(--text-on-blue);
  padding: 60px 40px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  top: -80px; right: -60px;
}
.hero::after {
  content: '';
  position: absolute;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
  bottom: -40px; left: -40px;
}
.hero h1 {
  font-size: clamp(28px, 4vw, 48px);
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}
.hero p {
  font-size: clamp(14px, 1.6vw, 18px);
  color: var(--blue-wash);
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* ─── 主容器 ─── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* ─── 頁面區塊 ─── */
.page-section { display: none; }
.page-section.active { display: block; }

/* ─── APP 卡片網格 ─── */
.section-title {
  font-size: 22px;
  margin: 32px 0 20px;
  color: var(--blue-deep);
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--blue-wash);
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}
.app-card {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  cursor: pointer;
  transition: all 0.25s ease;
  border: none;
  box-shadow: 0 1px 4px rgba(26,58,92,0.04);
}
.app-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(26,58,92,0.12);
}
.app-card-icon {
  width: 80px; height: 80px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--blue-mid), var(--blue-light));
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  color: #fff;
  margin-bottom: 16px;
}
.app-card h3 { font-size: 17px; margin-bottom: 6px; }
.app-card p { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* ─── APP 主頁 ─── */
.app-header {
  background: var(--blue-mist);
  padding: 40px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.app-header-icon {
  width: 80px; height: 80px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--blue-mid), var(--blue-light));
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  color: #fff;
  flex-shrink: 0;
}
.app-header-info h1 { font-size: 26px; margin-bottom: 4px; }
.app-header-info p { font-size: 14px; color: var(--text-secondary); }

.app-layout {
  display: flex;
  gap: 24px;
  padding: 24px 0;
  min-height: 400px;
}
.app-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  border: none;
  align-self: flex-start;
  position: sticky;
  top: 80px;
}
.app-sidebar h4 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--blue-wash);
}
.category-tree { list-style: none; }
.category-tree li { margin: 2px 0; }
.category-tree a {
  display: block;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text-primary);
  border-radius: 6px;
  transition: background 0.15s;
  cursor: pointer;
}
.category-tree a:hover { background: var(--blue-mist); }
.category-tree a.active { background: var(--blue-mist); color: var(--blue-mid); font-weight: 600; }
.category-tree .has-children > a::before {
  content: '▸ ';
  color: var(--text-muted);
}
.category-tree .has-children.open > a::before {
  content: '▾ ';
}
.category-tree .children { padding-left: 16px; }
.category-tree .open > .children { display: block; }

.app-main {
  flex: 1;
  min-width: 0;
}

/* ─── 文章列表 ─── */
.article-list {}
.article-item.pinned {
  border-color: #FFB74D;
  background: #FFF8E1;
}
.article-item {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}
.article-item:hover {
  box-shadow: 0 4px 12px rgba(26,58,92,0.08);
}
.article-item-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.pin-badge {
  display: inline-block;
  background: #FFF3E0;
  color: #E65100;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  margin-right: 4px;
}
.article-item-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.article-item-summary { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.article-item-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tag {
  display: inline-block;
  background: var(--blue-mist);
  color: var(--blue-mid);
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 500;
}

/* ─── 語系切換器 ─── */
.lang-switcher {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}
.lang-btn {
  padding: 4px 12px;
  border: none;
  border-radius: 16px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.lang-btn:hover { border-color: var(--blue-mid); }
.lang-btn.active { background: var(--blue-mid); color: #fff; border-color: var(--blue-mid); }

/* ─── 文章詳情 ─── */
.article-detail {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px;
}
.article-detail .back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  cursor: pointer;
}
.article-detail .back-link:hover { color: var(--blue-mid); }
.article-detail h1 {
  font-size: clamp(24px, 3vw, 32px);
  margin-bottom: 12px;
  line-height: 1.3;
}
.article-detail-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--blue-wash);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.article-detail-cover {
  width: 100%;
  height: 280px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue-mist), var(--blue-wash));
  margin-bottom: 24px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  object-fit: cover;
}
.article-detail-body {
  line-height: 1.8;
  font-size: 15px;
}
.article-detail-body p { margin-bottom: 16px; }
.article-detail-body h3 { font-family: "Noto Serif TC", serif; font-size: 20px; margin: 24px 0 12px; color: var(--blue-deep); }
.article-detail-body h4 { font-size: 16px; margin: 16px 0 8px; }
.article-detail-body h5 { font-size: 15px; margin: 14px 0 6px; font-weight: 600; color: var(--blue-mid); }
.article-detail-body pre {
  background: #1A1F2E;
  color: #E2E8F0;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
  margin: 16px 0;
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
}
.article-detail-body pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.article-detail-body code {
  background: #EDF2F7;
  color: #C7254E;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
}
.dark-theme .article-detail-body code {
  background: #2D3748;
  color: #F687B3;
}
.dark-theme .article-detail-body pre {
  background: #0D1117;
  color: #E6EDF3;
}
.dark-theme .article-detail-body thead {
  background: #1A3A5C;
}
.dark-theme .article-detail-body td {
  border-bottom-color: rgba(255,255,255,.08);
}
.article-detail-body strong { color: var(--text-primary); }
.article-detail-body ul, .article-detail-body ol {
  padding-left: 24px;
  margin: 12px 0;
  line-height: 1.8;
}
.article-detail-body li { margin-bottom: 4px; }
.article-detail-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
  display: block;
  overflow-x: auto;
}
.article-detail-body thead {
  background: var(--blue-deep);
  color: var(--text-on-blue);
}
.article-detail-body th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}
.article-detail-body td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--blue-wash);
  vertical-align: top;
  line-height: 1.6;
}
.article-detail-body tbody tr:hover {
  background: var(--porcelain-warm);
}
.dark-theme .article-detail-body tbody tr:hover {
  background: rgba(255,255,255,.03);
}
.article-detail-body img {
  max-width: 100%;
  border-radius: 8px;
  margin: 16px 0;
  border: none;
  display: block;
}
.article-detail-body .yt-embed {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  margin: 16px 0;
  background: var(--blue-deep);
  border-radius: 10px;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-on-blue);
  font-size: 14px;
}
.article-detail-body .yt-embed iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}
.yt-embed-placeholder {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
}
.yt-embed-placeholder .play-icon {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
}
.share-bar {
  display: flex;
  gap: 10px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--blue-wash);
}
.share-btn {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
}
.share-btn:hover { border-color: var(--blue-mid); color: var(--blue-mid); }

/* ─── 搜尋結果 ─── */
.search-page { padding: 28px; }
.search-page h2 { margin-bottom: 16px; color: var(--blue-deep); }
.search-query { color: var(--text-secondary); font-size: 14px; margin-bottom: 20px; }

/* ─── 狀態標籤 badge ─── */
.status-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}
.status-badge.published { background: #E8F5E9; color: #2E7D32; }
.status-badge.pending { background: #FFF8E1; color: #F57F17; }
.status-badge.draft { background: #F5F5F5; color: #757575; }

/* ─── Footer ─── */
.footer {
  background: var(--blue-deepest);
  color: var(--text-on-blue);
  text-align: center;
  padding: 32px 24px;
  margin-top: 40px;
  font-size: 13px;
}
.footer a { color: var(--blue-wash) !important; }
.footer a:hover { color: var(--text-on-blue) !important; }

/* ─── 載入與錯誤 ─── */
.loading {
  text-align: center;
  padding: 60px;
  color: var(--text-muted);
}
.error-message {
  text-align: center;
  padding: 40px;
  color: var(--danger);
}
.empty-state {
  text-align: center;
  padding: 60px;
  color: var(--text-muted);
}

/* ─── 分頁 ─── */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 24px 0;
}
.pagination button {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
}
.pagination button:hover { border-color: var(--blue-mid); color: var(--blue-mid); }
.pagination button.active { background: var(--blue-mid); color: #fff; border-color: var(--blue-mid); }

/* ─── 響應式 ─── */
@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .app-sidebar { width: 100%; position: static; }
  .navbar-search { width: 160px; }
  .hero { padding: 40px 20px; }
}
