/* Shared scroll-driven hero for secronyx.com (issue #122). Used with js/hero.js.
 *
 * Markup: <section class="hx"> > .hx-pin > .hx-inner > .hx-copy + figure.hx-stage
 * (visual, aria-hidden) + ol.hx-steps (the text equivalent, one <li> per step).
 * Elements with data-at="k" are shown from step k (data-off="m": until step m).
 * State lives in data attributes, not classes, because the pages run the Tailwind CDN, which rescans
 * the page on every class change. The default is the final frame: hero.js sets data-live only when
 * motion is allowed,
 * so no-JS and prefers-reduced-motion both get every element with its full text.
 * Only transform and opacity are animated. Colours come from the page tokens. */

/* Metric-matched fallbacks, so text in the hero keeps its size when the web fonts arrive and the
   stage does not move (Lighthouse counted that as layout shift). */
@font-face { font-family: "Inter Fallback"; src: local("Arial"), local("ArialMT"), local("Liberation Sans"), local("LiberationSans-Regular"), local("Helvetica"); size-adjust: 107.1%; ascent-override: 90.4%; descent-override: 22.5%; line-gap-override: 0%; }
@font-face { font-family: "JetBrains Mono Fallback"; src: local("Courier New"), local("CourierNewPSMT"), local("Liberation Mono"), local("LiberationMono-Regular"); size-adjust: 100%; ascent-override: 102%; descent-override: 30%; line-gap-override: 0%; }

:root { --hx-top: 64px; --hx-bad: #b91c1c; --hx-ok: #15803d; --hx-warn: #b45309; --hx-term: #f6f6f7; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --hx-bad: #f87171; --hx-ok: #4ade80; --hx-warn: #f59e0b; --hx-term: #161618; } }
:root[data-theme="dark"] { --hx-bad: #f87171; --hx-ok: #4ade80; --hx-warn: #f59e0b; --hx-term: #161618; }

/* Full bleed, after the Highfield --pb-edge technique: a section spans the window and is an inline-size
   container, and --hx-edge is the distance from the window edge to the centred 1152px content column.
   Text sits inside the column; backgrounds, canvases and media run to the window edge. No 100vw, so no
   horizontal scrollbar. var() is substituted where it is used, so 100cqw resolves against the section. */
.hx { position: relative; container-type: inline-size; overflow-x: clip;
  --hx-gutter: clamp(16px, 4cqw, 48px); --hx-edge: max(var(--hx-gutter), calc((100cqw - 1152px) / 2 + var(--hx-gutter))); }
.hx { border-bottom: 1px solid var(--border); background: var(--bg); font-family: Inter, "Inter Fallback", ui-sans-serif, system-ui, sans-serif; }
.hx-bg { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(50% 60% at 70% 40%, var(--glow), transparent 70%); }
.hx-pin { position: relative; }
.hx-inner { position: relative; display: grid; }
.hx-copy { min-width: 0; padding: 48px var(--hx-edge) 32px; }
.hx-eyebrow { display: inline-block; margin-bottom: 16px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--brand-fg); }
.hx h1 { color: var(--heading); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-size: 36px; }
@media (min-width: 640px) { .hx h1 { font-size: 48px; } }
.hx-lede { margin-top: 20px; font-size: 18px; line-height: 1.6; color: var(--text-2); max-width: 560px; }
.hx-cta { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 12px; }

/* The stage is the animation canvas: edge to edge under the copy on narrow screens; on wide screens the
   right-hand split, running from the copy column to the right window edge. */
.hx-stage { position: relative; margin: 0; min-width: 0; padding: 24px var(--hx-edge) 28px; background: color-mix(in srgb, var(--card) 80%, transparent); border-top: 1px solid var(--border); }
.hx-stage > :not(.hx-field) { position: relative; max-width: 760px; }
.hx .hx-stage > svg { display: block; width: 100%; max-width: 540px; height: auto; overflow: visible; }
@media (min-width: 1024px) {
  .hx-inner { grid-template-columns: calc(var(--hx-edge) + (min(100cqw, 1152px) - 2 * var(--hx-gutter)) * .5) minmax(0, 1fr); }
  .hx-copy { padding: 72px 48px 72px var(--hx-edge); align-self: center; }
  .hx-stage { border-top: 0; border-left: 1px solid var(--border); padding: 48px var(--hx-gutter) 48px 48px; display: flex; flex-direction: column; justify-content: center; }
}
/* Dot field behind the stage, to the window edge; the .lit copy lights up as a wave at its step. */
.hx-field { position: absolute; inset: 0; pointer-events: none; background-image: radial-gradient(var(--border) 1.3px, transparent 1.6px); background-size: 22px 22px; }
.hx-field.lit { background-image: radial-gradient(var(--brand-fg) 1.4px, transparent 1.7px); -webkit-mask-image: radial-gradient(closest-side at 35% 50%, #000, transparent); mask-image: radial-gradient(closest-side at 35% 50%, #000, transparent); transform: scale(.5); }
.hx-field.lit[data-on] { opacity: .55; transform: none; transition: opacity .8s, transform 1.4s cubic-bezier(.2,.7,.2,1); }
.hx:not([data-live]) .hx-field.lit { opacity: .35; transform: none; }

/* Scroll room: the pinned split plays while the page scrolls past it (wide, tall screens only). */
@media (min-width: 1024px) and (min-height: 640px) and (prefers-reduced-motion: no-preference) {
  .hx[data-live] { height: calc(100svh - var(--hx-top) + 70vh); }
  .hx[data-live] .hx-pin { position: sticky; top: var(--hx-top); height: calc(100svh - var(--hx-top)); display: flex; flex-direction: column; }
  .hx[data-live] .hx-inner { flex: 1; min-height: 0; }
}
.hx-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--border); }
.hx-bar > span { display: block; height: 100%; background: var(--brand-fg); transform-origin: 0 50%; transform: scaleX(var(--p, 1)); }

/* Contained hero (.hx--contained): the same component kept inside the 1152px column, with the stage
   as a card. Only the home and compliance heroes run edge to edge. */
.hx--contained .hx-inner { width: 100%; max-width: 1152px; margin: 0 auto; padding: 48px 16px 40px; gap: 32px; align-items: center; }
.hx--contained .hx-copy { padding: 0; }
.hx--contained .hx-stage { overflow: hidden; border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: var(--card); }
@media (min-width: 640px) { .hx--contained .hx-inner { padding: 64px 24px 48px; } .hx--contained .hx-stage { padding: 20px; } }
@media (min-width: 1024px) {
  .hx--contained .hx-inner { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 48px; }
  .hx--contained .hx-copy { padding: 0; }
  .hx--contained .hx-stage { padding: 24px; border-left: 1px solid var(--border); }
}

.hx-steps { list-style: none; margin: 16px 0 0; padding: 12px 0 0; border-top: 1px solid var(--border); display: grid; gap: 6px; font-size: 14px; line-height: 1.5; counter-reset: hx; }
.hx-steps li { counter-increment: hx; position: relative; padding-left: 28px; color: var(--text-2); }
.hx-steps li::before { content: counter(hx); position: absolute; left: 0; top: 1px; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--border); font-size: 11px; font-weight: 600; text-align: center; line-height: 18px; }
.hx-steps li[aria-current] { color: var(--heading); }
.hx-steps li[aria-current]::before { background: #2dd4bf; border-color: #2dd4bf; color: #04211e; }

/* Step reveal */
.hx [data-at], .hx [data-off] { transition: opacity .45s ease, transform .6s cubic-bezier(.2,.7,.2,1); }
.hx[data-live] [data-at]:not([data-on]) { opacity: 0; }
.hx [data-off]:not([data-on]) { opacity: 0; }
.hx .d1 { transition-delay: .12s; } .hx .d2 { transition-delay: .24s; } .hx .d3 { transition-delay: .36s; }

/* SVG diagram parts */
.hx .n rect { fill: var(--card-2); stroke: var(--border); stroke-width: 1; }
.hx .n.hot rect { stroke: var(--brand-fg); }
.hx .t { fill: var(--heading); font: 600 13px Inter, "Inter Fallback", system-ui, sans-serif; }
.hx .ts { fill: var(--text-2); font: 500 11px Inter, "Inter Fallback", system-ui, sans-serif; }
.hx .tm { fill: var(--text-2); font: 500 11px "JetBrains Mono", "JetBrains Mono Fallback", ui-monospace, monospace; }
.hx .w { stroke: var(--border); stroke-width: 1.5; fill: none; }
.hx .w-lit { stroke: var(--brand-fg); stroke-width: 2; fill: none; }
.hx .w-back { stroke: var(--hx-warn); stroke-width: 2; fill: none; stroke-dasharray: 4 4; }
.hx .ok { fill: var(--hx-ok); } .hx .bad { fill: var(--hx-bad); }
.hx .bubble rect { fill: var(--bg); stroke: var(--brand-fg); }
.hx .pk { opacity: 0; }
.hx .pk[data-on] { animation: hx-fly 1.1s cubic-bezier(.4,0,.2,1) both; }
.hx .pk.d1[data-on] { animation-delay: .12s; } .hx .pk.d2[data-on] { animation-delay: .24s; }
@keyframes hx-fly { 0% { opacity: 0; transform: none; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)); } }

/* HTML stage parts. No Tailwind utilities inside the hero: the pages build those at runtime, and
   anything they size would shift the layout after first paint. */
:where(.hx) :is(h1, p, figure, ol) { margin: 0; }
.hx-gap { display: grid; gap: 12px; }
.hx-mt { margin-top: 6px; } .hx-mt2 { margin-top: 12px; }
.hx-clip { overflow: hidden; white-space: nowrap; }
.hx-split { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.hx-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.hx-chip { position: relative; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--heading); background: var(--card-2); }
.hx-chip::after { content: ''; position: absolute; inset: -1px; border-radius: inherit; border: 2px solid var(--brand-fg); opacity: 0; transition: opacity .4s; }
.hx-chip[data-on]::after, .hx-chip:hover::after, .hx-chip:focus-visible::after { opacity: 1; }
button.hx-chip { cursor: help; font-family: inherit; line-height: inherit; }
.hx-mono { font-family: "JetBrains Mono", "JetBrains Mono Fallback", ui-monospace, monospace; font-size: 12.5px; }
.hx-box { position: relative; border: 1px solid var(--border); border-radius: 8px; background: var(--card-2); padding: 10px 12px; min-width: 0; }
.hx-tag { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.hx-tag.ok { color: var(--hx-ok); } .hx-tag.bad { color: var(--hx-bad); } .hx-tag.warn { color: var(--hx-warn); }
.hx-tip { margin-top: 10px; min-height: 3em; font-size: 13px; line-height: 1.5; color: var(--text); }
.hx-x { color: var(--hx-bad); font-weight: 700; }

/* Features: the refused shell command is struck through */
.hx-strike { position: absolute; left: 10px; right: 10px; top: 50%; height: 2px; background: var(--hx-bad); transform-origin: 0 50%; }
.hx[data-live] .hx-strike:not([data-on]) { opacity: 1; transform: scaleX(0); }
.hx-redact { position: relative; display: inline-block; }
.hx-redact > [data-at] { position: absolute; left: 0; top: 0; white-space: nowrap; background: var(--card-2); color: var(--hx-ok); }

/* Compliance: audit chain */
.hx-chain { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .hx-chain { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; } }
.hx-entry { font-size: 12px; line-height: 1.5; }
.hx-entry b { color: var(--heading); }
.hx[data-tampered] .hx-entry.victim { border-color: var(--hx-bad); }
.hx-entry .hx-was, .hx-entry .hx-now { transition: opacity .3s; }
.hx-entry .hx-now { position: absolute; left: 0; top: 0; color: var(--hx-bad); opacity: 0; }
.hx[data-tampered] .hx-entry .hx-now { opacity: 1; }
.hx[data-tampered] .hx-entry .hx-was { opacity: 0; }
.hx-link { display: block; font-size: 11px; margin-top: 4px; color: var(--hx-ok); transition: transform .4s, opacity .4s; }
.hx[data-tampered] .hx-link.brk { color: var(--hx-bad); transform: translateY(3px) rotate(-4deg); }
.hx-verify { margin-top: 12px; font-size: 13px; font-weight: 600; }
.hx-verify .bad { display: none; color: var(--hx-bad); } .hx-verify .ok { color: var(--hx-ok); }
.hx[data-tampered] .hx-verify .bad { display: inline; } .hx[data-tampered] .hx-verify .ok { display: none; }
.hx-btn { font: inherit; line-height: 1.5; font-size: 13px; font-weight: 600; border-radius: 999px; padding: 6px 14px; border: 1px solid var(--border); background: var(--btn, var(--card-2)); color: var(--heading); cursor: pointer; }
.hx-btn:hover { border-color: var(--brand-fg); }
.hx-btn[aria-pressed="true"] { border-color: var(--hx-bad); }

/* Downloads: terminal with self-typing lines */
.hx-term { background: var(--hx-term); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; overflow-x: auto; font-family: "JetBrains Mono", "JetBrains Mono Fallback", ui-monospace, monospace; font-size: 12.5px; line-height: 1.9; color: var(--heading); }
.hx-term .c { color: var(--text-2); }
.hx-type { position: relative; display: inline-block; overflow: hidden; vertical-align: bottom; white-space: pre; }
.hx-type::after { content: ''; position: absolute; inset: 0; background: var(--hx-term); border-left: .6em solid var(--brand-fg); transform: translateX(100%); }
.hx[data-live] .hx-type::after { transform: translateX(-.6em); transition: transform calc(var(--n, 30) * 22ms) steps(var(--n, 30)); }
.hx[data-live] .hx-type[data-on]::after { transform: translateX(100%); }
.hx[data-live] .hx-type.later[data-on]::after { transition-delay: .9s; }
.hx-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.hx-tabs button[aria-pressed="true"] { background: #2dd4bf; border-color: #2dd4bf; color: #04211e; }
.hx [data-os-pane] { display: none; }
.hx[data-os="linux"] [data-os-pane="linux"], .hx[data-os="macos"] [data-os-pane="macos"], .hx[data-os="windows"] [data-os-pane="windows"] { display: block; }

/* Plugins: tampered pack bounces off */
.hx-bounce[data-on] { animation: hx-bounce .7s cubic-bezier(.3,.7,.4,1) both; }
@keyframes hx-bounce { 0% { transform: translateX(40px); } 55% { transform: translateX(-4px); } 75% { transform: translateX(10px); } 100% { transform: none; } }

/* Demos: timeline */
.hx-tl { position: relative; list-style: none; margin: 0; padding: 0 0 0 22px; display: grid; gap: 10px; }
.hx-tl::before, .hx-tl::after { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.hx-tl::after { background: var(--brand-fg); transform-origin: 50% 0; transform: scaleY(var(--p, 1)); }
.hx-tl > li { position: relative; }
.hx-tl > li::before { content: ''; position: absolute; left: -21px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand-fg); }

/* CSS scroll-driven drift of the glow where supported; JS drives the steps everywhere. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .hx-bg { animation: hx-drift linear both; animation-timeline: view(); animation-range: exit 0% exit 100%; }
    @keyframes hx-drift { to { transform: translateY(18%); opacity: .4; } }
  }
}

/* hero.js sets this for one frame to restart typing without animating the reset. */
.hx[data-reset] *, .hx[data-reset] *::after { transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  .hx *, .hx *::before, .hx *::after { transition: none !important; animation: none !important; }
  .hx .pk { opacity: 0; }
}
