/* hdpf-area-map.css — the interactive service-area map.
 *
 * A Maps JavaScript map with the coverage polygon, the office pin, and a panel
 * carrying the live Google name, rating, and reviews. Promoted from the map lab
 * (variant 02) after review. Only renders when a key AND a Map ID are set;
 * otherwise the component falls back to the free Embed iframe, which uses the
 * .hdpf-map-embed chrome in hdpf-site.css. This file styles the interactive
 * layer that sits on top of that same frame.
 *
 * Tokens only. The one place literal colours are unavoidable is the marker and
 * polygon fill, which Google's API takes as values, not custom properties — the
 * JS reads the computed token there so the palette stays single-sourced.
 *
 * The panel collapses to a chip on a narrow frame so the map itself stays
 * visible on a phone. That breakpoint is a container query on the frame (these
 * maps can sit in a narrow column on a wide page); the JS reads the resolved
 * state off the toggle rather than keeping its own copy of the number.
 */

/* The interactive container reuses .hdpf-map-embed for its frame (aspect ratio,
 * border, radius, shadow, and the --fill override), so it drops into the same
 * slots the Embed iframe used. This block only adds what the live map needs. */
.hdpf-area-map {
  container-type: inline-size;
  container-name: area-map;
  isolation: isolate;
}

.hdpf-area-map__canvas {
  position: absolute;
  inset: 0;
}

/* Google draws its own controls and attribution into the canvas; nothing of
 * ours should cover the bottom-left attribution, hence the panel sits top-left
 * and the controls keep their default corners. */

/* ---- Loading / fallback plane ------------------------------------ *
 * Shown until the map reports idle, and left in place if the map errors (the JS
 * swaps in the Embed iframe on hard failure). Same blueprint plane the no-key
 * fallback uses, so a slow or failed load reads as intentional. */
.hdpf-area-map__loading {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-content: center;
  gap: var(--hdpf-space-2);
  background-color: var(--hdpf-surface-inset);
  background-image:
    linear-gradient(var(--hdpf-bp-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--hdpf-bp-line) 1px, transparent 1px);
  background-size: var(--hdpf-bp-size) var(--hdpf-bp-size);
  color: var(--hdpf-ink-muted);
  font-family: var(--hdpf-font-mono);
  font-size: var(--hdpf-fs-micro);
  letter-spacing: var(--hdpf-tracking-wide);
  text-transform: uppercase;
}

.hdpf-area-map__loading .hdpf-icon {
  color: var(--hdpf-accent);
}

/* JS removes this once the map is idle. */
.hdpf-area-map.is-ready .hdpf-area-map__loading {
  display: none;
}

/* The Embed fallback iframe (no-JS via <noscript>, or JS error) fills the frame
 * exactly like the interactive canvas. */
.hdpf-area-map__frame {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ================================================================== *
 * Panel — the business card over the map
 * ================================================================== */

.hdpf-area-map__panel {
  position: absolute;
  z-index: 3;
  top: var(--hdpf-space-4);
  left: var(--hdpf-space-4);
  width: min(21rem, calc(100% - var(--hdpf-space-8)));
  max-height: calc(100% - var(--hdpf-space-8));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--hdpf-border);
  border-radius: var(--hdpf-radius-xl);
  background: color-mix(in srgb, var(--hdpf-surface) 96%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--hdpf-shadow-lg);
}

/* Scroll + padding live on the body, so the collapsed chip is exactly button
 * sized with no dead inset. */
.hdpf-area-map__body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--hdpf-space-5);
}

/* ---- Toggle — the collapse control ------------------------------- */

.hdpf-area-map__toggle {
  display: none;
  align-items: center;
  gap: var(--hdpf-space-2);
  margin: 0;
  padding: var(--hdpf-space-3) var(--hdpf-space-4);
  border: 0;
  border-radius: inherit;
  background: none;
  color: var(--hdpf-ink-strong);
  font: inherit;
  font-weight: var(--hdpf-fw-semibold);
  cursor: pointer;
}

.hdpf-area-map__toggle:focus-visible {
  outline: 2px solid var(--hdpf-focus-outline);
  outline-offset: 2px;
}

.hdpf-area-map__toggle-open {
  display: inline-flex;
  align-items: center;
  gap: var(--hdpf-space-2);
}

.hdpf-area-map__toggle-open svg {
  width: 1.1em;
  height: 1.1em;
  fill: var(--hdpf-warning);
}

.hdpf-area-map__toggle-close {
  display: none;
  color: var(--hdpf-ink-muted);
}

.hdpf-area-map__toggle-close svg {
  width: 1.1em;
  height: 1.1em;
}

/* ---- Collapsed regime — narrow frame only ------------------------ *
 * Container query on the frame is the single source of truth for the
 * breakpoint; the JS reads the toggle's resolved display rather than keeping a
 * second copy, so this value can be tuned in one place. */
@container area-map (max-width: 38rem) {
  .hdpf-area-map__panel {
    width: auto;
    max-width: calc(100% - var(--hdpf-space-8));
  }

  .hdpf-area-map__toggle {
    display: inline-flex;
  }

  .hdpf-area-map__panel[data-expanded="false"] {
    border-radius: var(--hdpf-radius-pill);
  }

  .hdpf-area-map__panel[data-expanded="false"] .hdpf-area-map__body {
    display: none;
  }

  .hdpf-area-map__panel[data-expanded="true"] {
    width: min(21rem, calc(100% - var(--hdpf-space-8)));
  }

  .hdpf-area-map__panel[data-expanded="true"] .hdpf-area-map__toggle {
    justify-content: space-between;
    width: 100%;
    border-bottom: 1px solid var(--hdpf-border);
    border-radius: 0;
  }

  .hdpf-area-map__panel[data-expanded="true"] .hdpf-area-map__toggle-open [data-area-map-chip-label] {
    display: none;
  }

  .hdpf-area-map__panel[data-expanded="true"] .hdpf-area-map__toggle-close {
    display: inline-flex;
  }
}

/* ================================================================== *
 * Card internals — name, rating, reviews, actions
 * ================================================================== */

.hdpf-area-map__eyebrow {
  display: block;
  margin-bottom: var(--hdpf-space-2);
  font-family: var(--hdpf-font-mono);
  font-size: var(--hdpf-fs-micro);
  letter-spacing: var(--hdpf-tracking-wider);
  text-transform: uppercase;
  font-weight: var(--hdpf-fw-semibold);
  color: var(--hdpf-accent-strong);
}

.hdpf-area-map__name {
  margin: 0 0 var(--hdpf-space-2);
  font-family: var(--hdpf-font-display);
  font-size: var(--hdpf-fs-title);
  font-weight: var(--hdpf-fw-extrabold);
  line-height: var(--hdpf-lh-snug);
  letter-spacing: var(--hdpf-tracking-tight);
  color: var(--hdpf-ink-strong);
  text-wrap: balance;
}

.hdpf-area-map__addr {
  margin: 0 0 var(--hdpf-space-3);
  font-size: var(--hdpf-fs-micro);
  line-height: var(--hdpf-lh-relaxed);
  color: var(--hdpf-ink-muted);
}

/* Rating row — every part comes from the live Places response. */
.hdpf-area-map__rating {
  display: flex;
  align-items: center;
  gap: var(--hdpf-space-2);
  margin-bottom: var(--hdpf-space-3);
  font-size: var(--hdpf-fs-caption);
  color: var(--hdpf-ink-muted);
}

.hdpf-area-map__score {
  font-family: var(--hdpf-font-display);
  font-size: var(--hdpf-fs-body);
  font-weight: var(--hdpf-fw-bold);
  color: var(--hdpf-ink-strong);
  font-variant-numeric: tabular-nums;
}

/* Temporarily hide the review count in the rating row */
.hdpf-area-map__rating span:nth-child(3) {
  display: none;
}

.hdpf-area-map__stars {
  display: inline-flex;
  gap: 0.1em;
  color: var(--hdpf-warning);
  line-height: 1;
}

.hdpf-area-map__stars svg {
  width: 1em;
  height: 1em;
  fill: currentColor;
}

.hdpf-area-map__stars svg[data-empty] {
  fill: color-mix(in srgb, var(--hdpf-warning) 22%, transparent);
}

/* One row: the consult CTA takes the space, the phone sits beside it as an
 * icon-only button of matching height — the same treatment as the article rail
 * (.hdpf-rail__actions). */
.hdpf-area-map__actions {
  display: flex;
  align-items: stretch;
  gap: var(--hdpf-space-2);
  margin-top: var(--hdpf-space-4);
  padding-top: var(--hdpf-space-4);
  border-top: 1px dashed var(--hdpf-border-strong);
}

.hdpf-area-map__actions > .hdpf-btn:not(.hdpf-btn--icon-only) {
  flex: 1 1 auto;
  min-width: 0;
}

.hdpf-area-map__actions > .hdpf-btn--icon-only {
  flex: 0 0 auto;
}

/* ---- Reviews ----------------------------------------------------- *
 * Google Maps Platform policy: each review must show its author's name, photo,
 * and a link back. The markup is heavier than a quote because that attribution
 * is required, not decorative. */
.hdpf-area-map__reviews {
  display: grid;
  gap: var(--hdpf-space-3);
  margin: var(--hdpf-space-4) 0 0;
  padding-top: var(--hdpf-space-4);
  border-top: 1px dashed var(--hdpf-border-strong);
}

.hdpf-area-map__review {
  margin: 0;
  padding: var(--hdpf-space-4);
  border: 1px solid var(--hdpf-border);
  border-radius: var(--hdpf-radius-lg);
  background: var(--hdpf-surface-inset);
}

.hdpf-area-map__review-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--hdpf-space-3);
  align-items: center;
  margin-bottom: var(--hdpf-space-3);
}

.hdpf-area-map__review-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: var(--hdpf-radius-pill);
  object-fit: cover;
  background: var(--hdpf-surface-strong);
}

.hdpf-area-map__review-author {
  display: block;
  font-size: var(--hdpf-fs-caption);
  font-weight: var(--hdpf-fw-semibold);
  color: var(--hdpf-ink-strong);
  text-decoration: none;
}

.hdpf-area-map__review-author:hover {
  text-decoration: underline;
}

.hdpf-area-map__review-meta {
  display: flex;
  align-items: center;
  gap: var(--hdpf-space-2);
  font-size: var(--hdpf-fs-micro);
  color: var(--hdpf-ink-muted);
}

.hdpf-area-map__review-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  overflow: hidden;
  margin: 0;
  font-size: var(--hdpf-fs-caption);
  line-height: var(--hdpf-lh-relaxed);
  color: var(--hdpf-ink);
  text-wrap: pretty;
}

.hdpf-area-map__attrib {
  margin: var(--hdpf-space-3) 0 0;
  font-family: var(--hdpf-font-mono);
  font-size: var(--hdpf-fs-micro);
  color: var(--hdpf-ink-faint);
}

.hdpf-area-map__attrib a {
  color: var(--hdpf-ink-muted);
}

/* Screen-reader-only, local to this component. */
.hdpf-area-map__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
