/* Route planner. Global (not component-scoped) because suggestions, route options and
   map markers are created at runtime and would miss WaldJS's scope attribute. */

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #14111b;
  color: var(--text);
}
.app .sprite {
  position: absolute;
  width: 0;
  height: 0;
}
.app .map {
  position: absolute;
  inset: 0;
}

/* ── Mode switching ── */
.app .nav,
.app .arrived,
.app .options,
.app .actions {
  display: none;
}
.app[data-mode='preview'] .options,
.app[data-mode='preview'] .actions {
  display: grid;
}
.app[data-mode='navigate'] .panel,
.app[data-mode='arrived'] .panel {
  display: none;
}
.app[data-mode='navigate'] .nav {
  display: block;
}
.app[data-mode='arrived'] .arrived {
  display: grid;
}

/* ── Brutalist surfaces ── */
.app .panel,
.app .hud,
.app .arrived {
  background: var(--surface);
  border: 3px solid var(--text);
  box-shadow: 8px 8px 0 var(--ir-red);
}

/* ── Planner panel ── */
.app .panel {
  position: absolute;
  z-index: 10;
  top: max(0.75rem, env(safe-area-inset-top));
  left: 0.75rem;
  right: calc(0.75rem + 8px);
  display: grid;
  gap: var(--space-4);
  max-height: calc(100dvh - 1.5rem - 8px);
  overflow: auto;
  padding: var(--space-4);
}
@media (min-width: 900px) {
  .app .panel {
    top: 1.25rem;
    left: 1.25rem;
    right: auto;
    width: 27rem;
    padding: var(--space-6);
  }
}
.app .panel-head {
  display: grid;
  gap: var(--space-2);
}
.app .home img {
  width: 8.25rem;
  height: auto;
}
.app h1 {
  font-size: clamp(1.75rem, 1.4rem + 1.5vw, 2.25rem);
  font-weight: 900;
  text-transform: uppercase;
  line-height: 0.95;
}

.app .search {
  position: relative;
  display: grid;
  gap: var(--space-3);
  padding-right: 3.25rem;
}
.app .field {
  position: relative;
  display: grid;
  gap: var(--space-1);
}
.app .field label {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.app .field input {
  width: 100%;
  min-height: 3rem;
  padding: 0 var(--space-3);
  border: 2px solid var(--border);
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  font: 500 1rem / 1.2 var(--font);
}
.app .field input::placeholder {
  color: var(--text-muted);
}
.app .field input:focus {
  outline: none;
  border-color: var(--ir-gold);
  box-shadow: 4px 4px 0 var(--ir-gold);
}
.app .swap {
  position: absolute;
  right: 0;
  top: 50%;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-top: -0.4rem;
  border: 2px solid var(--border);
  background: var(--surface-raised);
  color: var(--text);
  cursor: pointer;
}
.app .swap:hover {
  border-color: var(--ir-gold);
  color: var(--ir-yellow);
}
.app .swap svg,
.app .suggestions svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app .suggestions {
  position: absolute;
  z-index: 30;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 18rem;
  overflow: auto;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  background: var(--surface-raised);
  border: 2px solid var(--ir-gold);
  box-shadow: 6px 6px 0 var(--ir-red);
}
.app .suggestions[hidden] {
  display: none;
}
.app .option {
  display: grid;
  gap: 2px;
  padding: var(--space-3);
  border-left: 4px solid transparent;
  cursor: pointer;
}
.app .option + .option {
  border-top: 1px solid var(--border);
}
.app .option strong {
  font-weight: 700;
}
.app .option span {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.app .option.me {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--ir-yellow);
  font-weight: 700;
}
.app .option:hover,
.app .option[aria-selected='true'] {
  background: #2a2335;
  border-left-color: var(--ir-gold);
}

.app .status:empty {
  display: none;
}
.app .status {
  padding: var(--space-3);
  border-left: 4px solid var(--ir-red);
  background: rgb(255 59 59 / 0.1);
  font-size: var(--fs-sm);
}

/* ── Route options ── */
.app .options {
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}
.app .route-option {
  position: relative;
  display: grid;
  gap: var(--space-1);
  justify-items: start;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.app .route-option:hover {
  border-color: var(--text-muted);
}
.app .route-option[aria-pressed='true'] {
  border: 3px solid;
  border-image: var(--ir-gradient) 1;
  box-shadow: 6px 6px 0 var(--ir-red);
}
.app .ro-time {
  font-size: 1.75rem;
  font-weight: 900;
  font-style: italic;
  line-height: 1;
}
.app .route-option[aria-pressed='true'] .ro-time {
  color: transparent;
  background: var(--ir-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  padding-inline-end: 0.15em;
}
.app .ro-meta {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.app .ro-tag {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  padding: 2px var(--space-2);
  background: var(--ir-gradient);
  color: var(--on-accent);
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.app .ro-delay {
  color: var(--ir-red);
  font-size: var(--fs-sm);
  font-weight: 700;
}

/* ── Buttons ── */
.app .actions {
  grid-template-columns: 1fr auto;
  gap: var(--space-3);
}
.app .btn-go,
.app .btn-line,
.app .stop,
.app .recenter {
  min-height: 3.25rem;
  padding: 0 var(--space-5, 1.25rem);
  font: italic 900 1rem / 1 var(--font);
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.app .btn-go {
  border: 3px solid var(--on-accent);
  background: var(--ir-gradient);
  color: var(--on-accent);
  box-shadow: 6px 6px 0 var(--ir-red);
}
.app .btn-go:hover {
  transform: translate(-2px, -2px);
  box-shadow: 8px 8px 0 var(--ir-red);
}
.app .btn-go:active {
  transform: translate(4px, 4px);
  box-shadow: 2px 2px 0 var(--ir-red);
}
.app .btn-line {
  border: 2px solid var(--text);
  background: transparent;
  color: var(--text);
}
.app .btn-line:hover {
  background: var(--surface-raised);
}

/* ── Navigation ── */
.app .banner {
  position: absolute;
  z-index: 10;
  top: max(0.75rem, env(safe-area-inset-top));
  left: 0.75rem;
  right: calc(0.75rem + 8px);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--ir-gradient);
  color: var(--on-accent);
  border: 3px solid var(--on-accent);
  box-shadow: 8px 8px 0 var(--ir-red);
}
@media (min-width: 900px) {
  .app .banner {
    left: 1.25rem;
    right: auto;
    width: 30rem;
  }
}
.app .m-icon {
  flex: none;
  width: 3.75rem;
  height: 3.75rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.app .m-text {
  display: grid;
  min-width: 0;
  line-height: 1.1;
}
.app .m-dist {
  font-size: clamp(2rem, 1.6rem + 2vw, 2.75rem);
  font-weight: 900;
  font-style: italic;
  line-height: 1;
}
.app .m-label {
  font-size: 1.125rem;
  font-weight: 800;
}
.app .m-road {
  overflow: hidden;
  font-size: var(--fs-sm);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app .m-road:empty {
  display: none;
}
.app .rerouting {
  position: absolute;
  z-index: 10;
  top: 9rem;
  left: 0.75rem;
  padding: var(--space-2) var(--space-3);
  background: var(--on-accent);
  border: 2px solid var(--ir-red);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
}
@media (min-width: 900px) {
  .app .rerouting {
    left: 1.25rem;
  }
}

.app .hud {
  position: absolute;
  z-index: 10;
  left: 0.75rem;
  right: calc(0.75rem + 8px);
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3, 1fr) auto auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}
@media (min-width: 900px) {
  .app .hud {
    left: 50%;
    right: auto;
    width: 36rem;
    transform: translateX(-50%);
  }
}
.app .hud p {
  display: grid;
  line-height: 1.1;
}
.app .hud strong {
  font-size: 1.375rem;
  font-weight: 900;
}
.app .hud span {
  color: var(--text-muted);
  font-size: 0.75rem;
}
.app .speed {
  place-items: center;
  align-content: center;
  gap: 2px;
  width: 3.75rem;
  height: 3.75rem;
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px var(--ir-yellow);
  text-align: center;
}
.app .speed span {
  font-size: 0.625rem;
}
.app .stop {
  border: 3px solid var(--on-accent);
  background: var(--ir-red);
  color: #fff;
}
.app .stop:hover {
  filter: brightness(1.1);
}
.app .recenter {
  position: absolute;
  z-index: 10;
  right: 1.25rem;
  bottom: 7.5rem;
  border: 3px solid var(--on-accent);
  background: var(--ir-gradient);
  color: var(--on-accent);
  box-shadow: 5px 5px 0 var(--ir-red);
}
.app .recenter[hidden] {
  display: none;
}

/* ── Arrival ── */
.app .arrived {
  position: absolute;
  z-index: 10;
  left: 50%;
  top: 50%;
  justify-items: start;
  gap: var(--space-3);
  width: min(calc(100% - 2rem), 24rem);
  padding: var(--space-6);
  transform: translate(-50%, -50%);
}
.app .arrived-tag {
  padding: 2px var(--space-2);
  background: var(--ir-gradient);
  color: var(--on-accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.app .arrived h2 {
  font-size: 2.5rem;
  font-weight: 900;
  text-transform: uppercase;
}
.app .arrived-place {
  color: var(--text-muted);
}

/* ── Map markers (HERE DomMarkers) ── */
.pin-marker {
  width: 32px;
  height: 40px;
  margin: -40px 0 0 -16px;
}
.pin-marker svg,
.puck-marker svg,
.incident-marker svg {
  display: block;
  width: 100%;
  height: 100%;
}
.origin-marker {
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 4px solid #0e0b14;
  border-radius: 50%;
  background: #fff;
}
.puck-marker {
  position: relative;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  transform: rotate(var(--rot, 0deg));
  transition: transform 0.4s ease;
}
.puck-marker .halo {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: rgb(255 59 59 / 0.35);
  animation: puck-halo 1.6s ease-out infinite;
}
@keyframes puck-halo {
  from {
    transform: scale(0.6);
    opacity: 1;
  }
  to {
    transform: scale(1.4);
    opacity: 0;
  }
}
.incident-marker {
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  fill: var(--ir-yellow);
  filter: drop-shadow(2px 2px 0 #0e0b14);
  cursor: help;
}
.incident-marker.is-accident,
.incident-marker.is-closure,
.incident-marker.is-critical {
  fill: var(--ir-red);
}

.noscript {
  padding: var(--space-6);
}
