:root {
  --red: #ff2d21;
  --ink: #201f1d;
  --muted: #6d6a63;
  --line: rgba(32, 31, 29, 0.12);
  --sidebar-width: 380px;
  --peek-height: 68px;
  --peek-selected-height: 168px;
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: #fff;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
}

/* ── layout ─────────────────────────────────────────────────────────── */

#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

#sheet {
  order: 0;
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  min-height: 0;
}

#map {
  order: 1;
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  touch-action: none;
  background: #f1f1ee;
}

#viewport {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  background: #f1f1ee;
}

/* ── list ───────────────────────────────────────────────────────────── */

#sheet-head {
  display: none;
}

#sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  --pad-top: 28px;
  padding: var(--pad-top) 20px 28px 24px;
}

.brand h1 {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 2px;
  padding-left: 8px;
}

.brand p {
  margin: 0 0 48px;
  padding-left: 8px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.group h2 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 26px 0 8px;
  padding-left: 8px; /* same inset as the rows, so headings line up with the badges */
}

.group:first-child h2 {
  margin-top: 0;
}

.group ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tenant-row {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 7px 8px;
  margin: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background-color 120ms ease;
}

.tenant-row--static {
  cursor: default;
}

.tenant-row:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.tenant.is-active > .tenant-row {
  background: #fdecea;
}

/* The selected tenant's headline stays at the top of the list until the
   last of its exhibitors has scrolled past (sticky is bounded by the <li>). */
.tenant.is-pinned > .tenant-row {
  position: sticky;
  top: calc(-1 * var(--pad-top)); /* flush with the top edge, not below the padding */
  z-index: 3;
  background: #fdecea;
  box-shadow: 0 6px 8px -6px rgba(32, 31, 29, 0.18);
}

.badge {
  flex-shrink: 0;
  min-width: 34px;
  height: 34px;
  padding: 0 7px;
  border-radius: 17px;
  background: var(--red);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.badge--dot {
  padding: 0;
  width: 34px;
}

.tenant-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-top: 5px;
  min-width: 0;
}

.tenant-name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
}

.tenant.is-pinned .tenant-name {
  color: var(--red);
}

.tenant-hint {
  font-size: 12px;
  color: var(--muted);
}

/* Exhibitor list: folds open under the pinned tenant. */
.tenant-more {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 220ms ease;
}

.tenant.is-pinned .tenant-more {
  grid-template-rows: 1fr;
}

.exhibitors {
  overflow: hidden;
  padding: 0 8px 0 54px !important;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}

.tenant.is-pinned .exhibitors {
  padding-bottom: 10px !important;
}

/* Legend */

.legend {
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.credits {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 20px;
  margin: 18px 0 0; /* matches the legend's 18px above its content */
  padding: 13px 0 0 8px; /* + the 5px row padding = 18px to the first line */
  border-top: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.4;
}

.credits dt {
  color: var(--muted);
}

.credits dd {
  margin: 0;
}

.credits dt,
.credits dd {
  padding: 5px 0; /* comfortable tap height for the links */
}

.credits a {
  color: var(--red);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.legend ul {
  list-style: none;
  margin: 0;
  padding: 0 0 0 8px; /* same inset as the rows */
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  font-size: 13px;
  font-weight: 700;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lg {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: var(--ink);
}

.lg svg {
  width: 15px;
}

.lg--pin {
  background: var(--red);
}

.lg--P {
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 0 0 2.5px var(--ink);
}

.lg--U {
  border-radius: 6px;
}

.lg--wc {
  font-size: 9px;
}

.lg--rundgang {
  background: none;
  border-radius: 0;
  height: 0;
  border-top: 3px dashed var(--red);
}

/* ── map controls ───────────────────────────────────────────────────── */

.map-brand {
  display: none;
}

.view-toggle {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  padding: 3px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 0 1px var(--line), 0 4px 16px rgba(0, 0, 0, 0.08);
  z-index: 10000;
}

.view-toggle button {
  border: 0;
  background: none;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.view-toggle button[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
}

/* ── overlay on the map ─────────────────────────────────────────────── */

.overlay {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.pin,
.poi,
.dir-marker {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
}

.pin-button {
  pointer-events: auto;
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, calc(-100% - 8px));
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border: 1.5px solid #fff;
  border-radius: 12px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity 200ms ease, transform 120ms ease;
}

/* a bigger invisible hit area for fingers */
.pin-button::before {
  content: "";
  position: absolute;
  inset: -8px;
}

/* Door on the far side of the building from this angle: still clickable,
   just a touch quieter. Selecting it turns the building round. */
.pin.is-away .pin-button {
  opacity: 0.72;
}

.pin.is-active .pin-button {
  opacity: 1;
  transform: translate(-50%, calc(-100% - 8px)) scale(1.18);
  box-shadow: 0 0 0 2.5px var(--ink);
}

.pin-button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* The selected pin: number and name share one white pill with an ink
   outline. The pill sits behind the red number (which keeps its place),
   --btn-w (set from overlay.js) is the number's width so the pill can wrap
   around it on whichever side the name opens. */
.pin-tag {
  position: absolute;
  top: -20px; /* centred on the number */
  left: calc(var(--btn-w, 24px) / -2 - 4px);
  transform: translateY(-50%);
  z-index: 1;
  min-height: 32px;
  padding: 4px 14px 4px calc(var(--btn-w, 24px) + 12px);
  display: flex;
  align-items: center;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 0 0 2.5px var(--ink), 0 3px 10px rgba(0, 0, 0, 0.12);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  width: max-content; /* long names wrap instead of being cut off */
  max-width: min(260px, 46vw);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.pin.flip .pin-tag {
  left: auto;
  right: calc(var(--btn-w, 24px) / -2 - 4px);
  padding: 4px calc(var(--btn-w, 24px) + 12px) 4px 14px;
}

.pin.has-tag .pin-tag {
  opacity: 1;
}

.pin.has-tag .pin-button {
  z-index: 2;
  transform: translate(-50%, calc(-100% - 8px)); /* no scale: the pill is the emphasis */
  box-shadow: none;
}

/* Zoomed out on a small screen the pins collapse to dots; the active one
   (and everything once you zoom in) stays a full badge. */
.is-compact .pin:not(.is-active) .pin-button {
  min-width: 12px;
  width: 12px;
  height: 12px;
  padding: 0;
  font-size: 0;
  border-width: 1.5px;
}

/* WC / food, stacked above the number of the pin they belong to. */
.pin-pois {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, calc(-100% - 35px)); /* 8px above the anchor + 24px button + the 3px gap */
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: none;
}

.pin.is-active .pin-pois {
  transform: translate(-50%, calc(-100% - 38px)); /* the active button is scaled up */
}

.pin.has-tag .pin-pois {
  transform: translate(-50%, calc(-100% - 44px)); /* clear of the pill and its outline */
}

.pin.is-away .pin-pois {
  opacity: 0.72;
}

.is-compact .pin:not(.is-active) .pin-pois {
  transform: translate(-50%, calc(-100% - 23px)); /* 8px + 12px dot + 3px */
}

.pin-pois .poi {
  position: relative;
}

/* a door with icons but no tenant: no number underneath */
.pin.pin--bare .pin-pois {
  transform: translate(-50%, calc(-100% - 8px));
}

.is-compact .pin.pin--bare .pin-pois {
  transform: translate(-50%, calc(-100% - 6px));
}

.poi {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 8.5px;
  font-weight: 800;
}

.poi svg {
  width: 14px;
}

.is-compact .poi {
  width: 16px;
  height: 16px;
  font-size: 0;
}

.is-compact .poi--wc {
  font-size: 6.5px;
}

.is-compact .poi svg {
  width: 10px;
}

.dir-marker {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--ink);
}

.dir-arrow {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
}

.dir-arrow svg {
  width: 100%;
}

.chip {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}

.chip--U {
  border-radius: 7px;
}

.chip--P {
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 0 0 3px var(--ink);
}

.compass {
  position: absolute;
  right: 18px;
  bottom: 22px;
  width: 34px;
  height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 800;
}

.compass svg {
  width: 22px;
  height: 22px;
}

/* ── phones & small tablets: map on top, list as a bottom sheet ─────── */

@media (max-width: 1000px) {
  #app {
    flex-direction: column;
  }

  #map {
    order: 0;
  }

  #sheet {
    order: 1;
    width: 100%;
    border-right: 0;
    border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.08);
    height: calc(var(--peek-height) + env(safe-area-inset-bottom) + 1px);
    overflow: hidden;
    transition: height 280ms cubic-bezier(0.3, 0.8, 0.3, 1);
    z-index: 2;
    background: #fff;
  }

  #sheet[data-state="open"] {
    height: 62dvh;
  }

  /* A tenant is selected and the sheet is collapsed: no title (its row is
     right below, scrolled to the top), just a taller strip of the list. */
  #sheet[data-state="peek"][data-selected] {
    height: calc(var(--peek-selected-height) + env(safe-area-inset-bottom));
  }

  #sheet[data-state="peek"][data-selected] #sheet-head {
    height: 24px;
  }

  #sheet[data-state="peek"][data-selected] #sheet-title {
    display: none;
  }

  #sheet-head {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    flex-shrink: 0;
    height: var(--peek-height);
    padding: 8px 14px 0;
    border: 0;
    background: none;
    text-align: left;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    touch-action: none;
  }

  #sheet-head #sheet-title {
    padding-left: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 34px;
  }

  .grabber {
    align-self: center;
    width: 38px;
    height: 4px;
    border-radius: 2px;
    background: rgba(32, 31, 29, 0.22);
  }

  #sheet-body {
    --pad-top: 4px;
    padding: var(--pad-top) 14px 28px;
  }

  .brand {
    display: none;
  }

  .map-brand {
    display: flex;
    align-items: center;
    position: absolute;
    left: 16px;
    top: calc(10px + env(safe-area-inset-top));
    height: 36.5px; /* the toggle's height: both sit on one centre line */
    font-size: 17px;
    font-weight: 800;
    z-index: 10000;
  }

  .view-toggle {
    left: auto;
    right: 16px; /* same gutter as the headline and the compass */
    bottom: auto;
    top: calc(10px + env(safe-area-inset-top));
    transform: none;
  }

  .view-toggle button {
    padding: 8px 12px;
    font-size: 12px;
  }

  .compass {
    right: 14px;
    bottom: 14px;
  }

  .legend ul {
    grid-template-columns: 1fr 1fr;
  }

  .group h2 {
    font-size: 22px;
  }
}

@media (max-width: 400px) {
  .map-brand {
    font-size: 15px;
  }
}

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