/**
 * Responsive Styles
 *
 * Mobile-first responsive breakpoints.
 */

/* Sidebar responsive - tablets and below (< 768px) */
@media (max-width: 767.98px) {
  /* Show toggle button on mobile */
  .sidebar__toggle {
    display: flex;
  }

  /* Show close button on mobile */
  .sidebar__close {
    display: flex;
  }

  /* Map takes full width when sidebar is collapsed */
  .map-container {
    right: 0;
  }

  /* Sidebar takes full width and slides in from right */
  .sidebar {
    width: 100%;
    max-width: 100%;
    right: 0;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    box-shadow: -4px 0 10px rgba(0, 0, 0, 0.3);
    z-index: 1000;
  }

  .sidebar.sidebar--open {
    transform: translateX(0);
  }

  /* Hide toggle button when sidebar is open on mobile */
  .sidebar.sidebar--open + .map-container .sidebar__toggle {
    display: none;
  }
}

/* Small devices (landscape phones, 576px and up) */
@media (max-width: 575.98px) {
  :root {
    --font-size-3xl: 1.5rem;
    --font-size-2xl: 1.25rem;
    --font-size-xl: 1.125rem;
  }

  .header__container {
    padding: 0 var(--spacing-sm);
  }

  .header__title {
    font-size: var(--font-size-lg);
  }

  .search {
    width: 180px;
  }

  .search__input {
    height: 32px;
    font-size: var(--font-size-xs);
  }

  .station-page {
    padding: var(--spacing-md);
  }

  .station-stats__grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .station-stats__value {
    font-size: var(--font-size-lg);
  }

  /* Stack delay breakdown on mobile */
  .delay-breakdown-container {
    flex-direction: column;
    align-items: flex-start;
  }

  .delay-breakdown-chart {
    margin: 0 auto var(--spacing-md);
  }

  .station-chart__canvas {
    height: 250px;
  }

  .station-links {
    flex-direction: column;
  }

  /* Smaller sidebar on very small screens */
  .sidebar {
    width: 280px;
  }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
  .search {
    width: 220px;
  }

  .station-stats__grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
  .station-stats__grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 992px) {
  .station-stats__grid {
    grid-template-columns: repeat(7, 1fr);
  }
}

/* Touch device adjustments */
@media (hover: none) and (pointer: coarse) {
  .station-marker {
    /* Slightly larger touch target on mobile */
    width: 16px;
    height: 16px;
  }

  .station-marker:hover {
    /* Disable hover effects on touch */
    transform: none;
  }

  .search__result {
    padding: var(--spacing-md);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  :root {
    --color-border: #000;
    --color-text-muted: #555;
  }

  .station-marker {
    border: 2px solid #000;
  }
}

/* Print styles */
@media print {
  .header {
    position: static;
    background-color: white;
    color: black;
    box-shadow: none;
    border-bottom: 1px solid #000;
  }

  .search {
    display: none;
  }

  .main {
    padding-top: 0;
  }

  .map-container {
    display: none;
  }

  .station-chart {
    page-break-inside: avoid;
  }

  .station-links {
    display: none;
  }
}
