@import url('https://fonts.googleapis.com/css2?family=Courier+Prime:wght@400;700&family=Instrument+Serif&family=DM+Mono:wght@300;400;500&family=Syne:wght@400;700;800&display=swap');

@font-face {
  font-family: 'Scratch';
  src: url('../assets/fonts/scratch.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #f5f4f2;
  cursor: crosshair;
}

#bgCanvas {
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

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

.content-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  mix-blend-mode: difference;
  color: #fff;
}

/* ═══ NAV ═══ */
.nav {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-end;
  padding: 28px 32px 18px 120px;
}

.nav-links {
  display: flex;
  gap: 40px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.25);
  flex: 1;
}

.nav-links a {
  color: #fff;
  text-decoration: none;
  transition: letter-spacing 0.3s, opacity 0.3s;
  display: inline-block;
}
.nav-links a:hover { letter-spacing: 0.06em; opacity: 0.7; }

.nav-links a:nth-child(1) {
  font-family: 'DM Mono', monospace;
  font-size: 15px;
  letter-spacing: 0.06em;
  transform: scaleY(2);
  transform-origin: left top;
}
.nav-links a:nth-child(2) {
  font-family: 'Instrument Serif', serif;
  font-size: 22px;
  letter-spacing: -0.01em;
  transform: scaleX(1.05);
  transform-origin: left bottom;
}
.nav-links a:nth-child(3) {
  font-family: 'Syne', sans-serif;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  transform: scaleX(0.92);
  transform-origin: left bottom;
}

/* ═══ CUBE ═══ */
.cube-area {
  position: absolute;
  top: 80px;
  right: 80px;
  z-index: 20;
}

.cube-label {
  font-family: 'Courier Prime', monospace;
  font-size: 8px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.1);
  margin-bottom: 8px;
  transition: color 0.3s;
}

.cube-container {
  width: 200px;
  height: 200px;
  perspective: 550px;
  cursor: grab;
}

.cube-wrap {
  width: 100%; height: 100%;
  position: relative;
  transform-style: preserve-3d;
}

.cube-face {
  position: absolute;
  width: 200px; height: 200px;
  border: 1px solid rgba(255,255,255,0.35);
  backface-visibility: visible;
  pointer-events: none;
}

.cube-face.front  { transform: translateZ(100px); }
.cube-face.back   { transform: rotateY(180deg) translateZ(100px); }
.cube-face.right  { transform: rotateY(90deg) translateZ(100px); }
.cube-face.left   { transform: rotateY(-90deg) translateZ(100px); }
.cube-face.top    { transform: rotateX(90deg) translateZ(100px); }
.cube-face.bottom { transform: rotateX(-90deg) translateZ(100px); }

.fi {
  padding: 16px;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  font-family: 'DM Mono', monospace;
}
.fi .fi-l { font-size: 8px; letter-spacing: 0.2em; text-transform: uppercase; color: rgba(255,255,255,0.12); margin-bottom: 6px; }
.fi .fi-t { font-family: 'Instrument Serif', serif; font-size: 18px; color: rgba(255,255,255,0.45); letter-spacing: -0.01em; margin-bottom: 4px; }
.fi .fi-m { font-size: 9px; color: rgba(255,255,255,0.18); letter-spacing: 0.06em; }

/* ═══ ROUTE VISIBILITY ═══ */
.route-sub .cube-area {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  position: absolute;
}
.route-home .cube-area {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.3s;
}

/* ═══ MAIN CONTENT ═══ */
.main-content {
  position: absolute;
  top: 170px;
  left: 120px;
  right: 320px;
  bottom: 40px;
  overflow-y: auto;
  scrollbar-width: none;
}

/* Expand main-content when cube is hidden */
.route-sub .main-content {
  right: 40px;
  top: 100px;
}
.main-content::-webkit-scrollbar { display: none; }

.sl {
  font-family: 'Courier Prime', monospace;
  font-size: 9px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sl::after { content: ''; flex: 1; height: 0.5px; background: rgba(255,255,255,0.06); }

.pr {
  display: flex;
  align-items: baseline;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255,255,255,0.025);
  cursor: pointer;
  transition: padding-left 0.3s;
  gap: 20px;
}
.pr:hover { padding-left: 12px; }

.pr-i { font-family: 'Courier Prime', monospace; font-size: 9px; color: rgba(255,255,255,0.35); width: 30px; flex-shrink: 0; }
.pr-n { font-family: 'Instrument Serif', serif; font-size: 22px; color: rgba(255,255,255,0.75); letter-spacing: -0.01em; transition: color 0.2s; flex: 1; }
.pr:hover .pr-n { color: rgba(255,255,255,0.95); }
.pr-s { font-family: 'DM Mono', monospace; font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(255,255,255,0.35); flex-shrink: 0; }
.pr-d { font-family: 'Courier Prime', monospace; font-size: 9px; color: rgba(255,255,255,0.25); flex-shrink: 0; }

.bb {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 12px 32px;
  display: flex;
  justify-content: space-between;
  font-family: 'Courier Prime', monospace;
  font-size: 8px;
  letter-spacing: 0.15em;
  color: rgba(255,255,255,0.12);
}

/* ═══ LOG WINDOW ═══ */
.log-window {
  overflow: hidden;
  position: relative;
  cursor: ns-resize;
}

.log-window .pr {
  transition: opacity 0.15s ease;
}

/* ═══ HUD CANVAS ═══ */
#hudCanvas {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: -1;
}

/* ═══ MOBILE ═══ */
@media (max-width: 768px) {
  html, body {
    overflow-y: auto;
    overflow-x: hidden;
  }

  .content-layer {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
  }

  /* Nav */
  .nav {
    position: relative;
    padding: 20px 20px 14px 20px;
  }

  .nav-links {
    gap: 24px;
  }

  .nav-links a:nth-child(1) { font-size: 13px; }
  .nav-links a:nth-child(2) { font-size: 18px; }
  .nav-links a:nth-child(3) { font-size: 15px; }

  /* Cube — centered below nav, hide instantly on route change */
  .cube-area {
    position: relative;
    top: auto;
    right: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px 8px;
    transition: none;
  }

  .cube-container {
    width: 160px;
    height: 160px;
    perspective: 450px;
  }

  .cube-face {
    width: 160px;
    height: 160px;
  }

  .cube-face.front  { transform: translateZ(80px); }
  .cube-face.back   { transform: rotateY(180deg) translateZ(80px); }
  .cube-face.right  { transform: rotateY(90deg) translateZ(80px); }
  .cube-face.left   { transform: rotateY(-90deg) translateZ(80px); }
  .cube-face.top    { transform: rotateX(90deg) translateZ(80px); }
  .cube-face.bottom { transform: rotateX(-90deg) translateZ(80px); }

  /* Main content — full width, static flow */
  .main-content,
  .route-sub .main-content {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    padding: 24px 20px 60px;
    overflow-y: visible;
  }

  .pr {
    gap: 12px;
    padding: 12px 0;
  }

  .pr-n { font-size: 18px; }

  /* Bottom bar */
  .bb {
    position: relative;
    padding: 12px 20px;
  }
}

@media (max-width: 420px) {
  .nav-links {
    gap: 16px;
  }

  .nav-links a:nth-child(1) { font-size: 11px; }
  .nav-links a:nth-child(2) { font-size: 16px; }
  .nav-links a:nth-child(3) { font-size: 13px; }

  .cube-container {
    width: 130px;
    height: 130px;
    perspective: 380px;
  }

  .cube-face {
    width: 130px;
    height: 130px;
  }

  .cube-face.front  { transform: translateZ(65px); }
  .cube-face.back   { transform: rotateY(180deg) translateZ(65px); }
  .cube-face.right  { transform: rotateY(90deg) translateZ(65px); }
  .cube-face.left   { transform: rotateY(-90deg) translateZ(65px); }
  .cube-face.top    { transform: rotateX(90deg) translateZ(65px); }
  .cube-face.bottom { transform: rotateX(-90deg) translateZ(65px); }

  .fi { padding: 10px; }
  .fi .fi-t { font-size: 14px; }

  .pr-n { font-size: 16px; }
  .pr-i { width: 24px; }
}
