/*
Theme Name: Shelf
Description: ダーク基調のカードグリッド型ブログテーマ。新着/人気/高評価の並び替え、評価スコア、ライト/ダーク切替、ブックマーク、スマホ用タブバーを備えています。
Version: 1.0.0
Requires at least: 6.2
Requires PHP: 7.4
Text Domain: shelf
*/

/* ---------- tokens ---------- */
:root {
	--bg: #0e0e11;
	--bg-elev: #17171c;
	--bg-card: #1c1c22;
	--line: #2a2a33;
	--text: #ececf1;
	--text-sub: #9a9aa8;
	--accent: #ff4d7d;
	--accent-soft: rgba(255, 77, 125, .14);
	--star: #ffc24b;
	--shadow: 0 10px 28px rgba(0, 0, 0, .45);
	--radius: 12px;
	--header-h: 60px;
	--tabbar-h: 58px;
	color-scheme: dark;
}
:root[data-theme="light"] {
	--bg: #f5f5f7;
	--bg-elev: #ffffff;
	--bg-card: #ffffff;
	--line: #e2e2e8;
	--text: #1a1a22;
	--text-sub: #6b6b78;
	--accent: #e8336a;
	--accent-soft: rgba(232, 51, 106, .1);
	--star: #e89c00;
	--shadow: 0 10px 24px rgba(20, 20, 40, .12);
	color-scheme: light;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", Meiryo, system-ui, sans-serif;
	font-size: 15px;
	line-height: 1.7;
	transition: background .2s, color .2s;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
img { max-width: 100%; height: auto; display: block; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
.screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.icon { width: 20px; height: 20px; flex: none; }

/* ---------- header ---------- */
.site-header {
	position: sticky; top: 0; z-index: 50;
	background: color-mix(in srgb, var(--bg) 88%, transparent);
	backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 24px; height: var(--header-h); }
.site-logo { font-size: 20px; font-weight: 400; letter-spacing: .02em; white-space: nowrap; }
.site-logo b { font-weight: 800; color: var(--accent); }
.global-nav { flex: 1; min-width: 0; }
.global-nav ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; overflow-x: auto; scrollbar-width: none; }
.global-nav ul::-webkit-scrollbar { display: none; }
.global-nav a { display: block; padding: 6px 12px; border-radius: 999px; font-size: 14px; color: var(--text-sub); white-space: nowrap; }
.global-nav a:hover, .global-nav .current-menu-item > a { color: var(--text); background: var(--bg-elev); }
.header-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: var(--text-sub); position: relative; }
.icon-btn:hover { background: var(--bg-elev); color: var(--text); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }
.bm-count { position: absolute; top: 3px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 10px; line-height: 16px; text-align: center; font-weight: 700; }
.bm-count:empty { display: none; }

.search-panel { display: none; border-top: 1px solid var(--line); padding: 12px 0; }
.search-panel.is-open { display: block; }
.search-form { display: flex; gap: 8px; }
.search-form input[type="search"] {
	flex: 1; min-width: 0; height: 42px; padding: 0 16px; border-radius: 999px;
	border: 1px solid var(--line); background: var(--bg-elev); color: var(--text); font-size: 15px;
}
.search-form input[type="search"]:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search-form button { height: 42px; padding: 0 20px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 700; }

/* ---------- sections ---------- */
.site-main { padding: 24px 0 48px; min-height: 60vh; }
.section { margin-bottom: 44px; }
.section-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 12px; margin-bottom: 16px; }
.section-title { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: .02em; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .06em; }
.section-count { color: var(--text-sub); font-size: 13px; }
.section-count strong { color: var(--text); font-size: 15px; }
.section-sub { color: var(--text-sub); font-size: 13px; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; }
.more-link { margin-left: auto; font-size: 13px; color: var(--text-sub); white-space: nowrap; }
.more-link:hover { color: var(--accent); }

.tabs { display: flex; gap: 2px; padding: 3px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 999px; }
.tab { padding: 3px 12px; border-radius: 999px; font-size: 13px; color: var(--text-sub); }
.tab[aria-selected="true"] { background: var(--accent); color: #fff; font-weight: 700; }
.tab-panel[hidden] { display: none; }

/* ---------- card grid ---------- */
.card-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 18px 14px; list-style: none; margin: 0; padding: 0; }
@media (max-width: 1200px) { .card-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 960px)  { .card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 720px)  { .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 10px; } }
@media (max-width: 480px)  { .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.card {
	position: relative; display: flex; flex-direction: column; height: 100%;
	background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
	transition: transform .2s ease, box-shadow .2s ease, border-color .2s;
}
.card:hover { transform: translateY(-3px) scale(1.02); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.card-link { display: flex; flex-direction: column; flex: 1; color: inherit; }
.card-link:hover { color: inherit; }
.card-thumb { position: relative; aspect-ratio: 3 / 4; background: var(--bg-elev); overflow: hidden; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.card:hover .card-thumb img { transform: scale(1.05); }
.card-thumb-placeholder {
	width: 100%; height: 100%; display: grid; place-items: center;
	background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 35%, var(--bg-elev)), var(--bg-elev));
	font-size: 42px; font-weight: 800; color: rgba(255, 255, 255, .85);
}
.card-rank { position: absolute; top: 0; left: 0; min-width: 30px; padding: 3px 8px; background: var(--accent); color: #fff; font-weight: 800; font-size: 13px; border-bottom-right-radius: 10px; text-align: center; }
.card-extra { position: absolute; right: 6px; bottom: 6px; padding: 1px 7px; border-radius: 4px; background: rgba(0, 0, 0, .7); color: #fff; font-size: 11px; }
.card-body { display: flex; flex-direction: column; gap: 6px; padding: 9px 10px 11px; flex: 1; }
.card-title {
	margin: 0; font-size: 13.5px; font-weight: 700; line-height: 1.45;
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em;
}
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; font-size: 12px; }
.card-cat { padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.rating { display: inline-flex; align-items: center; gap: 3px; color: var(--star); font-weight: 700; white-space: nowrap; }
.rating .icon { width: 13px; height: 13px; }
.rating.is-empty { color: var(--text-sub); font-weight: 400; }

.bm-btn {
	position: absolute; top: 6px; right: 6px; z-index: 2; display: grid; place-items: center;
	width: 30px; height: 30px; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; opacity: 0; transition: opacity .2s;
}
.bm-btn .icon { width: 16px; height: 16px; }
.card:hover .bm-btn, .bm-btn.is-on, .bm-btn:focus-visible { opacity: 1; }
.bm-btn.is-on { color: var(--accent); }
.bm-btn.is-on .icon path { fill: currentColor; }
@media (hover: none) { .bm-btn { opacity: 1; } }

/* ---------- category cards ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 960px) { .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .cat-grid { grid-template-columns: 1fr; } }
.cat-card {
	display: flex; flex-direction: column; gap: 8px; padding: 18px;
	background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
	transition: transform .2s, box-shadow .2s, border-color .2s;
}
.cat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.cat-card-name { margin: 0; font-size: 17px; font-weight: 800; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.cat-card-name span { font-size: 12px; font-weight: 400; color: var(--text-sub); }
.cat-card-desc { margin: 0; font-size: 13px; color: var(--text-sub); line-height: 1.6; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.chips.is-small { gap: 6px; }
.chip {
	display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px;
	background: var(--bg-elev); border: 1px solid var(--line); font-size: 13px; color: var(--text); transition: all .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip small { color: var(--text-sub); font-size: 11px; }
.chips.is-small .chip { padding: 2px 10px; font-size: 12px; }

/* ---------- archive / single / page ---------- */
.page-head { margin-bottom: 20px; }
.page-title { margin: 0 0 6px; font-size: 24px; font-weight: 800; }
.page-desc { margin: 0; color: var(--text-sub); font-size: 14px; }
.sort-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.pagination { margin-top: 32px; }
.pagination .nav-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.pagination .page-numbers { min-width: 38px; height: 38px; padding: 0 10px; display: grid; place-items: center; border-radius: 8px; background: var(--bg-elev); border: 1px solid var(--line); font-size: 14px; }
.pagination .page-numbers.current { background: var(--accent); border-color: var(--accent); color: #fff; }
.empty { padding: 48px 16px; text-align: center; color: var(--text-sub); border: 1px dashed var(--line); border-radius: var(--radius); }

.single-hero { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 28px; margin-bottom: 32px; }
@media (max-width: 720px) { .single-hero { grid-template-columns: 1fr; } .single-hero .card-thumb { max-width: 240px; } }
.single-hero .card-thumb { border-radius: var(--radius); }
.single-title { margin: 0 0 12px; font-size: 24px; line-height: 1.4; }
.single-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; color: var(--text-sub); font-size: 14px; margin-bottom: 14px; }
.single-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-elev); font-size: 14px; font-weight: 700; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.is-on .icon path { fill: currentColor; }
.entry-content { max-width: 780px; }
.entry-content h2 { font-size: 20px; margin: 2em 0 .8em; padding-left: 10px; border-left: 4px solid var(--accent); }
.entry-content h3 { font-size: 17px; margin: 1.6em 0 .6em; }
.entry-content a { color: var(--accent); text-decoration: underline; }
.entry-content img { border-radius: 8px; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-elev); padding: 40px 0 24px; font-size: 13px; }
.footer-cols { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px; }
@media (max-width: 960px) { .footer-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.footer-col h2 { margin: 0 0 10px; font-size: 13px; font-weight: 800; letter-spacing: .06em; color: var(--text); }
.footer-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.footer-col a { color: var(--text-sub); }
.footer-col a:hover { color: var(--accent); }
.footer-bottom { margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--text-sub); font-size: 12px; text-align: center; line-height: 1.8; }
.footer-bottom p { margin: 0; }

/* ---------- mobile tab bar ---------- */
.tabbar { display: none; }
@media (max-width: 720px) {
	.global-nav { display: none; }
	.header-inner { gap: 12px; }
	.section-title { font-size: 18px; }
	body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
	.tabbar {
		display: grid; grid-template-columns: repeat(4, 1fr);
		position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
		height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
		background: color-mix(in srgb, var(--bg-elev) 94%, transparent); backdrop-filter: blur(10px);
		border-top: 1px solid var(--line);
	}
	.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10.5px; color: var(--text-sub); }
	.tabbar a.is-current { color: var(--accent); }
	.tabbar .icon { width: 22px; height: 22px; }
}
@media (max-width: 480px) {
	.more-link { font-size: 12px; }
	.card-body { padding: 8px 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { transition: none !important; }
}
