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

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

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

:root {
  --bg: #f8f6f0;
  --surface: #ffffff;
  --ink: #1f2433;
  --muted: #5a6275;
  --line: #d0d7de;
  /* 文字色としても使うので、--bg / --surface の上で WCAG AA (4.5:1) を満たす濃さにしてある。
     明るい色に変えるときは、setup-site の palette.mjs で検査する */
  --accent: #34507a;
  --accent-soft: #ebeef2;
  --accent-hover: #2c4468; /* 主色ボタンのホバー。--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%; }

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

/* ---------- 部品: ギャラリー(script.js) ---------- */
/* columns(段組み)だと中身が縦に流れ、新しい順に並べても読み順が変わる。
   grid で左から右へ並べ、段の高さの差は script.js が grid-row-end: span で詰める
   (1行 = 1px として数えるので、grid-auto-rows: 1px は変えない) */
.gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  grid-auto-rows: 1px; column-gap: 22px; row-gap: 0;
  align-items: start; /* 高さを測る前に、行の高さへ引き伸ばされないように */
}
.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; }

/* ---------- 部品: おすすめ動画(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行全体。スマホ幅では1列 */
.facts { display: grid; grid-template-columns: repeat(2, 1fr); align-items: stretch; gap: 16px; margin: 0; }
.fact-wide { grid-column: 1 / -1; }
@media (max-width: 768px) { .facts { grid-template-columns: 1fr; } }
.fact dd { margin: 0; }
.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) ---------- */
.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); }
}

/* ---------- 部品: メニュー(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; }
}
