/* ============================================================
   ingredient-calc.css
   ポケモンスリープ 食材個数計算ツール

   ・すべて .ingcalc 配下にスコープ済み（既存サイトのCSSと衝突しません）
   ・配色は :root ではなく .ingcalc の変数で定義。
     既存サイトのテーマに合わせる場合はこの変数だけ上書きしてください。
   ============================================================ */

.ingcalc {
  /* --- テーマ変数（ここだけ差し替えればOK） --- */
  --ic-bg:        #f4f6fb;  /* 全体の背景 */
  --ic-card:      #ffffff;  /* パネル背景 */
  --ic-ink:       #1e2436;  /* 本文 */
  --ic-ink-sub:   #7a8399;  /* 補助テキスト */
  --ic-line:      #e3e7f0;  /* 罫線 */
  --ic-accent:    #3d5a9e;  /* フォーカス・リンク */
  --ic-accent-bg: #eaf0ff;  /* ホバー */
  --ic-mark:      #ffd75e;  /* 選択中（A食材） */
  --ic-mark-deep: #b98a00;  /* 選択中の文字色 */
  --ic-mark-row:  #fff8e1;  /* 選択中の行背景 */
  --ic-good:      #2f9e58;  /* お得(緑) */
  --ic-bad:       #e2483d;  /* 損(赤) */
  --ic-radius:    12px;
  --ic-font: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;

  box-sizing: border-box;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  color: var(--ic-ink);
  background: var(--ic-bg);
  font-family: var(--ic-font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
.ingcalc *,
.ingcalc *::before,
.ingcalc *::after { box-sizing: inherit; }

/* --- 見出し --- */
.ingcalc__title { font-size: 1.15rem; letter-spacing: .04em; margin: 0 0 4px; }
.ingcalc__lead  { margin: 0 0 14px; font-size: .8rem; color: var(--ic-ink-sub); }

/* --- トグル行(とくいなもの + 割合を表示) --- */
.ingcalc__toggle-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 8px;
}
.ingcalc__typesel {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--ic-card);
  border: 1px solid var(--ic-line);
  border-radius: var(--ic-radius);
  padding: 10px 14px;
}
.ingcalc__typesel b { font-size: .92rem; white-space: nowrap; }
.ingcalc__typebtns {
  margin-left: auto;
  display: flex;
  gap: 3px;
  background: var(--ic-line);
  border-radius: 999px;
  padding: 3px;
}
.ingcalc__typebtn {
  padding: 5px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ic-ink-sub);
  font: inherit;
  font-size: .74rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.ingcalc__typebtn.is-active {
  background: var(--ic-mark);
  color: var(--ic-mark-deep);
}

/* 割合を表示トグル(小さめボタン) */
.ingcalc__pctbtn {
  flex: none;
  align-self: center;
  padding: 6px 10px;
  border: 1px solid var(--ic-line);
  border-radius: 999px;
  background: var(--ic-card);
  color: var(--ic-ink-sub);
  font: inherit;
  font-size: .68rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.ingcalc__pctbtn.is-on {
  background: var(--ic-accent);
  border-color: var(--ic-accent);
  /* --ic-accent(=--navy)はダークモードで明転するため、常に白固定だと
     沈んでしまう。地の色と一緒に反転する--selected-inkを使う。 */
  color: var(--selected-ink, #fff);
}

.ingcalc__dealnote {
  margin: 0 0 10px;
  font-size: .72rem;
  color: var(--ic-ink-sub);
}
.ingcalc__dealnote-good { color: var(--ic-good); font-weight: 700; }
.ingcalc__dealnote-bad { color: var(--ic-bad); font-weight: 700; }

/* --- 本体テーブル --- */
.ingcalc__board {
  background: var(--ic-card);
  border: 1px solid var(--ic-line);
  border-radius: var(--ic-radius);
  overflow: hidden;
}
.ingcalc__board table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.ingcalc__board col.ingcalc__col-a { width: 46%; }

.ingcalc__board thead th {
  padding: 9px 6px;
  background: #fafbfe;
  border-bottom: 1px solid var(--ic-line);
  color: var(--ic-ink-sub);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
}
.ingcalc__board thead th:first-child { text-align: left; padding-left: 12px; }

.ingcalc__board tbody td {
  height: 44px;
  padding: 0;
  border-bottom: 1px solid var(--ic-line);
  border-left: 1px solid var(--ic-line);
  text-align: center;
}
.ingcalc__board tbody td:first-child { border-left: 0; }
.ingcalc__board tbody tr:last-child td { border-bottom: 0; }

/* 割合を表示ON時は3段(個数/エナジー/割合バッジ)になるため高さを可変にする */
.ingcalc.is-pctmode .ingcalc__board tbody td:not(:first-child) {
  height: auto;
  padding: 6px 0;
}

/* --- A食材の選択ボタン（1列目） --- */
.ingcalc__pick {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  height: 100%;
  padding: 0 10px 0 12px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: .84rem;
  text-align: left;
  cursor: pointer;
}
.ingcalc__pick:hover { background: var(--ic-accent-bg); }
.ingcalc__pick:focus-visible { outline: 2px solid var(--ic-accent); outline-offset: -2px; }
.ingcalc__icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex: none;
}
.ingcalc__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ingcalc__energy {
  margin-left: auto;
  color: var(--ic-ink-sub);
  font-size: .7rem;
  font-variant-numeric: tabular-nums;
}

/* --- 選択中の行 --- */
.ingcalc__row.is-selected td { background: var(--ic-mark-row); }
.ingcalc__row.is-selected .ingcalc__pick {
  background: var(--ic-mark);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--ic-mark-deep);
}
.ingcalc__row.is-selected .ingcalc__energy { color: var(--ic-mark-deep); }

/* --- 個数表示 --- */
.ingcalc__count {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.ingcalc__subrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}
.ingcalc__sub {
  color: var(--ic-ink-sub);
  font-size: .64rem;
  font-variant-numeric: tabular-nums;
}
.ingcalc__sub--good { color: var(--ic-good); font-weight: 700; }
.ingcalc__sub--bad { color: var(--ic-bad); font-weight: 700; }
.ingcalc__dash { color: var(--ic-ink-sub); font-size: .9rem; }

/* --- 損得の割合バッジ(株価アプリ風の小さいピル)。エナジー(括弧内)の隣に並べる --- */
.ingcalc__pct {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--ic-line);
  color: var(--ic-ink-sub);
  font-size: .6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ingcalc__pct--good { background: var(--ic-good); color: #fff; }
.ingcalc__pct--bad { background: var(--ic-bad); color: #fff; }

/* --- 注記 --- */
.ingcalc__note {
  margin-top: 14px;
  color: var(--ic-ink-sub);
  font-size: .72rem;
  line-height: 1.7;
}
.ingcalc__note code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--ic-accent-bg);
  color: var(--ic-accent);
  font-size: .95em;
}

/* --- 狭い画面 --- */
@media (max-width: 420px) {
  .ingcalc { padding: 10px; }
  .ingcalc__board col.ingcalc__col-a { width: 50%; }
  .ingcalc__pick { padding-left: 8px; font-size: .78rem; }
  .ingcalc__energy { display: none; }
}
