/*
Theme Name: Keisan Desk
Description: 経理・総務向けの計算ツール群（kd_tool）とコラム（post）を運用する専用テーマ。Kaiaku テーマの設計言語（紙の配色・細い罫線・カード）を踏襲。
Version: 0.1.6
Author: yabea
Text Domain: keisan-desk
*/

:root {
  --paper: #fbfbf9;
  --paper-2: #f2f3ef;
  --ink: #1a1d21;
  --ink-2: #4b5157;
  --ink-3: #7d848b;
  --rule: #d9dcd6;
  --rule-2: #e8eae5;
  --accent: #1e4fa3;
  --accent-bg: #eaf0fa;
  --accent-2: #1f6f5c;
  --accent-2-bg: #e9f3ef;
  --warn: #b7791f;
  --warn-bg: #fbf3e4;
  --link: #1e4fa3;
  --font: "Zen Kaku Gothic New", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --wrap: 1040px;
  --gutter: 20px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 500;
  font-size: 15px;
  line-height: 1.75;
  font-feature-settings: "palt" 1, "tnum" 1;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
h1, h2, h3 { font-weight: 700; line-height: 1.35; margin: 0; letter-spacing: 0.01em; }
p { margin: 0; }
ol, ul { margin: 0; padding: 0; list-style: none; }
dl, dt, dd { margin: 0; }
small { font-size: 12px; }
b { font-weight: 700; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 6px 12px; z-index: 10; }
.skip:focus { left: 8px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- ヘッダー ---------- */
.site-head { border-bottom: 1px solid var(--rule); background: var(--paper); }
.site-head-in { display: flex; align-items: center; gap: 28px; min-height: 60px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
.site-name { color: var(--ink); font-weight: 700; font-size: 18px; letter-spacing: 0.02em; display: inline-flex; align-items: center; gap: 8px; }
.site-mark { display: inline-block; border: 2px solid var(--accent); color: var(--accent); border-radius: 4px; font-size: 11px; line-height: 1; padding: 3px 4px; letter-spacing: 0.05em; }
.site-name:hover { text-decoration: none; }
.site-nav { display: flex; gap: 20px; font-size: 14px; }
.site-nav a { color: var(--ink-2); }
.site-nav a:hover, .site-nav a[aria-current] { color: var(--ink); }
.site-nav a[aria-current] { box-shadow: inset 0 -2px 0 var(--ink); }
.site-tools { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.site-search input { width: 240px; max-width: 100%; padding: 7px 12px; border: 1px solid var(--rule); border-radius: 6px; background: #fff; font: inherit; font-size: 13px; color: var(--ink); }
.site-search input::placeholder { color: var(--ink-3); }

main.wrap { padding-top: 36px; padding-bottom: 72px; }

/* ---------- 見出し・セクション ---------- */
.sec-title { font-size: 16px; color: var(--ink); }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.sec-more { font-size: 13px; white-space: nowrap; }
section + section { margin-top: 56px; }
.page-head { margin-bottom: 24px; }
.page-title { font-size: 26px; }
.page-lead { color: var(--ink-2); margin-top: 6px; }
.crumb { font-size: 13px; color: var(--ink-3); margin-bottom: 10px; }
.crumb a { color: var(--ink-3); }
.crumb ol { display: flex; flex-wrap: wrap; gap: 4px; }
.crumb li + li::before { content: "/"; margin: 0 6px 0 2px; color: var(--rule); }
.empty { color: var(--ink-2); padding: 32px 0; }

/* ---------- トップ：導入 ---------- */
.intro { max-width: 720px; margin-bottom: 44px; }
.intro-title { font-size: 28px; line-height: 1.4; text-wrap: balance; }
.nb { display: inline-block; }
.intro-lead { margin-top: 14px; color: var(--ink-2); font-size: 15px; text-wrap: pretty; }
.intro-points { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.intro-points li { font-size: 13px; color: var(--ink-2); border: 1px solid var(--rule); border-radius: 999px; padding: 3px 12px; background: #fff; }

/* ---------- ツールカード ---------- */
.tool-cat-title { font-size: 13px; color: var(--ink-3); margin: 22px 0 8px; font-weight: 500; display: flex; align-items: baseline; gap: 10px; }
.tool-cat-title a { color: var(--ink-3); }
/* 1行3つまで。カードは行内で高さを揃える */
.tool-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: stretch; }
.tool-grid > li { display: flex; min-width: 0; }
.tool-card {
  flex: 1;
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 16px; border: 1px solid var(--rule); border-radius: 8px; background: #fff; color: var(--ink); min-width: 0;
}
/* 説明文は2行で切り、カードの高さを揃える */
.tool-card-desc {
  font-size: 12.5px; color: var(--ink-2); line-height: 1.55;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
/* 分類ラベルはカード下端に寄せる（検索結果などで表示する場合） */
.tool-card-cat { font-size: 11px; color: var(--ink-3); margin-top: auto; padding-top: 4px; }
.tool-card:hover { text-decoration: none; border-color: var(--ink-3); }
.tool-card:hover .tool-card-name { text-decoration: underline; text-underline-offset: 3px; }
.tool-card-name {
  font-weight: 700; font-size: 15px; line-height: 1.4;
  /* タイトルは2行分の高さを確保し、カードの高さをページ全体で揃える */
  min-height: 2.8em;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.tool-card-name::before { content: "▸"; color: var(--accent); margin-right: 6px; font-size: 12px; }
.tool-grid-compact .tool-card { padding: 11px 14px; }
.tool-grid-compact .tool-card-name { min-height: 0; }
.tool-grid-compact .tool-card-desc { display: none; }

/* ---------- ツールページ ---------- */
.tool-page { max-width: 760px; margin: 0 auto; }
.tool-head { margin-bottom: 18px; }
.tool-head .article-cats { margin-bottom: 8px; }
.tool-title { font-size: 26px; line-height: 1.4; }
.tool-lead { margin-top: 10px; color: var(--ink-2); font-size: 15px; }
.tool-meta { margin-top: 8px; font-size: 12px; color: var(--ink-3); }
.tool-related { margin-top: 48px; }
.tool-related .tool-grid { margin-top: 12px; }
.tool-columns { margin-top: 44px; }
.tool-columns .post-grid { margin-top: 14px; }

/* プラグイン（Biz Calc Tools）のUIをテーマに馴染ませる */
.bct-tool {
  --bct-accent: var(--accent);
  --bct-accent-bg: var(--accent-bg);
  --bct-border: var(--rule);
  --bct-text: var(--ink);
  --bct-muted: var(--ink-3);
  --bct-result-bg: var(--paper-2);
  font-family: inherit; font-size: 15px; margin: 22px 0; max-width: none; border-radius: 10px;
}
.prose .bct-tool { margin: 22px 0; }
.bct-articles { --bct-accent: var(--accent); --bct-border: var(--rule); --bct-muted: var(--ink-3); font-size: 15px; border-radius: 10px; }
.prose .bct-articles ul { padding-left: 0; list-style: none; }
.prose .bct-articles li + li { margin-top: 0; }
.prose .bct-tool ul, .prose .bct-tool ol { padding-left: 0; list-style: none; }
.prose .bct-tool li + li { margin-top: 0; }
.prose .bct-tool > * + * { margin-top: 0; }
.tool-page .bct-title { display: none; } /* ページのh1と重複するのでツール内タイトルは隠す */

/* ---------- 絞り込みチップ ---------- */
.filter-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; padding: 3px 10px; border: 1px solid var(--rule); border-radius: 999px; font-size: 13px; color: var(--ink-2); background: #fff; }
.chip small { color: var(--ink-3); margin-left: 2px; }
.chip:hover { text-decoration: none; border-color: var(--ink-3); color: var(--ink); }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.is-on small { color: rgba(255, 255, 255, 0.7); }

/* ---------- ページ送り・フッター ---------- */
.pagination { margin-top: 28px; font-size: 14px; }
.pagination .nav-links { display: flex; gap: 6px; flex-wrap: wrap; }
.pagination .page-numbers { padding: 4px 10px; border: 1px solid var(--rule); border-radius: 6px; color: var(--ink-2); background: #fff; }
.pagination .page-numbers.current { background: var(--ink); color: #fff; border-color: var(--ink); }
.pagination .page-numbers.dots { border: 0; background: none; }
.site-foot { border-top: 1px solid var(--rule); padding: 28px 0 40px; color: var(--ink-2); font-size: 13px; }
.site-foot p + p { margin-top: 8px; }
.foot-meta { color: var(--ink-3); margin-top: 16px !important; }
.foot-in { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 40px; }
.foot-name { font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.foot-nav { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.foot-nav a { color: var(--ink-2); }

/* ---------- 2カラム（コンテンツ＋サイドバー） ---------- */
.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 48px; align-items: start; }
.layout-narrow, .layout-wide { display: block; }
.layout-narrow .content { max-width: 760px; margin: 0 auto; }
.layout-wide .content { max-width: none; }
.content { min-width: 0; }
.side { position: sticky; top: 20px; }
.widget + .widget { margin-top: 28px; }
.widget-title { font-size: 14px; color: var(--ink); padding-bottom: 8px; border-bottom: 1px solid var(--rule); margin-bottom: 10px; }
.side-posts li, .side-tools li, .side-archive li { border-bottom: 1px solid var(--rule-2); }
.side-posts a, .side-tools a { display: flex; gap: 10px; padding: 9px 0; color: var(--ink); align-items: flex-start; }
.side-posts a:hover, .side-tools a:hover { text-decoration: none; }
.side-posts a:hover .side-title, .side-tools a:hover .side-title { text-decoration: underline; text-underline-offset: 3px; }
.side-thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; display: block; }
.side-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.side-title { font-size: 13px; font-weight: 700; line-height: 1.45; }
.side-body time, .side-cat { font-size: 11px; color: var(--ink-3); }
.side-tools a { padding: 8px 0; font-size: 13px; }
.side-tools .side-title::before { content: "▸"; color: var(--accent); margin-right: 5px; font-size: 11px; }
.side-archive li { display: flex; justify-content: space-between; padding: 7px 0; font-size: 13px; }
.side-archive li a { color: var(--ink); }
.side-archive span { color: var(--ink-3); }
.side-more { margin-top: 10px; font-size: 13px; }

/* ---------- コラム一覧 ---------- */
.blog-tools { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.blog-search input { width: 100%; max-width: 420px; padding: 9px 12px; border: 1px solid var(--rule); border-radius: 6px; background: #fff; font: inherit; font-size: 14px; }
.chip-cat small { font-weight: 500; }
.blog-result { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--ink-3); }
.blog-result .chip { font-size: 12px; }
.post-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 24px; margin-top: 8px; }
.post-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.post-grid[aria-busy="true"] { opacity: 0.5; pointer-events: none; }
.post-card-link { display: block; color: var(--ink); }
.post-card-link:hover { text-decoration: none; }
.post-card-link:hover .post-card-title { text-decoration: underline; text-underline-offset: 3px; }
.post-card-thumb { aspect-ratio: 16 / 9; overflow: hidden; border-radius: 8px; border: 1px solid var(--rule-2); background: var(--paper-2); }
.post-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-card-noimg { width: 100%; height: 100%; display: grid; place-items: center; }
.post-card-noimg span { border: 2px solid var(--rule); color: var(--ink-3); border-radius: 6px; padding: 6px 10px; font-weight: 700; letter-spacing: 0.1em; }
.post-card-body { padding: 10px 2px 0; }
.post-card-meta { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--ink-3); }
.post-card-cat { color: var(--ink-2); border: 1px solid var(--rule); border-radius: 999px; padding: 1px 8px; }
.post-card-title { font-size: 16px; line-height: 1.45; margin-top: 6px; }
.post-card-excerpt { margin-top: 6px; font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.search-sec + .search-sec { margin-top: 48px; }
.home-posts .post-grid { margin-top: 14px; }

/* ---------- 記事 ---------- */
.article-head { margin-top: 6px; }
.article-head-hero { position: relative; border-radius: 10px; overflow: hidden; background-size: cover; background-position: center; color: #fff; min-height: 300px; display: flex; align-items: flex-end; }
.article-head-hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0.05) 30%, rgba(0,0,0,0.65)); }
.article-head-hero .article-head-in { position: relative; padding: 28px; }
.article-head-hero .article-title, .article-head-hero .article-meta, .article-head-hero .article-cats a { color: #fff; }
.article-head-hero .article-cats a { border-color: rgba(255,255,255,0.6); }
.article-cats { display: flex; gap: 6px; flex-wrap: wrap; }
.article-cats a { font-size: 12px; color: var(--ink-2); border: 1px solid var(--rule); border-radius: 999px; padding: 1px 10px; }
.article-title { font-size: 28px; line-height: 1.4; margin-top: 10px; }
.article-meta { margin-top: 10px; font-size: 13px; color: var(--ink-3); display: flex; gap: 14px; }
.article-eyecatch { margin: 22px 0 0; }
.article-eyecatch img { width: 100%; height: auto; border-radius: 10px; display: block; }
.article-body { margin-top: 28px; }
.article-tags { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; }
.article-tags a { color: var(--ink-2); }
.share { display: flex; align-items: center; gap: 8px; margin-top: 20px; font-size: 13px; color: var(--ink-3); flex-wrap: wrap; }
.share a { padding: 5px 12px; border: 1px solid var(--rule); border-radius: 6px; color: var(--ink-2); background: #fff; }
.share a:hover { text-decoration: none; border-color: var(--ink-3); color: var(--ink); }
/* 運営者紹介欄（2026-09-30） */
.post-author { margin-top: 28px; padding: 16px 20px; border: 1px solid var(--rule); border-radius: 10px; background: var(--paper-2); font-size: 14px; line-height: 1.75; }
.post-author p { margin: 0; }
.post-author-label { font-size: 12px; font-weight: 700; color: var(--ink-3); letter-spacing: .04em; }
.post-author-name { font-weight: 700; font-size: 16px; margin: 2px 0 6px !important; }
.post-author-name span { font-weight: 500; font-size: 13px; color: var(--ink-3); }
.post-author-policy { color: var(--ink-2); }
.post-author-links { margin-top: 6px !important; font-size: 13px; }
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--rule); }
.post-nav a { color: var(--ink); font-weight: 700; font-size: 14px; line-height: 1.45; }
.post-nav a small { display: block; font-weight: 500; color: var(--ink-3); margin-bottom: 4px; }
.post-nav-next { text-align: right; }
.related { margin-top: 48px; }
.related .post-grid { margin-top: 14px; }

/* 記事内のツール導線 */
.tool-cta { margin-top: 40px; padding: 20px 22px; border: 1px solid var(--rule); border-radius: 10px; background: #fff; }
.tool-cta-title { font-size: 15px; font-weight: 700; }
.tool-cta .tool-grid { margin-top: 12px; }
.prose .tool-cta { margin: 2em 0; }
.prose .tool-cta ul { padding: 0; list-style: none; }
.prose .tool-cta li + li { margin-top: 0; }
.prose .tool-cta a { text-decoration: none; }
.prose .tool-cta a:hover .tool-card-name { text-decoration: underline; }

/* ---------- 記事本文の型（prose） ---------- */
.prose { font-size: 16px; line-height: 1.95; color: var(--ink); }
.prose > * + * { margin-top: 1.4em; }
.prose h2 { font-size: 22px; line-height: 1.45; margin-top: 2.4em; padding: 0 0 10px; border-bottom: 2px solid var(--ink); }
.prose h3 { font-size: 18px; margin-top: 2em; padding-left: 12px; border-left: 4px solid var(--accent); }
.prose h4 { font-size: 16px; margin-top: 1.6em; }
.prose ul, .prose ol { padding-left: 1.5em; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li + li { margin-top: 0.4em; }
.prose a { text-decoration: underline; text-underline-offset: 3px; }
.prose img { max-width: 100%; height: auto; border-radius: 8px; }
.prose figure { margin: 1.6em 0; }
.prose figcaption { font-size: 13px; color: var(--ink-3); text-align: center; margin-top: 6px; }
.prose blockquote { margin: 1.6em 0; padding: 14px 18px; border-left: 4px solid var(--rule); background: var(--paper-2); color: var(--ink-2); border-radius: 0 8px 8px 0; }
.prose blockquote p { margin: 0; }
.prose .b { font-weight: 700; }
.prose .b.blue { color: var(--accent-2); background: linear-gradient(transparent 60%, var(--accent-2-bg) 60%); }
.prose .b.orange { color: var(--warn); background: linear-gradient(transparent 60%, var(--warn-bg) 60%); }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.6; }
/* 表の枠線は外側のスクロール枠だけが持ち、セルは内側の罫線だけを引く。
   両方が枠線を描くと、角丸で切り取られて四隅が欠けて見えるため */
.prose th, .prose td {
  padding: 10px 12px; text-align: left; vertical-align: top;
  border: 0; border-bottom: 1px solid var(--rule); border-right: 1px solid var(--rule);
}
.prose tr > *:last-child { border-right: 0; }
.prose tbody tr:last-child > * { border-bottom: 0; }
.prose th { background: var(--paper-2); font-weight: 700; white-space: nowrap; }
.prose .wp-block-table { margin: 1.6em 0; }
.prose .wp-table-responsive {
  margin: 1.6em 0; overflow-x: auto; -webkit-overflow-scrolling: touch; position: relative;
  border: 1px solid var(--rule); border-radius: 8px;
}
.prose .wp-block-table .wp-table-responsive { margin: 0; }
.prose .wp-table-responsive table { margin: 0; min-width: 480px; }
.prose .wp-table-responsive.can-scroll:not(.at-end) { box-shadow: inset -24px 0 20px -20px rgba(0,0,0,0.25); }
.prose .wp-table-responsive.can-scroll:not(.at-start) { box-shadow: inset 24px 0 20px -20px rgba(0,0,0,0.25); }
.prose .wp-table-responsive.can-scroll:not(.at-start):not(.at-end) { box-shadow: inset 24px 0 20px -20px rgba(0,0,0,0.25), inset -24px 0 20px -20px rgba(0,0,0,0.25); }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.4em 0; }
.prose .note { font-size: 14px; color: var(--ink-2); padding: 12px 16px; background: var(--paper-2); border-radius: 8px; }
.prose code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.9em; background: var(--paper-2); padding: 1px 6px; border-radius: 4px; }
.prose .wp-block-buttons a { display: inline-block; padding: 10px 18px; background: var(--ink); color: #fff; border-radius: 6px; text-decoration: none; font-weight: 700; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 960px) {
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-side { grid-template-columns: 1fr; }
  .side { position: static; margin-top: 48px; padding-top: 32px; border-top: 1px solid var(--rule); }
  .post-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .tool-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body { font-size: 14px; }
  .site-head-in { gap: 12px 20px; }
  .site-nav { order: 3; width: 100%; gap: 16px; overflow-x: auto; white-space: nowrap; padding-bottom: 2px; }
  .site-tools { width: 100%; order: 4; }
  .site-search { width: 100%; }
  .site-search input { width: 100%; }
  .intro-title { font-size: 22px; }
  .page-title, .tool-title { font-size: 22px; }
  .post-grid, .post-grid-3 { grid-template-columns: 1fr; gap: 24px; }
  .article-title { font-size: 22px; }
  .prose { font-size: 15px; }
  .prose h2 { font-size: 19px; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav-next { text-align: left; }
  .foot-in { grid-template-columns: 1fr; gap: 20px; }
  .foot-nav { flex-direction: row; flex-wrap: wrap; gap: 8px 16px; }
}
@media (prefers-reduced-motion: no-preference) {
  .chip, .site-search input, .tool-card { transition: border-color 0.15s, color 0.15s; }
}

/* アフィリエイトの紹介枠 */
.kd-ad { position: relative; margin: 1.5em 0; padding: 14px 16px; border: 1px solid #d9dee8; border-left: 4px solid #1f3a6d; border-radius: 8px; background: #f7f9fc; font-size: .92rem; line-height: 1.7; }
.kd-ad p { margin: 0; }
.kd-ad__lead { color: #4a5568; margin-bottom: .3em !important; }
.kd-ad__link a { font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.kd-ad__pr { font-size: .75rem; color: #718096; margin-left: .4em; }
