/*
 * Dark glass map controls inspired by the selected CrownAccess prototype
 * reference. This file intentionally sits after the legacy map stylesheet so
 * the visual direction is isolated and easy to iterate on.
 */

:root {
  /* Genuinely see-through: the map is the content, the controls are glass over
     it. Heavier blur carries the legibility that the lost opacity used to. */
  --prototype-glass: rgba(12, 26, 21, 0.54);
  --prototype-glass-soft: rgba(18, 34, 28, 0.46);
  --prototype-row: rgba(16, 34, 27, 0.42);
  --prototype-row-hover: rgba(25, 46, 37, 0.6);
  --prototype-line: rgba(218, 232, 224, 0.24);
  --prototype-line-soft: rgba(218, 232, 224, 0.1);
  --prototype-text: #e9eeeb;
  --prototype-muted: #9da9a3;
  --prototype-lime: #c7f33d;
  --prototype-lime-deep: #a9db23;
  --prototype-panel-width: 330px;
}

.map-frame .basemap-panel.glass-panel,
.map-frame .layer-picker-panel.glass-panel,
.map-frame .map-toolbar.glass-panel {
  border: 1px solid var(--prototype-line);
  background: var(--prototype-glass);
  color: var(--prototype-text);
  box-shadow:
    0 22px 48px rgba(0, 0, 0, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(30px) saturate(1.25);
  -webkit-backdrop-filter: blur(30px) saturate(1.25);
}

.map-frame .basemap-panel.glass-panel::before,
.map-frame .layer-picker-panel.glass-panel::before,
.map-frame .map-toolbar.glass-panel::before {
  display: none;
}

.map-frame .top-right-stack {
  top: 20px;
  right: 20px;
  bottom: auto;
  gap: 10px;
}

.map-frame .basemap-panel {
  width: 214px;
  min-height: 62px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  padding: 11px 14px;
  border-radius: 15px;
}

.basemap-panel-icon,
.layer-row-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--prototype-text);
}

.basemap-panel-icon svg {
  width: 24px;
  height: 24px;
  stroke-width: 1.65;
}

.basemap-panel-copy {
  min-width: 0;
}

.map-frame .basemap-panel .panel-heading {
  margin: 0 0 2px;
  color: var(--prototype-muted);
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0;
  text-transform: none;
}

.map-frame .basemap-panel .select-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px;
  align-items: center;
  margin: 0;
}

.map-frame .basemap-panel .select-shell::after {
  display: none;
}

.map-frame .basemap-panel #basemap-select {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--prototype-text);
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1.15;
  box-shadow: none;
  cursor: pointer;
}

.map-frame .basemap-panel #basemap-select:focus-visible {
  outline: 2px solid var(--prototype-lime);
  outline-offset: 4px;
}

.map-frame .basemap-panel #basemap-select option {
  background: #101d18;
  color: var(--prototype-text);
}

.basemap-chevron {
  width: 17px;
  height: 17px;
  color: var(--prototype-text);
  pointer-events: none;
}

.map-frame .right-panel-stack,
.map-frame.has-context-panel .right-panel-stack {
  /* --top-right-stack-bottom is measured in app.js so the dock always clears
     the account chip and basemap card instead of guessing their height. */
  top: calc(var(--top-right-stack-bottom, 134px) + 18px);
  right: 20px;
  bottom: auto;
  left: auto;
  width: var(--prototype-panel-width);
  max-width: calc(100vw - 40px);
  max-height: calc(100dvh - var(--top-right-stack-bottom, 134px) - 42px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.map-frame .layer-picker-panel,
.map-frame .layer-picker-panel.glass-panel {
  width: var(--prototype-panel-width);
  min-width: 0;
  max-width: calc(100vw - 40px);
  max-height: min(69dvh, 650px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0;
  padding: 13px;
  overflow: hidden;
  border-radius: 24px;
}

.map-frame .layer-picker-panel > .panel-header-row {
  min-height: 38px;
  margin: 0;
  padding: 2px 3px 10px;
  color: var(--prototype-text);
  cursor: grab;
}

.layer-panel-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.layer-panel-title svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.65;
}

.map-frame .layer-picker-panel > .panel-header-row .panel-heading {
  margin: 0;
  color: var(--prototype-text);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
}

.map-frame .layer-picker-panel .panel-icon-button {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--prototype-text);
  box-shadow: none;
}

.map-frame .layer-picker-panel .panel-icon-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
  transition: transform 180ms ease;
}

.map-frame .layer-picker-panel .panel-icon-button:hover,
.map-frame .layer-picker-panel .panel-icon-button:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: var(--prototype-lime);
  transform: none;
  box-shadow: none;
}

.map-frame .layer-picker-groups {
  width: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 1px 1px 2px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.map-frame .layer-picker-groups::-webkit-scrollbar {
  display: block;
  width: 4px;
}

.map-frame .layer-picker-groups::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
}

.layer-panel-section {
  display: grid;
  gap: 7px;
}

.layer-panel-section + .layer-panel-section {
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px solid var(--prototype-line-soft);
}

.layer-section-heading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 3px;
  color: var(--prototype-muted);
  font-size: 0.61rem;
  font-weight: 750;
  line-height: 1;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.layer-section-heading svg {
  width: 13px;
  height: 13px;
  stroke-width: 1.8;
}

.map-frame .mode-picker.is-flat-layer-bar,
.layer-activity-groups {
  width: 100%;
  max-width: none;
  display: grid;
  align-items: stretch;
  gap: 5px;
}

.map-frame .mode-picker.is-flat-layer-bar .layer-toggle-row,
.map-frame .layer-toggle-row,
.forestry-layer-row {
  position: relative;
  width: 100%;
  max-width: none;
  display: block;
}

.map-frame .mode-picker.is-flat-layer-bar .layer-toggle-button,
.map-frame .layer-toggle-button,
.map-frame .forestry-layer-toggle {
  width: 100%;
  max-width: none;
  min-width: 0;
  min-height: 50px;
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr) 28px 40px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 12px;
  border: 1px solid var(--prototype-line);
  border-radius: 12px;
  background: var(--prototype-row);
  color: var(--prototype-text);
  box-shadow: none;
  text-align: left;
}

.map-frame .layer-toggle-button:hover,
.map-frame .layer-toggle-button:focus-visible,
.map-frame .forestry-layer-toggle:hover,
.map-frame .forestry-layer-toggle:focus-visible {
  outline: none;
  border-color: rgba(199, 243, 61, 0.48);
  background: var(--prototype-row-hover);
  color: var(--prototype-text);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
}

.map-frame .layer-toggle-button.is-visible,
.map-frame .layer-toggle-button.is-selected,
.map-frame .mode-picker.is-flat-layer-bar .layer-toggle-button.is-visible,
.map-frame .mode-picker.is-flat-layer-bar .layer-toggle-button.is-selected,
.map-frame .forestry-layer-toggle.is-active {
  border-color: rgba(199, 243, 61, 0.42);
  background: rgba(26, 44, 36, 0.94);
  color: var(--prototype-text);
}

.map-frame .layer-toggle-button.is-feature-card {
  min-height: 66px;
  border-color: rgba(199, 243, 61, 0.38);
  background:
    radial-gradient(circle at 88% 18%, rgba(199, 243, 61, 0.14), transparent 38%),
    rgba(16, 31, 25, 0.92);
}

.map-frame .layer-toggle-button.is-feature-card:hover,
.map-frame .layer-toggle-button.is-feature-card:focus-visible {
  border-color: rgba(199, 243, 61, 0.7);
  background:
    radial-gradient(circle at 88% 18%, rgba(199, 243, 61, 0.2), transparent 42%),
    rgba(24, 43, 35, 0.96);
}

.map-frame .layer-toggle-button.is-feature-card .layer-copy {
  display: grid;
  gap: 3px;
}

.map-frame .layer-toggle-button.is-feature-card .layer-label {
  color: #f7faef;
  font-weight: 720;
}

.map-frame .layer-toggle-button.is-feature-card .layer-meta {
  overflow: hidden;
  color: #b8c3bd;
  font-size: 0.58rem;
  font-weight: 560;
  line-height: 1.28;
  text-overflow: ellipsis;
  white-space: normal;
}

.map-frame .layer-toggle-button.is-feature-card .layer-row-icon {
  color: var(--prototype-lime);
}

.map-frame .layer-toggle-button.is-feature-card.is-visible {
  border-color: rgba(199, 243, 61, 0.76);
  background:
    radial-gradient(circle at 88% 18%, rgba(199, 243, 61, 0.19), transparent 42%),
    rgba(28, 48, 39, 0.98);
}

.map-frame .layer-toggle-button.is-feature-card + .layer-info-button {
  top: 23px;
}

.layer-row-icon {
  width: 27px;
  height: 27px;
}

.layer-row-icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.65;
}

.map-frame .layer-copy,
.map-frame .forestry-layer-copy {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.map-frame .mode-picker.is-flat-layer-bar .layer-copy {
  flex: initial;
}

.map-frame .mode-picker.is-flat-layer-bar .layer-label,
.map-frame .layer-label,
.map-frame .forestry-layer-copy > span {
  overflow: hidden;
  color: var(--prototype-text);
  font-size: 0.78rem;
  font-weight: 520;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-frame .layer-state.is-switch,
.map-frame .forestry-layer-state.is-switch {
  position: relative;
  grid-column: 4;
  width: 38px;
  min-width: 38px;
  height: 22px;
  display: block;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: #3d4944;
  color: transparent;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

.layer-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #f8faf8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.34);
  transition: transform 180ms ease;
}

.map-frame .layer-toggle-button.is-visible .layer-state.is-switch,
.map-frame .layer-toggle-button.is-selected .layer-state.is-switch,
.map-frame .forestry-layer-toggle.is-active .forestry-layer-state.is-switch {
  border-color: var(--prototype-lime);
  background: var(--prototype-lime);
  color: transparent;
}

.map-frame .layer-toggle-button.is-visible .layer-switch-knob,
.map-frame .layer-toggle-button.is-selected .layer-switch-knob,
.map-frame .forestry-layer-toggle.is-active .layer-switch-knob {
  transform: translateX(16px);
}

.map-frame .layer-state.is-text-status,
.map-frame .forestry-layer-state.is-text-status {
  grid-column: 4;
  min-width: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 5px 7px;
  border-radius: 999px;
  background: rgba(199, 243, 61, 0.13);
  color: var(--prototype-lime);
  font-size: 0.54rem;
  font-weight: 800;
  line-height: 1;
}

.map-frame .layer-info-button,
.map-frame .forestry-info-button {
  position: absolute;
  top: 50%;
  right: 60px;
  z-index: 2;
  width: 24px;
  min-width: 24px;
  min-height: 24px;
  margin: 0;
  border: 0;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: transparent;
  color: #8e9b95;
  box-shadow: none;
  transform: translateY(-50%);
}

.map-frame .layer-info-button svg,
.map-frame .forestry-info-button svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.8;
}

.map-frame .layer-info-button:hover,
.map-frame .layer-info-button:focus-visible,
.map-frame .forestry-info-button:hover,
.map-frame .forestry-info-button:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--prototype-lime);
  box-shadow: none;
  transform: translateY(-50%);
}

.map-frame .forestry-layer-group {
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--prototype-line);
  border-radius: 12px;
  background: var(--prototype-row);
  box-shadow: none;
}

.map-frame .forestry-group-header {
  position: relative;
  width: 100%;
  min-height: 50px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: center;
  gap: 4px;
  padding-right: 6px;
}

.map-frame .forestry-group-toggle {
  grid-column: 1;
  width: 100%;
  min-height: 50px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px;
  align-items: center;
  gap: 8px;
  padding: 8px 4px 8px 12px;
  border: 0;
  background: transparent;
  color: var(--prototype-text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 540;
  text-align: left;
  cursor: pointer;
}

.map-frame .forestry-group-toggle:hover,
.map-frame .forestry-group-toggle:focus-visible {
  outline: none;
  background: var(--prototype-row-hover);
}

.layer-group-label {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.layer-group-label > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-frame .forestry-group-toggle > svg,
.map-frame .fishing-group-meta > svg {
  width: 17px;
  height: 17px;
  color: var(--prototype-text);
  stroke-width: 1.8;
  transition: transform 180ms ease;
}

.map-frame .forestry-layer-group.is-expanded .forestry-group-toggle > svg,
.map-frame .fishing-layer-group.is-expanded .fishing-group-meta > svg {
  transform: rotate(180deg);
}

.map-frame .forestry-group-header > .forestry-info-button {
  position: static;
  grid-column: 2;
  grid-row: 1;
  right: auto;
  top: auto;
  transform: none;
}

.map-frame .forestry-group-header > .forestry-info-button:hover,
.map-frame .forestry-group-header > .forestry-info-button:focus-visible {
  transform: none;
}

.map-frame .forestry-layer-children {
  display: grid;
  gap: 5px;
  padding: 0 5px 6px;
  border-top: 1px solid var(--prototype-line-soft);
}

.map-frame .forestry-layer-children[hidden] {
  display: none;
}

.map-frame .forestry-layer-row:first-child {
  margin-top: 5px;
}

.map-frame .forestry-layer-toggle {
  min-height: 46px;
  border-color: var(--prototype-line-soft);
  background: rgba(8, 18, 15, 0.46);
}

.map-frame .forestry-layer-row .forestry-info-button {
  right: 60px;
}

.map-frame .fishing-group-count {
  min-width: 18px;
  height: 18px;
  background: rgba(199, 243, 61, 0.14);
  color: var(--prototype-lime);
}

.map-frame .hunting-group-footnote {
  margin: 0 6px 5px;
  color: var(--prototype-muted);
  font-size: 0.58rem;
  line-height: 1.35;
}

.map-frame .layer-panel-footer {
  padding: 9px 1px 1px;
  border-top: 1px solid var(--prototype-line-soft);
  background: linear-gradient(180deg, rgba(12, 26, 21, 0), rgba(12, 26, 21, 0.28));
}

.map-frame .forestry-suggest-layer,
.map-frame .layer-panel-suggest-layer {
  width: 100%;
  min-height: 40px;
  margin: 0;
  border: 1px dashed var(--prototype-line);
  border-radius: 10px;
  background: transparent;
  color: var(--prototype-muted);
  font-size: 0.66rem;
  line-height: 1.2;
}

.map-frame .forestry-suggest-layer:hover,
.map-frame .forestry-suggest-layer:focus-visible,
.map-frame .layer-panel-suggest-layer:hover,
.map-frame .layer-panel-suggest-layer:focus-visible {
  border-color: rgba(199, 243, 61, 0.5);
  background: rgba(199, 243, 61, 0.08);
  color: var(--prototype-lime);
}

.map-frame .layer-panel-footer .forestry-suggest-inline {
  margin: 0;
}

.map-frame .layer-panel-footer .forestry-suggest-inline input {
  min-width: 0;
  border-color: var(--prototype-line);
  background: rgba(237, 242, 239, 0.94);
  color: #17231e;
}

.map-frame .layer-panel-footer .forestry-suggest-inline button {
  border-color: var(--prototype-line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--prototype-text);
}

.map-frame .layer-panel-footer .forestry-suggest-inline button[type="submit"] {
  border-color: var(--prototype-lime-deep);
  background: var(--prototype-lime-deep);
  color: #17210e;
}

.map-frame .map-toolbar,
.map-frame .right-panel-stack .map-toolbar,
.map-frame.has-context-panel .right-panel-stack .map-toolbar {
  width: fit-content;
  align-self: center;
  gap: 5px;
  padding: 6px;
  border-radius: 15px;
}

.map-frame .map-toolbar .tool-button {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--prototype-text);
  box-shadow: none;
}

.map-frame .map-toolbar .tool-button:hover,
.map-frame .map-toolbar .tool-button:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.13);
  color: var(--prototype-lime);
  transform: none;
}

.map-frame .map-toolbar .tool-button:disabled {
  opacity: 0.3;
}

.map-frame .map-toolbar .tool-svg {
  stroke: currentColor;
}

.map-frame .right-panel-stack.is-layer-panel-minimized .layer-picker-panel,
.map-frame .right-panel-stack.is-layer-panel-minimized .layer-picker-panel.glass-panel {
  width: 142px;
  min-width: 142px;
  max-height: 48px;
  padding: 7px 9px;
  border-radius: 15px;
}

.map-frame .right-panel-stack.is-layer-panel-minimized .layer-picker-panel > .panel-header-row {
  min-height: 32px;
  padding: 0;
}

.map-frame .right-panel-stack.is-layer-panel-minimized .panel-heading {
  color: var(--prototype-text);
  font-size: 0.78rem;
}

.map-frame .right-panel-stack.is-layer-panel-minimized .layer-panel-title svg {
  width: 19px;
  height: 19px;
}

.map-frame .right-panel-stack.is-layer-panel-minimized .panel-icon-button {
  width: 30px;
  height: 30px;
  transform: none;
}

.map-frame .right-panel-stack.is-layer-panel-minimized .panel-icon-button svg {
  transform: rotate(180deg);
}

.map-frame .right-panel-stack.is-layer-panel-minimized .layer-picker-groups {
  display: none;
}

.map-frame .right-panel-stack.is-layer-panel-minimized .layer-panel-footer {
  display: none;
}

@media (max-height: 760px) and (min-width: 861px) {
  .map-frame .right-panel-stack,
  .map-frame.has-context-panel .right-panel-stack {
    /* Short viewports tighten the gap but still clear the measured stack. */
    top: calc(var(--top-right-stack-bottom, 112px) + 12px);
    max-height: calc(100dvh - var(--top-right-stack-bottom, 112px) - 30px);
  }

  .map-frame .layer-picker-panel,
  .map-frame .layer-picker-panel.glass-panel {
    max-height: min(66dvh, 520px);
  }

  .map-frame .basemap-panel {
    min-height: 56px;
    padding-block: 8px;
  }
}

@media (max-width: 860px) {
  .map-frame .top-right-stack {
    top: calc(12px + env(safe-area-inset-top));
    right: 12px;
  }

  .map-frame .basemap-panel {
    width: 190px;
    min-height: 56px;
    padding: 9px 11px;
  }

  .map-frame .right-panel-stack,
  .map-frame.has-context-panel .right-panel-stack {
    position: absolute;
    top: auto;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: auto;
    width: min(var(--prototype-panel-width), calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 106px);
    align-items: flex-end;
  }

  .map-frame .right-panel-stack:not(.is-layer-panel-minimized) .layer-picker-panel,
  .map-frame.has-context-panel
    .right-panel-stack:not(.is-layer-panel-minimized)
    .layer-picker-panel,
  .map-frame .layer-picker-panel,
  .map-frame .layer-picker-panel.glass-panel {
    position: static;
    width: min(var(--prototype-panel-width), calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    max-height: min(64dvh, 570px);
    margin: 0;
  }

  .map-frame .map-toolbar,
  .map-frame .right-panel-stack .map-toolbar,
  .map-frame.has-context-panel .right-panel-stack .map-toolbar {
    align-self: center;
  }
}

@media (max-width: 560px) {
  .map-frame .brand-lockup {
    top: calc(12px + env(safe-area-inset-top));
    left: 12px;
  }

  .map-frame .basemap-panel {
    width: 190px;
  }

  .map-frame .right-panel-stack,
  .map-frame.has-context-panel .right-panel-stack {
    width: min(var(--prototype-panel-width), calc(100vw - 24px));
  }

  .map-frame .right-panel-stack:not(.is-layer-panel-minimized) .layer-picker-panel,
  .map-frame.has-context-panel
    .right-panel-stack:not(.is-layer-panel-minimized)
    .layer-picker-panel {
    width: min(var(--prototype-panel-width), calc(100vw - 24px));
    max-height: min(58dvh, 520px);
    margin: 0;
  }

  .map-frame .layer-picker-panel,
  .map-frame .layer-picker-panel.glass-panel {
    padding: 11px;
    border-radius: 21px;
  }

  .map-frame .layer-picker-panel > .panel-header-row {
    cursor: default;
    touch-action: auto;
  }

  .map-frame .mode-picker.is-flat-layer-bar .layer-label,
  .map-frame .layer-label,
  .map-frame .forestry-layer-copy > span,
  .map-frame .forestry-group-toggle {
    font-size: 0.72rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .layer-switch-knob,
  .map-frame .forestry-group-toggle > svg,
  .map-frame .fishing-group-meta > svg {
    transition: none;
  }
}
