/* Full-window viewer and its embedded version. */
@media (max-width: 600px) {
  body:has(.postal-map-frame) .header-chulapa h1 {
    font-size: 1.8rem;
    margin-bottom: 0.3rem;
  }
  body:has(.postal-map-frame) .chulapa-subtitle {
    font-size: 1rem;
    margin-bottom: 0.5rem;
  }
}
.postal-map-frame {
  display: block;
  width: 100%;
  height: 75vh;
  min-height: 540px;
  border: 1px solid #a8c4cb;
  margin-bottom: 2rem;
}
.postal-map-page {
  margin: 0;
}
.postal-map-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  color: #333;
}
.postal-map-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.15rem 0.75rem;
  padding: 0.25rem 0.7rem;
  background: #f2f1f1;
  font-size: 0.75rem;
  line-height: 1.3;
  flex: none;
}
.postal-map-toolbar a {
  color: #262626;
  font-weight: 600;
  text-decoration: none;
}
.postal-map-toolbar a:hover,
.postal-map-toolbar a:focus-visible {
  text-decoration: underline;
}
.postal-map-toolbar span {
  margin-left: auto;
}
/* Use Focal's Bootstrap controls consistently throughout the viewer. */
.postal-map-app .viewer-controls,
.postal-map-app .postal-map-actions {
  font-family: inherit;
}
.postal-map-app :is(.viewer-controls, .postal-map-actions) :is(input, select, button) {
  box-shadow: none;
}
.postal-map-app :is(#postal-prefix, #postal-code, #address-query, #share-url, #code-filter, #code-list) {
  box-sizing: border-box;
  border: 1px solid #ced4da;
  border-radius: .25rem;
  background-color: #fff;
  color: #262626;
  font-family: inherit;
  font-size: .875rem;
  line-height: 1.5;
  padding: .25rem .5rem;
}
.postal-map-app :is(.viewer-controls, .postal-map-actions) .btn {
  box-sizing: border-box;
  font-family: inherit;
  font-size: .875rem;
  line-height: 1.5;
  min-height: 32px;
  padding: .25rem .5rem;
  border-width: 1px;
  border-radius: .25rem;
  text-transform: none;
}
.postal-map-app :is(#postal-search, #address-search, #browse-codes) .btn-primary {
  background: #ff9285;
  border-color: #ff9285;
  color: #262626;
}
.postal-map-app :is(#postal-search, #address-search, #browse-codes) .btn-primary:hover {
  background: #ff7160;
  border-color: #ff7160;
}
.postal-map-app .postal-map-actions #share-view {
  background: #fff;
  color: #6e6e6e;
  border-color: #6e6e6e;
  font-weight: 400;
  font-size: .75rem;
  padding: .2rem .4rem;
}
.postal-map-app .postal-map-actions #share-view:hover {
  background: #6e6e6e;
  color: #fff;
}
.postal-map-app #code-list {
  height: auto;
  min-height: 9rem;
}
.postal-map-app #code-list option {
  padding: .2rem .35rem;
}
.postal-map-app .leaflet-container {
  font-family: inherit;
}
#postal-map .leaflet-popup-content-wrapper,
#postal-map .leaflet-tooltip {
  background: #fff;
  color: #262626;
  border: 1px solid #ced4da;
  border-radius: .25rem;
  box-shadow: none;
}
#postal-map .leaflet-popup-tip {
  background: #fff;
  box-shadow: none;
}
#postal-map .leaflet-popup-content,
#postal-map .leaflet-tooltip {
  font-size: .875rem;
  line-height: 1.5;
}
#postal-map .leaflet-popup-content strong {
  color: #262626;
  font-size: inherit;
  font-weight: 600;
}
#postal-map .leaflet-popup-content {
  margin: .5rem 1.75rem .5rem .625rem;
}
#postal-map .leaflet-popup-close-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: #262626;
  font: 1.125rem/1 "Fira Sans", sans-serif;
  border-radius: .25rem;
  text-decoration: none;
}
#postal-map .leaflet-popup-close-button:hover {
  background: #fff0ed;
}
#postal-map .leaflet-popup-close-button:focus-visible {
  outline: 2px solid #262626;
  outline-offset: -3px;
}
.postal-map-app :is(input, select, button):focus-visible {
  outline: 2px solid #262626;
  outline-offset: 2px;
}
@media (max-width: 600px) {
  #postal-map .leaflet-popup-content {
    margin-right: 2.125rem;
  }
  #postal-map .leaflet-popup-close-button {
    width: 32px;
    height: 32px;
  }
  .postal-map-app .postal-map-actions #share-view {
    font-size: .75rem;
    padding-inline: .4rem;
  }
  .postal-map-app :is(.viewer-controls, .postal-map-actions) :is(.form-control, .btn) {
    min-height: 44px;
  }
  .postal-map-app :is(#postal-prefix, #postal-code, #address-query, #share-url, #code-filter, #code-list) {
    font-size: 16px;
  }
}
.viewer-controls {
  flex: none;
  background: #fff;
  border-bottom: 1px solid #e3e3e3;
}
.viewer-controls > summary {
  display: none;
  cursor: pointer;
  padding: 0.65rem 0.7rem;
  font-weight: 600;
  font-size: 0.875rem;
}
.viewer-controls-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(20rem, 1fr);
  column-gap: 1rem;
  padding: 0.4rem 0.7rem 0.5rem;
}
.viewer-onboarding {
  grid-column: 1 / -1;
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  color: #333;
}
.postal-map-controls,
.postal-search-panel {
  min-width: 0;
  font-size: 0.8rem;
}
.prefix-row {
  display: grid;
  grid-template-columns: auto minmax(0, 20rem) auto 1.5rem;
  justify-content: start;
  gap: 0.35rem;
  align-items: center;
}
.prefix-row label {
  margin: 0;
}
#postal-prefix {
  width: 100%;
  max-width: 20rem;
  height: 2rem;
  padding: 0.15rem 0.3rem;
  font-size: 0.8rem;
}
#map-status {
  margin: 0;
  font-size: 0.75rem;
  white-space: nowrap;
  color: #333;
}
#map-status[data-state="error"] {
  grid-column: 1 / -1;
  white-space: normal;
  color: #965047;
}
.help-toggle {
  flex: none;
  appearance: none;
  grid-column: 4;
  grid-row: 1;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 1px solid #999;
  background: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  color: #333;
}
.help-toggle:hover,
.help-toggle[aria-expanded="true"] {
  background: #f0f0f0;
  border-color: #666;
}
.help-text {
  font-size: 0.75rem;
  margin: 0.3rem 0 0;
  color: #333;
  overflow-wrap: anywhere;
}
.search-tabs {
  display: flex;
  width: fit-content;
  max-width: 100%;
  border: 1px solid #ccc;
  border-radius: 4px;
  border-bottom: 1px solid #ccc;
  margin-bottom: 0.35rem;
}
.tab {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: #444;
  margin-bottom: -1px;
}
.tab:hover {
  color: #222;
  background: #f2f1f1;
}
.tab.active {
  color: #965047;
  border-bottom-color: #965047;
  font-weight: 600;
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}
#postal-search,
#address-search {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}
#postal-code {
  width: 7.5rem;
  padding: 0.25rem 0.4rem;
}
#address-query {
  flex: 1;
  min-width: 0;
  max-width: 32rem;
  padding: 0.25rem 0.4rem;
}
#postal-code-status,
#address-status {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
}
#postal-code-status:empty,
#address-status:empty {
  margin: 0;
}
#postal-search button,
#address-search button[type="submit"],
.postal-map-actions button {
  appearance: none;
  padding: 5px 12px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  background: #fff;
  color: #333;
  cursor: pointer;
  text-transform: none;
  box-shadow: none;
}
#postal-search button:hover,
#address-search button[type="submit"]:hover,
.postal-map-actions button:hover {
  background: #f4f4f4;
}
#address-results {
  list-style: none;
  padding: 0;
  margin: 0.3rem 0 0;
  max-height: 9rem;
  overflow-y: auto;
}
#address-results button {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid #ddd;
  padding: 0.4rem;
}
#address-results button:hover,
#address-results button:focus-visible {
  background: #fff0ed;
}
.postal-map-actions {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  flex: none;
}
.postal-map-actions #share-view {
  background: #fff;
  color: #965047;
  border-color: #bbb;
  font-weight: 600;
}
.postal-map-actions #share-view:hover {
  background: #f2f1f1;
  border-color: #965047;
}
#share-url {
  width: 100%;
}
#share-panel:not([hidden]) {
  display: flex;
  align-items: center;
  gap: .35rem;
  width: 100%;
}
#share-panel #share-url {
  flex: 1;
  min-width: 0;
}
.postal-map-app #share-close {
  flex: none;
  width: 32px;
  padding: 0;
  font-size: 1.25rem;
  color: #262626;
  border-color: #6e6e6e;
  background: #fff;
}
@media (max-width: 600px) {
  .postal-map-app #share-close {
    width: 44px;
    min-height: 44px;
  }
}
#share-status:empty {
  display: none;
}
.postal-legend {
  margin-left: auto;
}
.postal-code-browser-content {
  position: absolute;
  top: 100%;
  left: 0.7rem;
  z-index: 1300;
  width: min(320px, calc(100% - 1.4rem));
  max-height: min(55dvh, var(--code-list-height, 55dvh));
  box-sizing: border-box;
  overflow-y: auto;
  padding: 0.75rem;
  background: #fff;
  border: 1px solid #bbb;
  border-radius: 4px;
}
.postal-code-browser-content input {
  min-height: 44px;
  font-size: 16px;
}
.postal-code-browser summary {
  cursor: pointer;
  padding: 0.4rem;
}
.postal-code-browser-content label,
.postal-code-browser-content input,
.postal-code-browser-content select {
  display: block;
  width: 100%;
  margin-bottom: 0.4rem;
}
#postal-search button,
#address-search button[type="submit"] {
  color: #fff;
  background: #965047;
  border-color: #965047;
}
#postal-search button:hover,
#address-search button[type="submit"]:hover {
  background: #784039;
}
.postal-legend summary {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid #999;
  border-radius: 4px;
  background: #fff;
  color: #333;
  cursor: pointer;
  padding: 0.4rem 0.5rem;
  list-style: none;
  font-size: 0.85rem;
}
.postal-legend summary:hover,
.postal-legend[open] > summary {
  background: #f2f1f1;
  border-color: #555;
}
.legend-key {
  width: 0.7rem;
  height: 0.7rem;
  border: 2px solid #1a3446;
  background: rgba(46, 139, 87, 0.3);
}
.code-list-label-short {
  display: none;
}
.postal-legend summary::-webkit-details-marker {
  display: none;
}
.postal-legend summary::before {
  content: "▶ ";
  font-size: 0.65rem;
}
.postal-legend[open] summary::before {
  content: "▼ ";
}
.postal-legend-content {
  position: fixed;
  right: var(--legend-right, 4rem);
  top: var(--legend-top, 12rem);
  bottom: var(--legend-bottom, 4rem);
  z-index: 1300;
  width: min(var(--legend-width, 320px), calc(100vw - 5rem));
  background: #fff;
  border: 1px solid #bbb;
  border-radius: 6px;
  padding: 1rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  font-size: 0.85rem;
  line-height: 1.5;
  overflow-y: auto;
}
.legend-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border-bottom: 1px solid #ddd;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
}
.legend-heading-row h2 {
  margin: 0;
  font-size: 1.2rem;
}
.postal-map-actions #legend-close {
  padding: 0.1rem 0.5rem;
  border: 0;
  font-size: 1.5rem;
  background: transparent;
  color: #333;
}
.postal-legend-content p {
  margin: 0.75rem 0;
}
.legend-estimated,
.legend-selected {
  display: inline-block;
  width: 1.5rem;
  height: 0.9rem;
  border: 2px solid #1a3446;
  background: rgba(46, 139, 87, 0.3);
}
.legend-selected {
  border: 3px solid #262626;
  background: rgba(255, 146, 133, 0.5);
}
.postal-map-stage {
  position: relative;
  flex: 1 1 0;
  min-height: 240px;
}
#postal-map {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  background: #f2f1f1;
  border: 1px solid #a8c4cb;
}
#postal-map .leaflet-control-layers {
  max-width: min(260px, 75vw);
}
#postal-map .leaflet-control-layers label {
  margin-bottom: 0.35rem;
}
#postal-map .leaflet-control-attribution {
  max-width: 100%;
  color: #333;
  background: rgba(255, 255, 255, 0.96);
  font-size: 0.75rem;
  line-height: 1.4;
}
#postal-map .leaflet-control-attribution a {
  color: #71302d;
  text-decoration: underline;
}
.layers-close {
  display: none;
}
.leaflet-control-layers-expanded .layers-close {
  display: block;
  margin-left: auto;
  padding: 0.15rem 0.5rem;
  border: 0;
  background: #fff;
  color: #333;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
#postal-map .postal-full-window {
  border-radius: 5px;
}
#postal-map .postal-full-window a {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: inherit;
  font-size: 28px;
  line-height: 1;
  color: #222;
  background: #fff;
  text-decoration: none;
}
#postal-map.leaflet-touch .postal-full-window a {
  width: 44px;
  height: 44px;
}
#postal-map .postal-full-window a:hover,
#postal-map .postal-full-window a:focus-visible {
  color: #b52f2b;
  background: #fff0ed;
}
.postal-map-app :focus-visible {
  outline: 2px solid #333;
  outline-offset: 2px;
}
.map-loading,
.map-background-status {
  position: absolute;
  left: 50%;
  top: 0.75rem;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: calc(100% - 7rem);
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid #ccc;
  border-radius: 0.3rem;
  color: #333;
  font-size: 0.8rem;
  pointer-events: none;
}
.map-loading[hidden],
.map-background-status[hidden] {
  display: none;
}
.map-background-status {
  top: 4rem;
  font-size: 0.8rem;
}
#map-loading[hidden] + .map-background-status {
  top: 0.75rem;
}
.map-background-status[data-state="error"] .map-spinner {
  display: none;
}
.map-spinner {
  width: 1rem;
  height: 1rem;
  flex: none;
  border: 2px solid #ddd;
  border-top-color: #965047;
  border-radius: 50%;
  animation: postal-spin 0.8s linear infinite;
}
@keyframes postal-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .map-spinner {
    animation: none;
  }
}
@media (min-width: 850px) {
  .viewer-controls-content {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    column-gap: 0.75rem;
  }
  .viewer-onboarding {
    display: none;
  }
  .prefix-row {
    grid-template-columns: auto minmax(9rem, 15rem) auto 1.5rem;
    min-height: 32px;
  }
  .postal-search-panel {
    border-left: 1px solid #ddd;
    padding-left: 0.75rem;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 0.5rem;
  }
  .search-tabs {
    width: max-content;
    height: 32px;
    box-sizing: border-box;
    margin-bottom: 0;
  }
  .search-tabs .tab {
    height: 30px;
    margin-bottom: 0;
    white-space: nowrap;
    padding-inline: 0.4rem;
  }
  .tab-panel {
    min-width: 0;
  }
  #postal-search,
  #address-search {
    flex-wrap: nowrap;
  }
  #postal-prefix,
  #postal-code,
  #address-query,
  #postal-search button,
  #address-search button[type="submit"] {
    box-sizing: border-box;
    height: 32px;
  }
  #postal-code,
  #address-query {
    width: 100%;
    min-width: 0;
    flex: 1;
  }
  #postal-search button,
  #address-search button[type="submit"] {
    flex: none;
    padding-block: 0;
  }
  #address-query {
    max-width: 20rem;
  }
  #address-search {
    max-width: 27rem;
  }
}
@media (min-width: 601px) and (max-width: 849px) {
  .viewer-controls-content {
    grid-template-columns: 1fr;
    row-gap: 0.4rem;
  }
}
@media (max-width: 600px) {
  .code-list-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .code-list-label-short {
    display: inline;
  }
  .search-tabs {
    width: 100%;
  }
  #postal-prefix,
  #postal-code,
  #address-query,
  #postal-search button,
  #address-search button[type="submit"],
  .postal-map-actions > button,
  .postal-map-actions > details > summary {
    min-height: 44px;
  }
  .help-toggle {
    width: 44px;
    height: 44px;
  }
  .share-label-detail {
    display: none;
  }
  .postal-map-actions > button,
  .postal-map-actions > details > summary {
    font-size: 0.75rem;
    padding-inline: 0.4rem;
  }
  .prefix-row {
    grid-template-columns: auto minmax(0, 1fr) auto 44px;
  }
  .viewer-controls > summary {
    display: list-item;
    min-height: 44px;
  }
  .viewer-controls-content {
    display: block;
    max-height: 40dvh;
    overflow-y: auto;
  }
  .viewer-onboarding {
    font-size: 0.8rem;
  }
  .postal-search-panel {
    margin-top: 0.5rem;
  }
  .tab {
    flex: 1;
    text-align: center;
    min-height: 40px;
  }
  .postal-map-stage {
    min-height: 65dvh;
  }
  .viewer-controls[open] ~ .postal-map-stage {
    min-height: 40dvh;
  }
  .postal-map-actions {
    min-height: 44px;
  }
  .postal-legend-content {
    top: var(--legend-top, 12rem);
    width: min(var(--legend-width, 320px), calc(100vw - 1.4rem));
  }
  #postal-code,
  #address-query {
    font-size: 16px;
  }
}
