/* =====================
   カラーパレット（ライト）
   ===================== */
:root,
[data-theme="light"] {
  --accent:       #4a7c59;
  --accent-light: #e8f5ee;
  --bg:           #ffffff;
  --surface:      #f8f8f6;
  --border:       #e4e4e0;
  --text:         #222222;
  --muted:        #666666;
}

/* =====================
   カラーパレット（ダーク）
   ===================== */
[data-theme="dark"] {
  --accent:       #7ec49a;
  --accent-light: #1e3530;
  --bg:           #1e1e22;
  --surface:      #26262d;
  --border:       #38383f;
  --text:         #dcdce4;
  --muted:        #9090a0;
}

/* =====================
   リセット・基本
   ===================== */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: 'Noto Sans JP', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN',
               Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 780px;
  margin: 0 auto;
  padding: 0 1.25rem;
  line-height: 1.8;
  font-size: 1rem;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* =====================
   ヘッダー
   ===================== */
header {
  padding: 2rem 0 1.5rem;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 2.5rem;
}

.header-inner {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

header h1 a {
  color: var(--text);
  text-decoration: none;
}

.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 2.2rem;
  height: 2.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
  color: var(--text);
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle svg {
  transition: opacity 0.15s;
}

.icon-sun  { display: none; }
.icon-moon { display: block; }
[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* =====================
   メインコンテンツ
   ===================== */
main {
  min-height: 60vh;
}

/* =====================
   記事ページ
   ===================== */
article h2.post-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  line-height: 1.4;
}

/* 記事ページ ヒーロー画像 */
.post-hero {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  object-position: center;
  border-radius: 6px;
  margin-bottom: 1.25rem;
  display: block;
}

.post-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.post-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tag {
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15em 0.6em;
  border-radius: 3px;
  letter-spacing: 0.03em;
}

article .post-content {
  margin-top: 1.5rem;
}

article .post-content h2,
article .post-content h3 {
  margin-top: 2rem;
}

/* =====================
   目次 (TOC)
   ===================== */
/* モバイルでは非表示。デスクトップでのみサイドバーとして表示 */
.toc {
  display: none;
}

.toc__title {
  font-weight: 700;
  font-size: 0.9rem;
  margin: 0 0 0.6rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.toc__item--h3 {
  padding-left: 1.1rem;
}

.toc__link {
  display: block;
  padding: 0.2rem 0 0.2rem 0.6rem;
  border-left: 2px solid transparent;
  color: var(--text);
  text-decoration: none;
  line-height: 1.5;
  transition: color 0.15s, border-color 0.15s;
}

.toc__link:hover {
  color: var(--accent);
  text-decoration: none;
}

.toc__link--active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* デスクトップ: 本文右外に固定サイドバーとして表示（空の場合は非表示） */
@media (min-width: 1200px) {
  .toc:not(:empty) {
    display: block;
    position: fixed;
    top: 2rem;
    left: calc(50% + 390px + 1.5rem);
    width: 185px;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem 1.25rem 1.1rem;
    font-size: 0.82rem;
  }
}

/* =====================
   記事一覧に戻るボタン
   ===================== */
.back-to-list {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.back-to-list__link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.5rem 1.4rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}

.back-to-list__link:hover {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}

/* =====================
   リンクカード
   ===================== */
.link-card {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  margin: 1.5rem 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.link-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.09);
  text-decoration: none;
  color: var(--text);
}

.link-card__body {
  flex: 1;
  padding: 0.9rem 1.1rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.link-card__title {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.45;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-card__desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-card__meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.2rem 0 0;
}

.link-card__favicon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.link-card__domain {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-card__img {
  flex: 0 0 140px;
  width: 140px;
}

.link-card__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@media (max-width: 600px) {
  .link-card__img {
    flex: 0 0 100px;
    width: 100px;
  }
}

/* =====================
   タグフィルター
   ===================== */

.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}

.tag-filter {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.3em 0.85em;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.tag-filter:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tag-filter.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* =====================
   記事一覧（カードスタイル）
   ===================== */

.post-list {
  list-style: none;
  padding: 0;
  margin: 0 0 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.post-list li {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;   /* stretched-link の基点 */
  cursor: pointer;
}

.post-list li:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
}

/* サムネイル */
.post-thumb,
.post-thumb--placeholder {
  flex: 0 0 45%;
  width: 45%;
  min-height: 200px;
}

.post-thumb {
  object-fit: cover;
  object-position: center;
  display: block;
}

.post-thumb--placeholder {
  background: var(--border);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23aaaaaa' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='16' y1='13' x2='8' y2='13'/%3E%3Cline x1='16' y1='17' x2='8' y2='17'/%3E%3Cline x1='10' y1='9' x2='8' y2='9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 3.5rem;
}

/* 記事情報 */
.post-list-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.4rem;
  padding: 1.25rem 1.5rem;
  min-width: 0;
  flex: 1;
}

/* カード全体をリンクにする stretched-link */
.post-list-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  line-height: 1.4;
  text-decoration: none;
}

.post-list-title::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
}

.post-list li:hover .post-list-title {
  color: var(--accent);
}

/* stretched-link より前面に出したい要素があれば z-index: 2 を付与 */
.post-list .tag {
  position: relative;
  z-index: 2;
}

.post-excerpt {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-list-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.15rem;
}

.post-date {
  font-size: 0.78rem;
  color: var(--muted);
}

.section-heading {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

/* =====================
   フッター
   ===================== */
footer {
  margin-top: 4rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

footer a {
  color: var(--muted);
  text-decoration: underline;
}

.footer-copy {
  margin-top: 0.25rem;
  font-size: 0.8rem;
}

/* =====================
   ヘッダーナビ
   ===================== */
.header-nav {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.header-nav__link {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.12s;
}

.header-nav__link:hover,
.header-nav__link[aria-current="page"] {
  color: var(--accent);
  text-decoration: none;
}

.header-nav__link[aria-current="page"] {
  position: relative;
}

.header-nav__link[aria-current="page"]::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

/* =====================
   ページネーション
   ===================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 2rem 0 3rem;
}

.pagination-btn {
  display: inline-block;
  padding: 0.45em 1.1em;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.pagination-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.pagination-btn--disabled {
  color: var(--border);
  cursor: default;
  pointer-events: none;
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 4rem;
  text-align: center;
}

/* =====================
   関連記事
   ===================== */
.related-posts {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.related-posts__heading {
  font-size: 1rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 1rem;
}

.related-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.related-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
  position: relative;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.related-item:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
}

.related-thumb,
.related-thumb--placeholder {
  width: 90px;
  height: 66px;
  flex-shrink: 0;
}

.related-thumb {
  object-fit: cover;
  object-position: center;
  display: block;
}

.related-thumb--placeholder {
  background: var(--border);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23aaaaaa' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='16' y1='13' x2='8' y2='13'/%3E%3Cline x1='16' y1='17' x2='8' y2='17'/%3E%3Cline x1='10' y1='9' x2='8' y2='9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 2rem;
}

.related-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.5rem 0.75rem 0.5rem 0;
  min-width: 0;
}

.related-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.related-title::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
}

.related-item:hover .related-title {
  color: var(--accent);
}

/* =====================
   アーカイブページ
   ===================== */
.page-heading {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 2rem;
}

.archive-year {
  margin-bottom: 2.5rem;
}

.archive-year__heading {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  border-left: 4px solid var(--accent);
  padding-left: 0.75rem;
  margin: 0 0 0.75rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.archive-year__count {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 400;
}

.archive-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.archive-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.archive-item:last-child {
  border-bottom: none;
}

.archive-item__date {
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 3.2rem;
}

.archive-item__title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.archive-item__title:hover {
  color: var(--accent);
}

.archive-item__tags {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

/* =====================
   レスポンシブ
   ===================== */
@media (max-width: 600px) {
  body {
    font-size: 0.95rem;
    padding: 0 1rem;
  }
  header {
    padding: 1.25rem 0 1rem;
    margin-bottom: 1.75rem;
  }
  .post-thumb,
  .post-thumb--placeholder {
    flex: 0 0 38%;
    width: 38%;
    min-height: 140px;
  }
  .post-list-body {
    padding: 0.75rem 0.9rem;
  }
}

/* =====================
   タグ一覧ページ
   ===================== */
.tag-section {
  margin-bottom: 2.5rem;
}

.tag-section__heading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}

.tag-section__count {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 400;
}

/* =====================
   プロフィール・固定ページ
   ===================== */
.about-page,
.privacy-page {
  max-width: 680px;
}

.about-section {
  margin-bottom: 2rem;
}

.about-section h3 {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

/* =====================
   giscus コメント
   ===================== */
.comments {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

/* =====================
   フッターナビ
   ===================== */
.footer-nav {
  display: flex;
  gap: 1.2rem;
  justify-content: center;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.footer-nav a {
  color: var(--muted);
  text-decoration: none;
}

.footer-nav a:hover {
  color: var(--accent);
}
