/* Beer Trails dialog and map controls */
.trail-sheet select {
  display: block;
  appearance: none;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--control-radius);
  background: var(--color-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%234b6259' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right 12px center / 16px no-repeat;
  color: var(--color-brand);
}

.trail-callout a {
  color: var(--color-brand);
  text-underline-offset: 3px;
}

.trail-alert { color: #8b4c16; }

.trail-endpoint b {
  border-color: var(--color-border);
  border-radius: 8px;
  color: var(--color-ink);
  font-family: var(--font-ui);
  box-shadow: var(--card-shadow);
}

.trail-endpoint.start i,
.trail-endpoint.circuit i { background: var(--color-brand); }

.trail-stop-pin {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-surface);
  border-radius: 50%;
  color: var(--color-surface);
  font: 700 var(--font-size-sm) var(--font-ui);
  box-shadow: 0 2px 5px #0005;
}

/* The non-modal sheet leaves the rest of the map interactive. */
.trail-fab,
.trail-sheet-close {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: var(--map-action-size);
  height: var(--map-action-size);
  padding: 0;
  border-radius: 50%;
  color: var(--color-ink);
  cursor: pointer;
}

.trail-fab {
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  box-shadow: var(--shadow-map-control);
}

.trail-fab.is-active {
  border-color: var(--color-brand);
  background: var(--color-brand);
  color: var(--color-surface);
}

.trail-sheet-close {
  border: 0;
  background: var(--color-surface-subtle);
}

.trail-fab svg,
.trail-sheet-close svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trail-fab:active,
.trail-sheet-close:active,
.trail-callout-actions button:active { transform: scale(.98); }

.trail-fab:focus-visible,
.trail-sheet-close:focus-visible,
.trail-callout-actions button:focus-visible,
.trail-sheet select:focus-visible {
  outline: 2px solid var(--color-gold-strong);
  outline-offset: 2px;
}

.trail-sheet {
  position: fixed;
  z-index: 2500;
  inset: auto 0 max(12px, env(safe-area-inset-bottom, 0px));
  width: calc(100% - 24px);
  max-width: 480px;
  max-height: none;
  margin: 0 auto;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 24px;
  background: transparent;
  color: var(--color-ink);
  box-shadow: 0 14px 50px #17171738;
}

.trail-sheet:not([open]) { display: none; }
.trail-sheet[open] { animation: trail-sheet-enter .2s ease-out; }

.trail-sheet .trail-map-control {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: min(32vh, 260px);
  min-height: min(32dvh, 260px);
  max-height: min(54vh, 460px);
  max-height: min(54dvh, 460px);
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: inherit;
  background: var(--color-surface);
}

.trail-sheet .trail-sheet-header {
  position: relative;
  z-index: auto;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: auto;
  min-height: 64px;
  margin: 0;
  padding: 10px 12px 6px 22px;
  border: 0;
  background: transparent;
  color: inherit;
}

.trail-sheet-header h2 {
  margin: 0;
  font: 700 23px/1.2 var(--font-display);
  letter-spacing: -.025em;
}

.trail-sheet-content {
  min-height: 0;
  padding: 0 22px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.trail-sheet label {
  display: block;
  margin: 2px 0 8px;
  color: var(--color-muted);
  font: 700 var(--font-size-sm)/1.3 var(--font-ui);
}

.trail-sheet select {
  min-height: 48px;
  padding: 10px 36px 10px 12px;
  color: var(--color-ink);
  font: 500 16px/1.35 var(--font-ui);
}

.trail-sheet-hint {
  margin: 12px 0 0;
  color: var(--color-muted);
  font: var(--font-size-body)/1.5 var(--font-ui);
}

.trail-callout {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
  color: var(--color-text);
  font: var(--font-size-body)/1.45 var(--font-ui);
}

.trail-callout[hidden],
.trail-sheet-hint[hidden] { display: none; }

.trail-callout strong {
  display: block;
  margin-bottom: 12px;
  color: var(--color-ink);
  font: 700 20px/1.25 var(--font-display);
}

.trail-callout-meta,
.trail-callout p,
.trail-callout a { font-size: var(--font-size-label); }

.trail-callout-meta,
.trail-callout-stats span { color: var(--color-muted); }
.trail-callout p { margin: 7px 0; }
.trail-callout a { display: inline-block; margin-top: 8px; font-weight: 700; }
.trail-callout-stats { display: flex; gap: 36px; margin: 12px 0; }
.trail-callout-stats span { font-size: var(--font-size-sm); }

.trail-callout-stats b {
  display: block;
  color: var(--color-ink);
  font: 800 25px/1.2 var(--font-ui);
}

.trail-callout-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.trail-callout-actions button {
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--color-border-strong);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-ink);
  font: 700 var(--font-size-body) var(--font-ui);
  cursor: pointer;
}

.trail-callout-actions button[data-fit] {
  border-color: var(--color-gold);
  background: var(--color-gold);
}

@keyframes trail-sheet-enter {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-height: 480px) {
  .trail-sheet .trail-map-control {
    max-height: calc(100vh - 72px);
    max-height: calc(100dvh - 72px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .trail-sheet[open] { animation: none; }
}

@media (min-width: 721px) {
  .trail-sheet {
    /* The map stack has three buttons, plus one gap between the stack and dialog. */
    --trail-sheet-bottom: calc(var(--map-actions-bottom) + 3 * (var(--map-action-size) + var(--map-actions-gap)));
    inset: auto var(--map-actions-right) var(--trail-sheet-bottom) auto;
    width: min(400px, calc(100% - 2 * var(--map-actions-right)));
    margin: 0;
  }

  .trail-sheet .trail-map-control {
    min-height: 0;
    max-height: min(460px, calc(100vh - var(--trail-sheet-bottom) - 12px));
    max-height: min(460px, calc(100dvh - var(--trail-sheet-bottom) - 12px));
  }
}

@media (max-width: 720px) {
  body:not([data-mobile-view="map"]) #trailSheet { display: none; }
}

@media (forced-colors: active) {
  .trail-sheet select {
    appearance: auto;
    background-image: none;
    padding-right: 12px;
  }
}

@media (max-width: 720px) {
  .trail-sheet {
    bottom: calc(66px + env(safe-area-inset-bottom, 0px));
  }
  .trail-sheet .trail-map-control {
    max-height: calc(100dvh - 140px - env(safe-area-inset-bottom, 0px));
  }
}
