/* =========================================================
   DESIGN TOKENS
   ========================================================= */
:root {
  --font: 'Inter', system-ui, -apple-system, sans-serif;

  --color-bg: #0e0e0e;
  --color-surface: rgba(14, 18, 27, 0.94);
  --color-surface-light: rgba(25, 32, 45, 0.96);
  --color-border: rgba(255, 255, 255, 0.07);
  --color-border-light: rgba(255, 255, 255, 0.12);
  --color-text: #e8ecf2;
  --color-text-dim: #7d8694;
  --color-accent: #216fcf;
  --color-accent-soft: rgba(96, 165, 250, 0.12);

  --panel-w: 440px;
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-full: 50%;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 180ms var(--ease);
  --t-norm: 380ms var(--ease);
  --t-slow: 560ms var(--ease);
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* =========================================================
   CANVAS
   ========================================================= */
#canvas-container {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#canvas-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* =========================================================
   INFO CARD (hovers near building)
   ========================================================= */
.info-card {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  padding: 14px 18px 12px;
  background: var(--color-surface-light);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-md);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.3);
  transform: translate(-50%, -100%) translateY(-18px);
  transition: opacity var(--t-fast), transform var(--t-fast);
  min-width: 180px;
  text-align: center;
}

.info-card.hidden {
  opacity: 0;
  transform: translate(-50%, -100%) translateY(-10px);
}

.info-card__badge {
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  margin: 0 auto 8px;
}

.info-card__title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 3px;
  white-space: nowrap;
}

.info-card__tagline {
  font-size: 12px;
  color: var(--color-text-dim);
  white-space: nowrap;
  margin-bottom: 8px;
}

.info-card__cta {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-accent);
  letter-spacing: 0.3px;
}

/* pointer triangle */
.info-card::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: var(--color-surface-light);
  border-right: 1px solid var(--color-border-light);
  border-bottom: 1px solid var(--color-border-light);
}

/* =========================================================
   SIDE PANEL
   ========================================================= */
.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--panel-w);
  max-width: 92vw;
  height: 100%;
  z-index: 200;
  background: var(--color-surface);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-left: 1px solid var(--color-border);
  transform: translateX(100%);
  transition: transform var(--t-slow);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-shadow: -12px 0 60px rgba(0, 0, 0, 0.6);
}

.side-panel.open {
  transform: translateX(0);
}

.panel-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.06);
  transition: background var(--t-fast);
  z-index: 10;
}

.panel-close:hover {
  background: rgba(255, 255, 255, 0.14);
}

.side-panel__content {
  padding: 60px 32px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.side-panel__header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.side-panel__color-dot {
  width: 14px;
  height: 14px;
  border-radius: var(--r-full);
  flex-shrink: 0;
}

.side-panel__title {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.15;
}

.side-panel__tagline {
  font-size: 13px;
  color: var(--color-text-dim);
  margin-top: 2px;
}

.side-panel__description {
  font-size: 15px;
  line-height: 1.7;
  color: var(--color-text-dim);
}

.side-panel__divider {
  height: 1px;
  background: var(--color-border);
  margin: 4px 0;
}

.side-panel__meta {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.side-panel__meta-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--color-accent);
  display: flex;
  align-items: center;
  gap: 6px;
}

.side-panel__meta-value {
  font-size: 14px;
  color: var(--color-text-dim);
  line-height: 1.5;
}

.side-panel__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 26px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--color-accent);
  border-radius: var(--r-sm);
  transition: filter var(--t-fast), transform var(--t-fast);
  text-decoration: none;
  width: fit-content;
  margin-top: 8px;
}

.side-panel__link:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
  text-decoration: none;
}

/* =========================================================
   ABOUT MODAL
   ========================================================= */
.about-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-norm);
}

.about-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.about-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.about-modal__card {
  position: relative;
  width: 580px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-lg);
  padding: 44px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  transform: scale(0.9) translateY(30px);
  transition: transform var(--t-slow);
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.7);
}

.about-modal.open .about-modal__card {
  transform: scale(1) translateY(0);
}

.panel-close--modal {
  top: 16px;
  right: 16px;
}

/* hero */
.about-modal__hero {
  display: flex;
  align-items: center;
  gap: 20px;
}

.about-modal__avatar {
  width: 72px;
  height: 72px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  flex-shrink: 0;
  color: #fff;
}

.about-modal__name {
  font-size: 26px;
  font-weight: 800;
}

.about-modal__role {
  font-size: 14px;
  color: var(--color-text-dim);
  margin-top: 2px;
}

.about-modal__location {
  font-size: 12px;
  color: var(--color-text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.about-modal__bio {
  font-size: 15px;
  line-height: 1.7;
  color: var(--color-text-dim);
}

/* sections */
.about-modal__section h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--color-accent);
  margin-bottom: 14px;
}

.about-modal__skill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.about-modal__skill-grid span {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--color-border);
  transition: background var(--t-fast), border-color var(--t-fast);
}

.about-modal__skill-grid span:hover {
  background: var(--color-accent-soft);
  border-color: rgba(96, 165, 250, 0.3);
}

.about-modal__links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.about-modal__link-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--color-border);
  color: var(--color-text-dim);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.about-modal__link-btn:hover {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  border-color: rgba(96, 165, 250, 0.3);
  text-decoration: none;
}

/* =========================================================
   LEGEND
   ========================================================= */
.legend {
  position: fixed; bottom: 24px; left: 24px; z-index: 150;
  background: var(--color-surface);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  padding: 16px 20px; min-width: 210px;
  max-height: 50vh;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  animation: slideUp 0.7s var(--ease) 1.8s both;
}

.legend__header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--color-text-dim);
  margin-bottom: 12px;
}

.legend__list {
  list-style: none; display: flex; flex-direction: column; gap: 4px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.legend__list::-webkit-scrollbar { width: 4px; }
.legend__list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }
.legend__list::-webkit-scrollbar-track { background: transparent; }

.legend__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast);
  font-size: 13px;
  font-weight: 500;
}

.legend__item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.legend__item--construction {
  color: var(--color-text-dim);
  font-style: italic;
}

.legend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* =========================================================
   TOWN HALL TOP LEFT LEGEND
   ========================================================= */
.town-hall-legend {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--color-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--color-border);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.7s var(--ease) 1.4s both;
  user-select: none;
  cursor: pointer;
  transition: transform var(--t-fast), background var(--t-fast);
}

.town-hall-legend:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-2px);
}

/* =========================================================
   RESET BUTTON
   ========================================================= */
.reset-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 150;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  font-size: 13px;
  font-weight: 600;
  background: var(--color-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--color-border);
  border-radius: 100px;
  transition: background var(--t-fast), transform var(--t-fast);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.7s var(--ease) 1.8s both;
}

@media screen and (width < 1000px) {
  .legend {
    display: none;
  }
}

.reset-btn:hover {
  background: var(--color-surface-light);
  transform: translateY(-2px);
}

/* =========================================================
   INSTRUCTIONS TOAST
   ========================================================= */
.instructions {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 140;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: var(--color-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--color-border);
  border-radius: 100px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
  font-size: 13px;
  color: var(--color-text-dim);
  animation: toastIn 0.6s var(--ease) 2.5s both, toastOut 0.5s var(--ease) 9s forwards;
}

.instructions p {
  white-space: nowrap;
}

/* =========================================================
   LOADING SCREEN
   ========================================================= */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.7s ease, visibility 0.7s ease;
}

.loading-screen.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-screen__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.loading-screen__city-icon {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  position: relative;
  height: 56px;
}

.loading-screen__building {
  animation: buildUp 1.2s var(--ease) infinite alternate;
}

.loading-screen__building.b1 {
  width: 14px;
  background: #60a5fa;
  animation-delay: 0s;
}

.loading-screen__building.b2 {
  width: 14px;
  background: #a78bfa;
  animation-delay: 0.15s;
}

.loading-screen__building.b3 {
  width: 14px;
  background: #34d399;
  animation-delay: 0.3s;
}

.loading-screen__building.b4 {
  width: 14px;
  background: #fbbf24;
  animation-delay: 0.45s;
}

.loading-screen__ground {
  position: absolute;
  bottom: 0;
  left: -8px;
  right: -8px;
  height: 3px;
  background: var(--color-border-light);
  border-radius: 2px;
}

.loading-screen__text {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-dim);
  letter-spacing: 0.5px;
}

.dots {
  animation: dotPulse 1.5s ease-in-out infinite;
}

/* =========================================================
   KEYFRAMES
   ========================================================= */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

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

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  to {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
  }
}

@keyframes buildUp {
  0% {
    height: 10px;
  }

  100% {
    height: 48px;
  }
}

@keyframes dotPulse {

  0%,
  100% {
    opacity: 0.3;
  }

  50% {
    opacity: 1;
  }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 640px) {
  .side-panel {
    width: 100vw;
    max-width: 100vw;
  }

  .side-panel__content {
    padding: 52px 22px 28px;
  }

  .about-modal__card {
    padding: 28px;
  }

  .about-modal__links {
    grid-template-columns: 1fr;
  }

  .legend {
    bottom: 14px;
    left: 14px;
    padding: 12px 14px;
    min-width: 170px;
  }

  .town-hall-legend {
    top: 14px;
    left: 14px;
    padding: 8px 12px;
  }

  .reset-btn {
    bottom: 14px;
    right: 14px;
  }

  .instructions {
    display: none;
  }
}