/*
 * Valley Trail game CSS.
 * Sits on top of 98.css (or whichever theme is linked) and only styles the
 * things 98.css does not: layout, HUD, map, cards, modals, toasts.
 */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--vt-black);
  font-family: var(--vt-font-ui);
  font-size: var(--vt-text-sm);
  color: var(--vt-fg);
  image-rendering: pixelated;
}

body.vt-dragging {
  cursor: grabbing;
  user-select: none;
}

#vt-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* ================================================================== */
/* HUD                                                                 */
/* ================================================================== */

.vt-hud {
  flex: 0 0 auto;
  min-height: var(--vt-hud-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--vt-space-4);
  padding: var(--vt-space-2) var(--vt-space-3);
  background: var(--vt-hud-bg);
  color: var(--vt-hud-fg);
  border-bottom: var(--vt-border-hard);
  font-family: var(--vt-font-body);
  font-size: var(--vt-text-sm);
  flex-wrap: wrap;
}

.vt-hud-group {
  display: flex;
  align-items: center;
  gap: var(--vt-space-3);
}

.vt-hud-right {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.vt-hud-day {
  font-family: var(--vt-font-display);
  font-size: var(--vt-text-xl);
  color: var(--vt-gold);
  letter-spacing: 0.5px;
}

.vt-hud-route {
  max-width: 14ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vt-hud-control,
.vt-hud select {
  font-family: var(--vt-font-body);
  font-size: var(--vt-text-xs);
  color: var(--vt-hud-fg);
}

.vt-hud select {
  color: var(--vt-fg);
}

.vt-hud button {
  font-family: var(--vt-font-body);
  font-size: var(--vt-text-xs);
  min-width: 28px;
}

.vt-speed {
  display: inline-flex;
}

.vt-speed button.vt-active,
.vt-taskbar button.vt-active {
  box-shadow: inset 0 0 0 2px var(--vt-sky-deep);
  font-weight: bold;
}

.vt-stat {
  display: inline-flex;
  align-items: center;
  gap: var(--vt-space-1);
  padding: var(--vt-space-1) var(--vt-space-2);
  background: var(--vt-slate);
  border: 1px solid var(--vt-black);
  white-space: nowrap;
}

.vt-miles {
  font-family: var(--vt-font-display);
  font-size: var(--vt-text-lg);
  color: var(--vt-paper);
}

.vt-van-hud {
  font-size: var(--vt-text-lg);
  animation: vt-bounce 1.6s steps(2, end) infinite;
}

@keyframes vt-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

/* HUD meters */
.vt-meter {
  display: inline-flex;
  align-items: center;
  gap: var(--vt-space-2);
  font-size: var(--vt-text-xs);
  color: var(--vt-hud-dim);
}

.vt-meter-track {
  display: inline-block;
  width: 64px;
  height: 10px;
  background: var(--vt-black);
  border: 1px solid var(--vt-steel);
}

.vt-meter-fill {
  display: block;
  height: 100%;
  background: var(--vt-moss);
}

.vt-meter-fill--fuel {
  background: var(--vt-sky);
}

.vt-meter.vt-warn .vt-meter-fill {
  background: var(--vt-amber);
}

.vt-meter.vt-danger .vt-meter-fill {
  background: var(--vt-rose);
}

/* ================================================================== */
/* Desktop & windows                                                   */
/* ================================================================== */

.vt-desktop {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.02) 0 2px,
      transparent 2px 4px
    ),
    var(--vt-bg-desktop);
}

.vt-window {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 280px;
  min-height: 180px;
  box-shadow: var(--vt-shadow-pixel);
}
.vt-window[hidden] {
  display: none !important;
}

.vt-window--minimizing {
  animation: vt-window-minimize 180ms ease-in forwards;
  pointer-events: none;
}

.vt-window--restoring {
  animation: vt-window-restore 180ms ease-out;
}

@keyframes vt-window-minimize {
  to {
    opacity: 0;
    transform: translateY(calc(100vh - var(--vt-taskbar-height)));
  }
}

@keyframes vt-window-restore {
  from {
    opacity: 0;
    transform: translateY(calc(100vh - var(--vt-taskbar-height)));
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.vt-window--inactive .title-bar {
  filter: saturate(0.35) brightness(0.9);
}

.vt-window-body {
  flex: 1 1 auto;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: var(--vt-space-3);
  font-size: var(--vt-text-sm);
}

.vt-window .title-bar-text {
  font-size: var(--vt-text-sm);
}

.vt-resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 40%, var(--vt-steel) 40% 55%, transparent 55%),
    linear-gradient(135deg, transparent 65%, var(--vt-steel) 65% 80%, transparent 80%);
}

/* ================================================================== */
/* Taskbar                                                             */
/* ================================================================== */

.vt-taskbar {
  flex: 0 0 auto;
  min-height: var(--vt-taskbar-height);
  display: flex;
  align-items: center;
  gap: var(--vt-space-2);
  padding: var(--vt-space-1) var(--vt-space-2);
  background: var(--vt-paper);
  border-top: var(--vt-border-hard);
}

.vt-taskbar-apps {
  display: flex;
  gap: var(--vt-space-1);
  flex: 1 1 auto;
  overflow-x: auto;
}

.vt-taskbar button {
  font-size: var(--vt-text-xs);
  white-space: nowrap;
}

.vt-start {
  font-weight: bold;
}

.vt-tray {
  display: flex;
  align-items: center;
  gap: var(--vt-space-3);
  padding: 0 var(--vt-space-2);
  font-size: var(--vt-text-xs);
  border-left: 1px solid var(--vt-steel);
}

.vt-tray-phase {
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--vt-fg-dim);
}

/* ================================================================== */
/* Shared content bits                                                 */
/* ================================================================== */

.vt-dim {
  color: var(--vt-fg-dim);
  font-size: var(--vt-text-xs);
}

.vt-good {
  color: var(--vt-forest);
}

.vt-warn {
  color: var(--vt-rust);
}

.vt-danger {
  color: var(--vt-blood);
}

.vt-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.vt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--vt-space-3);
  flex-wrap: wrap;
  margin: var(--vt-space-1) 0;
}

.vt-toolbar {
  display: flex;
  align-items: center;
  gap: var(--vt-space-3);
  flex-wrap: wrap;
  padding-bottom: var(--vt-space-2);
  border-bottom: 1px solid var(--vt-steel);
}

.vt-flavor {
  margin: var(--vt-space-1) 0;
  font-style: italic;
  color: var(--vt-fg-dim);
  font-size: var(--vt-text-xs);
  line-height: 1.4;
}

.vt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--vt-text-xs);
}

.vt-table td {
  padding: 2px 4px;
  border-bottom: 1px dotted var(--vt-steel);
}

.vt-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: var(--vt-space-2);
}

.vt-kpi {
  display: flex;
  flex-direction: column;
  padding: var(--vt-space-2);
  background: var(--vt-white);
  border: 1px solid var(--vt-steel);
}

.vt-kpi strong {
  font-family: var(--vt-font-display);
  font-size: var(--vt-text-lg);
}

/* Bars */
.vt-bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 40px;
  align-items: center;
  gap: var(--vt-space-2);
  margin: var(--vt-space-1) 0;
  font-size: var(--vt-text-xs);
}

.vt-bar {
  display: block;
  height: 12px;
  background: var(--vt-white);
  border: 1px solid var(--vt-black);
}

.vt-bar--thin {
  height: 8px;
}

.vt-bar-fill {
  display: block;
  height: 100%;
  background: var(--vt-sky);
  /* chunky segmented fill, like a 16-bit gauge */
  background-image: repeating-linear-gradient(
    90deg,
    var(--vt-sky) 0 4px,
    var(--vt-sky-deep) 4px 6px
  );
}

.vt-bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ================================================================== */
/* Cards (team, candidates)                                            */
/* ================================================================== */

.vt-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--vt-space-2);
}

.vt-card {
  padding: var(--vt-space-2);
  background: var(--vt-white);
  border: 1px solid var(--vt-steel);
  border-left: 4px solid var(--vt-forest);
}

.vt-card.vt-warn {
  border-left-color: var(--vt-amber);
}

.vt-card.vt-danger {
  border-left-color: var(--vt-blood);
}

.vt-card--candidate {
  border-left-color: var(--vt-plum);
  background: #fbfaff;
}

.vt-card-head {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: var(--vt-space-2);
}

.vt-avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  font-size: var(--vt-text-lg);
  background: var(--vt-paper);
  border: 1px solid var(--vt-steel);
}

.vt-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--vt-space-1);
  margin: var(--vt-space-1) 0;
  font-family: var(--vt-font-body);
  font-size: var(--vt-text-xs);
}

.vt-stats span {
  padding: 0 3px;
  background: var(--vt-paper);
  border: 1px solid var(--vt-steel);
}

.vt-traits {
  display: flex;
  flex-wrap: wrap;
  gap: var(--vt-space-1);
}

.vt-trait {
  padding: 0 4px;
  font-size: var(--vt-text-xs);
  background: var(--vt-lemon);
  border: 1px solid var(--vt-black);
  cursor: help;
}

/* ================================================================== */
/* Map                                                                 */
/* ================================================================== */

.vt-map-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 220px;
  border: 2px inset var(--vt-steel);
  overflow: hidden;
  background: var(--vt-black);
}

.vt-map-container {
  position: absolute;
  inset: 0;
}

/* The 16-bit trick: render tiles small, scale them up without smoothing. */
.vt-map--pixelated canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.vt-map-canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.vt-van-marker {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.6));
}

.vt-van-sprite {
  font-size: 22px;
  animation: vt-bounce 1.2s steps(2, end) infinite;
}

.maplibregl-popup.vt-popup .maplibregl-popup-content {
  font-family: var(--vt-font-body);
  font-size: var(--vt-text-xs);
  border: var(--vt-border-hard);
  border-radius: 0;
  background: var(--vt-paper);
}

/* ================================================================== */
/* Event log                                                           */
/* ================================================================== */

.vt-log-panel {
  flex: 1 1 auto;
  overflow: auto;
  max-height: 100%;
  background: var(--vt-white);
}

.vt-log {
  list-style: none;
  margin: 0;
  padding: var(--vt-space-2);
}

.vt-log-item {
  padding: var(--vt-space-2) 0;
  border-bottom: 1px dotted var(--vt-steel);
}

.vt-log-head {
  display: flex;
  align-items: baseline;
  gap: var(--vt-space-2);
}

.vt-log-day {
  font-family: var(--vt-font-body);
  font-size: var(--vt-text-xs);
  color: var(--vt-fg-dim);
  min-width: 5ch;
}

.vt-deltas {
  display: flex;
  flex-wrap: wrap;
  gap: var(--vt-space-1);
  margin-top: var(--vt-space-1);
}

.vt-delta {
  padding: 0 3px;
  font-family: var(--vt-font-body);
  font-size: var(--vt-text-xs);
  background: var(--vt-paper);
  border: 1px solid var(--vt-steel);
}

/* ================================================================== */
/* Modals                                                              */
/* ================================================================== */

.vt-modal-layer {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: grid;
  place-items: center;
  padding: var(--vt-space-5);
}

.vt-modal-layer[hidden] {
  display: none;
}

.vt-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 14, 20, 0.6);
  /* dithered overlay, because gradients are cheating */
  background-image: repeating-conic-gradient(
    rgba(0, 0, 0, 0.25) 0% 25%,
    transparent 0% 50%
  );
  background-size: 4px 4px;
}

.vt-modal {
  position: relative;
  width: min(620px, 92vw);
  max-height: 88vh;
  overflow: auto;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.5);
  animation: vt-modal-in 140ms steps(3, end);
}

.vt-modal--newrun {
  width: min(760px, 94vw);
}

@keyframes vt-modal-in {
  from {
    transform: translateY(8px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.vt-modal .title-bar {
  font-size: var(--vt-text-md);
}

.vt-modal-desc {
  margin: var(--vt-space-2) 0;
  font-size: var(--vt-text-md);
  line-height: 1.5;
}

.vt-modal-meta {
  margin: 0 0 var(--vt-space-3);
}

/* Category accents on the modal edge. */
.vt-modal--technical {
  border-top: 4px solid var(--vt-sky-deep);
}
.vt-modal--team {
  border-top: 4px solid var(--vt-plum);
}
.vt-modal--business {
  border-top: 4px solid var(--vt-forest);
}
.vt-modal--marketing {
  border-top: 4px solid var(--vt-rust);
}
.vt-modal--random {
  border-top: 4px solid var(--vt-steel);
}
.vt-modal--disaster {
  border-top: 4px solid var(--vt-blood);
}
.vt-modal--checkpoint {
  border-top: 4px solid var(--vt-gold);
}
.vt-modal--pitch {
  border-top: 4px solid var(--vt-rose);
}
.vt-modal--outcome {
  border-top: 4px solid var(--vt-lemon);
}

/* Choices */
.vt-choices {
  display: grid;
  gap: var(--vt-space-2);
  margin-top: var(--vt-space-3);
}

.vt-choices--tight {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: var(--vt-space-2);
}

.vt-choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: var(--vt-space-3);
  text-align: left;
  min-height: 40px;
  cursor: pointer;
}

.vt-choice:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.vt-choice-label {
  font-size: var(--vt-text-md);
  font-weight: bold;
}

.vt-choice-preview {
  font-family: var(--vt-font-body);
  font-size: var(--vt-text-xs);
  color: var(--vt-sky-deep);
}

.vt-choice-locked {
  font-size: var(--vt-text-xs);
  color: var(--vt-blood);
}

.vt-choice--pick.vt-active {
  box-shadow: inset 0 0 0 3px var(--vt-sky-deep);
}

.vt-scorecard {
  margin: var(--vt-space-3) 0 0;
  padding: var(--vt-space-2);
  font-family: var(--vt-font-body);
  font-size: var(--vt-text-xs);
  white-space: pre-wrap;
  background: var(--vt-white);
  border: 1px solid var(--vt-steel);
}

.vt-file {
  cursor: pointer;
  padding: 2px 8px;
  border: 1px solid var(--vt-steel);
  background: var(--vt-paper);
}

/* ================================================================== */
/* Toasts                                                              */
/* ================================================================== */

.vt-toasts {
  position: fixed;
  right: var(--vt-space-3);
  bottom: calc(var(--vt-taskbar-height) + var(--vt-space-3));
  z-index: 9500;
  display: flex;
  flex-direction: column;
  gap: var(--vt-space-2);
  pointer-events: none;
}

.vt-toast {
  max-width: 320px;
  padding: var(--vt-space-2) var(--vt-space-3);
  background: var(--vt-ink);
  color: var(--vt-paper);
  border: var(--vt-border-hard);
  box-shadow: var(--vt-shadow-pixel);
  font-family: var(--vt-font-body);
  font-size: var(--vt-text-xs);
  animation: vt-toast-in 120ms steps(2, end);
}

.vt-toast--out {
  opacity: 0;
  transition: opacity 300ms;
}

@keyframes vt-toast-in {
  from {
    transform: translateX(12px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* ================================================================== */
/* Boot screen                                                         */
/* ================================================================== */

.vt-boot {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-content: center;
  gap: var(--vt-space-3);
  text-align: center;
  background: var(--vt-black);
  color: var(--vt-gold);
  font-family: var(--vt-font-display);
}

.vt-boot h1 {
  margin: 0;
  font-size: 40px;
  letter-spacing: 2px;
}

.vt-boot p {
  margin: 0;
  color: var(--vt-fog);
  font-family: var(--vt-font-body);
  font-size: var(--vt-text-sm);
}

.vt-boot--error {
  color: var(--vt-rose);
}

/* ================================================================== */
/* Narrow screens                                                      */
/* ================================================================== */

@media (max-width: 900px) {
  .vt-hud {
    font-size: var(--vt-text-xs);
  }
  .vt-hud-center {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .vt-window {
    left: 8px !important;
    width: calc(100% - 16px) !important;
  }
  .vt-bar-row {
    grid-template-columns: 90px 1fr 36px;
  }
}
