/*
 * natto-static テーマ。現行 natto.moe（Cocoon / skin-innocence）の雰囲気に寄せた軽量スタイル。
 * 薄いドット地紋の背景・白い角丸カード・中央ロゴ・横並びグローバルメニュー・2カラムのサムネカード・右サイドバー。
 */
:root {
  --fg: #4a4a4a;
  --heading: #333;
  --muted: #888;
  --accent: #1e92bf;
  --accent-dark: #14789e;
  --bg: #eef0f1;
  --card: #fff;
  --bg-soft: #f6f7f8;
  --border: #e3e3e3;
  --max: 1080px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 18px;
}

body {
  margin: 0;
  color: var(--fg);
  background-color: var(--bg);
  /* skin-innocence の地紋（squ_ten2.png）を CSS のドットパターンで再現 */
  background-image: radial-gradient(rgba(0, 0, 0, 0.045) 1px, transparent 1px);
  background-size: 8px 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  line-height: 1.8;
  font-size: 1rem;
}

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

a:hover {
  text-decoration: underline;
}

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

.container {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 16px;
}

/* ---- Header（中央ロゴ） ---- */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.site-header-in {
  max-width: var(--max);
  margin: 0 auto;
  padding: 22px 16px 0;
}

.site-title {
  margin: 0;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.site-title a {
  color: var(--heading);
}

.global-nav {
  margin-top: 16px;
  border-top: 1px solid var(--border);
}

.global-nav ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}

.global-nav li {
  border-left: 1px solid var(--border);
}

.global-nav li:last-child {
  border-right: 1px solid var(--border);
}

.global-nav a {
  display: block;
  padding: 12px 18px;
  color: var(--fg);
  font-size: 0.82rem;
  font-weight: 500;
}

.global-nav a:hover {
  background: var(--bg-soft);
  text-decoration: none;
  color: var(--accent);
}

.global-nav a.is-active {
  color: var(--accent);
  font-weight: 700;
}

/* スマホ専用要素はデスクトップでは隠す（カテゴリーは従来の横並び .global-nav を表示） */
.nav-toggle,
.cat-drawer,
.tag-strip,
.header-search {
  display: none;
}

/*
 * スマホ用ヘッダー（560px以下）。
 * ・タイトル行を小さくし、右に ☰（カテゴリーはハンバーガーで展開）。
 * ・その下に「食材タグ」の横スクロール帯を固定し、回遊しやすくする。
 * ・下スクロール時はタイトル＋☰を畳み、タグ帯だけ残す。
 * デスクトップ表示（.global-nav）は変更しない。
 */
@media (max-width: 560px) {
  .site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  }
  .site-header-in {
    position: relative;
    padding: 10px 0 0;
  }

  /* デスクトップ用カテゴリー横並びはスマホでは隠す */
  .global-nav {
    display: none;
  }

  /* タイトル行（左）＋ ☰（右） */
  .site-title {
    font-size: 1.05rem;
    line-height: 1.3;
    text-align: left;
    padding: 2px 60px 0 16px;
    overflow: hidden;
    max-height: 4em;
    opacity: 1;
    transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.25s ease;
  }
  .nav-toggle {
    display: grid;
    place-content: center;
    gap: 4px;
    position: absolute;
    top: 8px;
    right: 12px;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--bg-soft);
    cursor: pointer;
    transition: opacity 0.2s ease;
  }
  .nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--fg);
    border-radius: 2px;
  }
  .site-header.nav-open .nav-toggle {
    background: var(--accent);
    border-color: var(--accent);
  }
  .site-header.nav-open .nav-toggle span {
    background: #fff;
  }

  /* 下スクロール時: タイトル＋☰を畳み、タグ帯だけ残す */
  .site-header.is-scrolled .site-header-in {
    padding-top: 0;
  }
  .site-header.is-scrolled .site-title {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
  }
  .site-header.is-scrolled .nav-toggle {
    opacity: 0;
    visibility: hidden;
  }

  /* カテゴリードロワー（☰で開閉） */
  .cat-drawer {
    display: block;
    max-height: 0;
    overflow: hidden;
    background: var(--card);
    transition: max-height 0.28s ease;
  }
  .site-header.nav-open .cat-drawer {
    max-height: 75vh;
    overflow: auto;
    border-top: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
  }
  .cat-drawer ul {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  .cat-drawer a {
    display: block;
    padding: 12px 16px;
    font-size: 0.9rem;
    color: var(--fg);
    border-bottom: 1px solid var(--border);
  }
  .cat-drawer a.is-active {
    color: var(--accent);
    font-weight: 700;
  }

  /* ヘッダー内検索（タイトル下・タグ帯の上）。下スクロールで畳まれる */
  .header-search {
    display: flex;
    gap: 6px;
    padding: 8px 16px 0;
    max-height: 60px;
    overflow: hidden;
    opacity: 1;
    transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.25s ease;
  }
  .header-search input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.85rem;
    background: var(--bg-soft);
    color: var(--fg);
  }
  .header-search button {
    flex: 0 0 auto;
    padding: 8px 16px;
    border: none;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
  }
  .site-header.is-scrolled .header-search {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
  }

  /* 食材タグの横スクロール帯（回遊用・常時表示） */
  .tag-strip {
    display: block;
    position: relative;
    margin-top: 8px;
    border-top: 1px solid var(--border);
    /* 中の ul は overflow-x:auto で横スクロールするが、nav 側が visible だと
       はみ出した子要素がページ全体の幅を押し広げてしまう（実測で 390→407px） */
    overflow: hidden;
  }
  .tag-strip::after {
    content: "";
    position: absolute;
    top: 1px;
    right: 0;
    bottom: 0;
    width: 32px;
    pointer-events: none;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), var(--card));
  }
  .tag-strip ul {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    margin: 0;
    padding: 10px 14px;
    list-style: none;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tag-strip ul::-webkit-scrollbar {
    display: none;
  }
  .tag-strip a {
    display: block;
    white-space: nowrap;
    font-size: 0.8rem;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-soft);
    color: var(--fg);
  }
  .tag-strip a.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
  }
  /* ドロワー内「食材タグ一覧」への区切りリンク */
  .cat-drawer .drawer-sep a {
    color: var(--accent);
    font-weight: 700;
  }
  /* タグ帯の末尾「すべて →」リンク */
  .tag-strip .tag-strip-all a {
    color: var(--accent);
    border-color: var(--accent);
    font-weight: 600;
  }
}

/* ---- Layout ---- */
.main-body {
  display: flex;
  flex-direction: row-reverse;
  gap: 32px;
  align-items: flex-start;
  padding: 28px 0;
}

.main-conts {
  flex: 1 1 auto;
  min-width: 0;
}

.sidebar {
  flex: 0 0 300px;
  max-width: 300px;
}

@media (max-width: 768px) {
  .main-body {
    flex-direction: column;
    gap: 28px;
  }
  .sidebar {
    flex-basis: auto;
    max-width: none;
    width: 100%;
  }
}

/* ---- 一覧: 2カラムのサムネカード（Cocoon entry-card 風） ---- */
.entry-cards {
  display: grid;
  /* minmax(0,1fr) にしないと、中身（長い記事タイトル等）が縮まず列がはみ出す。
     1fr の既定の最小値は auto = 中身の最小幅のため */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

@media (max-width: 560px) {
  .entry-cards {
    grid-template-columns: 1fr;
  }
}

.entry-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.entry-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.entry-card-thumb {
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--bg-soft);
}

.entry-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.entry-card-body {
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.entry-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.entry-card-title {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.5;
  font-weight: 700;
}

.entry-card-title a {
  color: var(--heading);
}

.entry-card-title a:hover {
  color: var(--accent);
  text-decoration: none;
}

.entry-card-excerpt {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- 記事単体ページ ---- */
.article.is-single {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px 32px;
}

@media (max-width: 560px) {
  .article.is-single {
    padding: 20px 16px;
  }
}

.article-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.article-title {
  margin: 0 0 12px;
  font-size: 1.5rem;
  line-height: 1.5;
  color: var(--heading);
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.article-cat {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 3px;
  background: var(--cat-color, #8a6d3b);
  color: #fff !important;
  font-size: 0.72rem;
}

.article-cat:hover {
  text-decoration: none;
  opacity: 0.9;
}

/* ---- Tags (Phase3) ---- */
/* 記事下部のタグ。スマホで押しやすいチップUI（最小44pxの当たり判定を意識）。 */
.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 24px 0 4px;
}

.tag-chip {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--accent);
  font-size: 0.8rem;
  line-height: 1.4;
  white-space: nowrap;
}

.tag-chip:hover {
  text-decoration: none;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.tag-chip:hover .count {
  color: #fff;
}

/* サイドバーのタグ雲 */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-cloud .tag-chip {
  font-size: 0.78rem;
  padding: 5px 10px;
}

.tag-cloud .count {
  color: var(--muted);
  font-size: 0.72rem;
}

.article-body :where(h2, h3) {
  margin-top: 1.6em;
  line-height: 1.5;
  color: var(--heading);
}

.article-body img {
  border-radius: 4px;
}

.article-hero {
  margin: 0 0 20px;
}

/* TikTok 埋め込みは中央寄せ・幅制御 */
.article-body .tiktok-embed {
  margin: 20px auto;
  max-width: 605px;
}

/* 埋め込みが表示されない場合の保険リンク（cite の動画URLへ） */
.article-body .tiktok-fallback {
  max-width: 605px;
  margin: -6px auto 20px;
  text-align: center;
}

.article-body .tiktok-fallback a {
  display: inline-block;
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--accent-dark);
  font-size: 0.85rem;
  font-weight: 600;
}

.article-body .tiktok-fallback a:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  text-decoration: none;
}

/* ---- Gallery ---- */
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0;
}

.gallery-item {
  margin: 0;
}

.gallery-item img {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* ---- Sidebar widgets ---- */
.widget {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 20px;
}

.widget-title {
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent);
  font-size: 0.95rem;
  color: var(--heading);
}

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

.widget-categories li {
  padding: 8px 0;
  border-bottom: 1px dotted var(--border);
  font-size: 0.85rem;
}

.widget-categories li:last-child {
  border-bottom: 0;
}

.widget .count {
  color: var(--muted);
  font-size: 0.78rem;
}

.widget-search form {
  display: flex;
  gap: 6px;
}

.widget-search input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
}

.widget-search button {
  padding: 8px 14px;
  border: 0;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
}

.widget-search button:hover {
  background: var(--accent-dark);
}

.widget-archive select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
}

.widget-popular li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dotted var(--border);
  font-size: 0.85rem;
  line-height: 1.5;
}

.widget-popular li:last-child {
  border-bottom: 0;
}

.widget-popular .rank {
  flex: 0 0 auto;
  font-weight: 700;
  color: var(--accent);
}

/* ---- パンくずリスト ---- */
.breadcrumbs {
  margin: 0 0 14px;
  font-size: 0.78rem;
  color: var(--muted);
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 0;
}

.breadcrumbs li + li::before {
  content: "\203A";
  margin: 0 6px;
  color: var(--muted);
}

.breadcrumbs li[aria-current="page"] {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60vw;
}

/* ---- 記事内 前後ナビ ---- */
.article-nav {
  display: flex;
  gap: 16px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.article-nav p {
  margin: 0;
  flex: 1 1 0;
  min-width: 0;
}

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

.article-nav a {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .article-nav a {
    white-space: normal;
    line-height: 1.5;
  }
}

/* ---- 関連レシピ ---- */
.related-articles {
  margin-top: 24px;
}

.related-articles-title {
  font-size: 1.1rem;
  margin: 0 0 14px;
  padding: 10px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent);
  border-radius: 6px;
  color: var(--heading);
}

.related-articles .entry-card-title {
  font-size: 0.88rem;
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0;
  font-size: 0.9rem;
}

/* 番号ページネーション（トップ・カテゴリ一覧） */
.pagination-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 28px 0;
}

.pagination-nav .page-numbers {
  display: inline-block;
  min-width: 2.2em;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--fg);
  background: var(--card);
}

.pagination-nav a.page-numbers:hover {
  background: var(--bg-soft);
  text-decoration: none;
}

.pagination-nav .page-numbers.current {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.pagination-nav .page-numbers.dots {
  border: none;
  background: transparent;
  min-width: auto;
  padding: 8px 2px;
  color: var(--muted);
}

.pagination-nav .page-numbers.prev,
.pagination-nav .page-numbers.next {
  min-width: auto;
}

/* アーカイブ・カテゴリ一覧の見出し */
.archive-title {
  font-size: 1.25rem;
  margin: 0 0 18px;
  padding: 10px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent);
  border-radius: 6px;
  color: var(--heading);
}

/* ---- タグ一覧ページ ---- */
.tag-index-lead {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* 一覧ページの大きめタグ雲（サイドバーより読みやすく） */
.tag-cloud-lg {
  gap: 10px;
}

.tag-cloud-lg .tag-chip {
  font-size: 0.92rem;
  padding: 8px 14px;
}

.tag-cloud-lg .count {
  margin-left: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.tag-cloud-lg .tag-chip:hover .count {
  color: #fff;
}

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--card);
  margin-top: 20px;
}

.site-footer-in {
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px 16px;
  text-align: center;
}

.footer-title a {
  color: var(--heading);
  font-weight: 700;
}

.footer-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 10px 0 0;
}

.footer-nav a {
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: underline;
}

.footer-copy {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 8px 0 0;
}
