/* サイト共通のヘッダーと下のタブ(site-chrome.js の部品)の見た目。全ページで読み込む。
   色はページの変数(--ink・--bg・--surface・--brass・--brass-soft・--line・--muted)を使う */
/* 画面の一番外側の背景も body と同じ色に(iPhone の時計・電池の表示の裏や、引っぱってスクロールしたときに見える所) */
html { background: var(--bg); }
/* ヘッダー: viewport-fit=cover なので、iPhone の時計・電池の表示の下から始める(下のタブの safe-area-inset-bottom と同じ考え方) */
.sh { position: relative; z-index: 40; padding-top: env(safe-area-inset-top, 0px); }
.sh-bar {
  display: flex; align-items: center; gap: 12px;
  height: 52px; margin-inline: auto; max-width: 1480px;
}
.sh-brand { margin: 0; font: inherit; flex: 1; min-width: 0; }
.sh-logo { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; color: var(--ink); text-decoration: none; }
.sh-mark { display: block; width: 28px; height: 28px; flex: none; }
.sh-logo span { font-family: var(--font-display); font-weight: 400; font-size: 18px; letter-spacing: .02em; line-height: 1.2; white-space: nowrap; }
.sh-nav { display: none; }
.sh-right { display: flex; align-items: center; gap: 2px; }
.sh-about { display: none; }
.sh-icon {
  display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 12px; background: transparent; color: var(--ink); cursor: pointer; text-decoration: none; font: inherit;
}
.sh-icon:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.sh-icon svg { width: 24px; height: 24px; }
.sh-help-btn { display: none; }
.sh-menu-btn .i-close { display: none; }
.sh-menu-btn[aria-expanded="true"] .i-open { display: none; }
.sh-menu-btn[aria-expanded="true"] .i-close { display: block; }

/* スマホのメニュー: ヘッダーの下に、画面全体を暗くしてカードで出す */
.sh-menu {
  position: fixed; left: 0; right: 0; bottom: 0; top: calc(52px + env(safe-area-inset-top, 0px));
  z-index: 70; background: rgba(8, 10, 14, .55);
  padding: 8px max(12px, env(safe-area-inset-right, 0px)) calc(76px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
}
.sh-menu-card {
  display: grid; gap: 12px; max-height: 100%; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 8px 14px 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .3);
}
.sh-menu-links { display: grid; }
.sh-menu-links a {
  display: flex; align-items: center; justify-content: space-between; min-height: 48px;
  color: var(--ink); text-decoration: none; font-weight: 700; font-size: 15px; border-bottom: 1px solid var(--line);
}
.sh-menu-links a:last-child { border-bottom: 0; }
.sh-menu-links a[aria-current="page"] { color: var(--brass); }
.sh-menu-links svg { width: 18px; height: 18px; color: var(--muted); }
.sh-menu-app:empty { display: none; }
.sh-menu-app { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 12px; }
html.sh-menu-open, html.sh-menu-open body { overflow: hidden; }

/* パソコンの「?」: ヘッダーの右下に出すカード */
.sh-help {
  position: absolute; right: 0; top: calc(100% - 4px); z-index: 70; width: min(360px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .18); font-size: 14px; line-height: 1.7;
}
.sh-help-title { margin: 0 0 8px; font-weight: 700; font-size: 15px; }
.sh-keys { margin: 0; display: grid; gap: 6px; }
.sh-keys div { display: grid; grid-template-columns: 7.5em 1fr; gap: 10px; align-items: baseline; }
.sh-keys dt { margin: 0; white-space: nowrap; }
.sh-keys dd { margin: 0; color: var(--muted); }
.sh-help kbd { font-family: var(--font-mono); font-size: 12px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--bg); color: var(--ink); }
.sh-tips { margin: 12px 0 0; padding: 12px 0 0 1.1em; border-top: 1px solid var(--line); color: var(--muted); display: grid; gap: 4px; }

/* スマホの下のタブ(高さ 64px と iPhone の下の余白) */
.st {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.st a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500; line-height: 1.2; min-width: 0;
}
.st-icon { display: grid; place-items: center; width: 56px; height: 30px; border-radius: 999px; transition: background-color .15s ease; }
.st-icon svg { width: 22px; height: 22px; }
.st a[aria-current="page"] { color: var(--ink); font-weight: 700; }
.st a[aria-current="page"] .st-icon { background: var(--brass-soft); }
.st-label { white-space: nowrap; }
/* タブの分だけ、ページの下を空ける */
body { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }

@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .st { display: none; }
  .sh-menu { display: none !important; }
  .sh-bar { height: 64px; gap: 20px; }
  .sh-brand { flex: 1 1 0; }
  .sh-logo span { font-size: 20px; }
  .sh-nav { display: flex; align-items: center; gap: 4px; }
  .sh-nav a {
    display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px;
    color: var(--ink); text-decoration: none; font-weight: 700; font-size: 15px; white-space: nowrap;
  }
  .sh-nav a:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
  .sh-nav a[aria-current="page"] { background: var(--brass-soft); color: var(--brass); }
  .sh-right { flex: 1 1 0; justify-content: flex-end; gap: 6px; position: relative; }
  .sh-about { display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; color: var(--ink); font-size: 14px; font-weight: 500; text-decoration: none; white-space: nowrap; }
  .sh-about:hover, .sh-about[aria-current="page"] { color: var(--brass); }
  .sh-help-btn { display: inline-grid; border: 1px solid var(--line); border-radius: 999px; font-weight: 700; font-size: 16px; background: var(--surface); }
  .sh-help-btn[aria-expanded="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
  .sh-search, .sh-menu-btn { display: none; }
  /* ヘッダーを画面の上に固定する(スマホは固定しない)。白い地と下の細い線は、.app の左右の余白の外まで画面の端から端へ
     (border-image を左右へはみ出させて塗る。はみ出した分は見た目だけで、横のスクロールは出ない。一番下の 1px が線) */
  .sh { position: sticky; top: 0; background: var(--surface);
    border-image: linear-gradient(to top, var(--line) 1px, var(--surface) 1px) 0 fill / 0 / 0 100vmax; }
  /* ページ内のリンク(#…)で飛んだ先が、固定したヘッダーの下に隠れないように */
  html { scroll-padding-top: 72px; }
}
/* 幅がせまいパソコン(タブレット): 文字とすき間を小さく */
@media (min-width: 768px) and (max-width: 960px) {
  .sh-bar { gap: 10px; }
  .sh-logo { gap: 7px; }
  .sh-logo span { font-size: 15px; }
  .sh-nav { gap: 0; }
  .sh-nav a { padding: 0 10px; font-size: 13px; }
  .sh-about { padding: 0 4px; font-size: 13px; }
}
@media print { .st, .sh-right { display: none; } }
