/* style.css
   サイト全体で共通のデザイン定義。
   ここで決めた色や角丸を全ページで使い回すことで、見た目を統一します。 */

/* ---- デザイントークン（色・角丸・影などの共通ルールをCSS変数として定義） ---- */
:root {
  /* 色：オフホワイトの背景に、深緑をアクセントにした上品な配色 */
  --color-bg: #faf8f5;          /* ページ背景（あたたかみのあるオフホワイト） */
  --color-surface: #ffffff;     /* カード（白い箱）の背景 */
  --color-accent: #1f5f4a;      /* アクセント色（深緑）。ボタンや見出しに使う */
  --color-accent-dark: #17493a; /* アクセント色の少し濃い版（ボタンを押したとき用） */
  --color-text: #333333;        /* 基本の文字色（濃いグレー） */
  --color-text-sub: #777777;    /* 補足文の文字色（控えめグレー） */
  --color-border: #dddad4;      /* 枠線の色（うすいグレー） */
  --color-error-bg: #fdf0ef;    /* エラーメッセージの背景（うすい赤） */
  --color-error-text: #b3372f;  /* エラーメッセージの文字色 */
  --color-notice-bg: #fdf6e8;   /* 注意書きの背景（うすい黄色） */
  --color-notice-text: #8a6712; /* 注意書きの文字色 */

  /* 形：角丸と影 */
  --radius: 12px;                              /* カードや入力欄の角の丸み */
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);     /* カードにつける控えめな影 */

  /* 空き状況バーの3色（明るさをはっきり段階分けして、ひと目で区別できるように） */
  --slot-free: #ece9e2;          /* 空き：明るい色面（「入れる余白」だと分かる） */
  --slot-free-border: #d3cec4;   /* 空きの枠線（余白の輪郭） */
  --slot-reserved: #8f8a80;      /* 予約済み：はっきり暗いグレー（もう取れない） */
  --slot-reserved-stripe: rgba(0, 0, 0, 0.22); /* 予約済みに重ねる斜線の色 */
  --slot-selected: #1f5f4a;      /* 選択中：アクセントの深緑でハッキリ */
}

/* ---- ページ全体の基本設定 ---- */
* {
  box-sizing: border-box; /* 幅の計算に余白や枠線も含める（レイアウトを安定させる） */
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  /* システムフォント：その端末に元から入っているきれいな文字を使う */
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  line-height: 1.7;
  /* スマホの左右に少し余白を確保 */
  padding: 16px;
}

/* ---- 中央寄せの1カラムレイアウト（スマホ最優先、PCでは中央に寄る） ---- */
.container {
  max-width: 480px;   /* PCでも広がりすぎないように上限を設ける */
  margin: 0 auto;     /* 左右中央に配置 */
}

/* ---- 全ページ共通の控えめなアプリ名ヘッダー（ブランド表示） ---- */
.app-header {
  text-align: center;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 0.15em; /* 文字を少し広げてロゴ風に見せる */
  color: var(--color-accent);
  opacity: 0.85;          /* 主役の見出しより目立たないよう少し薄く */
  padding: 8px 0 2px;
}

/* アプリ名の前に置く小さな飾りの丸 */
.app-header::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-accent);
  margin-right: 6px;
  vertical-align: middle;
}

/* ---- ページのタイトルまわり ---- */
.page-title {
  font-size: 22px;
  color: var(--color-accent);
  margin: 16px 0 4px;
  text-align: center;
}

.page-lead {
  font-size: 14px;
  color: var(--color-text-sub);
  text-align: center;
  margin: 0 0 20px;
}

/* ---- トップページの「使い方3ステップ」ガイド ----
   HTML側で class="steps-guide card" のように .card と一緒に指定し、
   フォーム部分（.card）と同じ白背景・角丸・影のカードにする。
   ここには .card に無い、このガイド専用の見た目だけを追加する。 */
.steps-guide .section-title {
  text-align: center;
}

.steps-list {
  margin: 10px 0 0;
}

/* 1ステップぶんの行（丸バッジ＋説明を横に並べる。
   バッジと文字の「上端」をそろえることで、バッジが本文に添えられた
   一体のブロックに見えるようにする） */
.step-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
}

/* ステップ同士の間にうっすら区切り線を入れる（1つ目の上には付けない） */
.step-item + .step-item {
  border-top: 1px solid var(--color-border);
}

/* 番号の丸バッジ（アクセント色の背景に白文字の①②③）。
   flex-shrink: 0 で、説明文が長くても潰れて楕円にならないようにする。
   カードと同じ --shadow を薄くかけて、少し立体感を出す */
.step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #ffffff;
  font-size: 15px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

.step-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* バッジ(32px)と1行目の文字の高さを視覚的にそろえるための微調整 */
  padding-top: 4px;
}

/* タイトルもアクセント色にして、バッジと呼応する差し色にする */
.step-text strong {
  font-size: 14px;
  color: var(--color-accent);
}

.step-text span {
  font-size: 13px;
  color: var(--color-text-sub);
}

/* ---- カード（白い角丸の箱） ---- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px;
  margin-bottom: 20px;
}

/* ---- フォームの部品 ---- */
.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 6px;
}

/* 「任意」など、ラベルに添える小さな文字 */
.label-hint {
  font-size: 12px;
  font-weight: normal;
  color: var(--color-text-sub);
}

/* 入力欄。高さ48px以上・文字16px以上（iPhoneで自動ズームされるのを防ぐ） */
input[type="text"],
input[type="time"],
textarea {
  width: 100%;
  min-height: 48px;
  font-size: 16px;
  font-family: inherit; /* ページと同じフォントを使う */
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px;
}

textarea {
  min-height: 96px;
  resize: vertical; /* 縦方向だけ広げられるようにする */
}

/* 入力欄を選んだとき、アクセント色の枠で分かりやすくする */
input:focus,
textarea:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: -1px;
}

/* 受付時間の「開始〜終了」を横に並べる */
.time-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-row input {
  flex: 1; /* 2つの入力欄を同じ幅にする */
}

/* ---- ボタン ---- */
.btn {
  display: block;
  width: 100%;
  min-height: 48px;
  font-size: 16px;
  font-weight: bold;
  font-family: inherit;
  color: #ffffff;
  background: var(--color-accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  /* 押したときの色・沈みをなめらかに変化させて手触りを良くする */
  transition: background-color 0.15s ease, transform 0.05s ease;
}

.btn:active {
  background: var(--color-accent-dark); /* 押した瞬間に少し濃くする */
  transform: translateY(1px);           /* ほんの少し沈ませる */
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* 小さめの補助ボタン（コピー用など）。白地に深緑の枠 */
.btn-sub {
  min-height: 48px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: bold;
  font-family: inherit;
  color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap; /* ボタンの文字を折り返さない */
  transition: background-color 0.15s ease, transform 0.05s ease;
}

.btn-sub:active {
  background: var(--color-bg);
  transform: translateY(1px);
}

.btn-sub:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ---- メッセージ表示 ---- */
/* エラーメッセージ（入力ミスなどのお知らせ） */
.error-box {
  background: var(--color-error-bg);
  color: var(--color-error-text);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 16px;
}

/* 注意書き（大切なお願いごと） */
.notice-box {
  background: var(--color-notice-bg);
  color: var(--color-notice-text);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  margin-top: 12px;
}

/* ---- URL表示まわり（登録完了後に使う） ---- */
.url-block {
  margin-bottom: 24px;
}

.url-block h3 {
  font-size: 15px;
  margin: 0 0 8px;
}

/* URLとコピーボタンを横に並べる */
.url-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

/* URLの文字を表示する部分。長いURLは横スクロールで見られるようにする */
.url-text {
  flex: 1;
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 8px 12px;
  font-size: 13px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow-x: auto;
  white-space: nowrap;
}

/* 「コピーしました」の小さなフィードバック */
.copy-done {
  font-size: 12px;
  color: var(--color-accent);
  margin: 4px 0 0;
  min-height: 1.5em; /* 表示が出たり消えたりしてもガタつかないよう高さを確保 */
}

/* ---- 準備中・404ページ用 ---- */
.center-card {
  text-align: center;
  padding: 40px 20px;
}

.center-card .big-icon {
  font-size: 40px;
  margin-bottom: 8px;
}

.center-card h2 {
  font-size: 18px;
  color: var(--color-accent);
  margin: 0 0 8px;
}

.center-card p {
  font-size: 14px;
  color: var(--color-text-sub);
  margin: 0;
}

/* 画面の表示・非表示を切り替えるためのクラス */
.hidden {
  display: none;
}

/* ==== ここから予約ページ（/r/…）専用のスタイル ==== */

/* ---- 注意書きカード ---- */
.room-note {
  margin: 0;
  font-size: 14px;
  color: var(--color-text);
  white-space: pre-wrap; /* 注意書きの改行をそのまま活かして表示する */
}

/* ---- カレンダー ---- */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cal-title {
  font-size: 16px;
  font-weight: bold;
}

/* 前月・翌月ボタン。押せないとき（範囲外）は薄くする */
.cal-nav {
  min-height: 44px;
  padding: 0 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.05s ease;
}

.cal-nav:not(:disabled):active {
  background: var(--color-bg);
  transform: translateY(1px);
}

.cal-nav:disabled {
  color: var(--color-border);
  border-color: var(--color-border);
  cursor: default;
}

/* 曜日の行（日〜土） */
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  color: var(--color-text-sub);
  margin-bottom: 4px;
}

/* 日付マスの一覧（7列のマス目） */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

/* 日付のマス（タップ領域44px以上） */
.cal-day {
  min-height: 44px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  color: var(--color-text);
  cursor: pointer;
  padding: 0;
}

/* 日曜は薄い赤、土曜は薄い青 */
.cal-weekdays .sun, .cal-day.sun { color: #c96f6a; }
.cal-weekdays .sat, .cal-day.sat { color: #6a87c9; }

/* 選べない日（過去や3ヶ月より先）は薄いグレーにする */
.cal-day:disabled {
  color: #cdc9c2;
  cursor: default;
}

/* 今日の日付には輪郭を付ける */
.cal-day.today {
  box-shadow: inset 0 0 0 1.5px var(--color-accent);
}

/* 選択中の日付はアクセント色で塗る（曜日の色より優先させるため一番最後に書く） */
.cal-day.selected {
  background: var(--color-accent);
  color: #ffffff;
  font-weight: bold;
}

/* ---- その日の空き状況（横棒のタイムライン） ---- */
.day-title {
  font-size: 16px;
  color: var(--color-accent);
  margin: 0 0 12px;
}

/* 受付時間全体を表す横棒。地の色が「空き」を表し、この上に予約済み・選択中を重ねる */
.timeline {
  position: relative;
  height: 44px;
  background: var(--slot-free); /* 空きを表す明るい色面 */
  border: 1px solid var(--slot-free-border); /* 「入れる余白」の輪郭 */
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}

/* 予約済みの時間帯ブロック（暗いグレー＋斜線で「もう取れない」と直感的に伝える） */
.tl-reserved {
  position: absolute;
  top: 0;
  bottom: 0;
  background-color: var(--slot-reserved);
  /* 斜線パターン。色だけに頼らず、模様でも予約済みと分かるようにする */
  background-image: repeating-linear-gradient(
    45deg,
    var(--slot-reserved-stripe) 0,
    var(--slot-reserved-stripe) 3px,
    transparent 3px,
    transparent 8px
  );
}

/* いま選択している時間帯ブロック（アクセントの深緑でハッキリ目立たせる） */
.tl-selected {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--slot-selected);
  /* 下に予約済みが重なっても分かるよう、白い枠で縁取りして際立たせる */
  box-shadow: inset 0 0 0 2px #ffffff;
}

/* 横棒の下に出す時刻ラベル（左端＝受付開始、右端＝受付終了） */
.tl-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--color-text-sub);
  margin-top: 4px;
}

/* 凡例（色の意味の説明） */
.legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--color-text-sub);
  margin-top: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  display: inline-block;
}

/* 凡例の色見本は、バーの3状態とまったく同じ見た目にそろえる */
.sw-free {
  background: var(--slot-free);
  border: 1px solid var(--slot-free-border);
}
.sw-reserved {
  background-color: var(--slot-reserved);
  background-image: repeating-linear-gradient(
    45deg,
    var(--slot-reserved-stripe) 0,
    var(--slot-reserved-stripe) 2px,
    transparent 2px,
    transparent 5px
  );
}
.sw-selected { background: var(--slot-selected); }

/* ---- 予約済み時間帯の文字一覧（バーのすぐ下） ---- */
.reserved-list {
  display: flex;
  flex-wrap: wrap;      /* 予約が多い日は折り返して、横に見切れないようにする */
  align-items: center;
  gap: 6px 12px;        /* 縦6px・横12px のすきま */
  font-size: 13px;
  color: var(--color-text);
  margin-top: 10px;
}

/* 「予約済み：」の見出し */
.reserved-label {
  font-weight: bold;
  color: var(--color-text-sub);
}

/* 「色見本＋時間帯」ひとまとまり */
.reserved-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap; /* 「10:00〜11:30」を途中で折り返さない */
}

/* チップの中の色見本は少し小さめにそろえる */
.reserved-chip .legend-swatch {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* 予約0件の日のメッセージ */
.reserved-empty {
  font-size: 13px;
  color: var(--color-text-sub);
}

/* ちょっとした操作のヒント文 */
.hint {
  font-size: 12px;
  color: var(--color-text-sub);
  margin: 8px 0 16px;
}

/* 開始時刻・終了時刻を横に並べる */
.time-fields {
  display: flex;
  gap: 12px;
}

.time-fields .field {
  flex: 1;
}

/* ---- 画面下に固定表示する「選択中の内容」バー ---- */
.summary-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
  /* iPhoneの画面下の丸い領域（ホームバー）と重ならないよう余白を足す */
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  z-index: 10;
}

.summary-inner {
  max-width: 480px;
  margin: 0 auto;
  font-size: 14px;
  font-weight: bold;
  color: var(--color-accent);
  text-align: center;
}

/* バーの分だけページの下に余白を作り、内容が隠れないようにする */
body.has-summary {
  padding-bottom: 96px;
}

/* ---- 予約完了画面 ---- */
.done-big {
  font-size: 22px;
  font-weight: bold;
  color: var(--color-accent);
  text-align: center;
  margin: 8px 0 4px;
}

.done-sub {
  font-size: 14px;
  color: var(--color-text-sub);
  text-align: center;
  margin: 0 0 4px;
}

.done-name {
  font-size: 16px;
  text-align: center;
  margin: 12px 0 0;
}

/* ==== ここからホスト管理ページ（/h/…）専用のスタイル ==== */

/* カード内の小さな見出しと説明文 */
.section-title {
  font-size: 16px;
  color: var(--color-accent);
  margin: 0 0 4px;
}

.section-lead {
  font-size: 13px;
  color: var(--color-text-sub);
  margin: 0 0 12px;
}

/* 「予約一覧」の見出しと更新ボタンを横に並べる */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.list-header .section-title {
  margin: 0;
}

/* 成功のお知らせ（うすい緑の箱） */
.success-box {
  background: #eaf3ee;
  color: var(--color-accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 12px;
}

/* 日付ごとの見出し（例：7月12日（日）） */
.day-heading {
  font-size: 14px;
  font-weight: bold;
  color: var(--color-text-sub);
  margin: 16px 0 8px;
}

/* 予約1件ぶんのカード */
.rsv-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.rsv-time {
  font-size: 15px;
  font-weight: bold;
}

.rsv-sub {
  font-size: 12px;
  color: var(--color-text-sub);
}

.rsv-name {
  font-size: 14px;
  margin-top: 2px;
  /* 長い名前でもカードが崩れないよう折り返す */
  overflow-wrap: anywhere;
}

/* 取り消しボタン（控えめな危険色。白地に赤い文字と枠） */
.btn-danger {
  min-height: 48px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: bold;
  font-family: inherit;
  color: var(--color-error-text);
  background: var(--color-surface);
  border: 1px solid #dcaba7;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap; /* ボタンの文字を折り返さない */
  flex-shrink: 0;      /* カードが狭くてもボタンは潰さない */
  transition: background-color 0.15s ease, transform 0.05s ease;
}

.btn-danger:not(:disabled):active {
  transform: translateY(1px);
}

/* 確認モード（「本当に取り消す」表示中）は赤く塗って目立たせる */
.btn-danger.confirming {
  color: #ffffff;
  background: var(--color-error-text);
  border-color: var(--color-error-text);
}

.btn-danger:disabled {
  opacity: 0.6;
  cursor: default;
}

/* 予約が0件のときの表示 */
.empty-state {
  text-align: center;
  font-size: 14px;
  color: var(--color-text-sub);
  padding: 24px 0;
  line-height: 2;
}

/* 過去の予約の折りたたみ */
.past-details {
  margin-top: 16px;
  border-top: 1px solid var(--color-border);
}

/* 折りたたみの開閉部分（タップ領域48px以上） */
.past-details summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text-sub);
}

/* ==== 全ページ共通：キーボード操作時のフォーカスを見やすくする ==== */
/* （マウスやタップでは出さず、Tabキーで操作したときだけ枠を出す） */
.btn:focus-visible,
.btn-sub:focus-visible,
.cal-nav:focus-visible,
.cal-day:focus-visible,
.btn-danger:focus-visible,
.past-details summary:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
