/* 紙と墨、差し色に朱。読むことだけに集中できる一段組。 */

:root {
  --bg: #f6f3ea;
  --surface: #fffdf7;
  --ink: #1d1b17;
  --muted: #6d675c;
  --line: #ddd6c6;
  --accent: #a6311f;
  --mark: rgb(166 49 31 / 0.16);
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  --sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16150f;
    --surface: #1f1d16;
    --ink: #ebe6d9;
    --muted: #a29b8b;
    --line: #34312a;
    --accent: #e27861;
    --mark: rgb(226 120 97 / 0.24);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1rem/1.9 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration-color: var(--line); text-underline-offset: 0.25em; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

main { max-width: 41rem; margin: 0 auto; padding: 0 1.1rem 5rem; }

/* ---- ロゴと検索欄 ---- */

.brand {
  font: 600 1.15rem/1 var(--serif);
  letter-spacing: 0.06em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand::after { /* 朱の落款 */
  content: "";
  display: inline-block;
  width: 0.3em;
  height: 0.3em;
  margin-left: 0.1em;
  background: var(--accent);
  border-radius: 1px;
}
.brand:hover { color: var(--ink); }

.search { display: flex; flex: 1; align-items: stretch; border-bottom: 1px solid var(--ink); }
.search input {
  flex: 1;
  min-width: 0;
  padding: 0.3rem 0.1rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  outline: none;
  appearance: none;
}
.search input::placeholder { color: var(--muted); opacity: 0.65; }
.search input::-webkit-search-cancel-button { display: none; }
/* 虫眼鏡（探す）とサイコロ（おまかせ）。色は文字と同じ墨の濃淡だけ */
.search button {
  display: grid;
  place-items: center;
  padding: 0 0.45rem;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.search button:last-child { margin-right: -0.3rem; }
.search button:hover, .search button:focus-visible { color: var(--ink); }
.search svg { display: block; width: 1.15rem; height: 1.15rem; }
.search:focus-within { border-bottom-color: var(--ink); box-shadow: 0 1px 0 var(--ink); }
.search.busy {
  border-image: linear-gradient(90deg, var(--line) 0 35%, var(--ink) 50%, var(--line) 65% 100%) 1;
  animation: seek 1.1s linear infinite;
  box-shadow: none;
}
.search.busy button { opacity: 0.4; }
@keyframes seek {
  from { border-image-source: linear-gradient(90deg, var(--ink) -30%, var(--line) 0% 100%); }
  50% { border-image-source: linear-gradient(90deg, var(--line) 0 35%, var(--ink) 50%, var(--line) 65% 100%); }
  to { border-image-source: linear-gradient(90deg, var(--line) 0% 100%, var(--ink) 130%); }
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  max-width: 41rem;
  margin: 0 auto;
  padding: 1.1rem 1.1rem 0;
}
.topbar .search { font-size: 0.92rem; border-bottom-color: var(--line); }

/* ---- トップ ---- */

.home { padding-top: clamp(3rem, 16vh, 9rem); }
.brand-big { display: block; margin: 0; font-size: 2.5rem; }
.tagline { margin: 0.9rem 0 2.4rem; color: var(--muted); font-family: var(--serif); letter-spacing: 0.04em; }
.search-big { font: 1.45rem/1.6 var(--serif); }
.search-big input { padding: 0.45rem 0.1rem; }
.search-big button { padding: 0 0.6rem; }
.search-big svg { width: 1.5rem; height: 1.5rem; }

.problem { margin: 0.9rem 0 0; color: var(--accent); font-size: 0.92rem; }

.chip {
  display: inline-block;
  margin: 0.2rem 0 0 0.45rem;
  padding: 0.05rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }

/* ---- 判例の一覧 ---- */

.list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.list a { display: block; padding: 0.85rem 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.list-title { display: block; font: 600 1.06rem/1.55 var(--serif); }
.list-meta { display: block; margin-top: 0.1rem; color: var(--muted); font-size: 0.82rem; line-height: 1.6; }
.list a:hover .list-title { color: var(--accent); }
.list a:hover .list-meta { color: var(--muted); }
.badge {
  margin-left: 0.6rem;
  padding: 0.08rem 0.5rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--accent);
  font: 600 0.68rem var(--sans);
  letter-spacing: 0.06em;
  vertical-align: 0.18em;
  white-space: nowrap;
}

.results { padding-top: 2.6rem; }
.conditions { margin: 0 0 0.2rem; font-family: var(--serif); font-size: 1.2rem; }
.conditions span { margin-left: 0.6rem; color: var(--muted); font: 0.85rem var(--sans); }
.hint { margin: 0 0 1.2rem; color: var(--muted); font-size: 0.85rem; }
.empty { margin: 1.5rem 0; color: var(--muted); }
.results .list { margin-top: 1.2rem; }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.6rem; font-size: 0.9rem; }
.pager a:only-child:last-child { margin-left: auto; }

/* ---- 判例ページ ---- */

.case { padding-top: 3rem; }
.citation { display: flex; flex-wrap: wrap; column-gap: 0.9em; margin: 0; color: var(--muted); font-size: 0.82rem; letter-spacing: 0.03em; line-height: 1.7; }
.case h1 { margin: 0.5rem 0 0; font: 600 clamp(1.55rem, 5.2vw, 2.05rem)/1.45 var(--serif); letter-spacing: 0.02em; }
.gist { margin: 1rem 0 0; font-size: 1.04rem; }
.gist:empty, .tags:empty { display: none; }
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 1rem 0 0; }
.tags span { padding: 0 0.6rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 0.75rem; }

.status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1.6rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.status::before {
  content: "";
  flex: none;
  width: 0.8em;
  height: 0.8em;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.status-off { display: block; padding: 0.8rem 1rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.status-off::before { content: none; }
.status code { font-size: 0.92em; }
@keyframes spin { to { transform: rotate(1turn); } }

/* 1分 / 5分 の切り替え。幅を左右に二分し、読み進めても上端に留まる */
.levels-nav {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 2rem 0 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.levels-nav a {
  margin-bottom: -1px;
  padding: 0.55rem 0 0.45rem;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
/* 下を流れる本文が、線の直下でぷつりと切れて見えないようにぼかす */
.levels-nav::after {
  content: "";
  position: absolute;
  inset: calc(100% + 1px) 0 auto;
  height: 0.9rem;
  background: linear-gradient(var(--bg), transparent);
  pointer-events: none;
}
.levels-nav a:hover { color: var(--ink); }
.case[data-level="quick"] .levels-nav [data-set-level="quick"],
.case[data-level="detail"] .levels-nav [data-set-level="detail"] { border-bottom-color: var(--ink); color: var(--ink); }

.levels { margin-top: 0.6rem; scroll-margin-top: 3.2rem; }
.levels > section { display: none; }
.case[data-level="quick"] .levels > [data-l="quick"],
.case[data-level="detail"] .levels > [data-l="detail"] { display: block; }

.prose h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 2.2rem 0 0.4rem;
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.6;
  letter-spacing: 0.06em;
  scroll-margin-top: 3.6rem; /* 上端に留まる 1分 / 5分 のバーに隠れない位置で止める */
}
/* 押せる範囲は広く、見出しの行の高さは変えない */
.prose h2 .icon-btn { margin: -0.5rem -0.7rem -0.5rem 0; }
.prose p { margin: 0 0 0.9rem; text-align: justify; }
.prose ul { margin: 0 0 0.9rem; padding-left: 1.25rem; }
.prose li { margin-bottom: 0.3rem; }
.prose li::marker { color: var(--accent); }
.prose strong { font-weight: 600; background: linear-gradient(transparent 60%, var(--mark) 60%); }
.case[data-pending] .prose:empty::after { content: "このあと作成します…"; display: block; margin-top: 2rem; color: var(--muted); font-size: 0.9rem; }

.official { margin-top: 3.2rem; border-top: 1px solid var(--line); padding-top: 1rem; font-size: 0.88rem; }
.official summary { color: var(--muted); cursor: pointer; }
.official dl { margin: 0.8rem 0 0; }
.official dt { margin-top: 0.8rem; color: var(--muted); font-size: 0.75rem; letter-spacing: 0.08em; }
.official dd { margin: 0; white-space: pre-line; }
.official p { margin: 1rem 0 0; }

.case-foot { margin-top: 1.6rem; color: var(--muted); font-size: 0.8rem; }
/* 枠も塗りもないアイコンのボタン（見出しの右のリンク、ページ下部のシェアなど） */
.icon-btn {
  display: grid;
  flex: none;
  place-items: center;
  padding: 0.7rem;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover, .icon-btn.done { color: var(--ink); }
.icon-btn svg { display: block; width: 1.15rem; height: 1.15rem; }
.icon-btn .icon-check, .icon-btn.done .icon-link { display: none; }
.icon-btn.done .icon-check { display: block; }

.share { display: flex; flex-wrap: wrap; align-items: center; margin: 0 0 0 -0.7rem; }
.disclaimer { margin: 0.9rem 0 0; }

@media (max-width: 30rem) {
  .topbar { gap: 1rem; }
  .search-big { font-size: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .status::before { animation: none; }
  html { scroll-behavior: auto; }
}
