/* ================================================================
   base.css — keisan.net 共通スタイル
   ヘッダー・フッター・パンくず・CSS変数・レスポンシブを定義
   ================================================================ */

/* ─── RESET & BASE ─────────────────────────────────────────────── */
*, ::before, ::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ─── CSS VARIABLES ────────────────────────────────────────────── */
:root {
  /* サイト共通カラー */
  --bg:           #f5f3ee;
  --surface:      #ffffff;
  --border:       #d8d3c8;
  --border-light: #e8e4dd;
  --text:         #1a1a1a;
  --text-mid:     #4a4540;
  --text-muted:   #6b6560;

  /* タイポグラフィ */
  --font: 'Noto Sans JP', sans-serif;

  /* 角丸 */
  --radius:    8px;
  --radius-lg: 12px;

  /* シャドウ */
  --shadow:    0 2px 12px rgba(0,0,0,0.07);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);

  /* カテゴリアクセントカラー（各ページで --accent を上書き） */
  --keiri:      #2c5f3d;
  --keiri-bg:   #eef4f0;
  --keiri-mid:  #3d7a52;

  --zeimu:      #1e3a5f;
  --zeimu-bg:   #eef2f8;
  --zeimu-mid:  #2d5282;

  --roumu:      #5c3d85;
  --roumu-bg:   #f2edf8;
  --roumu-mid:  #7a52aa;

  --soumu:      #7a3e1e;
  --soumu-bg:   #f8f0eb;
  --soumu-mid:  #a05530;

  /* デフォルトのアクセント（各ページで上書き） */
  --accent:     var(--keiri);
  --accent-bg:  var(--keiri-bg);
  --accent-mid: var(--keiri-mid);
}

/* ─── HTML / BODY ──────────────────────────────────────────────── */
html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ─── HEADER ───────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 40px;
  height: 56px;
  font-family: var(--font);
}

/* ─── LOGO ─────────────────────────────────────────────────────── */
.site-logo {
  display: flex;
  align-items: baseline;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  text-decoration: none;
  color: inherit;
}
.site-logo-k    { font-size: 22px; color: var(--keiri); font-weight: 700; }
.site-logo-rest { color: var(--text); }
.site-logo-tld  { color: var(--text-muted); font-size: 15px; font-weight: 500; }

/* ─── HEADER SEARCH（トップページ用） ─────────────────────────── */
.site-header-search {
  flex: 1;
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 12px;
  height: 34px;
  color: var(--text-muted);
}
.site-header-search input {
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  outline: none;
  width: 100%;
}
.site-header-search input::placeholder { color: var(--text-muted); }

/* ─── HEADER NAV ────────────────────────────────────────────────── */
.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.site-nav a {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-mid);
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.site-nav a:hover  { background: var(--bg); color: var(--text); }
.site-nav a.active { color: var(--accent); font-weight: 700; }

/* ─── HAMBURGER ────────────────────────────────────────────────── */
.site-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  margin-left: auto;
}
.site-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.25s;
}

/* ─── MOBILE DRAWER ────────────────────────────────────────────── */
.site-drawer {
  display: none;
  position: fixed;
  top: 56px; left: 0; right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  z-index: 99;
  box-shadow: var(--shadow);
}
.site-drawer.open { display: block; }

.site-drawer-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
  color: var(--text-muted);
}
.site-drawer-search input {
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  outline: none;
  width: 100%;
}

.site-drawer-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.site-drawer-links a {
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-mid);
  border-radius: var(--radius);
  text-decoration: none;
}
.site-drawer-links a:hover { background: var(--bg); }

/* ─── BREADCRUMB ───────────────────────────────────────────────── */
.site-breadcrumb {
  font-family: var(--font);
  font-size: 12px;
  color: var(--text-muted);
  padding: 12px 40px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.site-breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}
.site-breadcrumb a:hover { color: var(--text); }
.bc-sep { color: var(--border); }

/* ─── PAGE HEADER（各ツールページ / カテゴリページ用） ─────────── */
.page-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}
.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  line-height: 1.3;
}
.page-header h1::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 22px;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}
.page-header p {
  font-size: 13px;
  color: var(--text-muted);
  padding-left: 14px; /* アクセントバー幅 + gap の分インデント */
}

/* ─── CARD（入力・結果エリア） ─────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* ─── TOOL CARDS GRID（カテゴリ一覧用） ────────────────────────── */
.cat-section {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.tool-card {
  display: block;
  padding: 18px 20px;
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
  position: relative;
}
.tool-card:nth-child(4n)        { border-right: none; }
.tool-card:nth-last-child(-n+4) { border-bottom: none; }

.cards-grid-5 .tool-card:nth-last-child(-n+4) { border-bottom: 1px solid var(--border-light); }
.cards-grid-5 .tool-card:nth-last-child(-n+1) { border-bottom: none; }

.cards-grid-6 .tool-card:nth-last-child(-n+4) { border-bottom: 1px solid var(--border-light); }
.cards-grid-6 .tool-card:nth-last-child(-n+2) { border-bottom: none; }

.cards-grid-7 .tool-card:nth-last-child(-n+4) { border-bottom: 1px solid var(--border-light); }
.cards-grid-7 .tool-card:nth-last-child(-n+3) { border-bottom: none; }

.cards-grid-9 .tool-card:nth-last-child(-n+4) { border-bottom: 1px solid var(--border-light); }
.cards-grid-9 .tool-card:nth-last-child(-n+1) { border-bottom: none; }

.tool-card:hover { background: var(--bg); }

.card-emoji  { font-size: 22px; margin-bottom: 10px; line-height: 1; }
.card-name   { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 4px; line-height: 1.4; }
.card-desc   { font-size: 11px; color: var(--text-muted); line-height: 1.5; }
.card-arrow  {
  position: absolute;
  top: 14px; right: 16px;
  font-size: 12px;
  color: var(--border);
  transition: color 0.15s;
}
.tool-card:hover .card-arrow { color: var(--text-muted); }

.badge-dummy {
  display: inline-block;
  font-size: 9px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  margin-top: 4px;
  letter-spacing: 0.03em;
}

/* ─── FOOTER ───────────────────────────────────────────────────── */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  padding: 28px 40px;
  margin-top: 32px;
  font-family: var(--font);
}
.site-footer-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-footer-logo {
  font-size: 15px;
  font-weight: 700;
}
.site-footer-logo .site-logo-k   { color: var(--keiri); font-size: 17px; }
.site-footer-logo .site-logo-tld { color: var(--text-muted); font-size: 13px; }
.site-footer-copy {
  font-size: 11px;
  color: var(--text-muted);
}

/* ─── NOTES BOX ────────────────────────────────────────────────── */
.notes {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.8;
}
.notes-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-mid);
  margin-bottom: 8px;
}
.notes ul { list-style: none; }
.notes li { padding-left: 1.2em; text-indent: -1.2em; margin-bottom: 3px; }
.notes li::before { content: '・'; }

/* ─── ERROR BOX ────────────────────────────────────────────────── */
.error-box {
  display: none;
  background: #fff5f5;
  border: 1px solid #f0c0c0;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: #a03030;
  margin-top: 12px;
}
.error-box.visible { display: block; }

/* ─── BUTTONS ──────────────────────────────────────────────────── */
.btn-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 20px;
}
.btn-primary {
  padding: 10px 32px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s;
  letter-spacing: 0.05em;
}
.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
  padding: 10px 16px;
  background: var(--bg);
  color: var(--text-mid);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--border-light); }

/* ─── UTILITY ──────────────────────────────────────────────────── */
.hidden { display: none; }

.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }

/* ─── SITE TOOL WRAP ───────────────────────────────────────────── */
.site-tool-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px 64px;
}

/* ─── RESPONSIVE ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  .site-header          { padding: 0 16px; }
  .site-header-search   { display: none; }
  .site-nav             { display: none; }
  .site-hamburger       { display: flex; }

  .site-breadcrumb      { padding: 10px 16px 0; }

  .cards-grid           { grid-template-columns: repeat(2, 1fr); }
  /* 2列レイアウトのボーダーリセット */
  .tool-card:nth-child(4n)        { border-right: 1px solid var(--border-light); }
  .tool-card:nth-child(2n)        { border-right: none; }
  .tool-card:nth-last-child(-n+4) { border-bottom: 1px solid var(--border-light); }
  .tool-card:nth-last-child(-n+2) { border-bottom: none; }

  .cards-grid-5 .tool-card:nth-last-child(-n+2) { border-bottom: 1px solid var(--border-light); }
  .cards-grid-5 .tool-card:nth-last-child(-n+1) { border-bottom: none; }

  .cards-grid-7 .tool-card:nth-last-child(-n+2) { border-bottom: 1px solid var(--border-light); }
  .cards-grid-7 .tool-card:nth-last-child(-n+1) { border-bottom: none; }

  .cards-grid-9 .tool-card:nth-last-child(-n+2) { border-bottom: 1px solid var(--border-light); }
  .cards-grid-9 .tool-card:nth-last-child(-n+1) { border-bottom: none; }

  main { padding: 16px 16px 48px; }
  .card { padding: 20px 16px; }

  .site-footer          { padding: 20px 16px; }
  .site-footer-inner    { flex-direction: column; gap: 8px; align-items: flex-start; }
}
