/* 360 Earth View — single stylesheet for both pages.
   Sections: tokens → reset/base → components → page scopes → media queries.
   Ad-well rules mirror the battle-tested maps.questfordirections.com
   patterns; see README.md before "simplifying" any of them. */

/* ---------- 1. Tokens ---------- */

:root {
  --c-bg: #f5f6f7;
  --c-surface: #ffffff;
  --c-text: #1f2328;
  --c-muted: #5f6a72;
  --c-border: #e2e5e9;
  --c-blue: #2b6bf3;
  --c-blue-ink: #1f56cc;
  --c-red: #e5342e;
  --c-ring: rgba(43, 107, 243, 0.35);
  --font: "Google Sans", system-ui, -apple-system, "Segoe UI", Roboto,
    sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-1: 0 1px 4px rgba(0, 0, 0, 0.14);
  --shadow-2: 0 8px 30px rgba(0, 0, 0, 0.22);
  /* z-scale: map canvas 0 · scrim 0 (paints after) · page/panels/rail 10 ·
     suggestions 30 · toast 40 */
}

/* ---------- 2. Reset / base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--c-text);
  background: var(--c-bg);
}

img {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--c-ring);
  outline-offset: 1px;
}

/* ---------- 3. Components ---------- */

/* Logo badge (HTML text + globe glyph so the wordmark uses Google Sans) */
.logo-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px 6px 8px;
  background: linear-gradient(135deg, #2f80ed, #1a5ed8);
  border-radius: 999px;
  box-shadow: var(--shadow-1);
  text-decoration: none;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
}

.logo-badge img {
  width: 24px;
  height: 24px;
}

.logo-badge .logo-360 {
  color: #ffd54d;
}

/* Search box + suggestions (shared) */
.search-box {
  position: relative;
  display: flex;
  height: 56px;
  text-align: left;
}

.search-box input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--c-border);
  border-right: none;
  border-radius: 10px 0 0 10px;
  padding: 0 18px;
  font-family: inherit;
  font-size: 17px;
  color: var(--c-text);
  background: var(--c-surface);
}

.search-box input:focus {
  outline: none;
  border-color: var(--c-blue);
}

.search-box .search-btn {
  width: 76px;
  border: none;
  border-radius: 0 10px 10px 0;
  background: var(--c-blue);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  text-decoration: none;
}

.search-box .search-btn:hover {
  background: var(--c-blue-ink);
}

.search-box .search-btn svg {
  width: 24px;
  height: 24px;
}

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  background: var(--c-surface);
  border-radius: 10px;
  box-shadow: var(--shadow-2);
  max-height: 320px;
  overflow-y: auto;
}

.suggestions li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
}

.suggestions li:hover,
.suggestions li.is-active {
  background: #eef3ff;
}

.suggestions .no-results {
  color: var(--c-muted);
  cursor: default;
}

.suggestions .no-results:hover {
  background: none;
}

.suggestions .s-icon {
  color: var(--c-muted);
  display: grid;
  place-items: center;
  flex: none;
}

.suggestions .s-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.suggestions .s-primary {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestions .s-secondary {
  font-size: 13px;
  color: var(--c-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-error {
  margin: 10px 0 0;
  font-size: 14px;
  color: #c62828;
}

/* Ad wells.
   - Fixed-size <ins> only (no data-ad-format): a display:block responsive
     <ins> inside a centered flex parent computes availableWidth=0 and
     AdSense never requests an ad.
   - Centering uses justify-content, not text-align: AdSense rewrites a
     filled <ins> to display:block.
   - min-height reserves the strip against CLS; collapse on no-fill is
     accepted. The wells are deliberately NOT pinned by pinLayout(). */
.top-ad {
  display: none;
}

.top-ad ins {
  display: none;
}

.ad-float {
  display: none;
}

/* 300x250 under the style switcher inside the map-page search panel.
   Desktop only; same fixed-size + justify-content rules as the other
   wells. Hidden ins below the gate -> zero-width, no ad request.
   max-height + overflow clip a creative that outgrows its slot (AdSense
   stamps height/min-height inline but never max-height). */
.panel-ad {
  display: none;
  max-height: 250px;
  overflow: hidden;
}

/* ---------- 4. Landing page ---------- */

#bg-map {
  position: fixed;
  inset: 0;
  z-index: 0;
  /* Fallback when the map cannot load */
  background: linear-gradient(160deg, #12314e 0%, #1d4438 55%, #3a5a2f 100%);
}

.bg-scrim {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0) 35%,
    rgba(0, 0, 0, 0.38) 100%
  );
}

body.landing .page {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  display: flex;
  justify-content: flex-end;
  padding: 14px 18px;
}

.hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 90px 16px 40px;
}

.hero-card {
  width: 100%;
  max-width: 720px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 16px;
  box-shadow: var(--shadow-2);
  padding: 12px 28px 30px;
  text-align: center;
}

.map-fold {
  width: 150px;
  margin: -78px auto 2px;
}

.hero-card h1 {
  margin: 6px 0 22px;
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 700;
  color: var(--c-blue);
}

.tile-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-top: 26px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 128px;
  padding: 12px 16px;
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  text-decoration: none;
  color: var(--c-text);
  font-size: 14px;
  font-weight: 500;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
}

.tile img {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.site-footer {
  padding: 14px;
  text-align: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.site-footer a {
  color: inherit;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 22px;
}

/* ---------- 5. Map page ---------- */

body.map-page .page {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

body.map-page .top-ad {
  background: var(--c-surface);
}

.map-wrap {
  flex: 1 1 0;
  position: relative;
  /* Floor: an injected auto-ad overflows instead of crushing the map */
  min-height: 50vh;
}

#map {
  position: absolute;
  inset: 0;
}

.panel-search {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  width: 360px;
  max-width: calc(100% - 32px);
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 14px;
}

.panel-search .search-box {
  height: 48px;
}

.style-switch {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.style-switch button {
  position: relative;
  width: 76px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  background: none;
  cursor: pointer;
}

.style-switch button img {
  width: 100%;
  height: 56px;
  object-fit: cover;
}

.style-switch button span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 0 3px;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.65));
}

.style-switch button[aria-pressed="true"] {
  border-color: var(--c-blue);
}

.map-logo {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
}

.rail {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rail button {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  box-shadow: var(--shadow-1);
  color: #3c4043;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.rail button:hover {
  background: #f1f3f4;
}

.rail button svg {
  width: 22px;
  height: 22px;
}

.map-pin {
  width: 34px;
  height: 44px;
  background: url("../img/pin.svg") no-repeat center / contain;
}

.user-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #1a73e8;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.35);
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  z-index: 40;
  transform: translate(-50%, 8px);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  background: rgba(32, 33, 36, 0.9);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

#map-error {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: var(--c-bg);
  text-align: center;
}

/* ---------- 6. Media queries ---------- */

@media (min-width: 768px) {
  /* Card high on the page (~25% from top incl. the map-fold graphic)
     rather than vertically centred. No landing top ad (competitor
     parity), so viewport-relative padding sets the position. */
  .hero {
    align-items: flex-start;
    padding-top: 26vh;
  }
}

@media (min-width: 1024px) {
  .ad-float {
    display: block;
    position: absolute;
    right: 16px;
    bottom: 28px;
    z-index: 10;
    width: 300px;
    height: 250px;
    max-width: 300px;
    max-height: 250px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-1);
    overflow: hidden;
  }

  .panel-ad {
    display: flex;
    justify-content: center;
    margin-top: 12px;
  }

  /* Ads (ours and Auto-ads overlays/side rails) claim the bottom-right
     region on desktop — anchor the rail top-right, under the logo, where
     no bottom-anchored format can cover it */
  .rail {
    top: 72px;
    transform: none;
  }
}

/* AdSense stamps data-ad-status="unfilled" + display:none on a no-fill
   ins; hide the float's card chrome too instead of showing an empty box */
.ad-float:has(ins[data-ad-status="unfilled"]) {
  display: none;
}

@media (min-width: 1160px) {
  body.map-page .top-ad {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    min-height: 120px;
  }

  body.map-page .top-ad ins {
    display: inline-block;
  }
}

@media (max-width: 767px) {
  .panel-search {
    top: 8px;
    left: 8px;
    right: 8px;
    width: auto;
    padding: 10px;
  }

  .style-switch button {
    width: 64px;
  }

  .style-switch button img {
    height: 44px;
  }

  .rail button {
    width: 40px;
    height: 40px;
  }

  .map-logo {
    display: none; /* the panel already owns the top strip on mobile */
  }

  .hero {
    padding-top: 84px;
  }

  .hero-card {
    padding: 10px 16px 22px;
  }
}
