/* Styles for page specific elements */

.homeHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.homeHeader h1 {
  font-size: 24px;
  font-family: Helvetica, Arial, sans-serif;
  text-align: center;
  padding-top: 16px;
}

h2 {
  font-size: 20px;
  font-family: Helvetica, Arial, sans-serif;
}

.homeHeader #homePage {
  width: 35px;
  height: 35px;
  padding: 11px 0 0 20px;
}

.homeHeader #dataDict {
  width: 45px;
  height: 45px;
  padding: 11px 20px 0 0;
}

#content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#textContent {
  padding: 22px;
}
/* Hidden on screen, visible in print */
#printLogoRow {
  display: none;
}

#printHuc8ResultRow {
  display: none;
}

#printAdjacentWatershedsTitle {
  display: none;
}

#printUrlRow {
  display: none;
}

#mapAndSidebar {
  display: grid;
  grid-template-columns: minmax(0, 35fr) minmax(0, 65fr);
  grid-template-areas: "sidebar map";
  gap: 0;
  align-items: start;
  overflow: hidden;
  border: 1px solid var(--border-neutral);
  border-radius: 4px;
  transition:
    grid-template-columns 220ms ease,
    gap 220ms ease;
}

#mapPane {
  min-width: 0;
  grid-area: map;
  border-left: 1px solid var(--border-neutral);
}

#map {
  position: relative;
  height: 600px;
  width: 100%;
}

.field-label {
  font-weight: bold;
}

button {
  cursor: pointer;
  font: inherit;
}

#lookupButton,
#resetButton,
#copyHuc8Button,
#mobileCopyHuc8Button,
#printMapButton,
#printModalConfirm,
#printModalCancel {
  border: 1px solid #012a52;
  border-radius: 6px;
  padding: 8px 14px;
  font-weight: 600;
  line-height: 1.2;
}

#lookupButton,
#printMapButton,
#printModalConfirm {
  background: #012a52;
  color: #ffffff;
}

#resetButton,
#copyHuc8Button,
#mobileCopyHuc8Button,
#printModalCancel {
  background: #ffffff;
  color: #012a52;
}

#huc8LookupSection {
  margin-bottom: 10px;
}

#huc8LookupForm {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-top: 10px;
}

.form-field {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 500px;
}

.radio-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.radio-element label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.radio-element {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tooltip-wrapper {
  position: relative;
  display: inline-flex;
  align-self: center;
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: #000;
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  line-height: 1;
  cursor: help;
}

.tooltip-trigger {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.tooltip-text {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  width: 240px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--border-neutral);
  font-size: 13px;
  line-height: 1.4;
  z-index: 10;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.tooltip-text::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  height: 6px;
}

.tooltip-text ul {
  margin: 0;
  padding-left: 1.2em;
}

.tooltip-text li {
  margin-bottom: 4px;
}

.tooltip-text li:last-child {
  margin-bottom: 0;
}

.tooltip-wrapper:hover .tooltip-text,
.tooltip-trigger:focus + .tooltip-text,
.tooltip-trigger[aria-expanded="true"] + .tooltip-text {
  clip: auto;
  white-space: normal;
  overflow: visible;
}

.tooltip-wrapper:focus {
  outline: none;
}

.tooltip-wrapper:focus .tooltip-icon {
  outline: 2px solid -webkit-focus-ring-color;
  outline-offset: 1px;
}

#addressInput,
#huc8CodeInput {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border-neutral);
  margin: 2px 0px;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 1rem;
}

#addressField {
  width: 100%;
}

.autocomplete-field {
  position: relative;
  width: 100%;
}

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% - 1px);
  left: 0;
  right: 0;
  z-index: 1001;
  background: white;
  border: 1px solid var(--border-neutral);
  border-top: none;
  border-radius: 0 0 4px 4px;
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.autocomplete-dropdown li {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-neutral);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.autocomplete-dropdown li:hover,
.autocomplete-dropdown li.active {
  background-color: #f0f6ff;
}

.input-example {
  margin-top: 2px;
  color: #5b6770;
  font-size: 13px;
}

.form-buttons {
  display: flex;
  gap: 8px;
}

.error-message {
  color: #d32f2f;
  font-size: 13px;
  margin-top: 2px;
}

#huc8ResultRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 14px 18px 16px 14px;
  border-left: 4px solid var(--stroke-focused);
  background-color: #e5f3ff !important;
}

#mobileSelectedWatershed {
  display: none;
}

#mobileWatershedResultsTitle {
  margin: 0;
  padding: 16px 18px 12px;
  border: 1px solid var(--border-neutral);
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  background-color: #ffffff;
  text-align: center;
}

#mobileHuc8ResultRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 8px;
  margin-bottom: 0;
  padding: 14px 18px 16px 14px;
  border-left: 4px solid var(--stroke-focused);
  border-right: 1px solid var(--border-neutral);
  border-bottom: 1px solid var(--border-neutral);
  border-radius: 0 0 4px 4px;
  background-color: #e5f3ff;
}

#mobileHuc8Result {
  flex: 1 1 220px;
  min-width: 0;
  padding: 4px 0;
  background-color: #e5f3ff;
}

#mobileHuc8Result .adjacent-huc8-card-name {
  color: var(--stroke-focused);
}

#mobileHuc8Result .adjacent-huc8-card-code {
  margin-top: 6px;
  color: #2f6999;
}

#huc8Result {
  flex: 1 1 220px;
  min-width: 0;
  padding: 4px 0;
  background-color: #e5f3ff;
}

#huc8Result .adjacent-huc8-card-name {
  color: var(--stroke-focused);
}

#huc8Result .adjacent-huc8-card-code {
  margin-top: 6px;
  color: #2f6999;
}

#copyHuc8Button {
  flex: 0 0 auto;
  margin-left: auto;
}

#copyHuc8Button.copy-success {
  color: green;
}

#adjacentHuc8Table {
  width: 100%;
  border-collapse: collapse;
  border: 2px solid var(--border-neutral);
  display: none;
}

#adjacentHuc8Table td {
  border: 1px solid var(--border-neutral);
  padding: 10px;
  width: 50%;
}

#adjacentHuc8Table td:hover {
  background-color: #f5f5f5;
}

#adjacentHuc8Table a {
  display: block;
}

#adjacentWatershedsSection {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 600px;
  max-height: 600px;
  overflow: hidden;
  width: auto;
  opacity: 1;
  padding: 0;
  border: 0;
  border-radius: 0;
  background-color: #ffffff;
  transform: none;
  transition:
    width 220ms ease,
    opacity 180ms ease,
    transform 220ms ease,
    border-color 220ms ease;
}

#adjacentWatershedsBody {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
}

#adjacentWatershedsBody.empty-state {
  justify-content: center;
  overflow: hidden;
  scrollbar-gutter: auto;
  scrollbar-width: none;
}

#adjacentWatershedsBody.empty-state::-webkit-scrollbar {
  width: 0;
  height: 0;
}

#adjacentWatershedsBody {
  scrollbar-width: none;
}

#adjacentWatershedsBody::-webkit-scrollbar {
  width: 10px;
}

#adjacentWatershedsBody:not(.empty-state):hover,
#adjacentWatershedsBody:not(.empty-state):focus-within {
  scrollbar-width: thin;
}

#adjacentWatershedsBody:not(.empty-state):hover::-webkit-scrollbar,
#adjacentWatershedsBody:not(.empty-state):focus-within::-webkit-scrollbar {
  width: 10px;
}

#adjacentWatershedsBody::-webkit-scrollbar-track {
  background: transparent;
}

#adjacentWatershedsBody::-webkit-scrollbar-thumb {
  background-color: transparent;
  border-radius: 999px;
}

#adjacentWatershedsBody:not(.empty-state):hover::-webkit-scrollbar-thumb,
#adjacentWatershedsBody:not(.empty-state):focus-within::-webkit-scrollbar-thumb {
  background-color: rgba(91, 103, 112, 0.4);
  border: 2px solid transparent;
  background-clip: padding-box;
}

#adjacentWatershedsHeader {
  background-color: #ffffff;
}

#resultsHeaderBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border-neutral);
  border-radius: 8px 8px 0 0;
}

#adjacentWatershedsSection h2 {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  text-align: left;
}

#adjacentResultsDivider {
  display: block;
  flex: 0 0 8px;
  height: 8px;
  width: 100%;
  border-top: 1px solid var(--border-neutral);
  border-bottom: 1px solid var(--border-neutral);
  background-color: #ffffff;
}

#adjacentHuc8Error {
  display: block;
  padding: 10px 18px 0;
}

#adjacentWatershedsPlaceholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px 24px;
  color: #5b6770;
  text-align: center;
}

.adjacent-placeholder-icon {
  width: 40px;
  height: 40px;
  opacity: 0.82;
}

#adjacentWatershedsPlaceholder p {
  max-width: 220px;
  margin: 0;
  line-height: 1.5;
}

#adjacentHuc8List {
  display: flex;
  flex-direction: column;
}

#adjacentHuc8List p {
  margin: 0;
  padding: 16px 18px 20px;
  color: #5b6770;
}

.adjacent-huc8-card {
  display: block;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-neutral);
  text-decoration: none;
  color: inherit;
  background-color: #ffffff;
  transition: background-color 120ms ease;
}

.adjacent-huc8-card.mobile-adjacent-last-visible {
  border-bottom: 0;
}

.adjacent-huc8-card:hover {
  background-color: #f6f9fc;
}

.adjacent-huc8-card:focus-visible {
  outline: 2px solid #012a52;
  outline-offset: -2px;
  background-color: #eef4fa;
}

.adjacent-huc8-card-name {
  display: block;
  color: #1f2a33;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
}

.adjacent-huc8-card-code {
  display: block;
  margin-top: 8px;
  color: #6e560e;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

#adjacentHuc8SeeMoreLink {
  display: none;
  width: 100%;
  margin: 0;
  padding: 14px 18px 16px;
  border: 0;
  border-top: 1px solid var(--border-neutral);
  background: transparent;
  color: #00376f;
  font: inherit;
  text-align: center;
  cursor: pointer;
}

.adjacent-see-more-icon {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

#adjacentHuc8SeeMoreLink.adjacent-see-less .adjacent-see-more-icon {
  transform: translateY(4px) rotate(-135deg);
}

#mapLegend {
  position: absolute;
  top: 20px;
  right: 20px;
  background: white;
  padding: 10px 15px;
  border-radius: 5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  pointer-events: auto;
}

.huc8-code-map-label,
.adjacent-huc8-code-map-label {
  background: transparent;
  border: none;
}

.adjacent-huc8-pattern {
  fill: url(#adjacentHuc8Pattern);
}

.huc8-code-map-label span {
  display: inline-block;
  padding: 4px 9px;
  background: #ffffff;
  border: 1px solid var(--stroke-focused);
  border-radius: 4px;
  color: #011d39;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(1, 42, 82, 0.18);
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: mapLabelEnter 180ms ease-out;
}

.adjacent-huc8-code-map-label span {
  display: inline-block;
  padding: 4px 9px;
  background: #fbf3df;
  border: 1px solid var(--stroke-adjacent);
  border-radius: 4px;
  color: #6e560e;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: mapLabelEnter 180ms ease-out;
}

@keyframes mapLabelEnter {
  from {
    opacity: 0;
    transform: translate(-50%, -42%) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}
.legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
}

.legend-item:last-child {
  margin-bottom: 0px;
}

.legend-color {
  width: 20px;
  height: 15px;
  display: inline-block;
  margin-right: 8px;
  border: 1px solid #333;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-label {
  font-size: 11px;
  line-height: 15px;
}

.hidden {
  display: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Define colors for the map legend and visualizations here, values are referenced in styles below and in MapStyles*/
:root {
  --border-neutral: #d9d9d9;
  --color-default: #d4e1ea;
  --color-focused: #6486a4;
  --color-adjacent: #c99b2f;
  --color-hover: #29b22e;
  --stroke-default: #8ea1af;
  --stroke-focused: #012a52;
  --stroke-adjacent: #7b5e11;
  --stroke-hover: #114913;
}

#focused-legend {
  background-color: var(--color-focused);
  border-color: var(--stroke-focused);
}

#adjacent-legend {
  background-color: var(--color-adjacent);
  border-color: var(--stroke-adjacent);
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(123, 94, 17, 0.34) 0 3px,
    rgba(123, 94, 17, 0) 3px 8px
  );
}

#default-legend {
  background-color: var(--color-default);
  border-color: var(--stroke-default);
}

#printRecommendModal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

#printModalContent {
  background: #ffffff;
  border-radius: 8px;
  padding: 2rem;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

#printModalButtons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

#printLoadingOverlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
}

#printLoadingContent {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: #333;
  font-size: 15px;
}

#printLoadingSpinner {
  width: 36px;
  height: 36px;
  border: 3px solid #d9d9d9;
  border-top-color: #012a52;
  border-radius: 50%;
  animation: printSpinnerRotate 0.7s linear infinite;
}

@keyframes printSpinnerRotate {
  to { transform: rotate(360deg); }
}

@media (max-width: 920px) {
  #textContent {
    padding: 15px;
  }

  #mapAndSidebar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "map"
      "sidebar";
    gap: 16px;
  }

  #adjacentWatershedsSection {
    width: auto;
    min-height: 280px;
    max-height: none;
    opacity: 1;
    overflow: visible;
    transform: none;
  }

  #adjacentWatershedsBody {
    overflow: visible;
  }
}

@media (min-width: 701px) and (max-width: 1024px) {
  #resultsHeaderBar,
  #huc8ResultRow {
    flex-wrap: wrap;
  }

  #huc8Result {
    flex-basis: 100%;
  }

  #copyHuc8Button,
  #printMapButton {
    flex-shrink: 0;
    white-space: nowrap;
    margin-left: 0;
  }

  #copyHuc8Button {
    border-color: transparent;
  }
}

@media (max-width: 700px) {
  #content {
    gap: 16px;
  }

  #mobileSelectedWatershed:not(.hidden) {
    display: block;
    margin-top: -4px;
    margin-bottom: -16px;
  }

  #mapPane {
    border-left: 0;
  }

  #mapAndSidebar {
    gap: 0;
    border-radius: 0;
  }

  #map {
    border-radius: 0;
  }

  #adjacentResultsDivider {
    display: none !important;
  }

  #mobileWatershedResultsTitle {
    border-radius: 4px 4px 0 0;
  }

  #mobileHuc8ResultRow {
    border-radius: 0;
    border-bottom: 0;
  }

  #resultsHeaderBar {
    padding: 16px 18px 12px;
  }

  #resultsHeaderBar h2 {
    display: none;
  }

  #adjacentWatershedsSection h2 {
    display: none;
  }

  #huc8ResultRow {
    display: none !important;
  }

  .radio-group {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .tooltip-wrapper.mobile-tooltip-open .tooltip-text {
    clip: auto;
    white-space: normal;
    overflow: visible;
  }

  .tooltip-text {
    left: auto !important;
    right: 0 !important;
    margin-right: 0;
    transform: none !important;
  }

  #mapLegend {
    top: 10px;
    right: 10px;
  }

  .mobile-adjacent-hidden {
    display: none;
  }

  #adjacentHuc8SeeMoreLink:not(.hidden) {
    display: block;
  }

}

@media (max-width: 460px) {

  #huc8ResultRow {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  #huc8Result {
    width: 100%;
  }

  #printModalContent {
    padding: 18px;
    width: 80%;
  }

  #printModalButtons {
    flex-direction: column-reverse;
    gap: 6px;
  }
}
