/* =============================================================
   sidebar-article.css — 記事詳細ページ サイドバー専用スタイル
   ============================================================= */

/* ─────────────────────────────────────────
   サイドバー共通
───────────────────────────────────────── */
.sidebar {
	flex: 0 1 320px;
	min-width: 200px;
	display: flex;
	flex-direction: column;
	gap: 24px;
	align-self: stretch;
}

.sidebar-sticky-block {
	position: sticky;
	top: calc(var(--header-h) + 24px);
	display: flex;
	flex-direction: column;
	gap: 24px;
}

.sidebar-widget {
	background: #fff;
	border: 1px solid var(--border-color);
	border-radius: 8px;
	padding: 20px;
}
.sidebar-widget__title {
	font-size: 14px;
	font-weight: 700;
	color: var(--text-primary);
	margin: 0 0 16px;
	line-height: 1;
}

/* ─────────────────────────────────────────
   検索
───────────────────────────────────────── */
.sidebar-search {
	background: #fff;
	border: 1px solid var(--border-color);
	border-radius: 8px;
	padding: 16px;
}
.sidebar-search__row {
	display: flex;
	gap: 8px;
	align-items: center;
}
.sidebar-search__input-wrap {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: 10px;
	height: 44px;
	background: var(--bg-subtle);
	border-radius: 6px;
	padding: 0 12px;
	cursor: text;
	box-sizing: border-box;
}
.sidebar-search__icon {
	flex-shrink: 0;
}
.sidebar-search .sidebar-search__input {
	border: none;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
	box-shadow: none;
	padding: 0;
	font-size: 14px;
	color: #333;
	background: transparent;
	flex: 1;
	min-width: 0;
}
.sidebar-search .sidebar-search__input:focus {
	color: #333;
	border: none;
	outline: none;
	box-shadow: none;
}
.sidebar-search .sidebar-search__input::placeholder {
	color: var(--text-muted);
}
.sidebar-search__btn {
	height: 44px;
	padding: 0 16px;
	background: var(--accent);
	color: var(--btn-text, #fff);
	border: none;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
	white-space: nowrap;
	flex-shrink: 0;
	box-sizing: border-box;
	transition: opacity 0.2s;
}
.sidebar-search__btn:hover {
	opacity: 0.85;
}

/* ─────────────────────────────────────────
   広告エリア
───────────────────────────────────────── */
.sidebar-ad {
	position: relative;
	background: #d0d0d0;
	border-radius: 8px;
	height: 250px;
	overflow: hidden;
	display: flex;
	align-items: flex-start;
	justify-content: flex-start;
}
.sidebar-ad__badge {
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 1;
	background: var(--accent);
	border-radius: 999px;
	padding: 4px 8px;
	font-size: 11px;
	color: var(--btn-text, #fff);
}
.sidebar-ad__image-link {
	display: block;
	width: 100%;
	height: 100%;
}
.sidebar-ad__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* ─────────────────────────────────────────
   カテゴリー
───────────────────────────────────────── */
.sidebar-cat-list {
	list-style: none;
	padding: 0;
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.sidebar-cat-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.sidebar-cat-item__name {
	font-size: 13px;
	color: #333;
	text-decoration: none;
	transition: color 0.2s;
}
.sidebar-cat-item__name:hover {
	color: var(--accent);
}
.sidebar-cat-item__count {
	font-size: 13px;
	color: #666;
}

/* ─────────────────────────────────────────
   タグクラウド
───────────────────────────────────────── */
.sidebar-tag-cloud {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}
.sidebar-tag {
	display: inline-flex;
	align-items: center;
	padding: 6px 10px;
	background: var(--bg-subtle);
	border-radius: 999px;
	font-size: 12px;
	color: var(--text-primary);
	text-decoration: none;
	transition: background 0.2s;
	line-height: 1;
}
.sidebar-tag:hover {
	background: var(--border-color);
}

/* ─────────────────────────────────────────
   人気記事
───────────────────────────────────────── */
.sidebar-popular-list {
	list-style: none;
	padding: 0;
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 16px;
}
.sidebar-popular-item {
	display: flex;
	align-items: flex-start;
	gap: 12px;
}
.sidebar-popular-item__thumb {
	display: block;
	position: relative;
	width: 60px;
	height: 60px;
	flex-shrink: 0;
	border-radius: 8px;
	overflow: hidden;
	background: #d0d0d0;
}
.sidebar-popular-item__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.sidebar-popular-item__thumb-placeholder {
	width: 100%;
	height: 100%;
	background: #d0d0d0;
}
.sidebar-popular-item__rank {
	position: absolute;
	top: 0;
	left: 0;
	width: 22px;
	height: 22px;
	background: var(--accent);
	border-radius: 3px;
	font-size: 11px;
	font-weight: 700;
	color: var(--btn-text, #fff);
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}
.sidebar-popular-item__text {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}
.sidebar-popular-item__title {
	font-size: 13px;
	color: #333;
	text-decoration: none;
	line-height: 1.5;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	transition: color 0.2s;
	min-width: 0;
	max-width: 100%;
	word-break: break-word;
}
.sidebar-popular-item__title:hover {
	color: var(--accent);
}
.sidebar-popular-item__date {
	font-size: 12px;
	color: #666;
}

/* ─────────────────────────────────────────
   追従目次
───────────────────────────────────────── */
.sidebar-toc {
	background: #fff;
	border: 1px solid var(--border-color);
	border-radius: 8px;
	padding: 20px;
	box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}
.sidebar-toc__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 16px;
}
.sidebar-toc__header .sidebar-widget__title {
	margin: 0;
}
.sidebar-toc__badge {
	background: var(--bg-subtle);
	border: 1px solid var(--border-color);
	border-radius: 999px;
	padding: 4px 8px;
	font-size: 11px;
	color: #666;
	line-height: 1;
}
.sidebar-toc-list {
	list-style: none;
	padding: 0;
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.sidebar-toc-item {
	display: flex;
	align-items: baseline;
	gap: 8px;
}
.sidebar-toc-item--depth-1 {
	margin-left: 32px;
}
.sidebar-toc-item--depth-2 {
	margin-left: 48px;
}
.sidebar-toc-item--depth-3 {
	margin-left: 64px;
}
.sidebar-toc-item--depth-4 {
	margin-left: 80px;
}
.sidebar-toc-item__num {
	font-size: 13px;
	color: var(--text-muted);
	flex-shrink: 0;
	transition: color 0.2s;
}
.sidebar-toc-item__text {
	font-size: 13px;
	color: #888;
	text-decoration: none;
	line-height: 1.5;
	transition: color 0.2s;
}
.sidebar-toc-item__text:hover {
	color: var(--accent);
}
.sidebar-toc-item.is-active .sidebar-toc-item__num {
	color: var(--accent);
}
.sidebar-toc-item.is-active .sidebar-toc-item__text {
	color: #333;
	font-weight: 600;
}

/* ─────────────────────────────────────────
   SP 対応
───────────────────────────────────────── */
@media (max-width: 768px) {

	/* 追従バナーは SP で非表示 */
	.sidebar-ad {
		display: none;
	}

	/* ウィジェットは常に縦並び（.sidebar のベースの flex-direction: column をそのまま使用）。
	   flexはgapに加えbasisも明示的に上書きする: 親(.article-layout__inner等)がSPで
	   flex-direction:columnに切り替わるため、PC用のflex:0 1 320pxをそのまま引き継ぐと
	   320pxが「幅」ではなく「高さの目安」として効いてしまい、ウィジェットの合計高さが
	   320px未満のとき（例: ウィジェットをSP非表示にした場合）に余白が生まれる。 */
	.sidebar {
		flex: 0 0 auto;
		width: 100%;
		gap: 16px;
	}

	/* タグクラウドは横スクロール */
	.sidebar-tag-cloud {
		flex-wrap: wrap;
		gap: 6px;
	}

	/* SPでは追従させない（通常表示） */
	.sidebar-sticky-block {
		position: static;
	}
}

/* ─────────────────────────────────────────
   標準ウィジェット用の汎用ラッパー
   （カレンダー・タグクラウド・最近の投稿等、テーマ独自ウィジェット以外の
   安全網。.sidebar-widget のカード枠は既存スタイルをそのまま流用）
───────────────────────────────────────── */
.sidebar-widget--generic ul {
	list-style: none;
	margin: 0;
	padding: 0;
}
.sidebar-widget--generic li {
	padding: 8px 0;
	border-bottom: 1px solid var(--border-color);
	font-size: 13px;
}
.sidebar-widget--generic li:last-child {
	border-bottom: none;
	padding-bottom: 0;
}
.sidebar-widget--generic li:first-child {
	padding-top: 0;
}
.sidebar-widget--generic p {
	margin: 0;
	font-size: 13px;
	color: var(--text-primary);
}
.sidebar-widget--generic .sidebar-widget__title {
	margin: 0 0 16px;
}
.sidebar-widget--generic a {
	color: var(--text-primary);
	text-decoration: none;
}
.sidebar-widget--generic a:hover {
	color: var(--accent);
}
.sidebar-widget--generic select {
	width: 100%;
}

/* カレンダーウィジェット */
.sidebar-widget--generic .wp-calendar-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 12px;
	text-align: center;
}
.sidebar-widget--generic .wp-calendar-table caption {
	text-align: left;
	font-size: 12px;
	color: var(--text-muted);
	margin-bottom: 8px;
}
.sidebar-widget--generic .wp-calendar-table th,
.sidebar-widget--generic .wp-calendar-table td {
	padding: 6px 2px;
}
.sidebar-widget--generic .wp-calendar-table th {
	color: var(--text-muted);
	font-weight: 500;
}
.sidebar-widget--generic .wp-calendar-table #today {
	background: var(--accent);
	color: #fff;
	border-radius: 4px;
}
.sidebar-widget--generic .wp-calendar-nav {
	display: flex;
	justify-content: space-between;
	font-size: 12px;
	margin-top: 8px;
}

/* タグクラウドウィジェット（テーマ独自の .sidebar-tag と同じトーン） */
.sidebar-widget--generic .tagcloud {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}
.sidebar-widget--generic .tagcloud a {
	display: inline-flex;
	align-items: center;
	padding: 6px 10px;
	background: var(--bg-subtle);
	border-radius: 999px;
	color: var(--text-primary);
	text-decoration: none;
	transition: background 0.2s;
	line-height: 1;
	font-size: 12px !important;
}
.sidebar-widget--generic .tagcloud a:hover {
	background: var(--border-color);
	color: var(--text-primary);
}

/* ギャラリーウィジェット（メディア: ギャラリー） */
.sidebar-widget--generic .gallery {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 8px;
	margin: 0;
}
.sidebar-widget--generic .gallery-item {
	margin: 0;
}
.sidebar-widget--generic .gallery-item img {
	display: block;
	width: 100%;
	height: 100px;
	object-fit: cover;
	border-radius: 6px;
}
.sidebar-widget--generic .gallery-caption {
	font-size: 11px;
	color: var(--text-muted);
	margin: 4px 0 0;
}

/* テキストウィジェット */
.sidebar-widget--generic .textwidget {
	display: flex;
	flex-direction: column;
	gap: 12px;
	font-size: 13px;
	line-height: 1.7;
}
.sidebar-widget--generic .textwidget img {
	display: block;
	max-width: 100%;
	height: auto;
	border-radius: 6px;
}
.sidebar-widget--generic .textwidget ul,
.sidebar-widget--generic .textwidget ol {
	list-style: revert;
	margin: 0;
	padding-left: 20px;
	display: flex;
	flex-direction: column;
	gap: 4px;
}
.sidebar-widget--generic .textwidget li {
	padding: 0;
	border-bottom: none;
	font-size: 13px;
	line-height: 1.7;
}

/* ナビゲーションメニューウィジェット */
.sidebar-widget--generic .menu-item {
	padding: 0;
	border-bottom: 1px solid var(--border-color);
}
.sidebar-widget--generic .menu-item:last-child {
	border-bottom: none;
}
.sidebar-widget--generic .menu-item > a {
	display: block;
	padding: 8px 0;
}
.sidebar-widget--generic .current-menu-item > a {
	color: var(--accent);
	font-weight: 700;
}
.sidebar-widget--generic .sub-menu {
	margin: 0 0 4px;
	padding-left: 14px;
}
.sidebar-widget--generic .sub-menu .menu-item {
	border-bottom: none;
}
.sidebar-widget--generic .sub-menu .menu-item > a {
	padding: 4px 0;
	font-size: 12px;
	color: #666;
}
