/*
Theme Name: Atsumare AI
Theme URI: https://atsumare-ai.com
Description: あつまれAIの森 専用テーマ。AI・テクノロジーブログ向けのクリーンでモダンなデザイン。
Author: Atsumare AI
Version: 1.0.9
License: GPL-2.0+
Text Domain: atsumare-ai
*/

/* ===== リセット & ベース ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #2563eb;
  --primary-d:  #1d4ed8;
  --accent:     #06b6d4;
  --bg:         #f8fafc;
  --card-bg:    #ffffff;
  --text:       #1e293b;
  --text-muted: #64748b;
  --border:     #e2e8f0;
  --radius:     12px;
  --shadow:     0 2px 12px rgba(0,0,0,.08);
  --shadow-h:   0 8px 24px rgba(0,0,0,.14);
  --max-w:      1100px;
  --font:       'Noto Sans JP', 'Hiragino Kaku Gothic ProN', sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-d); }
img { max-width: 100%; width: auto; height: auto; display: block; }
figure { max-width: 100%; margin: 0; }

/* ===== レイアウト ===== */
.site-wrapper { max-width: var(--max-w); margin: 0 auto; padding: 0 32px; box-sizing: border-box; width: 100%; }
@media (min-width: 480px) { .site-wrapper { padding: 0 36px; } }
@media (min-width: 768px) { .site-wrapper { padding: 0 40px; } }

.content-area { display: grid; grid-template-columns: 1fr 300px; gap: 40px; margin: 32px auto; width: 100%; box-sizing: border-box; }
@media (max-width: 768px) {
  .content-area { grid-template-columns: 1fr; gap: 24px; margin: 20px 0; }
  .sidebar { order: 2; }
}

/* ===== ヘッダー ===== */
.site-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 8px rgba(0,0,0,.06);
}
.header-inner {
  max-width: var(--max-w); margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; box-sizing: border-box;
}
@media (min-width: 480px) { .header-inner { padding: 0 28px; height: 64px; } }
.site-title a {
  font-size: 1.25rem; font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.site-description { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

/* ナビ */
.main-nav ul { display: flex; gap: 8px; list-style: none; }
.main-nav a {
  padding: 6px 14px; border-radius: 20px; font-size: .875rem; font-weight: 600;
  color: var(--text-muted); transition: all .2s;
}
.main-nav a:hover, .main-nav .current-menu-item a {
  background: var(--primary); color: #fff;
}
@media (max-width: 600px) { .main-nav { display: none; } }

/* ===== ヒーロー（トップのみ） ===== */
.hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0e7490 100%);
  color: #fff; padding: 40px 20px; text-align: center;
}
@media (min-width: 480px) { .hero { padding: 60px 24px; } }
.hero h1 { font-size: clamp(1.3rem, 5vw, 2.4rem); font-weight: 900; margin-bottom: 12px; }
.hero p { font-size: clamp(.85rem, 3vw, 1rem); opacity: .85; max-width: 560px; margin: 0 auto; }

/* ===== 記事カード グリッド ===== */
.posts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
@media (min-width: 540px) { .posts-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .posts-grid { grid-template-columns: repeat(3, 1fr); gap: 24px; } }
.post-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .25s, box-shadow .25s;
  display: flex; flex-direction: column;
}
.post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-h);
}

/* サムネイル */
.post-card__thumb {
  aspect-ratio: 16/9;
  overflow: hidden;
  background: linear-gradient(135deg, #1e3a5f, #0e7490);
  position: relative;
  width: 100%;
  max-width: 100%;
}
.post-card__thumb img {
  width: 100%; height: 100%; object-fit: cover;
  max-width: 100%;
  transition: transform .4s;
}
.post-card:hover .post-card__thumb img { transform: scale(1.05); }

/* サムネなし */
.post-card__thumb--noimage {
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.5); font-size: 2.5rem;
}

/* カテゴリバッジ */
.post-card__cat {
  position: absolute; top: 12px; left: 12px;
  background: var(--primary); color: #fff;
  font-size: .7rem; font-weight: 700; padding: 3px 10px;
  border-radius: 20px; letter-spacing: .04em;
}

/* 本文エリア */
.post-card__body { padding: 14px 16px 16px; flex: 1; display: flex; flex-direction: column; }
@media (min-width: 480px) { .post-card__body { padding: 20px; } }
.post-card__title {
  font-size: .95rem; font-weight: 700; line-height: 1.5;
  color: var(--text); margin-bottom: 10px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.post-card__excerpt {
  font-size: .8rem; color: var(--text-muted); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  flex: 1;
}
.post-card__meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 14px; font-size: .75rem; color: var(--text-muted);
}
.post-card__date::before { content: "📅 "; }
.post-card__read-more {
  display: inline-block;
  padding: 4px 12px; border-radius: 20px;
  background: var(--primary); color: #fff;
  font-size: .75rem; font-weight: 600;
}

/* ===== 単一記事 ===== */
.post-header { margin-bottom: 32px; }
.post-header__cat {
  display: inline-block;
  background: var(--primary); color: #fff;
  font-size: .75rem; font-weight: 700; padding: 4px 14px;
  border-radius: 20px; margin-bottom: 16px;
}
.post-header__title {
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 900; line-height: 1.4; color: var(--text);
}
.post-header__meta {
  display: flex; gap: 16px; align-items: center;
  margin-top: 16px; font-size: .8rem; color: var(--text-muted);
}

/* アイキャッチ */
.post-eyecatch {
  border-radius: var(--radius); overflow: hidden;
  margin-bottom: 32px; box-shadow: var(--shadow);
  aspect-ratio: 16/9;
  max-width: 100%;
}
.post-eyecatch img { width: 100%; height: 100%; object-fit: cover; max-width: 100%; }

/* 本文 */
.post-content {
  font-size: clamp(.9rem, 3.5vw, 1rem); line-height: 1.9; color: var(--text);
  overflow-wrap: break-word; word-break: break-word;
}
.post-content h2 {
  font-size: 1.4rem; font-weight: 800;
  margin: 2.5em 0 .8em;
  padding-left: 16px;
  border-left: 4px solid var(--primary);
  color: var(--text);
}
.post-content h3 {
  font-size: 1.15rem; font-weight: 700;
  margin: 2em 0 .6em;
  padding: 8px 14px;
  background: #f1f5f9; border-radius: 6px;
  border-left: 3px solid var(--accent);
}
.post-content p { margin-bottom: 1.4em; }
.post-content ul, .post-content ol { padding-left: 1.6em; margin-bottom: 1.4em; }
.post-content li { margin-bottom: .4em; }
.post-content blockquote {
  margin: 1.6em 0; padding: 16px 20px;
  border-left: 4px solid var(--accent);
  background: #f0fdff; border-radius: 0 8px 8px 0;
  color: var(--text-muted); font-style: italic;
}
.post-content a { color: var(--primary); text-decoration: underline; }
.post-content strong { font-weight: 700; color: #0f172a; }
.post-content table { width: 100%; border-collapse: collapse; margin: 1.6em 0; font-size: .9rem; }
.post-content th { background: var(--primary); color: #fff; padding: 10px 14px; text-align: left; }
.post-content td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.post-content tr:nth-child(even) td { background: #f8fafc; }
.post-content img {
  border-radius: 8px; margin: 1.2em auto; box-shadow: var(--shadow);
  max-width: 100%; width: auto; height: auto;
}
.post-content figure { max-width: 100%; overflow: hidden; }
.wp-block-image { max-width: 100% !important; }
.wp-block-image img { max-width: 100% !important; width: auto; height: auto; }

/* FAQ */
.faq-item { margin-bottom: 16px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.faq-q {
  background: #f1f5f9; padding: 14px 18px;
  font-weight: 700; font-size: .95rem;
  display: flex; gap: 10px; align-items: flex-start;
}
.faq-q::before { content: "Q"; background: var(--primary); color: #fff; padding: 2px 8px; border-radius: 4px; flex-shrink: 0; font-size: .85rem; }
.faq-a { padding: 14px 18px; font-size: .9rem; line-height: 1.7; display: flex; gap: 10px; align-items: flex-start; }
.faq-a::before { content: "A"; background: var(--accent); color: #fff; padding: 2px 8px; border-radius: 4px; flex-shrink: 0; font-size: .85rem; }

/* ===== サイドバー ===== */
.widget {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 24px;
}
.widget-title {
  font-size: .9rem; font-weight: 800;
  padding-bottom: 10px; margin-bottom: 16px;
  border-bottom: 2px solid var(--primary);
  color: var(--text);
}

/* 人気記事ウィジェット */
.popular-posts li {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 0; border-bottom: 1px solid var(--border); list-style: none;
}
.popular-posts li:last-child { border-bottom: none; }
.popular-posts__num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: .75rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.popular-posts__title { font-size: .8rem; line-height: 1.5; color: var(--text); }

/* ===== フッター ===== */
.site-footer {
  background: #0f172a; color: rgba(255,255,255,.7);
  padding: 40px 20px 24px; margin-top: 60px;
  text-align: center;
}
.footer-logo { font-size: 1.1rem; font-weight: 800; color: #fff; margin-bottom: 8px; }
.footer-links { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.footer-links a { color: rgba(255,255,255,.6); font-size: .8rem; }
.footer-links a:hover { color: #fff; }
.footer-copy { font-size: .75rem; color: rgba(255,255,255,.4); }

/* ===== パンくず ===== */
.breadcrumb {
  font-size: .8rem; color: var(--text-muted);
  padding: 12px 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.breadcrumb a { color: var(--primary); }
.breadcrumb span::before { content: "/"; margin-right: 6px; opacity: .5; }

/* ===== ページネーション ===== */
.pagination {
  display: flex; gap: 8px; justify-content: center;
  margin: 40px 0; flex-wrap: wrap;
}
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 8px;
  font-size: .875rem; font-weight: 600;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  transition: all .2s;
}
.pagination a:hover, .pagination .current {
  background: var(--primary); border-color: var(--primary); color: #fff;
}

/* ===== ユーティリティ ===== */
.section-title {
  font-size: 1.1rem; font-weight: 800; margin-bottom: 20px;
  display: flex; align-items: center; gap: 8px; color: var(--text);
}
.section-title::after { content: ""; flex: 1; height: 2px; background: var(--border); }

/* ===== スマホ横スクロール完全防止 ===== */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}

/* Gutenberg ブロック アライメントリセット */
.post-content .alignfull,
.post-content .alignwide {
  max-width: 100% !important;
  width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* ブロック系要素が親をはみ出さないよう制御 */
.post-content > * {
  max-width: 100%;
  box-sizing: border-box;
}

.wp-block-image,
.wp-block-image figure,
.wp-block-image img {
  max-width: 100% !important;
  width: auto !important;
  height: auto !important;
}

.wp-block-table {
  overflow-x: auto;
  max-width: 100%;
}

/* pre/code ブロックの横はみ出し防止 */
.post-content pre,
.post-content code {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* iframe/embed 系 */
.post-content iframe,
.post-content embed,
.post-content object {
  max-width: 100% !important;
}

/* カード・メインカラム全体 */
main, article, .post-content, .post-header, .post-eyecatch {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
