/* ==========================================================================
   app.css — Texas BBQ Manager
   theme: tone=dark color=red | design-studio

   このファイルの色・サイズ・余白はすべて tokens.css の変数を経由する。
   下の :root は tokens.css に無い項目だけを足したもので、根拠を各行に書く。
   ========================================================================== */

:root {
  /* タッチターゲット下限（WCAG 2.1 AA）。屋外・手袋での操作を想定 */
  --tap: 44px;

  /* チャート系列色。dataviz の既定（#CC0000 / #3E5C76）は白地前提で、
     ダーク面 #2D2D2D 上ではコントラストが 4.5:1 に届かない。
     アクセシビリティ規定を優先し、同系の明色版に置き換える。 */
  --viz-meat: #F0918A;   /* 主系列＝肉温（アクセント系の明色版） */
  --viz-pit:  #7FC3EE;   /* 比較系列＝ピット温（スレート系の明色版） */
  --viz-grid: rgba(255, 255, 255, .10);
  --viz-axis: rgba(255, 255, 255, .30);
  --viz-band: rgba(127, 195, 238, .10);

  /* CTA の琥珀に白文字はコントラストが 2.1:1 しか出ない。
     WCAG 4.5:1 を満たすため、主ボタンの文字だけ濃色を使う（6.6:1）。 */
  --cta-ink: #2D2D2D;

  --maxw: 760px;   /* 1カラム。スマホ縦持ちが基準 */
}

*, *::before, *::after { box-sizing: border-box; }

/* hidden 属性は .field などの display 指定より優先する（計画フォームの出し分け） */
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  padding-bottom: calc(var(--tap) + var(--sp-4) + var(--sp-3));  /* 下の固定ボタンぶん */
  -webkit-text-size-adjust: 100%;
}

.num { font-feature-settings: 'tnum'; font-variant-numeric: tabular-nums; }

/* --- 安全表示（§26 常時） ------------------------------------------------- */

.safety-strip {
  width: 100%;
  background: var(--alt);
  border-bottom: 1px solid var(--rule);
  color: var(--ink-note);
  font-size: var(--fs-note);
  line-height: 1.7;
  padding: var(--sp-1) var(--sp-2);
}
.safety-strip .wrap { max-width: var(--maxw); margin: 0 auto; }
.safety-strip b { font-weight: 700; }

/* --- ヘッダー -------------------------------------------------------------- */

.app-header {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--sp-2) var(--sp-2) 0;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.app-title {
  margin: 0;
  font-size: var(--fs-h3);
  font-weight: 700;
  letter-spacing: .04em;
}
.app-title span { color: var(--ink-sub); font-weight: 400; font-size: var(--fs-note); margin-left: var(--sp-1); }
.head-sub { margin: 4px 0 0; font-size: var(--fs-body); color: var(--ink); }
.head-sub b { font-weight: 700; }

/* --- レイアウト ------------------------------------------------------------ */

main { max-width: var(--maxw); margin: 0 auto; padding: var(--sp-2) var(--sp-2) 0; }
main > * + * { margin-top: var(--sp-2); }

/* --- カード ---------------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-card);
  padding: var(--sp-2) var(--sp-3);
}
.card-head {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  color: var(--ink-sub);
  font-size: var(--fs-note);
  letter-spacing: .08em;
  margin-bottom: var(--sp-1);
}
.card-head .right { margin-left: auto; letter-spacing: 0; }
.card p { margin: var(--sp-1) 0 0; }
.card p.tight { margin-top: 4px; }
.note { font-size: var(--fs-note); color: var(--ink-note); }
.sub { color: var(--ink-sub); }

/* --- 提案（状態は色＋記号。色だけに意味を持たせない） ---------------------- */

.advice .advice-alert  { color: var(--alert); }
.advice .advice-notice { color: var(--notice-tag); }
.advice .advice-info   { color: var(--ink); }

/* --- 段取りの1行 ----------------------------------------------------------- */

.plan-line .steps {
  display: flex;
  flex-wrap: wrap;
  gap: 4px var(--sp-2);
  font-size: var(--fs-note);
  color: var(--ink-sub);
}
.plan-line .step b { color: var(--ink); font-weight: 700; }
.plan-line .step.done { color: var(--ink-sub); }
.plan-line .step.done b { color: var(--ink-sub); font-weight: 400; text-decoration: line-through; }
.plan-line .btn-text { margin-top: var(--sp-1); }

/* --- チャート -------------------------------------------------------------- */

.chart-card { padding: var(--sp-2); }
.chart { width: 100%; height: auto; display: block; }
.chart-note { margin: var(--sp-1) var(--sp-1) 0; }
.chart-card > .note:last-child { margin: var(--sp-1) var(--sp-1) var(--sp-1); }

.chart-grid { stroke: var(--viz-grid); stroke-width: 1; }
.chart-grid-v { stroke-dasharray: 1 3; }
.chart-axis-line { stroke: var(--viz-axis); stroke-width: 1; }
.chart-axis { fill: var(--ink-sub); font-size: var(--fs-note); font-family: var(--font); font-feature-settings: 'tnum'; }
.chart-band { fill: var(--viz-band); }
.chart-line { fill: none; stroke-width: 2; }
.chart-sim { stroke-dasharray: 5 5; opacity: .55; }
.chart-pit { stroke: var(--viz-pit); }
.chart-meat { stroke: var(--viz-meat); }
.chart-dot.chart-pit { fill: var(--viz-pit); stroke: none; }
.chart-dot.chart-meat { fill: var(--viz-meat); stroke: none; }
.chart-value { font-size: var(--fs-note); font-weight: 700; font-family: var(--font); font-feature-settings: 'tnum'; stroke: none; }
.chart-value.chart-pit { fill: var(--viz-pit); }
.chart-value.chart-meat { fill: var(--viz-meat); }
.chart-mark { stroke: var(--rule-strong); stroke-width: 1; stroke-dasharray: 3 4; }
.chart-mark.done { stroke-dasharray: none; }
.chart-mark-label { fill: var(--ink); font-size: var(--fs-note); font-weight: 700; font-family: var(--font); }
.chart-mark-label.done { fill: var(--ink-sub); font-weight: 400; }
.chart-now { stroke: var(--key); stroke-width: 1.5; }
.chart-now-label { fill: var(--key-text); font-size: var(--fs-note); font-weight: 700; font-family: var(--font); }
.chart-wood { fill: none; stroke: var(--ink-sub); stroke-width: 1.5; }
.chart-wood-actual { fill: var(--ink-sub); }
.chart-fuel { fill: var(--ink-sub); }

/* --- ボタン ---------------------------------------------------------------- */

.btn {
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  padding: 0 var(--sp-3);
  border-radius: var(--radius-btn);
  font: inherit;
  font-size: var(--fs-btn);
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  text-align: center;
}
.btn-primary { background: var(--cta); color: var(--cta-ink); box-shadow: var(--btn-shadow); }
.btn-primary:hover { background: var(--cta-hover); }
.btn-secondary { background: var(--card); color: var(--ink); border-color: var(--key); }
.btn-secondary:hover { background: var(--key-pale); }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--rule-strong); }
.btn-quiet:hover { background: var(--alt); }
.btn-text {
  min-height: var(--tap);
  background: none; border: 0; padding: 0 var(--sp-1);
  color: var(--key-text); font: inherit; font-size: var(--fs-note);
  text-decoration: underline; cursor: pointer;
}
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-top: var(--sp-2); }
.btn-row .btn { flex: 1 1 auto; }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
summary:focus-visible { outline: 2px solid var(--key-text); outline-offset: 2px; }

/* --- 入力 ------------------------------------------------------------------ */

.field { display: block; margin-bottom: var(--sp-2); }
.field > span { display: block; font-size: var(--fs-note); color: var(--ink-note); margin-bottom: 4px; }
.field > span em { font-style: normal; color: var(--ink-sub); }

input[type="number"], input[type="text"], input[type="time"], input[type="datetime-local"],
select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: var(--sp-1) var(--sp-2);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-btn);
  font: inherit;
  font-size: var(--fs-body);
}
textarea { min-height: calc(var(--tap) * 2); line-height: 1.7; }

.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.inline-fields .field { margin-bottom: 0; }

.temp-entry { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.temp-entry .field { margin-bottom: 0; }
.temp-entry input { font-size: var(--fs-h2); font-weight: 700; text-align: center; }

/* チェックリスト */
.checks { list-style: none; margin: var(--sp-1) 0 0; padding: 0; }
.checks li + li { border-top: 1px solid var(--divider); }
.checks label {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  min-height: var(--tap); padding: var(--sp-1) 0; cursor: pointer;
}
.checks input[type="checkbox"] { width: 22px; height: 22px; margin-top: 3px; flex: 0 0 auto; accent-color: var(--key); }

/* --- ログ ------------------------------------------------------------------ */

.log { list-style: none; margin: 0; padding: 0; }
.log li { display: grid; grid-template-columns: 56px 1fr auto; gap: var(--sp-2); align-items: center; padding: var(--sp-1) 0; border-bottom: 1px solid var(--divider); }
.log li.editable { cursor: pointer; min-height: var(--tap); }
.log li.editable:hover { background: var(--alt); }
.log .edit-mark { color: var(--ink-sub); font-size: var(--fs-h3); padding: 0 var(--sp-1); }
.log time { color: var(--ink-sub); font-size: var(--fs-note); padding-top: 2px; }
.log .what { font-size: var(--fs-body); }
.log .detail { font-size: var(--fs-note); color: var(--ink-note); }
.log-more summary { min-height: var(--tap); display: flex; align-items: center; font-size: var(--fs-note); color: var(--key-text); cursor: pointer; }

/* --- 計画づくり ------------------------------------------------------------ */

.setup h2 { margin: 0 0 var(--sp-2); font-size: var(--fs-h2); }
.setup-steps { margin: 0 0 var(--sp-2); padding: 0; list-style: none; counter-reset: step; }
.setup-steps > li {
  counter-increment: step;
  padding: var(--sp-2) 0;
  border-top: 1px solid var(--divider);
  position: relative;
  padding-left: var(--sp-4);
}
.setup-steps > li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: var(--sp-2);
  color: var(--key-text);
  font-weight: 700;
  font-feature-settings: 'tnum';
}
.setup-steps .field:last-child { margin-bottom: 0; }

/* --- 手順と安全（別ページ） ------------------------------------------------ */

.guide-top {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 var(--sp-1);
  font-size: var(--fs-note);
  color: var(--key-text);
  white-space: nowrap;
}
.guide-page main { padding-bottom: var(--sp-5); }

/* 置き方の図（§4）。線画・無彩色＋キー淡色面のみ */
.orientation { width: 100%; height: auto; display: block; margin: var(--sp-2) 0; }
.or-box { fill: none; stroke: var(--rule-strong); stroke-width: 1.5; }
.or-meat { fill: var(--key-pale); stroke: var(--key); stroke-width: 1.5; }
.or-label { fill: var(--ink); font-size: var(--fs-note); font-family: var(--font); }
.or-sub { fill: var(--ink-sub); font-size: var(--fs-note); font-family: var(--font); }
.or-arrow { stroke: var(--rule-strong); stroke-width: 1.5; fill: none; }
section.block { margin-bottom: var(--sp-4); }
section.block > h2 {
  font-size: var(--fs-h3);
  margin: 0 0 var(--sp-2);
  border-left: 5px solid var(--key);
  padding-left: var(--sp-2);
  line-height: 1.4;
}
section.block > h3 { font-size: var(--fs-body); font-weight: 700; margin: var(--sp-3) 0 var(--sp-1); }
section.block p { margin: 0 0 var(--sp-2); }
section.block ul, section.block ol { margin: 0 0 var(--sp-2); padding-left: var(--sp-3); }
section.block li { margin-bottom: 4px; }
.key-b { color: var(--key-text); font-weight: 700; }

.foot-links { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin: 0; }

/* --- 下の固定ボタン --------------------------------------------------------- */

#fab .fab-inner {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  background: var(--surface);
  border-top: 1px solid var(--rule);
  padding: var(--sp-2);
}
#fab .fab-inner .btn { max-width: var(--maxw); margin: 0 auto; display: flex; }

/* --- コマンドシート --------------------------------------------------------- */

.sheet-back {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0, 0, 0, .55);
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  max-width: var(--maxw); margin: 0 auto;
  max-height: 80vh; overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--rule-strong);
  border-bottom: 0;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  padding: var(--sp-2) var(--sp-3) var(--sp-4);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.panel-head b { font-size: var(--fs-h3); }
.cmd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-1); }
.cmd {
  min-height: calc(var(--tap) + 11px);
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  gap: 2px;
  padding: var(--sp-1) var(--sp-2);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-btn);
  font: inherit; font-size: var(--fs-body); font-weight: 700;
  cursor: pointer;
  text-align: left;
}
.cmd:hover { background: var(--alt); }
.cmd small { font-size: var(--fs-note); font-weight: 400; color: var(--ink-sub); }
.time-row { max-width: 280px; }

/* --- モバイル -------------------------------------------------------------- */

@media (max-width: 560px) {
  main { padding-left: var(--sp-1); padding-right: var(--sp-1); }
  .inline-fields { grid-template-columns: 1fr; gap: var(--sp-2); }
  .inline-fields .field { margin-bottom: 0; }
}

@media print {
  #fab, #overlay, .foot-links { display: none; }
}
