/* ============================================================================
   shell.css — Piano Lounge Segno 共通シェル（紅茶々丸 / chachamaru-live）
   impl-chachamaru-01 P1（2026-09-26）

   土台は土台テナントの -live 版 shell.css（v0.23）。中身は全面差し替え:
     §1  橋渡し   … 各ページの既存 CSS が参照する変数名（--color-* / --font-* と
                    打鍵の短い名前 --paper / --accent …）を、tenant.css のトークンへ向ける。
                    ⚠ 色の実値はここに書かない。値は tenant.css だけが持つ。
                    ⚠ --ink / --line / --dur / --ease は tenant.css に同名があるので
                      ここで定義しない（定義すると自己参照で無効値になる）。
     §2  基底
     §3  共通ヘッダー（納品書 §4-1）
     §4  モバイル下タブ（767px 以下）
     §5  フッター
     §6  D.S. 印（納品書 §3-4）
     §7  打鍵のオーバーフロー（旧 shell.css §7 から移植・配色のみ変更）
     §8  土台テナントの蝶（.bfly）は使わない。JS が描画する分も含めて非表示
   ============================================================================ */

/* ── §1 橋渡し ──────────────────────────────────────────────────────────── */
:root {
  --color-bg:           var(--bg-0);
  --color-bg-paper:     var(--bg-1);
  --color-bg-mist:      var(--bg-1);
  --color-bg-active:    var(--bg-2);
  --color-bg-soft:      var(--bg-1);
  --color-bg-input:     var(--bg-0);

  --color-ink:          var(--ink);
  --color-ink-soft:     var(--ink-2);
  --color-ink-muted:    var(--ink-3);
  --color-ink-subtle:   var(--ink-3);

  --color-line:         var(--line);
  --color-line-soft:    var(--line);

  --color-accent:       var(--rose);
  --color-accent-deep:  var(--rose-deep);
  --color-accent-light: var(--bg-2);
  --color-accent-tint:  var(--rose);

  --color-rec:          var(--rose);
  --color-on-dark:      var(--on-rose);

  --font-serif: var(--f-display);
  --font-sans:  var(--f-body);
  --font-mono:  var(--f-mono);

  /* 打鍵（stamper.html）の短い名前 */
  --bg:          var(--bg-0);
  --paper:       var(--bg-1);
  --paper-soft:  var(--bg-1);
  --line-soft:   var(--line);
  --ink-soft:    var(--ink-2);
  --ink-muted:   var(--ink-3);
  --ink-subtle:  var(--ink-3);
  --accent:      var(--rose);
  --accent-deep: var(--rose-deep);
  --accent-lt:   var(--bg-2);
  --danger:      var(--rose);
  --serif: var(--f-display);
  --sans:  var(--f-body);
  --mono:  var(--f-mono);

  /* レイアウト（旧 shell.css §1 の名前をそのまま残す。各ページが参照している） */
  --w-gutter:    48px;
  --w-container: min(1680px, calc(100% - 2 * var(--w-gutter)));
  --grid-gap:    20px;
  --card-min:    280px;
  --tap-min:     44px;
  --h-header:    72px;
  --h-bottom-tabs: 72px;
  --h-mini-player: 56px;
}
@media (max-width: 1199px) { :root { --w-gutter: 40px; } }
@media (max-width:  959px) { :root { --w-gutter: 20px; } }
@media (max-width:  767px) { :root { --w-gutter: 16px; --h-header: 56px; } }

/* ── §2 基底 ────────────────────────────────────────────────────────────── */
/* 納品書 rev.1 #8: Cormorant Garamond の既定数字は old-style で「1」が「I」に見える。
   数字は全ページ lining（高さ揃い）＋ tabular（等幅）にする。font-variant-numeric は継承する */
html { background: var(--bg-0); font-variant-numeric: lining-nums tabular-nums; }
body {
  background: var(--bg-0);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--fs-body);
}
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* ── §3 共通ヘッダー ────────────────────────────────────────────────────── */
.sg-header {
  position: relative; z-index: 20;
  height: var(--h-header);
  box-sizing: border-box;
  padding: 0 var(--w-gutter);
  display: flex; align-items: center; gap: 40px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
}
.sg-brand {
  display: flex; align-items: center; gap: 12px;
  color: var(--ink); text-decoration: none;
  flex-shrink: 0;
}
.sg-emblem { width: 40px; height: 40px; flex-shrink: 0; display: block; }
/* ワードマーク（納品書 rev.3）: 「紅茶々丸」を「Piano Lounge Segno」と同じ横幅に両端そろえ。
   箱の幅＝長い方（欧文）の幅。和文は text-align-last: justify で広げる（letter-spacing で合わせない） */
.sg-word { display: inline-grid; line-height: 1.15; }
.sg-word-ja {
  font-family: var(--f-display); font-weight: 700; font-size: 22px;
  text-align: justify; text-align-last: justify; text-justify: inter-character;
}
.sg-word-en { font-family: var(--f-latin); font-style: italic; font-size: 14px; color: var(--brass); white-space: nowrap; }

.sg-nav {
  display: flex; gap: 32px; flex-grow: 1;
  align-self: stretch;
  font-family: var(--f-display); font-size: 17px;
}
.sg-nav a {
  display: flex; align-items: center;
  color: var(--ink-2); text-decoration: none;
  border-bottom: 2px solid transparent;
  border-top: 2px solid transparent;
  transition: color var(--dur) var(--ease);
}
.sg-nav a:hover { color: var(--ink); }
.sg-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brass); }

.sg-theme {
  display: flex; flex-shrink: 0;
  border: 1px solid var(--line); border-radius: var(--r-m);
  overflow: hidden;
}
.sg-theme button {
  height: 44px; padding: 0 16px;
  border: 0; background: transparent; color: var(--ink-2);
  font-family: var(--f-body); font-size: var(--fs-small);
  cursor: pointer;
}
.sg-theme button[aria-pressed="true"] { background: var(--brass); color: var(--on-brass); }

.sg-theme-flip {
  display: none;
  width: 44px; height: 44px; flex-shrink: 0;
  align-items: center; justify-content: center;
  background: transparent; color: var(--brass);
  border: 1px solid var(--line); border-radius: var(--r-m);
  cursor: pointer;
}

/* 既存 JS が値を書き込む先（ヘッダーには表示しない） */
.sg-sink { display: none; }

@media (max-width: 1023px) {
  .sg-header { gap: 24px; }
  .sg-nav { gap: 20px; font-size: 16px; }
}
@media (max-width: 767px) {
  .sg-header { gap: 10px; }
  .sg-emblem { width: 30px; height: 30px; }
  /* 右側を押し出すのは margin-right: auto（flex-grow だと箱が伸びて和文も伸びる・rev.3） */
  .sg-brand { margin-right: auto; }
  .sg-word-ja { font-size: 20px; }
  .sg-word-en { font-size: 12px; }
  .sg-nav, .sg-theme { display: none; }
  .sg-theme-flip { display: flex; }
}

/* ── §4 モバイル下タブ ──────────────────────────────────────────────────── */
.sg-tabs { display: none; }
@media (max-width: 767px) {
  .sg-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--h-bottom-tabs) + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    padding: 0 8px calc(8px + env(safe-area-inset-bottom, 0px));
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    background: var(--bg-1);
    border-top: 1px solid var(--line);
  }
  .sg-tabs a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    text-decoration: none; color: var(--ink-2);
    border-top: 2px solid transparent;
  }
  .sg-tabs .sg-tab-name { font-family: var(--f-display); font-size: 16px; }
  .sg-tabs .sg-tab-sub  { font-size: 10px; color: var(--ink-3); }
  .sg-tabs a[aria-current="page"] { color: var(--ink); border-top-color: var(--brass); }
  .sg-tabs a[aria-current="page"] .sg-tab-name { font-weight: 700; }

  /* 本文の最下部に下タブ分の余白。詳細度 0,0,2 はページ側の html, body {padding:0} に勝つため */
  html body { padding-bottom: calc(var(--h-bottom-tabs) + env(safe-area-inset-bottom, 0px)); }
}

/* ── §5 フッター ────────────────────────────────────────────────────────── */
.sg-footer {
  padding: 28px var(--w-gutter);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  flex-wrap: wrap;
  background: var(--bg-0);
  font-family: var(--f-body); font-size: 12px; color: var(--ink-3);
}
.sg-footer-ds { font-family: var(--f-latin); font-style: italic; font-size: 14px; }
@media (max-width: 767px) {
  .sg-footer { flex-direction: column; align-items: flex-start; gap: 6px; padding-block: 20px; }
}

/* 譜棚（rev.1 #1）: ヘッダー帯・本文・フッターを同じ内側幅（max 1440px・内側 40px）にそろえる。
   余韻・打鍵は全幅のアプリなので対象外（body.pg-fudana のときだけ） */
.pg-fudana .sg-header,
.pg-fudana .sg-footer { padding-inline: max(var(--w-gutter), calc((100% - 1440px) / 2 + 40px)); }

/* ── §6 D.S. 印 ─────────────────────────────────────────────────────────── */
.sg-ds {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--f-latin); font-style: italic; font-size: 14px;
  color: var(--segno);
  white-space: nowrap;
}

/* ── §7 打鍵のオーバーフロー（旧 §7。639px は stamper.html の matchMedia と対） ── */
.sh-overflow { display: none; position: relative; flex-shrink: 0; }
.sh-overflow-btn {
  position: relative;
  width: var(--tap-min); height: var(--tap-min);
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--line); border-radius: var(--r-m);
  color: var(--ink);
  font-size: 16px; line-height: 1;
  cursor: pointer;
}
.sh-overflow-panel {
  display: none;
  position: absolute; right: 0; top: calc(100% + 6px);
  z-index: 45;
  min-width: 210px; padding: 8px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  box-shadow: var(--shadow-gloss);
}
.sh-overflow.open .sh-overflow-panel { display: block; }
@media (max-width: 639px) {
  .sh-overflow { display: block; }
}

/* ── §8 蝶は使わない ────────────────────────────────────────────────────── */
.bfly { display: none !important; }
