/* ========================================
   Responsive Breakpoints
   Mobile-first approach
   ======================================== */

/* Mobile header fixes */
@media (max-width: 480px) {
  .header {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  .header__end {
    flex-wrap: wrap;
    gap: var(--space-xs);
  }

  .header__status {
    font-size: var(--font-size-xs);
    padding: 3px 8px;
  }

  .header__status-text {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header__theme {
    padding: 1px;
  }

  .theme-btn--header {
    width: 24px;
    height: 24px;
  }

  .theme-btn--header svg {
    width: 12px;
    height: 12px;
  }
}

/* Small phones (< 360px) */
@media (max-width: 359px) {
  :root {
    font-size: 14px;
  }

  .app {
    padding: var(--space-sm);
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
  }
}

/* Regular phones (360px - 479px) - base styles apply */

/* Large phones / small tablets (480px - 767px) */
@media (min-width: 480px) {
  .app {
    padding: var(--space-lg);
  }

  .card {
    padding: var(--space-xl);
  }

  .gauge {
    width: 220px;
  }
}

/* Tablets (768px+) */
@media (min-width: 768px) {
  .app {
    max-width: 560px;
    padding: var(--space-xl);
  }

  .header {
    padding: var(--space-xl) 0;
  }

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

  .card {
    padding: var(--space-xl);
    border-radius: var(--radius-xl);
  }

  .gauge {
    width: 240px;
  }

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

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  .app {
    max-width: 600px;
  }
}

/* ========================================
   Touch & Interaction
   ======================================== */

/* Remove hover effects on touch devices */
@media (hover: none) {
  .card:hover {
    border-color: var(--color-border);
  }

  .btn--primary:hover {
    transform: none;
  }

  .city-list__item:hover {
    background: transparent;
  }

  /* Active states for touch */
  .btn--primary:active {
    transform: scale(0.98);
    opacity: 0.9;
  }

  .city-list__item:active {
    background: var(--color-surface-2);
  }
}

/* ========================================
   Safe Area (for notched phones)
   ======================================== */
@supports (padding-top: env(safe-area-inset-top)) {
  .alert-banner {
    padding-top: calc(var(--space-md) + env(safe-area-inset-top));
  }

  .app {
    padding-left: calc(var(--space-md) + env(safe-area-inset-left));
    padding-right: calc(var(--space-md) + env(safe-area-inset-right));
    padding-bottom: calc(var(--space-2xl) + env(safe-area-inset-bottom));
  }
}

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

  .spinner {
    animation: spin 1.5s linear infinite;
  }
}

/* ========================================
   High Contrast Mode
   ======================================== */
@media (prefers-contrast: high) {
  :root {
    --color-border: #4a5580;
    --color-text-secondary: #b0b8d0;
    --color-text-muted: #8090b0;
  }

  .card {
    border-width: 2px;
  }
}

/* ========================================
   Print
   ======================================== */
@media print {
  body {
    background: white;
    color: black;
  }

  .alert-banner,
  .header__status,
  .btn,
  .toast-container {
    display: none;
  }

  .card {
    border: 1px solid #ddd;
    break-inside: avoid;
  }
}

/* ========================================
   Landscape phone orientation
   ======================================== */
@media (max-height: 500px) and (orientation: landscape) {
  .gauge {
    width: 150px;
  }

  .card {
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
  }

  .header {
    padding: var(--space-sm) 0;
    margin-bottom: var(--space-sm);
  }
}
