/*
Theme Name: keishi-blog
Theme URI: https://keishi-blog.com
Author: keishi
Description: AIで作る・解決するをテーマにしたミニマルブログ
Version: 1.1.0
License: GNU General Public License v2 or later
Text Domain: keishi-blog
*/

/* ===========================
   Reset & Base
=========================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg:      #f9f9f7;
  --color-surface: #f0f0ed;
  --color-text:    #1a1a1a;
  --color-muted:   #6b7280;
  --color-border:  #e5e7eb;
  --color-tag-bg:  #f0f0ec;

  /* Category accent colors */
  --cat-web-bg:    #eff6ff;
  --cat-web-text:  #3b82f6;
  --cat-ai-bg:     #f5f3ff;
  --cat-ai-text:   #7c3aed;
  --cat-dev-bg:    #ecfdf5;
  --cat-dev-text:  #059669;
  --cat-news-bg:   #fffbeb;
  --cat-news-text: #d97706;
  --cat-noise-bg:  #f9fafb;
  --cat-noise-text:#6b7280;

  --font-sans:  'Zen Kaku Gothic New', sans-serif;
  --font-serif: 'DM Serif Display', serif;
  --max-width:  1080px;
  --content-width: 720px;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.8;
  letter-spacing: 0.02em;
}

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

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

ul, ol {
  list-style: none;
}

/* ===========================
   Layout
=========================== */

.site-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
}

.container--narrow {
  max-width: var(--content-width);
}

.site-main {
  flex: 1;
}

/* ===========================
   Header
=========================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 2rem;
}

.site-title {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.site-title a {
  transition: opacity 0.2s;
}

.site-title a:hover {
  opacity: 0.55;
}

.site-tagline {
  font-size: 0.6875rem;
  color: var(--color-muted);
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* Nav */
.site-nav ul {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.site-nav a {
  font-size: 0.8125rem;
  color: var(--color-muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: color 0.2s;
}

.site-nav a:hover {
  color: var(--color-text);
}

/* Hamburger */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.nav-toggle span {
  display: block;
  width: 100%;
  height: 1px;
  background: var(--color-text);
  transition: transform 0.25s, opacity 0.25s;
}

.nav-toggle.is-open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.nav-toggle.is-open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ===========================
   Hero (front-page only)
=========================== */

.hero {
  padding: 5rem 0 4.5rem;
  border-bottom: 1px solid var(--color-border);
}

.hero-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: center;
}

.hero-text {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-left: 2rem;
}

.hero-eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  color: var(--color-muted);
  text-transform: uppercase;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: 0.01em;
}

.hero-desc {
  font-size: 0.9375rem;
  color: var(--color-muted);
  line-height: 1.75;
}

.hero-visual {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-visual svg {
  width: 80%;
  height: auto;
}

/* ===========================
   Section base
=========================== */

.fp-section {
  padding: 5rem 0;
  border-bottom: 1px solid var(--color-border);
}

.fp-section:last-child {
  border-bottom: none;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 2.5rem;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: 0.03em;
}

.section-more {
  font-size: 0.8125rem;
  color: var(--color-muted);
  transition: color 0.2s;
}

.section-more:hover {
  color: var(--color-text);
}

/* ===========================
   Post Grid (front-page Latest)
=========================== */

.post-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.post-card-grid {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.post-card-grid:hover {
  border-color: #c5c5c0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

/* サムネイル */
.card-thumbnail {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.card-thumbnail__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.post-card-grid:hover .card-thumbnail__img {
  transform: scale(1.03);
}

.card-thumbnail__placeholder {
  width: 100%;
  height: 100%;
}

/* カード本文エリア */
.card-body {
  padding: 1.25rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
}

.post-card-grid .post-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.post-card-grid .post-date {
  font-size: 0.75rem;
  color: var(--color-muted);
  letter-spacing: 0.04em;
}

.post-card-grid .post-title-grid {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  font-weight: 400;
  line-height: 1.5;
  flex: 1;
}

.post-card-grid .post-title-grid a {
  transition: opacity 0.2s;
}

.post-card-grid .post-title-grid a:hover {
  opacity: 0.6;
}

.post-card-grid .post-excerpt-sm {
  font-size: 0.8125rem;
  color: var(--color-muted);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===========================
   Category Cards (front-page Topics)
=========================== */

.cat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
}

.cat-card {
  border-radius: 6px;
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: opacity 0.2s, transform 0.2s;
}

.cat-card:hover {
  opacity: 0.8;
  transform: translateY(-2px);
}

.cat-card-name {
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.3;
}

.cat-card-count {
  font-size: 0.75rem;
}

.cat-card-arrow {
  font-size: 0.875rem;
  margin-top: auto;
}

/* ===========================
   Post Card (index / archive)
=========================== */

.post-list-wrap {
  padding: 4rem 0;
}

.post-list {
  display: flex;
  flex-direction: column;
  gap: 3.5rem;
}

.post-card {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 3.5rem;
}

.post-card:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.post-date {
  font-size: 0.75rem;
  color: var(--color-muted);
  letter-spacing: 0.04em;
}

.post-category {
  display: inline-block;
  font-size: 0.6875rem;
  padding: 2px 10px;
  border-radius: 3px;
  letter-spacing: 0.06em;
  font-weight: 700;
  white-space: nowrap;
}

.post-card .post-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

.post-card .post-title a {
  transition: opacity 0.2s;
}

.post-card .post-title a:hover {
  opacity: 0.6;
}

.post-excerpt {
  font-size: 0.9rem;
  color: #555;
  line-height: 1.9;
}

.read-more {
  display: inline-block;
  margin-top: 1rem;
  font-size: 0.8125rem;
  color: var(--color-muted);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 1px;
  transition: color 0.2s, border-color 0.2s;
}

.read-more:hover {
  color: var(--color-text);
  border-color: var(--color-text);
}

/* ===========================
   Single Post
=========================== */

.single-wrap {
  padding: 4rem 0 6rem;
}

/* 記事ヘッダー */
.post-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 3.5rem;
}

.post-header .post-title {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 400;
  line-height: 1.3;
}

.post-header .post-date {
  font-size: 0.8125rem;
  color: var(--color-muted);
  letter-spacing: 0.04em;
}

/* アイキャッチ */
.post-eyecatch {
  margin-top: 0.5rem;
  border-radius: 6px;
  overflow: hidden;
}

.post-eyecatch__img {
  width: 100%;
  height: auto;
  display: block;
}

/* 目次 */
.toc {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 1.5rem 1.75rem;
  margin-bottom: 3rem;
}

.toc-title {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  margin-bottom: 0.875rem;
}

.toc-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  counter-reset: toc-counter;
}

.toc-item {
  counter-increment: toc-counter;
  font-size: 0.9rem;
  line-height: 1.5;
}

.toc-item a {
  color: var(--color-text);
  border-bottom: none;
  transition: opacity 0.2s;
}

.toc-item a:hover {
  opacity: 0.6;
  border-bottom: none;
}

.toc-item a::before {
  content: counter(toc-counter) ". ";
  color: var(--color-muted);
  font-size: 0.8125rem;
}

.toc-h3 {
  padding-left: 1.25rem;
}

.toc-h3 a::before {
  content: "– ";
  counter-increment: none;
}

/* 目次に戻る */
.toc-back {
  text-align: right;
  margin-top: 1.5rem;
  margin-bottom: 0;
}

.toc-back a {
  font-size: 0.75rem;
  color: var(--color-muted);
  letter-spacing: 0.04em;
  border-bottom: none;
  transition: color 0.2s;
}

.toc-back a:hover {
  color: var(--color-text);
  border-bottom: none;
}

/* 記事本文 */
.post-content {
  font-size: 1rem;
  line-height: 1.9;
}

.post-content h2 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 400;
  margin-top: 3.5rem;
  margin-bottom: 1rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--color-text);
}

.post-content h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.375rem;
  border-bottom: 1px dashed var(--color-border);
}

.post-content p {
  margin-bottom: 1.75rem;
}

.post-content ul,
.post-content ol {
  list-style: revert;
  padding-left: 1.5rem;
  margin-bottom: 1.75rem;
}

.post-content li {
  margin-bottom: 0.4rem;
}

.post-content a {
  border-bottom: 1px solid var(--color-border);
  transition: border-color 0.2s;
}

.post-content a:hover {
  border-color: var(--color-text);
}

.post-content blockquote {
  border-left: 2px solid var(--color-border);
  padding-left: 1.5rem;
  color: var(--color-muted);
  margin: 2rem 0;
  font-style: italic;
}

.post-content code {
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
  background: #f0eeea;
  padding: 2px 6px;
  border-radius: 3px;
}

.post-content pre {
  background: #f0eeea;
  padding: 1.5rem;
  border-radius: 6px;
  overflow-x: auto;
  margin-bottom: 1.75rem;
}

.post-content pre code {
  background: none;
  padding: 0;
}

.post-content img {
  margin: 2rem auto;
  border-radius: 4px;
}

/* 前後ナビ */
.post-navigation {
  margin-top: 5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--color-border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.nav-prev,
.nav-next {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-next {
  text-align: right;
}

.nav-label {
  font-size: 0.75rem;
  color: var(--color-muted);
  letter-spacing: 0.06em;
}

.nav-title {
  font-size: 0.9rem;
  line-height: 1.5;
  transition: opacity 0.2s;
}

.nav-title:hover {
  opacity: 0.6;
}

/* トップに戻る */
.back-to-top {
  margin-top: 2.5rem;
  text-align: center;
}

.back-to-top__link {
  font-size: 0.8125rem;
  color: var(--color-muted);
  letter-spacing: 0.04em;
  transition: color 0.2s;
}

.back-to-top__link:hover {
  color: var(--color-text);
}

/* ===========================
   Archive
=========================== */

/* ページヘッダー */
.arc-header-wrap {
  border-bottom: 1px solid var(--color-border);
  padding: 3.5rem 0 3rem;
}

.arc-header {
  border-top: 4px solid;          /* カテゴリカラーをインラインで指定 */
  padding-top: 1.5rem;
}

.arc-header__label {
  font-size: 0.75rem;
  color: var(--color-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.arc-header__title {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 400;
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

.arc-header__desc {
  font-size: 0.9rem;
  color: var(--color-muted);
  line-height: 1.75;
  margin-top: 0.75rem;
}

/* 記事グリッド */
.arc-posts {
  padding: 3.5rem 0 5rem;
}

/* ページネーション */
.arc-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.arc-pagination__prev a,
.arc-pagination__next a {
  font-size: 0.875rem;
  color: var(--color-muted);
  transition: color 0.2s;
}

.arc-pagination__prev a:hover,
.arc-pagination__next a:hover {
  color: var(--color-text);
}

.arc-pagination__next {
  margin-left: auto;
}

/* ===========================
   Pagination
=========================== */

.pagination {
  margin-top: 5rem;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

.pagination .page-numbers {
  font-size: 0.875rem;
  color: var(--color-muted);
  padding: 6px 14px;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  transition: all 0.2s;
}

.pagination .page-numbers.current,
.pagination .page-numbers:hover {
  color: var(--color-text);
  border-color: var(--color-text);
}

/* ===========================
   No posts
=========================== */

.no-posts {
  text-align: center;
  padding: 5rem 0;
  color: var(--color-muted);
  font-size: 0.9rem;
}

/* ===========================
   Footer
=========================== */

.site-footer {
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  padding: 1.5rem 0;
}

.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}

.footer-copy {
  font-size: 0.75rem;
  color: var(--color-muted);
}

.footer-nav ul {
  display: flex;
  gap: 2rem;
}

.footer-nav a {
  font-size: 0.75rem;
  color: var(--color-muted);
  transition: color 0.2s;
}

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

/* ===========================
   Responsive — Tablet: 1024px
=========================== */

@media (max-width: 1024px) {
  /* グリッド：2カラム */
  .post-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .cat-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* ヒーロー：gap縮小・タイトル縮小 */
  .hero-inner {
    gap: 2.5rem;
  }

  .hero-title {
    font-size: clamp(1.75rem, 3.5vw, 2.5rem);
  }
}

/* ===========================
   Responsive — Mobile: 768px
=========================== */

@media (max-width: 768px) {
  .container {
    padding: 0 1.25rem;
  }

  /* ---- ハンバーガーメニュー ---- */
  .nav-toggle {
    display: flex;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    z-index: 99;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: 1.25rem 1.5rem 1.75rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  }

  .site-nav.is-open {
    display: block;
  }

  .site-nav ul {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .site-nav a {
    font-size: 1rem;
    color: var(--color-text);
  }

  /* ---- ヒーロー：1カラム（テキスト上・SVG下） ---- */
  .hero {
    padding: 2.5rem 0 2rem;
  }

  .hero-inner {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .hero-visual {
    display: none;
  }

  /* ---- Front-page: Latest → 1カラム ---- */
  .post-grid {
    grid-template-columns: 1fr;
  }

  /* ---- Front-page: Topics → 2カラム ---- */
  .cat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* ---- Front-page: Section余白縮小 ---- */
  .fp-section {
    padding: 3rem 0;
  }

  /* ---- 記事一覧 ---- */
  .post-list-wrap {
    padding: 2.5rem 0;
  }

  .post-list {
    gap: 2.5rem;
  }

  .post-card {
    padding-bottom: 2.5rem;
  }

  .post-card .post-title {
    font-size: 1.25rem;
  }

  /* ---- 個別記事 ---- */
  .single-wrap {
    padding: 2.5rem 0 4rem;
  }

  .post-header .post-title {
    font-size: 1.5rem;
  }

  .post-content h2 {
    font-size: 1.2rem;
    margin-top: 2.5rem;
  }

  .post-content h3 {
    font-size: 1rem;
    margin-top: 2rem;
  }

  .toc {
    padding: 1.25rem;
  }

  /* ---- 前後ナビ ---- */
  .post-navigation {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .nav-next {
    text-align: left;
  }

  /* ---- アーカイブ ---- */
  .arc-header-wrap {
    padding: 2.5rem 0 2rem;
  }

  .arc-posts {
    padding: 2.5rem 0 3.5rem;
  }

  /* ---- フッター：縦並び ---- */
  .site-footer .container {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .footer-nav ul {
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
  }
}
