/*
 * HUD over the map: title card, search box, minimap, info card, landmark strip,
 * toolbar (with the phone "More" pop-up), credits, and the phone layout.
 * Colours come from the tokens in map.css.
 */
.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding-block: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid;
  grid-template-columns: minmax(0, 300px) 1fr minmax(0, 360px);
  grid-template-rows: auto 1fr auto auto auto;
  gap: 12px;
}
.hud > * { pointer-events: auto; }

.card {
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: var(--pixel-shadow);
  min-width: 0;
}

.title-card { grid-column: 1; grid-row: 1; padding: 14px 16px 12px; align-self: start; }
.title-card h1 {
  margin: 0;
  font: 700 34px/1 var(--font-display);
  letter-spacing: 0.01em;
  text-wrap: balance;
}
.title-card .telugu { font: 500 17px/1.4 var(--font-telugu); color: var(--muted); margin: 4px 0 0; }
.title-card .coords { font: 500 11px/1.4 var(--font-mono); color: var(--muted); letter-spacing: 0.04em; margin: 6px 0 0; }
.title-card .hint { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
/* Today's weather and festival under the coordinates (js/weather.js, js/festivals.js). */
.title-card .sky-note { font: 500 11px/1.4 var(--font-mono); color: var(--muted); letter-spacing: 0.04em; margin: 4px 0 0; }
.sky-note-festival { color: var(--accent); }
.sky-note > span:not(:empty) ~ span:not(:empty)::before { content: ' · '; color: var(--muted); }
.title-card .status { margin: 8px 0 0; font: 500 12px/1.4 var(--font-mono); color: var(--accent); }
.info-note { padding: 8px 10px; background: var(--chip); border-left: 3px solid var(--accent); font-size: 14px; }
.credits {
  grid-column: 1 / -1;
  grid-row: 5;
  justify-self: center;
  text-align: center;
  max-width: 760px;
  padding: 2px 8px;
  font: 400 11px/1.4 var(--font-body);
  color: var(--muted);
  background: var(--panel);
}
.credits a { color: inherit; }

/* Search box column on the left. */
.left-column {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 8px;
  min-height: 0;
  pointer-events: none;
}
.left-column > * { pointer-events: auto; }
@media (min-width: 861px) {
  .left-column > .search-box { align-self: stretch; }
}
/* "● 2 here now · 1,280 visitors" just under the search box (js/visit-counter.js), in the same pixel-edged
   panel style as the search box and toolbar; the search results drop down over it. */
.visit-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 4px 10px;
  border: 2px solid var(--line);
  background: var(--panel);
  box-shadow: var(--pixel-shadow);
  font: 500 12px/1.4 var(--font-mono);
  color: var(--muted);
  white-space: nowrap;
  /* Live green, the usual "online" signal. */
  --live-dot: #2fa84f;
}
.visit-count strong { color: var(--ink); font-weight: 700; }
/* The live dot: a small square (pixel style) that breathes slowly. */
.visit-dot { width: 8px; height: 8px; background: var(--live-dot); box-shadow: 0 0 0 2px color-mix(in srgb, var(--live-dot) 25%, transparent); animation: visit-dot-pulse 2.4s ease-in-out infinite; }
@keyframes visit-dot-pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .visit-dot { animation: none; } }
.visit-count[hidden] { display: none; }
/* Phones only: today's weather, air and festival in a pill under the visitors (the title card that carries
   them on wider screens is folded away into the search box there). ui.js keeps it in step. */
.phone-sky-note { display: none; }
/* Overview map: small, in the bottom-right corner, its bottom edge level with the credits line, out of the way
   of the title and search (top-right corner on phones, where the bottom belongs to the toolbar). */
.minimap-dock { grid-column: 3; grid-row: 2 / -1; justify-self: end; align-self: end; position: relative; }
@media (min-width: 861px) {
  /* The landmark card and the unfolded landmark strip use the same corner; while either is open the map steps aside. */
  .hud:has(.info:not([hidden])) .minimap-dock,
  .hud:has(.landmark-strip:not(.is-collapsed)) .minimap-dock { display: none; }
}
/* Below this width the centred toolbar and credits would run into the map, so it sits just above the toolbar row. */
@media (min-width: 861px) and (max-width: 1180px) {
  .minimap-dock { grid-row: 2; }
}
.minimap { display: block; padding: 0; cursor: crosshair; line-height: 0; }
.minimap-toggle {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 24px;
  height: 24px;
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: 700 14px/1 var(--font-display);
  cursor: pointer;
}
/* Collapsed: only the toggle remains, showing a map glyph. */
.minimap-dock.is-collapsed .minimap { display: none; }
.minimap-dock.is-collapsed .minimap-toggle { position: static; width: 34px; height: 34px; box-shadow: 2px 2px 0 var(--line); }
.minimap-toggle:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* One-time gesture hint for phones, above the toolbar. */
.hint-toast {
  position: fixed;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--paper);
  font: 600 13px/1.3 var(--font-body);
  border: 2px solid var(--line);
  white-space: nowrap;
  pointer-events: none;
}
.title-card { transition: opacity 0.6s ease; }
.title-card.is-faded { opacity: 0; pointer-events: none; }
.minimap canvas { display: block; }
.minimap:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* Search box in the left column; its results drop down below it only while you search or browse. */
.search-box { position: relative; z-index: 3; flex: none; padding: 8px 10px; }
.search { display: flex; align-items: center; gap: 6px; padding: 0 8px; border: 2px solid var(--line); background: var(--paper); }
.search:focus-within { outline: 3px solid var(--accent); outline-offset: 1px; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: 400 14px/1 var(--font-body); padding: 8px 0; outline: none; }
.search kbd { font: 500 11px/1 var(--font-mono); color: var(--muted); border: 1px solid var(--muted); padding: 2px 5px; }
.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: min(60vh, 420px);
  overflow-y: auto;
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: var(--pixel-shadow);
}
.search-results { list-style: none; margin: 0; padding: 4px; }
.places-empty { margin: 0; padding: 10px 14px; color: var(--muted); font-size: 13px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.search-results button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  text-align: left;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 400 14px/1.3 var(--font-body);
  cursor: pointer;
}
.search-results button small { color: var(--muted); font: 500 10px/1.3 var(--font-mono); white-space: nowrap; }
.search-results button:hover { background: var(--chip); }
.search-results button[aria-current="true"] { background: var(--accent); color: var(--accent-ink); }
.search-results button[aria-current="true"] small { color: var(--accent-ink); }
.search-results button:focus-visible, .tool:focus-visible, .info-actions button:focus-visible, .info-close:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }

.info { overflow-x: hidden; grid-column: 3; grid-row: 1 / span 2; align-self: start; padding: 16px 18px 14px; max-height: 100%; overflow-y: auto; position: relative; }
.info-eyebrow { margin: 0 32px 6px 0; font: 500 11px/1.4 var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.info h2 { margin: 0 0 8px; font: 700 26px/1.05 var(--font-display); text-wrap: balance; }
.info p { margin: 0 0 10px; max-width: 62ch; }
.info ul { margin: 0 0 12px; padding-left: 18px; }
.info li { margin-bottom: 4px; font-size: 14px; }
.info li::marker { color: var(--accent); content: "◆  "; font-size: 10px; }
.info-telugu { margin: -4px 0 10px; font: 500 17px/1.4 var(--font-telugu); color: var(--muted); }
.info-model {
  box-sizing: border-box;
  display: block;
  width: 100%;
  height: 180px;
  margin: 0 0 12px;
  background: var(--chip);
  border: 2px solid var(--line);
}
.info-model[hidden] { display: none; }
.info-table {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  margin: 0 0 12px;
  padding: 10px 12px;
  background: var(--chip);
  font-size: 13px;
}
.info-table[hidden] { display: none; }
.info-table dt { font: 500 11px/1.6 var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.info-table dd { margin: 0; }
.info-about h3 { margin: 4px 0 6px; font: 700 13px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.08em; }
.info-about p { font-size: 14px; }
.info-about[hidden], .info-links [hidden] { display: none; }
.info-questions details { border-top: 1px solid var(--chip); padding: 6px 0; }
.info-questions summary { cursor: pointer; font-weight: 700; font-size: 14px; }
.info-questions details p { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.info-links { margin: 4px 0 12px; font-size: 14px; }
.info-links a { color: var(--accent); }
.info-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: 700 16px/1 var(--font-display);
  cursor: pointer;
}
.info-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.info-actions button {
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 7px 12px;
  font: 600 13px/1 var(--font-display);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--line);
}
.info-actions button.primary { background: var(--accent); color: var(--accent-ink); }
.info-actions button:active { transform: translate(2px, 2px); box-shadow: none; }

.toolbar {
  grid-column: 1 / -1;
  grid-row: 4;
  justify-self: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  padding: 6px;
}
.tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border: 2px solid transparent;
  background: transparent;
  color: var(--ink);
  font: 600 13px/1 var(--font-display);
  cursor: pointer;
  justify-content: center;
}
.tool:hover { background: var(--chip); }
.tool[aria-pressed="true"] { border-color: var(--line); background: var(--chip); }
.tool svg { width: 18px; height: 18px; shape-rendering: crispEdges; fill: currentColor; flex: none; }
.tool-group { display: inline-flex; gap: 2px; }
/* Secondary tools sit inline on wide screens and fold into a "More" pop-up on phones. */
.toolbar { position: relative; }
/* Secondary tools (transit, zoom, rotate, view toggles) live in a pop-up above the "More" button, at every
   screen size, so the toolbar itself stays a short row. */
.tool-more { display: inline-flex; }
.tool-extras {
  display: none;
  position: absolute;
  right: -2px;
  bottom: calc(100% + 8px);
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 2px;
  width: 196px;
  padding: 4px;
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: var(--pixel-shadow);
}
.tool-extras.is-open { display: flex; }
.tool-extras .tool-divider { display: none; }
.tool-extras .tool-text:not(.keep-text) { display: none; }
.tool-divider { width: 2px; align-self: stretch; background: var(--line); opacity: 0.25; margin: 4px 2px; }


.landmark-strip {
  grid-column: 1 / -1;
  grid-row: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 8px;
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: var(--pixel-shadow);
}
.landmark-strip ol {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}
.landmark-strip ol::-webkit-scrollbar { display: none; }
.landmark-strip li { scroll-snap-align: center; flex: none; }
.strip-card {
  display: flex;
  flex-direction: column;
  width: 132px;
  padding: 0;
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.strip-card img { display: block; width: 100%; height: 72px; object-fit: cover; background: var(--chip); }
.strip-caption { display: grid; grid-template-columns: auto 1fr; gap: 0 6px; padding: 5px 6px 6px; align-items: baseline; }
.strip-number { grid-row: span 3; font: 700 11px/1 var(--font-mono); background: var(--ink); color: var(--paper); padding: 3px 5px; }
.strip-name { font: 600 12px/1.15 var(--font-display); }
.strip-telugu { grid-column: 2; font: 500 11px/1.3 var(--font-telugu); color: var(--muted); }
.strip-caption small { grid-column: 2; font: 500 10px/1.3 var(--font-mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip-card:hover { background: var(--chip); }
.strip-card[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.strip-card[aria-current="true"] .strip-number { background: var(--accent); color: var(--accent-ink); }
.strip-card:focus-visible, .strip-arrow:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.landmark-strip { position: relative; }
.strip-toggle {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: 600 12px/1.2 var(--font-display);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--line);
  white-space: nowrap;
}
.strip-toggle:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* Folded: only the "Landmarks" tab remains, sitting on the toolbar's top edge. */
.landmark-strip.is-collapsed { padding: 0; border: 0; background: none; box-shadow: none; height: 0; }
.landmark-strip.is-collapsed ol, .landmark-strip.is-collapsed .strip-arrow { display: none; }
.title-card.is-compact .hint, .title-card.is-compact .coords { display: none; }
.strip-arrow {
  flex: none;
  width: 30px;
  height: 30px;
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: 700 18px/1 var(--font-display);
  cursor: pointer;
}

.fatal { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; }
.fatal .card { padding: 20px; max-width: 420px; }
.fatal h2 { margin: 0 0 8px; font: 700 22px/1.1 var(--font-display); }

@media (max-width: 860px) {
  /* One top bar: search (and the title before it fades) on the left, the overview map on the right, sharing a top
     edge. --top-bar-map-room is the map's width (96 px canvas + 2 px borders) plus the gap. */
  .hud { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto auto auto; gap: 8px; --top-bar-map-room: 108px; }
  /* Landmarks strip: folded to a small tab on the toolbar's left edge; open, one swipeable row of compact cards
     (picture and name) that snaps a card at a time. It folds again after a pick (ui.js) and stays out of the way
     while the landmark card, which uses the same space, is open. */
  .landmark-strip { padding: 6px; }
  .hud:has(.info:not([hidden])) .landmark-strip { display: none; }
  .strip-toggle { left: 0; transform: none; top: -28px; padding: 3px 10px; }
  .strip-arrow { display: none; }
  .landmark-strip ol { gap: 6px; scroll-snap-type: x mandatory; scroll-padding-left: 0; }
  .landmark-strip li { scroll-snap-align: start; }
  .strip-card { width: 104px; height: 100%; }
  /* Two lines at most, so one long name (NTR Gardens & Lumbini Park) can't make the whole row taller. */
  .strip-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .strip-card img { height: 56px; }
  .strip-caption { padding: 4px 5px 5px; }
  .strip-telugu, .strip-caption small { display: none; }
  .credits { grid-row: 5; font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .credits-extra { display: none; }
  /* The title sits over the search box on arrival and fades into it, so it never leaves a gap behind. */
  /* Opaque (the panels are slightly see-through), since it sits over the search box. */
  .title-card { background: var(--paper); grid-column: 1; grid-row: 1; z-index: 4; margin-right: var(--top-bar-map-room); padding: 6px 10px 7px; align-self: start; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
  .title-card h1 { font-size: 20px; }
  .title-card .telugu { font-size: 13px; margin: 0; }
  .title-card .hint, .title-card .coords, .title-card .sky-note, .title-card .telugu-tagline { display: none; }
  .title-card .status { flex-basis: 100%; margin-top: 2px; }
  .search-box { grid-column: 1; grid-row: 1; margin-right: var(--top-bar-map-room); align-self: start; padding: 4px; }
  /* One border, not a field inside a card. */
  .search-box .search { border: 0; }
  /* Under the search box in the top bar: the box is 45 px tall, plus the 8 px gap. */
  .visit-count { grid-column: 1; grid-row: 1; justify-self: start; align-self: start; margin-top: 53px; }
  /* The arrival title is taller than the search box, so the count waits until the title has faded. */
  .title-card:not(.is-faded) ~ .left-column .visit-count { visibility: hidden; }
  /* Under the visitors pill (29 px tall, plus the 8 px gap), or in its place when there is no count to show. */
  .phone-sky-note:not([hidden]) {
    display: inline-flex; grid-column: 1; grid-row: 1; justify-self: start; align-self: start; margin: 90px 0 0;
    padding: 3px 9px; border: 2px solid var(--line); background: var(--panel); box-shadow: var(--pixel-shadow);
    font: 500 11px/1.4 var(--font-mono); color: var(--muted); white-space: nowrap; max-width: calc(100% - var(--top-bar-map-room));
    overflow: hidden; text-overflow: ellipsis;
  }
  .visit-count[hidden] ~ .phone-sky-note { margin-top: 53px; }
  .title-card:not(.is-faded) ~ .left-column .phone-sky-note { visibility: hidden; }
  /* On phones the column dissolves so the search box and the minimap return to their own grid cells. */
  .left-column { display: contents; }
  .minimap-dock { grid-column: 1; grid-row: 1; justify-self: end; align-self: start; }
  /* The fold button sits inside the map's corner; folded, it is a square as tall as the search box, level with it. */
  .minimap-toggle { top: 2px; right: 2px; }
  .minimap-dock.is-collapsed .minimap-toggle { width: 45px; height: 45px; }
  /* Folded, the map needs only that square, so the search box takes the rest of the row. */
  .hud:has(.minimap-dock.is-collapsed) { --top-bar-map-room: 53px; }
  .info { grid-column: 1; grid-row: 3; max-height: 40vh; padding: 12px 14px; }
  .info h2 { font-size: 22px; }
  .info-model { height: 120px; }
  .toolbar { grid-column: 1 / -1; grid-row: 4; gap: 2px; padding: 4px; flex-wrap: nowrap; }
  .tool .tool-text { display: none; }
  .tool { min-width: 38px; padding: 0 6px; }
  .tool-divider { margin: 4px 0; }
}
@media (prefers-reduced-motion: reduce) {
  .info-actions button:active { transform: none; }
  .sky-stars::after { animation: none; }
}
