/* XGVE Studios — cinematic site
 * Motion follows the brand foundation: fast, hard reveals that END STILL.
 * Diagonal wipes, red pixel-trail advance, single-pass sweeps. No bounce, no
 * glow, no continuous spin, no glitch. Red stays scarce.
 * Layout is standalone-HTML CSS (this is a showcase site, not a DS primitive).
 */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--surface-canvas);
  color: var(--content-primary);
  font-family: var(--font-body);
  overflow: hidden;                 /* single viewport, no scroll */
  -webkit-font-smoothing: antialiased;
}
#root { height: 100vh; }
a { color: inherit; text-decoration: none; }

/* ============================================================= STAGE */
.stage {
  position: relative;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: #000;
  --mo: 1;
}

/* faint vignette for cinematic depth (toggleable) */
.stage[data-vignette="on"]::after {
  content: "";
  position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background: radial-gradient(120% 120% at 50% 46%,
              transparent 52%, rgb(0 0 0 / 0.55) 100%);
}
/* film grain (toggleable) — subtle, cinematic, does not touch the mark's edges */
.stage[data-grain="on"] .grain {
  position: absolute; inset: -50%; z-index: 6; pointer-events: none;
  opacity: 0.05; mix-blend-mode: screen;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  animation: grain-shift 1.1s steps(3) infinite;
}
.stage:not([data-grain="on"]) .grain { display: none; }
.stage:not([data-grain="on"]) .grain { display: none; }
@keyframes grain-shift {
  0% { transform: translate(0,0); }
  50% { transform: translate(-2%, 1%); }
  100% { transform: translate(1%, -2%); }
}

/* cursor-follow light + ambient dust — aura, barely there at rest */
.cursor-light {
  display: none;
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(240px circle at calc(var(--mx,0.5) * 100%) calc(var(--my,0.5) * 100%),
              rgba(150,170,200,0.07), rgba(150,170,200,0.02) 40%, transparent 66%);
}
.dust {
  position: absolute; inset: -10%; z-index: 1; pointer-events: none; opacity: 0.6;
  background-image:
    radial-gradient(1.5px 1.5px at 18% 24%, rgba(255,255,255,0.22), transparent 60%),
    radial-gradient(1px 1px at 62% 16%, rgba(255,255,255,0.16), transparent 60%),
    radial-gradient(1.5px 1.5px at 82% 38%, rgba(255,255,255,0.18), transparent 60%),
    radial-gradient(1px 1px at 33% 58%, rgba(255,255,255,0.14), transparent 60%),
    radial-gradient(1.5px 1.5px at 74% 66%, rgba(255,255,255,0.16), transparent 60%),
    radial-gradient(1px 1px at 12% 78%, rgba(255,255,255,0.12), transparent 60%),
    radial-gradient(1.5px 1.5px at 52% 86%, rgba(255,255,255,0.15), transparent 60%),
    radial-gradient(1px 1px at 90% 82%, rgba(255,255,255,0.12), transparent 60%);
  animation: dust-drift 46s linear infinite;
}
@keyframes dust-drift { from { transform: translate3d(0,0,0); } to { transform: translate3d(-14px,-30px,0); } }

/* ascii mask column (left) + fire glyph stream (off emblem left edge) */
.mask-col {
  position: absolute; left: clamp(24px, 7vw, 120px); top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; gap: clamp(4px, 1.2vh, 18px);
  z-index: 2; pointer-events: none;
  opacity: 0; animation: layer-in 1s ease-out 1.5s forwards;
}
.stage.phase-idle .mask-col { opacity: 0.95; }
.mask-cell { position: relative; }
.mask-cell canvas { display: block; }

.fire-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 1; pointer-events: none;
  opacity: 0; animation: layer-in 1.2s ease-out 1.5s forwards;
}
.stage.phase-idle .fire-canvas { opacity: 1; }
@keyframes layer-in { to { opacity: 1; } }

@media (max-width: 900px) { .mask-col { display: none; } }

/* cursor glyph trail (follows the mouse) */
.ascii-trail { position: absolute; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; }
.ascii-trail .tglyph {
  position: absolute; transform: translate(-50%,-50%);
  font-family: var(--font-mono, "IBM Plex Mono", monospace); font-weight: 500; line-height: 1;
  text-shadow: 0 0 6px rgba(200,215,235,0.30); will-change: transform, opacity;
}

.stage-inner {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  z-index: 2;
}

/* screen-wide geometric ASCII field (background art) */
.ascii-field {
  position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: 0.9;
  -webkit-mask-image: radial-gradient(120% 120% at 50% 50%, #000 86%, transparent 100%);
  mask-image: radial-gradient(120% 120% at 50% 50%, #000 86%, transparent 100%);
}
.foxglove-ghost { position: absolute; inset: 0; z-index: 1; pointer-events: none; }

/* retro window entrance + close hover */
@keyframes xgwin-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
.xgwin-close:hover { background: #e6202e !important; border-color: #e6202e !important; }
.xgwl-btn { transition: border-color .18s ease, color .18s ease; }
.xgwl-btn:hover { border-color: #e6202e; color: #fff; }
.hud .corner.tr .pp-btn { display: inline-flex; align-items: center; justify-content: center; }
.hud .corner.tr .pp-btn::after { display: none; }

/* corner links pop over the busy ASCII field */
.hud .corner .navlink, .hud .corner.br a {
  color: #fff; font-weight: 600; font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase;
}
.hud .corner .navlink, .hud .corner.br a {
  background: rgba(8,8,10,0.45); border: 1px solid transparent; padding: 7px 13px;
  transition: border-color .2s ease, color .2s ease, background .2s ease;
}
.hud .corner.tr .navlink:hover, .hud .corner.br a:hover { border-color: #e6202e; background: rgba(216,32,46,0.16); }
.hud .corner.br a { text-decoration: none; }

/* top-left lockup: mini metallic emblem beside the wordmark (static — no rev/pulse/sheen) */
.hud .corner.tl { gap: 3px; }
.tl-mini { position: relative; height: 62px; aspect-ratio: 524 / 425; flex: none; filter: drop-shadow(0 0 12px rgba(0,0,0,0.6)); }
.tl-wordmark { position: relative; top: 5px; }
.tl-mini .rl-px { box-shadow: 0 0 2px rgba(230,2,27,0.45); }

/* emblem: half ASCII (left) / half metallic (right) */
.emblem-split { position: relative; width: clamp(420px, 96vh, 1040px); aspect-ratio: 524 / 425; }
.es-metal { position: absolute; inset: 0; clip-path: inset(0 0 0 49.6%); }
.emblem-split .rl-emblem { width: 100% !important; }
.es-ascii { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
.es-seam {
  position: absolute; left: 50%; top: 7%; bottom: 7%; width: 1.5px; transform: translateX(-50%); z-index: 3;
  background: linear-gradient(to bottom, transparent, rgba(255,42,56,0.85) 18%, rgba(255,42,56,0.85) 82%, transparent);
  box-shadow: 0 0 8px rgba(255,42,56,0.55); pointer-events: none;
}

/* ---- entrance sequence ---- */
.ascii-field { animation: field-in 1.3s ease-out both; }
@keyframes field-in { from { opacity: 0; } to { opacity: 0.9; } }
.es-metal { animation: metal-in 1.3s ease-out 1.6s both; }
@keyframes metal-in { from { opacity: 0; filter: blur(9px); } to { opacity: 1; filter: none; } }
.es-seam { animation: seam-in 0.8s ease-out 2.1s both; }
@keyframes seam-in { from { opacity: 0; } to { opacity: 1; } }

/* focus visibility */
.hud .navlink:focus-visible, .hud .corner.br a:focus-visible { outline: 1px solid #e6202e; outline-offset: 3px; }

/* grouped action cluster (bottom-right) + copyright (bottom-left) */
.hud .corner.br { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.hud .corner.bl { position: absolute; bottom: 24px; left: 30px; }

/* reduced motion: no decorative loops */
@media (prefers-reduced-motion: reduce) {
  .stage[data-grain="on"] .grain { animation: none !important; }
  .ascii-field, .es-metal, .es-seam { animation: none !important; }
  .ascii-field { opacity: 0.9 !important; }
}

/* mobile pass */
@media (max-width: 760px) {
  .foxglove-ghost { display: none; }
  .emblem-split { width: 86vw !important; }
  .rl-tagline { white-space: normal !important; text-align: center; }
  .hud .corner.br .navlink, .hud .corner.br a { font-size: 11px; padding: 6px 10px; }
}

/* decorative broken visor ring behind the mark (documented motif) */
.ring-motif {
  position: absolute;
  top: 50%; left: 50%;
  width: min(78vh, 62vw); aspect-ratio: 1;
  translate: -50% -52%;
  border-radius: 50%;
  background: conic-gradient(from -18deg,
      var(--accent) 0deg 22deg,
      transparent 22deg 52deg,
      var(--xg-n-6) 52deg 300deg,
      transparent 300deg 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 calc(100% - 1.5px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 calc(100% - 1.5px));
  opacity: 0.16;
  z-index: 1;
  pointer-events: none;
}

/* =========================================================== LOCKUP */
.lockup {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 2.4vh, 26px);
  z-index: 3;
  will-change: transform, clip-path, opacity;
}
.lockup--stacked   { flex-direction: column; }
.lockup--emblem    { flex-direction: column; gap: clamp(20px, 3.2vh, 40px); }
.lockup--horizontal{ flex-direction: row; gap: clamp(20px, 2.4vw, 40px); }

.emblem { display: block; height: auto; width: auto; }
.wordmark { display: block; height: auto; width: auto; }

/* sizes per lockup */
.lockup--stacked .emblem    { height: clamp(96px, 17vh, 168px); }
.lockup--stacked .wordmark  { width: clamp(230px, 30vw, 470px); }

.lockup--emblem .emblem     { height: clamp(150px, 30vh, 300px); }
.lockup--emblem .wordmark   { width: clamp(150px, 18vw, 280px); }

.lockup--horizontal .emblem { height: clamp(90px, 15vh, 150px); }
.lockup--horizontal .wordmark { width: clamp(220px, 26vw, 420px); }

.lockup--wordmark .emblem   { display: none; }
.lockup--wordmark .wordmark { width: clamp(300px, 46vw, 760px); }

/* Mono treatment — strip red, pure white structure (red only in tagline dot) */
.lockup--mono .emblem   { filter: brightness(0) invert(1); }
.lockup--mono .wordmark { filter: brightness(0) invert(1); }

/* =========================================================== TAGLINE */
.tagline-wrap {
  position: absolute;
  left: 50%; translate: -50%;
  top: calc(50% + clamp(150px, 26vh, 260px));
  text-align: center;
  z-index: 3;
}
.tagline {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--weight-medium);
  font-size: clamp(15px, 1.7vw, 24px);
  letter-spacing: var(--tracking-tight);
  color: var(--content-secondary);
  white-space: nowrap;
}
.tagline .dot { color: var(--accent); }
/* bolder accent beat: a scarce red rule under the tagline */
.stage[data-accent="bolder"] .tagline { color: var(--content-primary); }
.stage[data-accent="bolder"] .tagline-wrap::after {
  content: ""; display: block; height: 2px; width: 34px; margin: 14px auto 0;
  background: var(--accent);
}

/* red pixel-trail motif (used by the "pixel" intro; sits near emblem) */
.pixels { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.px {
  position: absolute;
  background: var(--accent);
  opacity: 0;
}

/* =============================================================== HUD */
.hud { position: absolute; inset: 0; z-index: 7; pointer-events: none; }
.hud .corner {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--content-muted);
  display: flex; align-items: center; gap: 8px;
}
.hud .tl { top: 26px; left: 30px; }
.hud .tr { top: 22px; right: 30px; pointer-events: auto; gap: 22px; }
.hud .bl { bottom: 24px; left: 30px; }
.hud .br { bottom: 24px; right: 30px; pointer-events: auto; }

.hud .navlink {
  pointer-events: auto;
  color: var(--content-secondary);
  position: relative;
  transition: color var(--dur-fast) var(--ease-out);
  cursor: pointer;
  background: none; border: 0; padding: 0;
  font: inherit; letter-spacing: inherit; text-transform: inherit;
}
.hud .navlink::after {
  content: ""; position: absolute; left: 0; right: 100%; bottom: -6px;
  height: 1.5px; background: var(--accent);
  transition: right var(--dur-base) var(--ease-out);
}
.hud .navlink:hover { color: var(--content-primary); }
.hud .navlink:hover::after { right: 0; }

.hud .status-dot {
  width: 7px; height: 7px; background: var(--accent);
  display: inline-block;
}
.hud .br a:hover { color: var(--content-primary); }

/* HUD enters last, after the mark settles */
.phase-intro .hud .corner { opacity: 0; }
.phase-idle  .hud .corner {
  opacity: 1;
  animation: hud-in var(--dur-slow) var(--ease-out) both;
}

@keyframes hud-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ============================================================ INTROS
 * Rest state == base styles (visible). During .phase-intro each engine
 * animates FROM hidden TO the rest state, then the class is removed.
 * All durations scale with --mo.
 */
.phase-intro .lockup,
.phase-intro .tagline-wrap { }

/* ---- 1. DIAGONAL WIPE ------------------------------------------------ */
.intro--wipe .lockup {
  animation: wipe-reveal calc(0.9s * var(--mo)) var(--ease-enter) both;
}
.intro--wipe .wipe-bar {
  position: absolute; top: -20%; height: 140%; width: 40px;
  left: 50%; z-index: 8;
  background: var(--accent);
  transform: skewX(-18deg);
  opacity: 0;
  animation: wipe-bar calc(1.05s * var(--mo)) var(--ease-in-out) both;
  pointer-events: none;
}
.intro--wipe .tagline-wrap {
  animation: fade-up calc(0.5s * var(--mo)) var(--ease-out) calc(0.85s * var(--mo)) both;
}
@keyframes wipe-reveal {
  from { clip-path: polygon(0 0, 0 0, -35% 100%, -35% 100%); }
  to   { clip-path: polygon(0 0, 135% 0, 100% 100%, 0 100%); }
}
@keyframes wipe-bar {
  0%   { left: -12%; opacity: 0; }
  22%  { opacity: 1; }
  78%  { opacity: 1; }
  100% { left: 112%; opacity: 0; }
}

/* ---- 2. PIXEL ASSEMBLE ---------------------------------------------- */
.intro--pixel .emblem {
  animation: snap-in calc(0.6s * var(--mo)) var(--ease-enter) calc(0.45s * var(--mo)) both;
}
.intro--pixel .wordmark {
  animation: rise-clip calc(0.7s * var(--mo)) var(--ease-enter) calc(0.62s * var(--mo)) both;
}
.intro--pixel .px {
  animation: pixel-advance calc(0.5s * var(--mo)) var(--ease-accel) both;
}
.intro--pixel .px:nth-child(1) { animation-delay: calc(0.02s * var(--mo)); }
.intro--pixel .px:nth-child(2) { animation-delay: calc(0.10s * var(--mo)); }
.intro--pixel .px:nth-child(3) { animation-delay: calc(0.18s * var(--mo)); }
.intro--pixel .px:nth-child(4) { animation-delay: calc(0.26s * var(--mo)); }
.intro--pixel .tagline-wrap {
  animation: fade-up calc(0.5s * var(--mo)) var(--ease-out) calc(1.05s * var(--mo)) both;
}
@keyframes pixel-advance {
  0%   { opacity: 0; transform: translate(calc(-40px * var(--mo)), calc(40px * var(--mo))) scale(0.4); }
  55%  { opacity: 1; }
  100% { opacity: 1; transform: translate(0,0) scale(1); }
}
@keyframes snap-in {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes rise-clip {
  from { opacity: 0; transform: translateY(22px); clip-path: inset(0 0 100% 0); }
  to   { opacity: 1; transform: none; clip-path: inset(0 0 0% 0); }
}

/* ---- 3. RING SWEEP -------------------------------------------------- */
.intro--sweep .sweep-arc {
  position: absolute; top: 50%; left: 50%;
  width: min(80vh, 64vw); aspect-ratio: 1;
  translate: -50% -52%;
  border-radius: 50%;
  background: conic-gradient(from -90deg, var(--accent) 0deg 8deg, transparent 8deg 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
  z-index: 4; pointer-events: none;
  animation: sweep-once calc(1.05s * var(--mo)) var(--ease-in-out) both;
}
.intro--sweep .lockup {
  animation: fade-scale calc(0.7s * var(--mo)) var(--ease-out) calc(0.55s * var(--mo)) both;
}
.intro--sweep .tagline-wrap {
  animation: fade-up calc(0.5s * var(--mo)) var(--ease-out) calc(1.1s * var(--mo)) both;
}
@keyframes sweep-once {
  0%   { transform: rotate(-95deg); opacity: 0; }
  12%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { transform: rotate(272deg); opacity: 0; }
}
@keyframes fade-scale {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---- 4. PUSH-THROUGH ----------------------------------------------- */
.intro--push .lockup {
  animation: push-through calc(1.1s * var(--mo)) var(--ease-enter) both;
}
.intro--push .wordmark {
  animation: push-word calc(0.8s * var(--mo)) var(--ease-out) calc(0.4s * var(--mo)) both;
}
.intro--push .tagline-wrap {
  animation: fade-up calc(0.5s * var(--mo)) var(--ease-out) calc(0.95s * var(--mo)) both;
}
@keyframes push-through {
  from { opacity: 0; transform: scale(1.7); }
  60%  { opacity: 1; }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes push-word {
  from { opacity: 0; transform: scale(1.12); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---- 5. SCAN BUILD ------------------------------------------------- */
.intro--scan .lockup {
  animation: scan-clip calc(1.0s * var(--mo)) var(--ease-in-out) both;
}
.intro--scan .scanline {
  position: absolute; left: 0; right: 0; height: 2px;
  background: var(--accent);
  box-shadow: 0 0 0 0 transparent;
  z-index: 8; pointer-events: none; opacity: 0;
  animation: scan-move calc(1.0s * var(--mo)) var(--ease-in-out) both;
}
.intro--scan .tagline-wrap {
  animation: fade-up calc(0.5s * var(--mo)) var(--ease-out) calc(1.0s * var(--mo)) both;
}
@keyframes scan-clip {
  from { clip-path: inset(0 0 100% 0); }
  to   { clip-path: inset(0 0 0% 0); }
}
@keyframes scan-move {
  0%   { top: 30%; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { top: 72%; opacity: 0; }
}

/* shared */
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============================================================== WORK */
.work {
  position: absolute; inset: 0; z-index: 20;
  background: var(--surface-canvas);
  display: flex; flex-direction: column;
  padding: clamp(30px, 6vh, 68px) clamp(30px, 7vw, 110px);
  animation: work-in var(--dur-slow) var(--ease-enter) both;
}
@keyframes work-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.work-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: clamp(20px, 4vh, 46px); }
.work-eyebrow {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: var(--tracking-widest);
  text-transform: uppercase; color: var(--content-muted);
}
.work-eyebrow b { color: var(--accent); font-weight: 500; }

.work-list { display: flex; flex-direction: column; border-top: 1px solid var(--border-subtle); }
.work-row {
  display: grid;
  grid-template-columns: 62px 1fr auto auto;
  align-items: center;
  gap: clamp(16px, 3vw, 48px);
  padding: clamp(16px, 2.6vh, 30px) 6px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: default;
  transition: padding-left var(--dur-base) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.work-row:hover { padding-left: 20px; background: var(--surface-hover); }
.work-idx { font-family: var(--font-mono); font-size: 13px; color: var(--content-muted); transition: color var(--dur-fast) var(--ease-out); }
.work-row:hover .work-idx { color: var(--accent); }
.work-name {
  font-family: var(--font-display); font-weight: var(--weight-semibold);
  font-size: clamp(24px, 4.2vw, 52px); letter-spacing: var(--tracking-tight);
  line-height: 1; color: var(--content-primary);
  display: flex; align-items: center; gap: 18px;
}
.work-name .arrow { color: var(--accent); opacity: 0; transform: translateX(-8px); transition: all var(--dur-base) var(--ease-out); font-weight: 400; }
.work-row:hover .work-name .arrow { opacity: 1; transform: none; }
.work-type { font-family: var(--font-mono); font-size: 11px; letter-spacing: var(--tracking-wider); text-transform: uppercase; color: var(--content-secondary); }
.work-year { font-family: var(--font-mono); font-size: 12px; color: var(--content-muted); }
.work-note { margin-top: auto; padding-top: 22px; font-family: var(--font-mono); font-size: 11px; letter-spacing: var(--tracking-wide); color: var(--content-faint); }

/* ======================================================= REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
  .stage-inner *, .work { animation-duration: 0.001ms !important; animation-delay: 0ms !important; }
  .stage[data-grain="on"] .grain { display: none; }
  .dust { animation: none !important; }
}
