@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap");

:root {
  --green: #00ff41;
  --yellow: #ffe600;
  --blue: #0055ff;
  --dark: #0a0a0a;
  --frame-w: min(48vw, 360px);
  --frame-h: min(64vh, 460px);
  --zoom-progress-segments: 16;
}

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

html,
body {
  background: var(--dark);
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "JetBrains Mono", monospace;
  -webkit-tap-highlight-color: transparent;
}

#mainCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  cursor: crosshair;
}

/* ── HUD ── */
.hud-logo {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 100;
  font-size: 12px;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.85);
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hud-logo .icon {
  width: 18px;
  height: 18px;
  background: conic-gradient(
    #ff0040,
    #ff8800,
    #ffe600,
    #00ff41,
    #0066ff,
    #8800ff,
    #ff0040
  );
  border-radius: 3px;
}

.hud-nav {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  gap: 2px;
  background: rgba(0, 0, 0, 0.85);
  padding: 4px 5px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hud-nav a {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
  padding: 6px 12px;
  transition: 0.25s;
  cursor: pointer;
}

.hud-nav a:hover {
  color: white;
  background: rgba(255, 255, 255, 0.06);
}

.hud-nav a.highlighted {
  color: var(--dark);
  background: var(--green);
  font-weight: 700;
}

.nav-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 110;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  font-size: 18px;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.mobile-nav {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.mobile-nav.open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-nav::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.03),
    rgba(255, 255, 255, 0.03) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.mobile-nav.open::before {
  opacity: 0.35;
  animation: scanSweep 1.2s linear infinite;
}

.mobile-nav-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: white;
  font-size: 26px;
  cursor: pointer;
}

.mobile-nav-list {
  display: flex;
  flex-direction: column;
  gap: 28px;
  text-align: center;
}

.mobile-nav-list a {
  font-size: 28px;
  color: white;
  text-decoration: none;
  font-weight: 500;
  opacity: 0;
  transform: translateY(10px);
  text-shadow: 0 0 0 rgba(255, 255, 255, 0);
}

.mobile-nav.open .mobile-nav-list a {
  opacity: 1;
  transform: translateY(0);
  animation: glitchIn 0.6s steps(2, end) both;
}

.mobile-nav.open .mobile-nav-list a:nth-child(1) {
  animation-delay: 0.05s;
}
.mobile-nav.open .mobile-nav-list a:nth-child(2) {
  animation-delay: 0.1s;
}
.mobile-nav.open .mobile-nav-list a:nth-child(3) {
  animation-delay: 0.15s;
}
.mobile-nav.open .mobile-nav-list a:nth-child(4) {
  animation-delay: 0.2s;
}
.mobile-nav.open .mobile-nav-list a:nth-child(5) {
  animation-delay: 0.25s;
}
.mobile-nav.open .mobile-nav-list a:nth-child(6) {
  animation-delay: 0.3s;
}

@keyframes scanSweep {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 0 6px;
  }
}

@keyframes glitchIn {
  0% {
    opacity: 0;
    transform: translateY(12px);
    text-shadow: 2px 0 #00ff41, -2px 0 #ff3ac9;
  }
  20% {
    opacity: 1;
    transform: translateY(0);
    text-shadow: -2px 0 #00ff41, 2px 0 #ff3ac9;
  }
  40% {
    text-shadow: 2px 0 #00ff41, -2px 0 #ff3ac9;
  }
  60% {
    text-shadow: 0 0 0 rgba(0, 0, 0, 0);
  }
  100% {
    text-shadow: 0 0 0 rgba(0, 0, 0, 0);
  }
}

@media (max-width: 768px) {
  .hud-logo {
    top: 12px;
    left: 12px;
    font-size: 10px;
    padding: 5px 10px;
  }
  .hud-logo .icon {
    width: 14px;
    height: 14px;
  }
  .hud-nav {
    display: none;
  }
  .hud-nav a {
    font-size: 9px;
    padding: 5px 8px;
  }
  .nav-toggle {
    display: inline-flex;
  }
  .mobile-nav-list a {
    font-size: 24px;
  }
}

/* ── Zoomed overlays ── */
.zoom-label {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: var(--frame-w);
  height: var(--frame-h);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.zoom-label.visible {
  opacity: 1;
}

.zoom-frame {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: var(--frame-w);
  height: var(--frame-h);
  border: 2px solid #1d3cff;
  box-shadow: 0 0 0 1px rgba(29, 60, 255, 0.35), 0 12px 30px rgba(0, 0, 0, 0.35);
  background: rgba(255, 255, 255, 0.14);
  z-index: 48;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.zoom-frame.visible {
  opacity: 1;
}

.zoom-label-tag {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateY(-100%);
  font-size: 16px;
  font-weight: 700;
  color: white;
  background: #1d3cff;
  padding: 6px 14px;
  display: inline-block;
  text-transform: lowercase;
  letter-spacing: 0.2px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
}

.zoom-label-desc {
  position: absolute;
  left: 0;
  bottom: 80px;
  transform: translateX(-50%);
  font-size: 16px;
  color: white;
  background: #ff3ac9;
  padding: 10px 14px;
  display: inline-block;
  line-height: 1.35;
  white-space: pre-line;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}

.back-btn {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 28px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s, color 0.2s, border-color 0.2s;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.back-btn:hover {
  color: var(--green);
  border-color: var(--green);
}
.back-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

.cam-indicator {
  position: fixed;
  bottom: 20px;
  left: 16px;
  z-index: 100;
  font-size: 11px;
  color: var(--green);
  background: rgba(0, 0, 0, 0.7);
  padding: 4px 10px;
  border: 1px solid rgba(0, 255, 65, 0.25);
  opacity: 0;
  transition: opacity 0.4s;
}
.cam-indicator.visible {
  opacity: 1;
}

.timestamp {
  position: absolute;
  top: 0;
  right: 0;
  transform: translateY(-100%);
  z-index: 52;
  font-size: 11px;
  color: white;
  background: #1d3cff;
  padding: 4px 10px;
  letter-spacing: 0.3px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: opacity 0.4s;
}
.timestamp.visible {
  opacity: 1;
}

.enhance-label {
  position: fixed;
  bottom: 50%;
  left: 50%;
  transform: translate(-50%, 80px);
  z-index: 60;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--green);
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 0 20px rgba(0, 255, 65, 0.4);
}

.enhance-label.visible {
  opacity: 1;
  animation: enhanceBlink 0.15s steps(1) 4;
}

.zoom-progress {
  position: fixed;
  left: calc(50% - (var(--frame-w) / 2));
  top: calc(50% + (var(--frame-h) / 2) + 12px);
  transform: none;
  z-index: 101;
  display: flex;
  gap: 3px;
  padding: 5px;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.zoom-progress.visible {
  opacity: 1;
}

.zoom-progress-segment {
  width: 14px;
  height: 28px;
  background: #3b3b3f;
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.zoom-progress-segment.active {
  background: var(--green);
  box-shadow: 0 0 10px rgba(0, 255, 65, 0.3);
}

.model-drawer-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 102;
  pointer-events: none;
}

.model-drawer {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  height: 70vh;
  background: rgba(8, 8, 10, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 -14px 30px rgba(0, 0, 0, 0.45);
  padding: 10px;
  overflow: visible;
  display: flex;
  flex-direction: column;
  transform: translateY(calc(100% + 20px));
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}

.model-drawer-content {
  height: 100%;
  overflow-y: auto;
}

.model-drawer-head {
  position: absolute;
  top: -36px;
  left: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.model-drawer-name {
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: white;
  background: rgba(8, 8, 10, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 10px;
}

.model-drawer-close {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(8, 8, 10, 0.92);
  color: white;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.model-drawer-close:hover {
  color: var(--green);
  border-color: var(--green);
}

.model-drawer.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.model-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.model-gallery img {
  width: 100%;
  height: 82px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: block;
  background: #151515;
}

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

.drag-hint {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s;
}
.drag-hint.visible {
  opacity: 1;
}

.drag-hint span {
  display: inline-block;
  animation: dragSlide 2s ease-in-out infinite;
}

@keyframes dragSlide {
  0%,
  100% {
    transform: translateX(-4px);
  }
  50% {
    transform: translateX(4px);
  }
}

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 97;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 0, 0, 0.025) 3px,
    rgba(0, 0, 0, 0.025) 4px
  );
  opacity: 0.5;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: 98;
  pointer-events: none;
  background: repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.03),
      rgba(255, 255, 255, 0.03) 1px,
      transparent 1px,
      transparent 2px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.06),
      rgba(0, 0, 0, 0.06) 1px,
      transparent 1px,
      transparent 3px
    );
  opacity: 0;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 96;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    transparent 40%,
    rgba(0, 0, 0, 0.55) 100%
  );
}

.zoomed #mainCanvas {
  filter: contrast(1.06) saturate(1.08) hue-rotate(2deg);
}

.zoomed .scanlines {
  opacity: 0.65;
  animation: scanlinesMove 0.5s linear infinite;
}

.zoomed .noise {
  opacity: 0.22;
  animation: noiseShift 0.6s steps(2, end) infinite;
}

.zoomed .vignette {
  background: radial-gradient(
    ellipse at center,
    transparent 32%,
    rgba(0, 0, 0, 0.65) 100%
  );
}

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

/* ── Debug ── */
#debugPanel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.92);
  color: var(--green);
  font-size: 11px;
  padding: 10px 16px;
  display: none;
  border-top: 1px solid rgba(0, 255, 65, 0.2);
}

#debugPanel.visible {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}

#debugPanel .debug-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#debugPanel .debug-label {
  color: rgba(255, 255, 255, 0.4);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
#debugPanel .debug-val {
  color: var(--green);
  font-weight: 500;
}
#debugPanel .debug-log {
  color: var(--yellow);
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 768px) {
  :root {
    --frame-w: min(70vw, 280px);
    --frame-h: min(70vh, 360px);
  }

  .zoom-label-tag {
    font-size: 13px;
    padding: 5px 10px;
  }
  .zoom-label-desc {
    font-size: 13px;
    padding: 8px 10px;
    display: none;
  }
  .zoom-progress {
    top: calc(50% + (var(--frame-h) / 2) + 10px);
    gap: 2px;
    padding: 4px;
  }
  .zoom-progress-segment {
    width: 10px;
    height: 20px;
  }

  .model-drawer {
    left: 8px;
    right: 8px;
    bottom: 8px;
    height: 70vh;
    padding: 8px;
  }
  .model-drawer-head {
    top: -32px;
  }
  .model-drawer-name {
    padding: 5px 9px;
    font-size: 9px;
  }
  .model-drawer-close {
    width: 24px;
    height: 24px;
    font-size: 15px;
  }
  .model-gallery {
    gap: 6px;
  }
  .model-gallery img {
    height: 62px;
  }
}
