/* ============================================
   Drawer & filters — toggle buttons, drawer, filter tree, route list
   Loaded via <link> in index.html (after style.css).
   Depends on tokens.css custom properties.
   ============================================ */

/* ---- Drawer Toggle (Hamburger) ---- */
.drawer-toggle {
  position: fixed;
  top: var(--top-safe);
  left: var(--spacing-10);
  z-index: calc(var(--z-panel) + 1);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-input);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  transition: background var(--duration-base), border-color var(--duration-base);
}

.drawer-toggle:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-border-hover);
}

.drawer-toggle:active { transform: scale(0.92); }

/* ---- Filter Toggle (map, next to hamburger) ---- */
.filter-toggle {
  position: fixed;
  top: var(--top-safe);
  left: 58px;
  z-index: calc(var(--z-panel) + 1);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-input);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  transition: background var(--duration-base), border-color var(--duration-base);
}

.filter-toggle:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-border-hover);
}

.filter-toggle:active { transform: scale(0.92); }
.filter-toggle[hidden] { display: none; }

/* ---- Drawer Backdrop ---- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-panel) - 1);
  background: var(--color-overlay);
  transition: opacity var(--duration-slow);
}

.drawer-backdrop[hidden] { display: none; }

/* ---- Drawer ---- */
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--drawer-width);
  z-index: var(--z-panel);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform var(--duration-slow) var(--ease-out), box-shadow var(--duration-slow) var(--ease-out);
}

.drawer.open {
  transform: translateX(0);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.06);
}

/* ---- Drawer Header ---- */
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-16);
  padding-top: 52px;
  border-bottom: 1px solid var(--color-border);
}

.drawer-title {
  font-size: var(--text-heading);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-heading);
  letter-spacing: var(--tracking-heading);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-16);
}

.drawer-section { margin-bottom: var(--spacing-20); }

.drawer-section h3 {
  font-size: var(--text-caption);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-8);
}

/* ---- Neighborhood Filters ---- */
.neighborhood-filters {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-4);
  margin-bottom: var(--spacing-16);
}

.neighborhood-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-4);
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-geist-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--duration-base);
  white-space: nowrap;
}

.neighborhood-pill:hover {
  border-color: var(--color-border-hover);
  color: var(--color-text-primary);
}

.neighborhood-pill.active {
  background: var(--color-cta-bg);
  border-color: var(--color-cta-bg);
  color: var(--color-cta-text);
}

.neighborhood-pill .pill-count {
  font-size: 10px;
  opacity: 0.6;
}

.neighborhood-city {
  display: flex;
  align-items: center;
  gap: var(--spacing-4);
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: var(--radius-base);
  background: transparent;
  color: var(--color-text-primary);
  font-family: var(--font-geist);
  font-size: var(--text-body);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration-base);
  text-align: left;
}

.neighborhood-city:hover {
  background: var(--color-surface-alt);
}

.neighborhood-city.active {
  color: var(--color-text-heading);
}

.neighborhood-city .pill-count {
  font-size: 10px;
  font-weight: 400;
  opacity: 0.5;
  font-family: var(--font-geist-mono);
}

.neighborhood-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.neighborhood-row .neighborhood-city,
.neighborhood-row .neighborhood-pill {
  flex: 1;
  min-width: 0;
}

.neighborhood-goto {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  border-radius: var(--radius-base);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-base), color var(--duration-base), background var(--duration-base);
}

.neighborhood-row:hover .neighborhood-goto,
.neighborhood-goto:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

.neighborhood-goto:hover {
  color: var(--color-text-primary);
  background: var(--color-surface-alt);
}

.neighborhood-caret {
  display: inline-block;
  font-size: 8px;
  opacity: 0.45;
  flex-shrink: 0;
  transition: transform var(--duration-base), opacity var(--duration-base);
}

.neighborhood-city.expanded .neighborhood-caret {
  transform: rotate(90deg);
  opacity: 0.75;
}


.neighborhood-children {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 8px 20px;
}

.neighborhood-child {
  font-size: 10px;
  display: flex;
  align-items: center;
  gap: var(--spacing-4);
  text-align: left;
}

.neighborhood-child .pill-wrapper {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.neighborhood-child .pill-inner {
  display: block;
  white-space: nowrap;
}

.neighborhood-child:hover .pill-inner {
  animation: pill-ticker 2.5s ease-in-out forwards;
}

.neighborhood-child .pill-count {
  flex-shrink: 0;
}

.neighborhood-none {
  font-family: var(--font-geist-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  opacity: 0.5;
  padding: 3px 8px;
  margin-right: 28px;
}

@keyframes pill-ticker {
  0%, 15% { transform: translateX(0); }
  85%, 100% { transform: translateX(var(--ticker-dist, 0px)); }
}

.neighborhood-city-pill {
  font-size: 10px;
  margin-right: 28px;
}

.neighborhood-city-pill.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.neighborhood-city-pill:not(.active):hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.neighborhood-city-pill.active:hover {
  background: var(--color-accent-light);
  border-color: var(--color-accent-light);
}

/* ---- Filter Tags (text-only toggles, Barcelona style) ---- */
.filter-tag {
  display: inline-block;
  padding: 2px 4px;
  background: transparent;
  border: none;
  font-family: var(--font-geist-mono);
  font-size: 11px;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--duration-base);
}

.filter-tag:hover {
  color: var(--color-text-primary);
}

.filter-tag:active { opacity: 0.6; }

.filter-tag.active {
  color: var(--color-accent-light);
}

/* ---- Route List ---- */
.route-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-6);
}

.route-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-8);
  padding: 8px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  font-size: var(--text-body);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: border-color var(--duration-base);
}

.route-item:hover {
  border-color: var(--color-border-hover);
}

.route-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---- Dark-theme open-drawer shadow ---- */
/* Relocated from tokens.css in slice #71. Higher specificity than the base
   .drawer.open rule, so it wins regardless of <link> order. */
[data-theme="dark"] .drawer.open {
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
}

/* On phones the floating toggle buttons (top: var(--top-safe), 40px tall) AND
   the full-width map search bar (top: 60px + safe, ~44px tall) overlay the
   drawer at z-panel+1. The base 52px padding-top leaves the "Filters" title
   clipped under them in the full-bleed PWA (#86 follow-up). Push the header
   below the search bar's bottom edge (~104px + safe) plus a small gap. */
@media (max-width: 767px) {
  .drawer-header {
    padding-top: calc(112px + env(safe-area-inset-top, 0px));
  }
}
