/* ============================================================
   MARKET RIVALS — splash page
   Layout: one fixed stage. Candlestick canvas behind, graffiti
   marks mid-depth, logo + tagline + CTA in front, ticker tapes
   pinned to top and bottom edges like a trading floor.
   ============================================================ */

:root {
  --ink:        #17131F;   /* page ground, near-black with a violet bias */
  --ink-deep:   #0D0A12;   /* boot curtain / tape ground */
  --bone:       #F6F3EB;   /* off-white type */
  --purple:     #A12CFA;   /* electric purple */
  --lime:       #B8FF32;   /* neon lime */
  --purple-ink: #4C148A;   /* purple shadow stack */
  --mute:       rgba(246, 243, 235, 0.50);   /* lowest that keeps small text at AA contrast on --ink */
  --line:       rgba(246, 243, 235, 0.10);

  --display: 'Big Shoulders Display', 'Arial Narrow', Impact, 'Helvetica Neue', sans-serif;
  --mono:    'Space Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --tape-h: 30px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

html {
  background: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--ink);
  color: var(--bone);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.4;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--lime); color: var(--ink); }

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 4px;
}

/* ------------------------------------------------------------
   Depth layers (back to front)
   0 canvas · 1 graffiti · 2 grain · 3 stage · 4 tapes · 5 splats · 9 boot
   ------------------------------------------------------------ */

#market {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

.graffiti {
  position: fixed;
  inset: -8%;
  z-index: 1;
  pointer-events: none;
  will-change: transform;
}

.graffiti__layer {
  position: absolute;
  inset: 0;
  will-change: transform;
}

.graffiti svg {
  position: absolute;
  overflow: visible;
}

.graffiti .g-arrow {
  left: 2%;
  bottom: 4%;
  width: min(78vw, 1100px);
  height: auto;
  opacity: 0.13;
}

.graffiti .g-crown {
  left: 4%;
  top: 6%;
  width: min(34vw, 420px);
  opacity: 0.11;
}

.graffiti .g-marks {
  right: 6%;
  top: 12%;
  width: min(40vw, 520px);
  opacity: 0.16;
}

.graffiti .g-stroke {
  stroke-linecap: butt;
  stroke-linejoin: miter;
  fill: none;
}

/* Huge stencil tag along the right edge */
.stencil {
  position: fixed;
  right: calc(var(--gutter-r) - 0.1em);
  top: 50%;
  z-index: 1;
  transform: translateY(-50%) rotate(180deg);
  writing-mode: vertical-rl;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(5rem, 15vh, 11rem);
  line-height: 0.8;
  letter-spacing: 0.02em;
  color: transparent;
  -webkit-text-stroke: 1px rgba(246, 243, 235, 0.16);
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 220px 220px;
  mix-blend-mode: overlay;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(13, 10, 18, 0.75) 100%);
}

/* ------------------------------------------------------------
   Ticker tapes
   ------------------------------------------------------------ */

.tape {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 4;
  height: var(--tape-h);
  background: var(--ink-deep);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  display: flex;
  align-items: center;
}

.tape--top { top: 0; padding-top: env(safe-area-inset-top, 0px); height: calc(var(--tape-h) + env(safe-area-inset-top, 0px)); }
.tape--bottom { bottom: 0; padding-bottom: env(safe-area-inset-bottom, 0px); height: calc(var(--tape-h) + env(safe-area-inset-bottom, 0px)); }

.tape__track {
  display: flex;
  gap: 0;
  width: max-content;
  animation: tape-run var(--tape-dur, 60s) linear infinite;
  will-change: transform;
}

.tape--bottom .tape__track { animation-direction: reverse; }

.tape__item {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  padding: 0 1.6em;
  color: var(--mute);
  border-right: 1px solid var(--line);
}

.tape__sym { color: var(--bone); font-weight: 700; }
.tape__item.up .tape__chg { color: var(--lime); }
.tape__item.down .tape__chg { color: var(--purple); filter: brightness(1.35); }
.tape__item.flash .tape__chg { animation: tape-flash 0.5s steps(2) 1; }
.tape__item.brand { color: var(--lime); }
.tape__item.brand .tape__sym { color: var(--lime); }

@keyframes tape-run {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-50%, 0, 0); }
}
@keyframes tape-flash {
  0%, 100% { background: transparent; }
  50% { background: var(--bone); color: var(--ink) !important; }
}

/* ------------------------------------------------------------
   Stage
   ------------------------------------------------------------ */

.stage {
  position: relative;
  z-index: 3;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 2.6vh, 28px);
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
  padding-block: calc(var(--tape-h) + env(safe-area-inset-top, 0px) + 36px) calc(var(--tape-h) + env(safe-area-inset-bottom, 0px) + 36px);
  perspective: 1200px;
  text-align: center;
  /* The logo's paint splat reaches 22% past the logo. On phones that ran past
     the screen edge and made browsers lay the page out wider than the screen. */
  overflow: hidden;   /* fallback for Safari < 16 */
  overflow: clip;
}

/* HUD corners */
.hud {
  position: fixed;
  z-index: 4;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mute);
  line-height: 1.5;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.hud--tl { top: calc(var(--tape-h) + env(safe-area-inset-top, 0px) + 14px); left: var(--gutter-l); text-align: left; }
.hud--tr { top: calc(var(--tape-h) + env(safe-area-inset-top, 0px) + 14px); right: var(--gutter-r); text-align: right; }
.hud--bl { bottom: calc(var(--tape-h) + env(safe-area-inset-bottom, 0px) + 14px); left: var(--gutter-l); text-align: left; }
.hud--br { bottom: calc(var(--tape-h) + env(safe-area-inset-bottom, 0px) + 14px); right: var(--gutter-r); text-align: right; }

.hud strong { color: var(--bone); font-weight: 700; }

.hud__dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 0.6em;
  vertical-align: 1px;
  background: var(--purple);
  box-shadow: 0 0 0 2px var(--ink);
  animation: dot-pulse 2.2s ease-in-out infinite;
}
.hud__dot.open { background: var(--lime); }

@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ------------------------------------------------------------
   Logo
   ------------------------------------------------------------ */

.logo {
  position: relative;
  width: min(88vw, 640px, 70vh);
  aspect-ratio: 1440 / 1067;
  max-width: 100%;
  transform-style: preserve-3d;
  will-change: transform;
  flex: 0 1 auto;
  min-height: 0;
}

.logo__float {
  position: absolute;
  inset: 0;
  will-change: transform;
}

.logo__splat {
  position: absolute;
  inset: -22%;
  pointer-events: none;
  transform-origin: 50% 50%;
}

.logo__splat svg { width: 100%; height: 100%; overflow: visible; }
.logo__splat .halo { opacity: 0.32; }

.logo__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 18px 40px rgba(13, 10, 18, 0.7));
}

.logo picture { position: absolute; inset: 0; display: block; }
.logo picture img { position: static; }

/* Chromatic ghost layers, only shown while glitching */
.logo__img--r,
.logo__img--b {
  opacity: 0;
  mix-blend-mode: screen;
  filter: none;
  pointer-events: none;
}
.logo__img--r { filter: hue-rotate(-50deg) saturate(2.4) brightness(1.1); }
.logo__img--b { filter: hue-rotate(60deg) saturate(2.4) brightness(1.1); }

.logo.is-glitching .logo__img--r { animation: glitch-r 0.24s steps(1) 1; }
.logo.is-glitching .logo__img--b { animation: glitch-b 0.24s steps(1) 1; }
.logo.is-glitching picture        { animation: glitch-base 0.24s steps(1) 1; }

@keyframes glitch-r {
  0%   { opacity: .8; transform: translate(-6px, 2px);  clip-path: inset(10% 0 62% 0); }
  25%  { opacity: .8; transform: translate(5px, -1px);  clip-path: inset(48% 0 20% 0); }
  50%  { opacity: .8; transform: translate(-3px, 0);    clip-path: inset(70% 0 5% 0); }
  75%  { opacity: .8; transform: translate(7px, 1px);   clip-path: inset(22% 0 55% 0); }
  100% { opacity: 0;  transform: none;                   clip-path: none; }
}
@keyframes glitch-b {
  0%   { opacity: .8; transform: translate(6px, -2px);  clip-path: inset(55% 0 12% 0); }
  25%  { opacity: .8; transform: translate(-5px, 1px);  clip-path: inset(5% 0 70% 0); }
  50%  { opacity: .8; transform: translate(4px, 0);     clip-path: inset(30% 0 40% 0); }
  75%  { opacity: .8; transform: translate(-7px, -1px); clip-path: inset(62% 0 18% 0); }
  100% { opacity: 0;  transform: none;                   clip-path: none; }
}
@keyframes glitch-base {
  0%   { transform: translate(2px, 0); }
  25%  { transform: translate(-3px, 1px); }
  50%  { transform: translate(1px, -1px); }
  75%  { transform: translate(-2px, 0); }
  100% { transform: none; }
}

/* ------------------------------------------------------------
   Tagline
   ------------------------------------------------------------ */

.copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 1.8vh, 18px);
  max-width: 100%;
}

.tagline {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  font-size: min(clamp(2.6rem, 8.2vw, 6rem), 11vh);
  line-height: 0.88;
  letter-spacing: 0.012em;
  text-transform: uppercase;
  text-wrap: balance;
  max-width: 11.5em;
}

.tagline .w {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  padding: 0.04em 0.05em 0.08em;
  margin: 0 -0.05em;
}

.tagline .w__in {
  display: inline-block;
  will-change: transform;
}

.tagline .w--hit {
  color: var(--lime);
  padding-bottom: 0.34em;
  margin-bottom: -0.1em;
}
.tagline .w--hit .w__in { position: relative; }

.tagline .scrawl {
  position: absolute;
  left: -2%;
  bottom: -0.26em;
  width: 104%;
  height: 0.28em;
  overflow: visible;
  pointer-events: none;
}
.tagline .scrawl path {
  fill: none;
  stroke: var(--purple);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 320;
  stroke-dashoffset: 0;
}

.sub {
  margin: 0;
  font-size: clamp(0.72rem, 1.5vw, 0.95rem);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--mute);
  min-height: 1.4em;
}
.sub .sub__text { color: var(--bone); }
.sub .caret {
  display: inline-block;
  width: 0.6em;
  height: 1em;
  margin-left: 0.2em;
  vertical-align: -0.15em;
  background: var(--lime);
  animation: caret-blink 1s steps(2) infinite;
}
@keyframes caret-blink { 50% { opacity: 0; } }

/* ------------------------------------------------------------
   CTA
   ------------------------------------------------------------ */

.actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.cta {
  position: relative;
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  will-change: transform;
  touch-action: manipulation;
}

.cta__bg {
  position: absolute;
  inset: 0;
  background: var(--bone);
  overflow: hidden;
  transform: skewX(-9deg);
  box-shadow: 7px 7px 0 var(--lime), 14px 14px 0 var(--purple);
  transition: box-shadow 0.18s cubic-bezier(.2,.9,.3,1.3), transform 0.18s cubic-bezier(.2,.9,.3,1.3);
}

.cta__bg::after {
  /* diagonal paint sweep on hover */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, var(--lime) 30%, var(--lime) 44%, transparent 44%);
  transform: translateX(-130%);
  transition: transform 0.4s cubic-bezier(.7,0,.2,1);
  mix-blend-mode: multiply;
}

.cta__label {
  position: relative;
  display: block;
  padding: 0.62em 1.5em 0.56em;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  letter-spacing: 0.1em;
  line-height: 1;
  color: var(--ink);
  text-transform: uppercase;
}

.cta:hover .cta__bg,
.cta:focus-visible .cta__bg {
  box-shadow: 3px 3px 0 var(--lime), 6px 6px 0 var(--purple);
  transform: skewX(-9deg) translate(4px, 4px);
}
.cta:hover .cta__bg::after { transform: translateX(130%); }
.cta:active .cta__bg {
  box-shadow: 0 0 0 var(--lime), 0 0 0 var(--purple);
  transform: skewX(-9deg) translate(7px, 7px);
}

.cta.is-denied .cta__bg { background: var(--purple); }
.cta.is-denied .cta__label { color: var(--bone); }

.xlink {
  display: inline-flex;
  align-items: center;
  gap: 0.7em;
  color: var(--mute);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 6px 4px;
  transition: color 0.15s;
}
.xlink svg { width: 14px; height: 14px; fill: currentColor; }
.xlink span { position: relative; }
.xlink span::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -3px;
  height: 2px;
  background: var(--lime);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s cubic-bezier(.7,0,.2,1);
}
.xlink:hover { color: var(--bone); }
.xlink:hover span::after { transform: scaleX(1); }

/* ------------------------------------------------------------
   Click splats (spray paint)
   ------------------------------------------------------------ */

.splats {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}

.splat {
  position: absolute;
  width: 160px;
  height: 160px;
  margin: -80px 0 0 -80px;
  transform-origin: 50% 50%;
  animation: splat-in 0.35s cubic-bezier(.2,1.4,.3,1) both, splat-out 1.2s ease 5s forwards;
}
.splat svg { width: 100%; height: 100%; overflow: visible; transform-origin: 50% 50%; }
.splat .drip {
  transform-origin: 50% 0;
  animation: drip-run 2.6s cubic-bezier(.5,0,.9,1) forwards;
}
@keyframes splat-in {
  from { transform: scale(0.2) rotate(-12deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes splat-out { to { opacity: 0; } }
@keyframes drip-run { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* ------------------------------------------------------------
   Boot curtain
   ------------------------------------------------------------ */

.boot {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: none;
  grid-template-columns: repeat(6, 1fr);
  pointer-events: none;
}
.boot__slice {
  background: var(--ink-deep);
  transform-origin: 50% 0;
  will-change: transform;
}
.boot__log {
  position: absolute;
  left: var(--gutter-l);
  bottom: calc(var(--tape-h) + 28px);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--mute);
  line-height: 1.7;
  text-align: left;
}
.boot__log div { opacity: 0; }
.boot__log .ok { color: var(--lime); }
.boot__log .k { color: var(--bone); }

/* ------------------------------------------------------------
   Intro state: hide foreground until GSAP runs the sequence.
   The class is set by JS, so without JS everything is visible.
   ------------------------------------------------------------ */

html.intro .logo,
html.intro .tagline .w__in,
html.intro .sub,
html.intro .actions,
html.intro .hud,
html.intro .tape,
html.intro .stencil { visibility: hidden; }
html.intro .tagline .scrawl path { stroke-dashoffset: 320; }
html.intro .boot { display: grid; }
html.ready .boot { display: none; }

/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */

@media (max-width: 720px) {
  :root { --tape-h: 26px; }
  .hud--tl, .hud--bl { display: none; }
  .hud { font-size: 9.5px; }
  .stencil { display: none; }
  .graffiti .g-arrow { width: 140vw; left: -30%; bottom: 10%; }
  .graffiti .g-crown { width: 60vw; top: 4%; left: -10%; }
  .graffiti .g-marks { width: 70vw; right: -15%; top: 8%; }
  .logo { width: min(92vw, 420px, 55vh); }
  .sub { letter-spacing: 0.12em; font-size: 0.7rem; }
  .cta__bg { box-shadow: 5px 5px 0 var(--lime), 10px 10px 0 var(--purple); }
  .boot__log { font-size: 10px; }
}

@media (max-height: 640px) {
  .stage { gap: 10px; }
  .cta__label { font-size: clamp(1.2rem, 2.6vh, 1.8rem); }
}

/* Short-and-narrow fallback: let the stage scroll instead of clipping */
@media (max-height: 520px) and (max-width: 720px) {
  body { overflow: auto; }
  .stage { height: auto; min-height: 100%; }
}

/* ------------------------------------------------------------
   Reduced motion
   ------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
  .tape__track { animation: none; }
  .hud__dot, .sub .caret { animation: none; }
  html.intro .boot { display: none; }
  html.intro .logo,
  html.intro .tagline .w__in,
  html.intro .sub,
  html.intro .actions,
  html.intro .hud,
  html.intro .tape,
  html.intro .stencil { visibility: visible; }
  html.intro .tagline .scrawl path { stroke-dashoffset: 0; }
}
