/**
 * Re-Systems Blog — カスタムCSS
 * SWELL風デザインの追加スタイル
 * theme.json で制御できない細かなスタイルをここで定義
 */

/* ============================================================
   リセット & ベース
   ============================================================ */

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

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  word-break: break-word;
  overflow-wrap: break-word;
}

img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

/* ============================================================
   ヘッダー
   ============================================================ */

/* ヘッダー下の影（SWELL風） */
.wp-block-template-part[data-area="header"] > .wp-block-group {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  position: relative;
  z-index: 100;
}

/* ナビゲーションリンク — ホバー下線アニメーション */
.wp-block-navigation .wp-block-navigation-item a {
  position: relative;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.wp-block-navigation .wp-block-navigation-item a::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--wp--preset--color--accent-light);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.25s ease;
}

.wp-block-navigation .wp-block-navigation-item a:hover::after {
  transform: scaleX(1);
}

/* ============================================================
   記事カード
   ============================================================ */

.rsb-post-card {
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  overflow: hidden;
}

.rsb-post-card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

/* アイキャッチ画像 — ホバーズーム */
.rsb-post-card .wp-block-post-featured-image img {
  transition: transform 0.3s ease;
}

.rsb-post-card:hover .wp-block-post-featured-image img {
  transform: scale(1.03);
}

.rsb-post-card .wp-block-post-featured-image {
  overflow: hidden;
}

/* ============================================================
   カテゴリバッジ（SWELL風）
   ============================================================ */

.rsb-cat-badge a {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 3px;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.rsb-cat-badge a:hover {
  opacity: 0.85;
}

/* ============================================================
   記事本文 — タイポグラフィ
   ============================================================ */

.wp-block-post-content p {
  margin-bottom: 1.5em;
}

.wp-block-post-content h2 {
  padding-bottom: 0.4em;
  border-bottom: 3px solid var(--wp--preset--color--main);
  margin-top: 2.5em;
}

.wp-block-post-content h3 {
  padding-left: 0.8em;
  border-left: 4px solid var(--wp--preset--color--main);
}

.wp-block-post-content h4 {
  position: relative;
  padding-left: 1.2em;
}

.wp-block-post-content h4::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  background: var(--wp--preset--color--main);
  border-radius: 50%;
}

/* リスト */
.wp-block-post-content ul,
.wp-block-post-content ol {
  padding-left: 1.8em;
  margin-bottom: 1.5em;
}

.wp-block-post-content li {
  margin-bottom: 0.4em;
  line-height: 1.8;
}

/* テーブル */
.wp-block-post-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5em;
}

.wp-block-post-content th,
.wp-block-post-content td {
  padding: 0.75em 1em;
  border: 1px solid var(--wp--preset--color--border);
  text-align: left;
}

.wp-block-post-content th {
  background: var(--wp--preset--color--surface);
  font-weight: 600;
  color: var(--wp--preset--color--main);
}

.wp-block-post-content tr:nth-child(even) td {
  background: var(--wp--preset--color--surface);
}

/* 強調テキスト */
.wp-block-post-content strong {
  color: var(--wp--preset--color--main);
  font-weight: 700;
}

/* インラインコード */
.wp-block-post-content code:not([class*="language-"]) {
  background: var(--wp--preset--color--surface);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: var(--wp--preset--font-family--mono);
}

/* ============================================================
   サイドバー
   ============================================================ */

/* サイドバーウィジェット — リストスタイル */
.wp-block-template-part .wp-block-categories-list li,
.wp-block-template-part .wp-block-latest-posts__list li {
  padding: 0.5em 0;
  border-bottom: 1px solid var(--wp--preset--color--border);
  list-style: none;
}

.wp-block-template-part .wp-block-categories-list li:last-child,
.wp-block-template-part .wp-block-latest-posts__list li:last-child {
  border-bottom: none;
}

.wp-block-template-part .wp-block-categories-list,
.wp-block-template-part .wp-block-latest-posts__list {
  padding-left: 0;
}

/* タグクラウド */
.wp-block-tag-cloud a {
  display: inline-block;
  padding: 3px 10px;
  margin: 2px;
  background: var(--wp--preset--color--white);
  border: 1px solid var(--wp--preset--color--border);
  border-radius: 20px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.wp-block-tag-cloud a:hover {
  background: var(--wp--preset--color--main);
  color: var(--wp--preset--color--white);
  border-color: var(--wp--preset--color--main);
}

/* ============================================================
   ページネーション
   ============================================================ */

.wp-block-query-pagination {
  gap: 0.5rem;
}

.wp-block-query-pagination .page-numbers,
.wp-block-query-pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5em;
  height: 2.5em;
  padding: 0 0.75em;
  border: 1px solid var(--wp--preset--color--border);
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.wp-block-query-pagination .page-numbers.current,
.wp-block-query-pagination .page-numbers:hover,
.wp-block-query-pagination a:hover {
  background: var(--wp--preset--color--main);
  color: var(--wp--preset--color--white);
  border-color: var(--wp--preset--color--main);
}

/* ============================================================
   フッター
   ============================================================ */

.wp-block-template-part[data-area="footer"] a {
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.wp-block-template-part[data-area="footer"] a:hover {
  opacity: 0.8;
}

/* ============================================================
   検索フォーム
   ============================================================ */

.wp-block-search__input {
  border: 1px solid var(--wp--preset--color--border);
  padding: 0.6em 1em;
  font-size: 0.875rem;
  transition: border-color 0.2s ease;
}

.wp-block-search__input:focus {
  border-color: var(--wp--preset--color--accent);
  outline: none;
  box-shadow: 0 0 0 2px rgba(57, 160, 255, 0.15);
}

.wp-block-search__button {
  background: var(--wp--preset--color--main);
  color: var(--wp--preset--color--white);
  border: none;
  padding: 0.6em 1em;
  cursor: pointer;
  transition: background 0.2s ease;
}

.wp-block-search__button:hover {
  background: var(--wp--preset--color--main-light);
}

/* ============================================================
   コメント欄
   ============================================================ */

.wp-block-comment-template {
  list-style: none;
  padding-left: 0;
}

.wp-block-comment-template > li {
  padding: 1.5em 0;
  border-bottom: 1px solid var(--wp--preset--color--border);
}

/* ============================================================
   レスポンシブ
   ============================================================ */

@media (max-width: 782px) {
  /* サイドバーをメインの下に配置 */
  .wp-block-columns {
    flex-direction: column;
  }

  .wp-block-column {
    flex-basis: 100% !important;
  }

  /* 記事本文のH2装飾を少し小さく */
  .wp-block-post-content h2 {
    font-size: 1.375rem;
  }

  .wp-block-post-content h3 {
    font-size: 1.1875rem;
  }

  /* カード内のパディング調整 */
  .rsb-post-card .wp-block-group {
    padding: var(--wp--preset--spacing--sm);
  }
}

@media (max-width: 480px) {
  .wp-block-post-content h2 {
    font-size: 1.25rem;
  }
}

/* ============================================================
   アクセシビリティ
   ============================================================ */

:focus-visible {
  outline: 2px solid var(--wp--preset--color--accent);
  outline-offset: 2px;
}

.screen-reader-text {
  clip: rect(1px, 1px, 1px, 1px);
  position: absolute;
  height: 1px;
  width: 1px;
  overflow: hidden;
}

/* ============================================================
   スムーズスクロール
   ============================================================ */

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .rsb-post-card,
  .rsb-post-card .wp-block-post-featured-image img,
  .wp-block-navigation .wp-block-navigation-item a::after {
    transition: none;
  }
}
