/*
 * フラット UI：影・ぼかし・浮き上がり変形は使わず、境界線と単色で区切る。
 * カラーは M3 系トークンをベースに Lume / Simple Blog の --color-* へ橋渡し。
 */

/* Lume DS（@lumeland/ds）の本文・UI フォント。
 * 記事体裁の参考: https://sizu.me/（Noto Sans JP / BIZ UDPGothic 系の落ち着いた組版） */

:root {
  --font-family-ui: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", sans-serif;
  --font-family-display: var(--font-family-ui);
  /* sizu っぽい読みやすい桁（本文ブロック用、記事ページで上書き） */
  --prose-max-width: 42rem;
}

html[data-theme="dark"] {
  --font-family-ui: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", sans-serif;
  --font-family-display: var(--font-family-ui);
}

/* --- M3 トークン（ライト）— プライマリ＝本文・H1 と同じオンフサーフェス（青系は使わない）--- */

html[data-theme="light"] {
  --md-sys-color-primary: #1a1c1e;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #e6e8ec;
  --md-sys-color-on-primary-container: #1a1c1e;
  --md-sys-color-surface: #f8f9fc;
  --md-sys-color-on-surface: #1a1c1e;
  --md-sys-color-on-surface-variant: #43474e;
  --md-sys-color-outline: #73777f;
  --md-sys-color-outline-variant: #c3c6cf;
  --md-sys-color-surface-container-low: #f1f3f9;
  --md-sys-color-surface-container: #eceef4;
  --md-sys-color-surface-container-high: #e6e8ec;
  --md-sys-color-inverse-surface: #2f3033;
  --md-sys-color-inverse-on-surface: #f1f0f4;

  /* Lume DS へ */
  --color-base: var(--md-sys-color-on-surface);
  --color-dim: var(--md-sys-color-on-surface-variant);
  --color-line: var(--md-sys-color-outline-variant);
  --color-highlight: var(--md-sys-color-surface-container);

  /* 互換用アクセント（バッジ・リンク強調） */
  --zenn-accent: var(--md-sys-color-primary);
  --zenn-accent-dim: var(--md-sys-color-primary-container);
  --zenn-surface: var(--md-sys-color-surface-container-low);

  --link-underline-pink: #e9a6af;
  /* タグバッジ（ピンク背景） */
  --tag-badge-bg: #fce8eb;
  --tag-badge-fg: #3a2429;
  --tag-badge-border: #e9a6af;
}

/* --- M3 トークン（ダーク）— プライマリ＝オンフサーフェスに合わせる --- */

html[data-theme="dark"] {
  --md-sys-color-primary: #e2e2e6;
  --md-sys-color-on-primary: #121316;
  --md-sys-color-primary-container: #3a3b3c;
  --md-sys-color-on-primary-container: #e2e2e6;
  --md-sys-color-surface: #121316;
  --md-sys-color-on-surface: #e2e2e6;
  --md-sys-color-on-surface-variant: #c4c6cf;
  --md-sys-color-outline: #8e9099;
  --md-sys-color-outline-variant: #44474e;
  --md-sys-color-surface-container-low: #121316;
  --md-sys-color-surface-container: #1b1c1f;
  --md-sys-color-surface-container-high: #262628;
  --md-sys-color-inverse-surface: #e2e2e6;
  --md-sys-color-inverse-on-surface: #2f3033;

  --color-base: var(--md-sys-color-on-surface);
  --color-dim: var(--md-sys-color-on-surface-variant);
  --color-line: var(--md-sys-color-outline-variant);
  --color-highlight: var(--md-sys-color-surface-container-high);

  --zenn-accent: var(--md-sys-color-primary);
  --zenn-accent-dim: var(--md-sys-color-primary-container);
  --zenn-surface: var(--md-sys-color-surface-container);

  --link-underline-pink: #f0b6be;
  --tag-badge-bg: #4a3038;
  --tag-badge-fg: #fce8eb;
  --tag-badge-border: #8f5c6a;
}

/* ページ背景を M3 の Surface に（画面全体まで塗る） */

html[data-theme="light"],
html[data-theme="dark"] {
  min-height: 100%;
  min-height: 100dvh;
  background-color: var(--md-sys-color-surface);
}

html[data-theme="light"] body,
html[data-theme="dark"] body {
  min-height: 100%;
  min-height: 100dvh;
  background-color: var(--md-sys-color-surface);
}

/* TOP: ナビ下の main まで縦いっぱいにサーフェスを敷く */

body:has(> main.body-home) {
  display: flex;
  flex-direction: column;
  margin: 0;
}

main.body-home {
  flex: 1 0 auto;
  width: 100%;
  box-sizing: border-box;
  background-color: var(--md-sys-color-surface);
}

/* ナビ：フラット（単色＋下線のみ） */

.navbar {
  background: var(--md-sys-color-surface);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

/* 記事タイトル周り（詳細ページ：テーマの h1 既定より一段小さめ） */

.post-header .post-emoji {
  margin: 0 0 0.35em;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  line-height: 1;
  letter-spacing: 0.02em;
}

.post-title {
  font-weight: 700;
}

/* --- 記事ページ: sizu.me 系の読みやすい本文列（タイトル〜脚注まで同じ桁） --- */

article.post {
  max-width: var(--prose-max-width);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 1.75rem);
}

.post-header .post-title {
  font-size: clamp(1.35rem, 3.2vw, 1.75rem);
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--md-sys-color-on-surface);
}

/* 記事ヘッダー直下：SNS 共有（フラット・本文リンクのピンク下線は付けない） */

.post-share {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.75rem;
}

.post-share-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
  letter-spacing: 0.04em;
}

.post-share-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.post-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0.25rem 0.65rem;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--md-sys-color-on-surface);
  text-decoration: none !important;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 4px;
  cursor: pointer;
  box-sizing: border-box;
}

a.post-share-btn:hover,
button.post-share-btn:hover {
  background: color-mix(
    in srgb,
    var(--md-sys-color-on-surface) 6%,
    var(--md-sys-color-surface-container)
  );
  border-color: color-mix(
    in srgb,
    var(--link-underline-pink) 45%,
    var(--md-sys-color-outline-variant)
  );
}

.post-body.body {
  font-size: 1.0625rem;
  line-height: 1.9;
  letter-spacing: 0.03em;
}

/* 記事先頭：AI 共同執筆の注記（本文より薄く） */

.post-body.body p.post-ai-disclosure {
  margin: 0 0 1.35em;
  font-size: 0.8125rem;
  line-height: 1.55;
  letter-spacing: 0.04em;
  color: color-mix(
    in srgb,
    var(--md-sys-color-on-surface-variant) 72%,
    transparent
  );
}

.post-body.body p {
  margin: 0;
}

.post-body.body p + p {
  margin-top: 1.35em;
}

.post-body.body :is(h1, h2, h3, h4, h5, h6) {
  margin-top: 1.65em;
  margin-bottom: 0.55em;
  line-height: 1.45;
  font-weight: 700;
}

.post-body.body :is(ul, ol) {
  padding-left: 1.35em;
}

.post-body.body li + li {
  margin-top: 0.4em;
}

.post-body.body blockquote {
  margin: 1.5em 0;
  padding-left: 1em;
  border-left: 3px solid
    color-mix(in srgb, var(--md-sys-color-outline) 55%, transparent);
  color: var(--md-sys-color-on-surface-variant);
}

.post-body.body hr {
  margin: 2.25em 0;
  border: none;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

/* 目次 */

.post .toc {
  margin-bottom: 1.5rem;
  padding: 1rem 1.15rem;
  border-radius: 4px;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.post .toc h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.65em;
  color: var(--md-sys-color-on-surface-variant);
}

/* タグバッジ（ピンク背景・リンクは従来どおり下線なし） */

.badge {
  border-radius: 4px;
  border: 1px solid var(--tag-badge-border);
  background: var(--tag-badge-bg);
  color: var(--tag-badge-fg);
}

a.badge:hover {
  filter: brightness(0.97);
}

html[data-theme="dark"] a.badge:hover {
  filter: brightness(1.08);
}

/* 記事本文の見出しはレベルに関わらず同じ色（テーマの段階別カラーを上書き） */

.body :is(h1, h2, h3, h4, h5, h6) {
  color: var(--md-sys-color-on-surface);
}

/* 共有ボタンは上記 .post-share-btn で下線なし（本文リンクルールの対象外） */

article.post a:not(.badge):not(.post-share-btn),
.page-pagination a {
  color: var(--md-sys-color-on-surface);
  text-decoration: underline;
  text-decoration-color: var(--link-underline-pink);
  text-underline-offset: 0.15em;
  text-decoration-thickness: 1px;
}

article.post a:not(.badge):not(.post-share-btn):hover,
.page-pagination a:hover {
  color: var(--md-sys-color-on-surface);
  text-decoration-color: color-mix(
    in srgb,
    var(--link-underline-pink) 75%,
    var(--md-sys-color-on-surface)
  );
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
  border-radius: 4px;
}

/* ナビ：サイトアイコン（M3 シェイプ: 角丸四角） */

.navbar-home {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar-home .site-logo {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  -o-object-fit: cover;
     object-fit: cover;
  border: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: none;
}

/* テーマ切替 */

.navbar .button {
  border-radius: 4px;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-high);
  box-shadow: none;
}

/* トップ：アイコン＋プロフィールリンクのみ */

.page-header--home .home-hero--profile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.page-header--home .home-avatar {
  width: 80px;
  height: 80px;
  border-radius: 4px;
  -o-object-fit: cover;
     object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: none;
}

.page-header--home .home-profile-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  width: 100%;
}

.page-header--home .home-profile-tagline {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--md-sys-color-on-surface);
  letter-spacing: 0.02em;
}

.page-header--home .home-profile-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.page-header--home .home-profile-icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 4px;
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  box-shadow: none;
}

.page-header--home .home-profile-icon-link:hover {
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  border-color: var(--md-sys-color-outline);
}

.page-header--home .home-sns-svg {
  width: 22px;
  height: 22px;
  display: block;
  flex-shrink: 0;
}

.page-header--home .home-profile-intro {
  margin: 0;
  max-width: min(100%, 36rem);
  font-size: 0.875rem;
  line-height: 1.5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
}

.page-header--home .home-profile-intro-link {
  color: var(--md-sys-color-on-surface);
  text-decoration: underline;
  text-decoration-color: var(--link-underline-pink);
  text-underline-offset: 0.15em;
  text-decoration-thickness: 1px;
}

.page-header--home .home-profile-intro-link:hover {
  color: var(--md-sys-color-on-surface);
  text-decoration-color: color-mix(
    in srgb,
    var(--link-underline-pink) 75%,
    var(--md-sys-color-on-surface)
  );
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 6%, transparent);
  border-radius: 4px;
}

.page-header--home .home-profile-intro-link:not(:first-child)::before {
  content: "·";
  margin-right: 0.35rem;
  color: var(--md-sys-color-outline);
  text-decoration: none;
  display: inline-block;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 1.25rem;
  margin-top: 0.5rem;
}

.post-card {
  margin: 0;
}

.post-card-link {
  display: block;
  text-decoration: none;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container);
  box-shadow: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.post-card-link:hover {
  border-color: var(--md-sys-color-outline);
  background: var(--md-sys-color-surface-container-high);
}

.post-card-thumb {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: middle;
  background: var(--md-sys-color-surface-container);
}

.home-archive-link {
  margin-top: 2rem;
  font: var(--font-small);
}

.home-archive-link a {
  color: var(--md-sys-color-on-surface);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--link-underline-pink);
  text-underline-offset: 0.15em;
  text-decoration-thickness: 1px;
}

.home-archive-link a:hover {
  text-decoration-color: color-mix(
    in srgb,
    var(--link-underline-pink) 75%,
    var(--md-sys-color-on-surface)
  );
}

/* ---------- アーカイブ・タグ一覧（Simple Blog の body-tag）---------- */

main.body-tag {
  max-width: var(--prose-max-width);
  margin-inline: auto;
  padding: 1rem clamp(1rem, 4vw, 1.75rem) 2.5rem;
  box-sizing: border-box;
}

main.body-tag .page-header {
  margin-bottom: 1.25rem;
}

main.body-tag .page-header .page-title {
  margin: 0 0 0.75rem;
  font-size: clamp(1.35rem, 3.2vw, 1.75rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--md-sys-color-on-surface);
}

main.body-tag .page-header > p {
  margin: 0 0 1rem;
  font-size: 0.9375rem;
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

main.body-tag .page-header .search {
  margin-top: 0.75rem;
}

main.body-tag .page-navigation {
  margin: 1.5rem 0 2rem;
  padding: 1rem 1.15rem;
  border-radius: 4px;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container);
}

main.body-tag .page-navigation > h2 {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--md-sys-color-on-surface-variant);
}

main.body-tag .page-navigation-tags {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

main.body-tag ul.postList {
  list-style: none;
  margin: 0;
  padding: 0;
}

main.body-tag .postList > .post {
  margin: 0;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

main.body-tag .postList > .post:first-child {
  padding-top: 0;
}

main.body-tag .postList > .post:last-child {
  border-bottom: none;
}

main.body-tag .postList .post-title {
  margin: 0 0 0.5rem;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.45;
}

main.body-tag .post-details {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--md-sys-color-on-surface-variant);
}

main.body-tag .post-details p {
  margin: 0.2rem 0 0;
}

main.body-tag .post-tags {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* バッジ以外＝ピンク下線（RSS・記事タイトル・フッタリンク等） */

main.body-tag a:not(.badge) {
  color: var(--md-sys-color-on-surface);
  text-decoration: underline;
  text-decoration-color: var(--link-underline-pink);
  text-underline-offset: 0.15em;
  text-decoration-thickness: 1px;
}

main.body-tag a:not(.badge):hover {
  text-decoration-color: color-mix(
    in srgb,
    var(--link-underline-pink) 75%,
    var(--md-sys-color-on-surface)
  );
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 6%, transparent);
  border-radius: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
