:root {
  --drwr-bg: #fff;
  --drwr-radius: 16px;
  --drwr-handle-width: 32px;
  --drwr-handle-height: 4px;
  --drwr-handle-color: rgba(0, 0, 0, 0.25);
  --drwr-overlay-color: rgba(0, 0, 0, 0.4);
  --drwr-shadow:
    0 -1px 0 rgba(0, 0, 0, 0.04),
    0 -8px 32px rgba(0, 0, 0, 0.12),
    0 -24px 60px rgba(0, 0, 0, 0.06);
  --drwr-z-index: 9999;
  --drwr-border: 1px solid rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --drwr-bg: var(--color-gray-900);
    --drwr-handle-color: var(--color-gray-500);
    --drwr-border: 1px solid var(--color-gray-800);
  }
}

.drwr-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--drwr-z-index);
  background: var(--drwr-overlay-color);
  opacity: 0;
  pointer-events: none;
  -webkit-tap-highlight-color: transparent;
}

.drwr-overlay[data-visible="true"] {
  pointer-events: auto;
}

@media (max-width: 767px) {
  [data-controller~="place-detail-panel"].drwr-controlling {
    translate: none !important;
    transform: none !important;
  }
}

.drwr-sheet {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: calc(var(--drwr-z-index) + 1);
  display: flex;
  flex-direction: column;
  background: var(--drwr-bg);
  border-radius: var(--drwr-radius) var(--drwr-radius) 0 0;
  border-top: var(--drwr-border);
  border-left: var(--drwr-border);
  border-right: var(--drwr-border);
  box-shadow: var(--drwr-shadow);
  transform: translate3d(0, 100vh, 0);
  touch-action: auto;
  will-change: transform;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: contain;
  visibility: hidden;
}

.drwr-sheet[data-fit-content] {
  box-sizing: border-box;
  overflow: hidden;
  touch-action: auto;
}

/* Fit-content sheets only need drag gestures on the handle. */
.drwr-sheet[data-fit-content] .drwr-handle {
  touch-action: none;
}

.drwr-sheet[data-dragging="true"] {
  user-select: none;
  cursor: grabbing;
}

.drwr-handle {
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 14px 0 10px;
  cursor: grab;
  -webkit-tap-highlight-color: transparent;
}

.drwr-handle::before,
.place-detail-sheet-toggle::before {
  content: "";
  display: block;
  width: var(--drwr-handle-width);
  height: var(--drwr-handle-height);
  border-radius: 99px;
  background: var(--drwr-handle-color);
}

.drwr-handle:active {
  cursor: grabbing;
}

.drwr-content {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 0 16px 16px;
}

.drwr-controlling .drwr-handle {
  padding: 0;
}

.drwr-controlling .drwr-handle::before {
  display: none;
}

.place-detail-sheet-toggle {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 52px;
  cursor: grab;
}

.place-detail-sheet-toggle:active {
  cursor: grabbing;
}

.drwr-controlling .place-detail-sheet-toggle:focus:not(:focus-visible) {
  outline: none;
}

.place-detail-sheet-toggle:focus-visible {
  outline: 2px solid var(--drwr-handle-color);
  outline-offset: -5px;
  border-radius: var(--drwr-radius);
}

.drwr-controlling .drwr-content {
  padding: 0 0 env(safe-area-inset-bottom);
}

.drwr-content > .place-detail-card {
  max-width: none;
  min-height: 0;
  overflow: clip;
  border: 0;
  box-shadow: none;
}

.drwr-content.place-detail-sheet-compact {
  overflow: clip;
  touch-action: none;
}

/* Suppress pointer focus rings without removing keyboard-visible focus. */
.place-detail-sheet-toggle:focus:not(:focus-visible) { outline: none; }

/* WebKit lacks directional pan-down; expanded content remains native-scrolling,
   while the header remains an explicit drag affordance. */
@supports not (touch-action: pan-down) {
  .drwr-controlling .drwr-handle { min-height: 32px; touch-action: none; }
  .drwr-content.place-detail-sheet-at-top:not(.place-detail-sheet-compact) { touch-action: pan-y; }
}

/* At the top, allow native scrolling into the card (finger up) but reserve
   a pull toward the map for drwr. Unsupported directions fall back to pan-y. */
.drwr-content.place-detail-sheet-at-top:not(.place-detail-sheet-compact) {
  touch-action: pan-down;
}

@media (prefers-reduced-motion: reduce) {
  .drwr-sheet { transition: none !important; }
}

/* drwr alone owns mobile geometry. Snap callbacks change interaction state,
   never the containing block's height (which would move a fixed drawer). */
@media (max-width: 767px) {
  /* Keep the full solid band compact, not just the visible grip. Avoid an
     oversized hit region over the exposed map or the card's controls. */
  .drwr-controlling .place-detail-sheet-toggle {
    min-height: 32px;
  }

  [data-controller~="place-detail-panel"]:not(.drwr-controlling) {
    visibility: hidden;
  }

  /* The full-height frame/sheet are transparent geometry hosts, not hit areas.
     Include the frame: its pointer-events-auto utility would otherwise catch
     gestures above the compact wrapper even when the sheet is transparent. */
  .drwr-controlling [data-place-detail-panel-target~="frame"],
  .drwr-controlling [data-place-detail-panel-target~="sheet"] {
    pointer-events: none;
  }

  .drwr-controlling .drwr-sheet {
    pointer-events: auto;
  }

  .drwr-controlling [data-place-detail-panel-target~="sheet"] {
    height: 100dvh !important;
    transition: none;
  }
}
