/* tabikaban 共通のデザイン（PS-F9〜F12。要件は tabikaban-platform/docs/platform-standards.md）
   原本: tabikaban-id/sso-client/css/tabikaban-ui.css
   写し（各サービスの assets/ など）は、原本から写す。写しを直接直さない（check-shared.py で確かめる）。
   使い方: 各サービスの HTML で、自分の css より先に読む。自分の css の変数を、ここの --tb-* に合わせる。
   暗い表示を止めるには、html に data-theme="light" を付ける。 */

/* ---- 色（ホームページの紙と藍。アクセントは全サービス共通） ---- */
:root {
  --tb-accent: #0b7285;
  --tb-accent-strong: #095e6e;
  --tb-accent-ink: #fffdf6;
  --tb-accent-soft: #dcecef;
  --tb-danger: #b3261e;
  --tb-paper: #faf9f7;
  --tb-card: #fffdf6;
  --tb-ink: #3b3226;
  --tb-muted: #6e6250;
  --tb-line: #cdbf9f;
  --tb-radius: 10px;
  --tb-border: 1.5px;
  --tb-font: "M PLUS 1p", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tb-accent: #4dc4d8;
    --tb-accent-strong: #8fdce9;
    --tb-accent-ink: #1c1d1f;
    --tb-accent-soft: #1f3a40;
    --tb-danger: #ff8f86;
    --tb-paper: #1c1d1f;
    --tb-card: #26272a;
    --tb-ink: #ecebe8;
    --tb-muted: #a7a6a2;
    --tb-line: #47484c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --tb-accent: #4dc4d8;
  --tb-accent-strong: #8fdce9;
  --tb-accent-ink: #1c1d1f;
  --tb-accent-soft: #1f3a40;
  --tb-danger: #ff8f86;
  --tb-paper: #1c1d1f;
  --tb-card: #26272a;
  --tb-ink: #ecebe8;
  --tb-muted: #a7a6a2;
  --tb-line: #47484c;
  color-scheme: dark;
}

/* ---- テキスト入力（PS-F11）: 文字16px（iPhone の拡大を防ぐ）・高さ44px 以上 ----
   :where で詳細度を0にしてあり、各サービスの部品の指定が勝つ。 */
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]), select, textarea) {
  font: inherit;
  font-size: 16px;
  min-height: 44px;
  max-width: 100%;
  padding: 10px 12px;
  color: var(--tb-ink);
  background: var(--tb-card);
  border: var(--tb-border) solid var(--tb-line);
  border-radius: var(--tb-radius);
  box-sizing: border-box;
}
:where(textarea) { min-height: 88px; line-height: 1.6; }
:where(input, select, textarea):focus-visible {
  outline: 2px solid var(--tb-accent);
  outline-offset: 0;
  border-color: var(--tb-accent);
}
:where(input, select, textarea)::placeholder { color: var(--tb-muted); opacity: .8; }

/* ---- ボタン（PS-F10）: メイン・サブ・危険の3種類。角丸10px・高さ44px 以上 ---- */
.tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--tb-accent);
  background: var(--tb-card);
  border: var(--tb-border) solid var(--tb-accent);
  border-radius: var(--tb-radius);
  text-decoration: none;
  cursor: pointer;
}
.tb-btn--primary { color: var(--tb-accent-ink); background: var(--tb-accent); }
.tb-btn--danger { color: #fff; background: var(--tb-danger); border-color: var(--tb-danger); }

/* 状態（PS-F15）: 押せるものは、指すと色が変わり、押すと1px沈む。押せないものは半透明。 */
.tb-btn:hover { background: var(--tb-accent-soft); }
.tb-btn--primary:hover { background: var(--tb-accent-strong); border-color: var(--tb-accent-strong); }
.tb-btn--danger:hover { filter: brightness(.92); }
.tb-btn:active:not(:disabled) { transform: translateY(1px); }
.tb-btn:disabled { opacity: .5; cursor: default; }
/* キーボードで選んだときだけ見える枠（PS-F15）。ボタン・チップ・リンク・入力欄の共通 */
:where(button, a, [role="button"], [role="tab"], [role="switch"], select, input, textarea):focus-visible {
  outline: 2px solid var(--tb-accent);
  outline-offset: 2px;
}

/* ---- 下から出る画面の取っ手（PS-F13）: 開くのはタップ。閉じるのはタップか下スワイプ ---- */
.tb-sheet-grab {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  cursor: grab;
  touch-action: none;
}
.tb-sheet-grab::before {
  content: "";
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--tb-line);
}

/* 紙と文字の基本（PS-F12）。本文の大きさは各サービスが決める（16px を下回らない） */
.tb-paper { background: var(--tb-paper); color: var(--tb-ink); font-family: var(--tb-font); }

/* ---- サービスタブ（PS-F17）。部品: tabikaban-tabs.js。高さは --tb-tabs-h（JS が設定） ---- */
.tb-tabs {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  justify-content: center;
  box-sizing: border-box;
  height: calc(52px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 8px 0;
  background: var(--tb-paper);
  border-bottom: 1.5px solid var(--tb-line);
  font-family: var(--tb-font);
}
.tb-tabs[hidden] { display: none; }
.tb-tab {
  position: relative;
  flex: 1 1 0;
  max-width: 108px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--tb-muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.tb-tab-icon { border-radius: 6px; background: #fff; opacity: .72; }
.tb-tab:hover { background: var(--tb-accent-soft); color: var(--tb-ink); }
.tb-tab:active { transform: translateY(1px); }
.tb-tab[aria-current="page"] { color: var(--tb-accent); }
.tb-tab[aria-current="page"] .tb-tab-icon { opacity: 1; }
.tb-tab[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 14%;
  right: 14%;
  bottom: -1.5px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--tb-accent);
}
/* 広い画面: アイコンと名前を横に並べる */
@media (min-width: 640px) {
  .tb-tab { flex-direction: row; gap: 8px; font-size: 14px; max-width: 150px; }
}
/* 普通にスクロールする画面は、タブの高さの分だけ body の上に余白を足す（地図など固定の画面は、各サービスで --tb-tabs-h を使ってずらす） */
html.tb-has-tabs body { padding-top: var(--tb-tabs-h, 0px); }
/* PC（1024px 以上）: 各サービスの「？」と利用者アイコンの入れ物（.tb-tabs-actions）を、タブの行の右端に置く。
   サービス名の横の一言説明（.tb-lede）は、PC だけ出す（スマホは場所がないため出さない） */
.tb-lede { display: none; }
@media (min-width: 1024px) {
  html.tb-has-tabs .tb-tabs-actions {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 4px);
    right: 16px;
    z-index: 61;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    margin: 0;
  }
  .tb-lede {
    display: block;
    margin: 0;
    color: var(--tb-muted);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.55;
    word-break: auto-phrase;   /* 折り返すときは、文節の区切りで */
  }
  /* 1文ずつ <span> で囲む。幅が足りないときは、文と文の間で改行する */
  .tb-lede > span { display: inline-block; }
}
@media (prefers-reduced-motion: reduce) { .tb-tab:active { transform: none; } }
