/* 麻辣湯グラム計算 — built on the マーラーポン！ design system tokens defined in /blog/assets/blog.css */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sim-page { padding-bottom: 88px; }

.sim-hero { display: grid; gap: 10px; padding-block: 28px 8px; max-width: 44em; }
.sim-hero h1 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(32px, 6vw, 52px); line-height: 1.25; }
.sim-hero h1 em {
  font-style: normal; color: var(--highlight);
  background: linear-gradient(transparent 62%, var(--highlight-mark) 62%, var(--highlight-mark) 92%, transparent 92%);
}
.sim-note { margin-top: 16px; padding: 12px 16px; border-radius: var(--radius-md); background: var(--ground-sunk); font-size: 14px; line-height: 1.8; color: var(--ink-muted); }
.sim-note p { margin: 0; }
.sim-note strong { color: var(--ink); }

.sim-layout { margin-top: 24px; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.sim-side { position: sticky; top: 16px; display: grid; gap: 16px; }

/* ---------- group nav ---------- */
.sim-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.sim-tab {
  font-weight: 800; font-size: 13px; padding: 6px 12px; border-radius: var(--radius-pill);
  border: 2px solid var(--outline); background: var(--ground-raised); color: var(--ink); text-decoration: none;
  box-shadow: var(--shadow-pop-sm); transition: transform 140ms var(--ease-pop);
}
.sim-tab:hover { transform: translateY(-2px); }

.sim-group { scroll-margin-top: 16px; }
.sim-group h3 { margin: 24px 0 8px; font-family: var(--font-display); font-weight: 400; font-size: 22px; line-height: 1.4; }
.sim-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.sim-loading { color: var(--ink-muted); }

/* ---------- ingredient row ---------- */
.sim-row {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; grid-template-areas: "art info ctr" "art info sub" "basis basis basis";
  align-items: center; column-gap: 12px; padding: 10px 12px;
  background: var(--ground-raised); border: 2px solid var(--line); border-radius: var(--radius-lg);
  transition: border-color 160ms, box-shadow 160ms;
}
.sim-row.on { border-color: var(--outline); box-shadow: var(--shadow-pop-sm); }
.row-art { grid-area: art; width: 52px; height: 52px; object-fit: contain; filter: drop-shadow(0 3px 3px var(--ink-shadow)); }
.noimg {
  display: grid; place-items: center; border-radius: 50%; background: var(--ground-sunk); color: var(--ink-muted);
  border: 2px dashed var(--line); font-family: var(--font-display); font-size: 20px; filter: none;
}
.row-art.noimg { width: 48px; height: 48px; }
.row-info { grid-area: info; display: grid; gap: 2px; min-width: 0; }
.row-name { font-weight: 900; font-size: 16px; line-height: 1.4; color: var(--ink); text-decoration: none; }
.row-name:hover { color: var(--chili-ink); text-decoration: underline; }
.row-g { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-muted); }
.row-g input {
  width: 52px; padding: 2px 6px; font: inherit; font-size: 13px; font-weight: 700; color: var(--ink);
  background: var(--ground); border: 1.5px solid var(--line); border-radius: 8px; text-align: right;
}
.sim-row.edited .row-g input { border-color: var(--chili-ink); }
.row-basis { grid-area: basis; margin: 6px 0 0; padding-top: 6px; border-top: 1px dashed var(--line); display: flex; align-items: baseline; gap: 6px; font-size: 11px; line-height: 1.5; color: var(--ink-muted); }
.basis { flex: none; font-weight: 900; font-size: 10px; letter-spacing: .04em; padding: 1px 6px; border-radius: 999px; border: 1.5px solid currentColor; }
.basis-src, .basis-calc { color: var(--chili-ink); }
.basis-near { color: var(--ink-muted); }
.basis-est { color: var(--ink-muted); border-style: dashed; }
.sources { margin-top: 40px; max-width: 760px; }
.sources h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 26px; line-height: 1.4; }
.sources ol { padding-left: 1.4em; font-size: 14px; line-height: 1.8; }
.basis-legend { display: grid; gap: 8px; padding: 0; list-style: none; font-size: 14px; line-height: 1.6; }
.basis-legend li { display: flex; gap: 8px; align-items: baseline; }
.row-ctr { grid-area: ctr; display: inline-flex; align-items: center; gap: 6px; }
.ctr-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--outline); cursor: pointer;
  font-family: var(--font-display); font-size: 20px; line-height: 1; display: grid; place-items: center;
  box-shadow: var(--shadow-pop-sm); transition: transform 120ms var(--ease-pop), box-shadow 120ms var(--ease-pop);
}
.ctr-btn.plus { background: var(--chili); color: var(--on-chili); }
.ctr-btn.minus { background: var(--ground-raised); color: var(--ink); }
.ctr-btn:hover { transform: translateY(-2px); }
.ctr-btn:active { transform: translateY(2px) scale(1.06, .92); box-shadow: none; }
.ctr-num { min-width: 1.6em; text-align: center; font-family: var(--font-display); font-size: 20px; font-variant-numeric: tabular-nums; }
.ctr-num.bump { animation: bump 380ms var(--ease-pop); }
.row-sub { grid-area: sub; justify-self: end; font-size: 12px; font-weight: 800; color: var(--chili-ink); min-height: 1em; font-variant-numeric: tabular-nums; }

/* ---------- bowl ---------- */
.sim-bowl {
  --fill: 0;
  position: relative; height: 260px; border-radius: 0 0 160px 160px / 0 0 140px 140px;
  background: var(--ground-raised); border: 3px solid var(--outline); border-top-width: 0; overflow: hidden;
  box-shadow: var(--shadow-pop-md);
}
.sim-bowl::before { /* rim */
  content: ""; position: absolute; inset: 0 0 auto; height: 10px; background: var(--outline); opacity: .12;
}
.bowl-soup {
  position: absolute; left: 0; right: 0; bottom: 0; height: calc(18% + var(--fill) * 62%);
  background: linear-gradient(180deg, var(--chili) 0%, var(--chili-deep) 100%); opacity: .9;
  transition: height 500ms var(--ease-out, ease-out);
}
.bowl-soup::before { /* chili-oil bubbles */
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 210, 90, .55) 0 5px, transparent 6px),
    radial-gradient(circle at 62% 12%, rgba(255, 210, 90, .45) 0 4px, transparent 5px),
    radial-gradient(circle at 80% 34%, rgba(255, 210, 90, .5) 0 6px, transparent 7px),
    radial-gradient(circle at 40% 42%, rgba(255, 210, 90, .35) 0 3px, transparent 4px);
}
.bowl-items { position: absolute; inset: 14px 18px 10px; }
.bowl-piece {
  position: absolute; left: 0; bottom: 0; width: var(--s, 38px); height: var(--s, 38px);
  transform: translate(var(--x, 0), calc(-1 * var(--y, 0px))) rotate(var(--r, 0deg));
}
.bowl-piece.drop { animation: piece-drop 620ms cubic-bezier(0.2, 1.4, 0.4, 1) both; }
.piece-art { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 3px 3px rgba(18, 4, 3, .4)); }
.piece-art.noimg { font-size: 15px; border-width: 1.5px; background: var(--ground-raised); }
.bowl-empty { position: absolute; inset: auto 16px 40%; margin: 0; text-align: center; font-weight: 800; font-size: 13px; color: var(--ink-muted); }
.sim-bowl.pon { animation: bowl-pon 360ms var(--ease-pop); }

/* ---------- totals ---------- */
.sim-total {
  padding: 16px 18px; border-radius: var(--radius-lg); border: 3px solid var(--outline); box-shadow: var(--shadow-pop-md);
  background: radial-gradient(120% 90% at 0% 0%, var(--chili) 0%, var(--chili-deep) 60%, var(--broth) 100%); color: var(--on-chili);
  display: grid; gap: 4px;
}
.total-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.total-label { font-weight: 800; font-size: 14px; }
.total-g b, .total-yen b { font-family: var(--font-display); font-weight: 400; font-size: 36px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.total-yen b { color: var(--gold); }
.total-g, .total-yen { font-weight: 800; }
.total-break { margin: 2px 0 0; font-size: 12px; opacity: .85; text-align: right; }
.budget-msg { margin: 8px 0 4px; font-weight: 800; font-size: 14px; }
.budget-msg.over { color: var(--gold); }
.budget-meter { height: 10px; border-radius: 999px; background: rgba(255, 246, 232, .25); overflow: hidden; }
.budget-meter i { display: block; height: 100%; background: var(--gold); border-radius: 999px; transition: width 300ms; }
.sim-actions { display: flex; justify-content: flex-end; }
.sim-actions .btn { height: 40px; font-size: 14px; }

/* ---------- settings ---------- */
.sim-settings { margin-top: 48px; max-width: 760px; }
.sim-settings h2, .sim-tips h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 26px; line-height: 1.4; }
.set-lead { color: var(--ink-muted); font-size: 15px; }
.presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 12px; }
.preset {
  text-align: left; font: inherit; cursor: pointer; display: grid; gap: 4px; padding: 12px 14px; color: var(--ink);
  background: var(--ground-raised); border: 2px solid var(--line); border-radius: var(--radius-md);
}
.preset[aria-pressed="true"] { border-color: var(--outline); box-shadow: var(--shadow-pop-sm); background: var(--gold); color: var(--on-gold); }
.preset-label { font-weight: 900; font-size: 15px; }
.preset-note { font-size: 12px; line-height: 1.6; opacity: .85; }
.preset-src { font-size: 12px; color: var(--ink-muted); margin: 8px 0 0; }
.set-grid { margin-top: 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px; }
.set-grid label { display: grid; gap: 6px; font-weight: 800; font-size: 13px; }
.unit-in { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.unit-in input {
  width: 100%; max-width: 160px; padding: 8px 10px; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--ground-raised); border: 2px solid var(--outline); border-radius: var(--radius-sm);
}
.set-small { font-size: 12px; color: var(--ink-muted); }
.sim-tips { margin-top: 40px; max-width: 760px; }

/* ---------- mobile bottom bar ---------- */
.sim-bar { display: none; }
@media (max-width: 860px) {
  .sim-layout { grid-template-columns: 1fr; }
  .sim-side { position: static; order: -1; }
  .sim-bowl { height: 200px; }
  .sim-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
    padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    background: var(--broth); color: var(--on-chili); border-top: 3px solid var(--outline);
  }
  .sim-bar b { font-family: var(--font-display); font-weight: 400; font-size: 22px; font-variant-numeric: tabular-nums; }
  .bar-yen b { color: var(--gold); }
  .bar-link { margin-left: auto; color: var(--on-chili); font-weight: 800; font-size: 13px; }
}
@media (max-width: 420px) {
  .sim-row { grid-template-columns: 44px minmax(0, 1fr) auto; padding: 8px 10px; column-gap: 8px; }
  .row-art, .row-art.noimg { width: 44px; height: 44px; }
  .ctr-btn { width: 36px; height: 36px; font-size: 18px; }
}

@keyframes piece-drop {
  0% { transform: translate(var(--x, 0), -260px) rotate(-40deg); opacity: 0; }
  20% { opacity: 1; }
  70% { transform: translate(var(--x, 0), calc(-1 * var(--y, 0px) + 6px)) rotate(var(--r, 0deg)) scale(1.15, .85); }
  100% { transform: translate(var(--x, 0), calc(-1 * var(--y, 0px))) rotate(var(--r, 0deg)); }
}
@keyframes bowl-pon { 0%, 100% { transform: none; } 40% { transform: scale(1.02, .98); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.4); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .bowl-piece.drop, .sim-bowl.pon, .ctr-num.bump { animation: none !important; }
  .bowl-soup, .budget-meter i { transition: none; }
}
