/* Neon city inside the window. Geometry variables are set from js/city/index.js (WORLD). */

.city {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.city__sky {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 22% at 50% var(--horizon), rgba(255, 70, 190, .35), transparent 70%),
    radial-gradient(circle 22px at 57% 9%, #fff7e0 0 60%, rgba(255, 240, 200, .25) 75%, transparent),
    var(--stars) top / 100% auto no-repeat,
    linear-gradient(180deg, #04021a 0%, #120a3a 28%, #3b1260 var(--horizon), #1a0a2c calc(var(--horizon) + 1%), #0b0614 100%);
}

.city__scene {
  position: absolute;
  inset: 0;
  perspective: var(--persp);
  perspective-origin: 50% var(--horizon);
}

.city__world {
  position: absolute;
  left: 50%;
  top: var(--horizon);
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  transition: opacity .6s, transform .8s var(--ease-out);
}

.city__world > * {
  position: absolute;
  left: 0;
  top: 0;
  transform-style: preserve-3d;
}

/* ---------- Distant skyline + road ---------- */

.city__skyline {
  width: 8000px;
  height: 2000px;
  transform: translate3d(-4000px, calc(var(--cam-h) - 2000px), calc(var(--end-z) - 200px));
  background-size: 100% 100%;
  filter: saturate(1.2);
  opacity: .9;
}

/* Road + sidewalks. Ground beyond the facades comes from each building's lot. */
.city__street {
  --sh: var(--street-half);
  width: calc(var(--road-half) * 2);
  height: var(--street-len);
  transform-origin: 0 0;
  transform: translate3d(calc(-1 * var(--road-half)), var(--cam-h), var(--end-z)) rotateX(90deg);
  background:
    linear-gradient(90deg,
      #1d1a28 calc(50% - var(--sh)),
      #2c283a calc(50% - var(--sh)) calc(50% - var(--sh) + 40px),
      #4d4864 calc(50% - var(--sh) + 40px) calc(50% - var(--sh) + 44px),
      transparent calc(50% - var(--sh) + 44px) calc(50% + var(--sh) - 44px),
      #4d4864 calc(50% + var(--sh) - 44px) calc(50% + var(--sh) - 40px),
      #2c283a calc(50% + var(--sh) - 40px) calc(50% + var(--sh)),
      #1d1a28 calc(50% + var(--sh))),
    linear-gradient(0deg, #15121f 0%, #100d19 60%, #2a1240 100%);
}

/* Lane dashes on their own thin plane so walking only moves a transform (no repaint). */
.city__dashes {
  width: 6px;
  height: calc(var(--street-len) + var(--dash-gap));
  transform-origin: 0 0;
  transform: translate3d(-3px, calc(var(--cam-h) - .5px), calc(var(--end-z) - var(--dash-gap) + var(--dash-off, 0px))) rotateX(90deg);
  background: repeating-linear-gradient(180deg, rgba(255, 210, 90, .8) 0 70px, transparent 70px var(--dash-gap));
}

.city__blocks { transform-style: preserve-3d; }

/* ---------- Buildings ---------- */

.bldg {
  transform: translate3d(var(--x), var(--cam-h), var(--z));
  transform-style: preserve-3d;
  cursor: pointer;
}

/* The visible building; slides into the street like a book pulled from a shelf. */
.bldg__body {
  position: absolute;
  left: 0;
  top: 0;
  transform-style: preserve-3d;
  transition: transform .55s var(--ease-out);
  pointer-events: none;
}
.bldg--left.is-out .bldg__body { transform: translateX(52px); }
.bldg--right.is-out .bldg__body { transform: translateX(-52px); }

/* Invisible hit areas at the building's rest position (see makeBuilding). */
.bldg__hit {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}
.bldg__hit--front { width: var(--w); height: var(--h); }
.bldg__hit--facade { width: var(--d); height: var(--h); }
/* Slightly padded so thin, distant signs are easier to point at (but not so much that a nearer
   sign's box swallows the far one peeking out behind it). */
.bldg__hit--sign { width: 64px; height: calc(var(--sign-h) + 12px); }

.bldg--left .bldg__hit--front { transform: translate3d(calc(-1 * var(--w)), calc(-1 * var(--h)), 0); }
.bldg--right .bldg__hit--front { transform: translate3d(0, calc(-1 * var(--h)), 0); }
.bldg--left .bldg__hit--facade { transform: translate3d(0, calc(-1 * var(--h)), 0) rotateY(90deg); }
.bldg--right .bldg__hit--facade { transform: translate3d(0, calc(-1 * var(--h)), calc(-1 * var(--d))) rotateY(-90deg); }
.bldg--left .bldg__hit--sign { transform: translate3d(4px, calc(-1 * var(--sign-y) - 6px), -27px); }
.bldg--right .bldg__hit--sign { transform: translate3d(-68px, calc(-1 * var(--sign-y) - 6px), -27px); }

.bldg__face {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  backface-visibility: hidden;
}

/* --fade is set by js/city/walk.js as buildings pass the camera. Applied per leaf, because
   opacity on the preserve-3d building group would flatten it. */
.bldg__face,
.bldg__sign,
.bldg__lot,
.bldg__glow { opacity: var(--fade, 1); }

/* Pavement under the building and the alley behind it. */
.bldg__lot {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(var(--w) + 200px);
  height: var(--lot);
  transform-origin: 0 0;
  background: linear-gradient(90deg, #120f1a, #1b1726);
  pointer-events: none;
}
.bldg--left .bldg__lot { transform: translate3d(calc(-1 * (var(--w) + 200px)), .5px, 0) rotateX(-90deg); }
.bldg--right .bldg__lot { transform: translate3d(0, .5px, 0) rotateX(-90deg); }

/* Neon puddle on the wet street in front of the sign. */
.bldg__glow {
  position: absolute;
  left: 0;
  top: 0;
  width: 150px;
  height: 240px;
  transform-origin: 0 0;
  pointer-events: none;
}
.bldg--left .bldg__glow {
  transform: translate3d(0, -.5px, -20px) rotateX(-90deg);
  background: radial-gradient(ellipse 60% 50% at 25% 50%, color-mix(in srgb, var(--neon) 40%, transparent), transparent 70%);
}
.bldg--right .bldg__glow {
  transform: translate3d(-150px, -.5px, -20px) rotateX(-90deg);
  background: radial-gradient(ellipse 60% 50% at 75% 50%, color-mix(in srgb, var(--neon) 40%, transparent), transparent 70%);
}

/* Street-facing side of the building. */
.bldg__facade {
  width: var(--d);
  height: var(--h);
  border-top: 6px solid #2b2540;
  background:
    /* storefront glow */
    linear-gradient(0deg, color-mix(in srgb, var(--neon) 30%, #000) 0 54px, #0a0812 54px 62px, transparent 62px),
    /* neon spill around the sign */
    radial-gradient(ellipse 70% 30% at var(--spill-x) calc(100% - var(--sign-y) + var(--sign-h) / 2), color-mix(in srgb, var(--neon) 30%, transparent), transparent 70%),
    var(--tex) 0 0 / 520px auto,
    linear-gradient(180deg, #221c33, #15111f);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, .6);
  transition: filter .3s;
}

.bldg--left .bldg__facade {
  --spill-x: 6%;
  transform: translate3d(0, calc(-1 * var(--h)), 0) rotateY(90deg);
}

.bldg--right .bldg__facade {
  --spill-x: 94%;
  transform: translate3d(0, calc(-1 * var(--h)), calc(-1 * var(--d))) rotateY(-90deg);
}

/* End of the building facing the viewer; revealed as it slides out like a book. */
.bldg__front {
  width: var(--w);
  height: var(--h);
  border-top: 6px solid #241e36;
  background:
    var(--tex) 40px 0 / 520px auto,
    linear-gradient(180deg, #17121f, #0c0a12);
  filter: brightness(.6);
}

.bldg--left .bldg__front { transform: translate3d(calc(-1 * var(--w)), calc(-1 * var(--h)), 0); }
.bldg--right .bldg__front { transform: translate3d(0, calc(-1 * var(--h)), 0); }

.bldg.is-out .bldg__facade { filter: brightness(1.25); }

/* Vertical blade sign hanging off the facade, facing the viewer. */
.bldg__sign {
  position: absolute;
  left: 0;
  top: 0;
  width: 52px;
  height: var(--sign-h);
  border-radius: 8px;
  border: 2px solid var(--neon);
  background: rgba(10, 6, 18, .88);
  box-shadow:
    0 0 10px var(--neon),
    0 0 34px color-mix(in srgb, var(--neon) 60%, transparent),
    inset 0 0 14px color-mix(in srgb, var(--neon) 45%, transparent);
  display: grid;
  place-items: center;
  animation: neon-flicker 7s infinite;
}

.bldg--left .bldg__sign { transform: translate3d(10px, calc(-1 * var(--sign-y)), -28px); }
.bldg--right .bldg__sign { transform: translate3d(-62px, calc(-1 * var(--sign-y)), -28px); }

.bldg__sign-text {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: var(--font-neon);
  font-size: 27px;
  line-height: 1;
  letter-spacing: 3px;
  color: color-mix(in srgb, var(--neon) 35%, #fff);
  text-shadow: 0 0 4px var(--neon), 0 0 12px var(--neon), 0 0 26px var(--neon);
}

.bldg--github .bldg__sign { width: 60px; }

.bldg.is-out .bldg__sign { animation: none; filter: brightness(1.3); }

@keyframes neon-flicker {
  0%, 18%, 20%, 22%, 61%, 63%, 100% { filter: none; }
  19%, 21% { filter: brightness(.35); }
  62% { filter: brightness(.6); }
}

/* ---------- Street life (js/city/events.js) ---------- */

.city__overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.walker,
.car,
.cat { pointer-events: none; }

/* Pedestrians: silhouettes with a neon rim light, bottom-center anchored on the sidewalk. */
.walker {
  width: 22px;
  height: 50px;
  margin: -50px 0 0 -11px;
}

.walker svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: #07050c;
  stroke: var(--rim);
  stroke-width: .9;
  filter: drop-shadow(0 0 2px var(--rim));
  animation: walk-bob var(--step) ease-in-out infinite alternate;
}

.walker .leg,
.walker .arm { transform-box: fill-box; transform-origin: 50% 0; animation: stride var(--step) ease-in-out infinite alternate; }
.walker .leg--b,
.walker .arm--a { animation-direction: alternate-reverse; }

@keyframes walk-bob { to { transform: translateY(-1.5px); } }
@keyframes stride { from { transform: scaleY(1); } to { transform: scaleY(.82); } }

/* Cars: tiny front/back view with light beams on the road. */
.car { transform-style: preserve-3d; }

.car__body {
  position: absolute;
  left: -14px;
  top: -16px;
  width: 28px;
  height: 13px;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, var(--paint), #08070c);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 3px 3px;
}

.car__roof {
  position: absolute;
  left: 5px;
  right: 5px;
  top: -6px;
  height: 7px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, #2c3550, var(--paint));
}

.car__light {
  width: 5px;
  height: 3px;
  border-radius: 2px;
}

.car--toward .car__light { background: #fff8d8; box-shadow: 0 0 6px 2px #ffe9a0, 0 0 16px 4px rgba(255, 230, 150, .6); }
.car--away .car__light { background: #ff3040; box-shadow: 0 0 6px 2px #ff2030, 0 0 14px 3px rgba(255, 30, 50, .5); }

.car__beam {
  position: absolute;
  left: -22px;
  top: 0;
  width: 44px;
  height: 200px;
  transform-origin: 50% 0;
  transform: rotateX(90deg);
  background: radial-gradient(ellipse 60% 100% at 50% 0, rgba(255, 236, 170, .42), transparent 75%);
}
.car--away .car__beam {
  height: 60px;
  background: radial-gradient(ellipse 60% 100% at 50% 0, rgba(255, 40, 60, .35), transparent 75%);
}

/* Cat crossing the street. */
.cat {
  width: 36px;
  height: 20px;
  margin: -20px 0 0 -18px;
}
.cat svg { width: 100%; height: 100%; fill: #050308; stroke: #ffb02e; stroke-width: .5; }
.cat .tail { stroke: #050308; }
.cat--flip svg { transform: scaleX(-1); }
.cat .paw { transform-box: fill-box; transform-origin: 50% 0; animation: paw .28s ease-in-out infinite alternate; }
.cat .paw--b { animation-direction: alternate-reverse; }
@keyframes paw { from { transform: rotate(18deg); } to { transform: rotate(-18deg); } }

/* Birds fly past close to the window. */
.bird {
  position: absolute;
  aspect-ratio: 2;
  translate: -50% -50%;
}
.bird svg { width: 100%; height: 100%; fill: #0a0710; stroke: rgba(255, 150, 230, .8); stroke-width: 1; filter: drop-shadow(0 0 3px rgba(255, 90, 210, .9)); overflow: visible; }
.bird .wing { transform-box: view-box; transform-origin: 50% 53%; animation: flap .22s ease-in-out infinite alternate; }
@keyframes flap { from { transform: scaleY(1); } to { transform: scaleY(-.7); } }

.shooting-star {
  position: absolute;
  width: 90px;
  height: 2px;
  transform-origin: 100% 50%;
  background: linear-gradient(90deg, transparent, #fff);
  border-radius: 2px;
  filter: drop-shadow(0 0 4px #fff);
}

.plane {
  position: absolute;
  display: flex;
  gap: 6px;
}
.plane i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fff;
  animation: blink 1.1s steps(1) infinite;
}
.plane i:last-child { background: #ff3040; animation-delay: .55s; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- GitHub skyline view (js/city/skyline.js) ---------- */

.city__scene,
.city__overlay { transition: opacity .5s, transform .9s var(--ease-out); }

/* Street view zooms past the camera as the skyline fades in. */
.city.is-skyline .city__scene { opacity: 0; transform: scale(1.35); pointer-events: none; }
.city.is-skyline .city__overlay { opacity: 0; }

.skyline {
  position: absolute;
  inset: 0;
  z-index: 5;
  opacity: 0;
  visibility: hidden;
  transform: translateX(40px);
  transition: opacity .5s, transform .7s var(--ease-out), visibility 0s .7s;
}

.city.is-skyline .skyline {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .6s .25s, transform .8s .2s var(--ease-out), visibility 0s;
}

.skyline__sky {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 30% at 50% 88%, rgba(180, 80, 255, .35), transparent 70%),
    var(--stars) top / 100% auto no-repeat,
    linear-gradient(180deg, #04021a 0%, #160b40 45%, #3b1260 85%, #1a0a2c 100%);
}

.skyline__far {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 56px;
  height: 230px;
  background-repeat: repeat-x;
  background-size: auto 100%;
  opacity: .5;
}

.skyline__track {
  position: absolute;
  inset: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.skyline__track::-webkit-scrollbar { display: none; }

.skyline__row {
  display: flex;
  align-items: flex-end;
  gap: 54px;
  width: max-content;
  height: 100%;
  padding: 0 80px 56px;
}

.skyline__street {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 56px;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 210, 90, .8) 0 40px, transparent 40px 90px) 0 36px / 90px 4px repeat-x,
    linear-gradient(180deg, #4d4864 0 3px, #2c283a 3px 16px, #15121f 16px);
}

/* Towers */
.tower {
  position: relative;
  flex: none;
  width: var(--w);
  height: var(--h);
  border-top: 6px solid #2b2540;
  background:
    radial-gradient(ellipse 80% 22% at 50% 12%, color-mix(in srgb, var(--neon) 28%, transparent), transparent 70%),
    linear-gradient(0deg, color-mix(in srgb, var(--neon) 25%, #000) 0 40px, transparent 40px),
    var(--tex) var(--tex-x) 0 / 520px auto,
    linear-gradient(180deg, #211b33, #130f1d);
  box-shadow:
    inset -18px 0 22px -6px rgba(0, 0, 0, .65),
    inset 0 0 50px rgba(0, 0, 0, .55),
    0 0 0 1px #0c0a14;
  transform-origin: 50% 100%;
  transition: transform .45s var(--ease-spring), filter .3s;
}

.tower.is-active { transform: translateY(-8px) scale(1.04); filter: brightness(1.25); z-index: 2; }

.tower__sign {
  position: absolute;
  left: 50%;
  top: 18px;
  translate: -50% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 12px 5px;
  white-space: nowrap;
  border: 2px solid var(--neon);
  border-radius: 6px;
  background: rgba(10, 6, 18, .88);
  box-shadow: 0 0 10px var(--neon), 0 0 30px color-mix(in srgb, var(--neon) 55%, transparent), inset 0 0 12px color-mix(in srgb, var(--neon) 40%, transparent);
  animation: neon-flicker 8s infinite;
}

.tower:nth-child(2n) .tower__sign { animation-delay: -3s; }
.tower:nth-child(3n) .tower__sign { animation-delay: -5.5s; }

.tower__sign b {
  font-family: var(--font-neon);
  font-weight: 400;
  font-size: 18px;
  color: color-mix(in srgb, var(--neon) 30%, #fff);
  text-shadow: 0 0 4px var(--neon), 0 0 12px var(--neon);
}

.tower__sign small {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--neon);
}

.tower__door {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 26px;
  height: 34px;
  translate: -50% 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--neon) 60%, #fff), color-mix(in srgb, var(--neon) 40%, #000));
  box-shadow: 0 0 14px var(--neon);
}

/* Rooftop silhouettes: antenna, water tank, billboard frame. */
.tower__roof { position: absolute; bottom: calc(100% + 6px); }
.tower--roof-0 .tower__roof { left: 30%; width: 3px; height: 48px; background: #2b2540; }
.tower--roof-0 .tower__roof::after {
  content: '';
  position: absolute;
  top: -3px;
  left: -2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff3040;
  box-shadow: 0 0 8px #ff3040;
  animation: blink 1.6s steps(1) infinite;
}
.tower--roof-1 .tower__roof { right: 18%; width: 34px; height: 30px; border-radius: 6px 6px 2px 2px; background: #241e36; box-shadow: 0 14px 0 -10px #241e36; }
.tower--roof-2 .tower__roof { left: 14%; width: 60%; height: 22px; border: 3px solid #2b2540; border-bottom-width: 0; }

.skyline__back,
.skyline__nav {
  position: absolute;
  z-index: 3;
  color: var(--neon-cyan);
  border: 2px solid var(--neon-cyan);
  background: rgba(6, 10, 22, .8);
  box-shadow: 0 0 10px rgba(63, 243, 255, .6), inset 0 0 8px rgba(63, 243, 255, .35);
  text-shadow: 0 0 6px var(--neon-cyan);
  transition: background .2s;
}

.skyline__back:hover,
.skyline__nav:hover { background: rgba(63, 243, 255, .18); }

.skyline__back {
  top: 14px;
  left: 14px;
  padding: 6px 14px;
  border-radius: 999px;
  font-family: var(--font-neon);
  font-size: 17px;
}

.skyline__nav {
  top: 46%;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
}
.skyline__nav--prev { left: 12px; }
.skyline__nav--next { right: 12px; }

/* ---------- Walk controls (js/city/walk.js) ---------- */

.city { touch-action: pan-x; } /* vertical swipes walk; horizontal swipes still pan the room */

.walk {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 6;
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: opacity .4s;
}

.city.is-skyline .walk { opacity: 0; pointer-events: none; }

.walk__btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 13px;
  color: var(--neon-cyan);
  border: 2px solid var(--neon-cyan);
  background: rgba(6, 10, 22, .75);
  box-shadow: 0 0 10px rgba(63, 243, 255, .5), inset 0 0 8px rgba(63, 243, 255, .3);
  text-shadow: 0 0 6px var(--neon-cyan);
  transition: opacity .2s, background .2s;
}
.walk__btn:hover:not(:disabled) { background: rgba(63, 243, 255, .2); }
.walk__btn:disabled { opacity: .3; cursor: default; }

.walk__hint {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--neon-cyan);
  text-shadow: 0 0 6px rgba(63, 243, 255, .8);
  white-space: nowrap;
  transition: opacity .6s, width .6s;
}
.walk.is-used .walk__hint { opacity: 0; width: 0; overflow: hidden; }

/* ---------- WebGL city (js/city3d) ---------- */

.city3d { position: absolute; inset: 0; transition: opacity .5s, transform .9s var(--ease-out); }
.city3d canvas { display: block; width: 100%; height: 100%; }

/* Invisible stand-ins for keyboard focus and HUD anchoring, positioned over each projected sign. */
.city3d__proxies { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.bldg3d__sign {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
}
.bldg3d__sign:focus-visible { opacity: 1; outline: 2px solid var(--holo); outline-offset: 4px; }

.city.is-skyline .city3d { opacity: 0; transform: scale(1.35); pointer-events: none; }
.city.is-skyline .city3d__proxies { visibility: hidden; }

/* ---------- Loading: the city waits blurred and hidden behind the site loader (css/loader.css),
   then pulls into focus as it fades (.is-loading is removed in js/main.js) ---------- */

.city {
  transition: filter 1.4s var(--ease-out), opacity 1.4s var(--ease-out), transform 1.6s var(--ease-out);
}
.city.is-loading {
  filter: blur(18px) brightness(.5) saturate(1.4);
  opacity: 0;
  transform: scale(1.06);
}

@media (prefers-reduced-motion: reduce) {
  .city { transition-duration: .3s; }
  .city.is-loading { filter: none; transform: none; }
}
