/* =========================================================
   テーマは <html data-theme="simple|dark|rich"> で切り替え。
   各テーマは「変数(トークン)」と「少しの個別スタイル」だけで構成。
   ========================================================= */

/* ---------- シンプル: 白地・余白・細い罫線 ---------- */
:root,
[data-theme='simple'] {
  --bg: #fafaf7;
  --surface: #ffffff;
  --surface-2: #f2f2ee;
  --text: #1c1c1a;
  --muted: #6b6b66;
  --border: #e4e4de;
  --accent: #2b59c3;
  --accent-2: #2b59c3;
  --accent-text: #ffffff;
  --radius: 8px;
  --shadow: none;
  --shadow-hover: 0 2px 10px rgb(0 0 0 / 0.06);
  --font-body: 'Noto Sans JP', system-ui, sans-serif;
  --font-head: 'Noto Sans JP', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --head-weight: 700;
  --code-bg: #1e2430;
  color-scheme: light;
}

/* ---------- ダーク: 開発者向け・ターミナル感 ---------- */
[data-theme='dark'] {
  --bg: #0b0e14;
  --surface: #11161f;
  --surface-2: #171d29;
  --text: #e3e7ee;
  --muted: #8a93a6;
  --border: #212a38;
  --accent: #4ade80;
  --accent-2: #22d3ee;
  --accent-text: #06120a;
  --radius: 6px;
  --shadow: none;
  --shadow-hover: 0 0 0 1px var(--accent), 0 0 24px rgb(74 222 128 / 0.12);
  --font-body: 'Noto Sans JP', system-ui, sans-serif;
  --font-head: 'JetBrains Mono', 'Noto Sans JP', monospace;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --head-weight: 700;
  --code-bg: #0d1117;
  color-scheme: dark;
}

/* ---------- リッチ: オーロラ背景・ガラス・明朝見出し ---------- */
[data-theme='rich'] {
  --bg: #0e0b1e;
  --surface: rgb(255 255 255 / 0.05);
  --surface-2: rgb(255 255 255 / 0.08);
  --text: #f5f2ff;
  --muted: #b5addb;
  --border: rgb(255 255 255 / 0.12);
  --accent: #f3c46b;
  --accent-2: #a78bfa;
  --accent-text: #1d1405;
  --radius: 18px;
  --shadow: 0 10px 40px rgb(0 0 0 / 0.35);
  --shadow-hover: 0 18px 60px rgb(120 80 220 / 0.35);
  --font-body: 'Noto Sans JP', system-ui, sans-serif;
  --font-head: 'Zen Old Mincho', 'Noto Serif JP', serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --head-weight: 700;
  --code-bg: rgb(10 8 24 / 0.8);
  color-scheme: dark;
}

/* ---------- 共通ベース ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.85;
  transition: background-color 0.3s, color 0.3s;
}

[data-theme='rich'] body {
  background:
    radial-gradient(60rem 40rem at 10% -10%, rgb(167 139 250 / 0.28), transparent 60%),
    radial-gradient(50rem 35rem at 100% 10%, rgb(56 189 248 / 0.18), transparent 60%),
    radial-gradient(45rem 35rem at 50% 110%, rgb(243 196 107 / 0.14), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

[data-theme='dark'] body {
  background-image: radial-gradient(rgb(255 255 255 / 0.035) 1px, transparent 1px);
  background-size: 22px 22px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
[data-theme='dark'] a { color: var(--accent-2); }

h1, h2, h3 {
  font-family: var(--font-head);
  font-weight: var(--head-weight);
  line-height: 1.35;
  letter-spacing: 0.01em;
}

img { max-width: 100%; height: auto; display: block; }

.container { width: min(1080px, 100% - 32px); margin-inline: auto; }
.narrow { width: min(760px, 100% - 32px); margin-inline: auto; }

/* ---------- ヘッダー ---------- */
.site-header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header .inner {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding-block: 14px;
}
.logo { font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; color: var(--text); }
.logo:hover { text-decoration: none; }
[data-theme='dark'] .logo::before { content: '>_ '; color: var(--accent); }
[data-theme='rich'] .logo {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.nav { display: flex; gap: 18px; margin-left: auto; font-size: 0.95rem; }
.nav a { color: var(--muted); }
.nav a:hover, .nav a[aria-current='page'] { color: var(--text); text-decoration: none; }

.theme-switch {
  display: inline-flex; padding: 3px; gap: 2px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
}
.theme-switch button {
  font: inherit; font-size: 0.78rem; cursor: pointer;
  border: 0; background: transparent; color: var(--muted);
  padding: 4px 10px; border-radius: 999px;
}
.theme-switch button[aria-pressed='true'] { background: var(--accent); color: var(--accent-text); }

/* ---------- ヒーロー ---------- */
.hero { padding: 88px 0 56px; }
.hero .eyebrow {
  font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent);
  letter-spacing: 0.12em; text-transform: uppercase;
}
.hero h1 { font-size: clamp(2rem, 5vw, 3.4rem); margin: 12px 0 16px; }
.hero p { color: var(--muted); max-width: 40em; font-size: 1.05rem; }
[data-theme='rich'] .hero { padding: 120px 0 72px; text-align: center; }
[data-theme='rich'] .hero p { margin-inline: auto; }
[data-theme='rich'] .hero h1 {
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  background: linear-gradient(120deg, #fff 20%, var(--accent) 55%, var(--accent-2) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
[data-theme='dark'] .hero h1 .cursor {
  display: inline-block; width: 0.55em; height: 1em; margin-left: 4px;
  background: var(--accent); vertical-align: -0.1em; animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text) !important; font-weight: 700;
  border: 1px solid transparent;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--text) !important; border-color: var(--border); }
.hero .actions { display: flex; gap: 12px; margin-top: 28px; flex-wrap: wrap; }
[data-theme='rich'] .hero .actions { justify-content: center; }

/* ---------- セクション ---------- */
.section { padding: 40px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-head h2 { margin: 0; font-size: 1.5rem; }
.section-head a { font-size: 0.9rem; }
[data-theme='dark'] .section-head h2::before { content: '## '; color: var(--accent); }

.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ---------- カード ---------- */
.card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 22px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow); color: var(--text);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.card:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--shadow-hover); }
[data-theme='rich'] .card { backdrop-filter: blur(14px); }
.card h3 { margin: 0; font-size: 1.15rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.93rem; line-height: 1.7; }
.card .meta { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 0.78rem; color: var(--muted); }
.card .cover { border-radius: calc(var(--radius) - 6px); aspect-ratio: 16 / 9; object-fit: cover; background: var(--surface-2); }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 0.74rem; border: 1px solid var(--border); color: var(--muted);
  font-family: var(--font-mono);
}
.badge.status { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.tag { color: var(--muted); font-size: 0.8rem; }
.tag::before { content: '#'; }

/* 記事リスト */
.article-list { list-style: none; padding: 0; margin: 0; }
.article-list li { border-bottom: 1px solid var(--border); }
.article-list a { display: grid; grid-template-columns: 7.5em 1fr; gap: 16px; padding: 18px 4px; color: var(--text); }
.article-list a:hover { text-decoration: none; background: var(--surface); }
.article-list time { font-family: var(--font-mono); font-size: 0.85rem; color: var(--muted); padding-top: 2px; }
.article-list .t { font-weight: 700; }
.article-list .d { display: block; color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
@media (max-width: 560px) {
  .article-list a { grid-template-columns: 1fr; gap: 4px; }
}

/* ---------- 記事本文 ---------- */
.post-head { padding: 56px 0 24px; }
.post-head h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 8px 0 12px; }
.post-head .desc { color: var(--muted); }

.info-box {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px;
  padding: 16px 20px; margin: 8px 0 32px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.88rem;
}
.info-box dt { color: var(--muted); font-size: 0.75rem; }
.info-box dd { margin: 0; font-weight: 700; }

.prose { font-size: 1.02rem; }
.prose h2 { margin-top: 2.4em; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.prose h3 { margin-top: 1.8em; }
.prose code { font-family: var(--font-mono); font-size: 0.88em; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }
.prose pre { padding: 16px 18px; border-radius: var(--radius); overflow-x: auto; background: var(--code-bg) !important; border: 1px solid var(--border); }
.prose pre code { background: none; padding: 0; }
.prose blockquote { margin: 1.5em 0; padding: 4px 18px; border-left: 3px solid var(--accent); color: var(--muted); background: var(--surface); }
.prose table { border-collapse: collapse; width: 100%; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }

.related {
  margin: 48px 0; padding: 20px; border-radius: var(--radius);
  border: 1px dashed var(--border); background: var(--surface);
}

/* ---------- フッター ---------- */
.site-footer { margin-top: 80px; padding: 32px 0 48px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.85rem; }
.site-footer .inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }

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

/* 静的版の追加分 */
.prose .codehilite { background: var(--code-bg) !important; border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; margin: 1.2em 0; }
.prose .codehilite pre { margin: 0; border: 0; background: transparent !important; }
.prose table { display: block; overflow-x: auto; }
.tag-row { display: flex; flex-wrap: wrap; gap: 12px; }
a:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
