/* CAL-01 カロリー計算機のスタイル。節ごとに担当が決まっている(tool=S0・S1、notes=S2、a11y=S3、ads=S4)。 */

/* tool */
[hidden] { display: none !important; }

/* 結果の数字・見出しは中立の色(区分で赤・緑・橙に変えない) */
#results .result-value,
#results .pfc-value,
#results .meal-value { color: inherit; }
#results .result-card { border-top-color: #94a3b8; }

/* 入力エラー(検証は JS。ブラウザ標準の吹き出しは使わない) */
#form-error {
  margin: 20px 0 0;
  padding: 14px 16px;
  border: 2px solid #b45309;
  border-radius: 12px;
  background: #fffbeb;
  color: #7c2d12;
  font-size: 1rem;
  line-height: 1.7;
}
#form-error p { margin: 0 0 6px; font-weight: 700; }
#form-error ul { margin: 0; padding-left: 1.4em; }

/* 自己申告(任意) */
.care-fieldset {
  margin: 20px 0 0;
  padding: 14px 16px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #fff;
}
.care-fieldset legend { padding: 0 6px; font-size: 1rem; font-weight: 700; color: #1f2d29; }
.care-option { display: flex; align-items: flex-start; gap: 10px; padding: 10px 4px; min-height: 44px; font-size: 1rem; line-height: 1.6; cursor: pointer; }
.care-option input { width: 22px; height: 22px; flex: 0 0 22px; margin-top: 4px; }
.care-note { margin: 8px 0 0; font-size: 0.9rem; color: #475569; line-height: 1.7; }

/* 止めた・計画を出さない表示 */
#res-stop {
  margin: 0 0 24px;
  padding: 16px 18px;
  border: 2px solid #94a3b8;
  border-radius: 12px;
  background: #f8fafc;
  color: #1f2d29;
  font-size: 1rem;
  line-height: 1.8;
}
#res-stop p { margin: 0; }
#res-activity-note { margin: 0 0 24px; text-align: center; font-size: 0.95rem; color: #475569; }

/* S1: 最初の画面に h1 と入力欄を出す(ヒーローは h1+1文だけ) */
.container .header { margin: 8px 0 20px; padding: 28px 24px; }
.container .header p { margin: 0; font-size: 1rem; line-height: 1.6; }
.field-error:empty { display: none; }
@media (max-width: 640px) {
  .container .header { margin: 4px 0 10px; padding: 14px; border-radius: 18px; }
  .container .header h1 { font-size: 1.35rem !important; margin: 0 0 6px; line-height: 1.3; }
  .container .header p { font-size: 0.9rem; line-height: 1.5; }
  .calculator-card { padding: 14px; }
  .calculator-card .calculator-title { font-size: 1.05rem !important; line-height: 1.4; margin-bottom: 10px; padding-bottom: 8px; }
  .form-grid { gap: 8px !important; margin-bottom: 12px; }
  .form-group { gap: 4px !important; margin-bottom: 8px !important; }
  .form-label { margin-bottom: 0; font-size: 1rem; }
  .form-input, .form-select { padding: 12px 14px !important; min-height: 50px !important; }
}

/* 結果への着地(JS が固定ヘッダーの高さを足す。無いときの既定) */
#result-heading { scroll-margin-top: 88px; }

/* 活動レベルの選び方 */
.activity-help { margin: 8px 0 0; color: #334155; font-size: 0.95rem; line-height: 1.7; }
.activity-help p { margin: 0 0 6px; }

/* 入力を消す(計算ボタンより目立たせない) */
.clear-inputs { display: block; width: 100%; min-height: 48px; margin-top: 12px; font-size: 1rem; }

/* notes */
#safety-notes { margin: 0 0 24px; padding: 16px 18px; border: 1px solid #94a3b8; border-radius: 12px; background: #f8fafc; color: #1f2d29; }
#safety-notes .safety-note { margin: 0 0 12px; font-size: 14px; line-height: 1.8; overflow-wrap: anywhere; }
#safety-notes .safety-note:last-child { margin-bottom: 0; }
#safety-notes .safety-note a { color: #1d4ed8; text-decoration: underline; font-size: 14px; }
#safety-notes-dyn:empty { display: none; }
#safety-notes-dyn { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid #cbd5e1; }
.export-status { margin: 12px 0 0; min-height: 1.6em; font-size: 14px; line-height: 1.6; color: #1f2d29; text-align: center; }
@media print { #safety-notes, #note-fixed { display: block !important; } }

/* a11y */
/* 文字は 14px 以上。index.html のインライン style は書き換えず、値ごとに属性セレクタで引き上げる(S2・S4 が同じ行を編集しても衝突しない)。 */
[style*="font-size:0.85rem"],
[style*="font-size: 0.85rem"],
[style*="font-size:.85rem"],
[style*="font-size: .85rem"],
[style*="font-size:0.8rem"],
[style*="font-size: 0.8rem"],
[style*="font-size:.8rem"],
[style*="font-size: .8rem"],
[style*="font-size:0.78rem"],
[style*="font-size: 0.78rem"],
[style*="font-size:.78rem"],
[style*="font-size: .78rem"],
[style*="font-size:0.75rem"],
[style*="font-size: 0.75rem"],
[style*="font-size:.75rem"],
[style*="font-size: .75rem"],
[style*="font-size:0.72rem"],
[style*="font-size: 0.72rem"],
[style*="font-size:.72rem"],
[style*="font-size: .72rem"],
[style*="font-size:0.7rem"],
[style*="font-size: 0.7rem"],
[style*="font-size:.7rem"],
[style*="font-size: .7rem"],
[style*="font-size:0.68rem"],
[style*="font-size: 0.68rem"],
[style*="font-size:.68rem"],
[style*="font-size: .68rem"],
[style*="font-size:0.6rem"],
[style*="font-size: 0.6rem"],
[style*="font-size:.6rem"],
[style*="font-size: .6rem"],
[style*="font-size:.83rem"],
[style*="font-size: .83rem"],
[style*="font-size:0.83rem"],
[style*="font-size: 0.83rem"],
[style*="font-size:0.82rem"],
[style*="font-size: 0.82rem"],
[style*="font-size:.82rem"],
[style*="font-size: .82rem"],
[style*="font-size:0.85em"],
[style*="font-size: 0.85em"],
[style*="font-size:.85em"],
[style*="font-size: .85em"],
[style*="font-size:0.8em"],
[style*="font-size: 0.8em"],
[style*="font-size:.8em"],
[style*="font-size: .8em"],
[style*="font-size:12px"],
[style*="font-size: 12px"],
[style*="font-size:11px"],
[style*="font-size: 11px"],
[style*="font-size:10px"],
[style*="font-size: 10px"],
[style*="font-size:13px"],
[style*="font-size: 13px"],
[style*="font-size:0.8125rem"],
[style*="font-size: 0.8125rem"] { font-size: 14px !important; }
/* 出典の小さい字(small・.note)は 13px まで */
small, .note { font-size: max(13px, 0.8125rem); }
/* 一覧のスタイルシート側にある 14px 未満 */
.field-error { font-size: 0.9rem; }

/* 補足文・エラー文の色(白地で 4.5:1 以上) */
.result-description { color: #4a5568; }
.field-error { color: #b91c1c; }
[style*=";color:#a0aec0"], [style*=" color:#a0aec0"], [style^="color:#a0aec0"] { color: #4a5568 !important; }
[style*=";color:#9ca3af"], [style*=" color:#9ca3af"], [style^="color:#9ca3af"] { color: #4b5563 !important; }
[style*=";color:#718096"], [style*=" color:#718096"], [style^="color:#718096"] { color: #4a5568 !important; }
[style*=";color:#999"], [style*=" color:#999"], [style^="color:#999"] { color: #595959 !important; }

/* 選んだ性別のボタン: 白字が読める濃い緑に。マウスを載せても(インラインの onmouseover が背景を薄くしても)読める */
.gender-btn[aria-pressed="true"], .gender-btn[aria-pressed="true"]:hover { background: #047857 !important; border-color: #047857 !important; color: #fff !important; }

/* 止める・情報だけの表示でカードが全部隠れたとき、空の格子の余白を残さない */
.results-grid:not(:has(> .result-card:not([hidden]))) { display: none !important; }

/* スタイルシート側の小さい字・薄い色 */
.trust-badges span, .trust-badges span:nth-child(3), .nutri-chip p, .disclaimer, .nutri-chip h3 { font-size: 14px !important; }
.nutri-chip p { color: #4a5568; }
.trust-badges span:nth-child(3) { max-width: 100% !important; }
.result-unit { color: #4a5568; }
[style*="background:#1DA1F2"] { background: #0a6ea3 !important; }
[style*="background:#1877F2"] { background: #1558c0 !important; }
[style*="background:#06C755"] { background: #04703a !important; }

/* 結果表示後の横あふれ: 食事配分・PFC の格子は幅に合わせて折り返す */
#mealDistribution > div[style*="grid-template-columns"] { grid-template-columns: repeat(auto-fit, minmax(min(100%, 112px), 1fr)) !important; }
#card-pfc > div[style*="grid-template-columns"] { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)) !important; }
#results .chart-container, #results canvas { max-width: 100%; }
#results { min-width: 0; }
#results * { overflow-wrap: anywhere; }
.cal-crumbs { white-space: normal !important; overflow: visible !important; text-overflow: clip !important; }

/* 狭い幅(拡大表示を含む)で横あふれを作らない: 最小幅つきの格子・表・固定幅の広告枠を幅に収める */
@media (max-width: 480px) {
  .form-grid, .results-grid, .product-features,
  [style*="repeat(auto-fit,minmax("], [style*="repeat(auto-fill,minmax("] { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)) !important; }
  button:not([id^="consent-"]), [class*=btn]:not([id^="consent-"]) { min-width: 0 !important; max-width: 100%; box-sizing: border-box; }
  main table, .container table, section table { display: block; max-width: 100%; overflow-x: auto; }
  td, th { overflow-wrap: anywhere; }
  .ads-rakuten, .ads-rakuten table, .ads-rakuten tbody, .ads-rakuten tr, .ads-rakuten td { display: block; width: auto !important; max-width: 100%; box-sizing: border-box; overflow: visible; }
  .ads-rakuten div[style*="width"] { width: auto !important; max-width: 100%; box-sizing: border-box; }
  .ads-rakuten img { max-width: 100%; height: auto; }
}

/* タップ対象は 44px 以上(文中のリンクを除く) */
.site-header .logo a,
.cal-topbar a, .cal-crumbs a, .nav-links a,
.footer-links a, .cal-org a,
li > a:only-child, td a,
#static-share-section a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; box-sizing: border-box; }
.ads-rakuten td a { display: inline; min-width: 0; min-height: 0; }
.ads-rakuten td > a { display: block; min-height: 44px; }
/* 既定のボタンは 13.3px。クラスで大きさが決まっているボタンは変えない */
:where(button:not([id^="consent-"])) { font-size: 1rem; }
.footer-links a { padding: 0 6px; }
.cal-topbar a, .cal-crumbs a, .cal-org a { padding: 0 6px; }
.hamburger { min-width: 44px; min-height: 44px; }
.site-header .hamburger { width: auto !important; }

/* 同意バナー(共有物)が最後の本文や「ページトップへ」を覆わない。高さは cal-a11y.js が --cal-banner-h に入れる */
body { padding-bottom: var(--cal-banner-h, 0px); }
#back-to-top { bottom: calc(var(--cal-banner-h, 0px) + 24px) !important; }

/* 結果の出現は、位置をずらさず薄い状態から出すだけにする(HEAD の fadeInUp は 30px 下から動かすため、
   着地のスクロール位置が動き終わりの分だけずれて、見出しが固定ヘッダーの下に隠れた) */
@keyframes cal-fade-in { from { opacity: 0; } to { opacity: 1; } }
.results.show { animation: cal-fade-in 0.4s ease; }

/* 動きを減らす設定では結果のアニメーション・滑らかなスクロールを止める */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ads */
#ads-block {
  box-sizing: border-box;
  width: calc(100% - 32px);
  max-width: 728px;
  margin: 28px auto;
  padding: 18px 16px 20px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  color: #1f2937;
  line-height: 1.7;
}
#ads-block .ads-heading { margin: 0 0 8px; font-size: 1.1rem; font-weight: 700; color: #334155; }
#ads-block .ads-sub { margin: 18px 0 8px; font-size: 1rem; font-weight: 700; color: #334155; }
#ads-block .ads-note { margin: 0 0 6px; font-size: 0.9rem; color: #334155; }
#ads-block .ads-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
#ads-block .ads-link {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid #64748b;
  border-radius: 10px;
  background: #fff;
  color: #1e293b;
  font-size: 0.95rem;
  line-height: 1.5;
  text-decoration: none;
  overflow-wrap: anywhere;
}
#ads-block .ads-link:hover { background: #f1f5f9; }
#ads-block .ads-link:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
#ads-block .ads-pixel { position: absolute; width: 1px; height: 1px; border: 0; }
/* 楽天のウィジェットは各社の生成マークアップ。href と文言は編集せず、幅だけ収める */
#ads-block .ads-rakuten { max-width: 100%; overflow: hidden; margin-top: 8px; }
#ads-block .ads-rakuten table,
#ads-block .ads-rakuten div[style*="width:504px"] { width: 100% !important; max-width: 100% !important; box-sizing: border-box; }
#ads-block .ads-rakuten td { display: block; width: auto !important; max-width: 100%; }
#ads-block .ads-rakuten td > div { max-width: 100%; }
#ads-block .ads-rakuten img { max-width: 100%; height: auto; }
.footer .ads-footnote, .footer .updated { margin: 8px 0 0; font-size: 0.9rem; }
/* 本体の .js-track-affiliate(!important の大きな余白・太字・浮き上がり)を、この枠のリンクでは打ち消す(計測用のクラスは残す) */
#ads-block .ads-link.js-track-affiliate {
  font-size: 0.95rem !important;
  font-weight: 600 !important;
  padding: 10px 14px !important;
  border-radius: 10px !important;
  transition: none !important;
}
#ads-block .ads-link.js-track-affiliate:hover { transform: none !important; box-shadow: none !important; }
