/* 夜の書架 — 共通スタイル
   外部フォント・CDNは使わない（指示_Cloudflareで実装する_2026-09-27 §5）
   構成は 40_サイト/【設計】サイト全面設計_2026-10-03.md／指示_サイト改修_統合版 §5 */

:root {
  /* 黒と金の方向は維持し、背景・面・強調の明るさに差をつける */
  --bg: #111216;
  --surface: #1c1f26;
  --surface-2: #272b35;
  --border: #3b414e;
  --text: #ece8e0;
  --text-muted: #aaa597;
  --accent: #d4b072;
  --accent-soft: rgba(212, 176, 114, 0.14);
  --link: #e2c590;
  --pr-bg: #2a2418;
  /* カテゴリの見分け（色＋図形） */
  --c-sagasu: #d4b072;
  --c-erabikata: #7fbfae;
  --c-otoku: #e0957a;
  --radius: 10px;
  --wide: 1080px;
  --narrow: 720px;
  --header-h: 112px;
}

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

html { -webkit-text-size-adjust: 100%; scroll-padding-top: var(--header-h); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.85;
  overflow-wrap: anywhere;
}

a { color: var(--link); }
a:hover { color: var(--text); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

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

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------- ヘッダー（上に固定） */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--surface); border-bottom: 1px solid var(--border); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; padding-bottom: 10px; }
.site-title { margin: 0; font-size: 1.3rem; font-weight: 700; letter-spacing: 0.08em; line-height: 1.4; }
.site-title a { color: var(--text); text-decoration: none; }
.site-tagline { margin: 0; font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; }
.search-link {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 999px;
  color: var(--text); text-decoration: none; font-size: 0.9rem;
}
.search-link:hover { border-color: var(--accent); color: var(--accent); }
.cat-nav { border-top: 1px solid var(--border); }
.cat-nav .wrap { display: flex; gap: 8px; overflow-x: auto; padding-top: 6px; padding-bottom: 6px; scrollbar-width: none; }
.cat-nav a {
  flex: none; display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 999px;
  background: var(--surface-2); color: var(--text);
  font-size: 0.9rem; font-weight: 700; text-decoration: none;
}
.cat-nav a[aria-current="page"] { background: var(--accent); color: #17140e; }

/* ---------------- PR表記：識別できる位置と枠は保ち、主役にはしない */
.pr-notice {
  margin: 16px 0;
  padding: 8px 12px;
  background: var(--pr-bg);
  border: 1px solid rgba(212, 176, 114, 0.45);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.65;
  color: #e9dcc0;
}
.age-note { margin: 0 0 20px; font-size: 0.85rem; color: var(--text-muted); }

/* ---------------- 本文 */
main { padding: 4px 0 48px; }

.page-title, .article-title { margin: 20px 0 6px; font-size: 1.75rem; line-height: 1.45; letter-spacing: 0.02em; }
.meta { margin: 0; font-size: 0.82rem; color: var(--text-muted); }
.page-lead { margin: 12px 0 24px; font-size: 1.02rem; }
.page-note { margin: 40px 0 8px; font-size: 0.85rem; color: var(--text-muted); }

.article-body { font-size: 1.04rem; }
.article-body h2 {
  margin: 48px 0 14px;
  padding: 8px 0 8px 14px;
  font-size: 1.32rem;
  line-height: 1.5;
  border-left: 5px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 6px 6px 0;
}
.article-body h3 { margin: 30px 0 8px; font-size: 1.12rem; }
.article-body p { margin: 0 0 1.15em; }
.article-body ul, .article-body ol { margin: 0 0 1.2em; padding-left: 1.5em; }
.article-body li { margin: 0.35em 0; }
.article-body strong { color: #f6e6c4; }
hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }

/* 表：スマホでは表の中だけ横スクロール */
.table-scroll { overflow-x: auto; margin: 0 0 1.4em; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; min-width: 7em; }
th { background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

/* パンくず */
.breadcrumb ol { display: flex; flex-wrap: wrap; margin: 14px 0 0; padding: 0; list-style: none; font-size: 0.8rem; color: var(--text-muted); }
.breadcrumb li + li::before { content: "›"; margin: 0 8px; }
.breadcrumb a { display: inline-block; padding: 6px 0; color: var(--text-muted); }

.tag {
  display: inline-block; margin-right: 10px; padding: 0 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; text-decoration: none;
}

/* ---------------- 見出し（一覧系） */
.section-title { margin: 44px 0 16px; font-size: 1.25rem; letter-spacing: 0.02em; }
.cat-heading { margin: 28px 0 12px; font-size: 1.05rem; }
.cat-heading a { color: var(--text); text-decoration: none; border-bottom: 2px solid var(--accent); padding-bottom: 2px; }
.sub-title { margin: 22px 0 10px; font-size: 0.92rem; font-weight: 700; color: var(--text-muted); }

/* ---------------- トップ */
.hero { padding: 20px 0 8px; }
.hero-title { margin: 8px 0 10px; font-size: 1.9rem; line-height: 1.4; letter-spacing: 0.03em; }
.hero-lead { margin: 0 0 20px; font-size: 1.05rem; max-width: 40em; }
.first-read {
  display: flex; flex-direction: column; max-width: 640px; padding: 16px 18px;
  border: 1px solid var(--accent); border-radius: var(--radius);
  background: linear-gradient(135deg, var(--pr-bg), var(--surface)); color: var(--text); text-decoration: none;
}
.first-read:hover { background: var(--surface-2); }
.first-read .card-title { font-size: 1.1rem; color: var(--text); }
.home-search { margin-top: 8px; }

/* カテゴリ：色と小さな図形で見分ける */
.cat-sagasu { --c: var(--c-sagasu); }
.cat-erabikata { --c: var(--c-erabikata); }
.cat-otoku { --c: var(--c-otoku); }

.cat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.cat-tiles a {
  display: flex; flex-direction: column; height: 100%; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--c, var(--accent));
  border-radius: var(--radius); color: var(--text); text-decoration: none;
}
.cat-tiles a:hover { background: var(--surface-2); }
.tile-name { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; }
.tile-name::before, .card-cat::before { content: ""; flex: none; display: inline-block; width: 12px; height: 12px; background: var(--c, var(--accent)); }
.cat-sagasu .tile-name::before, .cat-sagasu .card-cat::before { border-radius: 50%; }
.cat-erabikata .tile-name::before, .cat-erabikata .card-cat::before { transform: rotate(45deg); width: 10px; height: 10px; }
.cat-otoku .tile-name::before, .cat-otoku .card-cat::before { border-radius: 2px 6px; }
.tile-desc { margin: 6px 0 10px; font-size: 0.9rem; line-height: 1.65; color: var(--text-muted); }
.tile-count { margin-top: auto; font-size: 0.85rem; font-weight: 700; color: var(--c, var(--accent)); }

/* 検索窓 */
.search-form { display: flex; gap: 8px; margin: 0 0 16px; max-width: 640px; }
.search-form input {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); font-size: 16px;
}
.search-form input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.search-form button { flex: none; width: 56px; min-height: 48px; background: var(--accent); color: #17140e; border: 0; border-radius: var(--radius); cursor: pointer; }
.search-status { margin: 0 0 14px; font-size: 0.92rem; color: var(--text-muted); }

/* ---------------- 記事カード */
.card-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
@media (min-width: 720px) { .card-list { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .wrap:not(.narrow) .card-list { grid-template-columns: repeat(3, 1fr); } }
.card a, .next-main {
  display: flex; flex-direction: column; height: 100%; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; transition: border-color .15s, background .15s;
}
.card a { border-left: 4px solid var(--c, var(--accent)); }
.card a:hover, .next-main:hover { border-color: var(--c, var(--accent)); background: var(--surface-2); }
.card-cat { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; margin-bottom: 6px; font-size: 0.78rem; font-weight: 700; color: var(--c, var(--accent)); }
.card-cat::before { width: 9px; height: 9px; }
.card-title, .card-lead { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.card-title { -webkit-line-clamp: 2; font-weight: 700; font-size: 1.02rem; line-height: 1.6; color: var(--link); }
.card-lead { -webkit-line-clamp: 2; margin-top: 6px; font-size: 0.88rem; line-height: 1.7; color: var(--text-muted); }
.card-meta { margin-top: 8px; font-size: 0.78rem; color: var(--text-muted); }

/* 目次 */
.toc { margin: 0 0 28px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.toc summary { cursor: pointer; font-weight: 700; min-height: 32px; }
.toc ol { margin: 8px 0 0; padding-left: 1.4em; font-size: 0.95rem; }
.toc li { margin: 4px 0; }
.toc a { display: inline-block; padding: 4px 0; color: var(--text); }

/* 次に読む記事 */
.next-read { margin: 48px 0 0; padding-top: 8px; border-top: 1px solid var(--border); }
.next-main { border: 1px solid var(--accent); background: linear-gradient(135deg, var(--pr-bg), var(--surface)); }
.next-main .card-title { font-size: 1.08rem; color: var(--text); }
.next-label { align-self: flex-start; margin-bottom: 6px; padding: 2px 10px; border-radius: 999px; background: var(--accent); color: #17140e; font-size: 0.78rem; font-weight: 700; }
.next-label::after { content: " →"; }
.back-link { margin: 32px 0 0; }
.back-link a { display: inline-block; padding: 10px 0; }

/* 検索0件のときのカテゴリ */
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.chip-list a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: 999px; background: var(--surface-2); color: var(--text); text-decoration: none; font-weight: 700; }

/* ---------------- フッター */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 16px 0 28px; font-size: 0.85rem; color: var(--text-muted); }
.footer-nav { display: flex; flex-wrap: wrap; gap: 0 20px; margin: 0 0 10px; padding: 0; list-style: none; }
.footer-nav a { display: inline-flex; align-items: center; min-height: 44px; }
.site-footer p { margin: 4px 0; }

/* ---------------- 年齢確認モーダル（js/age.js） */
html.age-pending body > *:not(.age-gate) { visibility: hidden; }
.age-gate { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(8, 9, 12, 0.96); }
.age-gate__box { width: 100%; max-width: 440px; padding: 28px 22px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; text-align: center; }
.age-gate__title { margin: 0 0 12px; font-size: 1.3rem; font-weight: 700; }
.age-gate__text { margin: 0 0 20px; font-size: 0.95rem; }
.age-gate__buttons { display: flex; gap: 12px; }
.age-gate__buttons button { flex: 1; min-height: 50px; border-radius: var(--radius); font-size: 1rem; font-weight: 700; cursor: pointer; }
.age-gate__yes { background: var(--accent); color: #17140e; border: 0; }
.age-gate__no { background: transparent; color: var(--text); border: 1px solid var(--border); }
.age-gate__denied { margin: 16px 0 0; font-size: 0.92rem; color: #f0a8a8; }
/* スマホ幅では横並びだと「はい（18歳以上）」が2行に折れるため、縦に積む */
@media (max-width: 480px) { .age-gate__buttons { flex-direction: column; } }

.noscript-note { padding: 12px 16px; background: var(--pr-bg); text-align: center; font-size: 0.9rem; }

/* ---------------- スマホ */
@media (max-width: 480px) {
  .page-title, .article-title { font-size: 1.45rem; }
  .hero-title { font-size: 1.55rem; }
  .section-title { font-size: 1.15rem; }
  .article-body h2 { font-size: 1.2rem; }
  .site-title { font-size: 1.15rem; }
  .search-link span { display: none; }
  .search-link { padding: 0 12px; }
}
