/* ============================================================================
   ui.css — "Lab Console" reskin.

   scrub-engine.js wraps its own defaults in `@layer sw` (verified in the engine
   source — see the injectCSS() comment "Wrap in a cascade layer so the page's
   own theme tokens … always win"). Per the CSS cascade-layers spec, ANY
   unlayered rule beats ANY layered rule regardless of source order or
   specificity — so this stylesheet (loaded as a plain <link>, not inside an
   @layer) overrides the engine's defaults without a single !important.

   Scope: visual reskin of the engine's existing chrome (topbar/nav/copy panel/
   route rail/hint/buttons) plus the loading screen and language toggle, which
   are new elements the engine doesn't build. The scroll/scrub mechanics and
   scrub-engine.js itself are untouched.

   Breakpoint mirrors the engine's own (860px) so mobile layout intent (nav
   hidden, copy panel becomes a bottom sheet, route labels hidden) is
   preserved — those engine rules are layered, so this stylesheet must restate
   them itself rather than relying on the now-lower-precedence originals.
   ========================================================================== */

:root, .sw-root {
  --sw-bg: #061A2F;        /* Deep Navy */
  --sw-ink: #F6FAFC;       /* Cloud White */
  --sw-ink-soft: #A9BFD0;
  --sw-accent: #22B8C8;    /* Data Cyan — per-section accent overrides at runtime */
  --lc-hair: color-mix(in srgb, var(--sw-accent) 30%, transparent);   /* hairline color */
  --lc-mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}

html, body { background: var(--sw-bg); }

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.sw-topbar {
  background: linear-gradient(180deg, color-mix(in srgb, var(--sw-bg) 72%, transparent) 0%, transparent 100%);
  border-bottom: 1px solid transparent; /* set on scroll would need JS; keep static + gradient does the legibility work */
}
.sw-brand { gap: 12px; }
.sw-brand__mark { display: none; }               /* replaced by ui.js with the mark <img> */
.sw-brand__logo { display: block; height: clamp(20px, 2.6vw, 26px); width: auto; }
/* Wordmark is baked into the lockup image now — the engine still builds this
   span (it always does, per config.brand.name), so hide it rather than
   double up on the name. Kept in the DOM (not display:none) so it still
   contributes an accessible name redundantly with the <img alt>. */
.sw-brand__name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.sw-nav {
  background: transparent; backdrop-filter: none; border: 0; border-radius: 0;
  gap: 0; padding: 0; align-items: center;
}
.sw-nav__item {
  font-family: var(--lc-mono); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--sw-ink-soft); padding: 6px 16px; border-radius: 0; position: relative;
}
.sw-nav__item + .sw-nav__item::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 1px; height: 14px; background: var(--lc-hair);
}
.sw-nav__item:hover { color: var(--sw-ink); background: transparent; }
.sw-nav__item.is-active { color: var(--sw-accent); background: transparent; text-shadow: 0 0 12px color-mix(in srgb, var(--sw-accent) 60%, transparent); }

/* Language toggle — appended into .sw-topbar by ui.js, after .sw-nav */
.sw-langtoggle {
  font: inherit; font-family: var(--lc-mono); font-size: .72rem; letter-spacing: .12em;
  color: var(--sw-ink-soft); background: transparent; cursor: pointer;
  border: 1px solid var(--lc-hair); border-radius: 3px; padding: 6px 11px;
  transition: color .2s, border-color .2s, background .2s;
}
.sw-langtoggle:hover { color: var(--sw-accent); border-color: color-mix(in srgb, var(--sw-accent) 55%, transparent); background: color-mix(in srgb, var(--sw-accent) 8%, transparent); }
.sw-langtoggle::before { content: "EN / KO  \2192  "; opacity: .55; font-size: .82em; }

/* ── Copy panel — HUD viewfinder brackets instead of a filled card ───────── */
.sw-copylayer::before {
  background: linear-gradient(90deg, var(--sw-bg) 0%, color-mix(in srgb, var(--sw-bg) 78%, transparent) 38%, transparent 100%);
}
.sw-copy { padding: 26px 28px; }
/* Desktop-only width tweak. Scoped behind min-width so it never fights the
   engine's own mobile rule (`.sw-copy{width:auto;max-width:560px}` inside its
   @media(max-width:860px) block) — that rule is layered but still cascades
   normally against itself; an unscoped unlayered `width` here would beat it
   at every viewport, which is what actually happened on first pass (measured
   .sw-copy at 135px on a 375px-wide viewport before this fix). */
@media (min-width: 861px) {
  .sw-copy { width: min(36vw, 500px); box-sizing: border-box; }
}
.sw-copy::before, .sw-copy::after,
.sw-copy .lc-br-tr, .sw-copy .lc-br-br { content: ""; position: absolute; width: 18px; height: 18px; border-color: var(--sw-accent); opacity: .75; }
.sw-copy::before { top: 0; left: 0; border-top: 1px solid var(--sw-accent); border-left: 1px solid var(--sw-accent); }
.sw-copy::after { bottom: 0; left: 0; border-bottom: 1px solid var(--sw-accent); border-left: 1px solid var(--sw-accent); }
/* two more corners via generated elements — see ui.js (adds .lc-br-tr / .lc-br-br spans once per .sw-copy) */
.sw-copy .lc-br-tr { top: 0; right: 0; border-top: 1px solid var(--sw-accent); border-right: 1px solid var(--sw-accent); }
.sw-copy .lc-br-br { bottom: 0; right: 0; border-bottom: 1px solid var(--sw-accent); border-right: 1px solid var(--sw-accent); }

.sw-copy__num { font-family: var(--lc-mono); letter-spacing: .16em; }
.sw-copy__eyebrow { font-family: var(--lc-mono); letter-spacing: .2em; font-weight: 500; }
.sw-copy__title {
  font-family: var(--sw-font-body, -apple-system, "Segoe UI", sans-serif);
  font-weight: 700; letter-spacing: -.015em; white-space: pre-line; /* honor the \n line breaks already in the copy */
  font-size: clamp(1.6rem, 2.7vw, 2.7rem); line-height: 1.14;
}
.sw-copy__body { font-size: clamp(.96rem, 1.15vw, 1.05rem); }

.sw-copy__tags { gap: 10px; }
.sw-copy__tags li {
  font-family: var(--lc-mono); font-size: .74rem; font-weight: 400; letter-spacing: .04em;
  color: var(--sw-accent); background: transparent; border-radius: 2px;
  border: 1px solid color-mix(in srgb, var(--sw-accent) 45%, transparent); padding: 6px 12px;
}

.sw-btn { border-radius: 2px; font-family: var(--lc-mono); font-size: .82rem; letter-spacing: .06em; padding: 13px 22px; }
.sw-btn--primary {
  background: transparent; color: var(--sw-ink);
  border: 1px solid var(--sw-ink);
}
.sw-btn--primary:hover { background: var(--sw-ink); color: var(--sw-bg); transform: none; }
.sw-btn--ghost {
  color: var(--sw-ink-soft); border: 1px solid var(--lc-hair);
}
.sw-btn--ghost:hover { color: var(--sw-ink); border-color: color-mix(in srgb, var(--sw-ink) 40%, transparent); transform: none; }

/* ── Route rail — nodes on a circuit trace, not filled pill dots ─────────── */
.sw-route::before { width: 1px; opacity: .4; }
.sw-route__dot i {
  width: 7px; height: 7px; background: transparent;
  border: 1.5px solid color-mix(in srgb, var(--sw-accent) 55%, transparent);
}
.sw-route__dot:hover i { background: color-mix(in srgb, var(--sw-accent) 30%, transparent); }
.sw-route__dot.is-active i {
  background: var(--sw-accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sw-accent) 20%, transparent);
}
.sw-route__label {
  font-family: var(--lc-mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--sw-accent); background: color-mix(in srgb, var(--sw-bg) 82%, transparent);
  backdrop-filter: blur(6px); border: 1px solid color-mix(in srgb, var(--sw-accent) 35%, transparent);
  border-radius: 2px;
}

/* ── Scroll hint ───────────────────────────────────────────────────────── */
.sw-hint { font-family: var(--lc-mono); letter-spacing: .2em; color: var(--sw-ink-soft); }
.sw-hint i { border-color: color-mix(in srgb, var(--sw-ink-soft) 55%, transparent); border-radius: 2px; }

/* ── Loading screen (built by loader.js, not by the engine) ──────────────── */
.sw-loader {
  position: fixed; inset: 0; z-index: 999; background: var(--sw-bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  transition: opacity .5s ease; opacity: 1;
}
.sw-loader.is-hidden { opacity: 0; pointer-events: none; }
.sw-loader__canvas { width: min(46vw, 420px); height: min(46vw, 420px); max-height: 52vh; }
.sw-loader__bar { width: min(60vw, 360px); height: 1px; background: color-mix(in srgb, var(--sw-accent) 25%, transparent); position: relative; }
.sw-loader__bar span { position: absolute; inset: 0 auto 0 0; width: 0%; background: var(--sw-accent); transition: width .15s linear; box-shadow: 0 0 8px color-mix(in srgb, var(--sw-accent) 70%, transparent); }
.sw-loader__label { font-family: var(--lc-mono); font-size: .78rem; letter-spacing: .18em; text-transform: uppercase; color: var(--sw-accent); }
.sw-loader__sub { font-family: var(--lc-mono); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--sw-ink-soft); }

@media (max-width: 860px) {
  .sw-nav { display: none; }
  .sw-copylayer::before { width: 100%; height: 60%; top: auto; bottom: 0; background: linear-gradient(0deg, var(--sw-bg) 10%, color-mix(in srgb, var(--sw-bg) 72%, transparent) 48%, transparent 100%); }
  .sw-copy { padding: 20px; }
  .sw-route__label { display: none; }
  .sw-loader__canvas { width: 66vw; height: 66vw; max-height: 42vh; }
}

@media (prefers-reduced-motion: reduce) {
  .sw-loader { transition: none; }
}

/* ── Hologram section — material structure / simulation / ML motif ───────── */
.lc-holo {
  position: relative; z-index: 5;
  min-height: 72vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 28px; padding: 60px 24px; overflow: hidden;
}
.lc-holo__canvas { width: min(50vw, 460px); height: min(50vw, 460px); max-height: 50vh; }
.lc-holo__copy { max-width: 640px; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.lc-holo__eyebrow {
  font-family: var(--lc-mono); font-size: .78rem; letter-spacing: .2em; text-transform: uppercase;
  color: var(--sw-accent);
}
.lc-holo__title {
  font-family: var(--sw-font-body, -apple-system, "Segoe UI", sans-serif);
  font-weight: 700; font-size: clamp(1.3rem, 2.2vw, 1.9rem); line-height: 1.4; color: var(--sw-ink);
  margin: 0;
}
@media (max-width: 860px) {
  .lc-holo { min-height: 56vh; padding: 40px 20px; gap: 20px; }
  .lc-holo__canvas { width: 78vw; height: 78vw; max-height: 40vh; }
}
@media (prefers-reduced-motion: reduce) {
  .lc-holo__canvas { display: none; } /* static text only, no point rendering an unanimated single frame */
}

/* ── Footer — real business info, sits below the video chain ─────────────── */
.sw-footer {
  position: relative; z-index: 5; /* above .sw-track(z:1), below the fixed chrome layers */
  background: var(--sw-bg);
  border-top: 1px solid var(--lc-hair);
}
.sw-footer__inner {
  max-width: 720px; margin: 0 auto; padding: 56px 24px 40px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  text-align: center;
}
.sw-footer__address {
  font-style: normal; font-size: .82rem; color: var(--sw-ink-soft); line-height: 1.6;
}
.sw-footer__email {
  font-family: var(--lc-mono); font-size: .82rem; color: var(--sw-accent); text-decoration: none;
}
.sw-footer__email:hover { text-decoration: underline; }
.sw-footer__social { display: flex; gap: 14px; }
.sw-footer__social a {
  display: grid; place-items: center; width: 34px; height: 34px;
  color: var(--sw-ink-soft); border: 1px solid var(--lc-hair); border-radius: 50%;
  transition: color .2s, border-color .2s;
}
.sw-footer__social a:hover { color: var(--sw-accent); border-color: color-mix(in srgb, var(--sw-accent) 55%, transparent); }
.sw-footer__copy { font-size: .74rem; color: color-mix(in srgb, var(--sw-ink-soft) 70%, transparent); margin: 6px 0 0; }
