/* Mobile layout for road tracker — relies on tokens from app.css */

@media (max-width: 768px) {
  #map {
    margin-left: 0 !important;
  }

  .reports-pane {
    top: auto;
    left: 0;
    right: 0;
    bottom: var(--bottom-nav-h, 3.5rem);
    width: 100%;
    max-width: none;
    border-right: none;
    border-top: 1px solid var(--stroke, #e3e6e0);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(27, 36, 48, 0.12);
    transition: max-height 0.22s ease;
    max-height: 42vh;
  }

  .reports-pane.reports-pane--peek {
    max-height: 5.5rem;
  }

  .reports-pane.reports-pane--half {
    max-height: 42vh;
  }

  .reports-pane.reports-pane--full {
    max-height: calc(100dvh - var(--header-h, 3.5rem) - var(--bottom-nav-h, 3.5rem) - 0.5rem);
  }

  .reports-pane.reports-pane--peek .reports-pane-tabs,
  .reports-pane.reports-pane--peek .reports-pane-content,
  .reports-pane.reports-pane--collapsed .reports-pane-tabs,
  .reports-pane.reports-pane--collapsed .reports-pane-content {
    display: none;
  }

  .reports-pane-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 1.6rem;
    padding: 0.3rem 0 0.1rem;
    border: none;
    background: transparent;
    color: var(--ink-muted, #5b6675);
    cursor: pointer;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  /* Chevron points the way the panel will move on the next tap. */
  .reports-pane-handle__glyph {
    width: 0.55rem;
    height: 0.55rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.18s ease;
  }

  .reports-pane-handle[aria-expanded="false"] .reports-pane-handle__glyph {
    transform: translateY(2px) rotate(-135deg);
  }

  .reports-pane-header {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  body.map-moving .reports-pane {
    opacity: 0.85;
  }

  .reports-pane-header {
    min-height: var(--touch-min, 44px);
    padding: 0.5rem 1rem 0.65rem;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .pane-tab {
    min-height: var(--touch-min, 44px);
    padding: 0.65rem 1rem;
    font-size: 1rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .report-form-inner,
  .reports-list {
    padding: 0.85rem 1rem;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    min-height: var(--touch-min, 44px);
    font-size: 16px;
    padding: 0.6rem 0.75rem;
  }

  .form-actions button {
    min-height: var(--touch-min, 44px);
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
  }

  /* Search + layers sit clear of Leaflet zoom; legend under it */
  .map-chrome {
    top: calc(var(--header-h, 3.5rem) + 0.4rem);
    left: 3.5rem;
    right: 0.5rem;
    max-width: none;
  }

  .map-toolbar {
    padding: 0.3rem 0.4rem;
    gap: 0.4rem;
  }

  .map-toolbar #search-input {
    padding: 0.35rem 0.5rem;
    font-size: 0.9rem;
    min-height: 36px;
  }

  .map-legend {
    max-width: 100%;
  }

  .report-fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: max(0.85rem, env(safe-area-inset-right));
    bottom: calc(var(--bottom-nav-h, 3.5rem) + 8.25rem);
    z-index: 1500;
    touch-action: manipulation;
    min-width: 3.5rem;
    min-height: 3.5rem;
    padding: 0 1.1rem;
    border: none;
    border-radius: 999px;
    background: var(--primary, #1f5f45);
    color: var(--primary-ink, #fff);
    font: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 0 6px 18px rgba(31, 95, 69, 0.35);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .report-fab:active {
    transform: scale(0.98);
  }

  .reports-pane.reports-pane--full ~ .report-fab,
  .reports-pane.reports-pane--half ~ .report-fab {
    bottom: calc(var(--bottom-nav-h, 3.5rem) + 42vh + 0.75rem);
  }

  .reports-pane.reports-pane--full ~ .report-fab {
    bottom: calc(var(--bottom-nav-h, 3.5rem) + 0.75rem);
    opacity: 0.92;
  }
}

/* Quick Report bottom sheet */
.quick-report-sheet {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--bottom-nav-h, 0px);
  z-index: 1400;
  background: var(--surface, #fff);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(27, 36, 48, 0.18);
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  max-height: 85vh;
  overflow-y: auto;
  color: var(--ink, #1b2430);
}

.quick-report-sheet.open {
  display: block;
}

.quick-close {
  display: block;
  margin: 0 0 0.75rem auto;
  min-height: 44px;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--stroke-strong, #cfd4cb);
  border-radius: 999px;
  background: var(--canvas, #f6f7f4);
  color: var(--ink, #1b2430);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.quick-report-sheet h2 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  color: var(--ink, #1b2430);
}

.quick-categories {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.quick-cat-btn {
  min-height: 56px;
  padding: 0.75rem 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  border: 2px solid var(--stroke-strong, #cfd4cb);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--surface, #fff);
  color: var(--ink, #1b2430);
  -webkit-tap-highlight-color: transparent;
}

.quick-cat-btn:active {
  transform: scale(0.98);
}

.quick-cat-btn[data-cat="snow"] {
  border-color: var(--snow, #2563eb);
  color: var(--snow, #2563eb);
}

.quick-cat-btn[data-cat="water"] {
  border-color: var(--water, #0891b2);
  color: var(--water, #0891b2);
}

.quick-cat-btn[data-cat="hazard"] {
  border-color: var(--hazard, #dc2626);
  color: var(--hazard, #dc2626);
}

.quick-cat-btn[data-cat="other"] {
  border-color: var(--other, #6b7280);
  color: var(--other, #6b7280);
}

.quick-cat-btn[aria-pressed="true"] {
  background: var(--primary-tint, #e6f0ea);
}

.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quick-actions button {
  min-height: 52px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  border: none;
  -webkit-tap-highlight-color: transparent;
}

.quick-submit {
  background: var(--primary, #1f5f45);
  color: var(--primary-ink, #fff);
}

.quick-location {
  background: var(--canvas, #f6f7f4);
  color: var(--ink, #1b2430);
  border: 2px solid var(--stroke-strong, #cfd4cb) !important;
}

.quick-add-details {
  background: transparent;
  color: var(--ink-muted, #5b6675);
  font-weight: 500;
}

.gps-accuracy {
  font-size: 0.9rem;
  color: var(--ink-muted, #5b6675);
  margin-top: 0.25rem;
}

.reports-pane-content,
.report-form-inner,
.reports-list,
.quick-report-sheet {
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .leaflet-popup-content {
    font-size: 1rem;
    min-width: 200px;
  }

  .popup-photo {
    max-width: 100%;
  }
}
