/* bridge · owner P4
   1. head  2. scene: the decimals made physical (pinned + scrubbed with motion; static = final state + all steps)
   3. calculator with a rolling readout (exact BigInt math)  4. notes (escape hatch, SOL)
   Odometer cells (.oc > .os) are built by bridge.js; without JS the plain text shows. */
#bridge { padding: var(--sec) 0; overflow-x: clip; }
#bridge .bridge__line { margin-top: clamp(22px, 2.4vw, 32px); font-size: clamp(17px, 1.3vw, 19px); max-width: 25em; }

/* ---------- odometer cells (shared by scene + calculator) ---------- */
#bridge .oc { position: relative; display: inline-block; vertical-align: top; height: var(--ch, 1.12em); overflow: hidden; -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 16%, #000 84%, transparent 100%); mask-image: linear-gradient(180deg, transparent 0, #000 16%, #000 84%, transparent 100%); }
#bridge .os { display: block; white-space: pre; line-height: var(--ch, 1.12em); text-align: center; will-change: transform; }
#bridge .op { display: inline-block; vertical-align: top; height: var(--ch, 1.12em); line-height: var(--ch, 1.12em); }

/* ---------- scene ---------- */
#bridge .scene { position: relative; margin-top: clamp(56px, 7vw, 104px); }
#bridge .scene__in { display: grid; gap: clamp(36px, 5vw, 64px); }

/* rail: Solana ---- marker ---- Veil Layer */
#bridge .rail { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: clamp(14px, 2vw, 28px); }
#bridge .rail__end { display: grid; gap: 2px; font-size: 13px; line-height: 1.25; color: var(--muted); white-space: nowrap; }
#bridge .rail__end b { font-size: clamp(15px, 1.2vw, 17px); font-weight: 600; font-stretch: 112%; color: #000; }
#bridge .rail__end--veil { text-align: right; }
#bridge .rail__track { position: relative; height: 18px; margin: 0 -10px; overflow: hidden; }
#bridge .rail__track::before { content: ""; position: absolute; left: 10px; right: 10px; top: 8px; height: 2px; background: rgba(0, 0, 0, 0.22); }
#bridge .rail__fill { position: absolute; left: 10px; right: 10px; top: 8px; height: 2px; background: var(--v); transform-origin: 0 50%; transform: scaleX(0); }
#bridge .rail__run { position: absolute; top: 0; bottom: 0; left: 10px; right: 10px; transform: translateX(0%); }
#bridge .rail__dot { position: absolute; left: -9px; top: 0; width: 18px; height: 18px; background: var(--v); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }

/* meter: where-label + the big number */
#bridge .meter { position: relative; container-type: inline-size; padding-bottom: calc(var(--odo-fs) * 1.5 + 30px); --odo-fs: clamp(36px, min(calc(100cqi / 8.9), 19svh), 160px); }
#bridge .meter__where { display: grid; margin-bottom: 14px; font-size: 14px; font-weight: 600; font-stretch: 112%; letter-spacing: 0.01em; }
#bridge .meter__where span { grid-area: 1 / 1; opacity: 0; }
#bridge .meter__where span[data-w="2"] { opacity: 1; }
#bridge .meter__math { display: none; }
#bridge .odo { --ch: 1.12em; position: relative; display: inline-flex; align-items: flex-start; white-space: nowrap; font-size: var(--odo-fs); font-weight: 600; font-stretch: 125%; line-height: var(--ch); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
#bridge .odo__xw { position: relative; display: inline-block; margin-left: .06em; }
#bridge .odo__x { display: inline-block; color: var(--v); transform: translateY(calc(var(--ch) + .24em)); }
#bridge .odo__slot { position: absolute; inset: .1em -.04em; border: 2px dashed rgba(102, 0, 255, 0.55); opacity: 0; }
#bridge .odo__tag { position: absolute; left: 0; bottom: 100%; margin-bottom: 10px; font-size: 13px; font-weight: 600; font-stretch: 100%; letter-spacing: 0; line-height: 1.2; color: var(--v-err); white-space: nowrap; opacity: 0; }
#bridge .tray { position: absolute; left: -.08em; right: -.08em; top: calc(var(--ch) + .2em); height: calc(var(--ch) + .08em); border: 2px solid var(--v); border-top-width: 0; background: rgba(102, 0, 255, 0.07); transform-origin: 50% 0; }
#bridge .tray__l { position: absolute; right: 0; top: 100%; margin-top: 10px; font-size: 14px; font-weight: 600; font-stretch: 105%; letter-spacing: 0; line-height: 1.2; color: var(--v-err); white-space: nowrap; }

/* steps: all visible in the static layout */
#bridge .steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 28px; }
#bridge .step { position: relative; }
#bridge .step__bar { display: block; position: relative; height: 2px; margin-bottom: 16px; background: rgba(0, 0, 0, 0.18); overflow: hidden; }
#bridge .step__bar i { position: absolute; inset: 0; background: var(--v); transform-origin: 0 50%; transform: scaleX(1); }
#bridge .step__t { display: flex; align-items: baseline; gap: 12px; font-size: clamp(19px, 1.5vw, 22px); }
#bridge .step__n { font-size: 13px; font-weight: 600; font-stretch: 100%; letter-spacing: 0; color: var(--v-err); font-variant-numeric: tabular-nums; }
#bridge .step__p { margin-top: 10px; font-size: 15px; line-height: 1.5; color: var(--muted); max-width: 30em; }
#bridge .step__m { margin-top: 10px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; color: #000; overflow-wrap: anywhere; }
@media (min-width: 900px) {
  #bridge .bridge__title { grid-column: 1 / span 7; grid-row: 1; }
  #bridge .bridge__line { grid-column: 9 / span 4; grid-row: 1; align-self: end; margin-top: 0; padding-bottom: .4em; }
  #bridge .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: var(--gut); }
}

@media (max-width: 899px) {
  #bridge .rail__end span { display: none; }
  #bridge .meter { --odo-fs: clamp(36px, calc(100cqi / 8.6), 92px); }
  #bridge .step__t { font-size: 20px; }
  #bridge .step__p { font-size: 15.5px; }
}

/* scene with motion: one pinned viewport, scrubbed by bridge.js (initial states set there).
   Only when the stage fits: under 520px of height (phone landscape) the static layout stays, as with reduced motion.
   bridge.js pins inside gsap.matchMedia with the same query. */
@media (min-height: 520px) {
  html.motion #bridge .rail__end b { color: var(--muted); transition: color .4s var(--ease); }
  html.motion #bridge .rail__end[data-on] b { color: #000; }
  html.motion #bridge .rail__end--veil[data-on] b { color: var(--v-err); }
  html.motion #bridge .meter__math { display: grid; position: absolute; left: 0; top: calc(var(--odo-fs) * 1.12 + 62px); max-width: calc(100% - var(--odo-fs) * 2.6); font-family: var(--mono); font-size: clamp(13px, 1.25vw, 18px); line-height: 1.45; color: #000; }
  html.motion #bridge .meter__math span { grid-area: 1 / 1; opacity: 0; }
  html.motion #bridge .step__m { display: none; }
  html.motion #bridge .scene { height: 100vh; height: 100svh; margin-top: clamp(24px, 3vw, 48px); }
  html.motion #bridge .scene__in { height: 100%; display: flex; flex-direction: column; justify-content: center; gap: clamp(26px, 5.2svh, 60px); padding: clamp(76px, 11svh, 116px) 0 clamp(24px, 5svh, 52px); }
  html.motion #bridge .meter__where span[data-w="2"] { opacity: 0; }
  html.motion #bridge .step { opacity: .32; transition: opacity .5s var(--ease); }
  html.motion #bridge .step[data-on] { opacity: 1; }
  html.motion #bridge .step__bar i { transform: scaleX(0); }
}
@media (max-width: 899px) and (min-height: 520px) {
  html.motion #bridge .steps { min-height: 11.5em; }
  html.motion #bridge .step { grid-area: 1 / 1; opacity: 0; transform: translateY(14px); transition: opacity .45s var(--ease), transform .7s var(--ease-out); }
  html.motion #bridge .step[data-on] { opacity: 1; transform: none; }
  html.motion #bridge .scene__in { gap: clamp(30px, 6svh, 56px); }
  html.motion #bridge .meter__math { max-width: calc(100% - var(--odo-fs) * 2.4); font-size: 12.5px; }
}

/* ---------- calculator ---------- */
#bridge .bridge__try { margin-top: clamp(72px, 9vw, 140px); }
#bridge .try__title { font-size: clamp(30px, 3.4vw, 52px); font-stretch: 125%; letter-spacing: -0.03em; line-height: 1; }
#bridge .try__line { margin-top: 14px; font-size: 15px; color: var(--muted); }
#bridge .calc { margin-top: clamp(32px, 4vw, 52px); padding-top: 28px; border-top: 2px solid #000; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gut); }
#bridge .calc__set, #bridge .calc__read { grid-column: 1 / -1; min-width: 0; }
#bridge .seg { position: relative; display: inline-flex; max-width: 100%; margin: 0 10px 10px 0; border: 1.5px solid #000; vertical-align: top; }
#bridge .seg button { position: relative; z-index: 1; padding: 9px 14px; border: 0; background: none; cursor: pointer; font-size: 14px; font-weight: 600; font-stretch: 105%; white-space: nowrap; transition: color .35s var(--ease); }
#bridge .seg button[aria-checked="true"] { background: #000; color: #fff; }
html.motion #bridge .seg[data-pill] button[aria-checked="true"] { background: none; }
#bridge .seg__pill { position: absolute; left: 0; top: 0; bottom: 0; width: 10px; background: #000; transform-origin: 0 50%; pointer-events: none; }
#bridge .seg button:focus-visible { outline-offset: 2px; z-index: 2; }
#bridge .calc__label { display: block; margin-top: 26px; font-size: 14px; color: var(--muted); }
#bridge .calc__field { display: flex; align-items: baseline; gap: 12px; margin-top: 6px; padding-bottom: 8px; border-bottom: 2px solid #000; transition: border-color .25s, box-shadow .25s; }
#bridge .calc__field:focus-within { border-bottom-color: var(--v); box-shadow: 0 2px 0 var(--v); }
#bridge .calc__field input { flex: 1; min-width: 0; width: 100%; padding: 4px 0; border: 0; border-radius: 0; background: none; outline: none; font-family: inherit; font-stretch: 112%; font-weight: 600; font-size: clamp(30px, 3vw, 44px); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; color: #000; }
#bridge .calc__unit { font-size: 15px; font-weight: 600; }
#bridge .calc__msg { margin-top: 10px; min-height: 3em; font-size: 14px; color: var(--muted); }
#bridge .calc__msg[data-err] { color: var(--v-err); font-weight: 600; }
#bridge .presets { display: flex; flex-wrap: wrap; align-items: center; gap: 0; margin: 4px 0 0 -10px; font-size: 14px; }
#bridge .presets span { padding: 0 2px 0 10px; color: var(--muted); }
#bridge .presets:not(:has(button)) { display: none; }
#bridge .presets button { min-width: 44px; min-height: 44px; padding: 0 10px; border: 0; background: none; cursor: pointer; font-weight: 600; font-variant-numeric: tabular-nums; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px; transition: color .2s; }
#bridge .presets button:hover { color: var(--v); }
#bridge .calc__read { container-type: inline-size; margin-top: 44px; }

/* rolling readout: right aligned like a calculator display, so new integer digits grow to the left */
#bridge .codo { --ch: 1.12em; position: relative; display: flex; justify-content: flex-end; padding: 38px 0 calc(var(--ch) + .3em + 40px); font-size: clamp(40px, calc(100cqi / 8.4), 104px); font-weight: 600; font-stretch: 125%; line-height: var(--ch); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
#bridge .codo__in { display: inline-flex; align-items: flex-start; transform-origin: 100% 0; transition: opacity .35s var(--ease); }
#bridge .codo__g { position: relative; display: inline-flex; align-items: flex-start; }
#bridge .codo__xw { margin-left: .06em; }
#bridge .codo__six::after, #bridge .codo__xw::after { content: ""; position: absolute; left: .04em; right: .04em; top: calc(var(--ch) + .04em); height: 3px; background: #000; transition: background-color .35s; }
#bridge .codo [data-l]::before { content: attr(data-l); position: absolute; left: 0; bottom: 100%; margin-bottom: 10px; font-size: 13px; font-weight: 500; font-stretch: 100%; letter-spacing: 0; line-height: 1.2; color: var(--muted); white-space: nowrap; }
#bridge .codo__xw[data-l]::before { left: auto; right: 0; color: var(--v-err); font-weight: 600; }
#bridge .codo__x { display: inline-flex; transition: transform .62s cubic-bezier(.55, 0, .35, 1.32), color .3s; }
#bridge .codo__tray { position: absolute; left: -.06em; right: -.06em; top: calc(var(--ch) + .04em); height: calc(var(--ch) + .14em); border: 2px solid var(--v); border-top: 0; background: rgba(102, 0, 255, 0.07); transform-origin: 50% 0; transform: scaleY(0); opacity: 0; transition: transform .45s var(--ease-out), opacity .3s; }
#bridge .codo__tray span { position: absolute; right: 0; top: 100%; margin-top: 10px; font-size: 13px; font-weight: 600; font-stretch: 100%; letter-spacing: 0; line-height: 1.2; color: var(--v-err); white-space: nowrap; }
#bridge .codo[data-mode="in"] .codo__x { color: transparent; -webkit-text-stroke: 1.5px var(--v); }
#bridge .codo[data-mode="in"] .codo__xw::after { background: var(--v); }
#bridge .codo[data-mode="out"] .codo__x { color: var(--g3); }
#bridge .codo[data-mode="out"][data-rest] .codo__x { color: var(--v); transform: translateY(calc(var(--ch) + .14em)); }
#bridge .codo[data-mode="out"][data-rest] .codo__xw::after { background: var(--v); }
#bridge .codo[data-mode="out"][data-rest] .codo__tray { transform: none; opacity: 1; transition-delay: 0s; }
#bridge .codo[data-mode="out"][data-rest] .codo__xw[data-l]::before { content: none; }
#bridge .codo[data-mode="err"] .codo__in { opacity: .16; }
#bridge .codo[data-mode="err"] [data-l]::before { content: none; }
#bridge .codo[data-landed] .codo__tray { animation: bridge-catch .5s var(--ease-out); }
@keyframes bridge-catch { 0% { transform: scaleY(1); } 35% { transform: scaleY(1.07); } 100% { transform: scaleY(1); } }

#bridge .out { display: grid; grid-template-columns: 1fr 1fr; gap: 20px var(--gut); padding-top: 18px; border-top: 1px solid rgba(0, 0, 0, 0.2); }
#bridge .out__k { display: block; font-size: 14px; color: var(--muted); }
#bridge .out__v { display: block; margin-top: 4px; font-size: clamp(18px, 1.7vw, 24px); font-weight: 600; font-stretch: 108%; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#bridge .out__rest:not([data-zero]) .out__v { color: var(--v-err); }
#bridge .calc__math { margin-top: 18px; font-family: var(--mono); font-size: 13px; line-height: 1.6; color: var(--muted); overflow-wrap: anywhere; }

/* ---------- notes ---------- */
#bridge .bridge__notes { margin-top: clamp(64px, 8vw, 112px); display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gut); row-gap: 18px; }
#bridge .bridge__notes > * { grid-column: 1 / -1; min-width: 0; }
#bridge .hatch { position: relative; padding-top: 30px; font-size: clamp(21px, 2.1vw, 30px); font-weight: 500; font-stretch: 108%; letter-spacing: -0.01em; line-height: 1.3; max-width: 24em; }
#bridge .hatch::before { content: ""; position: absolute; left: 0; top: 0; width: 52px; height: 12px; background: var(--v); clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%); }
#bridge .hatch b { font-weight: 700; }
#bridge .bridge__sol { font-size: 15px; line-height: 1.5; max-width: 26em; }
#bridge .bridge__sol b { font-weight: 600; }
#bridge .bridge__fine { max-width: 30em; }
@media (min-width: 900px) {
  #bridge .try__title { grid-column: 1 / span 6; }
  #bridge .try__line { grid-column: 1 / span 5; }
  #bridge .calc__set { grid-column: 1 / span 4; }
  #bridge .calc__read { grid-column: 6 / span 7; margin-top: 0; }
  #bridge .hatch { grid-column: 1 / span 7; grid-row: 1 / span 2; }
  #bridge .bridge__sol { grid-column: 9 / span 4; padding-top: 30px; }
  #bridge .bridge__fine { grid-column: 9 / span 4; }
}
@media (max-width: 520px) { #bridge .out { grid-template-columns: 1fr; } }
@media (min-width: 900px) and (max-width: 1199px) {
  #bridge .calc__set { grid-column: 1 / span 5; }
  #bridge .seg[data-group="dir"] { display: flex; width: 100%; }
  #bridge .seg[data-group="dir"] button { flex: 1 1 0; min-width: 0; white-space: normal; text-align: center; line-height: 1.25; }
}
#bridge .bridge__app { grid-column: 1 / -1; margin-top: 6px; color: var(--v); }
@media (min-width: 900px) { #bridge .bridge__app { grid-column: 9 / span 4; } }
