/* TensorLynx · Adjoint-based shape optimisation (adjoint-shape-optimization). Page-only drawings and motion.
   Scope: .tx-p-adj. Motion: transforms, opacity and stroke only; continuous loops live inside [data-tx-loop];
   html.tx-reduced / prefers-reduced-motion show every final state; without JS everything is visible. */

.tx-p-adj {
  --adj-red: var(--diag);
  --adj-blue: #5aa9ff;
  --adj-wall: var(--text-primary);
  --adj-pipe: rgba(14, 59, 67, .55);
}

/* ---- Shared drawing vocabulary -------------------------------------------------------------------------------- */
.tx-p-adj svg text { font-family: var(--font-mono); fill: var(--tx-muted); }
.tx-p-adj .adj-pipe { fill: var(--adj-pipe); stroke: none; }
.tx-p-adj .adj-pipe--new { fill: rgba(57, 208, 224, .10); }
.tx-p-adj .adj-wall { fill: none; stroke: var(--adj-wall); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.tx-p-adj .adj-wall--new { stroke: var(--tx-cyan); }
.tx-p-adj .adj-wall--ghost { stroke: var(--border-strong); stroke-dasharray: 7 7; stroke-width: 2; }
.tx-p-adj .adj-stream { fill: none; stroke: var(--tx-cyan); stroke-width: 1.8; opacity: .75; stroke-linecap: round; }
.tx-p-adj .adj-back { fill: none; stroke: var(--tx-amber); stroke-width: 3.2; stroke-linecap: round; stroke-dasharray: .03 .05; opacity: .9; animation: adj-back 3.2s linear infinite; }
@keyframes adj-back { to { stroke-dashoffset: -1; } }
.tx-p-adj .adj-sens { fill: none; stroke-width: 9; stroke-linecap: round; opacity: .95; }
.tx-p-adj .adj-hog path { fill: none; stroke-width: 2.6; stroke-linecap: round; }
.tx-p-adj .adj-hog--out path { stroke: var(--adj-red); }
.tx-p-adj .adj-hog--in path { stroke: var(--adj-blue); }
.tx-p-adj .adj-lattice path, .tx-p-adj .adj-lat { fill: none; stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 5; }
.tx-p-adj .adj-cps circle { fill: var(--surface-2); stroke: var(--tx-cyan); stroke-width: 1.6; }
.tx-p-adj .adj-t-h { font-family: var(--font-sans); font-size: 22px; font-weight: 600; fill: var(--tx-ink); }
.tx-p-adj .adj-t-big { font-family: var(--font-sans); font-size: 24px; font-weight: 600; fill: var(--tx-ink); }
.tx-p-adj .adj-t-s { font-size: 17px; }

/* ---- Hero ------------------------------------------------------------------------------------------------------ */
.tx-p-adj .adj-hero { display: grid; place-items: center; }
.tx-p-adj .adj-hero-tags rect { fill: var(--surface-1); stroke: var(--accent-border); }
.tx-p-adj .adj-hero-tags .adj-tag-amber { stroke: rgba(242, 163, 58, .5); }
.tx-p-adj .adj-hero-tags text { font-size: 18px; fill: var(--tx-ink); }
.tx-p-adj .adj-hero-tags .adj-legend { font-size: 17px; fill: var(--tx-muted); }
.tx-p-adj .adj-hero-glow { transform-box: fill-box; transform-origin: center; animation: adj-breathe 5s ease-in-out infinite; }
@keyframes adj-breathe { 50% { opacity: .55; transform: scale(.92); } }
.js .tx-p-adj .adj-hero .adj-hog { opacity: 0; transform: translateY(4px); transition: opacity .9s var(--ease-out) 1.2s, transform .9s var(--ease-out) 1.2s; }
.js .tx-p-adj .adj-hero.is-in .adj-hog { opacity: 1; transform: none; }
.js .tx-p-adj .adj-hero .adj-sens.tx-draw { transition-duration: 2s; transition-delay: calc(400ms + var(--i, 0) * 120ms); }

/* ---- Problem: the cost grid ------------------------------------------------------------------------------------ */
.tx-p-adj #adj-cell rect { fill: var(--tx-amber); }
.tx-p-adj .adj-cells-ghost { opacity: .12; }
.tx-p-adj .adj-cells { opacity: .9; }
.tx-p-adj .adj-blk--flow { fill: var(--tx-cyan); opacity: .85; }
.tx-p-adj .adj-blk--adj { fill: var(--tx-amber); opacity: .85; }
.js .tx-p-adj .adj-cost .adj-cells { transform-box: fill-box; transform-origin: top; transform: scaleY(0); transition: transform 1.6s var(--ease-out) .3s; }
.js .tx-p-adj .adj-cost.is-in .adj-cells { transform: none; }
.tx-p-adj .adj-n { display: grid; gap: .4rem; width: 100%; font-family: var(--font-mono); color: var(--tx-ink); }
.tx-p-adj .adj-n output { color: var(--tx-amber); font-weight: 600; }
.tx-p-adj .adj-n input { width: 100%; accent-color: var(--tx-amber); }
.tx-p-adj .adj-n input:focus-visible { outline: 2px solid var(--tx-amber); outline-offset: 4px; }

/* ---- How: the sticky stage, one state per step ------------------------------------------------------------------ */
.tx-p-adj .adj-g, .tx-p-adj .adj-cap { transition: opacity .6s var(--ease-out), transform .8s var(--ease-out); }
.tx-p-adj .adj-g-move path { fill: none; stroke: var(--tx-amber); stroke-width: 3; stroke-linecap: round; }
.tx-p-adj .adj-panel { fill: var(--surface-0); stroke: var(--accent-border); }
.tx-p-adj .adj-axis { fill: none; stroke: var(--border-strong); stroke-width: 1.5; }
.tx-p-adj .adj-ref { fill: none; stroke: var(--tx-muted); stroke-width: 1.2; stroke-dasharray: 5 6; }
.tx-p-adj .adj-taylor { fill: none; stroke: var(--tx-green); stroke-width: 2.6; }
.tx-p-adj .adj-pt { fill: var(--tx-green); }
.tx-p-adj .adj-cap { font-size: 20px; fill: var(--tx-ink); opacity: 0; }
.tx-p-adj .adj-g-wall1 { opacity: 0; }
/* With JS the step decides what the stage shows. */
.js .tx-p-adj .adj-how .adj-g-flow,
.js .tx-p-adj .adj-how .adj-g-back,
.js .tx-p-adj .adj-how .adj-g-sens,
.js .tx-p-adj .adj-how .adj-g-move,
.js .tx-p-adj .adj-how .adj-g-gate { opacity: 0; }
.js .tx-p-adj .adj-how .adj-g-sens { transform: translateY(6px); }
.js .tx-p-adj .adj-how .adj-g-lat { opacity: .25; }
.js .tx-p-adj .adj-how[data-active="1"] .adj-g-lat,
.js .tx-p-adj .adj-how[data-active="4"] .adj-g-lat { opacity: 1; }
.js .tx-p-adj .adj-how[data-active="2"] .adj-g-flow,
.js .tx-p-adj .adj-how[data-active="3"] .adj-g-flow,
.js .tx-p-adj .adj-how[data-active="5"] .adj-g-flow { opacity: 1; }
.js .tx-p-adj .adj-how[data-active="3"] .adj-g-flow { opacity: .3; }
.js .tx-p-adj .adj-how[data-active="3"] .adj-g-back { opacity: 1; }
.js .tx-p-adj .adj-how[data-active="3"] .adj-g-sens,
.js .tx-p-adj .adj-how[data-active="4"] .adj-g-sens { opacity: 1; transform: none; }
.js .tx-p-adj .adj-how[data-active="4"] .adj-g-sens { opacity: .45; }
.js .tx-p-adj .adj-how[data-active="4"] .adj-g-move { opacity: 1; }
.js .tx-p-adj .adj-how[data-active="4"] .adj-g-wall1,
.js .tx-p-adj .adj-how[data-active="5"] .adj-g-wall1 { opacity: 1; }
.js .tx-p-adj .adj-how[data-active="4"] .adj-g-wall0,
.js .tx-p-adj .adj-how[data-active="5"] .adj-g-wall0 { opacity: .3; }
.js .tx-p-adj .adj-how[data-active="5"] .adj-g-gate { opacity: 1; }
.js .tx-p-adj .adj-how[data-active="1"] .adj-cap-1,
.js .tx-p-adj .adj-how[data-active="2"] .adj-cap-2,
.js .tx-p-adj .adj-how[data-active="3"] .adj-cap-3,
.js .tx-p-adj .adj-how[data-active="4"] .adj-cap-4,
.js .tx-p-adj .adj-how[data-active="5"] .adj-cap-5 { opacity: 1; }
/* Without JS the stage shows the finished picture: new wall over the old, sensitivity and check. */
html:not(.js) .tx-p-adj .adj-g-wall1 { opacity: 1; }
html:not(.js) .tx-p-adj .adj-g-wall0 { opacity: .35; }
html:not(.js) .tx-p-adj .adj-g-back { opacity: 0; }

/* ---- Depth: the chain diagram and the tabs ---------------------------------------------------------------------- */
.tx-p-adj .adj-links path.tx-flow { fill: none; stroke: var(--tx-cyan); stroke-width: 3; opacity: .55; }
.tx-p-adj .adj-link-s { fill: none; stroke: var(--accent-border); stroke-width: 2; }
.tx-p-adj .adj-node rect { fill: var(--surface-2); stroke: var(--border-strong); stroke-width: 1.5; transition: stroke var(--dur-base), fill var(--dur-base); }
.tx-p-adj .adj-node text { font-family: var(--font-sans); font-size: 21px; font-weight: 600; fill: var(--tx-ink); }
.tx-p-adj .adj-node .adj-sub { font-family: var(--font-mono); font-size: 16px; font-weight: 400; fill: var(--tx-muted); }
.tx-p-adj .adj-node--amber rect { stroke: rgba(242, 163, 58, .6); }
.tx-p-adj .adj-node--gate rect { stroke: rgba(79, 209, 139, .6); }
.tx-p-adj .adj-node { outline: none; }
.tx-p-adj .adj-node:hover rect, .tx-p-adj .adj-node:focus-visible rect { stroke: var(--tx-cyan); fill: var(--surface-3); }
.tx-p-adj .adj-node:focus-visible rect { stroke: var(--tx-amber); stroke-width: 3; }
.tx-p-adj .adj-chain { align-self: start; }
.tx-p-adj .adj-pan { padding: .2rem 0; }
.tx-p-adj .adj-pan p { color: var(--tx-muted); }
.tx-p-adj .adj-pan:focus-visible { outline: 2px solid var(--tx-amber); outline-offset: 6px; border-radius: var(--radius-sm); }
.tx-p-adj .adj-eq {
  font-family: var(--font-mono); font-size: var(--step-md); color: var(--tx-ink) !important; padding: .8rem 1rem;
  border-left: 3px solid var(--tx-amber); background: var(--accent-2-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  overflow-x: auto; white-space: nowrap;
}
.tx-p-adj .adj-pan a, .tx-p-adj .tx-step a, .tx-p-adj .tx-card a { color: var(--tx-cyan); }

/* ---- Proof: ladder, comparator, facts --------------------------------------------------------------------------- */
.tx-p-adj .adj-grid path { fill: none; stroke: var(--border-subtle); stroke-width: 1; }
.tx-p-adj .adj-grid text { font-size: 17px; }
.tx-p-adj .adj-band { fill: rgba(57, 208, 224, .16); stroke: var(--accent-border); }
.tx-p-adj .adj-traj { fill: none; stroke: var(--tx-amber); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.tx-p-adj .adj-dot { stroke: var(--surface-1); stroke-width: 3; }
.tx-p-adj .adj-dot--base { fill: var(--text-primary); }
.tx-p-adj .adj-dot--gen { fill: var(--tx-violet); }
.tx-p-adj .adj-dot--ref { fill: var(--tx-cyan); }
.tx-p-adj .adj-v { font-size: 20px; font-weight: 600; fill: var(--tx-ink); }
.tx-p-adj .adj-xl { font-family: var(--font-sans); font-size: 19px; fill: var(--tx-ink); }
.js .tx-p-adj .adj-ladder .adj-dot { transform-box: fill-box; transform-origin: center; transform: scale(calc(.4 + .6 * min(1, var(--p, 1) * 2.2))); }

.tx-p-adj .adj-cmp-view { aspect-ratio: 640 / 540; touch-action: pan-y; }
.tx-p-adj .adj-cmp-view svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tx-p-adj .adj-cmp-base { position: relative !important; }
.tx-p-adj .adj-cmp-bg { fill: var(--surface-1); }
.tx-p-adj .adj-bubble { fill: none; stroke: var(--tx-amber); stroke-width: 2.4; stroke-dasharray: 5 4; }
.tx-p-adj .adj-cmp-l { font-family: var(--font-sans); font-size: 24px; font-weight: 600; fill: var(--tx-ink); }
.tx-p-adj .adj-cmp-v { font-size: 20px; fill: var(--tx-cyan); }
.tx-p-adj .adj-cmp-base .adj-cmp-v { fill: var(--tx-ink); }

.tx-p-adj .adj-facts { margin-top: 2rem; display: grid; gap: var(--tx-gap); }
.tx-p-adj .tx-kpis dd { margin: 0; }
.tx-p-adj .tx-kpi { display: flex; flex-direction: column; gap: .55rem; }
.tx-p-adj .tx-kpi .tx-kpi-l { margin: 0; order: 2; }
.tx-p-adj .tx-kpi .tx-kpi-v { order: 1; color: var(--tx-cyan); }
.tx-p-adj .tx-kpi .adj-kpi-n { order: 3; font-size: var(--step-xs); color: var(--tx-muted); display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.tx-p-adj .adj-kpi-s { text-transform: uppercase; letter-spacing: .02em; }
.tx-p-adj .adj-cards .tx-card p { line-height: var(--leading-normal); }

/* ---- Value ------------------------------------------------------------------------------------------------------ */
.tx-p-adj .adj-apps { margin-top: 2.4rem; }
.tx-p-adj .adj-cap-t { caption-side: top; text-align: left; padding: 1rem 1.1rem .2rem; font-family: var(--font-mono); font-size: var(--step-xs); color: var(--tx-muted); letter-spacing: .06em; text-transform: uppercase; }

/* ---- Small screens ----------------------------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .tx-p-adj .tx-hero-figure { aspect-ratio: 640 / 560; min-height: 0; }
  .tx-p-adj .adj-eq { font-size: var(--step-sm); }
}

/* ---- Reduced motion: final states ---------------------------------------------------------------------------------- */
.tx-reduced .tx-p-adj .adj-hero .adj-hog,
.tx-reduced .tx-p-adj .adj-cost .adj-cells { opacity: 1 !important; transform: none !important; transition: none !important; }
.tx-reduced .tx-p-adj .adj-back { stroke-dasharray: none; opacity: .7; }
.tx-reduced .tx-p-adj .adj-ladder .adj-dot { transform: none; }
.tx-reduced .tx-p-adj .adj-g, .tx-reduced .tx-p-adj .adj-cap { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .js .tx-p-adj .adj-hero .adj-hog, .js .tx-p-adj .adj-cost .adj-cells { opacity: 1; transform: none; }
  .js .tx-p-adj .adj-ladder .adj-dot { transform: none; }
}

/* Hero tilt lives on an inner wrapper so the reveal transform cannot cancel it. */
.tx-p-adj .adj-tilt { width: 100%; height: 100%; }
