#map { width: 100%; height: 100%; flex: 1; grid-area: map;}

#map-container { 
    display: grid; 
    grid-template-areas: 
    "nav sidebar"
    "map sidebar";
  grid-template-columns: 1fr min-content; /* Sidebar width, content takes the rest */
  grid-template-rows: min-content 1fr; /* Nav height, rest fills space */
  /* height: 100vh; Full viewport height */
    height: 100%; 
    position: relative;
}



h2 {
    margin: 0.25em 0;
}

#measureselect {
    grid-area: nav;
    background-color: var(--concrete);
    color: var(--parchment);
    /* position: relative; */
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5;
}

#measureselect .measureselect-toggle {
    display: none;
}

#measureselect .measureselect-toggler {
    position: absolute;
    right: 10px;
    bottom: -20px;
    width: 35px;
    height: 25px;
    cursor: pointer;
    z-index: 15;
    border-radius: 0 0 10px 10px;
}

#measureselect:has(.measureselect-toggle:checked)::after {
    content: "∨";
}

#measureselect:has(.measureselect-toggle:checked) .measurebar {
    /* max-height: calc(1.6em + 6px); */
    max-height: 0px;
    padding-top: 2px;
    padding-bottom: 0;
    overflow: hidden;
}

/* #measureselect:has(.measureselect-toggle:checked) .measurebar button:not([autofocus]) {
    display: none;
} */


.categorybar, .measurebar {
    width: calc(100% - 10px);
    overflow: hidden;
    max-height: 999px;
    transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.2s ease;
}

.categorybar {
    padding: 0px 5px;
    border-top: 2px solid var(--concrete);
    background-color: var(--charcoal);
    color: var(--parchment);
    display: grid;
    grid-auto-flow: column;
    grid-template-columns: repeat(auto-fill, minmax(fit-content , 1fr));
    gap: 0px;
    border-bottom: none;
    /* grid-template-rows: 100%; */
}
#measureselect .categorybar button {
    padding-top: 3px;
    height: 100%;
    background-color: var(--charcoal);
    color: var(--parchment);
}
#measureselect .categorybar button:hover {
    background-color: var(--forest-green) !important; 
    filter: brightness(100%);
}
#measureselect .categorybar button[autofocus] {
    border-bottom: 3px solid var(--sea-foam);
    background-color: var(--charcoal);
}

#measureselect .measurebar {
    display: grid;
    padding: 5px;
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    gap: 1px;
    border-bottom: 2px solid var(--charcoal);
    background-color: var(--light-charcoal);
    gap: 3px;
}

#measureselect button {
    opacity: 1;
    border: none;
    background-color: var(--light-charcoal);
}

#measureselect .measurebar button {
    background-color: var(--concrete);
    /* border: 1px solid var(--light-charcoal); */
}

#measureselect button:hover {
    filter: brightness(85%);
}
#measureselect button:active {
    filter: brightness(100%);
}

#measureselect button[autofocus] {
    background-color: var(--sea-foam);
}

/* .container {
    width: 95%;
} */

.measure {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    margin-bottom: 3px;
    margin-left: -5px;
    padding: 0px 5px;
    background: var(--warm-cloud);
    width: 100%;
    list-style: none;
}

.measure::-webkit-details-marker {
  display: none;
}

.name {
    margin: auto 0px;
    padding: 4px 0px;
    border: none;
    background-color: inherit;
}

.priority {
    font-weight: bold;
}

#sidebar {
    grid-area: sidebar;
    padding: 0px 16px; 
    background: var(--parchment); 
    overflow-y: auto;
    width: 370px;
    overflow-x: hidden;
    position: relative;
    scrollbar-width: none;
    box-shadow: 3px 0px 3px -2px gray inset;
}

.blurb {
    font-size: small;
    /* width: 95%; */
    margin: 0.5em
}

.category-header {
    font-size: large;
    font-weight: bold;
    padding-top: 0.5em;
    padding-bottom: 0.5em;
}

summary {
    padding: 0.25em 0;
    cursor: pointer;
    font-weight: bold;
}
summary:hover {
  filter: brightness(0.8);
}

.container {
    border: 1px solid var(--wool);
    border-left: 3px solid var(--wool);
}

.category-group, .container {
    border-radius: 3px;
    border-left: 3px solid var(--wool);
    margin-bottom: 0.5em;
    padding: 0 5px;
    background-color: var(--warm-cloud);
    width: calc(100% - 10px);
}

/* .category-header {
    padding-left: 5px;
} */

.value {
    padding: 0.2em;
    display: inline-block;
    text-align: right;
    margin-top: auto;
    margin-bottom: auto;
    font-weight: normal;
    font-size: initial;
}

/* .container>div {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
} */
.container > div {
    display: grid;
    grid-auto-flow: column;
    justify-content: space-between;
}

.focus {
    border-width: 3px;
    background-color: var(--sea-foam);
    border-color: var(--forest-green);
}

.detail {
    visibility: hidden;
    height: 0px;
}
.focus + .detail {
    visibility: visible !important;
    height: fit-content !important;
}

div:has(+ .delta) {
    grid-column: 2;
}

.delta{
    color: var(--charcoal);
    /* flex-basis: 100%; */
    grid-row: 2;
    grid-column: 2;
    font-size: 0.85em;
    justify-self: end;
}

.download{
    margin-left: auto;
    margin-right: auto;
    height: fit-content;
    width: fit-content;
    padding: 0.5em;
    background-color: var(--concrete);
}
.download a {
    padding: 0.5em;
    color: black;
    text-decoration: none;
    margin-bottom: 5px;
}

.download a:visited {
    color: var(--violet);
}
.download a:active {
    color: var(--violet);
}


.legend {
  background: white;
  padding: 10px;
  font-family: sans-serif;
  font-size: 12px;
  position: absolute;
  bottom: 30px;
  left: 10px;
  z-index: 2;
  border-radius: 5px;
  box-shadow: 0 0 5px rgba(0,0,0,0.3);
}
.legend h4 {
  margin: 0 0 5px;
}
.legend div {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}
.legend span {
  display: inline-block;
  width: 20px;
  height: 10px;
  margin-right: 8px;
}

.container[open]>.measure>.value {
    visibility: hidden;
    height: 1.125em;
}

.container[open]>.measure>.value>.priority {
    height: 1.125em;
    visibility: visible;
}

.lr {
    display: flex;
    flex-direction: row;
    margin-left: auto;
    margin-right: auto;
}

#measureselect::after {
    content: "∧";
    position: absolute;
    right: 12px;
    bottom: -20px;
    background-color: var(--concrete);
    color: white;
    padding: 0px 8px 4px;
    border-radius: 0 0 10px 10px;
    font-size: 0.9rem;
    line-height: 1;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 2px solid var(--charcoal);
    border-top: var(--light-charcoal) 2px solid;
}

@media (orientation: portrait), (max-width: 900px) {
  #map-container {
    grid-template-areas:
      "nav"
      "map"
      "sidebar";
    grid-template-columns: 1fr;
    grid-template-rows: min-content 1fr 30vh;
    /* height: 100vh; */
    z-index: 1;
  }
  #content {
    height: calc(100vh - 3.5em);
  }

  #sidebar {
    width: calc(100% - 32px);
    height: 100%;
    z-index: 0;
  }

  .legend {
    bottom: calc(30vh + 10px);
  }
}