/*
Theme Name: Content Hub
Theme URI: https://example.com/content-hub
Author: Your Name
Author URI: https://example.com
Description: 入口型（portal）WordPress 主題。首頁中間以「區域分類磚塊」呈現各分類代表圖片與名稱，右欄固定顯示搜尋、熱門文章、依主題分類的最新文章；全站頁首固定，Logo 在左、右側為橫向捲動的大主題選單；全站附回到頂部按鈕。適合內容型入口網站、媒體站、多主題內容站使用。
Version: 2.0.0
Requires at least: 6.0
Requires PHP: 7.4
Tested up to: 6.6
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: content-hub
Tags: blog, news, custom-menu, featured-images, threaded-comments, translation-ready, grid-layout

Content Hub is distributed under the terms of the GNU GPL.
*/

/* =========================================================
   0. CSS 變數 / Design Tokens
   ========================================================= */
:root {
	--ch-color-bg: #ffffff;
	--ch-color-surface: #f6f7f9;
	--ch-color-border: #e5e7eb;
	--ch-color-text: #1a1d23;
	--ch-color-text-muted: #6b7280;
	--ch-color-accent: #2454ff;
	--ch-color-accent-dark: #1739b3;
	--ch-color-accent-contrast: #ffffff;
	--ch-font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", Roboto, Helvetica, Arial, sans-serif;
	--ch-radius: 10px;
	--ch-radius-sm: 6px;
	--ch-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
	--ch-shadow-hover: 0 4px 10px rgba(16, 24, 40, .08), 0 2px 4px rgba(16, 24, 40, .06);
	--ch-container: 1320px;
	--ch-gap: 32px;
	--ch-right-w: 320px;
	--ch-header-h: 68px;
}

/* =========================================================
   1. Reset / Base
   ========================================================= */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
	margin: 0;
	font-family: var(--ch-font-base);
	color: var(--ch-color-text);
	background: var(--ch-color-bg);
	line-height: 1.6;
	font-size: 16px;
}

img { max-width: 100%; height: auto; display: block; }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--ch-color-accent); }

ul, ol { margin: 0; padding: 0; list-style: none; }

button, input, textarea, select { font-family: inherit; font-size: inherit; }

h1, h2, h3, h4, h5, h6 { margin: 0 0 .5em; line-height: 1.3; font-weight: 700; }

p { margin: 0 0 1em; }

.screen-reader-text {
	position: absolute !important;
	clip: rect(1px, 1px, 1px, 1px);
	width: 1px; height: 1px; overflow: hidden;
}

.container {
	max-width: var(--ch-container);
	margin: 0 auto;
	padding: 0 24px;
}

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 10px 20px;
	border-radius: var(--ch-radius-sm);
	background: var(--ch-color-accent);
	color: var(--ch-color-accent-contrast);
	font-weight: 600;
	font-size: 14px;
	border: none;
	cursor: pointer;
	transition: background .15s ease, transform .15s ease;
}
.btn:hover { background: var(--ch-color-accent-dark); color: var(--ch-color-accent-contrast); transform: translateY(-1px); }
.btn-outline {
	background: transparent;
	color: var(--ch-color-accent);
	border: 1px solid var(--ch-color-accent);
}
.btn-outline:hover { background: var(--ch-color-accent); color: #fff; }
.btn-block { display: flex; width: 100%; }

/* 小標籤：文章卡片/內文頁上的分類眼標（例如「棒球」） */
.eyebrow-cat {
	display: inline-block;
	font-size: 11px;
	font-weight: 700;
	color: var(--ch-color-accent);
	text-transform: uppercase;
	letter-spacing: .05em;
	margin-bottom: 6px;
}

/* =========================================================
   2. Site Header：全站固定，Logo 在左、右側為橫向捲動的大主題選單
   ========================================================= */
.site-header {
	position: sticky;
	top: 0;
	z-index: 100;
	background: rgba(255,255,255,.92);
	backdrop-filter: saturate(180%) blur(8px);
	border-bottom: 1px solid var(--ch-color-border);
}
.site-header-inner {
	display: flex;
	align-items: center;
	gap: 20px;
	height: var(--ch-header-h);
}
.site-branding { display: flex; align-items: center; flex: 0 0 auto; }
.site-branding img.custom-logo { max-height: 40px; width: auto; }
.site-title { font-size: 19px; font-weight: 800; margin: 0; letter-spacing: -.02em; white-space: nowrap; }
.site-title a:hover { color: var(--ch-color-text); }

/* 橫向捲動的大主題選單：分類數量多、螢幕變窄時自動變成可滑動的捲軸，
   不需要另外做漢堡選單／off-canvas，桌機和手機共用同一套元件。 */
.main-navigation {
	flex: 1 1 auto;
	min-width: 0;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}
.main-navigation::-webkit-scrollbar { display: none; }
.main-navigation ul {
	display: flex;
	align-items: center;
	gap: 4px;
	flex-wrap: nowrap;
	width: max-content;
}
.main-navigation a {
	display: inline-block;
	padding: 8px 14px;
	border-radius: 999px;
	font-size: 14px;
	font-weight: 600;
	white-space: nowrap;
	color: var(--ch-color-text);
}
.main-navigation a:hover,
.main-navigation a.current-menu-item { background: var(--ch-color-surface); color: var(--ch-color-accent); }
.main-navigation a.current-menu-item { background: var(--ch-color-accent); color: #fff; }

.search-toggle {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: 1px solid var(--ch-color-border);
	background: #fff;
	color: var(--ch-color-text);
	cursor: pointer;
}
.search-toggle:hover { border-color: var(--ch-color-accent); color: var(--ch-color-accent); }

.header-search-drawer {
	max-height: 0;
	overflow: hidden;
	border-top: 0 solid var(--ch-color-border);
	background: var(--ch-color-surface);
	transition: max-height .25s ease;
}
.header-search-drawer.is-open { max-height: 100px; border-top-width: 1px; }
.header-search-drawer .container { padding-top: 16px; padding-bottom: 16px; }
.header-search-drawer .search-form { max-width: 480px; }
.header-search-drawer input[type="search"] {
	width: 100%;
	border: 1px solid var(--ch-color-border);
	border-radius: 999px;
	padding: 10px 18px;
	background: #fff;
}
.header-search-drawer input[type="search"]:focus { outline: 2px solid var(--ch-color-accent); }

/* =========================================================
   3. 首頁：入口型「區域分類磚塊」+ 固定右欄
   ========================================================= */
.portal-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) var(--ch-right-w);
	gap: var(--ch-gap);
	padding: 32px 0 64px;
	align-items: start;
}

.portal-main { min-width: 0; }

/* --- 中間：區域分類磚塊，桌機每列 3 個 --- */
.category-tile-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 22px;
}

.category-tile {
	position: relative;
	display: block;
	border-radius: var(--ch-radius);
	overflow: hidden;
	aspect-ratio: 4 / 3;
	background: var(--ch-color-surface);
	box-shadow: var(--ch-shadow);
	transition: transform .2s ease, box-shadow .2s ease;
}
.category-tile:hover { transform: translateY(-3px); box-shadow: var(--ch-shadow-hover); }
.category-tile__media { position: absolute; inset: 0; display: block; }
.category-tile__media img,
.category-tile__fallback { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s ease; }
.category-tile:hover .category-tile__media img,
.category-tile:hover .category-tile__fallback { transform: scale(1.06); }
.category-tile__scrim {
	position: absolute;
	inset: 0;
	background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,.72) 100%);
}
.category-tile__body {
	position: absolute;
	left: 0; right: 0; bottom: 0;
	padding: 18px 20px;
	color: #fff;
}
.category-tile__name { display: block; font-size: 20px; font-weight: 800; letter-spacing: -.01em; text-shadow: 0 1px 3px rgba(0,0,0,.25); }
.category-tile__count { display: block; font-size: 12.5px; color: rgba(255,255,255,.8); margin-top: 4px; }

/* --- 右欄：固定顯示 搜尋 / 熱門文章 / 依主題最新文章 --- */
.portal-sidebar { display: flex; flex-direction: column; gap: 20px; position: sticky; top: calc(var(--ch-header-h) + 20px); }

.side-block {
	background: var(--ch-color-surface);
	border: 1px solid var(--ch-color-border);
	border-radius: var(--ch-radius);
	padding: 20px;
}
.side-block--search { padding: 14px; }
.side-block--search .search-form { display: flex; }
.side-block--search input[type="search"] {
	flex: 1;
	border: 1px solid var(--ch-color-border);
	border-radius: 999px;
	padding: 10px 18px;
	background: #fff;
}
.side-block--search input[type="search"]:focus { outline: 2px solid var(--ch-color-accent); }
.side-block__title {
	font-size: 13px;
	text-transform: uppercase;
	letter-spacing: .06em;
	color: var(--ch-color-text-muted);
	margin-bottom: 14px;
}

/* 熱門文章：排名清單 */
.popular-list { display: flex; flex-direction: column; gap: 14px; }
.popular-list__item { display: flex; align-items: center; gap: 12px; }
.popular-list__rank {
	flex: 0 0 auto;
	width: 22px;
	font-size: 15px;
	font-weight: 800;
	color: var(--ch-color-text-muted);
	font-style: italic;
}
.popular-list__item:nth-child(-n+3) .popular-list__rank { color: var(--ch-color-accent); }
.popular-list__thumb {
	flex: 0 0 52px;
	width: 52px;
	height: 52px;
	border-radius: var(--ch-radius-sm);
	overflow: hidden;
	background: #fff;
}
.popular-list__thumb img { width: 100%; height: 100%; object-fit: cover; }
.popular-list__title {
	font-size: 13.5px;
	font-weight: 600;
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	color: var(--ch-color-text);
}
.popular-list__title:hover { color: var(--ch-color-accent); }

/* 依主題最新文章：每個主題各一小組 */
.topic-group { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--ch-color-border); }
.topic-group:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.topic-group__title { display: block; font-size: 14px; font-weight: 800; margin-bottom: 8px; }
.topic-group__title:hover { color: var(--ch-color-accent); }
.topic-group__list { display: flex; flex-direction: column; gap: 6px; }
.topic-group__list a {
	font-size: 13px;
	color: var(--ch-color-text-muted);
	display: block;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.topic-group__list a:hover { color: var(--ch-color-accent); }

/* =========================================================
   4. 一般文章列表 / 單篇文章 / 頁面
   ========================================================= */
.page-header { padding: 40px 0 24px; border-bottom: 1px solid var(--ch-color-border); margin-bottom: 32px; }
.page-header .page-title { font-size: 28px; }
.page-header .archive-description { color: var(--ch-color-text-muted); }

.content-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) var(--ch-right-w);
	gap: var(--ch-gap);
	padding-bottom: 64px;
}

.entry-list { display: flex; flex-direction: column; gap: 28px; }
.entry-card { display: grid; grid-template-columns: 220px 1fr; gap: 20px; }
.entry-card__thumb { border-radius: var(--ch-radius); overflow: hidden; aspect-ratio: 4/3; background: var(--ch-color-surface); }
.entry-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.entry-card__title { font-size: 20px; margin-bottom: 8px; }
.entry-card__excerpt { color: var(--ch-color-text-muted); font-size: 14px; }
.entry-card__meta { font-size: 12.5px; color: var(--ch-color-text-muted); margin-top: 8px; }

.single-post .entry-header { margin-bottom: 24px; }
.single-post .entry-title { font-size: 32px; }
.single-post .entry-meta { color: var(--ch-color-text-muted); font-size: 13px; margin-bottom: 20px; display: flex; gap: 14px; flex-wrap: wrap; }
.single-post .entry-thumbnail { border-radius: var(--ch-radius); overflow: hidden; margin-bottom: 28px; }
.single-post .entry-content { font-size: 17px; }
.single-post .entry-content h2 { font-size: 24px; margin-top: 1.6em; }
.single-post .entry-content h3 { font-size: 20px; margin-top: 1.4em; }
.single-post .entry-content img { border-radius: var(--ch-radius); }
.single-post .entry-content blockquote {
	margin: 24px 0;
	padding: 12px 20px;
	border-left: 3px solid var(--ch-color-accent);
	background: var(--ch-color-surface);
	color: var(--ch-color-text-muted);
}
.single-post .entry-tags { margin-top: 28px; display: flex; gap: 8px; flex-wrap: wrap; }
.single-post .entry-tags a {
	font-size: 12.5px;
	padding: 5px 12px;
	border-radius: 999px;
	background: var(--ch-color-surface);
	border: 1px solid var(--ch-color-border);
}

.post-navigation { display: flex; justify-content: space-between; gap: 20px; margin: 40px 0; padding-top: 24px; border-top: 1px solid var(--ch-color-border); }
.post-navigation a { font-size: 14px; font-weight: 600; max-width: 45%; }
.post-navigation .nav-subtitle { display: block; font-size: 11px; color: var(--ch-color-text-muted); text-transform: uppercase; margin-bottom: 4px; }

.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 32px; }
.pagination a, .pagination span {
	display: inline-flex; align-items: center; justify-content: center;
	min-width: 38px; height: 38px; padding: 0 10px;
	border-radius: var(--ch-radius-sm); border: 1px solid var(--ch-color-border);
	font-size: 13px; font-weight: 600;
}
.pagination .current { background: var(--ch-color-text); color: #fff; border-color: var(--ch-color-text); }
.pagination a:hover { border-color: var(--ch-color-accent); color: var(--ch-color-accent); }

/* Comments */
.comments-area { margin-top: 48px; }
.comments-title { font-size: 20px; margin-bottom: 20px; }
.comment-list { display: flex; flex-direction: column; gap: 20px; }
.comment-body { border: 1px solid var(--ch-color-border); border-radius: var(--ch-radius); padding: 16px; }
.comment-author { font-weight: 700; font-size: 14px; }
.comment-metadata { font-size: 12px; color: var(--ch-color-text-muted); margin-bottom: 8px; }
.comment-form input, .comment-form textarea {
	width: 100%; padding: 10px 12px; border: 1px solid var(--ch-color-border);
	border-radius: var(--ch-radius-sm); margin-bottom: 12px; background: #fff;
}

/* Sidebar widgets (single/page/archive) */
.widget { margin-bottom: 28px; background: var(--ch-color-surface); border: 1px solid var(--ch-color-border); border-radius: var(--ch-radius); padding: 20px; }
.widget-title { font-size: 15px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 14px; }

/* =========================================================
   5. Footer
   ========================================================= */
.site-footer { background: var(--ch-color-text); color: rgba(255,255,255,.75); margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 32px; padding: 56px 0 32px; }
.footer-grid .widget-title { color: #fff; font-size: 14px; }
.footer-grid .widget { background: transparent; border: none; padding: 0; }
.footer-grid a:hover { color: #fff; }
.site-footer .footer-bottom {
	border-top: 1px solid rgba(255,255,255,.12);
	padding: 18px 0;
	font-size: 12.5px;
	display: flex;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 8px;
}

/* =========================================================
   6. 回到頂部按鈕（全站固定，捲動一段距離後才出現）
   ========================================================= */
.back-to-top {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 90;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: 1px solid var(--ch-color-border);
	background: #fff;
	color: var(--ch-color-text);
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: var(--ch-shadow-hover);
	cursor: pointer;
	opacity: 0;
	transform: translateY(10px);
	pointer-events: none;
	transition: opacity .2s ease, transform .2s ease, background .15s ease, color .15s ease;
}
.back-to-top.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.back-to-top:hover { background: var(--ch-color-accent); color: #fff; border-color: var(--ch-color-accent); }

/* =========================================================
   7. Responsive
   ========================================================= */
@media (max-width: 1180px) {
	.portal-layout { grid-template-columns: minmax(0,1fr) 280px; }
	.content-layout { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
	.category-tile-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 880px) {
	.portal-layout { grid-template-columns: 1fr; padding-top: 20px; }
	.portal-sidebar { position: static; }
	.entry-card { grid-template-columns: 1fr; }
	.footer-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- 手機版：頁首縮小、分類磚塊改一列一個（圖片+標題） ---- */
@media (max-width: 680px) {
	.footer-grid { grid-template-columns: 1fr; padding: 40px 0 20px; }

	:root { --ch-header-h: 56px; }
	.site-header-inner { gap: 12px; }
	.site-branding img.custom-logo { max-height: 30px; }
	.site-title { font-size: 16px; }
	.main-navigation a { padding: 7px 12px; font-size: 13.5px; }
	.search-toggle { width: 34px; height: 34px; }

	.category-tile-grid { grid-template-columns: 1fr; gap: 14px; }
	.category-tile { aspect-ratio: 16 / 10; }
	.category-tile__body { padding: 14px 16px; }
	.category-tile__name { font-size: 17px; }
	.category-tile__count { display: none; } /* 手機版依需求只顯示圖片＋標題 */

	.back-to-top { right: 16px; bottom: 16px; width: 40px; height: 40px; }
}

@media (max-width: 560px) {
	.entry-card__thumb { aspect-ratio: 16/10; }
}
