/* ==========================================================
   土台のスタイル。ここには「デザイン」を書かない。
   入っているのは、次の3つだけ。

   1. 色・フォント・角丸の変数(:root)。brief.md の「デザイン方針」から setup-site が書く
   2. 最小限の下地(box-sizing・body・画像のはみ出し防止・読み上げ専用の文字)
   3. 部品(ギャラリー・キービジュアル・プロフィール(立ち絵とカード)・拡大表示・メニュー・スクロール演出)が
      動くために必要な指定。script.js と assets/js/key-visual.js が、この形を前提に計算する

   依頼者ごとの見た目は、すべて custom.css に書く(このファイルは、テンプレートの修正で上書きされる)。
   ========================================================== */

:root {
  --bg: #fdf7f0;
  --surface: #ffffff;
  --ink: #3b2a1f;
  --muted: #76604f;
  --line: #d0d7de;
  /* 文字色としても使うので、--bg / --surface の上で WCAG AA (4.5:1) を満たす濃さにしてある。
     明るい色に変えるときは、setup-site の palette.mjs で検査する */
  --accent: #a75312;
  --accent-soft: #f6eee7;
  --accent-hover: #8e470f; /* 主色ボタンのホバー。--accent-soft と共に、主色から palette.mjs が計算した値(テストで一致を検査する) */
  --on-accent: #ffffff;
  --font-jp: "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", "Meiryo", sans-serif;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(31,35,40,.06), 0 4px 14px rgba(31,35,40,.06);
  --maxw: 1080px;
}

/* ---------- 下地 ---------- */

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-jp);
  line-height: 1.8;
}

img { max-width: 100%; }

/* 日本語の折り返し: 見出しや箇条書きで、最後の1文字だけ次の行に落ちるのを防ぐ。
   word-break: auto-phrase は文節の切れ目で折り返す(lang="ja" が前提)。対応していないブラウザでは無視され、今までどおり折り返す。
   :where で詳細度を 0 にしてあるので、custom.css で同じ要素に指定すれば、そちらが勝つ。
   ただし要素に直接当てているので、親に書いた word-break(keep-all など)は、ここに挙げた要素には継承されない。変えたいときは、要素に直接書く。
   Why not: text-wrap: pretty(まとめて書く形)は、折り返すかどうか(text-wrap-mode)まで wrap に戻し、親の white-space: nowrap を打ち消す。
   折り返し方だけを変える text-wrap-style を使う。長い段落(p)に auto-phrase を当てると、行末の凹凸が大きくなるので、短い文の要素だけにする */
:where(h1, h2, h3, h4, h5, h6, p, li, dt, dd, figcaption) { text-wrap-style: pretty; }
:where(h1, h2, h3, h4, h5, h6, li, dt, dd, figcaption, .tachie-credit, .design-credit) { word-break: auto-phrase; }

/* 読み上げだけに使う文字(画面には出さない) */
.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;
}

/* ---------- 部品: キービジュアル(assets/js/key-visual.js) ---------- */
/* 横に並べて、1枚ずつ止める。aspect-ratio は、1枚目の画像の実寸に setup-site が合わせる */
.kv { position: relative; aspect-ratio: 900 / 1200; overflow: hidden; }
.kv-track {
  position: absolute; inset: 0; display: flex; margin: 0; padding: 0; list-style: none;
  overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none;
}
.kv-track::-webkit-scrollbar { display: none; }
.kv-slide { position: relative; flex: 0 0 100%; overflow: hidden; scroll-snap-align: start; scroll-snap-stop: always; }
/* 縦横比が違う画像は、切り抜かず全体を見せる。余白は、下に敷いたぼかし画像(.kv-bg)が埋める */
.kv-slide img { position: relative; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.kv-slide .kv-bg {
  position: absolute; inset: 0; object-fit: cover;
  filter: blur(22px);
  transform: scale(1.2); /* ぼかしで縁が薄くなる分を、枠の外へ追い出す */
}
/* 2枚以上のときだけ JS が付ける。touch-action は指定しない(pan-y にすると、横スワイプがブラウザに取られる) */
.kv-track.is-carousel { cursor: grab; }
.kv-track.is-dragging { cursor: grabbing; scroll-snap-type: none; user-select: none; }
.kv-controls[hidden] { display: none; }
/* 操作の置き場所(data-kv-slot)は、1枚だけのとき・JS が動かないときは空のまま残る。枠や背景を付けても見えないよう隠す */
[data-kv-slot]:empty { display: none; }
/* 押せる範囲: 見た目の大きさは変えずに、指で押せる範囲を縦 44px まで広げる(見えない ::after を当たり判定にする)。
   形を描くのに ::after を使わない(使うと、この当たり判定と取り合う。::before は自由に使ってよい)。
   ドットの横は、間隔の半分(--kv-hit-x、既定 4px)までしか広げない。広げすぎると隣のドットと範囲が重なり、
   押したのと違うドットが反応する。ドットの間隔を広げたら、custom.css で --kv-hit-x を間隔の半分にしてよい */
.kv-dot, .kv-nav { position: relative; }
.kv-dot::after, .kv-nav::after { content: ""; position: absolute; top: 50%; translate: 0 -50%; height: max(100%, 44px); }
.kv-dot::after { left: calc(var(--kv-hit-x, 4px) * -1); right: calc(var(--kv-hit-x, 4px) * -1); }
.kv-nav::after { left: 50%; width: max(100%, 44px); translate: -50% -50%; }

/* ---------- 部品: ギャラリー(script.js) ---------- */
/* columns(段組み)だと中身が縦に流れ、新しい順に並べても読み順が変わる。
   grid で左から右へ並べ、段の高さの差は script.js が grid-row-end: span で詰める
   (1行 = 1px として数えるので、grid-auto-rows: 1px は変えない) */
.gallery, .works {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  grid-auto-rows: 1px; column-gap: 22px; row-gap: 0;
  align-items: start; /* 高さを測る前に、行の高さへ引き伸ばされないように */
}
/* 区分けしたギャラリー: 掲載0件の区分は、script.js が hidden にする。custom.css で display を付けても隠れるように */
.gallery-section[hidden] { display: none; }
.art { position: relative; margin: 0; }
.art button { display: block; width: 100%; padding: 0; cursor: zoom-in; border: 0; background: none; }
.art img { width: 100%; height: auto; }

/* ---------- 部品: 作品一覧(本人の作品。script.js) ---------- */
/* 並べ方はギャラリーと同じ(上の .works)。作品名と一言は、縦に積む。
   規則は部品の目印(#works-grid・#voice-list・.commission-*)の下に限る。依頼者の index.html が同じ名前のクラス
   (.status・.contact など)を別の用途で使っていても、テンプレートの修正を取り込んだだけで配置が変わらないように */
.works .work-caption { display: grid; gap: 2px; margin-top: 8px; }
.works .work-note { font-size: .85em; }

/* ---------- 部品: ボイスの見本(script.js) ---------- */
/* 1本 = 1行。再生の部品(<audio>)はブラウザの既定の見た目で、幅だけ行に合わせる */
.voice-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.voice-list .voice { display: grid; gap: 6px; }
.voice-list audio { width: 100%; }
.voice-list .voice-title, .voice-list .voice-note { margin: 0; }

/* ---------- 部品: 依頼ページ(script.js) ---------- */
/* 料金表は横にはみ出さないよう、表の幅を欄に合わせ、長いメニュー名は折り返す。見た目は custom.css で作る */
.commission-status-list, .commission-contacts-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.commission-status-list .status { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.commission-status-list .status-note { flex-basis: 100%; }
.commission-category .price-table { width: 100%; border-collapse: collapse; }
.commission-category .price-table th, .commission-category .price-table td { padding: 8px 6px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.commission-category .price-table td, .commission-category .price-table thead th:last-child { text-align: right; white-space: nowrap; }
/* 行の見出し(メニュー名)の display は変えない(表のセルでなくなり、列がそろわなくなる)。補足だけを改行して置く */
.commission-category .price-table th[scope="row"] { font-weight: inherit; }
.commission-category .price-description { display: block; margin-top: 2px; }
.commission-category .price-options { margin-top: 12px; }
.commission-contacts-list .contact { display: grid; gap: 2px; }
/* 中身が空のとき、JS が目印の要素に hidden を付ける。custom.css で #commission-menus { display: grid } のように
   id で display を書いても消えるよう、id を名指しして、それより強い指定にする */
#voice-list[hidden],
#commission-status[hidden], #commission-menus[hidden], #commission-flow[hidden],
#commission-notes[hidden], #commission-terms[hidden], #commission-contacts[hidden] { display: none; }

/* ---------- 部品: おすすめ動画(YouTube。script.js) ---------- */
/* 枠は 16:9 に固定し、サムネイルと埋め込みの差し替えで高さが変わらないようにする。見た目(枠線・影・再生ボタンの色)は custom.css で作る */
.yt-lite { margin: 0; }
.yt-play, .yt-frame { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; }
.yt-play { position: relative; padding: 0; cursor: pointer; background: #000; }
.yt-play img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* 再生の印(赤い角丸の四角に白い三角)。画像にせず CSS で描き、押せることを示す */
.yt-play::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 68px; height: 48px; translate: -50% -50%;
  background: #ff0033; border-radius: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
.yt-play::after {
  content: ""; position: absolute; left: 50%; top: 50%; translate: -35% -50%;
  border-style: solid; border-width: 11px 0 11px 19px; border-color: transparent transparent transparent #fff;
}

/* ---------- 部品: プロフィール(立ち絵とカード。script.js) ---------- */
/* 立ち絵が無いとき(欄を貼っていない・掲載が0件で隠れた)は、カードだけの1列。
   見えている立ち絵の欄があるときだけ、立ち絵(左)とカード(右)の2列にする。860px 以下では縦に積む。
   右の欄は、立ち絵より低いとき下が空かないよう縦に中央揃え。列の幅・間隔は custom.css で変えてよいが、
   左の列は固定の幅にする(中身に合わせると、衣装を切り替えるたびにクレジットの文字の幅で列の幅が変わり、周りが動く) */
.profile-body { display: grid; grid-template-columns: 1fr; gap: 40px 56px; align-items: center; }
@media (min-width: 861px) {
  .profile-body:has(> .tachie:not([hidden])) { grid-template-columns: 280px minmax(0, 1fr); }
}

/* カードは2枚ずつ横に並べ、同じ行のカードは高さをそろえる(読み仮名のあるカードだけ高くならないように)。
   wide の項目(ファンマーク・ハッシュタグ)は1行全体。スマホ幅(390px ほど)でも2列のままにする(1列だと、
   誕生日・身長のような短い項目が縦に長く並ぶ)。1列にするのは、2列では値が収まらない 359px 以下だけ。
   minmax(0, 1fr) と overflow-wrap は、長い値(URL・英字の名前)で列が押し広げられ、横にはみ出すのを防ぐ */
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; gap: 16px; margin: 0; }
.fact-wide { grid-column: 1 / -1; }
@media (max-width: 359px) { .facts { grid-template-columns: 1fr; } }
.fact dd { margin: 0; overflow-wrap: anywhere; }
.copy-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.copy-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.copy-btn { cursor: pointer; }

/* 立ち絵: タブ・絵・クレジットを同じ幅(絵の枠の幅)の中で中央にそろえる。タブが収まらない幅では折り返す */
.tachie { display: grid; gap: 16px; justify-items: center; width: min(100%, 280px); justify-self: center; }
/* 上の display: grid は、hidden(0件のとき JS が付ける)より強い。消さないと、空の欄が余白として残る */
.tachie[hidden] { display: none; }
.tachie-tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.tachie-tab { cursor: pointer; }
.tachie-item { margin: 0; width: 100%; }
.tachie-item[hidden] { display: none; }
/* 枠(ボタン)の縦横比を固定し、絵は枠の中央に contain で収める。縦横比の違う絵(ちびキャラなど)に
   切り替えても、枠と周りの要素は動かない。影や枠線を付けるなら、この枠に付ける */
.tachie-zoom { display: block; width: 100%; aspect-ratio: 1 / 2; padding: 0; cursor: zoom-in; border: 0; }
.tachie-zoom img { display: block; width: 100%; height: 100%; object-fit: contain; }
.tachie-credit { margin-top: 10px; text-align: center; }
/* 立ち絵は背景が透明な PNG が多い。暗い地に置くと黒い髪や服が溶けるので、枠と拡大表示に明るい地を敷く
   (拡大表示は、立ち絵を開いたときだけ JS が data-group="tachie" を付ける)。色は custom.css で変えてよい */
.tachie-zoom,
.lightbox[data-group="tachie"] img { background: #f4f4f5; }
/* 衣装の切り替えは、控えめなフェードだけ。動きを減らす設定では付けない */
@media (prefers-reduced-motion: no-preference) {
  .tachie-item:not([hidden]) { animation: tachie-fade .3s ease; }
}
@keyframes tachie-fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 部品: デザイン画・三面図(script.js) ---------- */
/* 横長の設定画が多いので、既定は1列で幅いっぱい。並べ方・枠の見た目は custom.css で作る */
.design-sheets { display: grid; gap: 28px; }
.design-sheets[hidden] { display: none; }
.design-item { margin: 0; }
.design-zoom { display: block; width: 100%; padding: 0; border: 0; cursor: zoom-in; background: #fff; }
.design-zoom img { display: block; width: 100%; height: auto; }
.design-credit { margin-top: 10px; text-align: center; }
/* 拡大表示でも、白地の設定画が暗い背景に溶けないよう、白い地を敷く */
.lightbox[data-group="design"] img { background: #fff; }

/* ---------- 部品: 拡大表示(script.js) ---------- */
.lightbox {
  width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; padding: 0;
  border: 0; background: rgba(15,18,22,.94); color: #f1f3f5;
}
.lightbox[open] { display: grid; place-items: center; }
/* 拡大表示の間は、後ろのページをスクロールさせない */
html:has(.lightbox[open]) { overflow: hidden; }
.lightbox::backdrop { background: rgba(0,0,0,.8); }
.lightbox figure { margin: 0; max-width: min(92vw, 1100px); display: grid; justify-items: center; gap: 12px; }
.lightbox img { max-height: 80dvh; width: auto; max-width: 100%; }
/* Why not: 見た目は custom.css の担当だが、前後のボタンは、狭い画面では作品の上に、広い画面では拡大画面の暗い背景の上に乗る。
   白系・半透明の地は白い作品の上で消え、背景と同じ暗い地は広い画面で溶けて白い縁だけが浮く。
   どちらとも違う主色の不透明な地と白い縁で、両方の上で見える状態をここで保証する(色は custom.css で変えてよい) */
.lb-close, .lb-nav {
  position: absolute; z-index: 1; cursor: pointer;
  display: grid; place-items: center; width: 48px; height: 48px; padding: 0;
  color: var(--on-accent); background: var(--accent); border: 2px solid #fff; border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
  font-size: 1.8rem; line-height: 1;
}
.lb-close { top: 16px; right: 16px; }
.lb-prev { left: 16px; top: 50%; translate: 0 -50%; }
.lb-next { right: 16px; top: 50%; translate: 0 -50%; }
/* 1枚しか無いまとまりを開いたとき、JS が hidden を付ける。上の display: grid に負けないよう、属性つきで消す */
.lb-nav[hidden] { display: none; }
/* 狭い画面では、前後のボタンを下端の中央に並べる。左右の中央に置くと、画面いっぱいの作品に重なって絵を隠すため。
   作品の高さは、ボタンとキャプションの分だけ抑える */
@media (max-width: 720px) {
  .lightbox img { max-height: calc(100dvh - 190px); }
  .lb-prev, .lb-next { top: auto; bottom: calc(16px + env(safe-area-inset-bottom)); translate: none; }
  .lb-prev { left: calc(50% - 64px); }
  .lb-next { right: calc(50% - 64px); }
}

/* ---------- フッター: 制作者クレジットのリンク ---------- */
/* 1行の文字のリンクは高さが 20px ほどしかなく、指で押しにくい。キービジュアルのドットと同じく、見えない ::after で
   縦 44px まで押せる範囲を広げる(形を描くのに ::after を使わない)。行の高さや下線の位置は変わらない。
   Why not: 常に 44px にすると、「立ち絵制作:」と「ロゴ制作:」のように行が続くとき(行の間隔は既定で 39px ほど)、
   範囲が重なり、上の行のリンクの下の方を押すと下の行のリンクが開く。1行の高さ + 段落の間隔(1em)を上限にして、隣の行に踏み込まない。
   lh に対応していないブラウザでは、1つ目の 32px が使われる */
.footer-note a { position: relative; }
.footer-note a::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 32px; height: min(44px, 1lh + 1em); translate: 0 -50%; }

/* ---------- 部品: メニュー(script.js) ---------- */
/* 広い画面ではボタンを出さない。狭い画面では、閉じている間 visibility: hidden にして、
   キーボードのフォーカスも受けないようにする(display で切ると、開閉の動きが付けられない) */
.nav-toggle { display: none; }

@media (max-width: 720px) {
  .js .nav-toggle { display: grid; place-items: center; cursor: pointer; }
  .js .topbar nav {
    position: absolute; top: 100%; left: 0; right: 0;
    visibility: hidden; opacity: 0; pointer-events: none;
    transition: opacity .2s, visibility .2s;
  }
  .js .topbar.is-open nav { visibility: visible; opacity: 1; pointer-events: auto; }
}

/* ---------- 部品: スクロールで現れる演出(script.js) ---------- */
/* JS が動く環境でだけ隠す(.js が付く)。JS が無ければ、最初から見えている */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.js .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
}
