/*
Theme Name: KABU Record Terminal
Description: 株・投資信託の資産記録ブログ用のダーク×トレード画面風テーマ（左カラム・日本式カラー）。週報記事に貼ったデータから、総資産・前週比・配当の累計を自動で集計して表示します。
Version: 1.0.0
Author: KABU_RECORD
Requires at least: 6.0
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: kabu-record-terminal
*/

/* ===== 色とフォント（ここを変えると全体の色が変わります） ===== */
:root {
	--bg: #0E1320;
	--bg-2: #121829;
	--panel: #1A2133;
	--panel-2: #141B2C;
	--line: #2A3348;
	--line-2: #3A4560;
	--grid: #1A2236;
	--text: #E6EAF2;
	--text-2: #C4CBDA;
	--text-body: #D5DBE7;
	--muted: #8B95AB;
	--accent: #5AA9FF;
	--accent-line: #2D4E78;
	--up: #FF5C7A;      /* 上昇（日本式：赤） */
	--down: #3DDC97;    /* 下落（日本式：緑） */
	--gold: #E8B04B;    /* 配当 */
	--purple: #B79CFF;  /* 米国株 */
	--mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
	--sans: 'Noto Sans JP', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
}

/* ===== 基本 ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background-color: var(--bg);
	background-image:
		linear-gradient(var(--grid) 1px, transparent 1px),
		linear-gradient(90deg, var(--grid) 1px, transparent 1px);
	background-size: 32px 32px;
	color: var(--text);
	font-family: var(--sans);
	line-height: 1.7;
}
a { color: var(--text); text-decoration: none; }
a:hover { color: var(--accent); }
img { max-width: 100%; height: auto; }
.screen-reader-text {
	position: absolute !important; width: 1px; height: 1px; overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px); white-space: nowrap;
}
.skip-link:focus {
	position: fixed; top: 8px; left: 8px; z-index: 1000; width: auto; height: auto; clip: auto;
	background: var(--accent); color: var(--bg); padding: 8px 12px; border-radius: 4px;
}
.wrap { max-width: 1200px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }
.num { font-family: var(--mono); }
.is-up, .up { color: var(--up); }
.is-down, .down { color: var(--down); }
.is-flat { color: var(--muted); }
.gold { color: var(--gold); }

/* ===== ヘッダー ===== */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); }
.site-header .wrap {
	padding-top: 20px; padding-bottom: 20px;
	display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
}
.site-brand { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.site-logo { font-family: var(--mono); font-size: 26px; font-weight: 700; letter-spacing: 1px; color: var(--text); line-height: 1.3; }
.site-logo .cursor { color: var(--gold); }
.site-desc { font-size: 12px; color: var(--muted); }
.global-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.global-nav a {
	display: block; padding: 10px 14px; border: 1px solid var(--line); border-radius: 4px;
	font-family: var(--mono); font-size: 13px; color: var(--text-2); line-height: 1.4;
}
.global-nav a:hover, .global-nav .is-current > a, .global-nav .current-menu-item > a, .global-nav .current-cat > a {
	border-color: var(--accent); color: var(--accent);
}

/* ===== ティッカー ===== */
.ticker { border-bottom: 1px solid var(--line); background: var(--bg-2); }
.ticker .wrap {
	padding-top: 12px; padding-bottom: 12px;
	display: flex; flex-wrap: wrap; gap: 6px 28px;
	font-family: var(--mono); font-size: 13px; color: var(--muted);
}
.ticker .val { color: var(--text); }

/* ===== 2カラム（PCは左サイドバー、スマホは本文が先） ===== */
.layout { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-start; padding-top: 36px; padding-bottom: 64px; }
.main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 32px; }
.sidebar { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
@media (min-width: 900px) { .sidebar { order: -1; } }

/* ===== 資産サマリー ===== */
.summary { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 28px 32px; }
.summary-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 20px; }
.label { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 2px; }
.big-total { font-family: var(--mono); font-size: 48px; font-weight: 700; line-height: 1; margin-top: 6px; white-space: nowrap; }
.big-total .yen { font-size: 18px; margin-left: 4px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; font-family: var(--mono); }
.stats .v { font-size: 20px; font-weight: 700; white-space: nowrap; }
.stats .s { font-size: 12px; }
.stat-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 24px; font-family: var(--mono); }
.stat-cards > div { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; min-width: 0; }
.stat-cards .v { font-size: 22px; font-weight: 700; white-space: nowrap; }
.stat-cards .s { font-size: 12px; }
.alloc { margin-top: 24px; }
.alloc-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; }
.alloc-bar span { display: block; min-width: 4px; }
.alloc-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 10px; font-size: 12px; color: var(--text-2); }
.alloc-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.c-fund { background: var(--accent); }
.c-jp { background: var(--gold); }
.c-us { background: var(--purple); }

/* ===== 一覧 ===== */
.list-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.list-title { margin: 0; font-family: var(--mono); font-size: 14px; font-weight: 500; letter-spacing: 3px; color: var(--accent); }
.list-note { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.post-list { display: flex; flex-direction: column; gap: 12px; }
.post-card {
	display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px;
	background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 20px 24px;
	transition: border-color .15s;
}
.post-card:hover { border-color: var(--line-2); }
.post-card:hover .post-card-title { color: var(--accent); }
.post-card-body { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.tag { color: var(--accent); border: 1px solid var(--accent-line); padding: 2px 8px; border-radius: 3px; line-height: 1.5; }
.pr { color: var(--text-2); background: var(--line); padding: 2px 8px; border-radius: 3px; line-height: 1.5; font-family: var(--sans); }
.post-card-title { font-size: 17px; font-weight: 500; color: var(--text); line-height: 1.5; word-break: break-word; }
.post-card-sub { font-size: 13px; color: var(--muted); }
.post-card-sub .num { color: var(--text-2); }
.post-card-sub .gold { color: var(--gold); }
.post-card-pl { text-align: right; margin-left: auto; }
.post-card-pl .v { font-family: var(--mono); font-size: 28px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.post-card-pl .v .yen { font-size: 14px; margin-left: 2px; }
.empty { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 32px 24px; color: var(--text-2); }
.empty a { color: var(--accent); }

.pagination .nav-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; font-family: var(--mono); font-size: 14px; }
.pagination .page-numbers {
	min-width: 44px; height: 44px; padding: 0 12px; display: flex; align-items: center; justify-content: center;
	border: 1px solid var(--line); border-radius: 4px; color: var(--text-2);
}
.pagination .page-numbers.current { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 700; }
.pagination .page-numbers.dots { border-color: transparent; }

/* ===== 記事ページ ===== */
.breadcrumb { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-bottom: -12px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb .here { color: var(--text-2); }
.entry { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.entry-header { padding: 32px 36px 28px; border-bottom: 1px solid var(--line); }
.entry-header .meta { margin-bottom: 14px; }
.entry-title { margin: 0; font-size: 26px; font-weight: 700; line-height: 1.5; word-break: break-word; }
.entry-hero { padding: 28px 36px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.entry-hero .big-total { font-size: 52px; }
.entry-hero .big-total .yen { font-size: 20px; }

/* 本文 */
.entry-content { padding: 32px 36px 40px; font-size: 15px; line-height: 1.8; color: var(--text-body); word-break: break-word; }
.entry-content > *:first-child { margin-top: 0; }
.entry-content p { margin: 0 0 1.4em; }
.entry-content h2, .entry-content h3, .entry-content h4 { color: var(--text); font-weight: 700; line-height: 1.5; margin: 2em 0 .9em; }
.entry-content h2 { font-size: 18px; }
.entry-content h2::before { content: '# '; font-family: var(--mono); color: var(--accent); }
.entry-content h3 { font-size: 16px; }
.entry-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.entry-content a:hover { color: var(--text); }
.entry-content a:has(img) { text-decoration: none; }
.entry-content ul, .entry-content ol { margin: 0 0 1.4em; padding-left: 1.4em; }
.entry-content ul li::marker { color: var(--accent); }
.entry-content strong { color: var(--text); }
.entry-content img { border-radius: 4px; }
.entry-content figure { margin: 0 0 1.4em; }
.entry-content blockquote { margin: 0 0 1.4em; padding: 12px 20px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); color: var(--text-2); }
.entry-content hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.entry-content .aligncenter { display: block; margin-left: auto; margin-right: auto; }
.entry-content::after { content: ''; display: block; clear: both; }

/* 週報データ（記事に貼るHTML） */
.kabu-data { display: none !important; }
.kabu-comment { border: 1px solid var(--line); border-radius: 6px; padding: 18px 20px; background: var(--panel-2); margin-bottom: 8px; }
.kabu-comment::before { content: '// COMMENT'; display: block; font-family: var(--mono); font-size: 12px; letter-spacing: 3px; color: var(--accent); margin-bottom: 8px; }
.kabu-comment p:last-child { margin-bottom: 0; }
.kabu-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; margin: 0 0 1.4em; }
.kabu-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 13px; line-height: 1.6; }
.kabu-table th {
	background: var(--panel-2); color: var(--muted); font-family: var(--mono); font-size: 11px; letter-spacing: 1px;
	font-weight: 500; text-align: left; padding: 10px 14px;
}
.kabu-table td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
.kabu-table .r { text-align: right; }
.kabu-table .num { font-family: var(--mono); white-space: nowrap; }
.kabu-table .sub { color: var(--muted); }
.kabu-table .nowrap { white-space: nowrap; }
.kabu-table .code { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.kabu-table small { font-size: 11px; }
.kabu-table tr.total td { border-top-color: var(--line-2); background: var(--panel-2); font-weight: 700; }
.kabu-note { font-size: 12px; color: var(--muted); }

/* 前後の記事 */
.post-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.post-nav a {
	background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 16px 18px;
	display: flex; flex-direction: column; gap: 6px; height: 100%;
}
.post-nav a:hover { border-color: var(--line-2); }
.post-nav .next a { text-align: right; align-items: flex-end; }
.post-nav .dir { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 2px; }
.post-nav .t { font-size: 14px; line-height: 1.5; }
.post-nav .p { font-family: var(--mono); font-size: 16px; font-weight: 700; }

/* ===== サイドバー ===== */
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 20px; }
.box-title { margin: 0 0 14px; font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: 3px; color: var(--accent); }
.box-title.gold { color: var(--gold); }
.side-label { font-size: 12px; color: var(--muted); }
.side-big { font-family: var(--mono); font-size: 28px; font-weight: 700; line-height: 1.3; white-space: nowrap; }
.side-big .yen { font-size: 13px; }
.side-rows { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.side-rows > div { display: flex; justify-content: space-between; gap: 12px; }
.side-rows .n { color: var(--text-2); min-width: 0; }
.side-rows .num { white-space: nowrap; }
.side-note { margin: 14px 0 0; font-size: 11px; color: var(--muted); line-height: 1.6; }
.holdings { display: flex; flex-direction: column; font-size: 13px; }
.holdings > div { padding: 10px 0; display: flex; flex-direction: column; gap: 2px; }
.holdings > div + div { border-top: 1px solid var(--line); }
.holdings .n { color: var(--text-2); line-height: 1.5; }
.holdings .row { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 12px; }
.year-list { display: flex; flex-wrap: wrap; gap: 8px; font-family: var(--mono); font-size: 14px; }
.year-list a { padding: 10px 16px; border: 1px solid var(--line); border-radius: 4px; }
.widget { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 20px; overflow: hidden; font-size: 14px; color: var(--text-2); }
.widget.widget_custom_html, .widget.widget_media_image { background: transparent; border: 0; padding: 0; text-align: center; }
.widget h2, .widget h3, .widget .wp-block-heading { margin: 0 0 14px; font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: 3px; color: var(--accent); }
.widget ul, .widget ol { margin: 0; padding-left: 1.2em; }
.widget li { margin: 6px 0; }
.widget li::marker { color: var(--accent); }
.widget a { color: var(--text-2); }
.widget a:hover { color: var(--accent); }
.wp-block-search__label { display: block; margin-bottom: 8px; font-family: var(--mono); font-size: 12px; letter-spacing: 3px; color: var(--accent); }
.wp-block-search__inside-wrapper, .search-form { display: flex; gap: 8px; }
.wp-block-search__input, .search-field {
	flex: 1; min-width: 0; height: 44px; padding: 0 12px; font-size: 16px;
	background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 4px;
}
.wp-block-search__button, .search-submit {
	height: 44px; padding: 0 16px; border: 0; border-radius: 4px; cursor: pointer;
	background: var(--accent); color: var(--bg); font-family: var(--mono); font-size: 13px; font-weight: 700;
}
.list-bottom { display: flex; flex-direction: column; gap: 16px; }

/* ===== 配当記録ページ ===== */
.div-chart { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; align-items: end; height: 180px; margin: 8px 0 6px; }
.div-chart .col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 4px; min-width: 0; }
.div-chart .bar { width: 100%; max-width: 36px; background: var(--gold); border-radius: 3px 3px 0 0; min-height: 2px; }
.div-chart .bar.zero { background: var(--line); }
.div-chart .amt { font-family: var(--mono); font-size: 10px; color: var(--text-2); white-space: nowrap; }
.div-months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: center; margin-bottom: 1.6em; }

/* ===== フッター ===== */
.site-footer { border-top: 1px solid var(--line); background: var(--bg); }
.site-footer .wrap {
	padding-top: 28px; padding-bottom: 28px;
	display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
	font-family: var(--mono); font-size: 12px; color: var(--muted);
}

/* ===== スマホ ===== */
@media (max-width: 640px) {
	.wrap { padding-left: 16px; padding-right: 16px; }
	.site-logo { font-size: 22px; }
	.layout { padding-top: 24px; }
	.summary { padding: 22px 20px; }
	.big-total, .entry-hero .big-total { font-size: 36px; }
	.stats, .stat-cards { grid-template-columns: minmax(0, 1fr); gap: 10px; }
	.post-card { padding: 16px 18px; }
	.post-card-pl { text-align: left; margin-left: 0; }
	.post-card-pl .v { font-size: 24px; }
	.entry-header, .entry-hero, .entry-content { padding-left: 20px; padding-right: 20px; }
	.entry-title { font-size: 21px; }
	.post-nav { grid-template-columns: minmax(0, 1fr); }
	.post-nav .next a { text-align: left; align-items: flex-start; }
	.div-chart .amt { display: none; }
}
