@font-face {
  font-family: 'Breton';
  src: url('../assets/fonts/Breton.woff2') format('opentype');
  font-weight: normal; font-style: normal; font-display: block;
}
@font-face {
  font-family: 'other';
  src: url('../assets/fonts/Machine.otf') format('opentype');
  font-weight: normal; font-style: normal; font-display: block;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  scrollbar-width: none;
  background: #0a0a0a;
  color: #f0f0f0;
  font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
html::-webkit-scrollbar { display: none; }

/* subtle grid */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 72px 72px;
  pointer-events: none;
  z-index: 0;
}

/* grain canvas */
#noise-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  image-rendering: pixelated;
}

/* frame corners */
.fc {
  position: fixed;
  width: 18px; height: 18px;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
}
.fc::before, .fc::after {
  content: '';
  position: absolute;
  background: rgba(255,255,255,0.3);
}
.fc::before { width: 1px; height: 100%; left: 50%; }
.fc::after  { height: 1px; width: 100%; top: 50%; }
.fc.tl { top: 2rem; left: 2rem; }
.fc.tr { top: 2rem; right: 2rem; }
.fc.bl { bottom: 5rem; left: 2rem; }
.fc.br { bottom: 5rem; right: 2rem; }

/* error label — top left */
.error-label {
  position: fixed;
  top: 3rem; left: 3rem;
  z-index: 300;
  font-family: 'Inter', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: rgba(255, 30, 0, 0.65);
  opacity: 0;
  pointer-events: none;
  user-select: none;
}

/* back button */
.back-btn {
  position: fixed;
  top: 3rem; right: 3rem;
  z-index: 300;
  text-decoration: none;
  opacity: 0;
}

/* chr-hover — same as all pages */
.chr-hover {
  display: inline-flex; gap: 0;
  cursor: pointer; text-decoration: none; color: inherit;
}
.ch-wrap { position: relative; overflow: hidden; display: inline-block; }
.ch-top, .ch-bot {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 1.1rem; font-weight: 600;
  letter-spacing: 0; text-transform: uppercase;
  line-height: 1.2;
  color: rgba(255,255,255,0.5);
  transition: transform 0.6s cubic-bezier(0.87, 0, 0.13, 1), color 0.3s ease;
  transition-delay: calc(var(--i) * 28ms);
}
.ch-bot { position: absolute; top: 100%; left: 0; }
.chr-hover:hover .ch-top { transform: translateY(-100%); }
.chr-hover:hover .ch-bot { transform: translateY(-100%); }
.chr-hover:hover .ch-top,
.chr-hover:hover .ch-bot { color: rgba(255,255,255,0.9); }

/* main scene */
.scene {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
  user-select: none;
}

/* 404 digit row */
.digits-wrap {
  display: flex;
  align-items: center;
  line-height: 1;
  gap: 0;
  position: relative;
}

/* scanlines over the digits */
.digits-wrap::after {
  content: '';
  position: absolute;
  inset: -4% -2%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.055) 2px,
    rgba(0,0,0,0.055) 3px
  );
  pointer-events: none;
  z-index: 5;
}

.digit-layer {
  position: relative;
  will-change: transform;
}

.digit-char {
  display: block;
  font-family: 'Breton', sans-serif;
  font-weight: 300;
  font-size: clamp(18vw, 27vw, 44vh);
  line-height: 0.88;
  letter-spacing: -0.03em;
  color: #f0f0f0;
  opacity: 0;
  text-shadow: 0 0 120px rgba(240,240,240,0.04);
}

/* zero container for orbit */
.zero-wrap {
  position: relative;
  display: inline-block;
}

/* orbit ring — sized by JS */
.orbit-ring {
  position: absolute;
  top: 50%; left: 50%;
  border: 1px solid rgba(255, 30, 0, 0.22);
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  /* dimensions and centering set by JS */
}

/* orbiting satellite */
.satellite {
  position: absolute;
  top: 50%; left: 50%;
  width: 9px; height: 9px;
  background: #ff1e00;
  border-radius: 50%;
  box-shadow:
    0 0 10px rgba(255, 30, 0, 1),
    0 0 24px rgba(255, 30, 0, 0.55),
    0 0 48px rgba(255, 30, 0, 0.2);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 6;
  animation: sat-pulse 2s ease-in-out infinite;
}

@keyframes sat-pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(255,30,0,1), 0 0 24px rgba(255,30,0,0.55), 0 0 48px rgba(255,30,0,0.2); }
  50%       { box-shadow: 0 0 6px rgba(255,30,0,0.8), 0 0 14px rgba(255,30,0,0.35), 0 0 30px rgba(255,30,0,0.1); }
}

/* subtitle */
.subtitle {
  margin-top: 2.4rem;
  font-family: 'Breton', sans-serif;
  font-size: clamp(0.82rem, 1.2vw, 1.05rem);
  letter-spacing: 0.005em;
  color: rgba(255,255,255,0.32);
  text-align: center;
  line-height: 1.7;
  opacity: 0;
}
.subtitle-dim {
  color: rgba(255,255,255,0.16);
  font-size: 0.9em;
}

/* HUD — bottom left */
.hud-data {
  position: fixed;
  bottom: 3.2rem; left: 3rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  opacity: 0;
  pointer-events: none;
}
.hud-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.hud-key {
  font-family: 'Inter', sans-serif;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: rgba(255,255,255,0.25);
  min-width: 3.8rem;
}
.hud-val {
  font-family: 'Inter', sans-serif;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.5);
}
.hud-val.red { color: rgba(255, 30, 0, 0.8); }

.signal-bars {
  display: flex;
  gap: 2px;
  align-items: flex-end;
}
.signal-bar {
  width: 3px;
  background: rgba(255,255,255,0.12);
  border-radius: 1px;
}
.signal-bar:nth-child(1) { height: 4px; }
.signal-bar:nth-child(2) { height: 6px; }
.signal-bar:nth-child(3) { height: 8px; }
.signal-bar:nth-child(4) { height: 10px; }
.signal-bar:nth-child(5) { height: 12px; }

/* ticker */
.ticker-wrap {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  height: 2.8rem;
  z-index: 200;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
}
.ticker-inner {
  display: flex;
  white-space: nowrap;
  animation: ticker-scroll 28s linear infinite;
}
.ticker-text {
  font-family: 'Inter', sans-serif;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: rgba(255,255,255,0.18);
  padding-right: 0;
  flex-shrink: 0;
}
@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* glitch flash overlay — triggered by JS class */
.scene.glitch-flash .digit-char {
  animation: glitch-shift 0.08s steps(1) 3;
}
@keyframes glitch-shift {
  0%   { clip-path: inset(20% 0 60% 0); transform: translateX(4px); color: #ff1e00; }
  33%  { clip-path: inset(60% 0 10% 0); transform: translateX(-3px); color: #f0f0f0; }
  66%  { clip-path: inset(5% 0 80% 0); transform: translateX(2px); color: #ff1e00; }
  100% { clip-path: inset(0 0 0 0); transform: none; color: #f0f0f0; }
}

/* responsive */
@media (max-width: 768px) {
  .error-label { top: 1.5rem; left: 1.5rem; }
  .back-btn    { top: 1.5rem; right: 1.5rem; }
  .fc.tl { top: 1rem; left: 1rem; }
  .fc.tr { top: 1rem; right: 1rem; }
  .fc.bl { bottom: 3.5rem; left: 1rem; }
  .fc.br { bottom: 3.5rem; right: 1rem; }
  .hud-data { bottom: 3.5rem; left: 1.5rem; gap: 0.25rem; }
  .ticker-wrap { height: 2.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
