/* Interactive Trail Maps - Trailforks-style public embed */
html,
body.itm-public-body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
  background: #0b120d;
  color: #111827;
  font-family: Inter, Arial, sans-serif;
}

.itm-public,
.itm-public * {
  box-sizing: border-box;
}

.itm-public {
  width: 100%;
  max-width: none;
  height: 100vh;
  min-height: 860px;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f4f6f2;
}

.itm-tf__header {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 28px;
  padding: 30px clamp(26px, 4vw, 70px) 26px;
  background:
    radial-gradient(circle at 12% 10%, rgba(120,184,51,.18), transparent 30%),
    linear-gradient(135deg, #071207 0%, #020702 100%);
  color: #fff;
  border-bottom: 6px solid #78b833;
}

.itm-kicker,
.itm-panel-kicker {
  color: #78b833;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .22em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.itm-tf__header h1 {
  margin: 0;
  font-size: clamp(38px, 4vw, 68px);
  line-height: .95;
  font-weight: 950;
  letter-spacing: -.045em;
}

.itm-tf__header p {
  max-width: 880px;
  margin: 12px 0 0;
  color: rgba(255,255,255,.78);
  font-size: 16px;
  line-height: 1.5;
}

.itm-tf__stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, auto));
  gap: 10px;
}

.itm-stat {
  min-width: 110px;
  padding: 13px 15px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 14px;
  background: rgba(255,255,255,.07);
  backdrop-filter: blur(10px);
}

.itm-stat strong {
  display: block;
  color: #78b833;
  font-size: 22px;
  line-height: 1;
  font-weight: 950;
  white-space: nowrap;
}

.itm-stat span {
  display: block;
  margin-top: 7px;
  color: rgba(255,255,255,.62);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.itm-tf__toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px clamp(18px, 3vw, 46px);
  background: #111827;
  border-bottom: 1px solid rgba(255,255,255,.08);
  overflow-x: auto;
  scrollbar-width: thin;
}

.itm-tool {
  appearance: none;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.82);
  padding: 8px 13px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
}

.itm-tool:hover,
.itm-tool.is-active {
  background: #78b833;
  border-color: #78b833;
  color: #fff;
}

.itm-tool--primary {
  background: #78b833;
  border-color: #78b833;
  color: #fff;
}

.itm-tool-sep {
  display: block;
  width: 1px;
  align-self: stretch;
  background: rgba(255,255,255,.12);
  margin: 0 4px;
}

.itm-tf__stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  background: #dbe4d6;
  overflow: hidden;
}

.itm-public__map {
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #dbe4d6;
}

.itm-tf__panel {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 600;
  width: min(420px, calc(100% - 40px));
  max-height: calc(100% - 40px);
  display: flex;
  flex-direction: column;
  padding: 18px;
  background: rgba(255,255,255,.95);
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 18px;
  box-shadow: 0 18px 55px rgba(0,0,0,.22);
  backdrop-filter: blur(12px);
  transition: transform .22s ease, opacity .22s ease;
}

.itm-tf__panel.is-hidden {
  transform: translateX(calc(100% + 34px));
  opacity: 0;
  pointer-events: none;
}

.itm-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.itm-panel-head h2 {
  margin: 0;
  font-size: 27px;
  line-height: 1.05;
  letter-spacing: -.02em;
}

.itm-panel-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #111827;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.itm-search-wrap {
  margin-bottom: 14px;
}

.itm-search-wrap input {
  width: 100%;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 14px;
  outline: none;
  background: #f8faf7;
}

.itm-search-wrap input:focus {
  border-color: #78b833;
  box-shadow: 0 0 0 4px rgba(120,184,51,.15);
}

.itm-public__list {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
}

.itm-trail-card {
  border: 1px solid rgba(0,0,0,.11);
  border-radius: 14px;
  padding: 15px;
  background: #fff;
  cursor: pointer;
  transition: .18s ease;
}

.itm-trail-card:hover,
.itm-trail-card.is-active {
  border-color: #78b833;
  box-shadow: 0 12px 30px rgba(0,0,0,.10);
  transform: translateY(-1px);
}

.itm-trail-card.is-hidden {
  display: none;
}

.itm-trail-card__top {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.itm-trail-card__title {
  font-weight: 950;
  font-size: 17px;
  line-height: 1.16;
}

.itm-dot,
.grade {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
  flex: 0 0 auto;
}

.itm-dot {
  margin-top: 3px;
}

.itm-grade-pill {
  border-radius: 999px;
  padding: 5px 8px;
  color: #fff;
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .08em;
  white-space: nowrap;
}

.grade-green,
.itm-grade-green { background: #58af2d; }
.grade-blue,
.itm-grade-blue { background: #2563eb; }
.grade-black,
.itm-grade-black { background: #111827; }
.grade-red,
.itm-grade-red { background: #e11d48; }
.grade-grey,
.itm-grade-grey { background: #64748b; }

.itm-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 11px 0 0;
}

.itm-chip {
  font-size: 12px;
  font-weight: 950;
  border-radius: 999px;
  background: #eef5e7;
  color: #33590f;
  padding: 5px 9px;
}

.itm-desc {
  font-size: 13px;
  line-height: 1.45;
  color: #4b5563;
  margin-top: 10px;
}

.itm-legend {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 500;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(0,0,0,.12);
  box-shadow: 0 12px 35px rgba(0,0,0,.14);
}

.itm-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #111827;
  font-size: 12px;
  font-weight: 900;
}

.itm-popup {
  min-width: 265px;
  max-width: 340px;
}

.itm-popup h3 {
  margin: 0 0 8px;
  font-size: 19px;
  line-height: 1.15;
}

.itm-popup .itm-meta {
  margin: 8px 0;
}

.itm-popup p {
  margin: 9px 0;
  color: #374151;
  line-height: 1.42;
}

.itm-popup iframe {
  width: 300px;
  max-width: 100%;
  height: 170px;
  border: 0;
  border-radius: 10px;
  margin-top: 8px;
}

.leaflet-container {
  font-family: Inter, Arial, sans-serif;
}

.leaflet-control-zoom a {
  font-weight: 950;
}

/* CMS full-width iframe/embed fixes */
.html-embed--trail-map,
.page-section iframe[src*="interactive-trail-map.php"] {
  width: 100%;
  max-width: none;
}

.html-embed--trail-map {
  max-width: none;
  margin: 0;
}

.html-embed--trail-map iframe,
.page-section iframe[src*="interactive-trail-map.php"] {
  display: block;
  width: 100% !important;
  height: 920px !important;
  min-height: 920px;
  border: 0 !important;
  border-radius: 0 !important;
  overflow: hidden;
  background: #fff;
}

.section-type-html.trail-map-embed-section,
.section-type-html:has(iframe[src*="interactive-trail-map.php"]) {
  padding: 0 !important;
  margin: 0 !important;
  background: #fff;
  width: 100vw;
  max-width: none;
  margin-left: calc(50% - 50vw) !important;
  margin-right: calc(50% - 50vw) !important;
}

.section-type-html.trail-map-embed-section .section-wrap,
.section-type-html.trail-map-embed-section .html-embed,
.section-type-html.trail-map-embed-section .html-embed--trail-map,
.section-type-html:has(iframe[src*="interactive-trail-map.php"]) .section-wrap,
.section-type-html:has(iframe[src*="interactive-trail-map.php"]) .html-embed,
.section-type-html:has(iframe[src*="interactive-trail-map.php"]) .html-embed--trail-map {
  width: 100% !important;
  max-width: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

@media (max-width: 1100px) {
  .itm-tf__header {
    display: block;
  }

  .itm-tf__stats {
    margin-top: 18px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  html,
  body.itm-public-body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .itm-public {
    height: auto;
    min-height: 0;
  }

  .itm-tf__header {
    padding: 24px 18px;
  }

  .itm-tf__header h1 {
    font-size: 38px;
  }

  .itm-tf__stats {
    grid-template-columns: 1fr 1fr;
  }

  .itm-tf__stage {
    height: 760px;
    flex: 0 0 auto;
  }

  .itm-tf__panel {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 12px;
    width: auto;
    max-height: 45%;
  }

  .itm-legend {
    left: 12px;
    right: 12px;
    bottom: auto;
    top: 12px;
    border-radius: 14px;
  }

  .html-embed--trail-map iframe,
  .page-section iframe[src*="interactive-trail-map.php"] {
    height: 1080px !important;
    min-height: 1080px;
  }
}

/* Area/group support */
.itm-area-heading {
  margin: 12px 2px 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #111827;
  color: #fff;
}

.itm-area-heading:first-child {
  margin-top: 0;
}

.itm-area-heading span {
  display: block;
  color: #78b833;
  font-size: 10px;
  font-weight: 950;
  letter-spacing: .16em;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.itm-area-heading strong {
  display: block;
  font-size: 15px;
  line-height: 1.18;
}

.itm-area-heading.is-hidden {
  display: none;
}

.itm-trail-card__area {
  color: #64748b;
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .12em;
  margin-bottom: 4px;
}

.itm-chip--area {
  background: #e8f2ff;
  color: #174ea6;
}

.itm-popup-area {
  color: #78b833;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .14em;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.itm-public[data-map-mode="all"] .itm-tf__header h1 {
  font-size: clamp(36px, 3.7vw, 62px);
}

.html-embed--trail-map iframe,
.page-section iframe[src*="interactive-trail-map.php"] {
  height: 940px !important;
  min-height: 940px;
}

/* Area zoom interaction */
.itm-area-heading {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.itm-area-heading:hover strong {
  color: #78b833;
}

.itm-area-zoom {
  appearance: none;
  border: 1px solid rgba(120,184,51,.35);
  background: rgba(120,184,51,.12);
  color: #78b833;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  cursor: pointer;
}

.itm-area-heading:hover .itm-area-zoom {
  background: #78b833;
  color: #fff;
}

/* Trail More Info modal */
.itm-more-btn {
  appearance: none;
  margin-top: 12px;
  border: 0;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 950;
  cursor: pointer;
}
.itm-more-btn:hover { background: #78b833; }
.itm-popup .itm-more-btn { width: 100%; }

.itm-info-modal {
  position: fixed;
  inset: 0;
  z-index: 200000;
  display: none;
}
.itm-info-modal.is-open { display: block; }
.itm-info-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2,7,2,.72);
  backdrop-filter: blur(8px);
}
.itm-info-dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(1180px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #fff;
  color: #111827;
  border-radius: 20px;
  box-shadow: 0 32px 90px rgba(0,0,0,.42);
}
.itm-info-close {
  position: sticky;
  top: 14px;
  float: right;
  z-index: 3;
  width: 42px;
  height: 42px;
  margin: 14px 14px 0 0;
  border: 0;
  border-radius: 50%;
  background: #111827;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
#itmInfoContent { padding: 34px; }
.itm-info-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(0,0,0,.1);
}
.itm-info-header h2 {
  margin: 0;
  font-size: clamp(34px, 4vw, 58px);
  line-height: .95;
  letter-spacing: -.04em;
}
.itm-info-area {
  margin-top: 9px;
  color: #64748b;
  font-weight: 800;
}
.itm-info-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
  align-items: start;
}
.itm-info-lead {
  margin: 0 0 16px;
  font-size: 18px;
  line-height: 1.55;
  color: #374151;
}
.itm-info-copy {
  margin: 0 0 20px;
  color: #374151;
  font-size: 15px;
  line-height: 1.65;
}
.itm-info-video iframe {
  width: 100%;
  min-height: 360px;
  border: 0;
  border-radius: 16px;
  margin: 0 0 20px;
}
.itm-info-photos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.itm-info-photos figure {
  margin: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #f1f5f9;
}
.itm-info-photos img {
  display: block;
  width: 100%;
  height: 230px;
  object-fit: cover;
}
.itm-info-photos figcaption {
  padding: 10px 12px;
  font-size: 13px;
  color: #475569;
}
.itm-info-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-radius: 16px;
  background: #f8faf7;
  border: 1px solid rgba(0,0,0,.1);
}
.itm-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(0,0,0,.08);
}
.itm-info-row:last-child { border-bottom: 0; }
.itm-info-row span {
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.itm-info-row strong {
  text-align: right;
  font-size: 14px;
}
@media (max-width: 820px) {
  .itm-info-dialog { width: calc(100vw - 20px); max-height: calc(100vh - 20px); }
  #itmInfoContent { padding: 22px; }
  .itm-info-grid { grid-template-columns: 1fr; }
  .itm-info-photos { grid-template-columns: 1fr; }
  .itm-info-video iframe { min-height: 220px; }
}

/* Route/type badges: Trail, Road, Criterium, MTB, etc. */
.itm-kind-pill {
  background: #111827;
}
.itm-chip--kind {
  background: #f1f5f9;
  color: #0f172a;
}

/* Route type dropdown filter */
.itm-tool-dropdown {
  position: relative;
  flex: 0 0 auto;
}

.itm-tool--dropdown {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 148px;
  justify-content: space-between;
}

.itm-tool-caret {
  font-size: 11px;
  opacity: .8;
}

.itm-tool-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  width: 230px;
  max-height: 360px;
  overflow: auto;
  padding: 8px;
  border-radius: 16px;
  background: #0b1220;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 20px 50px rgba(0,0,0,.34);
  z-index: 1200;
  display: none;
}

.itm-tool-dropdown.is-open .itm-tool-menu {
  display: block;
}

.itm-tool-menu__item {
  appearance: none;
  display: block;
  width: 100%;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: rgba(255,255,255,.82);
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.itm-tool-menu__item:hover,
.itm-tool-menu__item.is-active {
  background: #78b833;
  color: #fff;
}

@media (max-width: 760px) {
  .itm-tool-menu {
    position: fixed;
    left: 14px;
    right: 14px;
    top: auto;
    bottom: 16px;
    width: auto;
    max-height: 55vh;
  }
}

/* Fix route type dropdown being clipped behind the map */
.itm-tf__toolbar {
  position: relative;
  z-index: 5000;
  overflow: visible !important;
  flex-wrap: wrap;
}

.itm-tool-dropdown {
  position: relative;
  z-index: 6000;
}

.itm-tool-menu {
  z-index: 99999 !important;
}

.itm-tool-dropdown.is-open .itm-tool-menu {
  display: block !important;
}

.itm-tf__stage,
.itm-public__map,
.leaflet-container {
  z-index: 1;
}

@media (max-width: 760px) {
  .itm-tf__toolbar {
    overflow: visible !important;
    flex-wrap: wrap;
  }
  .itm-tool-menu {
    position: fixed !important;
    left: 14px !important;
    right: 14px !important;
    top: auto !important;
    bottom: 16px !important;
    width: auto !important;
    max-height: 55vh !important;
    z-index: 99999 !important;
  }
}


/* More Info modal must always sit above the route-type toolbar/dropdowns */
.itm-info-modal,
.itm-info-modal.is-open {
  z-index: 200000 !important;
}
.itm-info-modal.is-open .itm-info-dialog {
  position: absolute;
  z-index: 200002 !important;
}
.itm-info-modal.is-open .itm-info-backdrop {
  z-index: 200001 !important;
}
.itm-info-modal.is-open ~ .itm-tf__toolbar,
.itm-info-modal.is-open ~ .itm-tf__shell .itm-tf__toolbar {
  z-index: 10 !important;
}


/* ─── Interactive Map Popup + Header Alignment Fix ───────────────────────────
   Keeps the map header/tools aligned to the left edge and prevents the first
   letters/buttons being clipped in full-width embeds. Also makes popup buttons
   reliably clickable inside Leaflet popups. */
html,
body.itm-public-body {
  overflow-x: hidden !important;
}

.itm-public {
  position: relative;
  left: 0;
  transform: none !important;
  overflow-x: hidden !important;
}

.itm-tf__header,
.itm-tf__toolbar {
  width: 100%;
  max-width: 100%;
  margin-left: 0 !important;
  margin-right: 0 !important;
  transform: none !important;
}

.itm-tf__header {
  padding-left: max(28px, env(safe-area-inset-left)) !important;
  padding-right: max(28px, env(safe-area-inset-right)) !important;
}

.itm-tf__toolbar {
  justify-content: flex-start !important;
  padding-left: max(16px, env(safe-area-inset-left)) !important;
  padding-right: max(16px, env(safe-area-inset-right)) !important;
  scroll-padding-left: max(16px, env(safe-area-inset-left));
}

.itm-tf__toolbar .itm-tool:first-child {
  margin-left: 0 !important;
}

.leaflet-popup-content .itm-more-btn,
.itm-popup .itm-more-btn {
  pointer-events: auto !important;
  cursor: pointer !important;
  position: relative;
  z-index: 5;
}

.leaflet-popup-content {
  pointer-events: auto !important;
}

@media (max-width: 760px) {
  .itm-tf__header {
    padding-left: 18px !important;
    padding-right: 18px !important;
  }

  .itm-tf__toolbar {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}
