/* ==========================================================================
   LOCATION MAP — "Dhaka at night". The WebGL map is the ground; this file
   styles what sits over it: the frosted panel (heading, categories, nearby
   places), the project card rail, the map controls, and the HTML labels the
   module positions over the 3D scene each frame.
   States set by js/location-map.js on .loc:
     is-live      the section has entered the viewport and the intro runs
     is-labelled  district and project labels fade in
     is-selected  re-added on every selection (restarts the callout reveal)
     is-2d        top-down map mode
   ========================================================================== */

.loc {
  --loc-top: clamp(84px, 10vh, 120px);
  --loc-rail-h: 96px;
  --loc-glass: rgb(var(--scrim) / .62);
  --loc-line: rgb(208 173 103 / .2);
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 760px;
  max-height: 1100px;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(120% 80% at 60% 60%, #0f2740 0%, #071324 55%, #040d18 100%);
  color: var(--c-ivory);
  /* An ivory pause before the next dark scene (Architecture), the same size
     as the gap Featured projects leaves above the map. The page ground shows
     through the margin. */
  margin-block-end: var(--section-gap);
}

/* the gold seam where the section begins, as the footer has */
.loc::before {
  content: "";
  position: absolute;
  z-index: 4;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--c-gold) 30%, #f3dfae 50%, var(--c-gold) 70%, transparent);
  opacity: .7;
  pointer-events: none;
}

/* --- the map stage ------------------------------------------------------- */
.loc__stage {
  position: absolute;
  inset: 0;
}

.loc__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: pan-y;               /* a finger scrolls the page; the buttons steer */
  opacity: 0;
  transition: opacity 1.2s var(--ease-css);
}
.loc.is-live .loc__canvas { opacity: 1; }
.loc__stage.is-dragging .loc__canvas { cursor: grabbing; }

/* Shade: the panel side and the card rail get their own legibility, so the
   map itself is never dimmed. */
.loc__shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(to right, rgb(var(--scrim) / .7), transparent 42%),
    linear-gradient(to top, rgb(var(--scrim) / .75), transparent 24%),
    linear-gradient(to bottom, rgb(var(--scrim) / .5), transparent 16%);
}

.loc__overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

/* Every label is pinned at 0,0 and moved by the module with translate3d. */
.loc__label {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
  white-space: nowrap;
}
/* stepped out by the declutter pass while it would overlap a higher label */
.loc__label.is-clipped { opacity: 0 !important; pointer-events: none; }

.loc__label--district {
  translate: -50% -50%;
  font-size: 11px;
  font-weight: var(--fw-semi);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--c-mist);
  opacity: 0;
  transition: opacity 1s var(--ease-css);
}
.loc.is-labelled .loc__label--district { opacity: .55; }

/* Project tags ride above their beacons and select on click. */
.loc__label--project {
  translate: -50% -100%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border: 1px solid rgb(248 245 239 / .16);
  border-radius: var(--r-pill);
  background: rgb(var(--scrim) / .7);
  backdrop-filter: blur(8px);
  font-size: var(--fs-label);
  font-weight: var(--fw-semi);
  letter-spacing: .06em;
  color: var(--c-ivory);
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  transition: opacity .8s var(--ease-css), border-color var(--dur-fast) var(--ease-css),
              background-color var(--dur-fast) var(--ease-css);
}
.loc.is-labelled .loc__label--project { opacity: 1; }
.loc__label--project:hover,
.loc__label--project:focus-visible { border-color: var(--c-gold); }
.loc__label--project.is-active { opacity: 0 !important; pointer-events: none; }   /* the callout takes over */

.loc__label-num {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--c-gold);
  color: var(--c-navy);
  font-size: 10px;
  letter-spacing: 0;
}

/* Nearby places: a gold dot always, the name and distance only for the
   active category. */
.loc__label--place {
  translate: -6px -50%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity .6s var(--ease-css);
}
.loc__label--place.is-on { opacity: 1; }
.loc__label-dot {
  width: 12px;
  height: 12px;
  border: 2px solid var(--c-gold);
  border-radius: 50%;
  background: var(--c-navy-deep);
  box-shadow: 0 0 0 4px rgb(208 173 103 / .15);
  transition: transform var(--dur-fast) var(--ease-css), background-color var(--dur-fast) var(--ease-css);
}
.loc__label-text {
  display: grid;
  padding: 5px 10px;
  border-radius: 6px;
  background: rgb(var(--scrim) / .72);
  backdrop-filter: blur(6px);
}
.loc__label-place { font-size: 12px; font-weight: var(--fw-semi); color: var(--c-ivory); }
.loc__label-km { font-size: 11px; font-variant-numeric: tabular-nums; color: var(--c-gold); }
.loc__label--place.is-hot .loc__label-dot { transform: scale(1.35); background: var(--c-gold); }
.loc__label--place.is-hot .loc__label-text { outline: 1px solid var(--c-gold); }

.loc__label--ring {
  translate: -50% -50%;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: rgb(var(--scrim) / .8);
  font-size: 10px;
  font-weight: var(--fw-semi);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--c-gold);
  opacity: 0;
  transition: opacity .8s var(--ease-css) .6s;
}
.loc.is-selected .loc__label--ring { opacity: 1; }

/* The selected project's card, pinned above its beacon. The outer box is
   positioned by the module (inline transform); the reveal animates the inner
   one, so the animation can never overwrite the position. */
.loc__callout {
  translate: -50% calc(-100% - 8px);
  width: 230px;
  white-space: normal;
  pointer-events: auto;
}
.loc__callout-in {
  position: relative;
  padding: 16px 18px 14px;
  border: 1px solid var(--loc-line);
  border-top: 2px solid var(--c-gold);
  border-radius: var(--r-card);
  background: rgb(var(--scrim) / .82);
  backdrop-filter: blur(12px);
  box-shadow: 0 24px 60px rgb(0 0 0 / .35);
  opacity: 0;
}
.loc.is-selected .loc__callout-in { animation: loc-callout .9s var(--ease-css) .5s both; }
@keyframes loc-callout {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* the stem from the card down to the beacon */
.loc__callout-in::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1px;
  height: 8px;
  background: var(--c-gold);
}
.loc__callout-status {
  font-size: 10px;
  font-weight: var(--fw-bold);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--c-gold);
}
.loc__callout-name {
  margin-block-start: 4px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: var(--fw-medium);
  line-height: 1.1;
  color: var(--c-ivory);
}
.loc__callout-meta { margin-block: 2px 12px; font-size: 13px; color: var(--c-mist); }
.loc__callout-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  gap: 10px;
  font-size: var(--fs-label);
  font-weight: var(--fw-semi);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--c-gold);
}
.loc__callout-link svg { width: 22px; height: 10px; transition: translate var(--dur-fast) var(--ease-css); }
.loc__callout-link:hover svg { translate: 4px 0; }

/* --- controls ------------------------------------------------------------- */
.loc__controls {
  position: absolute;
  z-index: 3;
  top: var(--loc-top);
  right: calc((100% - var(--container)) / 2);
  display: grid;
  gap: 8px;
}
.loc__ctrl {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgb(248 245 239 / .18);
  border-radius: 50%;
  background: rgb(var(--scrim) / .6);
  backdrop-filter: blur(8px);
  color: var(--c-ivory);
  font-size: 11px;
  font-weight: var(--fw-bold);
  letter-spacing: .08em;
  transition: background-color var(--dur-fast) var(--ease-css), color var(--dur-fast) var(--ease-css),
              border-color var(--dur-fast) var(--ease-css);
}
.loc__ctrl svg { width: 16px; height: 16px; }
.loc__ctrl:hover,
.loc__ctrl:focus-visible,
.loc__ctrl[aria-pressed="true"] { background: var(--c-gold); border-color: var(--c-gold); color: var(--c-navy); }
.loc__ctrl-gap { height: 6px; }

.loc__credit {
  position: absolute;
  z-index: 3;
  right: calc((100% - var(--container)) / 2);
  bottom: calc(var(--loc-rail-h) + 36px);
  font-size: 10px;
  letter-spacing: .04em;
  color: rgb(184 196 207 / .6);
}

/* --- the panel and the rail ---------------------------------------------- */
.loc__ui {
  position: absolute;
  inset: 0;
  z-index: 3;
  margin-inline: auto;
  pointer-events: none;
}
.loc__ui > * { pointer-events: auto; }

.loc__panel {
  position: absolute;
  top: var(--loc-top);
  left: 0;
  width: min(400px, 34%);
  max-height: calc(100% - var(--loc-top) - var(--loc-rail-h) - 56px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px 26px 22px;
  border: 1px solid var(--loc-line);
  border-radius: var(--r-card);
  background: var(--loc-glass);
  backdrop-filter: blur(16px);
  scrollbar-width: thin;
  scrollbar-color: rgb(208 173 103 / .4) transparent;
  /* a soft fade at the foot: on short screens the list scrolls in here */
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent);
          mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent);
}

.loc__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: var(--fs-label);
  font-weight: var(--fw-semi);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--c-gold);
}
.loc__eyebrow::before { content: ""; width: 28px; height: 1px; background: currentColor; }

.loc__h {
  margin-block-start: 12px;
  font-family: var(--font-display);
  font-size: clamp(34px, 3.2vw, 52px);
  font-weight: var(--fw-medium);
  line-height: 1.04;
  letter-spacing: -.015em;
  color: var(--c-ivory);
}
.loc__lead {
  margin-block-start: 12px;
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--c-mist);
}

.loc__summary {
  display: grid;
  gap: 2px;
  margin-block: 20px 14px;
  padding-block-start: 16px;
  border-top: 1px solid rgb(248 245 239 / .1);
}
.loc__summary-k { font-family: var(--font-display); font-size: 22px; font-weight: var(--fw-semi); color: var(--c-ivory); }
.loc__summary-v { font-size: 12px; font-weight: var(--fw-semi); letter-spacing: .12em; text-transform: uppercase; color: var(--c-gold); }
.loc__summary-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-block-start: 8px;
  font-size: 12px;
  font-weight: var(--fw-semi);
  color: var(--c-ivory);
}
.loc__summary-specs span + span::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 3px;
  margin-inline-end: 14px;
  border-radius: 50%;
  background: var(--c-gold);
  vertical-align: middle;
}

.loc__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.loc__chip {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid rgb(248 245 239 / .16);
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: var(--fw-semi);
  letter-spacing: .04em;
  color: var(--c-mist);
  transition: background-color var(--dur-fast) var(--ease-css), color var(--dur-fast) var(--ease-css),
              border-color var(--dur-fast) var(--ease-css);
}
.loc__chip:hover { border-color: var(--c-gold); color: var(--c-ivory); }
.loc__chip.is-active { background: var(--c-gold); border-color: var(--c-gold); color: var(--c-navy); }

.loc__list { margin-block-start: 14px; display: grid; }
.loc__place {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) 64px 56px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 6px 4px;
  border-bottom: 1px solid rgb(248 245 239 / .07);
  text-align: start;
  transition: background-color var(--dur-fast) var(--ease-css);
}
.loc__place:hover,
.loc__place:focus-visible { background: rgb(208 173 103 / .08); }
.loc__place-dot { width: 8px; height: 8px; border: 1.5px solid var(--c-gold); border-radius: 50%; }
.loc__place:hover .loc__place-dot { background: var(--c-gold); }
.loc__place-name { font-size: 13px; font-weight: var(--fw-semi); color: var(--c-ivory); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loc__place-bar { height: 2px; background: rgb(248 245 239 / .1); border-radius: 2px; overflow: hidden; }
.loc__place-bar > span { display: block; width: var(--w); height: 100%; background: linear-gradient(90deg, var(--c-gold), rgb(208 173 103 / .4)); }
.loc__place-km { font-size: 13px; font-weight: var(--fw-semi); font-variant-numeric: tabular-nums; text-align: end; color: var(--c-gold); }

.loc__note { margin-block-start: 12px; font-size: 11px; color: rgb(184 196 207 / .7); }

/* The project rail: one card per project along the foot of the map. */
.loc__rail {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 24px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.loc__card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: var(--loc-rail-h);
  padding: 10px;
  border: 1px solid rgb(248 245 239 / .1);
  border-radius: var(--r-card);
  background: var(--loc-glass);
  backdrop-filter: blur(12px);
  text-align: start;
  transition: border-color var(--dur-fast) var(--ease-css), background-color var(--dur-fast) var(--ease-css),
              translate .4s var(--ease-css);
}
.loc__card:hover { border-color: rgb(208 173 103 / .5); translate: 0 -3px; }
.loc__card.is-active {
  border-color: var(--c-gold);
  background: rgb(15 44 72 / .78);
  box-shadow: inset 0 2px 0 var(--c-gold), 0 16px 40px rgb(0 0 0 / .3);
}
.loc__card-img { width: 56px; height: 72px; object-fit: cover; border-radius: 6px; }
.loc__card-text { display: grid; gap: 2px; min-width: 0; }
.loc__card-num { font-size: 10px; font-weight: var(--fw-bold); letter-spacing: .14em; color: var(--c-gold); }
/* Up to two lines, so a long name wraps rather than being cut off. */
.loc__card-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: var(--fw-semi);
  line-height: 1.12;
  color: var(--c-ivory);
}
.loc__card-area { font-size: 11px; font-weight: var(--fw-semi); letter-spacing: .08em; text-transform: uppercase; color: var(--c-mist); }

/* Touch and mid widths: the cards drop their frosted blur — a backdrop
   filter on every card is costly while a phone scrolls — and take a more
   opaque ground instead, which reads the same over the dark map. */
@media (max-width: 1199px), (pointer: coarse) {
  .loc__card { backdrop-filter: none; background: rgb(var(--scrim) / .86); }
}

/* --- fallback: no WebGL — the panel and rail still work ------------------- */
.loc--fallback .loc__canvas,
.loc--fallback .loc__controls,
.loc--fallback .loc__credit { display: none; }
/* the stage keeps the blueprint grid, so the panel still sits on a drawing */
.loc--fallback .loc__stage {
  background-image:
    linear-gradient(rgb(208 173 103 / .08) 1px, transparent 1px),
    linear-gradient(90deg, rgb(208 173 103 / .08) 1px, transparent 1px);
  background-size: 64px 64px;
}
@media (max-width: 959px) {
  .loc--fallback .loc__stage { display: none; }
}

/* --- narrow: map first, then the rail and the panel in the flow ------------ */
/* Mid widths: the cards become one row that scrolls sideways (most screens
   this size are tablets, where a swipe is natural), so the panel and the map
   keep their height. */
@media (max-width: 1199px) {
  .loc__rail {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(230px, 1fr);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }
  .loc__rail::-webkit-scrollbar { display: none; }
  .loc__card { scroll-snap-align: start; }
}

/* Narrow: one column in reading order — the heading, the map, the cards,
   then the details. The panel and its wrapper dissolve (display: contents)
   so their parts can sit either side of the map. */
@media (max-width: 959px) {
  .loc { display: flex; flex-direction: column; height: auto; max-height: none; min-height: 0; }
  .loc__ui,
  .loc__panel { display: contents; }

  .loc__head {
    order: 1;
    width: var(--container);
    margin-inline: auto;
    padding-block: var(--sp-xl) var(--sp-md);
  }
  .loc__h { font-size: clamp(36px, 8vw, 56px); }

  .loc__stage { order: 2; position: relative; height: 66vh; min-height: 440px; max-height: 720px; }
  .loc__shade { background: linear-gradient(to top, rgb(var(--scrim) / .6), transparent 30%), linear-gradient(to bottom, rgb(var(--scrim) / .55), transparent 22%); }
  .loc__controls { top: 14px; right: 14px; gap: 6px; }
  .loc__ctrl-gap { display: none; }
  .loc__credit { bottom: 10px; right: 14px; }

  .loc__rail {
    order: 3;
    position: static;
    width: var(--container);
    margin: var(--sp-md) auto 0;
    grid-auto-columns: minmax(240px, 72%);
    padding-block-end: 4px;
  }

  .loc__body {
    order: 4;
    width: var(--container);
    margin: var(--sp-md) auto var(--sp-xl);
    padding: 24px 22px 20px;
    border: 1px solid var(--loc-line);
    border-radius: var(--r-card);
    background: var(--loc-glass);
  }
  .loc__body .loc__summary { margin-block-start: 0; padding-block-start: 0; border-top: 0; }

  .loc__callout { width: 210px; }
}

@media (prefers-reduced-motion: reduce) {
  .loc__canvas,
  .loc__label--district,
  .loc__label--project,
  .loc__label--ring { transition: none; }
  .loc.is-selected .loc__callout-in { animation: none; opacity: 1; }
}
