@media (max-width: 359px) {

  html { font-size: 14px; }

  .hero-section {
    padding-right: 10px;
    padding-left: 10px;
  }

  .weather-main-card {
    padding: 16px;
    border-radius: var(--radius-lg);
  }

  .temp-value {
    font-size: 3rem;
  }

  .weather-card-body {
    grid-template-columns: 1fr;
  }

  .weather-stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .forecast-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .btn-search,
  .btn-location {
    height: 48px;
    padding: 0 14px;
    font-size: 0.8rem;
  }

  .search-input {
    height: 48px;
    font-size: 0.85rem;
    padding: 0 44px 0 14px;
  }

  .search-icon { right: 14px; }

  .city-name { font-size: 1.2rem; }

  .current-time { font-size: 1.4rem; }

  .nav-logo-text { font-size: 1.1rem; }
  .nav-logo-icon { font-size: 1.3rem; }

  .theme-toggle, .unit-toggle {
    width: 38px;
    height: 38px;
    font-size: 0.95rem;
  }

  .sun-times {
    flex-wrap: wrap;
    gap: 10px;
  }

  .sun-progress-container {
    display: none;
  }

  .scroll-top-btn {
    bottom: 16px;
    left: 16px;
    width: 44px;
    height: 44px;
    font-size: 0.95rem;
  }

  .preloader-title { font-size: 1.8rem; }
  .preloader-bar { width: 220px; }
  .preloader-icon { width: 90px; height: 90px; }
  .cloud { font-size: 3.5rem; }
  .sun-rays { font-size: 2rem; }

  .hourly-card {
    min-width: 70px;
    padding: 8px 6px;
  }

  .weather-main-icon { font-size: 3rem; }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .btn-search span,
  .btn-location span {
    display: none;
  }

  .btn-search,
  .btn-location {
    width: 48px;
    padding: 0;
    justify-content: center;
  }
}

@media (min-width: 360px) and (max-width: 479px) {

  .weather-card-body {
    grid-template-columns: 1fr;
  }

  .temp-section {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(102, 126, 234, 0.1);
  }

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

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

  .sun-progress-container { display: none; }

  .scroll-top-btn {
    bottom: 20px;
    left: 20px;
  }

  .info-grid {
    grid-template-columns: 1fr 1fr;
  }

  .astro-card {
    grid-column: 1 / -1;
  }
}

@media (min-width: 480px) and (max-width: 767px) {

  .weather-card-body {
    grid-template-columns: 1fr;
  }

  .temp-section {
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(102, 126, 234, 0.1);
  }

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

  .forecast-grid {
    grid-template-columns: repeat(4, 1fr);
  }

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

  .astro-card {
    grid-column: 1 / -1;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {

  .weather-card-body {
    grid-template-columns: 1fr 1.8fr;
  }

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

  .forecast-grid {
    grid-template-columns: repeat(4, 1fr);
  }

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

  .preloader-icon { width: 140px; height: 140px; }
}

@media (min-width: 1024px) {

  .weather-card-body {
    grid-template-columns: 1fr 2fr;
  }

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

  .forecast-grid {
    grid-template-columns: repeat(7, 1fr);
  }

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

  .search-wrapper {
    flex-wrap: nowrap;
  }

  .sun-progress-container {
    display: block;
  }
}

@media (min-width: 1400px) {

  .hero-section {
    max-width: 1400px;
  }

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

  .temp-value { font-size: 7rem; }
}

@media (max-height: 500px) and (orientation: landscape) {

  .hero-section {
    padding-top: calc(var(--navbar-height) + 16px);
  }

  .weather-main-card {
    padding: 16px;
  }

  .weather-card-body {
    grid-template-columns: 1fr 2fr;
  }

  .temp-value { font-size: 3.5rem; }
  .weather-main-icon { font-size: 2.5rem; }

  .sun-progress-container { display: none; }
  .extra-info { display: none; }

  .preloader-icon { width: 80px; height: 80px; }
  .cloud { font-size: 3rem; }
  .sun-rays { font-size: 1.8rem; }
}

@media (hover: none) and (pointer: coarse) {

  .stat-card:hover,
  .hourly-card:hover,
  .forecast-card:hover,
  .info-card:hover {
    transform: none;
  }

  .scroll-btn {
    width: 44px;
    height: 44px;
  }

  .theme-toggle, .unit-toggle {
    width: 48px;
    height: 48px;
  }

  .scroll-top-btn {
    width: 56px;
    height: 56px;
  }

  .stat-card:active,
  .hourly-card:active,
  .forecast-card:active {
    transform: scale(0.97);
  }
}

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

  html { scroll-behavior: auto; }
}

@media (prefers-contrast: high) {
  :root {
    --bg-glass: rgba(255, 255, 255, 0.98);
    --text-muted: #555;
  }

  .weather-main-card {
    border: 2px solid var(--primary);
  }

  .stat-card {
    border: 1px solid var(--primary);
  }
}

@media print {

  .preloader,
  .navbar,
  .search-container,
  .scroll-top-btn,
  .hourly-section,
  .weather-bg,
  .bg-overlay,
  .bg-particles,
  .scroll-controls,
  .btn-search,
  .btn-location {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .weather-main-card {
    background: white;
    box-shadow: none;
    border: 1px solid #ddd;
  }

  .forecast-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .hero-section {
    padding: 0;
  }
}

@media (max-width: 280px) {
  .search-buttons {
    width: 100%;
    justify-content: space-between;
  }

  .search-wrapper {
    flex-direction: column;
  }

  .search-input-group {
    width: 100%;
  }

  .weather-stats-grid,
  .forecast-grid {
    grid-template-columns: 1fr;
  }

  .temp-value { font-size: 2.5rem; }
  .city-name { font-size: 1.1rem; }
  .current-time { font-size: 1.3rem; }

  .extra-info { display: none; }
  .sun-times { flex-direction: column; gap: 8px; }
  .sun-progress-container { display: none; }
  .footer-update { display: none; }
}

@media (min-width: 2560px) {
  html { font-size: 18px; }

  .hero-section {
    max-width: 1600px;
  }
}

@supports (padding: env(safe-area-inset-bottom)) {
  .scroll-top-btn {
    bottom: calc(30px + env(safe-area-inset-bottom));
  }

  .site-footer {
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
}
