/* recipe widget: "The TowerBridge Recipe" (mount #tb-recipe). Every selector starts with #tb-recipe. */
#tb-recipe .tbr { position: relative; }

/* ---- head controls ---- */
#tb-recipe .tbr-ctrl { display: flex; gap: 6px; flex: none; }
#tb-recipe .tbr-btn { gap: 6px; padding: 7px 12px; }
#tb-recipe .tbr-btn svg { width: 15px; height: 15px; flex: none; }
#tb-recipe .tbr-btn:disabled { opacity: .45; cursor: default; transform: none; border-color: var(--rule-2); }
#tb-recipe .tbr-btn--play { min-width: 92px; justify-content: center; background: var(--ink); color: var(--bg); border-color: var(--ink); }
#tb-recipe .tbr-btn--play:hover { background: var(--ours); border-color: var(--ours); color: #fff; }

/* ---- step rail with per-step progress ---- */
#tb-recipe .tbr-rail { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-bottom: 1px solid var(--rule); background: var(--surface-2); }
#tb-recipe .tbr-tab { position: relative; appearance: none; border: 0; background: transparent; cursor: pointer; text-align: left; display: flex; align-items: center; gap: 10px; padding: 13px clamp(12px, 2vw, 22px) 15px; color: var(--muted); font: 600 0.9rem/1.25 var(--sans); transition: color .2s, background .2s; min-width: 0; }
#tb-recipe .tbr-tab + .tbr-tab { border-left: 1px solid var(--rule); }
#tb-recipe .tbr-tab:hover { color: var(--ink); }
#tb-recipe .tbr-tab:focus-visible { outline-offset: -3px; }
#tb-recipe .tbr-tab[aria-selected="true"] { color: var(--ink); background: var(--surface); }
#tb-recipe .tbr-tab__n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--neutral-soft); color: var(--ink-2); font-size: 0.8rem; font-weight: 700; letter-spacing: 0; transition: background .25s, color .25s; }
#tb-recipe .tbr-tab.is-done .tbr-tab__n { background: var(--ours-soft); color: var(--ours-ink); }
#tb-recipe .tbr-tab[aria-selected="true"] .tbr-tab__n { background: var(--ours); color: var(--surface); }
#tb-recipe .tbr-tab__l { min-width: 0; }
#tb-recipe .tbr-tab__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--rule); }
#tb-recipe .tbr-tab__bar i { display: block; height: 100%; background: var(--ours); transform-origin: 0 50%; transform: scaleX(0); }

/* ---- body: stage + text panel ---- */
#tb-recipe .tbr-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px 30px; align-items: start; }
#tb-recipe .tbr.is-wide .tbr-body { grid-template-columns: minmax(0, 1fr) 300px; }
#tb-recipe .tbr-stage { min-width: 0; width: 100%; max-width: 860px; margin-inline: auto; }
#tb-recipe .tbr.is-port .tbr-stage { max-width: 460px; }

#tb-recipe .tbr-phase { display: flex; align-items: baseline; gap: 10px; min-height: 2.9em; padding: 8px 12px; margin-bottom: 8px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--rule); color: var(--ink-2); font: 500 0.9rem/1.4 var(--sans); }
#tb-recipe .tbr-phase__k { flex: none; color: var(--ours-ink); font-size: 0.78rem; font-weight: 700; }
#tb-recipe .tbr-phase.is-new .tbr-phase__t { animation: tbr-in .45s cubic-bezier(.2, .7, .2, 1); }
@keyframes tbr-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
#tb-recipe .tbr.is-port .tbr-phase { min-height: 4.3em; align-items: flex-start; }

#tb-recipe .tbr-svgbox { width: 100%; }
#tb-recipe .tbr-svg { width: 100%; height: 100%; display: block; overflow: visible; font-family: var(--sans); pointer-events: none; user-select: none; }

#tb-recipe .tbr-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 0.8rem; color: var(--muted); }
#tb-recipe .tbr-legend span { display: inline-flex; align-items: center; gap: 6px; }
#tb-recipe .tbr-lg { display: inline-block; flex: none; width: 10px; height: 10px; }
#tb-recipe .tbr-lg--img { background: var(--img); border-radius: 2.5px; }
#tb-recipe .tbr-lg--txt { background: var(--txt); border-radius: 50%; }
#tb-recipe .tbr-lg--line { width: 18px; height: 3px; border-radius: 2px; }
#tb-recipe .tbr-lg--good { background: var(--good); }
#tb-recipe .tbr-lg--bad { background: var(--bad); }
#tb-recipe .tbr-lg--ours { background: var(--ours); }

/* panel: the three steps share one grid cell so the panel keeps the height of the longest step */
#tb-recipe .tbr-panel { display: grid; min-width: 0; }
#tb-recipe .tbr-step { grid-area: 1 / 1; opacity: 0; visibility: hidden; transform: translateY(6px); transition: opacity .35s ease, transform .35s ease, visibility 0s linear .35s; }
#tb-recipe .tbr-step.is-on { opacity: 1; visibility: visible; transform: none; transition: opacity .4s ease .08s, transform .4s ease .08s, visibility 0s; }
#tb-recipe .tbr-step__k { margin: 2px 0 6px; font: 700 0.74rem/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ours-ink); }
#tb-recipe .tbr-step__h { font-size: 1.32rem; margin-bottom: 10px; }
#tb-recipe .tbr-step__b p { font-size: 0.92rem; line-height: 1.55; color: var(--ink-2); margin-bottom: 0.7em; }
#tb-recipe .tbr-eq { margin-top: 12px; font-size: 1.02rem; padding: 12px 10px; gap: 8px 14px; background: var(--surface-2); }
#tb-recipe .tbr-eq .m-under small { font-size: 0.6em; }
#tb-recipe .tbr-build { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 12px; }
#tb-recipe .tbr-build__k { font-size: 0.8rem; color: var(--muted); margin-right: 2px; }

/* ---- fixed settings strip ---- */
#tb-recipe .tbr-fixed { display: grid; grid-template-columns: 200px minmax(0, 1fr); align-items: stretch; border-top: 1px solid var(--rule); }
#tb-recipe .tbr-fixed__h { display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 12px clamp(14px, 2vw, 22px); font-size: 0.8rem; color: var(--muted); line-height: 1.35; }
#tb-recipe .tbr-fixed__h strong { color: var(--ink); font-size: 0.86rem; }
#tb-recipe .tbr-fixed__g { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
#tb-recipe .tbr-fixed__i { padding: 12px 14px; border-left: 1px solid var(--rule); }
#tb-recipe .tbr-fixed__v { font: 600 1.12rem/1.2 var(--sans); color: var(--ours-ink); }
#tb-recipe .tbr-fixed__v .num { font-weight: 600; }
#tb-recipe .tbr-fixed__l { font-size: 0.78rem; color: var(--muted); line-height: 1.3; margin-top: 3px; }
#tb-recipe .figure__note .chip { margin-right: 4px; vertical-align: 1px; }

@media (max-width: 860px) {
  #tb-recipe .tbr-fixed { grid-template-columns: minmax(0, 1fr); }
  #tb-recipe .tbr-fixed__h { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; gap: 4px 10px; align-items: baseline; padding-bottom: 4px; }
  #tb-recipe .tbr-fixed__g { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); padding: 0 clamp(8px, 1.5vw, 16px) 8px; }
  #tb-recipe .tbr-fixed__i { border-left: 0; padding: 8px 6px; }
}
@media (max-width: 560px) {
  #tb-recipe .figure__head { gap: 10px; }
  #tb-recipe .tbr-ctrl { width: 100%; }
  #tb-recipe .tbr-ctrl .tbr-btn { flex: 1 1 0; justify-content: center; }
  #tb-recipe .tbr-tab { flex-direction: column; align-items: flex-start; gap: 6px; font-size: 0.8rem; padding: 10px 10px 12px; }
  #tb-recipe .tbr-tab__n { width: 22px; height: 22px; font-size: 0.74rem; }
  #tb-recipe .tbr-fixed__g { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #tb-recipe .tbr-legend { font-size: 0.76rem; gap: 4px 12px; }
}

/* ---- SVG scene ---- */
#tb-recipe .tbr-m { font-family: var(--serif); }
#tb-recipe .tbr-sans { font-family: var(--sans); }
#tb-recipe .tbr-label { font-size: 13px; fill: var(--muted); }
#tb-recipe .tbr-label--strong { font-weight: 600; fill: var(--ink-2); font-size: 13.5px; }
#tb-recipe .tbr-tiny { font-size: 12.5px; fill: var(--muted); }
#tb-recipe .tbr-real { font-weight: 600; fill: var(--ink-2); }

#tb-recipe .tbr-spacebg { fill: var(--surface-2); stroke: var(--rule); stroke-width: 1; }
#tb-recipe .tbr-unit { fill: none; stroke: var(--rule-2); stroke-width: 1.2; stroke-dasharray: 3 4; }
#tb-recipe .tbr-pt--i { fill: var(--img); stroke: var(--surface); stroke-width: 1.2; }
#tb-recipe .tbr-pt--t { fill: var(--txt); stroke: var(--surface); stroke-width: 1.2; }
#tb-recipe .tbr-part--i { fill: var(--img); }
#tb-recipe .tbr-part--t { fill: var(--txt); }
#tb-recipe .tbr-ring { fill: none; stroke-width: 2; }
#tb-recipe .tbr-ring--i { stroke: var(--img); }
#tb-recipe .tbr-ring--t { stroke: var(--txt); }
#tb-recipe .tbr-ring--bad { stroke: var(--bad); stroke-width: 1.8; }
#tb-recipe .tbr-mine { stroke-width: 2; stroke-linecap: round; stroke-dasharray: 1; }
#tb-recipe .tbr-mine--good { stroke: var(--good); stroke-width: 2.6; }
#tb-recipe .tbr-mine--bad { stroke: var(--bad); }

#tb-recipe .tbr-axis line { stroke-width: 2; stroke-linecap: round; }
#tb-recipe .tbr-axis--u line { stroke: var(--ours); stroke-width: 2.6; }
#tb-recipe .tbr-axis--o line { stroke: var(--neutral); stroke-dasharray: 5 4; }
#tb-recipe .tbr-ell { fill: none; stroke: var(--ours); stroke-width: 1.6; stroke-dasharray: 4 3; }
#tb-recipe .tbr-ulab__n { fill: var(--ours-ink); font-weight: 700; }
#tb-recipe .tbr-ulab__v { font-size: 13px; font-weight: 600; fill: var(--ours-ink); }
#tb-recipe .tbr-olab { font-size: 12.5px; fill: var(--muted); }

#tb-recipe .tbr-name { font-size: 13.5px; font-weight: 650; }
#tb-recipe .tbr-name.tbr-img { fill: var(--img); }
#tb-recipe .tbr-name.tbr-txt { fill: var(--txt); }
#tb-recipe .tbr-frozen text { font-size: 12.5px; fill: var(--muted); }
#tb-recipe .tbr-frozen rect { fill: var(--faint); }
#tb-recipe .tbr-lockarc { fill: none; stroke: var(--faint); stroke-width: 1.5; }
#tb-recipe .tbr-projname { font-size: 12.5px; fill: var(--muted); }
#tb-recipe .tbr-img .tbr-layer { fill: var(--img-soft); stroke: var(--img); stroke-width: 1.2; }
#tb-recipe .tbr-txt .tbr-layer { fill: var(--txt-soft); stroke: var(--txt); stroke-width: 1.2; }
#tb-recipe .tbr-proj { fill: var(--surface); stroke-width: 2; }
#tb-recipe .tbr-img .tbr-proj { stroke: var(--img); }
#tb-recipe .tbr-txt .tbr-proj { stroke: var(--txt); }
#tb-recipe .tbr-tower .tbr-proj--ed { fill: var(--ours-soft); stroke: var(--ours); stroke-width: 2.4; }
#tb-recipe .tbr-proj__t { fill: var(--ink); }
#tb-recipe .tbr-proj__t--ed { fill: var(--ours-ink); font-weight: 600; }
#tb-recipe .tbr-wire { stroke: var(--rule-2); stroke-width: 2; fill: none; }
#tb-recipe .tbr-photo { fill: var(--img-soft); stroke: var(--img); stroke-width: 1.2; }
#tb-recipe .tbr-photo--front { fill: var(--surface); }
#tb-recipe .tbr-photo__m { fill: var(--img); opacity: .55; }
#tb-recipe .tbr-capline { fill: var(--txt); opacity: .75; }
#tb-recipe .tbr-pairline { stroke: var(--rule-2); stroke-width: 1.5; stroke-dasharray: 3 3; fill: none; }
#tb-recipe .tbr-pairbg { fill: var(--surface); }
#tb-recipe .tbr-pairs { font-size: 12.5px; fill: var(--muted); }
#tb-recipe .tbr-pairs__n { font-size: 14px; font-weight: 700; fill: var(--ink); }

#tb-recipe .tbr-arrow { fill: none; stroke: var(--faint); stroke-width: 1.6; stroke-dasharray: 1; }
#tb-recipe .tbr-arrow--in { stroke-dasharray: none; stroke-width: 1.8; }
#tb-recipe .tbr-arrow--in.tbr-img { stroke: var(--img); opacity: .6; }
#tb-recipe .tbr-arrow--in.tbr-txt { stroke: var(--txt); opacity: .6; }
#tb-recipe .tbr-ahead { fill: context-stroke; }
#tb-recipe .tbr-route { fill: none; stroke: none; }

#tb-recipe .tbr-mframe { fill: var(--surface); stroke: var(--rule-2); stroke-width: 1; }
#tb-recipe .tbr-hpos { fill: var(--good); }
#tb-recipe .tbr-hneg { fill: var(--bad); }
#tb-recipe .tbr-dcell { fill: var(--neutral); opacity: .55; }
#tb-recipe .tbr-dcell--u { fill: var(--ours); }
#tb-recipe .tbr-dval { font-size: 13px; font-weight: 600; fill: var(--muted); }
#tb-recipe .tbr-dval--u { fill: var(--ours-ink); }
#tb-recipe .tbr-qlab { fill: var(--ink-2); font-weight: 600; }
#tb-recipe .tbr-qlab .tbr-sans { font-size: 13.5px; }
#tb-recipe .tbr-qlab--ours { fill: var(--ours-ink); }
#tb-recipe .tbr-metric { font-size: 13px; fill: var(--muted); }
#tb-recipe .tbr-metric__v { font-weight: 700; fill: var(--ours-ink); }
#tb-recipe .tbr-spec__u { fill: var(--ours); }
#tb-recipe .tbr-spec__r { fill: var(--neutral); opacity: .55; }
#tb-recipe .tbr-zero { stroke: var(--ink-2); stroke-width: 1; }
#tb-recipe .tbr-bracket { fill: none; stroke: var(--ours); stroke-width: 1.5; }

#tb-recipe .tbr-tile rect { fill: var(--ours-soft); stroke: var(--ours); stroke-width: 2; }
#tb-recipe .tbr-tile__t { fill: var(--ours-ink); font-weight: 700; }

#tb-recipe .tbr-card__bg { fill: var(--surface); stroke: var(--ours); stroke-width: 1.6; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, .14)); }
#tb-recipe .tbr-card__h { font-family: var(--serif); font-size: 17px; font-weight: 650; fill: var(--ink); }
#tb-recipe .tbr-card__l { font-size: 14px; fill: var(--ink-2); }
#tb-recipe .tbr-card__k { font-size: 12.5px; fill: var(--muted); font-weight: 600; letter-spacing: .02em; }
#tb-recipe .tbr-card__big { font-size: 19px; font-weight: 700; fill: var(--ours-ink); }
#tb-recipe .tbr-card__ok { fill: var(--good-soft); }
#tb-recipe .tbr-card__tick { fill: none; stroke: var(--good); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#tb-recipe .tbr-card__rule { stroke: var(--rule); stroke-width: 1; }
#tb-recipe .tbr-ring--good { stroke: var(--good); stroke-width: 1.8; }
#tb-recipe .tbr-card__big .num { font-family: var(--mono); }
#tb-recipe .tbr-card__u { font-family: var(--sans); font-size: 14px; font-weight: 600; }
/* phones: let the portrait stage use the full card width and keep every SVG label at 13 units or more */
#tb-recipe .tbr.is-port .tbr-svgbox { width: calc(100% + 20px); margin-inline: -10px; }
#tb-recipe .tbr-svg--port .tbr-tiny, #tb-recipe .tbr-svg--port .tbr-olab, #tb-recipe .tbr-svg--port .tbr-frozen text,
#tb-recipe .tbr-svg--port .tbr-projname, #tb-recipe .tbr-svg--port .tbr-pairs { font-size: 13px; }
