html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#map {
  position: fixed;
  inset: 0;
  /* The ocean: countries are drawn on top of this. */
  background: #a9d3de;
  cursor: grab;
}

#map.leaflet-dragging {
  cursor: grabbing;
}

.country-label span {
  position: absolute;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #4d4a44;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff;
  pointer-events: none;
  user-select: none;
}

.city-label .city-dot {
  position: absolute;
  left: -3px;
  top: -3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #5b5547;
  box-shadow: 0 0 0 1.5px #fff;
}

.city-label--capital .city-dot {
  left: -4px;
  top: -4px;
  width: 4px;
  height: 4px;
  background: #fff;
  border: 2px solid #5b5547;
  box-shadow: 0 0 0 1px #fff;
}

.city-label .city-name {
  position: absolute;
  left: 6px;
  top: 0;
  transform: translateY(-50%);
  white-space: nowrap;
  font-size: 11px;
  color: #3f3c36;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff;
  pointer-events: none;
  user-select: none;
}

.city-label--capital .city-name {
  font-weight: 600;
}

/* --- View switcher ------------------------------------------------------- */

.view-switch {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  padding: 3px;
  gap: 2px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.view-switch button {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #4d4a44;
  cursor: pointer;
}

.view-switch button:hover {
  background: #f1ede4;
}

.view-switch button[aria-pressed="true"] {
  background: #3f6f80;
  color: #fff;
}

.view-switch button:focus-visible {
  outline: 2px solid #3f6f80;
  outline-offset: 2px;
}

/* --- Menu ----------------------------------------------------------------- */

.menu-wrap {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1000;
}

.menu-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #4d4a44;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.menu-button:hover,
.menu-button[aria-expanded="true"] {
  background: #f1ede4;
}

.menu {
  position: absolute;
  top: 48px;
  right: 0;
  min-width: 200px;
  padding: 6px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.menu[hidden] {
  display: none;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  font-size: 14px;
  color: #3f3c36;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover {
  background: #f1ede4;
}

a.menu-item {
  text-decoration: none;
  box-sizing: border-box;
}

.menu-icon {
  display: flex;
  width: 16px;
  height: 16px;
  flex: none;
  color: #6b6558;
}

.menu-section {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #ebe6db;
}

.menu-heading {
  padding: 6px 10px 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8a8373;
}

.menu-setting {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 14px;
  color: #3f3c36;
}

.menu-setting label {
  flex: 1;
}

.menu-setting input[type="color"] {
  width: 32px;
  height: 24px;
  padding: 0;
  border: 1px solid #d6d0c3;
  border-radius: 5px;
  background: none;
  cursor: pointer;
}

.menu-setting input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.menu-setting input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 3px;
}

.menu-reset {
  padding: 2px 6px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 12px;
  color: #3f6f80;
  cursor: pointer;
}

.menu-reset[hidden] {
  display: none;
}

.menu-reset:hover {
  text-decoration: underline;
}

.menu-check {
  width: 16px;
  height: 16px;
  flex: none;
  border: 1.5px solid #9c9585;
  border-radius: 4px;
  box-sizing: border-box;
}

.menu-item[aria-checked="true"] .menu-check {
  background: #3f6f80 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
  border-color: #3f6f80;
}

.menu-button:focus-visible,
.menu-item:focus-visible {
  outline: 2px solid #3f6f80;
  outline-offset: 2px;
}

/* --- Visited legend ------------------------------------------------------- */

.visited-legend {
  position: fixed;
  left: 12px;
  bottom: 24px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  font-size: 13px;
  color: #3f3c36;
}

.visited-legend[hidden] {
  display: none;
}

.visited-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--visited-color, #1d4f91);
  border: 1px solid #b3a995;
}

/* --- Logo ----------------------------------------------------------------- */

.app-logo {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 1000;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  user-select: none;
}

/* --- Travel By Month ------------------------------------------------------ */

.planner {
  position: fixed;
  top: 64px;
  right: 12px;
  bottom: 96px;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  width: 320px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  color: #3f3c36;
}

.planner[hidden] {
  display: none;
}

.planner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 6px 16px;
}

.planner-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.planner-close {
  display: flex;
  padding: 6px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: #6b6558;
  cursor: pointer;
}

.planner-close:hover {
  background: #f1ede4;
}

.planner-months {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px 16px;
}

.planner-month {
  padding: 6px 0;
  border: 1px solid #e7e1d5;
  border-radius: 7px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  color: #3f3c36;
  cursor: pointer;
}

.planner-month:first-child {
  grid-column: 1 / -1;
}

.planner-month:hover {
  border-color: #cfc8b9;
}

.planner-month[aria-pressed="true"] {
  background: #2f9e6e;
  border-color: #2f9e6e;
  color: #fff;
}

.planner-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid #ebe6db;
}

.planner-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
}

.planner-filter--check {
  justify-content: flex-start;
  cursor: pointer;
}

.planner-filter select {
  padding: 4px 6px;
  border: 1px solid #d6d0c3;
  border-radius: 6px;
  background: #fff;
  font: inherit;
  font-size: 14px;
  color: #3f3c36;
}

.planner-filter input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #3f6f80;
}

.planner-summary {
  margin: 0;
  padding: 10px 16px 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #8a8373;
}

.planner-list {
  flex: 1;
  margin: 0;
  padding: 0 8px 8px;
  overflow-y: auto;
  list-style: none;
}

.planner-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 9px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.planner-item:hover {
  background: #f4f1ea;
}

.planner-flag {
  font-size: 20px;
  line-height: 1.2;
}

.planner-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.planner-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
}

.planner-badge {
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--visited-color, #1d4f91);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.planner-detail {
  font-size: 13px;
  color: #7d7667;
}

.planner-places {
  font-size: 13px;
  font-weight: 500;
  color: #2f9e6e;
}

.planner-empty {
  padding: 12px 8px;
  font-size: 14px;
  color: #7d7667;
}

.planner-month:focus-visible,
.planner-item:focus-visible,
.planner-close:focus-visible {
  outline: 2px solid #3f6f80;
  outline-offset: 1px;
}

/* Focus places pinned on the map (e.g. Banff, Jasper). */
.place-label .place-pin {
  position: absolute;
  left: -6px;
  top: -6px;
  width: 8px;
  height: 8px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #c2410c;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.place-label .place-name {
  position: absolute;
  left: 8px;
  top: 0;
  transform: translateY(-50%);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  color: #9a3412;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff;
  pointer-events: none;
}

/* On phones the panel becomes a sheet along the bottom. */
@media (max-width: 640px) {
  .planner {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 55vh;
    border-radius: 14px 14px 0 0;
  }

  .planner-months {
    grid-template-columns: repeat(7, 1fr);
  }

  .planner-month:first-child {
    grid-column: auto;
  }
}
