/* ==========================================================================
   NYCTO — domain holding page
   Design tokens live in :root. Everything else consumes them.
   ========================================================================== */

:root {
  /* --- Surfaces --- */
  --bg-0: #050505;
  --bg-1: #080a0c;
  --bg-2: #0b0f12;
  --surface: #0d1114;
  --border: #1b2226;
  --border-soft: #151a1d;

  /* --- Text --- */
  --text-hi: #f4f4f5;
  --text-lo: #a1a1aa;
  --text-dim: #5c6268;

  /* --- Accent (used sparingly) --- */
  --accent: #5eead4;        /* icy terminal cyan-green */
  --accent-strong: #8ff5e4;
  --accent-dim: rgba(94, 234, 212, 0.12);
  --accent-glow: rgba(94, 234, 212, 0.35);
  --danger: #ff6b6b;

  /* --- Type --- */
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;

  /* --- Motion --- */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 150ms;
  --dur-med: 400ms;

  /* --- Layout --- */
  --gutter: clamp(20px, 5vw, 64px);
  --radius: 6px;
}

/* ==========================================================================
   Reset
   ========================================================================== */

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text-hi);
  overflow-x: hidden;
}

body {
  font-family: var(--font-display);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100svh;
}

h1, h2, p, dl, dd, dt, figure { margin: 0; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.mono { font-family: var(--font-mono); }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 12px;
  background: var(--accent);
  color: var(--bg-0);
  padding: 8px 14px;
  border-radius: var(--radius);
  z-index: 999;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  transition: top var(--dur-fast) var(--ease);
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ==========================================================================
   Custom cursor (desktop / mouse only — see script.js for the toggle class)
   ========================================================================== */

.cursor-dot, .cursor-ring {
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  border-radius: 50%;
  z-index: 9999;
  transform: translate(-50%, -50%);
  will-change: transform;
}

.cursor-dot {
  width: 5px; height: 5px;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}

.cursor-ring {
  width: 32px; height: 32px;
  border: 1px solid rgba(94, 234, 212, 0.5);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease), width var(--dur-fast) var(--ease), height var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

/* Only show custom cursor once JS confirms a fine pointer is in use */
.has-fine-pointer .cursor-dot,
.has-fine-pointer .cursor-ring { opacity: 1; }

.has-fine-pointer, .has-fine-pointer * { cursor: none !important; }

.cursor-ring.is-hovering {
  width: 54px; height: 54px;
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* ==========================================================================
   Background layer
   ========================================================================== */

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse 120% 80% at 50% -10%, var(--bg-2) 0%, var(--bg-0) 60%);
}

.bg-grid {
  position: absolute;
  inset: -2px;
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, black 20%, transparent 75%);
}

#bgCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.bg-scanline {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--accent-glow), transparent);
  opacity: 0.35;
  animation: scan 9s linear infinite;
}

@keyframes scan {
  0%   { top: -5%; }
  100% { top: 105%; }
}

.bg-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 90% 90% at 50% 40%, transparent 40%, rgba(0,0,0,0.6) 100%);
}

/* ==========================================================================
   Boot sequence
   ========================================================================== */

.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg-0);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  transition: opacity 500ms var(--ease), visibility 500ms var(--ease);
}

.boot.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-lines {
  font-family: var(--font-mono);
  font-size: clamp(0.8rem, 2.4vw, 1rem);
  color: var(--accent);
  min-height: 8em;
  width: min(92vw, 480px);
}

.boot-lines div {
  opacity: 0;
  transform: translateY(4px);
  animation: bootLine 400ms var(--ease) forwards;
}

@keyframes bootLine {
  to { opacity: 1; transform: translateY(0); }
}

.boot-skip {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

/* ==========================================================================
   Main content
   ========================================================================== */

.main {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 600ms var(--ease);
}

.main.is-visible { opacity: 1; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px var(--gutter);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--text-lo);
}

.topbar-item { display: flex; align-items: center; gap: 8px; }

.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
}

.dot--live {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* --- Hero --- */

.hero {
  flex: 1;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: clamp(24px, 4vw, 64px);
  align-items: center;
  padding: clamp(24px, 4vw, 48px) var(--gutter) clamp(32px, 5vw, 56px);
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

.hero-inner { min-width: 0; }

.hero-eyebrow {
  color: var(--text-lo);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  margin-bottom: 14px;
}

.hero-name {
  font-size: clamp(2rem, 5.4vw, 3.6rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--text-hi);
  margin-bottom: 28px;
}

.glitch-wrap { position: relative; display: inline-block; }

/* Rare, brief RGB-split glitch — triggered by JS toggling .is-glitching */
.glitch-wrap.is-glitching::before,
.glitch-wrap.is-glitching::after {
  content: attr(data-text);
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  overflow: hidden;
  color: var(--text-hi);
}
.glitch-wrap.is-glitching::before {
  color: var(--accent);
  transform: translate(2px, 0);
  mix-blend-mode: screen;
}
.glitch-wrap.is-glitching::after {
  color: var(--danger);
  transform: translate(-2px, 0);
  mix-blend-mode: screen;
}

.callsign {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
  border-radius: var(--radius);
  padding: 4px 2px;
}

.callsign-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.callsign-value {
  position: relative;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: clamp(1.1rem, 2.6vw, 1.5rem);
  color: var(--accent);
  text-shadow: 0 0 18px var(--accent-glow);
  letter-spacing: 0.04em;
}

.callsign-value.is-glitching {
  animation: callsignGlitch 320ms steps(2, end);
}

@keyframes callsignGlitch {
  0%   { clip-path: inset(0 0 0 0); transform: translate(0,0); }
  20%  { clip-path: inset(20% 0 40% 0); transform: translate(-2px, 1px); }
  40%  { clip-path: inset(60% 0 5% 0); transform: translate(2px, -1px); }
  60%  { clip-path: inset(10% 0 70% 0); transform: translate(-1px, 0); }
  80%  { clip-path: inset(40% 0 20% 0); transform: translate(1px, 1px); }
  100% { clip-path: inset(0 0 0 0); transform: translate(0,0); }
}

.callsign-hint {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-bottom: 34px;
  transition: opacity var(--dur-med) var(--ease);
}

/* --- Metadata table --- */

.meta {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--border-soft);
  padding-top: 20px;
  max-width: 460px;
}

.meta-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
}

.meta-row dt { color: var(--text-dim); letter-spacing: 0.04em; }

.meta-val {
  color: var(--text-lo);
  min-height: 1.2em;
}

.meta-val--accent { color: var(--accent); }

.meta-val::after {
  content: "";
}

/* ==========================================================================
   Terminal
   ========================================================================== */

.terminal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  height: clamp(320px, 46vh, 460px);
  transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.terminal-dots { display: flex; gap: 6px; }
.terminal-dots i {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--border);
  display: block;
}

.terminal-title {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-left: 4px;
}

.terminal-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-lo);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.terminal-body::-webkit-scrollbar { width: 6px; }
.terminal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.terminal-line { margin-bottom: 6px; white-space: pre-wrap; word-break: break-word; }
.terminal-line--cmd { color: var(--text-hi); }
.terminal-line--cmd::before { content: "visitor> "; color: var(--accent); }
.terminal-line .accent { color: var(--accent); }
.terminal-line .warn { color: var(--danger); }

.terminal-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
}

.terminal-prompt { color: var(--accent); font-size: 0.82rem; }

.terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-hi);
  font-size: 0.82rem;
  min-width: 0;
}

.terminal-input:focus { outline: none; }

.terminal-cursor {
  width: 8px; height: 16px;
  background: var(--accent);
  animation: blink 1s steps(1) infinite;
  flex-shrink: 0;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  display: flex;
  justify-content: space-between;
  padding: 18px var(--gutter) 28px;
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

/* ==========================================================================
   Easter-egg flash overlay (Konami code)
   ========================================================================== */

.flash-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  background: var(--accent);
  opacity: 0;
  mix-blend-mode: overlay;
}

.flash-overlay.is-flashing {
  animation: flash 260ms ease-out;
}

@keyframes flash {
  0% { opacity: 0.55; }
  100% { opacity: 0; }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .terminal { height: 380px; }
}

@media (max-width: 480px) {
  .topbar { font-size: 0.65rem; padding: 16px var(--gutter); }
  .meta-row { grid-template-columns: 108px 1fr; font-size: 0.7rem; }
  .footer { flex-direction: column; gap: 6px; }
  .terminal { height: 340px; }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .bg-scanline, .dot--live { animation: none; opacity: 0.25; }
}
