/*
  =========================================
  CAR WORLD LAYER (Variant: 3d-car-world)
  Loaded AFTER style.css — reuses the base design tokens. Adds the HUD,
  sliding info cards, on-screen driving controls, help overlay and the
  "list view" accessibility fallback.
  =========================================
*/

html, body {
  height: 100%;
}
body {
  background-color: #070b15;
  overflow: hidden; /* the world fills the screen; no page scroll while driving */
}
[data-theme='light'] body {
  background-color: #7ec8e3;
}

/* The world canvas fills the viewport behind the UI */
#world {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
  touch-action: none;
}

/* Keep the navbar above the canvas; it's now a thin control bar */
.navbar { z-index: 50; }
.nav-links a { cursor: pointer; }

/* The "View as list" button in the nav */
.list-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: var(--border-radius-full);
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}
.list-toggle-btn:hover { border-color: var(--accent-primary); color: var(--accent-primary); }

/* ===================================================================
   INFO CARDS — slide in from the right when a kiosk is approached
   =================================================================== */
#cards {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}

.info-card {
  position: fixed;
  top: 50%;
  right: 1.5rem;
  transform: translate(120%, -50%);
  width: min(440px, 92vw);
  max-height: 78vh;
  overflow-y: auto;
  padding: 1.75rem;
  background: var(--card-bg);
  backdrop-filter: blur(22px) saturate(130%);
  -webkit-backdrop-filter: blur(22px) saturate(130%);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg), 0 0 50px -18px var(--accent-glow);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
  scrollbar-width: thin;
}
.info-card.active {
  transform: translate(0, -50%);
  opacity: 1;
  pointer-events: auto;
}
.info-card::-webkit-scrollbar { width: 8px; }
.info-card::-webkit-scrollbar-thumb { background: var(--scroll-bar-thumb); border-radius: 999px; }

.info-card .card-kicker {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent-primary);
  margin-bottom: 0.5rem;
}
.info-card h2 { font-size: 1.6rem; margin-bottom: 0.75rem; }
.info-card h3 { font-size: 1.15rem; margin-bottom: 0.75rem; }
.info-card p { color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 1rem; }
.info-card .about-stats { margin-top: 1.25rem; gap: 0.75rem; }
.info-card .skills-category { padding: 0; background: none; border: none; box-shadow: none; }
.info-card .skills-grid { grid-template-columns: 1fr; gap: 1.25rem; }
.info-card .project-tags { margin-bottom: 0.75rem; }
.info-card .contact-card { padding: 1rem; margin-bottom: 0.75rem; }
.info-card .form-grid { grid-template-columns: 1fr; }
.info-card .form-group-full { grid-column: span 1; }

/* ===================================================================
   HUD — help overlay, controls hint, touch d-pad
   =================================================================== */
.hud { position: fixed; z-index: 40; pointer-events: none; }

/* Help / start overlay — anchored near the top so the car + plaza
   stay visible underneath it from the very first frame */
#help-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: clamp(4.5rem, 9vh, 8rem);
  background: linear-gradient(
    to bottom,
    rgba(7, 11, 21, 0.82) 0%,
    rgba(7, 11, 21, 0.5) 42%,
    rgba(7, 11, 21, 0.08) 74%,
    rgba(7, 11, 21, 0) 100%
  );
  backdrop-filter: blur(2px);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
#help-overlay.hidden { opacity: 0; visibility: hidden; }
.help-card {
  max-width: 460px;
  text-align: center;
  padding: 2.5rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-lg);
  backdrop-filter: blur(22px);
  box-shadow: var(--shadow-lg);
}
.help-card .hero-tag { margin-bottom: 1.25rem; }
.help-card h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin-bottom: 0.5rem; }
.help-card h1 .name {
  background: var(--gradient-hero);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.help-card .hero-subtitle { justify-content: center; margin-bottom: 1rem; }
.help-card p { color: var(--text-secondary); margin-bottom: 1.5rem; }
.help-keys {
  display: flex; gap: 0.5rem; justify-content: center; margin-bottom: 1.75rem; flex-wrap: wrap;
}
.help-keys kbd {
  font-family: var(--font-heading);
  font-size: 0.85rem; font-weight: 700;
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: 0 2px 0 var(--card-border);
}

/* Persistent bottom hint */
.controls-hint {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  font-size: 0.75rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 0.45rem 1rem;
  border-radius: var(--border-radius-full);
  backdrop-filter: blur(10px);
  pointer-events: none;
}

/* Touch d-pad (mobile / no keyboard) */
.touch-controls {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 45;
  display: none;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(2, 56px);
  gap: 0.5rem;
}
.touch-controls button {
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  color: var(--text-primary);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  backdrop-filter: blur(10px);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.touch-controls button:active { background: var(--accent-glow); border-color: var(--accent-primary); }
#btn-up    { grid-column: 2; grid-row: 1; }
#btn-left  { grid-column: 1; grid-row: 2; }
#btn-down  { grid-column: 2; grid-row: 2; }
#btn-right { grid-column: 3; grid-row: 2; }

@media (pointer: coarse), (max-width: 820px) {
  .touch-controls { display: grid; }
  .controls-hint { display: none; }
  .info-card { top: auto; bottom: 0; right: 0; left: 0; width: 100%;
    max-height: 55vh; border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    transform: translateY(110%); }
  .info-card.active { transform: translateY(0); }
}

/* ===================================================================
   LIST VIEW — accessibility / recruiter / no-WebGL fallback
   =================================================================== */
.list-mode #world,
.list-mode .hud,
.list-mode #help-overlay,
.list-mode .controls-hint,
.list-mode .touch-controls,
.no-webgl #world,
.no-webgl #help-overlay,
.no-webgl .controls-hint,
.no-webgl .touch-controls {
  display: none !important;
}

body.list-mode, body.no-webgl { overflow: auto; }

/* In list / no-webgl mode the cards become a normal scrolling column */
.list-mode #cards,
.no-webgl #cards {
  position: static;
  pointer-events: auto;
  max-width: 820px;
  margin: 6rem auto 4rem;
  padding: 0 1.5rem;
}
.list-mode .info-card,
.no-webgl .info-card {
  position: static;
  transform: none;
  opacity: 1;
  width: 100%;
  max-width: 100%;
  max-height: none;
  margin: 0 0 1.5rem;
  pointer-events: auto;
}

#list-close {
  position: fixed;
  top: 1rem; right: 1.5rem;
  z-index: 70;
  display: none;
}
.list-mode #list-close { display: inline-flex; }
.no-webgl .list-toggle-btn { display: none; }

/* In list mode, free up the top-right corner for the Close button */
body.list-mode .nav-actions { display: none; }

/* Banner shown only when WebGL is unavailable */
.webgl-banner { display: none; }
.no-webgl .webgl-banner {
  display: block;
  max-width: 820px;
  margin: 6rem auto 0;
  padding: 1rem 1.5rem;
  border-radius: var(--border-radius-md);
  background: var(--accent-glow);
  border: 1px solid var(--card-border-hover);
  color: var(--text-primary);
  font-size: 0.9rem;
}
.no-webgl #cards { margin-top: 1.5rem; }
