/* StarTrading — site tokens and components. The lab (lab/index.html) imports this same file.
   Layout: a pinned three.js star-field hero driven by scroll, then alternating full-width bands:
   hub flow (night), approach (cream), work-in-progress banner, contact (star sky).
   One committed night look, with a single cream band for rhythm. */
:root {
  --night: #06080d;          /* page ground: the sky in the plates */
  --night-2: #0c111a;        /* raised night surface */
  --navy: #152238;           /* brand navy */
  --cream: #f3f1ea;          /* brand cream: type on night, ground of the approach band */
  --fg: #e7e4db;             /* body text on night */
  --muted: #8d93a0;          /* secondary text on night */
  --ink-on-cream: #121a2b;   /* type on the cream band */
  --muted-on-cream: #5a6170;
  --sodium: #f0c46a;         /* substation light; one small accent per view, never a fill */
  --line: rgba(243, 241, 234, 0.14);
  --line-strong: rgba(243, 241, 234, 0.34);
  --line-cream: rgba(18, 26, 43, 0.16);

  --font-display: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Hero and nav run edge to edge with a minimal margin; sections sit in a padded, capped column */
  --gutter-l: max(16px, 1.6vw, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, 1.6vw, env(safe-area-inset-right, 0px));
  --pad-x: max(24px, 6vw);
  --maxw: 1680px;
  --edge-l: var(--gutter-l);
  --edge-r: var(--gutter-r);
  --band-y: clamp(128px, 15vw, 240px);
  --ease: cubic-bezier(.2, .7, .15, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--sodium); outline-offset: 4px; }
p { margin: 0; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 500; text-wrap: balance; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding-left: max(var(--pad-x), env(safe-area-inset-left, 0px)); padding-right: max(var(--pad-x), env(safe-area-inset-right, 0px)); }
.mono { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }
.num { font-variant-numeric: tabular-nums; }

/* Logo from the brand kit, coloured by currentColor */
.logo { display: inline-block; width: 156px; height: 24px; background: currentColor;
  -webkit-mask: url("assets/brand/startrading-logo-white.svg") left center / contain no-repeat;
          mask: url("assets/brand/startrading-logo-white.svg") left center / contain no-repeat; }
.mark { display: inline-block; width: 1em; height: 1em; background: currentColor;
  -webkit-mask: url("assets/brand/startrading-mark-white.svg") center / contain no-repeat;
          mask: url("assets/brand/startrading-mark-white.svg") center / contain no-repeat; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 12px; height: 48px; padding: 0 22px; border-radius: 999px;
  font-family: var(--font-body); font-size: 0.95rem; font-weight: 500; letter-spacing: -0.005em;
  border: 1px solid var(--line-strong); color: var(--cream); background: transparent; cursor: pointer;
  transition: background-color .25s, color .25s, border-color .25s; }
.btn:hover { border-color: var(--cream); }
.btn.solid { background: var(--cream); color: var(--night); border-color: var(--cream); }
.btn.solid:hover { background: #fff; }
.btn .arr { transition: transform .3s var(--ease); }
.btn:hover .arr { transform: translateX(4px); }

/* Nav */
.nav { position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  padding-top: calc(18px + env(safe-area-inset-top, 0px)); padding-bottom: 18px;
  padding-left: var(--edge-l); padding-right: var(--edge-r);
  display: flex; align-items: center; justify-content: space-between; gap: 24px; color: var(--cream);
  transition: background-color .35s, border-color .35s, padding .35s; border-bottom: 1px solid transparent; }
.nav.solid { background: rgba(6, 8, 13, 0.82); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom-color: var(--line); padding-top: calc(12px + env(safe-area-inset-top, 0px)); padding-bottom: 12px; }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 30px; }
.nav li a:not(.btn) { font-size: 0.92rem; color: rgba(243, 241, 234, 0.78); transition: color .2s; }
.nav li a:not(.btn):hover { color: var(--cream); }
.nav .btn { height: 40px; padding: 0 18px; font-size: 0.88rem; }
@media (max-width: 820px) { .nav li:not(:last-child) { display: none; } }

/* Hero: a pinned stage; scroll position chooses the frame */
.hero { position: relative; height: 320vh; background: var(--night); }
.hero .stage { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; color: var(--cream); }
.hero canvas, .hero .poster { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero canvas { opacity: 0; transition: opacity 1.4s ease; }
.hero.gl-ready canvas { opacity: 1; }
/* Poster: shown while the scene loads and as the no-WebGL fallback */
.hero .poster { background: radial-gradient(ellipse 60% 55% at 68% 38%, #17243b 0%, #0a0f18 55%, var(--night) 100%); }
.hero .poster .mark { position: absolute; left: 68%; top: 38%; width: 92px; height: 92px; transform: translate(-50%, -50%);
  color: var(--cream); filter: drop-shadow(0 0 18px rgba(240,196,106,.55)); }
@media (max-aspect-ratio: 11/10) { .hero .poster .mark { left: 50%; top: 30%; } .hero .poster { background: radial-gradient(ellipse 90% 45% at 50% 30%, #17243b 0%, #0a0f18 55%, var(--night) 100%); } }
.hero .shade { position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(6,8,13,.5) 0%, rgba(6,8,13,0) 18%),
    linear-gradient(0deg, rgba(6,8,13,.8) 0%, rgba(6,8,13,.2) 34%, rgba(6,8,13,0) 55%); }
.hero .copy { position: absolute; left: var(--edge-l); right: var(--edge-r); bottom: calc(clamp(28px, 6vh, 64px) + env(safe-area-inset-bottom, 0px));
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 28px 56px; }
.hero .kicker { display: flex; align-items: center; gap: 10px; color: rgba(243,241,234,.72); margin-bottom: 22px; }
.hero .kicker .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--sodium); box-shadow: 0 0 12px var(--sodium); }
.hero h1 { font-size: clamp(2.6rem, 7.2vw, 7.4rem); line-height: .96; letter-spacing: -0.045em; max-width: 13ch; }
.hero h1 .ln { display: block; overflow: hidden; padding-bottom: .16em; margin-bottom: -.16em; } /* room for descenders (g, y) */
.hero h1 .ln > span { display: inline-block; transform: translateY(105%); transition: transform 1s var(--ease); }
.hero h1 .ln.on > span { transform: none; }
.hero h1 .ell { display: inline-block; transition: opacity .35s, transform .5s var(--ease); }
.hero h1 .ell.off { opacity: 0; transform: translateX(-.2em); }
.hero .side { display: grid; gap: 22px; max-width: 34ch; opacity: 0; transform: translateY(12px); transition: opacity .6s, transform .8s var(--ease); }
.hero .side.on { opacity: 1; transform: none; }
.hero .side p { color: rgba(243,241,234,.8); font-size: 1rem; line-height: 1.5; }
.hero .side .acts { display: flex; gap: 12px; flex-wrap: wrap; }
.hero .meta { position: absolute; top: calc(92px + env(safe-area-inset-top, 0px)); left: var(--edge-l); right: var(--edge-r);
  display: flex; justify-content: space-between; gap: 16px; color: rgba(243,241,234,.6); }
.hero .scroll { transition: opacity .3s; }
@media (max-width: 820px) {
  .hero .shade { background:
    linear-gradient(180deg, rgba(6,8,13,.5) 0%, rgba(6,8,13,0) 14%),
    linear-gradient(0deg, rgba(6,8,13,.94) 0%, rgba(6,8,13,.78) 42%, rgba(6,8,13,0) 62%); }
  .hero .copy { grid-template-columns: 1fr; }
  .hero h1 { max-width: none; }
  .hero .meta .hide-s { display: none; }
}

/* Bands */
.band { position: relative; padding-block: var(--band-y); }
.band.cream { background: var(--cream); color: var(--ink-on-cream); }
.label { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.cream .label { color: var(--muted-on-cream); }
.label::before { content: ""; width: 28px; height: 1px; background: currentColor; opacity: .6; }
h2 { font-size: clamp(2.1rem, 4.8vw, 4.4rem); line-height: 1.0; letter-spacing: -0.04em; color: var(--cream); }
.cream h2 { color: var(--ink-on-cream); }
.lead { font-size: clamp(1.1rem, 1.6vw, 1.4rem); line-height: 1.45; letter-spacing: -0.01em; max-width: 46ch; }
.body { color: var(--muted); max-width: 58ch; }
.cream .body { color: var(--muted-on-cream); }

/* Hub: information in, decisions out */
.hubsec .head { display: grid; gap: 24px; max-width: 1100px; }
.hubsec .head .lead { color: var(--muted); }
.flow { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, .8fr) minmax(0, 1fr); gap: 0 clamp(56px, 9vw, 160px);
  align-items: center; margin-top: clamp(80px, 10vw, 140px); }
.flow > .col { min-width: 0; position: relative; z-index: 1; }
.flow .wires { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; z-index: 0; pointer-events: none; }
.flow .wires path { fill: none; stroke: var(--line-strong); stroke-width: 1; transition: stroke .3s, opacity .3s; }
.flow .wires path.hot { stroke: var(--cream); }
.flow .wires circle { fill: var(--cream); }
.flow .wires circle.o { fill: var(--sodium); }
.flow .colh { color: var(--muted); padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.flow .node { position: relative; padding: 28px 0; border-bottom: 1px solid var(--line); cursor: default; }
.flow .node h3 { font-size: clamp(1.3rem, 1.7vw, 1.6rem); letter-spacing: -0.02em; color: var(--cream); }
.flow .node p { color: var(--muted); font-size: 1rem; margin-top: 8px; max-width: 36ch; }
.flow .in .node::after, .flow .out .node::before { content: ""; position: absolute; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; border-radius: 50%;
  background: var(--night); border: 1px solid var(--cream); }
.flow .in .node::after { right: -5px; } .flow .out .node::before { left: -5px; }
.flow .in .node { padding-right: 24px; } .flow .out .node { padding-left: 24px; }
.flow .out .colh { padding-left: 24px; }
.flow .core { display: grid; justify-items: center; text-align: center; gap: 22px; }
.flow .core p { color: var(--muted); font-size: 1rem; max-width: 30ch; }
.hubcore { position: relative; width: clamp(170px, 18vw, 260px); aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle, rgba(30,48,82,.9) 0%, rgba(21,34,56,.5) 45%, rgba(6,8,13,0) 70%); }
.hubcore .mark { width: 34%; height: 34%; color: var(--cream); filter: drop-shadow(0 0 16px rgba(240,196,106,.55)); }
.hubcore .ring { position: absolute; inset: 6%; border-radius: 50%; border: 1px dashed var(--line-strong); animation: spin 40s linear infinite; }
.hubcore .ring.r2 { inset: 22%; border-style: solid; border-color: var(--line); animation: pulse 3.2s var(--ease) infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0% { transform: scale(.85); opacity: .9; } 100% { transform: scale(1.35); opacity: 0; } }
.flow .steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; color: var(--cream); }
.flow .steps li { padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 999px; }
.flow .steps li + li::before { content: ""; }
@media (max-width: 900px) {
  .flow { grid-template-columns: 1fr; gap: 0; padding-left: 22px; }
  .flow::before { content: ""; position: absolute; left: 4px; top: 8px; bottom: 8px; width: 1px; background: linear-gradient(var(--line-strong), var(--sodium) 50%, var(--line-strong)); }
  .flow .wires { display: none; }
  .flow .in .node, .flow .out .node, .flow .out .colh { padding-left: 0; padding-right: 0; }
  .flow .in .node::after, .flow .out .node::before { left: -22px; right: auto; }
  .flow .core { justify-items: start; text-align: left; padding: 40px 0; }
  .flow .col.out { margin-top: 8px; }
}

/* Approach */
.approach .top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px clamp(32px, 6vw, 110px); align-items: end; }
.approach .top > * { min-width: 0; }
.approach .stack { display: grid; gap: 20px; }
.approach .neg { font-size: clamp(1.4rem, 2.6vw, 2.2rem); line-height: 1.15; letter-spacing: -0.03em; color: var(--ink-on-cream); }
.approach .neg s { text-decoration-thickness: 2px; text-decoration-color: rgba(18,26,43,.45); color: var(--muted-on-cream); }
.pillars { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin-top: clamp(64px, 9vw, 120px); border-top: 1px solid var(--line-cream); }
.pillar { padding: 28px 28px 8px 0; display: grid; gap: 14px; align-content: start; }
.pillar + .pillar { padding-left: 28px; border-left: 1px solid var(--line-cream); }
.pillar svg { width: 100%; height: auto; aspect-ratio: 2 / 1; display: block; overflow: visible; margin-bottom: 8px; }
.ill * { vector-effect: non-scaling-stroke; }
.ill-precision .grid path { stroke: var(--line-cream); stroke-width: 1; fill: none; }
.ill-precision .limit { stroke: var(--ink-on-cream); stroke-width: 1; stroke-dasharray: 3 4; opacity: .5; fill: none; }
.ill-precision text { font-family: var(--font-mono); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; fill: var(--muted-on-cream); }
.ill-precision .noise { fill: none; stroke: var(--muted-on-cream); stroke-width: 1; opacity: .55; }
.ill-precision .signal { fill: none; stroke: var(--ink-on-cream); stroke-width: 1.6; }
.ill-precision .orders path { fill: var(--ink-on-cream); }
.ill-precision .scan { stroke: #b07d1e; stroke-width: 1; opacity: .7; animation: scan 6s linear infinite; }
@keyframes scan { from { transform: translateX(0); } to { transform: translateX(320px); } }
.ill .draw { stroke-dasharray: 600; stroke-dashoffset: 600; transition: stroke-dashoffset 2.2s var(--ease); }
.pillars.on .ill .draw { stroke-dashoffset: 0; }
.ill-precision .orders path { opacity: 0; transition: opacity .4s; }
.pillars.on .ill-precision .orders path { opacity: 1; }
.pillars.on .ill-precision .orders path:nth-child(1) { transition-delay: .5s; } .pillars.on .ill-precision .orders path:nth-child(2) { transition-delay: .9s; }
.pillars.on .ill-precision .orders path:nth-child(3) { transition-delay: 1.3s; } .pillars.on .ill-precision .orders path:nth-child(4) { transition-delay: 1.7s; }
.ill-data .orbit { fill: none; stroke: var(--line-cream); stroke-width: 1; }
.ill-data .spin circle, .ill-data .inflow circle { fill: var(--ink-on-cream); }
.ill-data .inflow circle { fill: #b07d1e; }
.ill-data .spin { transform-box: view-box; transform-origin: 160px 80px; animation: spin 36s linear infinite; }
.ill-data .s2 { animation-duration: 24s; animation-direction: reverse; } .ill-data .s3 { animation-duration: 14s; }
.ill-data .core { fill: var(--ink-on-cream); }
.ill-data .pulse, .ill-dist .pulse { fill: none; stroke: var(--ink-on-cream); stroke-width: 1; transform-box: fill-box; transform-origin: center; animation: pulse 2.6s var(--ease) infinite; }
.ill-dist .links path { stroke: var(--ink-on-cream); stroke-width: 1; opacity: .3; fill: none; }
.ill-dist .nodes circle { fill: var(--cream); stroke: var(--ink-on-cream); stroke-width: 1.2; }
.ill-dist .out circle { fill: #b07d1e; }
.ill-dist .hub { fill: var(--ink-on-cream); }
.pillar .n { color: var(--muted-on-cream); }
.pillar h3 { font-size: 1.35rem; letter-spacing: -0.02em; }
.pillar p { color: var(--muted-on-cream); max-width: 32ch; }
@media (max-width: 860px) {
  .hubsec .grid, .approach .top { grid-template-columns: 1fr; }
  .pillars { grid-template-columns: 1fr; }
  .pillar, .pillar + .pillar { padding: 26px 0 10px; border-left: 0; border-top: 1px solid var(--line-cream); }
  .pillars { border-top: 0; }
}

/* Work-in-progress banner */
.wip { position: relative; overflow: hidden; background: var(--night-2); border-block: 1px solid var(--line); padding-block: var(--band-y); }
.wip .tape { display: flex; width: max-content; animation: tape 60s linear infinite; }
.wip .track { display: flex; align-items: center; gap: clamp(24px, 3vw, 44px); padding-right: clamp(24px, 3vw, 44px); }
.wip .track span { font-family: var(--font-display); font-weight: 500; font-size: clamp(2.2rem, 5.2vw, 4.4rem); line-height: 1; letter-spacing: -0.04em; white-space: nowrap;
  color: transparent; -webkit-text-stroke: 1px rgba(243,241,234,.26); }
.wip .track .mark { width: clamp(18px, 2.2vw, 28px); height: clamp(18px, 2.2vw, 28px); color: var(--sodium); opacity: .55; flex: none; }
@keyframes tape { to { transform: translateX(-50%); } }

/* Contact under a star sky */
.contact { position: relative; overflow: hidden; padding-block: clamp(120px, 18vw, 260px); background: var(--night); }
.contact > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.contact .bigmark { position: absolute; right: -6vw; top: 50%; width: min(62vw, 760px); height: min(62vw, 760px); transform: translateY(-50%);
  color: var(--cream); opacity: .07; }
.contact .lead { color: rgba(243,241,234,.82); }
.contact .wrap { position: relative; display: grid; gap: 28px; }
.contact h2 { max-width: 12ch; font-size: clamp(2.6rem, 6.4vw, 6.2rem); }
.contact .row { display: flex; align-items: center; gap: 14px 22px; flex-wrap: wrap; }
.contact .mail { font-family: var(--font-mono); font-size: 0.95rem; color: var(--cream); user-select: all; overflow-wrap: anywhere; min-width: 0; }

/* Footer */
.foot { border-top: 1px solid var(--line); padding-block: 48px 40px; color: var(--muted); }
.foot .wrap { display: grid; grid-template-columns: 1.4fr repeat(2, 1fr); gap: 32px; }
.foot .brand { display: grid; gap: 14px; align-content: start; color: var(--cream); }
.foot .brand p { color: var(--muted); max-width: 30ch; }
.foot ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; align-content: start; }
.foot li a:hover { color: var(--cream); }
.foot .legal { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; padding-top: 28px; border-top: 1px solid var(--line); }
@media (max-width: 760px) { .foot .wrap { grid-template-columns: 1fr 1fr; } .foot .brand { grid-column: 1 / -1; } }

/* Reduced motion: the end state, everything visible, nothing looping */
@media (prefers-reduced-motion: reduce) {
  .hero { height: auto; }
  .hero .stage { position: relative; }
  .hero h1 .ln > span, .hero .side { transform: none !important; opacity: 1 !important; transition: none; }
  .hubcore .ring, .wip .tape, .ill-precision .scan, .ill-data .spin, .ill-data .pulse, .ill-dist .pulse { animation: none; }
  .ill .draw { stroke-dashoffset: 0; transition: none; } .ill-precision .orders path { opacity: 1; transition: none; }
  .btn .arr { transition: none; }
}

/* Keep the scroll-revealed introduction usable when reached by keyboard. */
.hero:focus-within .side { opacity: 1; transform: none; }
.hero:focus-within h1 .ln > span { transform: none; }
.hero:focus-within .ell { visibility: hidden; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@media (max-width: 380px) {
  .nav { gap: 12px; }
  .nav .logo { width: 120px; }
  .nav .btn { white-space: nowrap; }
}
