/* MameChara docs — 設定画面のスクリーンショットが主役なので、
   紙面は静かにして、画像に枠と余白を与えることに寄せている */

:root {
  color-scheme: light dark;

  --ink:        oklch(27% 0.030 55);
  --ink-soft:   oklch(47% 0.032 58);
  --ink-faint:  oklch(63% 0.028 62);
  --paper:      oklch(96.8% 0.016 80);
  --paper-2:    oklch(94% 0.026 78);
  --line:       oklch(87% 0.026 74);
  --line-soft:  oklch(91.5% 0.020 76);

  --accent:     oklch(53% 0.130 52);
  --accent-2:   oklch(64% 0.145 58);
  --accent-wash: oklch(95% 0.040 72);

  /* 注意書きはアクセントと混ざらないよう赤茶寄りに置く */
  --warn:       oklch(49% 0.150 33);
  --warn-wash:  oklch(96% 0.038 40);

  --shot-mat:   oklch(91.5% 0.022 76);

  --text-base:  1.0625rem;
  --measure:    46rem;
  --shot:       35rem;   /* スクリーンショットの原寸 560px */
  --radius:     10px;

  /* 見出しとキャッチは丸ゴシック。明朝のような固い書体は使わない */
  --display: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "M PLUS Rounded 1c",
             "Yu Gothic UI", Meiryo, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
          "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Roboto Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink:        oklch(93% 0.016 78);
    --ink-soft:   oklch(76% 0.022 72);
    --ink-faint:  oklch(59% 0.022 66);
    --paper:      oklch(20% 0.018 52);
    --paper-2:    oklch(24% 0.024 56);
    --line:       oklch(34% 0.026 60);
    --line-soft:  oklch(28% 0.021 57);

    --accent:     oklch(81% 0.115 70);
    --accent-2:   oklch(73% 0.130 62);
    --accent-wash: oklch(28% 0.045 58);

    --warn:       oklch(83% 0.105 45);
    --warn-wash:  oklch(29% 0.042 38);

    --shot-mat:   oklch(27% 0.020 57);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--text-base);
  line-height: 1.85;
  letter-spacing: 0.01em;

  /* 日本語を文節で折り返す。「〜できま」で切れて次行が「す。」になるのを防ぐ。
     未対応のブラウザでは通常の折り返しに戻るだけ */
  word-break: auto-phrase;
  line-break: strict;
  text-wrap: pretty;
}

/* ── 上部ナビ ── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in oklab, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}

.topbar-inner {
  max-width: 84rem;
  margin: 0 auto;
  padding: 0.35rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.brand {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--ink);
  font-size: 1rem;
  flex: none;
}

.brand span { color: var(--accent); }

/* 項目の幅を揃える。文字数がばらばらでも等分に並ぶ */
.topbar nav {
  flex: 1;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  font-family: var(--display);
  font-size: 0.8125rem;
}

.topbar nav a {
  color: var(--ink-soft);
  text-decoration: none;
  text-align: center;
  padding: 0.55rem 0.25rem 0.45rem;
  border-bottom: 2px solid transparent;
  transition: color 140ms ease, border-color 140ms ease;
  white-space: nowrap;
}

.topbar nav a:hover { color: var(--ink); border-bottom-color: var(--line); }
.topbar nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* 右上の購入ボタン。読むページの並びとは別物なので、
   ナビの下線ではなく塗りで区別する */
.buy {
  flex: none;
  font-family: var(--display);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--paper);
  background: var(--accent);
  border-radius: 999px;
  padding: 0.4rem 0.95rem 0.42rem;
  white-space: nowrap;
  display: inline-flex;
  align-items: baseline;
  gap: 0.3em;
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.buy:hover {
  color: var(--paper);
  background: var(--accent-2);
  transform: translateY(-1px);
  box-shadow: 0 3px 12px -4px color-mix(in oklab, var(--accent) 60%, transparent);
}

.buy .arrow { font-size: 0.85em; opacity: 0.8; }

@media (max-width: 48rem) {
  .topbar-inner { flex-wrap: wrap; gap: 0.4rem 1rem; padding-bottom: 0.2rem; }
  .brand { padding: 0.35rem 0; order: 0; }
  /* 折り返すときは1段目にブランドと購入ボタン、2段目にナビ */
  .buy { order: 1; margin-left: auto; }
  .topbar nav {
    order: 2;
    flex-basis: 100%;
    grid-auto-flow: row;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.1rem;
    font-size: 0.8125rem;
  }
  /* 狭いところでは「ウィンドウのつくり」が1行に収まらないので折り返させる。
     nowrap のままだと枠から溢れる */
  .topbar nav a { white-space: normal; line-height: 1.5; }
}

@media (max-width: 30rem) {
  .topbar nav { grid-template-columns: repeat(2, 1fr); font-size: 0.78rem; }
  .buy { font-size: 0.78rem; padding: 0.35rem 0.8rem 0.37rem; }
}

/* ── 本文 ── */

main {
  max-width: 84rem;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 6rem;
}

.prose { max-width: var(--measure); }

h1 {
  font-family: var(--display);
  text-wrap: balance;
  font-size: clamp(1.7rem, 1.2rem + 1.9vw, 2.5rem);
  line-height: 1.3;
  letter-spacing: 0.01em;
  margin: 0 0 0.6rem;
  font-weight: 600;
}

.lede {
  font-family: var(--display);
  max-width: var(--measure);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.85;
  color: var(--ink-soft);
  margin: 0 0 3rem;
}

h2 {
  font-family: var(--display);
  text-wrap: balance;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 4.5rem 0 0.4rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--line);
  max-width: var(--measure);
}

h3 {
  font-family: var(--display);
  text-wrap: balance;
  font-size: 1.125rem;
  font-weight: 700;
  margin: 2.75rem 0 0.3rem;
  letter-spacing: 0.02em;
}

h3 .num {
  display: inline-block;
  min-width: 1.6em;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.85em;
}

p, ul, ol, table { max-width: var(--measure); }
p { margin: 0.9rem 0; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-2); }

ul, ol { padding-left: 1.4rem; }
li { margin: 0.35rem 0; }
li::marker { color: var(--ink-faint); }

code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--paper-2);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

kbd {
  font-family: var(--sans);
  font-size: 0.85em;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.1em 0.45em;
  white-space: nowrap;
}

strong { font-weight: 700; }

/* ── スクリーンショット ── */

figure {
  margin: 1.6rem 0 2.2rem;
  max-width: var(--shot);
}

figure.wide { max-width: var(--measure); }

figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--shot-mat);
}

/* 画像は原寸 560px。縮めると Unity の文字が読めないので、
   クリックで原寸を開けるようにしている */
figure a {
  display: block;
  border-radius: var(--radius);
  cursor: zoom-in;
}

figure a img { transition: border-color 160ms ease, box-shadow 160ms ease; }

figure a:hover img,
figure a:focus-visible img {
  border-color: var(--accent);
  box-shadow: 0 2px 18px -6px color-mix(in oklab, var(--accent) 55%, transparent);
}

figcaption {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--ink-faint);
  padding-left: 0.9rem;
  border-left: 2px solid var(--line);
}

/* 画像と文章を並べる。狭い画面では縦に落ちる。
   短い側を中央に置くと見出しが図の中ほどまで下がってしまうので、上端で揃える */
.split {
  display: grid;
  grid-template-columns: minmax(24rem, 1fr) minmax(0, var(--shot));
  gap: 3rem;
  align-items: start;
  max-width: 84rem;
}

.split > figure { margin: 0.4rem 0 0; max-width: none; }
.split .prose { max-width: none; }
.split .prose p, .split .prose ul, .split .prose ol, .split .prose table { max-width: none; }

@media (max-width: 68rem) {
  .split { grid-template-columns: minmax(0, 1fr); gap: 0.5rem; }
  .split > figure { max-width: var(--shot); }
}

/* 短いブロックは balance の方が文節で揃う。
   pretty だと行を詰めきろうとして「部分は上/書きされません」のように
   語の途中で切れることがある（実測して確かめた） */
.note p, .callout p, figcaption, .path p, .faq summary, .next .why, dl.terms dd {
  text-wrap: balance;
}

/* ── 注記 ── */

.note, .callout {
  margin: 1.5rem 0;
  padding: 0.95rem 1.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--paper-2);
  max-width: var(--measure);
  font-size: 0.95rem;
  line-height: 1.8;
}

.note > :first-child, .callout > :first-child { margin-top: 0; }
.note > :last-child, .callout > :last-child { margin-bottom: 0; }

.callout {
  border-color: color-mix(in oklab, var(--warn) 35%, var(--line));
  background: var(--warn-wash);
}

.callout .label, .note .label {
  display: block;
  font-size: 0.775rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  margin-bottom: 0.2rem;
  color: var(--warn);
}

.note .label { color: var(--accent); }

/* ── 入口カード ── */

.paths {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15.5rem, 1fr));
  gap: 1.25rem;
  max-width: 84rem;
  margin: 1.75rem 0 1rem;
}

.path {
  display: block;
  padding: 1.3rem 1.35rem 1.45rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  text-decoration: none;
  color: inherit;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.path:hover {
  border-color: var(--accent);
  background: var(--accent-wash);
  transform: translateY(-2px);
}

.path .who {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.11em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.path .title {
  display: block;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 0.4rem;
}

.path p { margin: 0; font-size: 0.9rem; line-height: 1.75; color: var(--ink-soft); }

/* ── 表 ── */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.925rem;
  margin: 1.4rem 0 2rem;
  display: block;
  overflow-x: auto;
}

table.full { max-width: var(--measure); }

th, td {
  text-align: left;
  vertical-align: top;
  padding: 0.6rem 0.9rem 0.6rem 0;
  border-bottom: 1px solid var(--line-soft);
  line-height: 1.7;
}

th {
  font-size: 0.775rem;
  letter-spacing: 0.09em;
  color: var(--ink-faint);
  font-weight: 700;
  border-bottom-color: var(--line);
  white-space: nowrap;
}

td:first-child { white-space: nowrap; padding-right: 1.4rem; font-weight: 600; }

/* ── 手順 ── */

.steps { counter-reset: step; list-style: none; padding-left: 0; max-width: 84rem; }

.steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 3rem;
  margin: 0 0 3rem;
}

.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.15rem;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1;
}

/* 番号の丸と見出しの高さを合わせる。図がある項目は見出しが
   .split > .prose の中に入るので、そちらにも同じ指定が必要 */
.steps > li > h3:first-child,
.steps > li > .split > .prose > h3:first-child,
.steps > li > .split > .prose > h2:first-child { margin-top: 0.1rem; }

/* 手順の中では見出しを番号の高さに合わせる。中央寄せにすると番号だけが
   ぽつんと上に残って、どの見出しの番号なのか分からなくなる */
.steps .split { align-items: start; }

/* ── 用語の定義リスト ── */

dl.terms { max-width: var(--measure); margin: 1.4rem 0 2rem; }
dl.terms dt { font-weight: 700; margin-top: 1.2rem; }
dl.terms dd { margin: 0.2rem 0 0; color: var(--ink-soft); }

/* ── 次に読む ── */

.next {
  margin-top: 5.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--line);
  max-width: 84rem;
}

.next .label {
  display: block;
  font-size: 0.775rem;
  letter-spacing: 0.11em;
  color: var(--ink-faint);
  font-weight: 700;
  margin-bottom: 0.9rem;
}

.next ul { list-style: none; padding: 0; max-width: none; display: grid; gap: 0.5rem; }
.next a { font-weight: 600; }
.next .why { color: var(--ink-faint); font-weight: 400; font-size: 0.9rem; }

footer {
  border-top: 1px solid var(--line-soft);
  padding: 2rem 1.5rem 3rem;
  color: var(--ink-faint);
  font-size: 0.85rem;
}

footer .inner {
  max-width: 84rem;
  margin: 0 auto;
  display: flex;
  gap: 0.6rem 1.5rem;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
}

footer a { font-weight: 600; }

/* ── 目次（リファレンス用） ── */

.toc {
  max-width: var(--measure);
  margin: 0 0 3rem;
  padding: 1.1rem 1.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
}

.toc .label {
  display: block;
  font-size: 0.775rem;
  letter-spacing: 0.11em;
  color: var(--ink-faint);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.toc ul { margin: 0; padding-left: 1.1rem; columns: 2; column-gap: 2rem; font-size: 0.925rem; }

@media (max-width: 34rem) {
  .toc ul { columns: 1; }
  main { padding-top: 2.5rem; }
}

/* ── よくある症状 ── */

.faq { max-width: var(--measure); }

.faq details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 0.6rem 0;
  background: var(--paper-2);
  overflow: hidden;
}

.faq summary {
  font-family: var(--display);
  cursor: pointer;
  padding: 0.85rem 1.15rem;
  font-weight: 600;
  list-style: none;
  display: flex;
  gap: 0.7rem;
  align-items: baseline;
  transition: background 140ms ease;
}

.faq summary::-webkit-details-marker { display: none; }
.faq summary:hover { background: var(--accent-wash); }

.faq summary::before {
  content: "＋";
  color: var(--accent);
  font-size: 0.85em;
  flex: none;
}

.faq details[open] summary::before { content: "－"; }
.faq details[open] summary { border-bottom: 1px solid var(--line-soft); }

.faq .body { padding: 0.3rem 1.15rem 1rem; font-size: 0.95rem; }
.faq .body > :first-child { margin-top: 0.7rem; }
.faq .body > :last-child { margin-bottom: 0; }
.faq .body p, .faq .body ul, .faq .body ol { max-width: none; }
