/* 居食館 南都乃風 ナイトデリバリー — LIFF UI
   夜のスナック・ラウンジで、薄暗い店内でスマホから注文される前提。
   明るい白背景は眩しくて使いにくいので、ダーク基調＋高コントラストの文字にしている。 */

:root {
  --bg: #12100f;
  --surface: #1c1917;
  --surface-2: #262220;
  --line: #3a3330;
  --text: #f5efe8;
  --text-dim: #a89f97;
  --accent: #e0a458;        /* 提灯のような暖色 */
  --accent-dark: #b8823c;
  --danger: #d9584a;
  --ok: #5fa86b;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* レスポンシブの基準値。
     スマホは全幅、それより広い画面では中央に寄せて1行を読みやすい幅に留める。
     --pad-x は「最低でも余白 --gutter、広い画面では中央寄せ」を padding だけで実現する。
     ヘッダーの背景は全幅のまま、中身だけが中央に揃う。 */
  --gutter: 16px;
  --content-max: 640px;
  --pad-x: max(var(--gutter), calc((100% - var(--content-max)) / 2));

  /* .tabs の sticky 位置。ヘッダーの高さと必ず一致させる必要があるため、
     ヘッダー側も height でこの値に固定している（文字量で高さが変わらないように）。 */
  --header-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
               "Noto Sans JP", "Yu Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  padding-bottom: calc(88px + var(--safe-bottom));
}

button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
textarea { min-height: 84px; resize: vertical; }

/* ---------- ヘッダー ---------- */
.header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(18,16,15,.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  /* 高さを固定する。店名が長くて折り返しても .tabs の sticky 位置とズレないようにするため。 */
  height: var(--header-h);
  padding: 0 var(--pad-x);
  display: flex; flex-direction: column; justify-content: center;
}
.header h1 {
  margin: 0; font-size: 18px; letter-spacing: .04em; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header .sub {
  font-size: 12px; color: var(--text-dim); margin-top: 2px; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.banner {
  margin: 10px var(--pad-x) 0;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  background: rgba(217,88,74,.14);
  border: 1px solid rgba(217,88,74,.4);
  color: #ffbdb5;
}
.banner.ok {
  background: rgba(95,168,107,.12);
  border-color: rgba(95,168,107,.35);
  color: #b6e2bd;
}

/* ---------- 検索 ---------- */
.searchwrap { padding: 12px var(--pad-x) 0; }
.searchwrap input {
  background: var(--surface);
  border-radius: 999px;
  padding: 11px 16px;
  /* 16px 未満だと iOS Safari が入力欄フォーカス時に勝手にズームする。下げないこと。 */
  font-size: 16px;
}

/* ---------- カテゴリタブ ---------- */
.tabs {
  position: sticky; top: var(--header-h); z-index: 20;
  display: flex; gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 10px var(--pad-x);
  background: rgba(18,16,15,.94);
  backdrop-filter: blur(8px);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 14px;
  white-space: nowrap;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #1a1512; font-weight: 700; }

/* ---------- メニュー ---------- */
.section-title {
  margin: 22px var(--pad-x) 10px;
  font-size: 15px;
  color: var(--accent);
  letter-spacing: .08em;
}
.menu-list { display: flex; flex-direction: column; gap: 10px; padding: 0 var(--pad-x); }

.card {
  display: flex; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  text-align: left;
  width: 100%;
}
.card:active { background: var(--surface-2); }
.card.soldout { opacity: .45; }
.card .thumb {
  flex: 0 0 74px; height: 74px;
  border-radius: 10px; object-fit: cover;
  background: var(--surface-2);
}
.card .body { flex: 1; min-width: 0; }
.card .name { font-weight: 700; font-size: 15px; }
.card .desc {
  font-size: 12.5px; color: var(--text-dim); margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .price { margin-top: 6px; font-weight: 700; color: var(--accent); }
.pill {
  display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--accent); color: var(--accent); margin-right: 6px;
}
.pill.warn { border-color: var(--danger); color: #ff9d92; }

/* ---------- カートバー ---------- */
.cartbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 12px var(--pad-x) calc(12px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.btn {
  width: 100%; padding: 15px;
  border-radius: 12px; font-weight: 700; font-size: 16px;
  background: var(--accent); color: #1a1512;
}
.btn:disabled { background: var(--surface-2); color: var(--text-dim); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.danger { background: transparent; border: 1px solid var(--danger); color: #ff9d92; }

/* ---------- シート（モーダル） ---------- */
.sheet-bg {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end;
}
.sheet {
  width: 100%; overflow-y: auto;
  /* dvh はアドレスバーの伸縮を考慮した高さ。非対応ブラウザは直前の vh にフォールバックする。 */
  max-height: 92vh;
  max-height: 92dvh;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(20px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.sheet h2 { margin: 0 0 4px; font-size: 18px; }
.sheet .hint { color: var(--text-dim); font-size: 13px; margin: 0 0 14px; }

.field { margin-bottom: 16px; }
.field > label {
  display: block; font-size: 13px; color: var(--text-dim);
  margin-bottom: 6px; letter-spacing: .04em;
}
.field .req { color: var(--accent); margin-left: 4px; }

.opt-group { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.opt-group .g-name { font-weight: 700; font-size: 14px; }
.opt-group .g-rule { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.opt-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); margin-bottom: 8px;
  background: var(--surface-2);
}
.opt-row input { width: auto; flex: 0 0 auto; accent-color: var(--accent); }
.opt-row .o-name { flex: 1; font-size: 14.5px; }
.opt-row .o-price { color: var(--accent); font-size: 13.5px; }

.qty { display: flex; align-items: center; gap: 16px; justify-content: center; margin: 18px 0; }
.qty button {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); font-size: 22px; line-height: 1;
}
.qty .n { font-size: 20px; font-weight: 700; min-width: 40px; text-align: center; }

/* ---------- カート明細 ---------- */
.cart-line {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.cart-line .cl-body { flex: 1; min-width: 0; }
.cart-line .cl-name { font-weight: 700; font-size: 14.5px; }
.cart-line .cl-opt { font-size: 12.5px; color: var(--text-dim); }
.cart-line .cl-price { font-weight: 700; white-space: nowrap; }
.cart-line .cl-del { color: var(--danger); font-size: 12.5px; margin-top: 4px; }

.total-row {
  display: flex; justify-content: space-between;
  padding: 6px 0; font-size: 14px; color: var(--text-dim);
}
.total-row.grand { font-size: 19px; font-weight: 700; color: var(--text); padding-top: 12px; }

/* ---------- 完了画面 ---------- */
.done { text-align: center; padding: 40px 24px; }
.done .mark { font-size: 52px; }
.done h2 { margin: 12px 0 6px; }
.done .oid {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px; color: var(--accent); letter-spacing: .06em;
}
.done .box {
  margin: 20px 0; padding: 16px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
  text-align: left; font-size: 14px;
}

.center-msg { text-align: center; color: var(--text-dim); padding: 48px 24px; }
.err { color: #ff9d92; font-size: 13.5px; margin-top: 8px; }

/* ==========================================================================
   レスポンシブ

   基本設計はスマホ縦持ち（LIFF は原則スマホで開かれる）。
   ここでは「それ以外の画面でも破綻しない」ための上書きだけを書く。
   ベース側の値は触らないこと。触るとスマホの見え方が変わる。
   ========================================================================== */

/* ---- 小型スマホ（iPhone SE 幅 375px 以下 / Android の 360px 級） ---- */
@media (max-width: 380px) {
  :root { --gutter: 12px; }
  .header h1 { font-size: 17px; }
  .card { padding: 10px; gap: 10px; }
  .card .thumb { flex: 0 0 64px; height: 64px; }
  .card .name { font-size: 14.5px; }
  .tab { padding: 7px 13px; font-size: 13.5px; }
  .btn { padding: 14px; font-size: 15.5px; }
  /* 数量ボタンは 44px を下回らせない。指で押せなくなる。 */
  .qty { gap: 12px; }
}

/* ---- 横向き（背の低い画面）----
   スナックのテーブルに置いた状態で横持ちされることがある。
   縦の余白を削り、シートが画面からはみ出さないようにする。 */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --header-h: 48px; }
  .header .sub { display: none; }
  .section-title { margin-top: 16px; }
  .sheet {
    max-height: 96vh;
    max-height: 96dvh;
  }
  .qty { margin: 12px 0; }
  .done { padding: 24px; }
  .done .mark { font-size: 40px; }
}

/* ---- タブレット・PC ----
   1行が長くなりすぎると読みにくいので中央に寄せ、メニューは複数列にする。
   店側が動作確認や卓上タブレットで開くケースもここに入る。 */
@media (min-width: 600px) {
  :root { --content-max: 760px; }

  /* 高さの揃わないカードが縦に伸びないよう align-items: start を入れる。 */
  .menu-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    align-items: start;
  }

  /* 画面下に貼り付くボトムシートは、広い画面では中央のダイアログにする。 */
  .sheet-bg { align-items: center; padding: 24px; }
  .sheet {
    max-width: 540px;
    margin: 0 auto;
    border-radius: 18px;
    border: 1px solid var(--line);
    max-height: 86vh;
    max-height: 86dvh;
    /* 中央配置ではセーフエリアの下駄が不要になる。 */
    padding-bottom: 20px;
  }

  /* カートバーは全幅に伸ばさず、コンテンツ幅に合わせる。 */
  .cartbar { background: linear-gradient(to top, var(--bg) 80%, transparent); }
}

/* ---- 大画面 ---- */
@media (min-width: 1000px) {
  :root { --content-max: 900px; }
  .menu-list { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

/* 「視差効果を減らす」設定への配慮は app.js 側（scrollTo の behavior 切り替え）で行う。
   CSS の scroll-behavior は JS で指定した behavior:"smooth" を上書きできないため。 */
