/* 月明洞写真展 予約システム — 共通スタイル
   スマートフォンを基準に書き、幅が広いときだけ横に広げる（詳細設計.md §8.1） */

:root {
  --bg: #faf8f5;
  /* 写真の上に重ねる白いベール。
     0.78 は実測で決めた値。写真の暗い側1%の上でも、本文で11.0:1、
     補助文字で5.0:1 のコントラストが出る（AA基準は4.5:1）。
     これ以上薄くすると補助文字が基準を下回る。 */
  --veil: rgba(255, 255, 255, 0.78);
  /* カードは少しだけ透かして、下の写真の気配を残す */
  --surface: rgba(255, 255, 255, 0.84);
  --surface-solid: #ffffff;
  --surface-2: rgba(243, 240, 235, 0.82);
  /* 背景が写真なので、文字は通常より濃くして読みやすさを確保する。
     補助文字は写真の暗部に重なることがあるため、さらに一段濃くしてある。 */
  --text: #1a1815;
  --text-muted: #4e463c;
  --border: rgba(120, 105, 85, 0.22);
  --accent: #5c4a33;
  --accent-text: #ffffff;
  --accent-soft: rgba(240, 235, 226, 0.9);
  --ok: #2f6b4f;
  --warn: #8a5a1f;
  --error: #9b3030;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(31, 29, 26, 0.08);
  --maxw: 760px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #171614;
    --veil: rgba(18, 17, 15, 0.82);
    --surface: rgba(33, 31, 28, 0.86);
    --surface-solid: #211f1c;
    --surface-2: rgba(42, 39, 36, 0.84);
    --text: #f1ede6;
    --text-muted: #afa89d;
    --border: rgba(200, 180, 150, 0.22);
    --accent: #c3ac8c;
    --accent-text: #1f1d1a;
    --accent-soft: #2e2a24;
    --ok: #7fc3a0;
    --warn: #d6a35e;
    --error: #e08585;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme='dark'] {
  --bg: #171614;
  --veil: rgba(18, 17, 15, 0.82);
  --surface: rgba(33, 31, 28, 0.86);
  --surface-solid: #211f1c;
  --surface-2: rgba(42, 39, 36, 0.84);
  --text: #f1ede6;
  --text-muted: #afa89d;
  --border: rgba(200, 180, 150, 0.22);
  --accent: #c3ac8c;
  --accent-text: #1f1d1a;
  --accent-soft: #2e2a24;
  --ok: #7fc3a0;
  --warn: #d6a35e;
  --error: #e08585;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

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

/* 背景は写真の上にベールを重ねる二層構造。
   background-attachment: fixed はスマートフォンで描画が重くなるため、
   固定配置の疑似要素で同じ見た目を作る。 */
body::before,
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
}
body::before {
  background: url('../img/background.webp') center center / cover no-repeat;
  z-index: -2;
}
body::after {
  background: var(--veil);
  z-index: -1;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Noto Sans JP',
    'Yu Gothic', Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.75;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px 64px;
}

/* 管理画面は読み物ではなく道具。枠28行の表を横に送らず見たいので、
   参加者向けのページ（760px）より広くとる（2026年10月31日）。
   max-width なので、画面がこれより狭ければそのぶん縮む。 */
body.admin { --maxw: 1200px; }

/* ------------------------------------------------------------------ 見出し */

h1, h2, h3 {
  font-family: 'Hiragino Mincho ProN', 'Yu Mincho', serif;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.02em;
}

h1 { font-size: 1.75rem; margin: 0 0 8px; }
h2 { font-size: 1.3rem; margin: 40px 0 12px; }
h3 { font-size: 1.05rem; margin: 24px 0 8px; }

.lead { color: var(--text-muted); white-space: pre-line; margin: 0 0 8px; }
.period { color: var(--accent); font-weight: 600; margin: 0 0 24px; }

/* 文言のなかに書かれた URL は自動でリンクになる（common.js の setTextWithLinks）。
   本文と地続きなので、下線を付けて押せると分かるようにする。
   長いURLが画面からはみ出さないよう、途中でも折り返す。 */
.lead a, .pre a, p[data-text] a {
  color: var(--accent);
  text-decoration: underline;
  overflow-wrap: anywhere;
}

/* -------------------------------------------------------------------- 外枠 */

header.site {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 20px 0 16px;
  margin-bottom: 28px;
}
header.site .wrap { padding-bottom: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 0.85rem;
}
.topbar nav { display: flex; gap: 14px; flex-wrap: wrap; }
.topbar a { color: var(--text-muted); text-decoration: none; }
.topbar a:hover { color: var(--text); text-decoration: underline; }
.topbar .who { color: var(--text-muted); }

/* ------------------------------------------------------------------ カード */

.card {
  background: var(--surface);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.card--muted { background: var(--surface-2); box-shadow: none; }

/* ---------------------------------------------------------------- 参加費 */

/* 参加費は申し込むかどうかを決める材料なので、ほかの説明文に埋もれさせない。
   箱に入れて左に色の線を引き、金額だけ大きくする。
   注記（program.*.feeNote）は文言編集タブで変えられるが、
   フォームに出す金額は枠の feeYen から計算するので数字はずれない。 */
.fee {
  margin: 12px 0 0;
  padding: 10px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}
.fee__text {
  display: block;
  font-size: 1.02rem;
  font-weight: 600;
}
.fee__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 8px;
}
.fee__amount {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}
.fee__note {
  display: block;
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* フォームのなかでは送信ボタンの直前に置くので、上下に余白をとる */
.fee--form { margin: 0 0 18px; }

/* 一覧のなかの一行として出すとき（マイページ）は、金額だけ色と大きさを変える */
.fee__inline { color: var(--accent); font-size: 1.1rem; }

.notice {
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 0 20px;
  white-space: pre-line;
}
.notice--warn { border-left: 3px solid var(--warn); }
.notice--error { border-left: 3px solid var(--error); color: var(--error); }

/* 「全ての枠で事前予約制です」。見落とされると当日受付で困るので、
   受付開始前の案内と同じ強さで出す（2026年10月31日） */
.notice--booking {
  border-left: 3px solid var(--accent);
  font-weight: 600;
}

/* 会場でのお知らせ。予約そのものの案内ではないので、
   事前予約制の案内より一段弱くする（太字にしない）。
   1行目は見出しとして書くので、そこだけ太らせる。 */
.notice--venue {
  border-left: 3px solid var(--text-muted);
}
.notice--venue::first-line {
  font-weight: 600;
}

/* -------------------------------------------------------- 無料枠カレンダー */

.calendar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 620px) {
  .calendar { grid-template-columns: repeat(3, 1fr); }
}

.day {
  background: var(--surface);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.day__label { font-weight: 600; margin-bottom: 6px; }
.day__times { list-style: none; margin: 0; padding: 0; font-size: 0.9rem; color: var(--text-muted); }
.day__times li { padding: 1px 0; }
.day__special {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 0.85rem;
}
.day__special span { display: block; color: var(--accent); }

/* ------------------------------------------------ 一般入場（無料・要予約） */

/* 1日ぶんを1枚にまとめ、その中に1時間ごとの行を並べる。
   列の幅は中身で決める — 時刻・予約数・ボタンが1行に収まる幅が要るため。 */
.freedays {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 10px;
}

.freeslots { list-style: none; margin: 0; padding: 0; }

.freeslot {
  display: flex;
  align-items: center;
  /* 帯を行の下に敷くため、折り返しを許す（帯は flex-basis 100%） */
  flex-wrap: wrap;
  /* 時刻・人数・言葉・ボタンを 375px に収めるため、間隔は詰めてある */
  gap: 6px;
  padding: 6px 0;
  border-top: 1px dashed var(--border);
}
.freeslot:first-child { border-top: none; }
.freeslot__time { font-size: 0.95rem; white-space: nowrap; }
/* ボタンと予約数を右端に寄せ、時刻だけ左に残す */
.freeslot__action { margin-left: auto; }
.freeslot__action .btn--small { white-space: nowrap; }

/* 混み具合。定員ではなく目安なので、数を色で添えるだけにとどめる。
   区切りは 〜20名／21〜30名／31名〜（common.js の crowdClass と揃えること） */
.crowd {
  display: inline-block;
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.crowd--low { color: var(--ok); }
.crowd--mid { color: var(--warn); }
.crowd--high { color: var(--error); }

/* 数字の右に添える言葉（余裕あり／やや混雑／混雑）。
   色は crowd--* から受け取るので、ここでは大きさだけ決める。 */
.crowdword {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  margin-left: -2px;
}

/* 混み具合の帯。行の下に敷くので、flex の折り返しで全幅を取らせる。
   色は文字の pill と同じ（currentColor をそのまま使う）。 */
.crowdbar {
  flex: 1 1 100%;
  height: 4px;
  margin-top: 2px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
}
.crowdbar span {
  display: block;
  height: 100%;
  background: currentColor;
}

/* ---------------------------------------------------------------- 枠の一覧 */

.slot {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.slot__main { flex: 1 1 240px; min-width: 0; }
.slot__label { font-weight: 600; }
.slot__when { color: var(--text-muted); font-size: 0.95rem; }
.slot__side { text-align: right; flex: 0 0 auto; }

/* 狭い画面では、残数とボタンを右寄せにせず左に揃えて全幅にする。
   そのままだと内容幅の箱が左端に来て、中の文字だけ右寄せになり不揃いに見える。 */
@media (max-width: 560px) {
  .slot__side {
    flex: 1 1 100%;
    text-align: left;
    margin-top: 4px;
  }
}

.slot__fee { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 4px; }
.slot__fee strong { color: var(--accent); font-size: 1.05rem; }

.remaining { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 6px; }
.remaining strong { color: var(--text); font-size: 1.15rem; }

.badge {
  display: inline-block;
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge--full { color: var(--error); }
.badge--ended { color: var(--text-muted); }
.badge--open { color: var(--ok); }
.badge--mine { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* 埋まり具合を目で見える形に。定員30以下は席をひとつずつ、それ以上は帯で */
.seats {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 10px;
}
.seats i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.seats i.on {
  background: var(--accent);
  border-color: var(--accent);
}
.bar {
  height: 6px;
  margin-top: 10px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}
/* 表の中では帯を使う。行の高さに合わせて上下の余白を詰める */
td .bar { margin: 0; }
.bar.is-full span { background: var(--error); }

/* ---------------------------------------------------------------- フォーム */

.field { margin-bottom: 18px; }
.field > label,
.field__title {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}
.field__hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 4px 0 6px;
  white-space: pre-line;
}
.required::after { content: ' ※'; color: var(--error); font-weight: normal; }

input[type='text'],
input[type='number'],
input[type='email'],
input[type='password'],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  /* 入力欄だけは透かさない。読み書きのしやすさを優先する */
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 8px;
}
textarea { min-height: 90px; resize: vertical; }

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.row > * { flex: 1 1 140px; min-width: 0; }

.sum {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 6px;
}
.sum--bad { color: var(--error); }

/* ---------------------------------------------------------------- ボタン */

button, .btn {
  font-family: inherit;
  font-size: 1rem;
  padding: 11px 20px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  min-height: 44px;
  line-height: 1.3;
}
button:hover:not(:disabled), .btn:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.5; cursor: default; }

.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn--danger { background: transparent; color: var(--error); border-color: var(--error); }
.btn--small { font-size: 0.875rem; padding: 7px 12px; min-height: 36px; }

/* 指で操作する端末では小さいボタンも押しやすい大きさにする。
   会場では管理画面をスマートフォンから使う（§7.3）。 */
@media (pointer: coarse) {
  .btn--small { min-height: 44px; padding: 10px 16px; }
}
.btn--wide { width: 100%; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

/* ----------------------------------------------------------------- 折り畳み */

.collapsible { border-top: 1px solid var(--border); margin-top: 24px; padding-top: 20px; }
.hidden { display: none !important; }

/* 文言編集タブ：キー名を等幅で小さく出す */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  opacity: 0.85;
}

/* -------------------------------------------------------------------- 表 */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* 列が多い表は、幅が足りないときに潰さず横に送る。
   width:100% だけだと、狭い画面で文字が1文字ずつ折り返されてしまう。
   集計のマトリクスは列が少ないので、広い表にだけ --wide を付ける。 */
.table-scroll--wide table { min-width: 1280px; }

/* 枠の一覧は28行あるので、横に送らず全部見えるほうがよい。
   一般入場の行から日時の重複を外したぶん、この幅で収まる（2026年10月31日）。 */
.table-scroll--slots table { min-width: 900px; }

/* 文字の多い列は、潰れると1文字ずつ折り返されて行が異様に縦長になる。
   最低限の幅を決めておき、足りなければ表ごと横に送る。 */
td.c-slot, th.c-slot { min-width: 160px; }
td.c-name, th.c-name { min-width: 110px; }
td.c-comp, th.c-comp { white-space: nowrap; }
/* 日時は途中で折り返すと読みにくい */
td.c-when, th.c-when { white-space: nowrap; }
td.c-time, th.c-time { white-space: nowrap; }
td.c-mail, th.c-mail { min-width: 180px; }
td.c-note, th.c-note { min-width: 190px; }

/* 新入生の列。人数と「男女・部署」を縦に並べるので、折り返さない幅を確保する。 */
td.nc, th.nc { min-width: 150px; }
.nc__line { display: block; }

/* ご連絡事項・新入生のご相談は最大2000文字入る。
   そのまま出すと1行が縦に伸びて表が読めなくなるので、1行に畳む。
   押すと開く（.clamp--open）。▸ が付いている行は続きがある合図。 */
.clamp {
  display: flex;
  gap: 4px;
  align-items: baseline;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-height: 0;
}
.clamp::before {
  content: '▸';
  flex: none;
  color: var(--text-muted);
  font-size: 0.8em;
}
.clamp--open::before { content: '▾'; }
.clamp__body {
  flex: 1;
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.clamp--open .clamp__body { -webkit-line-clamp: unset; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th { font-weight: 600; color: var(--text-muted); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ タブ */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tabs button {
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 14px;
  white-space: nowrap;
}
.tabs button[aria-selected='true'] {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ---------------------------------------------------------------- トースト */

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  max-width: calc(var(--maxw) - 32px);
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
  z-index: 50;
}
.toast.is-shown { opacity: 1; transform: translateY(0); }
.toast--error { background: var(--error); color: #fff; }
.toast--ok { background: var(--ok); color: #fff; }

/* ---------------------------------------------------------------- その他 */

.muted { color: var(--text-muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
.stack > * + * { margin-top: 10px; }
.spinner { color: var(--text-muted); padding: 24px 0; text-align: center; }

footer.site {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 20px 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}
footer.site a { color: var(--text-muted); }

/* 左に月明芸術会のマークと名前、右にページの案内。
   狭い画面では折り返して縦に並ぶ。 */
footer.site .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
/* ロゴは、四角いマークはそのまま、文字の部分だけ地を透明にしてある。
   文字の色が違う2枚を用意し、<picture> で出し分ける（明るい画面は黒、暗い画面は白）。
   表示される側しか読み込まれない。
   出し分けは OS の設定（prefers-color-scheme）だけを見ている。
   画面にテーマの切り替えを足すときは、ここも合わせること。 */
.brand picture { display: block; }
.brand img {
  display: block;
  height: 52px;
  width: auto;
}
.brand:hover img { opacity: 0.85; }

.pre { white-space: pre-line; }

/* ------------------------------------------------------------ 印刷 */
/* 受付用に印刷するとき、背景写真でインクを使わないようにする */
@media print {
  body::before,
  body::after { display: none; }
  body { background: #fff; color: #000; }
  .card, .day, header.site {
    background: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
  }
}
