/* ==========================
 *   ベーススタイル・リセット
 * =========================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  color: #333;
}

/* ==========================
 *   ヘッダー - サイトタイトルを#postsの左端に合わせる
 * =========================== */
header {
  background-color: #4CAF50;
  color: #fff;
  padding: 1rem 0; /* 左右のパディングを0に変更 */
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  /* ヘッダー全体を中央揃え */
  display: flex;
  justify-content: center;
}

.header-container {
  display: flex;
  flex-direction: column; /* 縦方向に配置 */
  align-items: flex-start; /* 左揃え */
  max-width: 1400px;
  width: 100%;
  padding: 0 2rem; /* mainと同じ左右パディングを追加 */
  box-sizing: border-box;
  /* サイトタイトルを#postsの位置に合わせるための調整 */
  position: relative;
}

/* サイトタイトルを#postsの左端に配置するための計算 */
.site-title {
  font-size: 1.8rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  width: auto; /* 幅をautoに変更 */
  text-align: left;
  /* #postsの左位置に合わせる */
  /* mainが1400px, #postsが800pxで中央配置の場合の左マージン計算 */
  margin-left: calc((100% - 800px) / 2); /* レスポンシブ対応のため%で計算 */
  /* 最大幅での固定計算も追加 */
  max-width: 800px; /* #postsと同じ最大幅 */
  position: relative;
  left: 0;
}

/* タブレットサイズでの調整 */
@media (max-width: 1024px) {
  .site-title {
    margin-left: 0; /* タブレットでは左端に */
    width: 100%;
    text-align: left;
  }
}

.site-title a {
  color: #fff;
  text-decoration: none;
  display: inline-block;
  padding: 0.2rem 0;
}

/* ナビゲーションもサイトタイトルと同じ位置に配置 */
header nav {
  width: auto; /* 幅をautoに変更 */
  display: flex;
  justify-content: flex-start;
  /* サイトタイトルと同じ位置に配置 */
  margin-left: calc((100% - 800px) / 2);
  max-width: 800px;
}

header nav ul {
  list-style: none;
  display: flex;
  gap: 0.8rem;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
  justify-content: flex-start;
}

header nav li {
  margin: 0;
}

header nav a {
  color: #fff;
  text-decoration: none;
  padding: 0.4rem 1rem;
  border-radius: 4px;
  transition: all 0.3s ease;
  display: inline-block;
  font-size: 0.95rem;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

header nav a:hover,
header nav a:focus {
  background-color: rgba(255, 255, 255, 0.25);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* アクティブなリンクのスタイル（オプション） */
header nav a.active {
  background-color: rgba(255, 255, 255, 0.3);
  font-weight: bold;
}

/* ==========================
 *   メインコンテンツ - 中央揃え
 * =========================== */
main {
  flex: 1;
  display: flex;
  gap: 2rem;
  padding: 2rem;
  box-sizing: border-box;
  overflow: visible;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ==========================
 *   右サイドバー
 * =========================== */
#recent-posts {
  position: sticky;
  top: 6rem;
  flex: 0 0 250px;
  width: 100%;
  background-color: #f8f8f8;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  align-self: flex-start;
  max-height: calc(100vh - 8rem);
  overflow-y: auto;
}

.sidebar-section h3 {
  color: #4CAF50;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #4CAF50;
}

.sidebar-list {
  list-style: none;
}

.sidebar-list li {
  margin-bottom: 0.8rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid #e0e0e0;
}

.sidebar-list li:last-child {
  border-bottom: none;
}

.sidebar-list a {
  color: #333;
  text-decoration: none;
  transition: color 0.3s;
}

.sidebar-list a:hover {
  color: #4CAF50;
}

/* ==========================
 *   記事一覧エリア
 * =========================== */
#posts {
  flex: 1;
  min-width: 0;
  max-width: 800px;
  margin: 0 auto;
}

.post {
  background-color: #f8f8f8;
  padding: 1.5rem;
  margin-bottom: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.post-header {
  display: none !important;
}
.post h2 {
  margin-bottom: 0.8rem;
  color: #2c3e50;
}

.post h2 a {
  color: inherit;
  text-decoration: none;
}

.post h2 a:hover {
  color: #4CAF50;
}

/* Jekyllの日付スタイル */
.post-date {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.post-date::before {
  content: "📅";
  font-size: 0.8rem;
}

.post-excerpt {
  color: #555;
  margin-bottom: 1rem;
}

/* ==========================
 *   タグスタイル
 * =========================== */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.tag {
  background-color: #e8f5e9;
  color: #2e7d32;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.8rem;
  text-decoration: none;
  transition: all 0.3s;
}

.tag:hover {
  background-color: #4CAF50;
  color: white;
}

/* ==========================
 *   ページネーション
 * =========================== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid #ddd;
}

.pagination a,
.pagination span {
  padding: 0.5rem 1rem;
  border-radius: 5px;
  text-decoration: none;
}

.pagination a {
  color: #4CAF50;
  border: 1px solid #4CAF50;
  transition: all 0.3s;
}

.pagination a:hover {
  background-color: #4CAF50;
  color: white;
}

.pagination .current {
  background-color: #4CAF50;
  color: white;
  border: 1px solid #4CAF50;
}

/* ==========================
 *   記事コンテンツスタイル
 * =========================== */
.post-content {
  line-height: 1.8;
}

.post-content h1,
.post-content h2,
.post-content h3 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: #2c3e50;
}

.post-content h1 {
  padding-bottom: 0.5rem;
  border-bottom: 3px solid #4CAF50;
}

.post-content h2 {
  padding-bottom: 0.3rem;
  border-bottom: 2px solid #e0e0e0;
}

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

.post-content ul,
.post-content ol {
  margin-left: 2rem;
  margin-bottom: 1.2rem;
}

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

.post-content blockquote {
  border-left: 4px solid #4CAF50;
  padding-left: 1.5rem;
  margin: 1.5rem 0;
  color: #555;
  font-style: italic;
  background-color: #f9f9f9;
  padding: 1rem 1.5rem;
  border-radius: 0 5px 5px 0;
}

.post-content a {
  color: #4CAF50;
  text-decoration: none;
  border-bottom: 1px dotted #4CAF50;
}

.post-content a:hover {
  border-bottom: 1px solid #4CAF50;
}

/* ==========================
 *   コードブロックスタイル
 * =========================== */
pre, code {
  font-family: 'Courier New', Courier, monospace;
}

pre {
  background-color: #2d2d2d;
  color: #f8f8f2;
  padding: 1.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  border-radius: 5px;
  line-height: 1.4;
}

code {
  background-color: #f5f5f5;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-size: 0.9em;
}

pre code {
  background-color: transparent;
  padding: 0;
  border-radius: 0;
}

/* ==========================
 *   フッター - 中央揃え
 * =========================== */
footer {
  background-color: #2c3e50;
  color: #ecf0f1;
  padding: 2rem 0;
  margin-top: auto;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 2rem;
  max-width: 1400px;
  width: 100%;
  padding: 0 2rem;
  box-sizing: border-box;
}

.footer-section {
  flex: 1;
  min-width: 250px;
}

.footer-section h3 {
  color: #4CAF50;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.footer-links {
  list-style: none;
}

.footer-links li {
  margin-bottom: 0.5rem;
}

.footer-links a {
  color: #bdc3c7;
  text-decoration: none;
  transition: color 0.3s;
}

.footer-links a:hover {
  color: #4CAF50;
}

.copyright {
  text-align: center;
  padding-top: 2rem;
  margin-top: 2rem;
  border-top: 1px solid #34495e;
  color: #95a5a6;
  font-size: 0.9rem;
  max-width: 1400px;
  width: 100%;
  padding: 2rem 2rem 0;
  box-sizing: border-box;
}

/* ==========================
 *   アクセシビリティ
 * =========================== */
a:focus,
button:focus {
  outline: 2px solid #4CAF50;
  outline-offset: 2px;
}

.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;
}

/* スキップリンク */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #4CAF50;
  color: white;
  padding: 8px;
  z-index: 1001;
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
}

/* ==========================
 *   レスポンシブデザイン
 * =========================== */

/* タブレット (1024px以下) */
@media (max-width: 1024px) {
  main {
    gap: 1.5rem;
    padding: 1.5rem;
    max-width: 95vw;
  }
  
  #recent-posts {
    min-width: 200px;
    max-width: 250px;
    flex: 0 0 220px;
    padding: 1.2rem;
  }
  
  #posts {
    max-width: 700px;
  }
  
  .footer-content {
    gap: 1.5rem;
    max-width: 95vw;
  }
  
  .header-container {
    max-width: 95vw;
    padding: 0 1.5rem;
  }
  
  .copyright {
    max-width: 95vw;
    padding: 2rem 1.5rem 0;
  }
  
  .footer-content {
    padding: 0 1.5rem;
  }
  
  /* サイトタイトルとナビゲーションの調整 */
  .site-title {
    margin-left: 0;
    width: 100%;
    max-width: 700px; /* #postsの最大幅に合わせる */
  }
  
  header nav {
    margin-left: 0;
    width: 100%;
    max-width: 700px;
  }
}

/* 中型モバイル (768px以下) */
@media (max-width: 768px) {
  main {
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
    max-width: 100%;
  }
  
  #recent-posts {
    position: static;
    max-width: 100%;
    margin: 0 0 1.5rem 0;
    max-height: none;
    top: auto;
    flex: none;
    width: 100%;
  }
  
  #posts {
    flex: none;
    width: 100%;
    max-width: 100%;
  }
  
  /* ヘッダーの調整 */
  .header-container {
    align-items: flex-start;
    max-width: 100%;
    padding: 0 1rem;
  }
  
  .site-title {
    font-size: 1.5rem;
    margin-bottom: 0.8rem;
    margin-left: 0;
    width: 100%;
    max-width: 100%;
  }
  
  header nav {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
  }
  
  /* ナビゲーションを折り返し対応 */
  header nav ul {
    gap: 0.5rem;
  }
  
  header nav a {
    padding: 0.3rem 0.7rem;
    font-size: 0.9rem;
  }
  
  .footer-content {
    flex-direction: column;
    gap: 1.5rem;
    max-width: 100%;
    padding: 0 1rem;
  }
  
  .footer-section {
    min-width: 100%;
  }
  
  .copyright {
    max-width: 100%;
    padding: 2rem 1rem 0;
  }
  
  /* ヘッダーとフッターのパディング調整 */
  header {
    padding: 1rem 0;
    justify-content: center;
  }
  
  footer {
    padding: 1.5rem 0;
    align-items: center;
  }
}

/* 小型モバイル (480px以下) */
@media (max-width: 480px) {
  main {
    padding: 0.8rem;
    max-width: 100%;
  }
  
  .post {
    padding: 1rem;
    margin-bottom: 1.5rem;
  }
  
  header {
    padding: 0.8rem 0;
  }
  
  .site-title {
    font-size: 1.3rem;
    margin-bottom: 0.6rem;
  }
  
  /* ナビゲーションをさらにコンパクトに */
  header nav ul {
    gap: 0.3rem;
  }
  
  header nav a {
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
  }
  
  footer {
    padding: 1.5rem 0;
  }
  
  .post-content h1 {
    font-size: 1.5rem;
  }
  
  .post-content h2 {
    font-size: 1.3rem;
  }
  
  /* パディング調整 */
  .header-container {
    padding: 0 0.8rem;
  }
  
  .footer-content {
    padding: 0 0.8rem;
  }
  
  .copyright {
    padding: 2rem 0.8rem 0;
  }
}

/* ==========================
 *   ダークモード対応（必要ないのでコメント）
 * =========================== */
/* @media (prefers-color-scheme: dark) {
  body {
    background-color: #1a1a1a;
    color: #e0e0e0;
  }
  
  .post {
    background-color: #2d2d2d;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  }
  
  .post h2 {
    color: #fff;
  }
  
  .post-content h1,
  .post-content h2,
  .post-content h3 {
    color: #fff;
  }
  
  #recent-posts {
    background-color: #2d2d2d;
    color: #e0e0e0;
  }
  
  .sidebar-list a {
    color: #e0e0e0;
  }
  
  code {
    background-color: #3d3d3d;
  }
  
  .post-content blockquote {
    background-color: #2d2d2d;
    color: #b0b0b0;
  }
} */

/* ==========================
 *   プリントスタイル
 * =========================== */
@media print {
  header,
  #recent-posts,
  footer,
  .pagination {
    display: none;
  }
  
  main {
    display: block;
    padding: 0;
    max-width: 100%;
  }
  
  body {
    font-size: 12pt;
    line-height: 1.5;
  }
  
  .post {
    box-shadow: none;
    border: 1px solid #ddd;
    page-break-inside: avoid;
  }
  
  a {
    color: #000;
    text-decoration: underline;
  }
  
  pre {
    background-color: #f8f8f8;
    border: 1px solid #ddd;
    color: #000;
  }
  
  #posts {
    max-width: 100%;
  }
}