/* HandyMaps Responsive & Accessibility — contrast hardening and breakpoint behavior */

:root {
  --hm-safe-gap: 12px;
  --hm-header-clearance: 50px;
  --hm-sidebar-width: 360px;
}
html, body, #app {
  max-width: 100%;
  -ms-scroll-chaining: none;
  overscroll-behavior: none;
}
.app-header,
    .map-title-card,
    .sidebar-card,
    .header-filter-popover,
    .search-suggestions,
    .fancybox-card,
    .screen-card {
  max-width: 100%;
}
.brand,
    .brand span:last-child,
    .header-search-wrap,
    .search-box,
    .stat-chip,
    .sidebar-card,
    .category-copy,
    .location-row span,
    .suggestion-row span {
  min-width: 0;
}
.brand strong,
    .brand small,
    .stat-chip strong,
    .stat-chip small,
    .location-row strong,
    .suggestion-row strong,
    .gallery-card strong {
  overflow-wrap: anywhere;
}
.app-header {
  min-height: 40px;
    max-height: 60px;
    align-items: center;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
}
.header-search-row { min-width: 0; }
.header-stats {
  min-width: 0;
  flex-wrap: nowrap;
  justify-content: flex-end;
}
.live-date-time-chip strong {
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-glass-top { max-width: min(460px, calc(100% - var(--hm-sidebar-width) - 86px)) !important; }
.info-sidebar { width: min(var(--hm-sidebar-width), calc(100% - 36px)) !important; }
@media (max-width: 1320px) {
  .app-header {
    grid-template-columns: minmax(166px, 240px) minmax(250px, 1fr) auto !important;
    gap: 9px !important;
    padding: 9px 10px !important;
  }
  .brand-mark {
    width: 38px !important;
    height: 38px !important;
    border-radius: 12px !important;
  }
  .brand strong { font-size: 13.5px !important; }
  .brand small { font-size: 9.5px !important; }
  .filter-button { min-width: 92px !important; }
  .live-date-time-chip { min-width: 154px !important; }
  .weather-chip { min-width: 106px !important; }
  .stat-chip {
    height: 42px !important;
    padding-inline: 8px !important;
  }
}
@media (max-width: 1120px) {
  :root { --hm-header-clearance: 156px; }
  .app-header {
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-areas: "brand stats"
          "search search";
    align-items: center;
    row-gap: 8px !important;
  }
  .brand { grid-area: brand; }
  .header-search-wrap { grid-area: search; }
  .header-stats {
    grid-area: stats;
    display: grid !important;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    align-items: center;
  }
  .header-search-row { grid-template-columns: minmax(0, 1fr) auto !important; }
  .filter-button { width: auto !important; }
  .map-glass-top {
    top: calc(var(--hm-safe-gap) + var(--hm-header-clearance)) !important;
    left: 18px !important;
    right: 86px !important;
    max-width: 560px !important;
  }
  .map-title-card { max-width: min(560px, 100%) !important; }
  .info-sidebar {
    display: flex !important;
    position: absolute !important;
    top: calc(var(--hm-safe-gap) + var(--hm-header-clearance)) !important;
    left: 18px !important;
    right: auto !important;
    bottom: 18px !important;
    max-height: none !important;
    height: auto !important;
    width: min(372px, calc(100% - 36px)) !important;
    z-index: 118 !important;
    transform: none;
  }
  .app-shell.sidebar-collapsed .info-sidebar {
    transform: translateX(calc(-100% - 32px)) !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
  .sidebar-toggle-btn { display: grid !important; }
  .map-tools { right: 18px !important; }
  .coordinate-card { max-width: min(420px, calc(100% - 118px)); }
  .tile-debug-card { display: none !important; }
}
@media (max-width: 820px) {
  :root {
    --hm-safe-gap: 10px;
    --hm-header-clearance: 186px;
  }
  .app-shell { padding: 10px !important; }
  .map-layout {
    inset: 10px !important;
    width: calc(100% - 20px) !important;
    height: calc(100% - 20px) !important;
  }
  .app-header {
    top: 10px !important;
    left: 10px !important;
    right: 10px !important;
    grid-template-columns: 1fr !important;
    grid-template-areas: "brand"
          "search"
          "stats";
    padding: 10px !important;
  }
  .brand small { white-space: normal !important; }
  .header-stats {
    width: 100%;
    grid-auto-flow: unset;
    grid-template-columns: minmax(0, 1fr) 110px 44px 44px;
    gap: 7px !important;
  }
  .live-date-time-chip,
      .weather-chip,
      .theme-toggle-btn,
      .screensaver-toggle-btn,
      .sidebar-toggle-btn {
    width: 100% !important;
    min-width: 0 !important;
  }
  .theme-toggle-btn, .screensaver-toggle-btn, .sidebar-toggle-btn {
    width: 44px !important;
    min-width: 44px !important;
  }
  .weather-chip { grid-template-columns: 28px minmax(0,1fr) !important; }
  .weather-anim {
    width: 28px !important;
    height: 28px !important;
    transform: scale(.88);
    transform-origin: center;
  }
  .map-glass-top {
    top: calc(var(--hm-safe-gap) + var(--hm-header-clearance)) !important;
    left: 14px !important;
    right: 70px !important;
    max-width: none !important;
  }
  .map-title-card {
    padding: 11px 12px !important;
    border-radius: 18px !important;
  }
  .map-title-card h1 { font-size: 18px !important; }
  .map-title-card p { display: none; }
  .tile-source-pill { max-width: 100%; }
  .info-sidebar {
    top: calc(var(--hm-safe-gap) + var(--hm-header-clearance)) !important;
    left: 14px !important;
    right: 14px !important;
    bottom: 14px !important;
    width: auto !important;
    border-radius: 20px;
    padding-right: 2px !important;
  }
  .sidebar-card {
    padding: 13px !important;
    border-radius: 17px !important;
  }
  .sidebar-card h2 { font-size: 15.5px !important; }
  .location-list { max-height: 34vh !important; }
  .map-tools {
    top: auto !important;
    right: 14px !important;
    bottom: 76px !important;
    transform: none !important;
  }
  .tool-btn {
    width: 36px !important;
    height: 36px !important;
  }
  .coordinate-card {
    left: 14px !important;
    right: 66px !important;
    bottom: 14px !important;
    min-width: 0 !important;
    max-width: none !important;
    padding: 9px 10px !important;
  }
}
@media (max-width: 560px) {
  :root {
    --hm-safe-gap: 8px;
    --hm-header-clearance: 60px;
  }
  .app-shell { padding: 8px !important; }
  .map-layout {
    inset: 8px !important;
    width: calc(100% - 16px) !important;
    height: calc(100% - 16px) !important;
  }
  .app-header {
    top: 8px !important;
    left: 8px !important;
    right: 8px !important;
    border-radius: 18px !important;
    gap: 8px !important;
  }
  .brand { gap: 8px !important; }
  .brand-mark {
    width: 36px !important;
    height: 36px !important;
  }
  .brand strong { font-size: 13px !important; }
  .brand small { font-size: 9px !important; }
  .header-search-row {
    grid-template-columns: minmax(0, 1fr) 46px !important;
    gap: 7px !important;
  }
  .search-box {
    height: 42px !important;
    border-radius: 14px !important;
    padding: 0 9px !important;
  }
  .search-box input { font-size: 12.5px !important; }
  .search-kbd { display: none !important; }
  .filter-button {
    min-width: 46px !important;
    width: 46px !important;
    height: 42px !important;
    padding: 0 !important;
    border-radius: 14px !important;
    position: relative;
  }
  .filter-button span { display: none !important; }
  .filter-button b {
    position: absolute;
    right: -5px;
    top: -6px;
    min-width: 18px !important;
    height: 18px !important;
    font-size: 8px !important;
  }
  .header-stats {
    grid-template-columns: minmax(0, 1fr) 42px 42px 42px;
    gap: 6px !important;
  }
  .stat-chip {
    height: 40px !important;
    border-radius: 13px !important;
    padding: 5px 7px !important;
  }
  .stat-chip small {
    font-size: 7px !important;
    letter-spacing: .04em !important;
  }
  .stat-chip strong { font-size: 10.5px !important; }
  .weather-chip {
    display: grid !important;
    place-items: center !important;
    grid-template-columns: 1fr !important;
    width: 42px !important;
    min-width: 42px !important;
    padding: 0 !important;
  }
  .weather-chip > span:last-child { display: none !important; }
  .theme-toggle-btn,
      .sidebar-toggle-btn {
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    border-radius: 40px !important;
  }
  .theme-toggle-btn { padding: 3px !important; }
  .theme-toggle-btn span {
    height: 32px !important;
    font-size: 12px !important;
  }
  .sidebar-toggle-btn {padding: 10px !important;}
  .search-suggestions,
      .header-filter-popover {
    position: fixed !important;
    left: 0px !important;
    right: 0px !important;
    /* top: 0; */
    width: auto !important;
    max-height: min(50vh, 350px) !important;
    z-index: 220 !important;
  }
  .header-filter-popover .category-list { max-height: 40vh !important; }
  .map-glass-top { display: none !important; }
  .info-sidebar {
    top: calc(var(--hm-safe-gap) + var(--hm-header-clearance)) !important;
    left: 10px !important;
    right: 10px !important;
    bottom: 10px !important;
    width: auto !important;
    gap: 9px !important;
  }
  .location-row { min-height: 44px; }
  .map-tools {
    right: 10px !important;
    bottom: 70px !important;
    gap: 6px !important;
  }
  .tool-group {
    padding: 4px !important;
    border-radius: 14px !important;
  }
  .tool-btn {
    width: 34px !important;
    height: 34px !important;
    border-radius: 11px !important;
  }
  .coordinate-card {
    left: 10px !important;
    right: 58px !important;
    bottom: 10px !important;
    font-size: 9px !important;
  }
  .coordinate-card strong { font-size: 9.8px !important; }
}
@media (max-width: 380px) {
  :root { --hm-header-clearance: 202px; }
  .brand small { display: none !important; }
  .header-stats { grid-template-columns: minmax(0, 1fr) 38px 38px 38px; }
  .weather-chip, .theme-toggle-btn, .sidebar-toggle-btn {
    width: 38px !important;
    min-width: 38px !important;
  }
  .live-date-time-chip strong { font-size: 9.8px !important; }
}
@media (max-height: 720px) and (max-width: 820px) {
  :root { --hm-header-clearance: 178px; }
  .brand small { display: none !important; }
  .app-header {
    gap: 6px !important;
    padding: 8px !important;
  }
  .search-box, .filter-button { height: 38px !important; }
  .stat-chip, .theme-toggle-btn, .sidebar-toggle-btn {/* height: 38px !important; */}
  .map-glass-top { display: none !important; }
  .info-sidebar,
      .search-suggestions,
      .header-filter-popover {
    top: calc(var(--hm-safe-gap) + var(--hm-header-clearance)) !important;
  }
}
.screensaver { overflow: auto !important; }
@media (max-width: 1024px) {
  .welcome-screen {
    height: auto !important;
    min-height: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: auto !important;
  }
  .welcome-hero,
      .welcome-meta,
      .welcome-data,
      .welcome-gallery,
      .welcome-map {
    grid-column: auto !important;
    grid-row: auto !important;
    min-height: 0 !important;
  }
  .welcome-hero {
    grid-column: 1 / -1 !important;
    min-height: 300px !important;
  }
  .welcome-meta.analytics-meta { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
  .welcome-gallery {
    grid-column: 1 / -1 !important;
    min-height: 260px !important;
  }
  .welcome-map {
    grid-column: 1 / -1 !important;
    min-height: 300px !important;
  }
  .welcome-gallery-grid {
    grid-template-columns: repeat(3, minmax(0,1fr)) !important;
    max-height: 300px;
  }
}
@media (max-width: 640px) {
  .screensaver { padding: 8px !important; }
  .welcome-screen {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
  .screen-card { border-radius: 20px !important; }
  .welcome-hero {
    padding: 20px !important;
    min-height: 300px !important;
  }
  .welcome-hero h2 { font-size: clamp(32px, 14vw, 48px) !important; }
  .welcome-hero p:last-child,
      .welcome-map p {
    font-size: 11px !important;
  }
  .welcome-meta.analytics-meta,
      .welcome-data.analytics-data {
    grid-template-columns: 1fr !important;
  }
  .mini-card { padding: 12px !important; }
  .welcome-gallery-grid {
    grid-template-columns: repeat(2, minmax(0,1fr)) !important;
    max-height: 300px;
  }
  .gallery-card {
    min-height: 78px;
    padding: 9px;
  }
  .welcome-map {
    padding: 18px !important;
    min-height: 300px !important;
  }
  .welcome-map h3 { font-size: 30px !important; }
}
@supports (height: 100dvh) {
  html, body, #app { height: 100dvh; }
}
.sidebar-feature-gallery {
  /* margin: 14px 0 2px;
  padding: 10px;
  border: 1px solid var(--line-dark);
  border-radius: 16px;
  background: rgba(255,255,255,.48); */
}
html[data-theme="dark"] .sidebar-feature-gallery {
  background: var(--hm-panel-soft);
  border-color: rgba(255,255,255,.13);
}
.sidebar-gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}
.sidebar-gallery-head strong {
  font-size: 11px;
  color: var(--ink);
}
.sidebar-gallery-head span {
  font-size: 9px;
  color: var(--muted);
  display: flex;
  gap: 10px;
}
.sidebar-gallery-wrap {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0,1fr) 28px;
  gap: 6px;
  align-items: center;
}
.sidebar-gallery-track {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -ms-scroll-snap-type: x mandatory;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  min-width: 0;
}
.sidebar-gallery-track::-webkit-scrollbar { display: none; }
.sidebar-gallery-item {
  scroll-snap-align: start;
  flex: 0 0 168px;
  border: 1px solid var(--line-dark);
  border-radius: 14px;
  overflow: hidden;
  padding: 0;
  background: var(--card-strong);
  color: var(--ink);
  text-align: left;
}
.sidebar-gallery-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(20,31,27,.14);
}
.sidebar-gallery-item img {
  display: block;
  width: 100%;
  height: 86px;
  -o-object-fit: cover;
  object-fit: cover;
  background: #dfe8df;
}
.sidebar-gallery-item span {
  display: block;
  padding: 8px 9px 9px;
  min-width: 0;
}
.sidebar-gallery-item strong {
  display: block;
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-gallery-item small {
  display: block;
  margin-top: 3px;
  font-size: 8px;
  color: var(--muted);
}
.gallery-nav {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line-dark);
  border-radius: 11px;
  background: var(--card-strong);
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}
.gallery-nav:hover {
  background: var(--accent);
  color: #06130f;
}
html[data-theme="dark"] .gallery-nav:hover { color: #06130f; }
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(47,174,208,.75) rgba(255,255,255,.18);
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-track { border-radius: 999px; }
*::-webkit-scrollbar-thumb { border-radius: 999px; }
.runtime-checks-title {
  margin: 3px 0 0;
  font-size: 17px;
}
.welcome-content-layer {
  position: relative;
  z-index: 2;
}
.loader-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 10px;
  color: var(--muted);
}
html:not([data-debug="true"]) .debug-only,
html[data-debug="false"] .debug-only {
  display: none !important;
}
html[data-debug="true"] .debug-only { visibility: visible; }

/* v26 swipeable map-explorer bottom sheet */
.sidebar-sheet-handle { display: none; }
@media (max-width: 1120px) {
  .info-sidebar#mapExplorerSheet {
    --sheet-y: calc(100% - 118px);
    display: flex !important;
    position: absolute !important;
    top: auto !important;
    left: 12px !important;
    right: 12px !important;
    bottom: 12px !important;
    width: auto !important;
    height: min(50dvh, 550px) !important;
    max-height: none !important;
    gap: 9px !important;
    padding: 0 8px 12px !important;
    border: 1px solid rgba(255,255,255,.78);
    border-radius: 24px 24px 18px 18px !important;
    background: rgba(247,250,246,.92);
    box-shadow: 0 -16px 60px rgba(7,17,31,.22);
    backdrop-filter: blur(26px) saturate(1.16);
    -webkit-backdrop-filter: blur(26px) saturate(1.16);
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    transform: translate3d(0, var(--sheet-y), 0) !important;
    transition: transform .3s cubic-bezier(.22,.78,.25,1), box-shadow .25s ease !important;
    z-index: 180 !important;
    will-change: transform;
  }
  html[data-theme="dark"] .info-sidebar#mapExplorerSheet {
    background: var(--hm-panel);
    border-color: rgba(255,255,255,.14);
    box-shadow: 0 -16px 60px rgba(0,0,0,.42);
  }
  .app-shell.sidebar-collapsed .info-sidebar#mapExplorerSheet {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translate3d(0, var(--sheet-y), 0) !important;
  }
  .info-sidebar#mapExplorerSheet[data-sheet-state="full"] { --sheet-y: 0px; }
  .info-sidebar#mapExplorerSheet[data-sheet-state="peek"] {--sheet-y: calc(100% - 50px);}
  .info-sidebar#mapExplorerSheet[data-dragging="true"] { transition: none !important; }
  .sidebar-sheet-handle {
    display: block;
    position: sticky;
    top: 0;
    z-index: 5;
    margin: 0 -8px 1px;
    padding: 7px 8px 3px;
    background: linear-gradient(180deg, rgba(247,250,246,.98) 76%, rgba(247,250,246,0));
    border-radius: 23px 23px 0 0;
  }
  html[data-theme="dark"] .sidebar-sheet-handle {
    background: linear-gradient(180deg, rgba(9,13,14,.99) 76%, rgba(9,13,14,0));
  }
  .sidebar-sheet-grab {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--ink);
    display: grid;
    grid-template-columns: minmax(0,1fr) 28px;
    align-items: stretch;
    gap: 10px;
    /* padding: 7px 9px 9px; */
    text-align: left;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    grid-auto-flow: column;
    align-content: space-evenly;
    justify-content: space-around;
    justify-items: stretch;
  }
  .sidebar-sheet-grip {
    position: absolute;
    left: 50%;
    top: 6px;
    width: 44px;
    height: 4px;
    transform: translateX(-50%);
    border-radius: 999px;
    background: rgba(16,24,21,.22);
  }
  html[data-theme="dark"] .sidebar-sheet-grip { background: rgba(212,175,98,.35); }
  .sidebar-sheet-label {
    display: grid;
    grid-template-columns: 28px minmax(0,1fr);
    grid-template-rows: auto auto;
    column-gap: 8px;
    align-items: center;
  }
  .sidebar-sheet-label > .hm-sprite-icon {
    grid-row: 1 / 3;
    width: 18px;
    height: 18px;
    color: var(--accent);
    justify-self: center;
  }
  .sidebar-sheet-label strong { font-size: 12px; line-height: 1.15; }
  .sidebar-sheet-label small { margin-top: 2px; color: var(--muted); font-size: 8.7px; line-height: 1.25; }
  .sidebar-sheet-caret {
    width: 15px;
    height: 15px;
    color: var(--muted);
    transition: transform .24s ease;
  }
  .info-sidebar#mapExplorerSheet[data-sheet-state="full"] .sidebar-sheet-caret { transform: rotate(180deg); }
  .info-sidebar#mapExplorerSheet .sidebar-card {flex: 0 0 auto;}
  .info-sidebar#mapExplorerSheet .sidebar-recommended-projects-card { order: 1; }
  .info-sidebar#mapExplorerSheet .sidebar-card:not(.sidebar-recommended-projects-card) { order: 2; }
  .map-tools { bottom: 128px !important; }
}
@media (max-width: 560px) {
  .info-sidebar#mapExplorerSheet {
    left: 8px !important;
    right: 8px !important;
    bottom: 8px !important;
    /* height: min(76dvh, 660px) !important; */
    border-radius: 22px 22px 16px 16px !important;
  }
  .sidebar-sheet-label small { max-width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .map-tools { bottom: 122px !important; }
}
