/*
 * The map is the picture, and the interface a caption laid over it, on soft shades rather than
 * in boxes, as on the train map. The look and its tokens are theme.css's; js/map.js uses the
 * same colours on the map.
 */

:root {
  --index: 420px;
  --timeline: 150px;
}

html,
body {
  height: 100%;
}

/* Small tracked capitals: every label, every control */
.wordmark,
.section-title,
.tile-label,
.tile-note,
.hero-sub,
.seg button,
.seg span,
.legend,
.actions button,
.compact-clock,
.day-title,
.feed-status,
.flight-status {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* The clock, figures and names: ultra-light */
.hero-value,
.qty,
.flight-title {
  font-weight: var(--display-weight);
  font-variant-numeric: tabular-nums lining-nums;
}

#app {
  position: relative;
  height: 100dvh;
  overflow: hidden;
}

/* ---------- The map, and what's laid over it ---------- */

#map {
  position: absolute;
  inset: 0;
  background: var(--bg);
}

/* A soft shade at the top, so the wordmark and controls read over the map */
#app::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  z-index: 1;
  height: 140px;
  background: linear-gradient(rgb(8 8 8 / 0.6), rgb(8 8 8 / 0));
  pointer-events: none;
}

.topbar,
.map-controls > :not(:has(.chrome-toggle)),
.index,
.timeline,
.map-buttons {
  transition:
    opacity var(--fade),
    visibility var(--fade);
}

#app.chrome-hidden
  :is(.topbar, .map-controls > :not(:has(.chrome-toggle)), .index, .timeline, .map-buttons) {
  opacity: 0;
  visibility: hidden;
}

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  padding: 30px var(--gutter) 0;
}

.wordmark {
  font-weight: 500;
  letter-spacing: 0.32em;
  text-shadow: var(--lift-text);
}

.map-controls {
  position: absolute;
  top: 26px;
  right: var(--gutter);
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: baseline;
  gap: 10px 32px;
  max-width: calc(100% - 280px);
}

.seg {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.seg button,
.actions button {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--ink-3);
  text-decoration: none;
  text-shadow: var(--lift-text);
  transition: color 0.2s;
}

.seg button:hover:not(:disabled),
.actions button:hover,
.seg button[aria-pressed='true'],
.actions button[aria-pressed='true'] {
  color: var(--ink);
}

.seg button[aria-pressed='true'],
.actions button[aria-pressed='true'] {
  text-decoration: underline;
  text-decoration-thickness: 0.5px;
  text-underline-offset: 6px;
}

/* A group's name, and a short rule between it and its buttons */
.seg > span {
  color: var(--ink-3);
  text-shadow: var(--lift-text);
}

.seg > span::after {
  content: '';
  display: inline-block;
  width: 14px;
  margin-left: 14px;
  vertical-align: middle;
  border-top: 1px solid var(--ink-4);
}

.seg button:disabled {
  opacity: 0.35;
  cursor: default;
}

.legend {
  display: flex;
  flex-basis: 100%;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin: 0;
  color: var(--ink-3);
  text-shadow: var(--lift-text);
}

.ramp-bar {
  display: inline-block;
  width: 72px;
  height: 2px;
}

/* Where am I, and zoom in and out: hairline squares, bottom right above the timeline */
.map-buttons {
  position: absolute;
  right: var(--gutter);
  bottom: calc(var(--timeline) + 40px);
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.zoom {
  display: flex;
  flex-direction: column;
}

.map-buttons button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--ink-4);
  background: rgb(8 8 8 / 0.8);
  color: var(--ink-2);
  transition:
    color 0.2s,
    border-color 0.2s;
}

.zoom button + button {
  border-top: 0;
}

.map-buttons button:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}

.map-buttons svg {
  width: 14px;
  height: 14px;
}

/* Found: the middle filled in. Looking: it breathes */
.locate[aria-pressed='true'] {
  color: var(--ink);
}

.locate[aria-pressed='true'] circle {
  fill: currentColor;
}

.locate[aria-busy='true'] svg {
  animation: locating 1s ease-in-out infinite alternate;
}

@keyframes locating {
  to {
    opacity: 0.25;
  }
}

/* Why it couldn't find you, beside the button */
.locate-note {
  position: absolute;
  top: 0;
  right: calc(100% + 12px);
  margin: 0;
  font-size: var(--caps-size);
  font-weight: 400;
  line-height: 32px;
  letter-spacing: var(--caps-tracking);
  text-shadow: var(--lift-text);
  text-transform: uppercase;
  white-space: nowrap;
}

.maplibregl-ctrl-bottom-right {
  bottom: calc(var(--timeline) - 24px);
  z-index: 3;
}

.maplibregl-ctrl-attrib {
  background: rgb(8 8 8 / 0.8) !important;
  color: var(--ink-3);
  font: 300 10px/1.6 var(--font);
}

.maplibregl-ctrl-attrib.maplibregl-compact {
  border-radius: 0 !important;
}

.maplibregl-ctrl-attrib a {
  color: var(--ink-2) !important;
}

.maplibregl-ctrl-attrib-button {
  filter: invert(1);
  opacity: 0.5;
}

/* deck.gl's tooltip */
.deck-tooltip .tooltip-meta {
  margin-top: 2px;
  color: var(--ink-3);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.map-error {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 10;
  margin: 0;
  font-size: 15px;
  transform: translate(-50%, -50%);
}

/* ---------- The index: the clock and figures, or the aircraft you picked ---------- */

.index {
  position: absolute;
  top: 0;
  left: 0;
  bottom: var(--timeline);
  z-index: 2;
  width: var(--index);
  padding: 104px 80px 32px var(--gutter);
  overflow-y: auto;
  background: linear-gradient(
    90deg,
    rgb(8 8 8 / 0.94) 0%,
    rgb(8 8 8 / 0.9) 70%,
    rgb(8 8 8 / 0) 100%
  );
  scrollbar-width: none;
  overscroll-behavior: contain;
  /* Fade out under the wordmark above and into the timeline below, rather than stop at an edge */
  -webkit-mask-image: linear-gradient(
    transparent 56px,
    #000 96px,
    #000 calc(100% - 48px),
    transparent
  );
  mask-image: linear-gradient(transparent 56px, #000 96px, #000 calc(100% - 48px), transparent);
}

.index::-webkit-scrollbar {
  display: none;
}

.section-title {
  margin: 0 0 18px;
  color: var(--ink-3);
}

.hero-value {
  margin: 0 0 10px;
  font-size: 88px;
  line-height: 0.9;
  letter-spacing: var(--display-tracking);
  white-space: nowrap;
}

.hero-value .qty-u {
  font-size: 22px;
  letter-spacing: 0;
}

.hero-sub {
  margin: 0 0 36px;
  color: var(--ink-2);
  line-height: 1.8;
}

.qty {
  white-space: nowrap;
}

.qty-u {
  margin-left: 6px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 0.04em;
}

.figures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 26px 24px;
}

.tile {
  display: block;
  min-width: 0;
}

.tile-button {
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
}

.tile-label {
  display: block;
  color: var(--ink-3);
}

.tile .qty {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  line-height: 1;
}

.tile-note {
  display: block;
  margin-top: 8px;
  overflow: hidden;
  color: var(--ink-3);
  font-size: 9px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tile-button:hover .tile-note {
  color: var(--ink-2);
  text-decoration: underline;
  text-decoration-thickness: 0.5px;
  text-underline-offset: 4px;
}

.airlines {
  margin-top: 56px;
}

.airline-bars {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.airline-bars button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 36px;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 5px 0;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  text-align: left;
}

.airline-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.airline-bars button:hover .airline-name {
  color: var(--ink);
}

/* With airlines picked out, the rest fade back */
.airline-bars.picking button[aria-pressed='false'] {
  opacity: 0.35;
}

.airline-bars.picking button[aria-pressed='true'] .airline-name {
  color: var(--ink);
}

.key {
  display: inline-block;
  flex: none;
  width: 14px;
  height: 1.5px;
}

.bar-track {
  height: 1px;
  background: var(--ink-4);
}

.bar {
  display: block;
  width: var(--w);
  min-width: 1px;
  height: 100%;
  background: var(--ink);
}

.bar-value {
  text-align: right;
}

.airline-more {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 10px 0 0;
}

.airline-more button {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--ink-3);
  font-size: 11px;
  letter-spacing: 0.04em;
  transition: color 0.2s;
}

.airline-more button:hover {
  color: var(--ink);
}

#airline-all {
  margin-left: auto;
}

/* Finding a flight: a hairline to type on, above whatever the index shows */
.search {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 44px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--ink-4);
  color: var(--ink-3);
  transition:
    border-color 0.2s,
    color 0.2s;
}

.search:focus-within {
  border-color: var(--ink-2);
  color: var(--ink);
}

.search svg {
  flex: none;
  width: 13px;
  height: 13px;
}

/* 16px, or a phone zooms in to type */
.search input {
  flex: 1;
  min-width: 0;
  padding: 4px 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--ink);
  font-size: 16px;
  font-weight: 300;
  letter-spacing: 0.04em;
  appearance: none;
}

.search input::placeholder {
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.search input::-webkit-search-cancel-button {
  display: none;
}

.search button {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: color 0.2s;
}

.search button:hover {
  color: var(--ink);
}

/* What it found: each aircraft's name and height, and who it is beneath */
.search-results {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.search-results button {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 4px 12px;
  width: 100%;
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--ink-2);
  text-align: left;
}

/* In their columns, with or without the airline's colour */
.search-results .key {
  align-self: center;
}

/* A callsign or registration: short, so it isn't cut off (or its underline would be) */
.result-name {
  grid-column: 2;
  font-size: 22px;
  font-weight: var(--display-weight);
  line-height: 1.1;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition: color 0.2s;
}

.result-height {
  grid-column: 3;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.result-sub {
  grid-column: 2 / -1;
  overflow: hidden;
  color: var(--ink-3);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.search-results button:hover .result-name,
.search-results button:focus-visible .result-name {
  color: var(--ink);
}

/* Moved to with the arrow keys: underlined, as a pressed button is */
.search-results button:focus-visible {
  outline: 0;
}

.search-results button:focus-visible .result-name {
  text-decoration: underline;
  text-decoration-thickness: 0.5px;
  text-underline-offset: 5px;
}

.results-note {
  margin: 14px 0 0;
  color: var(--ink-2);
  line-height: 1.7;
}

/* The search opens from a button on a phone; it's always there on a wide screen */
.map-buttons .search-toggle {
  display: none;
}

.search-toggle[aria-expanded='true'] {
  color: var(--ink);
}

/* The aircraft you picked: its heading stays put, and the rest scrolls beneath */
.index.has-flight {
  display: flex;
  flex-direction: column;
}

.flight-title {
  margin: 0 0 12px;
  font-size: 48px;
  line-height: 1;
  letter-spacing: var(--display-tracking);
}

/* Where it's flying from and to */
.flight-route {
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
}

.flight-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -12px 0 24px;
  color: var(--ink);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 22px;
}

#flight .actions {
  margin-bottom: 32px;
}

/* Its height over the last 15 minutes, drawn like the day along the bottom */
.profile {
  margin-top: 44px;
}

.profile svg {
  display: block;
  width: 100%;
  height: 96px;
  overflow: visible;
}

.profile .line {
  fill: none;
  stroke: var(--neon);
  stroke-width: 1.25;
  stroke-linejoin: round;
}

.profile .area {
  fill: rgb(255 240 31 / 0.06);
  stroke: none;
}

.profile .refs line {
  stroke: var(--ink-4);
  stroke-width: 1;
  stroke-dasharray: 1 4;
  shape-rendering: crispEdges;
}

.profile text {
  fill: var(--ink-3);
  font: 300 10px var(--font);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

/* ---------- The day along the bottom: the aircraft in the air, and now ---------- */

.timeline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  height: var(--timeline);
  padding: 44px var(--gutter) 16px;
  background: linear-gradient(
    0deg,
    rgb(8 8 8 / 0.94) 0%,
    rgb(8 8 8 / 0.85) 52%,
    rgb(8 8 8 / 0) 100%
  );
  pointer-events: none;
}

.timeline > * {
  pointer-events: auto;
}

.timeline-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  margin-bottom: 10px;
}

.compact-clock {
  display: none;
  margin: 0;
  color: var(--ink-2);
}

.compact-clock #clock-compact {
  color: var(--ink);
  font-size: 22px;
  font-weight: var(--display-weight);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--display-tracking);
}

/* What the chart shows, and how fresh the positions are: the dot is neon while they are */
.day-title {
  margin: 0 auto 0 0;
  color: var(--ink-3);
}

.feed-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--ink-2);
}

.feed-status .neon-dot {
  animation: live 2s ease-in-out infinite;
}

.feed-status .neon-dot.stale {
  background: transparent;
  border-color: var(--ink-3);
  box-shadow: none;
  animation: none;
}

@keyframes live {
  50% {
    box-shadow: 0 0 0 1px var(--neon-glow);
  }
}

@media (prefers-reduced-motion: reduce) {
  .feed-status .neon-dot {
    animation: none;
  }
}

.day-chart {
  position: relative;
  height: 70px;
}

.day-chart svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.day-chart text {
  fill: var(--ink-3);
  font: 300 10px var(--font);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.day-chart .refs line {
  stroke: var(--ink-4);
  stroke-width: 1;
  stroke-dasharray: 1 4;
  shape-rendering: crispEdges;
}

.day-chart .line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.25;
  stroke-linejoin: round;
}

.day-chart .area {
  fill: rgb(243 241 236 / 0.06);
  stroke: none;
}

/* Before the time trails stay: the day's tracks from then aren't drawn */
.day-chart .gone {
  opacity: 0.3;
}

.day-chart .now line {
  stroke: var(--neon);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.day-chart .now circle {
  fill: var(--neon);
  stroke: var(--bg);
  stroke-width: 1.5;
}

.day-chart .now text {
  fill: var(--ink);
}

/* ---------- Narrow screens ---------- */

@media (max-width: 1180px) {
  :root {
    --index: 360px;
  }

  .hero-value {
    font-size: 72px;
  }

  .index {
    padding-right: 48px;
  }
}

/* On a phone the map fills the screen, the day sits along the bottom with the clock, and the
   aircraft you pick rests above it. The index's figures are for bigger screens. */
@media (max-width: 860px) {
  :root {
    --gutter: 20px;
    --timeline: 136px;
  }

  .topbar {
    padding: 20px var(--gutter) 0;
  }

  .map-controls {
    top: 16px;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    max-width: none;
  }

  .legend {
    display: none !important;
  }

  .compact-clock {
    display: block;
  }

  .day-title {
    display: none;
  }

  .timeline {
    padding-top: 36px;
  }

  .timeline-bar {
    margin-bottom: 6px;
  }

  .day-chart {
    height: 64px;
  }

  .index {
    display: none;
  }

  /* The search, or the aircraft you picked, rests above the day as a sheet */
  .index:is(.has-flight, .searching) {
    display: flex;
    flex-direction: column;
    top: auto;
    right: 0;
    width: auto;
    height: 50dvh;
    padding: 56px var(--gutter) 8px;
    background: linear-gradient(rgb(8 8 8 / 0), rgb(8 8 8 / 0.9) 56px, rgb(8 8 8 / 0.94));
    /* A sheet fades in above by its background, with no wordmark to keep clear of */
    -webkit-mask-image: linear-gradient(#000 calc(100% - 48px), transparent);
    mask-image: linear-gradient(#000 calc(100% - 48px), transparent);
  }

  .flight-title {
    margin-bottom: 8px;
    font-size: 32px;
  }

  .flight-route {
    margin-bottom: 8px;
    font-size: 14px;
  }

  /* A sheet is half the screen: its heading kept short, so the figures show */
  .index .hero-sub {
    margin-bottom: 16px;
  }

  .flight-status {
    margin: 0 0 16px;
  }

  #flight .actions {
    margin-bottom: 20px;
  }

  .profile {
    margin-top: 28px;
  }

  /* With a sheet open, the map's buttons rest above it */
  #app:has(.index:is(.has-flight, .searching)) .map-buttons {
    bottom: calc(var(--timeline) + 50dvh + 12px);
  }

  /* The search, only while it's open; and over the map, just what it finds */
  .index:not(.searching) .search,
  .index.searching :is(#overview, #flight) {
    display: none;
  }

  .search {
    flex: none;
    margin-bottom: 24px;
  }

  .map-buttons .search-toggle {
    display: grid;
  }

  /* Why it couldn't find you, beside the locate button, below the search's */
  .locate-note {
    top: 40px;
  }
}
