/**
 * Interface layer — styles for ui.js.
 *
 * Same palette and doctrine as the rest of the site: hairlines, registration
 * marks, signal-orange accents. "Futuristic" here means instrument-like —
 * HUD readouts, a lock-on bracket, light that responds to the hand — not a
 * change of skin.
 */

@property --trk {
  syntax: "<length>";
  inherits: true;
  initial-value: 170px;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

/* Scroll progress drawn along the header's bottom edge, right to left. */
.site-header::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  width: calc(var(--scroll-progress, 0) * 100%);
  height: 1px;
  background: var(--signal);
  opacity: 0;
  transition: opacity .4s;
}
.site-header.is-scrolled::after { opacity: 1; }

.header-cta { transition: transform .6s var(--ease-flight), color .35s, background .35s; }
.header-cta i { transition: background .35s; }
.header-cta:hover { color: var(--paper); background: var(--ink); }
.header-cta:hover i { background: var(--signal); }

/* ── Magnetic ────────────────────────────────────────────────────────────── */

[data-magnetic] {
  transform: translate3d(var(--mag-x, 0px), var(--mag-y, 0px), 0);
  transition: transform .6s var(--ease-flight), color .35s, background .35s;
}

/* ── Mobile menu ─────────────────────────────────────────────────────────── */

.menu-toggle {
  display: none;
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink);
  cursor: pointer;
}
.menu-toggle span {
  position: absolute;
  left: 11px;
  right: 11px;
  height: 1.5px;
  background: currentColor;
  transition: transform .5s var(--ease-flight), top .5s var(--ease-flight), right .5s var(--ease-flight);
}
.menu-toggle span:first-child { top: 17px; }
.menu-toggle span:last-child { top: 25px; right: 18px; }
.menu-open .menu-toggle span:first-child { top: 21px; transform: rotate(45deg); }
.menu-open .menu-toggle span:last-child { top: 21px; right: 11px; transform: rotate(-45deg); }
.menu-open body { overflow: hidden; }
/* The open sheet is paper, so the header drops its scrolled glass. */
.menu-open .site-header { background: transparent; backdrop-filter: none; border-color: transparent; }

.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 75;
  padding: 104px var(--pad) 34px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  background: var(--paper);
  /* Opens as an iris from the toggle, which sits at the far left in RTL. */
  clip-path: circle(0 at calc(var(--pad) + 22px) 35px);
  transition: clip-path .65s var(--ease-flight);
}
/* `display: flex` above would otherwise override the hidden attribute. */
.mobile-menu[hidden] { display: none; }
.mobile-menu.is-open { clip-path: circle(150% at calc(var(--pad) + 22px) 35px); }
.mobile-menu nav { display: grid; }
.mobile-menu nav a {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  font-size: clamp(34px, 10vw, 56px);
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1.25;
  clip-path: inset(0 0 0 100%);
  transition: clip-path .7s var(--ease-flight);
  transition-delay: calc(.12s + var(--n, 0) * .07s);
}
.mobile-menu nav a:focus-visible { outline: 1px dashed var(--signal); outline-offset: -1px; }
.mobile-menu nav a small { color: var(--signal); font: 700 10px/1 system-ui, sans-serif; letter-spacing: .14em; }
.mobile-menu.is-open nav a { clip-path: inset(-10%); }
.mobile-menu__foot {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  clip-path: inset(0 0 0 100%);
  transition: clip-path .7s var(--ease-flight) calc(.12s + var(--n, 0) * .07s);
}
.mobile-menu.is-open .mobile-menu__foot { clip-path: inset(-10%); }
.mobile-menu__rose {
  position: absolute;
  left: -40px;
  bottom: 60px;
  width: 220px;
  height: 220px;
  color: var(--ink-soft);
  opacity: .35;
  animation: slow-turn 40s linear infinite;
}

@media (max-width: 900px) {
  .menu-toggle { display: block; }
}
@media (max-width: 600px) {
  .header-cta { display: none; }
}

/* ── Telemetry HUD ───────────────────────────────────────────────────────── */

.telemetry {
  display: grid;
  gap: 3px;
  font: 600 9px/1.55 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: .08em;
}
.telemetry b { margin-inline-end: 3px; color: var(--signal); font-weight: 700; }
.telemetry em { color: var(--ink); font-style: normal; font-variant-numeric: tabular-nums; }
.telemetry__live { margin-bottom: 4px; color: var(--ink); }
.telemetry__live i {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 3px rgba(227, 75, 50, .18);
  animation: telemetry-blink 1.6s steps(2, jump-none) infinite;
}

/* ── Tracking bracket ────────────────────────────────────────────────────── */

.tracker {
  --trk: 170px;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 3;
  width: 0;
  height: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .45s, --trk .9s var(--ease-flight);
}
/* Lock-on: the bracket closes from wide to tight as it acquires the bird. */
.tracker.is-locked { --trk: 150px; opacity: 1; }
.tracker i {
  position: absolute;
  width: 13px;
  height: 13px;
  border: 0 solid var(--signal);
}
.tracker i:nth-child(1) { left: calc(var(--trk) * var(--depth, 1) / -2); top: calc(var(--trk) * var(--depth, 1) / -2); border-width: 1.5px 0 0 1.5px; }
.tracker i:nth-child(2) { right: calc(var(--trk) * var(--depth, 1) / -2); top: calc(var(--trk) * var(--depth, 1) / -2); border-width: 1.5px 1.5px 0 0; }
.tracker i:nth-child(3) { left: calc(var(--trk) * var(--depth, 1) / -2); bottom: calc(var(--trk) * var(--depth, 1) / -2); border-width: 0 0 1.5px 1.5px; }
.tracker i:nth-child(4) { right: calc(var(--trk) * var(--depth, 1) / -2); bottom: calc(var(--trk) * var(--depth, 1) / -2); border-width: 0 1.5px 1.5px 0; }
.tracker__label {
  position: absolute;
  left: calc(var(--trk) * var(--depth, 1) / 2 + 8px);
  top: calc(var(--trk) * var(--depth, 1) / -2);
  padding: 4px 7px;
  color: var(--paper);
  background: var(--ink);
  direction: ltr;
  white-space: nowrap;
  font: 700 8px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: .14em;
}
.tracker__label b { margin-left: 6px; color: var(--lime); font-weight: 700; }

@media (max-width: 700px) {
  .tracker { --trk: 120px; }
  .tracker.is-locked { --trk: 100px; }
}

/* ── Reticle cursor ──────────────────────────────────────────────────────── */

.has-reticle, .has-reticle * { cursor: none !important; }
.has-reticle input, .has-reticle textarea, .has-reticle select { cursor: text !important; }

/* Difference blending inverts against whatever is under it, so one white
   cursor reads on paper, on the ink panel and on the signal-orange contact. */
.reticle {
  position: fixed;
  inset: 0;
  z-index: 150;
  color: #fff;
  pointer-events: none;
  mix-blend-mode: difference;
  opacity: 0;
  transition: opacity .3s;
}
.has-reticle .reticle { opacity: 1; }
.has-reticle .reticle.is-away { opacity: 0; }
.reticle__dot, .reticle__ring, .reticle__label { position: absolute; top: 0; left: 0; will-change: transform; }
.reticle__dot { width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: currentColor; transition: opacity .2s; }
.reticle__ring { width: 40px; height: 40px; margin: -20px 0 0 -20px; }
.reticle__ring svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
  transition: transform .5s var(--ease-flight), opacity .25s;
}
.reticle.is-hover .reticle__ring svg { transform: scale(1.65) rotate(45deg); }
.reticle.is-down .reticle__ring svg { transform: scale(.72); }
.reticle.is-hover.is-down .reticle__ring svg { transform: scale(1.3) rotate(45deg); }
.reticle.is-text .reticle__ring svg, .reticle.is-text .reticle__dot { opacity: 0; }
.reticle__label {
  margin: 30px 0 0 30px;
  white-space: nowrap;
  font: 700 9px/1 system-ui, sans-serif;
  letter-spacing: .14em;
  opacity: 0;
  transition: opacity .25s;
}
.reticle.has-label .reticle__label { opacity: 1; }

/* ── Spotlight cards ─────────────────────────────────────────────────────── */

.project-frame { position: relative; }
.spotlight {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .5s;
  background: radial-gradient(340px circle at var(--mx, 50%) var(--my, 50%), rgba(227, 75, 50, .14), transparent 65%);
}
/* A border that is lit only near the cursor, masked to a 1px frame. */
.spotlight::after {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 50%), var(--signal), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
[data-spotlight]:hover .spotlight { opacity: 1; }
.portfolio .spotlight { background: radial-gradient(380px circle at var(--mx, 50%) var(--my, 50%), rgba(184, 204, 91, .1), transparent 65%); }
.portfolio .spotlight::after { background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), var(--lime), transparent 70%); }
.capability h3, .capability p { position: relative; z-index: 1; }

.capability__icon svg { transition: transform .9s var(--ease-flight); }
.capability:hover .capability__icon svg { transform: rotate(-30deg) scale(1.08); }
.capability:hover .capability__icon { color: var(--paper); }

/* ── Hero ────────────────────────────────────────────────────────────────── */

/* The one holographic word in the type: a sheen of lime crossing the signal
   orange, timed to pass and rest rather than loop continuously. */
.hero__title em {
  color: transparent;
  background: linear-gradient(100deg, var(--signal) 0 36%, #ff9466 45%, #d6ee78 50%, #ff9466 55%, var(--signal) 64% 100%);
  background-size: 280% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  animation: holo-sheen 6s var(--ease-flight) infinite;
}
.hero__falcon-mark .glyph svg { animation: slow-turn 36s linear infinite; }

/* ── Ticker ──────────────────────────────────────────────────────────────── */

.ticker {
  position: relative;
  z-index: 1;
  padding: clamp(24px, 4vw, 60px) 0 clamp(40px, 6vw, 90px);
  overflow: hidden;
}
.ticker__lane { overflow: hidden; white-space: nowrap; }
.ticker__lane--ink {
  position: relative;
  z-index: 1;
  padding: 12px 0;
  color: var(--paper);
  background: var(--ink);
  transform: rotate(-2deg) scale(1.05);
}
.ticker__lane--outline {
  margin-top: -6px;
  padding: 8px 0;
  background: var(--paper);
  border-block: 1px solid var(--ink);
  transform: rotate(1.3deg) scale(1.05);
}
.ticker__track {
  display: inline-flex;
  align-items: center;
  gap: clamp(20px, 3vw, 44px);
  padding-inline-end: clamp(20px, 3vw, 44px);
  will-change: transform;
}
.ticker__track span { font-size: clamp(28px, 4.8vw, 70px); font-weight: 800; letter-spacing: -.04em; line-height: 1.25; }
.ticker__lane--outline span { color: transparent; -webkit-text-stroke: 1.2px var(--ink); }
.ticker__track .glyph { flex: 0 0 auto; width: clamp(24px, 2.8vw, 40px); height: clamp(24px, 2.8vw, 40px); color: var(--paper); }
.ticker .g-detail { stroke: var(--lime); }
.ticker__track b { color: var(--signal); font-size: clamp(16px, 2.2vw, 30px); }

/* ── Manifesto, word by word ─────────────────────────────────────────────── */

/* `--p` runs 0 → 1 as the quote crosses the viewport; each word lights once
   the sweep passes its index. Unlit words stay faintly present so the
   sentence is always readable as a whole. */
.motion-ready [data-words] .word {
  opacity: clamp(.13, calc((var(--p, 1) - .16) / .36 * var(--wn, 1) - var(--wi, 0)), 1);
}

/* ── Keyframes ───────────────────────────────────────────────────────────── */

@keyframes holo-sheen {
  0% { background-position: 110% 0; }
  55%, 100% { background-position: -30% 0; }
}
@keyframes slow-turn { to { transform: rotate(360deg); } }
@keyframes telemetry-blink { 50% { opacity: .15; } }

/* ── Reduced motion ──────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .motion-ready [data-words] .word { opacity: 1; }
  .tracker, .reticle { display: none; }
  .hero__title em { animation: none; background-position: 50% 0; }
  [data-magnetic] { transform: none; }
}
