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

:root {
  --index: 400px;
}

html,
body {
  height: 100%;
}

/* Small tracked capitals: every label, every control */
.section-title,
.tile-label,
.tile-note,
.hero-sub,
.seg button,
.actions button,
.pick-link,
.row-name,
.row-note {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

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

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

#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: 120px;
  background: linear-gradient(rgb(8 8 8 / 0.6), rgb(8 8 8 / 0));
  pointer-events: none;
}

.topbar,
.index,
.map-buttons,
.map-controls .seg:not(.seg-always) {
  transition: opacity var(--fade);
}

#app.chrome-hidden :is(.topbar, .index, .map-buttons, .map-controls .seg:not(.seg-always)) {
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--fade),
    visibility 0s var(--fade);
}

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

.wordmark {
  display: block;
  text-shadow: var(--lift-text);
}

.credit {
  display: block;
  max-width: 170px;
  margin-top: 8px;
  color: var(--ink);
  font-size: 9px;
  line-height: 1.5;
  letter-spacing: 0.08em;
  opacity: 0.55;
  pointer-events: auto;
  text-decoration: none;
}

.credit:hover {
  opacity: 1;
}

.map-controls {
  position: absolute;
  top: 26px;
  right: var(--gutter);
  z-index: 4;
  display: flex;
  align-items: baseline;
  gap: 10px 32px;
}

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

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

.seg button:hover,
.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;
}

.map-buttons {
  position: absolute;
  right: var(--gutter);
  bottom: 48px;
  z-index: 3;
  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;
}

.map-buttons button + button {
  border-top: 0;
}

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

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

/* ---------- The index ---------- */

.index {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 2;
  width: var(--index);
  padding: 112px 72px 32px var(--gutter);
  overflow-y: auto;
  background: linear-gradient(
    90deg,
    rgb(8 8 8 / 0.94) 0%,
    rgb(8 8 8 / 0.88) 68%,
    rgb(8 8 8 / 0) 100%
  );
  scrollbar-width: none;
  overscroll-behavior: contain;
  -webkit-mask-image: linear-gradient(
    transparent 64px,
    #000 104px,
    #000 calc(100% - 40px),
    transparent
  );
  mask-image: linear-gradient(transparent 64px, #000 104px, #000 calc(100% - 40px), transparent);
}

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

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

.hero-value {
  margin: 0 0 10px;
  font-size: 80px;
  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 28px;
  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;
}

/* Finding anything: a hairline under it, like everything else here */
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
  padding-bottom: 8px;
  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: 12px;
  height: 12px;
}

.search input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--ink);
  font-size: 12px;
  -webkit-appearance: none;
  appearance: none;
}

.search input::placeholder {
  color: var(--ink-3);
}

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

.search button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-3);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

.search-results {
  margin: 0;
  padding: 0;
  list-style: none;
}

.result {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: baseline;
  gap: 2px 8px;
  width: 100%;
  padding: 9px 0;
  border: 0;
  border-top: 1px solid var(--ink-5);
  background: none;
  text-align: left;
}

.result-title {
  overflow: hidden;
  font-size: 15px;
  font-weight: 300;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.result:hover .result-title {
  color: var(--neon);
}

.result-kind,
.result-about {
  color: var(--ink-3);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.result-about {
  grid-column: 2 / -1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Each layer: tap to turn it on and off, and its own map beside it */
.rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.row {
  position: relative;
  border-top: 1px solid var(--ink-5);
}

.row:last-child {
  border-bottom: 1px solid var(--ink-5);
}

.row-toggle {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: baseline;
  gap: 2px 8px;
  width: 100%;
  padding: 11px 26px 11px 0;
  border: 0;
  background: none;
  text-align: left;
  transition: opacity 0.2s;
}

.row-toggle[aria-pressed='false'] {
  opacity: 0.38;
}

.row-toggle:hover .row-name {
  color: var(--ink);
}

.swatch {
  align-self: baseline;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--swatch);
}

.row-toggle[aria-pressed='false'] .swatch {
  background: none;
  box-shadow: inset 0 0 0 1px var(--swatch);
}

.row-name {
  color: var(--ink-2);
  transition: color 0.2s;
}

.row-value {
  font-size: 22px;
  line-height: 1;
  text-align: right;
}

.row-unit {
  margin-left: 4px;
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 300;
}

.row-note {
  grid-column: 2 / -1;
  overflow: hidden;
  color: var(--ink-3);
  font-size: 9px;
  letter-spacing: 0.14em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.row-note.is-wrong {
  color: var(--ink);
}

.row-link {
  position: absolute;
  top: 10px;
  right: 0;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.5;
  text-decoration: none;
  transition: color 0.2s;
}

.row-link:hover {
  color: var(--ink);
}

.coverage {
  margin: 22px 0 0;
  color: var(--ink-3);
  font-size: 11px;
  line-height: 1.6;
}

/* ---------- What you picked ---------- */

.pick-title {
  margin: 0 0 12px;
  font-size: 40px;
  line-height: 1.05;
  letter-spacing: var(--display-tracking);
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 20px;
  margin-bottom: 28px;
}

.pick-link {
  color: var(--neon);
  text-decoration: none;
}

.pick-link:hover {
  text-decoration: underline;
  text-decoration-thickness: 0.5px;
  text-underline-offset: 6px;
}

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

.tile {
  min-width: 0;
}

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

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

.tile .qty.is-words {
  font-size: 15px;
  font-weight: 300;
  line-height: 1.3;
  white-space: normal;
}

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

.map-error {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 6;
  max-width: 24rem;
  margin: 0;
  transform: translate(-50%, -50%);
  text-align: center;
}

/* ---------- MapLibre's own ---------- */

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

.maplibregl-ctrl-attrib {
  background: rgb(8 8 8 / 0.75) !important;
  max-width: 520px;
  font-size: 10px;
}

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

.deck-tooltip .tooltip-meta {
  color: var(--ink-3);
  font-size: 11px;
}

/* ---------- A phone: the index lies along the bottom, as a list in two columns ---------- */

@media (max-width: 860px) {
  .topbar {
    padding: 20px var(--gutter) 0;
  }

  .map-controls {
    top: 16px;
    gap: 16px;
  }

  .map-buttons {
    bottom: auto;
    top: 64px;
  }

  .index {
    top: auto;
    right: 0;
    width: auto;
    max-height: 46dvh;
    padding: 34px var(--gutter) max(14px, env(safe-area-inset-bottom));
    background: linear-gradient(rgb(8 8 8 / 0), rgb(8 8 8 / 0.9) 34px, rgb(8 8 8 / 0.95));
    -webkit-mask-image: none;
    mask-image: none;
  }

  .search {
    margin-bottom: 10px;
    padding-bottom: 6px;
  }

  /* Any smaller, and a phone zooms in on it when it's tapped */
  .search input {
    font-size: 16px;
  }

  .index.searching {
    max-height: 60dvh;
  }

  .clock {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 8px;
  }

  .hero-value {
    margin: 0;
    font-size: 26px;
    letter-spacing: -0.02em;
  }

  .hero-value .qty-u {
    margin-left: 3px;
    font-size: 12px;
  }

  .clock .hero-sub {
    margin: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .rows {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 16px;
  }

  .row,
  .row:last-child {
    border-top: 1px solid var(--ink-5);
    border-bottom: 0;
  }

  .row-toggle {
    grid-template-columns: 11px 1fr auto;
    gap: 0 5px;
    padding: 7px 0;
  }

  .row-value {
    font-size: 15px;
  }

  .row-unit,
  .row-note,
  .row-link,
  #overview .coverage {
    display: none;
  }

  .row-name {
    font-size: 9px;
    letter-spacing: 0.12em;
  }

  .pick-title {
    margin-bottom: 6px;
    font-size: 26px;
  }

  #pick .hero-sub {
    margin-bottom: 12px;
  }

  #pick .actions {
    margin-bottom: 16px;
  }

  .figures {
    gap: 14px 16px;
  }

  .tile .qty {
    font-size: 20px;
  }

  .maplibregl-ctrl-bottom-right {
    top: 132px;
    bottom: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
