/* ARK3005 - Glitch Aesthetic Stylesheet */
@import url('https://fonts.googleapis.cn/css2?family=Share+Tech+Mono&family=Space+Grotesk:wght@300;400;500;600;700&display=swap');

/* ===== CSS Variables ===== */
:root {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #111111;
  --text-primary: #e0e0e0;
  --text-secondary: #888888;
  --text-dim: #444444;
  --accent-red: #ff2244;
  --accent-blue: #4488ff;
  --accent-purple: #aa44ff;
  --accent-green: #22ff88;
  --accent-orange: #ff8844;
  --font-mono: 'Share Tech Mono', 'JetBrains Mono', monospace;
  --font-display: 'Space Grotesk', sans-serif;
  --scan-line-opacity: 0.03;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== Scan Lines Overlay ===== */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(255, 255, 255, var(--scan-line-opacity)) 2px,
    rgba(255, 255, 255, var(--scan-line-opacity)) 4px
  );
  pointer-events: none;
  z-index: 9999;
  animation: scanMove 8s linear infinite;
}

@keyframes scanMove {
  0% { transform: translateY(0); }
  100% { transform: translateY(4px); }
}

/* ===== Noise Overlay ===== */
body::after {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9998;
  animation: noiseShift 0.5s steps(4) infinite;
}

@keyframes noiseShift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, -2%); }
  50% { transform: translate(2%, 1%); }
  75% { transform: translate(-1%, 2%); }
  100% { transform: translate(1%, -1%); }
}

/* ===== Main Container ===== */
#app {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ===== Grid Background ===== */
.grid-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(rgba(68, 136, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(68, 136, 255, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

/* ===== Crosshair Markers ===== */
.crosshair {
  position: fixed;
  width: 20px;
  height: 20px;
  pointer-events: none;
  z-index: 100;
}

.crosshair::before,
.crosshair::after {
  content: '';
  position: absolute;
  background: var(--text-dim);
}

.crosshair::before {
  width: 1px;
  height: 100%;
  left: 50%;
  transform: translateX(-50%);
}

.crosshair::after {
  width: 100%;
  height: 1px;
  top: 50%;
  transform: translateY(-50%);
}

.crosshair-tl { top: 20px; left: 20px; }
.crosshair-tr { top: 20px; right: 20px; }
.crosshair-bl { bottom: 20px; left: 20px; }
.crosshair-br { bottom: 20px; right: 20px; }

/* ===== Header / Protocol Bar ===== */
.protocol-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 50;
  pointer-events: none;
}

.protocol-bar .left,
.protocol-bar .right {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.protocol-bar .right {
  align-items: flex-end;
}

.protocol-label {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.protocol-value {
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

.protocol-value.status-active {
  color: var(--accent-green);
}

.protocol-value.status-lost {
  color: var(--accent-red);
  animation: blink 2s ease-in-out infinite;
}

.top-link-bar {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  max-width: min(720px, calc(100vw - 280px));
  z-index: 55;
}

.top-link-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 6px 10px;
  border: 1px solid rgba(68, 136, 255, 0.18);
  color: var(--text-secondary);
  background: rgba(10, 10, 10, 0.72);
  font-size: 10px;
  letter-spacing: 1.8px;
  line-height: 1;
  text-transform: uppercase;
  text-decoration: none;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease, text-shadow 0.2s ease;
}

.top-link-chip:hover {
  color: var(--accent-blue);
  border-color: rgba(68, 136, 255, 0.55);
  background: rgba(8, 12, 18, 0.92);
  text-shadow: 0 0 8px rgba(68, 136, 255, 0.35);
}

.top-link-chip:focus-visible {
  outline: 1px solid var(--accent-blue);
  outline-offset: 2px;
}

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

/* ===== Main Content Area ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 10;
  padding: 80px 40px 120px;
}

/* ===== Location Display ===== */
.location-container {
  max-width: 980px;
  width: 100%;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  column-gap: 48px;
  align-items: start;
}

/* Glitch title effect */
.location-title {
  font-family: var(--font-display);
  font-size: clamp(36px, 6vw, 72px);
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.1;
  margin-bottom: 8px;
  position: relative;
  color: var(--text-primary);
  grid-column: 1;
}

.location-title .glitch-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
}

.location-title .glitch-layer.red {
  color: var(--accent-red);
  animation: glitchRed 3s infinite;
}

.location-title .glitch-layer.blue {
  color: var(--accent-blue);
  animation: glitchBlue 3s infinite;
}

@keyframes glitchRed {
  0%, 92%, 100% { opacity: 0; transform: translate(0); }
  93% { opacity: 0.8; transform: translate(-3px, 1px); }
  94% { opacity: 0; transform: translate(0); }
  95% { opacity: 0.6; transform: translate(2px, -1px); }
  96% { opacity: 0; }
}

@keyframes glitchBlue {
  0%, 90%, 100% { opacity: 0; transform: translate(0); }
  91% { opacity: 0.7; transform: translate(3px, -1px); }
  92% { opacity: 0; }
  93% { opacity: 0.5; transform: translate(-2px, 2px); }
  94% { opacity: 0; }
}

.location-country {
  font-size: 14px;
  color: var(--accent-blue);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 24px;
  grid-column: 1;
}

.location-desc {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 32px;
  max-width: 500px;
  grid-column: 1;
}

.location-desc .typewriter {
  border-right: 2px solid var(--accent-red);
  animation: cursorBlink 1s step-end infinite;
  padding-right: 4px;
}

@keyframes cursorBlink {
  0%, 100% { border-color: var(--accent-red); }
  50% { border-color: transparent; }
}

/* ===== Data Panel ===== */
.data-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 24px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--bg-tertiary);
  grid-column: 1 / -1;
}

.data-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.data-label {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.data-value {
  font-size: 14px;
  color: var(--text-primary);
}

.data-value.time {
  color: var(--accent-orange);
  font-size: 20px;
  font-weight: 500;
}

.data-value.coord {
  color: var(--accent-blue);
  font-size: 12px;
}

.data-value.temp {
  color: var(--accent-orange);
}

.data-value.weather {
  color: var(--accent-green);
  text-transform: capitalize;
}

/* ===== Animals & Artwork ===== */
.extra-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--bg-tertiary);
  grid-column: 1 / -1;
}

.extra-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.extra-label {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.extra-value {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.animal-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.animal-tag {
  font-size: 11px;
  color: var(--accent-green);
  border: 1px solid rgba(34, 255, 136, 0.2);
  padding: 2px 8px;
  letter-spacing: 1px;
}

.artwork-text {
  font-size: 13px;
  color: var(--accent-purple);
  font-style: italic;
}

/* ===== Waveform Visualizer ===== */
.waveform-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  z-index: 40;
  pointer-events: none;
}

.waveform-canvas {
  width: 100%;
  height: 100%;
}

/* ===== Bottom Controls ===== */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 50;
}

.bottom-bar .left-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.link-status {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 2px;
}

.link-status.active {
  color: var(--accent-green);
}

/* ===== Teleport Button ===== */
.teleport-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid var(--text-dim);
  padding: 12px 32px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  pointer-events: all;
}

.teleport-btn:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
  text-shadow: 0 0 10px rgba(255, 34, 68, 0.5);
  animation: btnGlitch 0.3s ease;
}

.teleport-btn:active {
  background: rgba(255, 34, 68, 0.1);
}

@keyframes btnGlitch {
  0% { transform: translate(0); }
  20% { transform: translate(-2px, 1px); }
  40% { transform: translate(2px, -1px); }
  60% { transform: translate(-1px, -1px); }
  80% { transform: translate(1px, 2px); }
  100% { transform: translate(0); }
}

/* ===== Sound Toggle ===== */
.sound-toggle {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--bg-tertiary);
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  pointer-events: all;
}

.sound-toggle:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.sound-toggle.active {
  border-color: var(--accent-green);
  color: var(--accent-green);
}

/* ===== Teleport Overlay ===== */
.teleport-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s;
}

.teleport-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.teleport-overlay .tear-line {
  position: absolute;
  width: 100%;
  height: 2px;
  background: var(--accent-red);
  box-shadow: 0 0 20px var(--accent-red), 0 0 60px var(--accent-purple);
  animation: tearExpand 0.6s ease-out forwards;
}

@keyframes tearExpand {
  0% { transform: scaleX(0); opacity: 1; }
  50% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0; }
}

.teleport-overlay .noise-burst {
  position: absolute;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    rgba(255, 255, 255, 0.1) 1px,
    transparent 2px,
    transparent 4px
  );
  animation: noiseBurst 0.8s ease-out forwards;
}

@keyframes noiseBurst {
  0% { opacity: 0; transform: scaleY(0); }
  30% { opacity: 1; transform: scaleY(1); }
  100% { opacity: 0; transform: scaleY(1.5); }
}

.teleport-overlay .coord-text {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent-red);
  letter-spacing: 4px;
  animation: coordFlicker 0.1s steps(2) infinite;
}

@keyframes coordFlicker {
  0% { opacity: 1; }
  50% { opacity: 0.3; }
  100% { opacity: 0.8; }
}

/* ===== Intro Screen ===== */
.intro-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 32px;
  transition: opacity 1s ease;
}

.intro-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.intro-title {
  font-family: var(--font-display);
  font-size: clamp(48px, 8vw, 96px);
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--text-primary);
  text-align: center;
}

.intro-subtitle {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 4px;
  text-transform: uppercase;
}

.intro-enter {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--text-dim);
  padding: 16px 48px;
  cursor: pointer;
  transition: all 0.3s ease;
  animation: pulse 2s ease-in-out infinite;
}

.intro-enter:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
  text-shadow: 0 0 10px rgba(255, 34, 68, 0.5);
}

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

/* ===== Side Data Nodes ===== */
.side-node {
  position: fixed;
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 1px;
  z-index: 30;
  pointer-events: none;
}

.side-node.left {
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.side-node.right {
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-end;
}

.side-node .node-label {
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.side-node .node-value {
  color: var(--text-secondary);
}

/* ===== Mini Map Panel ===== */
.mini-map-panel {
  position: relative;
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: start;
  width: 280px;
  padding: 14px 14px 12px;
  border: 1px solid rgba(68, 136, 255, 0.18);
  background:
    linear-gradient(180deg, rgba(8, 12, 18, 0.92), rgba(0, 0, 0, 0.9)),
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.02) 0px,
      rgba(255, 255, 255, 0.02) 1px,
      transparent 1px,
      transparent 3px
    );
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.02),
    0 0 30px rgba(0, 0, 0, 0.35);
  z-index: 35;
  overflow: hidden;
}

.mini-map-panel::before,
.mini-map-panel::after {
  content: '';
  position: absolute;
  pointer-events: none;
}

.mini-map-panel::before {
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(68, 136, 255, 0.08), transparent);
  transform: translateX(-100%);
  animation: miniMapSweep 6s linear infinite;
}

.mini-map-panel::after {
  top: 0;
  left: 18px;
  width: calc(100% - 36px);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-red), transparent);
  opacity: 0.45;
}

.mini-map-header,
.mini-map-readout {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mini-map-id,
.mini-map-coord {
  font-size: 11px;
  color: var(--accent-blue);
  letter-spacing: 1.5px;
}

.mini-map-frame {
  position: relative;
  width: 100%;
  height: 148px;
  margin: 12px 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background:
    linear-gradient(rgba(68, 136, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(68, 136, 255, 0.06) 1px, transparent 1px),
    radial-gradient(circle at 50% 50%, rgba(68, 136, 255, 0.08), transparent 65%);
  background-size: 24px 24px, 24px 24px, auto;
}

.mini-map-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent, rgba(255, 34, 68, 0.06), transparent),
    repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent 2px,
      rgba(255, 255, 255, 0.025) 2px,
      rgba(255, 255, 255, 0.025) 3px
    );
  pointer-events: none;
}

.mini-map-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.mini-map-landmasses path {
  fill: rgba(224, 224, 224, 0.06);
  stroke: rgba(68, 136, 255, 0.28);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.mini-map-route {
  fill: none;
  stroke: rgba(255, 34, 68, 0.68);
  stroke-width: 1.4;
  stroke-dasharray: 4 5;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 6px rgba(255, 34, 68, 0.4));
  animation: signalRoute 1.4s linear infinite;
}

.mini-map-marker {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.mini-map-marker.previous.visible,
.mini-map-marker.active {
  opacity: 1;
}

.mini-map-marker.previous circle {
  fill: rgba(170, 68, 255, 0.5);
}

.mini-map-marker.active circle:first-child {
  fill: var(--accent-blue);
  filter: drop-shadow(0 0 8px rgba(68, 136, 255, 0.85));
}

.mini-map-marker .pulse-ring {
  fill: none;
  stroke: rgba(68, 136, 255, 0.45);
  stroke-width: 1;
  transform-origin: center;
  animation: markerPulse 1.8s ease-out infinite;
}

@keyframes miniMapSweep {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(110%); }
}

@keyframes signalRoute {
  0% { stroke-dashoffset: 18; }
  100% { stroke-dashoffset: 0; }
}

@keyframes markerPulse {
  0% { opacity: 0.8; transform: scale(0.6); }
  70% { opacity: 0; transform: scale(1.35); }
  100% { opacity: 0; transform: scale(1.35); }
}

/* ===== Plus Markers ===== */
.plus-marker {
  position: fixed;
  font-size: 14px;
  color: var(--text-dim);
  z-index: 30;
  pointer-events: none;
  font-family: var(--font-mono);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .main-content {
    padding: 80px 20px 120px;
  }

  .location-container {
    max-width: 700px;
    grid-template-columns: 1fr;
    column-gap: 0;
  }

  .data-panel {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  .extra-info {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .side-node {
    display: none;
  }

  .mini-map-panel {
    grid-column: 1;
    grid-row: auto;
    width: min(280px, 100%);
    margin: 4px 0 8px;
  }

  .protocol-bar {
    padding: 12px 16px;
  }

  .top-link-bar {
    top: 60px;
    max-width: calc(100vw - 32px);
    gap: 8px;
  }

  .top-link-chip {
    font-size: 9px;
    letter-spacing: 1.4px;
  }

  .bottom-bar {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .data-panel {
    grid-template-columns: 1fr;
  }

  .location-title {
    font-size: 32px;
  }

  .mini-map-panel {
    left: 16px;
    right: 16px;
    width: auto;
  }

  .mini-map-frame {
    height: 132px;
  }
}

/* ===== Chromatic Aberration on Hover ===== */
.glitch-hover:hover {
  animation: chromaticShift 0.15s ease;
}

@keyframes chromaticShift {
  0% { text-shadow: none; }
  25% { text-shadow: -2px 0 var(--accent-red), 2px 0 var(--accent-blue); }
  50% { text-shadow: 2px 0 var(--accent-red), -2px 0 var(--accent-blue); }
  75% { text-shadow: -1px 0 var(--accent-red), 1px 0 var(--accent-blue); }
  100% { text-shadow: none; }
}

/* ===== Barcode decoration ===== */
.barcode {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 60px;
  height: 30px;
  background: repeating-linear-gradient(
    90deg,
    var(--text-dim) 0px,
    var(--text-dim) 2px,
    transparent 2px,
    transparent 4px,
    var(--text-dim) 4px,
    var(--text-dim) 5px,
    transparent 5px,
    transparent 8px
  );
  z-index: 30;
  pointer-events: none;
  opacity: 0.3;
}

/* ===== Location counter ===== */
.location-counter {
  position: fixed;
  top: 50%;
  right: 24px;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 2px;
  z-index: 30;
  pointer-events: none;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}
