/* ========== Map popups ==========
   One shell for every category (see helpers.buildPopup). `--pp-cat` is set
   inline per popup from CATEGORY_COLORS, so the accent always matches the pin
   you just tapped. */

.leaflet-popup-content-wrapper {
  width: min(320px, calc(100vw - 32px));
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.22);
}

.leaflet-popup-content {
  width: auto !important;
  /* Leave room for the app bar so a tall popup can never open under it. */
  max-height: min(58dvh, 430px);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0 !important;
  padding: 0 !important;
  overflow-wrap: break-word;
}

.leaflet-popup-tip {
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.1);
}

/* Leaflet ships `.leaflet-popup-content p { margin: 1.3em 0 }` - one class plus a
   type, which outranks the single-class rules below and was silently re-inflating
   .pp-credit and .pp-note. Neutralise it once so the margins authored here apply
   as written. Same specificity trap as the link colours near the bottom. */
.leaflet-popup-content p { margin: 0; }

.leaflet-popup-close-button {
  width: 30px !important;
  height: 30px !important;
  padding: 6px 0 0 0 !important;
  font-size: 20px !important;
  color: var(--muted) !important;
}

.pp {
  display: grid;
  gap: 10px;
  padding: 16px;
  /* The accent bar reads as "this is the category you tapped". */
  border-top: 3px solid var(--pp-cat, var(--brand));
  border-radius: 16px 16px 0 0;
}

/* ---------- Heading ---------- */
.pp-head {
  display: grid;
  gap: 4px;
  padding-right: 22px; /* clear of Leaflet's close button */
}

.pp-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
}

.pp-cat {
  justify-self: start;
  padding: 2px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--pp-cat, var(--brand)) 14%, #fff);
  color: var(--pp-cat, var(--brand));
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* ---------- Photo ---------- */
.pp-photo {
  width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
  background: rgba(15, 23, 42, 0.04);
}

.pp-credit {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
  /* `anywhere`, not `break-word`: only the former shrinks a grid item's
     min-content width. A credit carrying a bare URL is one unbreakable word,
     and with break-word it widened the .pp track past the card, stretching the
     photo above it out under the clipped edge (Curtin Artificial Reef). */
  overflow-wrap: anywhere;
}

/* The credit belongs to the photo above it, so it sits tighter than the 10px
   the grid gives everything else. Two classes on purpose: one would lose to the
   Leaflet reset at the top of this file. */
.pp-photo + .pp-credit { margin-top: -4px; }

/* ---------- Photo carousel ----------
   One image at a time with arrows and an "n / N" counter, used by a grouped
   photo pin and by a sponsor's gallery alike (helpers.js renderCarousel).

   Slides are stacked and toggled rather than scrolled. The snap-scrolling strip
   this replaced was cheaper, but a scroll position cannot be read back as an
   index without a listener - and popup content is rebuilt on every open, so
   nothing inside it can hold one. */
.pp-carousel {
  display: grid;
  gap: 6px;
}

/* A fixed 3:2 box, so paging to a portrait photo doesn't resize the popup out
   from under the arrows you are tapping. */
.pp-carousel-frame {
  position: relative;
  aspect-ratio: 3 / 2;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.04);
}

.pp-shot {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pp-shot.is-current { display: block; }

.pp-carousel-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pp-carousel-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 50%;
  background: #fff;
  color: var(--pp-cat, var(--brand));
  cursor: pointer;
}

.pp-carousel-btn:hover { background: rgba(15, 23, 42, 0.06); }

.pp-carousel-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Tabular figures, so 9 / 16 -> 10 / 16 doesn't shift the row on every tap -
   the same reason the cluster donut uses them. */
.pp-carousel-count {
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* A photo with no date_taken gets no separator either. */
.pp-carousel-date:empty { display: none; }
.pp-carousel-date::before { content: '\00b7'; margin-right: 6px; }

.pp-carousel + .pp-credit { margin-top: -4px; }

/* ---------- Description ----------
   Clamping is what keeps a long ramp write-up from pushing the popup past the
   top of the screen; the toggle below restores the full text on demand. */
.pp-desc {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--ink);
}

/* The one place an author's own markup reaches the popup - see the link block
   in js/helpers.js. Underlined rather than colour-only, because colour alone is
   not a link affordance for anyone who cannot see this one. `anywhere` is what
   keeps a 90-character artefact URL used as its own label from widening a
   320px card. */
.pp-desc a {
  color: var(--pp-cat, var(--brand));
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.pp-desc a:hover { text-decoration-thickness: 2px; }

.pp-desc.is-clamped {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pp-more {
  justify-self: start;
  margin-top: -6px;
  padding: 2px 0;
  border: none;
  background: none;
  color: var(--brand);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.pp-more:hover { text-decoration: underline; }

/* ---------- Facility pills ---------- */
.pp-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pp-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
}

.pp-pill.is-yes {
  background: rgba(21, 128, 61, 0.12);
  color: #14532d;
}

.pp-pill.is-no {
  background: rgba(15, 23, 42, 0.06);
  color: var(--muted);
}

.pp-icon { flex-shrink: 0; }

/* ---------- Facts ---------- */
.pp-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px 12px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 119, 190, 0.05);
}

.pp-fact dt {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
}

.pp-fact dd {
  margin: 1px 0 0;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
}

/* ---------- Prose notes ---------- */
.pp-note {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--ink);
}

.pp-note strong {
  display: block;
  margin-bottom: 1px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Actions ----------
   Coordinates used to be inert text. They are now a copy button, sitting next
   to the action this app was missing entirely: directions. */
.pp-actions {
  display: flex;
  gap: 8px;
}

.pp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border: 1.5px solid rgba(0, 119, 190, 0.25);
  border-radius: 10px;
  background: #fff;
  color: var(--brand);
  font: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.pp-btn--primary {
  flex-shrink: 0;
  border-color: transparent;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
}

/* The link to this POI's own page on the website, under the actions row and
   full width - it is a destination, not a third button competing with
   Directions for the same line. Only POIs whose category has a page get one;
   see `page` in scripts/build_data.py. */
.pp-btn--page {
  display: flex;
  width: 100%;
  margin-top: 8px;
  border-color: rgba(0, 119, 190, 0.25);
  background: rgba(0, 119, 190, 0.06);
}

/* Leaflet ships `.leaflet-container a { color: #0078A8 }`, which is two classes
   and therefore beats a single class here - without these the Directions button
   rendered its label in link-blue on a blue gradient. */
.leaflet-popup-content a.pp-btn--primary { color: #fff; }
.leaflet-popup-content a.pp-source { color: var(--brand); }
.leaflet-popup-content .pp-credit a { color: var(--brand); }

.pp-copy {
  flex: 1;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.pp-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pp-btn:hover { filter: brightness(1.04); }
.pp-copy:hover { background: rgba(0, 119, 190, 0.08); }

.pp-copy.is-copied {
  border-color: #15803d;
  color: #15803d;
}

.pp-btn:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
}

/* ---------- Website breadcrumb ----------
   Sits under the title, so it has to read as a path to somewhere rather than
   compete with the heading: the host is muted, the page name carries the brand
   colour, and only the page name underlines on hover. */
/* Running text rather than a flex row: at 278px the longer off-site crumbs
   ("QLD National Parks > Gallagher Point Camping Area") always take two lines,
   and as flex items they wrapped into a ragged block instead of a sentence. */
.pp-source {
  display: block;
  max-width: 100%;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
}

.pp-source .pp-icon {
  display: inline-block;
  vertical-align: -2px;
  margin-right: 4px;
  color: var(--muted);
}

.pp-source-site {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.pp-source-sep {
  margin: 0 3px;
  color: var(--muted);
  opacity: 0.6;
}

/* The page name is the part that can be long, so it is the part that wraps. */
.pp-source-page {
  color: var(--brand);
}

.pp-source:hover .pp-source-page { text-decoration: underline; }

.pp-source:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .pp-btn { transition: none; }
}
