/* ============================================================
   OHNOLOGY UI — Web の土台（色・文字・余白・部品）
   白地に黒い文字。差し色は一点。飾りは最小限。

   使い方: このファイルを製品に写して読み込み、<html data-product="..."> で差し色を選ぶ。
   値を変えたいときは、ここを書き換えずに製品側で変数を上書きする。

   古い iPhone（iOS 15〜16.3）の Safari でも読める書き方だけで書いてある。
   color-mix()・入れ子（&）・:has()・@media (width<=…) は使っていない。
   ============================================================ */

/* ---------- 1. 値 ---------- */
:root {
  /* 面と文字 */
  --paper: #FFFFFF;        /* 画面の地 */
  --surface: #F4F4F4;      /* 一段沈めた面（入力欄の地、表の見出し） */
  --surface-2: #E9E9E9;    /* さらに沈めた面（写真の入る枠、押した状態） */
  --ink: #111111;          /* 文字・主ボタン。真っ黒ではない（白地との境目がちらつかない） */
  --ink-2: #3A3A3A;        /* 本文の補助 */
  --muted: #6E6E6E;        /* 注記・日付（白地で 5.1:1） */
  --line: #E4E4E4;         /* 区切りの線（飾り） */
  --line-2: #CFCFCF;       /* 札・ボタンの枠 */
  --line-3: #8C8C8C;       /* 入力欄の枠（白地で 3.4:1。枠が見えないと入力欄だと分からない） */

  /* 差し色。製品ごとに1色。派生色は scripts/accent.py で出す */
  --accent: #EE7622;       /* 印（点・線・下線）に使う。文字には使わない */
  --accent-ink: #B3520E;   /* 差し色の文字（白地で 5.1:1） */
  --accent-soft: #FDEFE4;  /* 差し色の淡い地 */

  /* 状態。色だけで伝えず、必ず言葉か記号を添える */
  --ok: #197B43;       --ok-soft: #E8F2EC;      /* 文字は淡い地の上でも 4.5:1 以上になる濃さ */
  --warn: #8A5A14;     --warn-soft: #F3EEE8;
  --danger: #B42318;   --danger-soft: #F8E9E8;

  /* 文字。OS 標準を使う。Web フォントは読み込まない（速い・どの端末でも同じに出る） */
  --font-sans: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, system-ui, sans-serif;
  --font-latin: 'Helvetica Neue', Arial, system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --text-display: clamp(30px, 4.2vw, 46px);
  --text-h2: clamp(24px, 3vw, 32px);
  --text-h3: 20px;
  --text-lead: clamp(16px, 1.3vw, 17px);
  --text-body: 16px;
  --text-sm: 14px;
  --text-xs: 13px;
  --text-eyebrow: 12px;
  --lh-body: 1.8;          /* 日本語の本文は行間を広く */
  --lh-head: 1.3;
  --measure: 720px;        /* 本文の1行の長さ（40字前後） */

  /* 余白。4 の倍数だけを使う。半端な値を作らない */
  --s-1: 4px;  --s-2: 8px;   --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px;
  --s-8: 32px; --s-10: 40px; --s-14: 56px; --s-18: 72px; --s-24: 96px;
  --section: clamp(64px, 9vw, 112px);
  --gutter: clamp(20px, 4vw, 40px);
  --container: 1200px;

  /* 角 */
  --r-chip: 4px;
  --r-control: 6px;
  --r-card: 10px;
  --r-card-lg: 16px;
  --r-pill: 999px;

  /* 影。ふだんは線で区切る。影は「浮いている」ものだけ */
  --shadow-1: 0 10px 30px rgba(0, 0, 0, .10);
  --shadow-2: 0 24px 60px rgba(0, 0, 0, .16);

  /* 動き */
  --ease: cubic-bezier(.22, 1, .36, 1);
  --dur-1: .15s;   /* 色の変化 */
  --dur-2: .35s;   /* 位置の変化 */
  --dur-3: .7s;    /* 画面に現れる */

  --tap: 44px;     /* 指で押すものの最小の大きさ */
  --control-h: 48px;
}

/* 暗い画面。data-scheme="dark" で固定、"auto" で端末の設定に従う */
:root[data-scheme="dark"] {
  --paper: #111111; --surface: #1C1C1C; --surface-2: #262626;
  --ink: #F5F5F5; --ink-2: #CFCFCF; --muted: #9A9A9A;
  --line: #2A2A2A; --line-2: #3D3D3D; --line-3: #767676;
  --accent-ink: #EE7622; --accent-soft: #3D2514;
  --ok: #209F56; --ok-soft: #13271B;
  --warn: #BF7D1C; --warn-soft: #292012;
  --danger: #E75449; --danger-soft: #321512;
  --shadow-1: 0 10px 30px rgba(0, 0, 0, .5);
  --shadow-2: 0 24px 60px rgba(0, 0, 0, .6);
}
@media (prefers-color-scheme: dark) {
  :root[data-scheme="auto"] {
    --paper: #111111; --surface: #1C1C1C; --surface-2: #262626;
    --ink: #F5F5F5; --ink-2: #CFCFCF; --muted: #9A9A9A;
    --line: #2A2A2A; --line-2: #3D3D3D; --line-3: #767676;
    --accent-ink: #EE7622; --accent-soft: #3D2514;
    --ok: #209F56; --ok-soft: #13271B;
    --warn: #BF7D1C; --warn-soft: #292012;
    --danger: #E75449; --danger-soft: #321512;
    --shadow-1: 0 10px 30px rgba(0, 0, 0, .5);
    --shadow-2: 0 24px 60px rgba(0, 0, 0, .6);
  }
}

/* 製品ごとの差し色（scripts/accent.py の出力を貼る） */
[data-product="kotsulog"] { --accent: #2E6FD9; --accent-ink: #2667D2; --accent-soft: #E6EEFA; }
[data-product="yukinote"] { --accent: #D9691F; --accent-ink: #AC5319; --accent-soft: #FAEDE4; }
[data-product="gauge"]    { --accent: #009E99; --accent-ink: #007A76; --accent-soft: #E0F3F3; }
[data-product="kotsulog"][data-scheme="dark"] { --accent-ink: #558AE0; --accent-soft: #172439; }
[data-product="yukinote"][data-scheme="dark"] { --accent-ink: #E06E23; --accent-soft: #392314; }
[data-product="gauge"][data-scheme="dark"]    { --accent-ink: #00A19B; --accent-soft: #0E2D2C; }

/* ---------- 2. 土台 ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* 横にはみ出したものがあっても、ページ全体は横に動かさない（最後の受け止め） */
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--lh-body);
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;      /* 長いメールアドレスや URL を枠の端で折る */
  text-wrap: pretty;
}
/* hidden 属性は、display を指定した部品でも必ず隠す */
[hidden] { display: none !important; }
img, svg, video, iframe, canvas { max-width: 100%; display: block; }
img { height: auto; }
input, select, textarea, button { max-width: 100%; font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
p, h1, h2, h3, h4, dl, dd, dt, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4 { line-height: var(--lh-head); font-weight: 700; font-feature-settings: "palt"; text-wrap: balance; }
a { color: inherit; }
/* 鍵盤で操作する人のための枠。消さない */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--accent-soft); color: var(--ink); }

/* ---------- 3. 並べ方 ---------- */
.oh-wrap { width: min(var(--container), 100% - var(--gutter) * 2); margin-left: auto; margin-right: auto; }
.oh-section { padding-top: var(--section); padding-bottom: var(--section); }
.oh-prose { max-width: var(--measure); }
.oh-stack { display: flex; flex-direction: column; gap: var(--s-4); }
.oh-row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.oh-between { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s-6); flex-wrap: wrap; }
/* 列の幅は必ず minmax(0, 1fr)。ただの 1fr だと中身に押されて画面からはみ出す */
.oh-grid { display: grid; gap: var(--s-6); }
.oh-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.oh-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .oh-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .oh-grid--2, .oh-grid--3 { grid-template-columns: minmax(0, 1fr); } }
.oh-divider { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ---------- 4. 文字 ---------- */
.oh-display { font-size: var(--text-display); line-height: 1.28; letter-spacing: .01em; font-weight: 700; }
.oh-h2 { font-size: var(--text-h2); line-height: var(--lh-head); font-weight: 700; }
.oh-h3 { font-size: var(--text-h3); line-height: 1.4; font-weight: 700; }
.oh-lead { font-size: var(--text-lead); color: var(--ink-2); }
.oh-sm { font-size: var(--text-sm); }
.oh-xs { font-size: var(--text-xs); }
.oh-muted { color: var(--muted); }
/* 数字・日付・コードは等幅で、桁をそろえる */
.oh-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
/* 眉（見出しの上の小さな英字）。差し色を使ってよい数少ない場所 */
.oh-eyebrow { font-family: var(--font-latin); font-size: var(--text-eyebrow); letter-spacing: .2em; text-transform: uppercase; font-weight: 600; color: var(--accent-ink); line-height: 1.4; }
/* 本文の中のリンクは下線で示す。色だけで示さない */
.oh-link { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.oh-link:hover { text-decoration-thickness: 2px; }

/* ---------- 5. ボタン ----------
   主ボタンは黒。差し色では塗らない（橙に白字は 2.9:1 で読めない）。1画面に主ボタンは1つ */
.oh-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--control-h); padding: 0 22px; border-radius: var(--r-control);
  font-weight: 700; font-size: 15px; line-height: 1.2; text-decoration: none; text-align: center;
  border: 1px solid transparent; cursor: pointer;
  transition: background-color var(--dur-1), color var(--dur-1), border-color var(--dur-1), transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.oh-btn:hover { transform: translateY(-1px); }
.oh-btn:active { transform: translateY(0); transition-duration: .1s; }
.oh-btn--primary { background: var(--ink); color: var(--paper); }
.oh-btn--primary:hover { box-shadow: var(--shadow-1); }
.oh-btn--secondary { background: var(--paper); color: var(--ink); border-color: var(--line-2); }
.oh-btn--secondary:hover { border-color: var(--ink); }
.oh-btn--quiet { background: transparent; color: var(--ink); padding-left: var(--s-3); padding-right: var(--s-3); }
.oh-btn--quiet:hover { background: var(--surface); transform: none; }
.oh-btn--danger { background: var(--paper); color: var(--danger); border-color: var(--danger); }
.oh-btn--sm { min-height: 38px; padding: 0 14px; font-size: 13px; }   /* 狭い画面では自動で 44px になる（下の @media） */
.oh-btn--block { display: flex; width: 100%; }
.oh-btn[disabled], .oh-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
/* 処理中。押せないことと、進んでいることの両方を示す */
.oh-btn[aria-busy="true"] { cursor: progress; }
.oh-btn[aria-busy="true"]::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: oh-spin .7s linear infinite; }
@keyframes oh-spin { to { transform: rotate(360deg); } }

/* ---------- 6. 札（小さな目印） ---------- */
.oh-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 2px 10px; border-radius: var(--r-chip); font-size: 12px; font-weight: 700; letter-spacing: .04em; line-height: 1.3; max-width: 100%; }
.oh-chip--ink { background: var(--ink); color: var(--paper); }
.oh-chip--line { background: var(--paper); color: var(--ink-2); border: 1px solid var(--line-2); }
.oh-chip--accent { background: var(--accent-soft); color: var(--accent-ink); }
.oh-chip--ok { background: var(--ok-soft); color: var(--ok); }
.oh-chip--warn { background: var(--warn-soft); color: var(--warn); }
.oh-chip--danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- 7. カード ---------- 線で区切る。影は付けない */
.oh-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-card); padding: clamp(20px, 4vw, 28px); min-width: 0; }
.oh-card--lg { border-radius: var(--r-card-lg); padding: clamp(24px, 5vw, 40px); }
.oh-card--sunken { background: var(--surface); border-color: transparent; }
a.oh-card, .oh-card--link { display: block; text-decoration: none; transition: border-color var(--dur-1), transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease); }
a.oh-card:hover, .oh-card--link:hover { border-color: var(--line-2); transform: translateY(-3px); box-shadow: var(--shadow-1); }

/* ---------- 8. 入力欄 ---------- ラベルは必ず欄の外・上に置く（placeholder をラベル代わりにしない） */
.oh-field { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; border: 0; padding: 0; margin: 0; }
.oh-label { font-weight: 700; font-size: var(--text-sm); }
.oh-label .oh-optional { font-weight: 400; color: var(--muted); margin-left: 6px; }
.oh-help { font-size: var(--text-xs); color: var(--muted); }
.oh-error { font-size: var(--text-xs); color: var(--danger); font-weight: 700; }
.oh-input {
  width: 100%; min-height: var(--control-h); padding: 0 14px;
  border: 1px solid var(--line-3); border-radius: var(--r-control);
  background: var(--paper); color: var(--ink);
  font-size: 16px;                /* 16px 未満だと iPhone が入力のたびに画面を拡大する */
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
.oh-input::placeholder { color: var(--muted); }
textarea.oh-input { padding: 12px 14px; line-height: 1.7; resize: vertical; min-height: 120px; }
.oh-input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent-soft); }
.oh-input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.oh-input[disabled] { background: var(--surface); color: var(--muted); cursor: not-allowed; }
.oh-check { display: flex; gap: var(--s-3); align-items: flex-start; font-size: var(--text-sm); min-height: var(--tap); padding: 10px 0; cursor: pointer; }
.oh-check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--ink); }

/* ---------- 9. 切り替え（タブ） ---------- 選ばれているものは黒。差し色は使わない */
.oh-tabs { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.oh-tab { min-height: 38px; padding: 0 18px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--paper); font-size: 13px; font-weight: 700; color: var(--ink); transition: border-color var(--dur-1), background-color var(--dur-1), color var(--dur-1); }
.oh-tab:hover { border-color: var(--ink); }
.oh-tab[aria-selected="true"], .oh-tab[aria-current="page"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
/* 指で押す画面では、小さいボタンと切り替えも 44px まで広げる */
@media (max-width: 820px) { .oh-btn--sm, .oh-tab { min-height: var(--tap); } }

/* ---------- 10. 「見出し｜中身」の表 ---------- 狭い画面では縦に積む */
.oh-kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: var(--s-3) var(--s-6); font-size: var(--text-sm); }
.oh-kv dt { color: var(--muted); }
.oh-kv dd { min-width: 0; }
@media (max-width: 560px) {
  .oh-kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .oh-kv dd + dt { margin-top: var(--s-3); }
}

/* ---------- 11. 一覧の行 ---------- 行全体を押せるようにする */
.oh-list { border-top: 1px solid var(--line); }
.oh-list__row { display: flex; gap: var(--s-4); align-items: center; padding: var(--s-4) 0; min-height: var(--tap); border-bottom: 1px solid var(--line); text-decoration: none; }
.oh-list__main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.oh-list__title { font-weight: 700; }
.oh-list__meta { font-size: var(--text-xs); color: var(--muted); }
a.oh-list__row:hover .oh-list__title { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- 12. お知らせ（帯） ---------- 色だけで種類を伝えない。見出しの言葉で伝える */
.oh-notice { display: flex; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-radius: var(--r-card); background: var(--surface); border-left: 3px solid var(--ink); font-size: var(--text-sm); }
.oh-notice--ok { background: var(--ok-soft); border-left-color: var(--ok); }
.oh-notice--warn { background: var(--warn-soft); border-left-color: var(--warn); }
.oh-notice--danger { background: var(--danger-soft); border-left-color: var(--danger); }
.oh-notice strong { display: block; }

/* ---------- 13. 何も無いとき ---------- 空の画面を白紙にしない。次にできることを1つ示す */
.oh-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-3); padding: var(--s-14) var(--s-5); color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--r-card); }
.oh-empty strong { color: var(--ink); font-size: var(--text-h3); }

/* ---------- 14. 表 ---------- 画面より広い表は、表の中だけ横に動かす */
.oh-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.oh-table { border-collapse: collapse; width: 100%; font-size: var(--text-sm); }
.oh-table th, .oh-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.oh-table th { font-weight: 700; color: var(--muted); font-size: var(--text-xs); white-space: nowrap; }
.oh-table td.oh-num, .oh-table th.oh-num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- 15. 目盛り ---------- OHNOLOGY のしるし。会社のページの区切りに使う。アプリの画面には置かない */
.oh-ticks {
  height: 14px;
  background-image:
    repeating-linear-gradient(90deg, var(--line-2) 0 1px, transparent 1px 10px),
    repeating-linear-gradient(90deg, var(--line-3) 0 1px, transparent 1px 50px);
  background-size: auto 7px, auto 14px;
  background-repeat: repeat-x;
  background-position: left bottom, left bottom;
}

/* ---------- 16. 動き ---------- 動きを止める設定の人には動かさない。JS が無くても中身は見える */
@keyframes oh-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.oh-rise { animation: oh-rise var(--dur-3) var(--ease) both; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* 画面に見えないが、読み上げには伝える文字 */
.oh-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
