/* 知識の羅針盤 の共通スタイル（モバイル優先。仕様書 4.4・4.5・5.2・12章） */

:root {
  --color-text: #1f2328;
  --color-muted: #59636e;
  --color-bg: #ffffff;
  --color-surface: #f6f8fa;
  --color-border: #d0d7de;
  --color-link: #0b5cad;
  --color-accent: #8a3b12;
  --color-notice-bg: #fff4e5;
  --color-notice-border: #d97706;
  --font-body: "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
  --font-size-base: 1rem;
  --line-height: 1.85;
  --measure: 40em; /* PCで1行38〜42字 */
  --space: 1rem;
  --radius: 6px;
}

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

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--color-text, #1f2328);
  background: var(--color-bg, #fff);
  font-family: var(--font-body, sans-serif);
  font-size: var(--font-size-base, 1rem);
  line-height: var(--line-height, 1.85);
}

a {
  color: var(--color-link, #0b5cad);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--color-accent, #8a3b12);
  outline-offset: 2px;
}

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

.skip-link {
  position: absolute;
  left: -999px;
}

.skip-link:focus {
  left: var(--space, 1rem);
  top: var(--space, 1rem);
  z-index: 10;
  background: var(--color-bg, #fff);
  padding: 0.5rem;
}

/* ヘッダー・パンくず */
.site-header {
  border-bottom: 1px solid var(--color-border, #d0d7de);
  background: var(--color-bg, #fff);
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  padding: 0.75rem var(--space, 1rem);
  max-width: 72rem;
  margin: 0 auto;
}

.site-logo {
  font-weight: 700;
  text-decoration: none;
  color: var(--color-text, #1f2328);
}

.search {
  position: relative;
  flex: 1 1 14rem;
}

.search__input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--color-border, #d0d7de);
  border-radius: var(--radius, 6px);
}

.search__results {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
  background: var(--color-bg, #fff);
  border: 1px solid var(--color-border, #d0d7de);
  border-radius: var(--radius, 6px);
  max-height: 60vh;
  overflow: auto;
}

.search__results li a {
  display: block;
  padding: 0.5rem 0.75rem;
}

.print-button,
.toc__tools button {
  font-size: 0.875rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--color-border, #d0d7de);
  border-radius: var(--radius, 6px);
  background: var(--color-surface, #f6f8fa);
  cursor: pointer;
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0 auto;
  padding: 0 var(--space, 1rem) 0.5rem;
  max-width: 72rem;
  list-style: none;
  font-size: 0.875rem;
}

.breadcrumb li + li::before {
  content: ">";
  margin-right: 0.25rem;
  color: var(--color-muted, #59636e);
}

.site-main {
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--space, 1rem);
}

.site-footer {
  border-top: 1px solid var(--color-border, #d0d7de);
  padding: var(--space, 1rem);
  font-size: 0.875rem;
  color: var(--color-muted, #59636e);
  text-align: center;
}

/* 第1ページ */
.term {
  max-width: var(--measure, 40em);
  margin: 0 auto;
}

.term > section {
  break-inside: avoid;
  margin-bottom: 1.5rem;
}

.term-highlight__headword {
  font-size: 1.75rem;
  margin: 0.5rem 0;
}

.term-highlight__reading {
  font-size: 1rem;
  font-weight: 400;
  color: var(--color-muted, #59636e);
}

.term-highlight__definition {
  font-size: 1.125rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  background: var(--color-surface, #f6f8fa);
  border-left: 4px solid var(--color-accent, #8a3b12);
}

.medical-notice {
  padding: 0.75rem 1rem;
  background: var(--color-notice-bg, #fff4e5);
  border: 1px solid var(--color-notice-border, #d97706);
  border-radius: var(--radius, 6px);
}

.term-data dl,
.term-relations dl {
  margin: 0;
}

.term-data dl > div,
.term-relations dl > div {
  display: grid;
  grid-template-columns: 1fr; /* スマートフォンでは項目名／値を縦に積む */
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--color-border, #d0d7de);
}

.term-data dt,
.term-relations dt {
  color: var(--color-muted, #59636e);
  font-size: 0.875rem;
}

.term-data dd,
.term-relations dd {
  margin: 0;
}

.citations {
  padding-left: 1.5rem;
  font-size: 0.9375rem;
}

.term-trust {
  font-size: 0.875rem;
  color: var(--color-muted, #59636e);
}

.cta__button {
  display: block;
  padding: 0.75rem 1rem;
  text-align: center;
  border-radius: var(--radius, 6px);
  background: var(--color-accent, #8a3b12);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.related__note {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--color-muted, #59636e);
}

.ad-slot {
  margin: 2rem 0;
  min-height: 6rem;
}

.ad-slot__label {
  display: block;
  font-size: 0.75rem;
  color: var(--color-muted, #59636e);
}

/* 詳細ページ */
.detail-bar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  padding: 0.5rem 0;
  background: var(--color-bg, #fff);
  border-bottom: 1px solid var(--color-border, #d0d7de);
  font-size: 0.875rem;
}

.detail-bar__progress {
  flex: 1 1 100%;
  height: 3px;
  background: var(--color-surface, #f6f8fa);
}

.detail-bar__progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--color-accent, #8a3b12);
}

.detail {
  display: block;
}

.toc ol {
  padding-left: 1.25rem;
  font-size: 0.9375rem;
}

.detail-body {
  max-width: var(--measure, 40em);
}

.detail-body__sub {
  display: block;
  font-size: 1rem;
  font-weight: 400;
  color: var(--color-muted, #59636e);
}

.chapter {
  scroll-margin-top: 4rem;
}

.chapter__meta {
  font-size: 0.875rem;
  color: var(--color-muted, #59636e);
}

.chapter p {
  margin: 0 0 1.25em;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  margin: 1rem 0;
}

th,
td {
  border: 1px solid var(--color-border, #d0d7de);
  padding: 0.35rem 0.6rem;
  vertical-align: top;
}

a.cite {
  text-decoration: none;
  font-size: 0.8125em;
}

.cite-popover {
  position: absolute;
  z-index: 6;
  max-width: 24rem;
  padding: 0.75rem;
  background: var(--color-bg, #fff);
  border: 1px solid var(--color-border, #d0d7de);
  border-radius: var(--radius, 6px);
  box-shadow: 0 4px 16px rgb(0 0 0 / 15%);
  font-size: 0.875rem;
}

@media (min-width: 48em) {
  .term-data dl > div,
  .term-relations dl > div {
    grid-template-columns: 8rem 1fr;
  }

  .detail {
    display: grid;
    grid-template-columns: 16rem 1fr;
    gap: 2rem;
  }

  .toc {
    position: sticky;
    top: 4rem;
    align-self: start;
    max-height: calc(100vh - 5rem);
    overflow: auto;
  }
}

/* 印刷（仕様書 4.4）: A4、上左右15mm・下12mm。検索・印刷ボタン・フッター・広告・CTA・関連記事は出さない */
@page {
  size: A4;
  margin: 15mm 15mm 12mm;
}

@media print {
  body {
    font-size: 10.5pt;
    line-height: 1.6;
  }

  .search,
  .print-button,
  .site-footer,
  .ad-slot,
  .cta,
  .related,
  .skip-link,
  .error-report {
    display: none !important; /* 印刷時はどの指定よりも優先して隠す */
  }

  .site-main {
    padding: 0;
  }

  .term > section {
    margin-bottom: 0.6em;
  }

  /* 印刷の幅（A4から左右の余白を引いた180mm）は 48em より狭く、画面幅の指定ではスマートフォン向けの
     縦積みになる。項目名と値を横に並べ、データ欄が1項目2行になって用紙を使い切るのを防ぐ */
  .term-data dl > div,
  .term-relations dl > div {
    grid-template-columns: 8rem 1fr;
  }

  /* 画面の読みやすさのための行の長さの上限（40em）と余白は、印刷では用紙を余らせるだけなので外す。
     字数の規定を守った原稿が縮小クラスなしでも1枚に収まる余裕を残す（2026-10-09、quantum-entanglement が
     概要解説330字・出典3件で1枚を超え、定期ビルドが止まった） */
  .term {
    max-width: none;
  }

  .site-header__inner,
  .breadcrumb ol {
    padding: 0 0 0.25rem;
  }

  .term h2 {
    font-size: 1.1rem;
    margin: 0.5em 0 0.25em;
  }

  .term p {
    margin: 0.35em 0;
  }

  .term-highlight__headword {
    font-size: 1.5rem;
    margin: 0 0 0.25rem;
  }

  .term-highlight__definition {
    margin: 0.4em 0;
    padding: 0.4rem 0.75rem;
  }

  .citations {
    margin: 0.25em 0;
  }

  /* A4に収まらない語に付ける縮小クラス（概要解説の文字を段階的に下げる。下限9pt） */
  .print-shrink-1 .term-overview {
    font-size: 10pt;
  }

  .print-shrink-2 .term-overview {
    font-size: 9.5pt;
  }

  .print-shrink-3 .term-overview {
    font-size: 9pt;
  }
}
