/* KIX Ultra-Photorealistic WebGPU + Rust/WASM Minimal AAA HUD & Single Virtual Joystick Stylesheet */
/* Designed for >92% unobstructed viewport, WCAG AAA contrast (>= 7:1), CLS = 0, zero clutter */

:root {
  --bg-glass: rgba(8, 13, 24, 0.82);
  --bg-glass-hover: rgba(20, 34, 58, 0.94);
  --border-subtle: rgba(148, 184, 224, 0.28);
  --text-primary: #f8fafc;
  --text-muted: #cbd5e1;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --radius-pill: 999px;
  --radius-card: 12px;
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.hud-bar {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  display: none;
  align-items: center;
  gap: 8px;
}

.kix-ready .hud-bar {
  display: flex;
}

.hud-top {
  top: max(10px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  justify-content: space-between;
  flex-wrap: nowrap;
}

.top-left-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-card {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 6px;
  background: linear-gradient(135deg, #0369a1, #0284c7);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.brand-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

/* Compact Vehicle / Aircraft Status + HP Pill (replaces brand-card cleanly when driving/flying!) */
.status-pill {
  display: none;
  pointer-events: auto;
  align-items: center;
  gap: 9px;
  padding: 6px 12px;
  border-radius: var(--radius-card);
  background: var(--bg-glass);
  border: 1px solid rgba(56, 189, 248, 0.44);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-primary);
  white-space: nowrap;
}

.gta-car-mode .brand-card,
.flight-mode .brand-card {
  display: none;
}

.gta-car-mode .car-status-pill {
  display: inline-flex;
}

.flight-mode .flight-status-pill {
  display: inline-flex;
}

.st-name {
  font-weight: 700;
  color: #7dd3fc;
}

.st-chip {
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(56, 189, 248, 0.20);
  color: #e0f2fe;
  font-weight: 800;
}

.st-val {
  font-weight: 800;
  color: #ffffff;
}

.st-dim {
  color: var(--text-muted);
  font-weight: 600;
}

.hp-track {
  width: 58px;
  height: 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.22);
  overflow: hidden;
  flex-shrink: 0;
}

.hp-fill {
  width: 100%;
  height: 100%;
  background: #22c55e;
  border-radius: 999px;
  transition: width 0.14s ease, background-color 0.2s ease;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  pointer-events: auto;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 11px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: var(--bg-glass-hover);
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-ico {
  flex: 0 0 auto;
  color: #f1f5f9;
}

.gta-launch-btn {
  background: linear-gradient(135deg, #047857, #059669);
  border-color: #6ee7b7;
  color: #ffffff;
}

.gta-launch-btn:hover,
.gta-launch-btn:focus-visible {
  background: linear-gradient(135deg, #059669, #10b981);
  border-color: #ffffff;
}

.pilot-launch-btn {
  background: linear-gradient(135deg, #0369a1, #0284c7);
  border-color: #7dd3fc;
  color: #ffffff;
}

.pilot-launch-btn:hover,
.pilot-launch-btn:focus-visible {
  background: linear-gradient(135deg, #0284c7, #0ea5e9);
  border-color: #ffffff;
}

.audio-btn {
  padding-inline: 9px;
}

.audio-btn .ico-off {
  display: none;
}

.audio-btn[aria-pressed="true"] .ico-on {
  display: none;
}

.audio-btn[aria-pressed="true"] .ico-off {
  display: block;
  color: #fca5a5;
}

/* Collapsible Location, Time & Aircraft Selector Drawer (Hidden by default -> 0 screen clutter!) */
.spot-drawer {
  position: fixed;
  top: max(54px, calc(env(safe-area-inset-top) + 46px));
  right: max(12px, env(safe-area-inset-right));
  z-index: 35;
  width: min(332px, calc(100vw - 24px));
  max-height: calc(100vh - 76px);
  overflow-y: auto;
  padding: 12px;
  border-radius: 14px;
  background: rgba(8, 14, 26, 0.94);
  border: 1px solid rgba(125, 211, 252, 0.36);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  gap: 11px;
  contain: layout style;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drawer-lbl {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #7dd3fc;
}

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

.drawer-row {
  display: flex;
  gap: 5px;
}

.pill-btn,
.chip-btn {
  cursor: pointer;
  white-space: nowrap;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(148, 184, 224, 0.24);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.chip-btn {
  flex: 1;
}

.pill-btn:hover,
.pill-btn:focus-visible,
.chip-btn:hover,
.chip-btn:focus-visible {
  background: rgba(56, 189, 248, 0.24);
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.pill-btn.active,
.chip-btn.active {
  background: #0369a1;
  border-color: #7dd3fc;
  color: #ffffff;
}

.fh-select {
  width: 100%;
  background: rgba(15, 23, 42, 0.96);
  color: #f8fafc;
  border: 1px solid rgba(125, 211, 252, 0.44);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

/* Mode-specific Minimal Action Clusters (Hidden unless active -> 0ms CLS!) */
.flight-hud,
.gta-foot-hud,
.gta-car-hud {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 25;
  pointer-events: none;
  contain: layout style;
}

.flight-mode .flight-hud { display: block; }
.gta-foot-mode .gta-foot-hud { display: block; }
.gta-car-mode .gta-car-hud { display: block; }

.hide-ui .hud-bar,
.hide-ui .spot-drawer,
.hide-ui .flight-hud,
.hide-ui .gta-foot-hud,
.hide-ui .gta-car-hud,
.hide-ui #mobile-controls,
.hide-ui #rotate-overlay {
  display: none !important;
}

/* Bottom-right minimal contextual buttons */
.ctx-actions {
  pointer-events: auto;
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 28;
}

.ctx-btn {
  cursor: pointer;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1.5px solid rgba(148, 184, 224, 0.44);
  background: var(--bg-glass);
  color: #ffffff;
  font-size: 0.80rem;
  font-weight: 800;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.42);
  transition: transform 0.1s ease, background 0.14s ease, border-color 0.14s ease;
}

.ctx-btn:active {
  transform: scale(0.95);
}

.ctx-btn:hover,
.ctx-btn:focus-visible {
  background: var(--bg-glass-hover);
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ctx-board {
  background: linear-gradient(135deg, #047857, #10b981);
  border-color: #a7f3d0;
}

.ctx-repair {
  background: linear-gradient(135deg, #b45309, #f59e0b);
  border-color: #fde68a;
  color: #ffffff;
}

.ctx-exit {
  background: rgba(185, 28, 28, 0.86);
  border-color: rgba(252, 165, 165, 0.65);
}

/* Proximity Boarding Prompt (Appears ONLY when standing right next to a car or parked aircraft!) */
.gta-prompt {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(68px, calc(env(safe-area-inset-bottom) + 64px));
  transform: translateY(8px);
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px 7px 14px;
  border-radius: 999px;
  background: rgba(6, 14, 26, 0.90);
  border: 1.5px solid #34d399;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  color: #f8fafc;
  font-size: 0.80rem;
  font-weight: 700;
  white-space: nowrap;
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 29;
}

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

/* --- Unified Single Virtual Joystick (Forward / Reverse / Left / Right!) --- */
#mobile-controls {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 22;
  contain: layout style;
  pointer-events: none;
  touch-action: none;
}

/* Always visible on touch devices AND whenever walking, driving, or flying so single-joystick control works everywhere! */
#mobile-controls.touch-active,
.gta-foot-mode #mobile-controls,
.gta-car-mode #mobile-controls,
.flight-mode #mobile-controls {
  display: block;
}

@media (pointer: coarse) {
  #mobile-controls {
    display: block;
  }
}

.joy-base {
  pointer-events: auto;
  position: fixed;
  left: max(20px, env(safe-area-inset-left));
  bottom: max(20px, env(safe-area-inset-bottom));
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(15, 28, 48, 0.42), rgba(6, 12, 24, 0.68));
  border: 2px solid rgba(125, 211, 252, 0.48);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.42), inset 0 0 18px rgba(56, 189, 248, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
  cursor: grab;
}

.joy-base:active {
  cursor: grabbing;
  border-color: rgba(125, 211, 252, 0.85);
}

.joy-arrow {
  position: absolute;
  font-size: 0.56rem;
  color: rgba(186, 230, 253, 0.56);
  pointer-events: none;
  line-height: 1;
}

.joy-up { top: 8px; left: 50%; transform: translateX(-50%); }
.joy-down { bottom: 8px; left: 50%; transform: translateX(-50%); }
.joy-left { left: 9px; top: 50%; transform: translateY(-50%); }
.joy-right { right: 9px; top: 50%; transform: translateY(-50%); }

.joy-knob {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #bae6fd, #0284c7 68%, #0369a1);
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.52);
  pointer-events: none;
}

.touch-look-zone {
  pointer-events: none;
  position: fixed;
  right: 0;
  top: 52px;
  bottom: 72px;
  width: 55vw;
  touch-action: none;
}

@media (pointer: coarse) {
  .touch-look-zone {
    pointer-events: auto;
  }
}

/* --- Authentic 1st-Person Flight Deck Cockpit Frame (visible ONLY in cockpit-view!) --- */
.fh-cockpit-frame {
  display: none;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 12;
  font-family: var(--font-mono);
}

.flight-mode.cockpit-view .fh-cockpit-frame {
  display: block;
}

.cp-overhead {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 16px;
  background: linear-gradient(180deg, #090e17 0%, #162030 70%, rgba(16, 24, 36, 0) 100%);
  border-bottom: 2px solid #243247;
}

.cp-pillar-center {
  position: fixed;
  top: 14px; bottom: 112px; left: 69%;
  width: 16px;
  transform: skewX(5deg);
  transform-origin: bottom center;
  background: linear-gradient(90deg, #080c14 0%, #243044 50%, #080c14 100%);
  opacity: 0.88;
}

.cp-pillar-left,
.cp-pillar-right {
  position: fixed;
  top: 0; bottom: 0;
  width: 22px;
  background: linear-gradient(90deg, #080c14 0%, #1b2434 100%);
}

.cp-pillar-left { left: 0; transform: skewX(-4deg); transform-origin: top left; }
.cp-pillar-right { right: 0; background: linear-gradient(270deg, #080c14 0%, #1b2434 100%); transform: skewX(4deg); transform-origin: top right; }

.cp-hud-ladder {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  color: rgba(52, 211, 153, 0.82);
  font-size: 0.64rem;
  font-weight: 700;
}

.cp-lad-row { display: flex; align-items: center; gap: 10px; }
.cp-lad-row i { display: block; width: 40px; height: 2px; background: rgba(52, 211, 153, 0.78); }
.cp-lad-zero i { width: 60px; }
.cp-lad-zero b { display: block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #34d399; }

.cp-glareshield {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 116px;
  background: linear-gradient(180deg, #1b2434 0%, #0f1724 16%, #070b12 100%);
  border-top: 3px solid #334155;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 36px 0;
}

.cp-mfd {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 12px;
  border-radius: 8px;
  background: #020814;
  border: 2px solid #1e3a5f;
  min-width: 184px;
}

.cp-mfd-hdr { font-size: 0.60rem; color: #38bdf8; letter-spacing: 0.1em; }
.cp-mfd-val { font-size: 0.74rem; font-weight: 700; color: #34d399; }

.cp-mcp-strip {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: #f59e0b;
  padding: 4px 10px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(245, 158, 11, 0.42);
}

/* Auto-Fullscreen Landscape Orientation Prompt on Portrait Mobile */
.rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 60;
  contain: layout style;
  background: rgba(6, 11, 20, 0.94);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: var(--text-primary);
}

@media (pointer: coarse) and (orientation: portrait) {
  .kix-ready .rotate-overlay:not(.dismissed) { display: flex; }
}

.rotate-overlay.dismissed { display: none !important; }

.rotate-cta {
  margin-top: 18px;
  padding: 13px 26px;
  border-radius: var(--radius-pill);
  border: 2px solid #7dd3fc;
  background: #0369a1;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

/* Fallback panel */
.fallback-panel {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  contain: layout style;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #071222 0%, #0d2340 100%);
  padding: 24px;
}

.fallback-panel.visible {
  display: flex;
}

.fallback-card {
  max-width: 540px;
  padding: 28px;
  border-radius: 18px;
  background: rgba(8, 14, 26, 0.92);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

/* Ultra-Compact Mobile Landscape Tuning (Zero overlap, >93% clear 3D viewport!) */
@media (max-width: 980px), (max-height: 520px) {
  .hud-top {
    top: max(6px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
  }
  .brand-card,
  .status-pill {
    padding: 4px 9px;
    gap: 6px;
    border-radius: 9px;
    font-size: 0.70rem;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .brand-title { font-size: 0.74rem; }
  .hp-track { width: 42px; height: 6px; }
  .icon-btn {
    padding: 5px 8px;
    font-size: 0.70rem;
    border-radius: 8px;
  }
  .spot-drawer {
    top: max(40px, calc(env(safe-area-inset-top) + 36px));
    padding: 9px;
    gap: 8px;
  }
  .joy-base {
    width: 92px;
    height: 92px;
    left: max(14px, env(safe-area-inset-left));
    bottom: max(14px, env(safe-area-inset-bottom));
  }
  .joy-knob {
    width: 38px;
    height: 38px;
  }
  .ctx-actions {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    gap: 6px;
  }
  .ctx-btn {
    padding: 7px 12px;
    font-size: 0.72rem;
  }
  .gta-prompt {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(54px, calc(env(safe-area-inset-bottom) + 50px));
    padding: 5px 8px 5px 11px;
    font-size: 0.72rem;
  }
  .cp-glareshield {
    height: 70px;
    padding: 6px 14px 0;
  }
  .cp-mfd { min-width: 120px; padding: 4px 8px; }
  .cp-mcp-strip { display: none; }
}
