/* Cubtopia site map. Map pieces (cm-) are shared by the website and the portal; mp- is the public page. */
:root{
  --cm-navy: #0c1c39;
  --cm-gold: #f5a621;
  --cm-paper: #f8f4ea;
  --cm-cream: #fffaf0;
  --cm-line: rgba(12,28,57,.14);
}

/* ---------- Map ---------- */
.cm-map{
  height: min(72vh, 760px);
  min-height: 420px;
  border-radius: 18px;
  overflow: hidden;
  background: var(--cm-paper);
  font-family: "Nunito Sans", system-ui, sans-serif;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.cm-map.cm-on-plan{ background: #efe9d9; }
.cm-map .leaflet-container, .cm-map.leaflet-container{ font: inherit; }
.cm-plan{ image-rendering: auto; }

/* Labels on areas: rounded tags in the item's colour, like the paper plan's letters */
.leaflet-tooltip.cm-label{
  background: var(--cm-gold);
  border: 2px solid #fff;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(12,28,57,.35);
  font-family: "Baloo 2", system-ui, sans-serif;
  font-weight: 800;
  font-size: 15px;
  line-height: 1;
  padding: 5px 7px 3px;
  white-space: nowrap;
  cursor: pointer;
}
.leaflet-tooltip.cm-label::before{ display: none; }
.leaflet-tooltip.cm-label-name{ font-size: 12px; font-family: "Nunito Sans", system-ui, sans-serif; font-weight: 700; padding: 4px 7px; }
.leaflet-tooltip.cm-label.cm-dim{ opacity: .35 !important; }

/* Points: a lettered square (or a name tag) */
.cm-pin{ background: none; border: 0; }
.cm-pin span{
  display: inline-block;
  transform: translate(-50%, -50%);
  min-width: 30px;
  padding: 6px 7px 3px;
  border: 2px solid #fff;
  border-radius: 8px;
  box-shadow: 0 2px 7px rgba(12,28,57,.4);
  font: 800 16px/1 "Baloo 2", system-ui, sans-serif;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
}
.cm-pin.cm-pin-name span{ font: 700 12px/1 "Nunito Sans", system-ui, sans-serif; padding: 5px 8px; min-width: 0; }
.cm-pin.cm-dim span{ opacity: .35; }
.cm-pin.cm-sel span{ outline: 3px solid var(--cm-gold); outline-offset: 1px; }
.cm-pin.cm-draft span{ outline: 3px dashed var(--cm-navy); }

/* Background switch and "whole site" button */
.cm-switch{ display: flex; background: #fff; border-radius: 10px !important; overflow: hidden; }
.cm-switch button{
  border: 0; background: #fff; color: var(--cm-navy);
  font: 700 13px/1 "Nunito Sans", system-ui, sans-serif;
  padding: 9px 12px; cursor: pointer;
}
.cm-switch button + button{ border-left: 1px solid var(--cm-line); }
.cm-switch button[aria-pressed="true"]{ background: var(--cm-navy); color: #fff; }
.cm-home{
  width: 34px; height: 34px; padding: 6px;
  background: #fff; color: var(--cm-navy);
  border-radius: 8px !important; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.cm-home svg{ width: 18px; height: 18px; }
.cm-map .leaflet-bar a{ color: var(--cm-navy); }
.cm-map .leaflet-control-attribution{ font-size: 10px; background: rgba(255,255,255,.8); }

/* ---------- Expanded view ---------- */
.cm-detail{
  background: #fff;
  border-radius: 18px;
  padding: 1rem 1.1rem 1.1rem;
  box-shadow: 0 10px 24px rgba(12,28,57,.18);
  border: 1px solid var(--cm-line);
  margin-bottom: 1rem;
  color: var(--cm-navy);
}
.cm-detail[hidden]{ display: none; }
.cm-d-head{ display: grid; grid-template-columns: auto 1fr auto; gap: .7rem; align-items: start; }
.cm-d-code{
  min-width: 46px; height: 46px; padding: 0 .4rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  font: 800 1.45rem/1 "Baloo 2", system-ui, sans-serif;
  padding-top: 4px;
}
.cm-d-title h2{ margin: 0; font-size: 1.35rem; line-height: 1.15; color: var(--cm-navy); }
.cm-d-cat{ margin: .15rem 0 0; font-size: .85rem; font-weight: 700; color: #5b6478; }
.cm-d-close{
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--cm-line); background: #fff; color: var(--cm-navy);
  font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 0;
}
.cm-d-close:hover{ background: var(--cm-paper); }
.cm-d-photo{ margin: .9rem 0 0; }
.cm-d-photo img{ width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; display: block; }
.cm-d-desc{ margin-top: .8rem; }
.cm-d-desc p{ margin: 0 0 .6rem; line-height: 1.55; font-size: .95rem; }
.cm-d-sub{ font-size: 1rem; margin: .9rem 0 .4rem; }
.cm-d-list{ list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.cm-chip{
  display: inline-flex; align-items: center; gap: .4rem;
  border: 1px solid var(--cm-line); background: var(--cm-cream); color: var(--cm-navy);
  border-radius: 99px; padding: .2rem .65rem .2rem .25rem; cursor: pointer;
  font: 700 .85rem/1.2 "Nunito Sans", system-ui, sans-serif;
}
.cm-chip span{ border-radius: 99px; padding: .15rem .45rem; font-family: "Baloo 2", sans-serif; font-weight: 800; }

/* ---------- Key / legend ---------- */
.cm-legend-wrap h2{ margin: 0 0 .5rem; font-size: 1.35rem; }
.cm-lg-group + .cm-lg-group{ margin-top: .8rem; }
.cm-lg-head{ margin: 0 0 .3rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: #5b6478; font-family: "Nunito Sans", system-ui, sans-serif; }
.cm-lg-toggle{ display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; font-weight: 800; }
.cm-lg-toggle input{ width: 16px; height: 16px; margin: 0; accent-color: var(--cm-navy); }
.cm-swatch{ width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.cm-lg-list{ list-style: none; margin: 0; padding: 0; }
.cm-lg-list.off{ opacity: .45; }
.cm-lg-item{
  width: 100%; display: flex; align-items: center; gap: .55rem;
  background: none; border: 0; border-radius: 10px; padding: .3rem .35rem;
  text-align: left; cursor: pointer; color: var(--cm-navy);
  font: 600 .95rem/1.25 "Nunito Sans", system-ui, sans-serif;
}
.cm-lg-item:hover:not(:disabled){ background: rgba(245,166,33,.18); }
.cm-lg-item.on{ background: var(--cm-gold); }
.cm-lg-item:disabled{ cursor: default; }
.cm-lg-code{
  flex: 0 0 auto; min-width: 34px; text-align: center;
  border-radius: 7px; padding: .2rem .35rem .05rem;
  font: 800 .95rem/1.1 "Baloo 2", system-ui, sans-serif;
}
.cm-lg-name{ flex: 1 1 auto; }

/* ---------- Public page ---------- */
.map-section{ padding-top: 2rem; }
.mp-wrap{ max-width: 1280px; margin: 0 auto; }
.mp-note{ background: var(--cm-cream); border-radius: 16px; padding: 1rem 1.25rem; font-weight: 700; box-shadow: 0 8px 18px rgba(12,28,57,.15); max-width: 760px; margin: 0 auto; text-align: center; }
.mp-toolbar{ display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center; justify-content: space-between; margin: 0 0 1rem; }
.mp-hint{ margin: 0; font-weight: 700; max-width: 60ch; }
.mp-print{ display: flex; gap: .5rem; align-items: center; }
.mp-print label{ font-weight: 700; font-size: .9rem; }
.mp-print select{ font: inherit; font-size: 15px; padding: .5rem .6rem; border: 1px solid rgba(12,28,57,.25); border-radius: 10px; background: #fff; color: var(--cm-navy); }
.mp-print .btn{ display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; border: 0; font: inherit; font-weight: 800; }
.mp-print .btn svg{ width: 18px; height: 18px; }
.mp-layout{ display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.mp-mapcol{ background: var(--cm-cream); border-radius: 22px; padding: 8px; box-shadow: 0 14px 30px rgba(12,28,57,.25); }
.mp-side{ position: sticky; top: 1rem; }
.mp-side .cm-legend-wrap{ background: var(--cm-cream); border-radius: 20px; padding: 1rem 1rem 1.1rem; box-shadow: 0 12px 26px rgba(12,28,57,.22); }
.mp-foot{ font-size: .85rem; margin: 1rem 0 0; text-align: center; font-weight: 600; }
.mp-print-head, .mp-print-url{ display: none; }

@media (max-width: 900px){
  .map-section{ padding-left: 1rem; padding-right: 1rem; }
  .mp-layout{ grid-template-columns: 1fr; }
  .mp-side{ position: static; }
  .cm-map{ height: 62vh; min-height: 360px; border-radius: 14px; }
  .mp-print{ width: 100%; }
  .mp-print select{ flex: 1; }
}

/* ---------- Printing ----------
   The script adds body.cm-printing just before printing, which fixes the map to the paper size
   so it can be refitted to the area being printed. */
body.cm-printing .cm-map{ width: 196mm; height: 158mm; min-height: 0; }
body.cm-printing.cm-a3 .cm-map{ width: 300mm; height: 240mm; }

@media print{
  @page{ size: A4 landscape; margin: 10mm; }
  html, body{ background: #fff !important; }
  body{ -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .skip-link, .site-header, .hero, .river-divider, .cloud, .critters, .scouts-footer, .mp-toolbar,
  .cm-d-close, .cm-lg-toggle input, .leaflet-control-zoom, .cm-switch, .cm-home{ display: none !important; }
  .sky{ background: none !important; min-height: 0 !important; padding: 0 !important; }
  .bush{ background: none !important; padding: 0 !important; }
  .mp-wrap{ max-width: none; }
  .mp-print-head{
    display: flex; align-items: center; gap: 5mm;
    border-bottom: 1.5mm solid var(--cm-gold); padding-bottom: 2.5mm; margin-bottom: 4mm;
  }
  .mp-print-head img{ height: 16mm; width: auto; }
  .mp-print-head .mp-print-scouts{ margin-left: auto; height: 11mm; }
  .mp-print-head h1{ margin: 0; font-size: 20pt; line-height: 1; color: var(--cm-navy); }
  .mp-print-head p{ margin: 1mm 0 0; font-size: 10pt; font-weight: 700; }
  .mp-print-url{ display: inline; }
  .mp-layout{ display: flex; gap: 5mm; align-items: flex-start; }
  .mp-mapcol{ box-shadow: none; padding: 0; border-radius: 0; background: none; flex: 0 0 auto; }
  .cm-map{ border-radius: 0; border: .3mm solid #999; }
  .mp-side{ position: static; flex: 1 1 auto; min-width: 0; }
  .mp-side .cm-legend-wrap, .cm-detail{ box-shadow: none; border: 0; padding: 0; background: none; border-radius: 0; }
  .cm-detail{ margin-bottom: 4mm; padding-bottom: 3mm; border-bottom: .3mm solid #ccc; }
  .cm-d-photo img{ max-height: 45mm; }
  .cm-legend-wrap h2{ font-size: 13pt; margin-bottom: 1.5mm; }
  .cm-lg-group + .cm-lg-group{ margin-top: 2mm; }
  .cm-lg-head{ font-size: 7.5pt; margin-bottom: .5mm; }
  .cm-lg-item{ font-size: 9pt; padding: .4mm 0; gap: 2mm; }
  .cm-lg-item.on{ background: none; font-weight: 800; }
  .cm-lg-code{ min-width: 9mm; font-size: 9pt; }
  .cm-lg-list.off, .cm-lg-group:has(.cm-lg-list.off){ display: none; }
  .mp-foot{ font-size: 8pt; text-align: left; margin-top: 3mm; }
  .leaflet-control-attribution{ font-size: 7pt !important; }
  .leaflet-control-scale{ display: block !important; }
}
