/* =========================================================
   Atmosphere — Responsive layout (phones → desktops)
   ========================================================= */

/* Shared fluid helpers */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: clip;
}

.app-shell,
.main,
.page,
.dashboard,
.search-strip,
.panel,
.neu {
  max-width: 100%;
  min-width: 0;
}

.page {
  width: 100%;
}

img,
svg,
video,
canvas {
  max-width: 100%;
}

/* Prevent long labels from blowing out cards */
.hero-day-label,
.hero-desc,
.hero-feels,
.country-line,
.compare-place,
.daily-desc,
.suggestion-country {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ---------- Large phones / phablets ---------- */
@media (max-width: 640px) {
  .app-shell {
    padding:
      0
      max(0.85rem, env(safe-area-inset-left))
      calc(5.75rem + env(safe-area-inset-bottom))
      max(0.85rem, env(safe-area-inset-right));
  }

  .navbar-inner {
    padding-top: max(0.65rem, env(safe-area-inset-top));
    gap: 0.45rem;
  }

  .navbar-actions {
    gap: 0.25rem;
  }

  .topbar-btn {
    width: 40px;
    height: 40px;
  }

  .search-field {
    flex-wrap: wrap;
    border-radius: 18px;
    padding: 0.45rem 0.45rem 0.45rem 0.85rem;
  }

  .search-btn {
    width: 100%;
    border-radius: 14px;
  }

  .hero {
    padding: 0.25rem 0 1rem;
  }

  .hero-icon-wrap,
  .hero-icon {
    width: min(140px, 38vw);
    height: min(140px, 38vw);
  }
  .hero-mark {
    width: min(110px, 30vw);
    height: min(110px, 30vw);
  }

  .hero-temp {
    font-size: clamp(3.25rem, 16vw, 4.5rem);
  }

  .hero-desc {
    font-size: 1.05rem;
  }

  .hero-feels {
    font-size: 0.78rem;
    padding: 0 0.5rem;
  }

  .metrics-card {
    padding: 0.85rem 0.35rem;
    margin-bottom: 1rem;
  }

  .metric strong {
    font-size: 0.92rem;
  }

  .metric span:last-child {
    font-size: 0.68rem;
  }

  .metric-icon {
    width: 28px;
    height: 28px;
  }

  .hourly-item {
    width: 66px;
    padding: 0.65rem 0.35rem;
  }

  .section-head h2 {
    font-size: 1.1rem;
  }

  .tomorrow-card.forecast-hero {
    grid-template-columns: 1fr;
    grid-template-areas:
      "copy"
      "icon"
      "metrics";
    text-align: center;
    justify-items: center;
  }

  .forecast-hero .tomorrow-icon {
    width: 96px;
    height: 96px;
  }

  .tomorrow-temps {
    font-size: 1.45rem;
  }

  .daily-item {
    grid-template-columns: 2.7rem 2.2rem minmax(0, 1fr) auto;
    gap: 0.45rem;
    padding: 0.75rem 0.7rem;
  }

  .page-header {
    margin-bottom: 0.75rem;
  }

  .ai-fab {
    width: 52px;
    height: 52px;
    right: max(0.85rem, env(safe-area-inset-right));
    bottom: calc(5.15rem + env(safe-area-inset-bottom));
  }

  .assistant-sheet {
    width: calc(100vw - 0.75rem);
    max-height: min(88dvh, 720px);
    margin: 0 0.35rem max(0.35rem, env(safe-area-inset-bottom));
    border-radius: 18px 18px 14px 14px;
  }

  .assistant-chat {
    max-height: min(32vh, 260px);
    min-height: 140px;
  }

  .anim-settings {
    right: max(0.75rem, env(safe-area-inset-right));
    left: max(0.75rem, env(safe-area-inset-left));
    bottom: calc(5.15rem + env(safe-area-inset-bottom));
    align-items: stretch;
  }

  .anim-settings-panel {
    width: 100%;
  }

  .modal-card {
    width: min(100% - 1.25rem, 420px);
    margin: 0.75rem;
  }

  .more-menu {
    right: 0;
    left: auto;
    min-width: min(200px, calc(100vw - 1.5rem));
  }

  .wa-sun {
    width: min(240px, 62vw);
    height: min(240px, 62vw);
    top: -6%;
    right: -8%;
  }

  .wa-sun--partial {
    width: min(190px, 50vw);
    height: min(190px, 50vw);
    top: 1%;
    right: 0;
  }

  .wa-sun-core {
    width: 72px;
    height: 72px;
    margin: -36px 0 0 -36px;
  }

  .wa-moon {
    width: 70px;
    height: 70px;
    top: 6%;
    right: 8%;
  }
}

/* ---------- Compact phones ---------- */
@media (max-width: 480px) {
  .app-shell {
    padding:
      0
      max(0.75rem, env(safe-area-inset-left))
      calc(5.9rem + env(safe-area-inset-bottom))
      max(0.75rem, env(safe-area-inset-right));
  }

  .hero-icon-wrap,
  .hero-icon {
    width: 120px;
    height: 120px;
  }
  .hero-mark {
    width: 96px;
    height: 96px;
  }

  .hero-temp {
    font-size: clamp(3rem, 15vw, 4.1rem);
  }

  .hourly-item {
    width: 62px;
  }

  .empty-actions {
    flex-direction: column;
  }

  .empty-actions .btn {
    width: 100%;
  }

  .api-key-row {
    flex-direction: column;
  }

  .api-key-row .btn {
    width: 100%;
  }

  .compare-fields {
    flex-direction: column;
    align-items: stretch;
  }

  .compare-vs {
    text-align: center;
  }

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

  .compare-divider {
    justify-content: center;
    padding: 0.15rem 0;
  }

  .compare-field {
    min-width: 0;
    width: 100%;
  }

  .compare-table {
    min-width: 340px;
    font-size: 0.78rem;
  }

  .daily-item {
    grid-template-columns: 2.5rem 2rem minmax(0, 1fr);
    grid-template-rows: auto auto;
  }

  .daily-temps {
    grid-column: 3;
    grid-row: 2;
    text-align: left;
    justify-self: start;
  }

  .navbar-brand .brand-text {
    font-size: 0.95rem;
  }

  .navbar-meta .location-name {
    max-width: min(42vw, 9.5rem);
  }

  .bottom-link span {
    font-size: 0.62rem;
  }

  .chip-list {
    gap: 0.4rem;
  }

  .metrics-mini {
    width: 100%;
  }
}

/* ---------- Very small phones ---------- */
@media (max-width: 360px) {
  .app-shell {
    padding-left: 0.65rem;
    padding-right: 0.65rem;
  }

  .metrics-card {
    padding: 0.7rem 0.15rem;
    gap: 0;
  }

  .metric strong {
    font-size: 0.82rem;
  }

  .metric span:last-child {
    font-size: 0.62rem;
  }

  .metric-divider {
    height: 28px;
  }

  .location-name {
    font-size: 0.95rem;
  }

  .bottom-link {
    min-height: 48px;
    padding: 0.2rem 0;
  }

  .bottom-link span {
    font-size: 0.58rem;
  }

  .bottom-link svg {
    width: 18px;
    height: 18px;
  }

  .hero-day-label {
    font-size: 0.72rem;
    padding: 0.3rem 0.7rem;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
  }
}

/* Hide search on denser utility pages (mobile / tablet portrait) */
@media (max-width: 959px) {
  body[data-page="forecast"] .search-strip,
  body[data-page="details"] .search-strip,
  body[data-page="insights"] .search-strip,
  body[data-page="compare"] .search-strip,
  body[data-page="places"] .search-strip {
    display: none;
  }

  .navbar-inner {
    padding-left: max(0.85rem, env(safe-area-inset-left));
    padding-right: max(0.85rem, env(safe-area-inset-right));
  }
}

/* ---------- Short landscape phones ---------- */
@media (max-height: 480px) and (orientation: landscape) {
  .app-shell {
    padding-bottom: calc(4.75rem + env(safe-area-inset-bottom));
  }

  .hero {
    padding-top: 0;
    padding-bottom: 0.5rem;
  }

  .hero-icon-wrap,
  .hero-icon {
    width: 84px;
    height: 84px;
    margin-bottom: 0;
  }
  .hero-mark {
    width: 68px;
    height: 68px;
  }

  .hero-temp {
    font-size: 2.6rem;
  }

  .hero-glow,
  .hero-burst {
    width: 120px;
    height: 120px;
  }

  .metrics-card {
    margin-bottom: 0.75rem;
  }

  .bottom-nav {
    padding-top: 0.2rem;
    padding-bottom: calc(0.2rem + env(safe-area-inset-bottom));
  }

  .bottom-link {
    min-height: 44px;
  }

  .ai-fab {
    width: 46px;
    height: 46px;
    bottom: calc(4.4rem + env(safe-area-inset-bottom));
  }

  .assistant-sheet {
    max-height: 92dvh;
  }
}

/* ---------- Tablet+ ---------- */
@media (min-width: 768px) {
  .app-shell {
    max-width: none;
    width: 100%;
    padding:
      0
      clamp(1.25rem, 3vw, 2rem)
      calc(5.5rem + env(safe-area-inset-bottom));
  }

  .main {
    width: 100%;
    max-width: none;
  }

  .search-strip {
    max-width: min(640px, 100%);
    width: 100%;
    margin-left: auto;
    margin-right: auto;
  }

  .empty-card {
    max-width: min(640px, 100%);
  }

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

  .compare-grid {
    grid-template-columns: 1fr auto 1fr;
  }

  .tomorrow-card.forecast-hero {
    grid-template-columns: 1fr auto;
  }

  .ai-fab {
    bottom: calc(5.5rem + env(safe-area-inset-bottom));
  }
}

/* ---------- Desktop — top nav, no bottom tabs ---------- */
@media (min-width: 960px) {
  .app-shell {
    max-width: none;
    width: 100%;
    padding:
      0
      clamp(1.5rem, 4vw, 3rem)
      max(2.5rem, env(safe-area-inset-bottom));
  }

  .navbar-inner {
    padding:
      max(0.75rem, env(safe-area-inset-top))
      clamp(1.5rem, 4vw, 3rem)
      0.75rem;
    gap: 1rem;
  }

  .navbar-left {
    flex: 0 1 auto;
  }

  .navbar-meta .location-name {
    max-width: min(220px, 18vw);
  }

  .navbar-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 0.15rem;
    padding: 0.25rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--stroke);
    max-width: min(640px, 52vw);
    margin: 0 auto;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .navbar-menu::-webkit-scrollbar {
    display: none;
  }

  .bottom-nav {
    display: none !important;
  }

  .ai-fab {
    bottom: max(1.5rem, env(safe-area-inset-bottom));
    right: max(1.5rem, env(safe-area-inset-right));
  }

  .anim-settings {
    bottom: max(1.5rem, env(safe-area-inset-bottom));
    left: auto;
    right: max(1.5rem, env(safe-area-inset-right));
    align-items: flex-end;
  }

  .anim-settings-panel {
    width: min(280px, calc(100vw - 2rem));
  }

  .topbar-btn {
    width: 42px;
    height: 42px;
  }

  .search-strip {
    max-width: min(720px, 100%);
    margin-left: auto;
    margin-right: auto;
  }

  .page {
    max-width: 980px;
    margin-inline: auto;
  }

  .page-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.1rem;
  }

  .hero {
    padding-top: 0.75rem;
    padding-bottom: 1.5rem;
  }

  .hero-icon-wrap,
  .hero-icon {
    width: 170px;
    height: 170px;
  }
  .hero-mark {
    width: 132px;
    height: 132px;
  }

  .hero-temp {
    font-size: clamp(4.25rem, 6vw, 5.25rem);
  }

  .hourly-scroll {
    padding-bottom: 0.5rem;
  }

  .empty-state {
    min-height: 0;
    width: 100%;
    padding-top: 1rem;
  }

  .empty-card {
    max-width: min(720px, 100%);
    width: 100%;
  }

  .assistant-sheet {
    width: min(420px, calc(100vw - 2rem));
    margin-right: max(1rem, env(safe-area-inset-right));
  }

  .wa-sun {
    width: min(360px, 42vw);
    height: min(360px, 42vw);
    top: -5%;
    right: -2%;
  }

  .wa-moon {
    width: 92px;
    height: 92px;
  }
}

/* ---------- Wide desktop ---------- */
@media (min-width: 1280px) {
  .app-shell {
    padding: 0 clamp(2rem, 5vw, 3.5rem) 3rem;
  }

  .navbar-inner {
    padding-left: clamp(2rem, 5vw, 3.5rem);
    padding-right: clamp(2rem, 5vw, 3.5rem);
  }

  .navbar-menu {
    max-width: 700px;
  }

  .page {
    max-width: 1080px;
  }

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

  #pagePlaces .page-grid,
  #pageCompare .page-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-temp {
    font-size: 5.25rem;
  }
}

@media (min-width: 1600px) {
  .app-shell {
    padding: 0 clamp(2.5rem, 6vw, 4.5rem) 3rem;
  }

  .navbar-inner {
    padding-left: clamp(2.5rem, 6vw, 4.5rem);
    padding-right: clamp(2.5rem, 6vw, 4.5rem);
  }

  .page {
    max-width: 1180px;
  }
}

/* ---------- Touch / coarse pointer ---------- */
@media (pointer: coarse) {
  .topbar-btn,
  .nav-link,
  .bottom-link,
  .hourly-item,
  .daily-item,
  .btn,
  .ask-chip,
  .suggestion-item,
  .more-item,
  .unit-btn {
    min-height: 44px;
  }

  .hourly-scroll {
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }

  .hourly-item {
    scroll-snap-align: start;
  }

  .search-suggestions,
  .compare-suggestions {
    max-height: min(42vh, 280px);
  }
}

/* ---------- Foldables / ultra-wide phones in portrait ---------- */
@media (min-width: 600px) and (max-width: 959px) {
  .search-strip {
    max-width: min(560px, 100%);
    margin-inline: auto;
  }

  .page {
    max-width: 720px;
    margin-inline: auto;
  }

  .hero-temp {
    font-size: clamp(4rem, 10vw, 4.75rem);
  }
}

/* Print: keep content readable, drop FX chrome */
@media print {
  .weather-fx,
  .bottom-nav,
  .ai-fab,
  .anim-settings,
  .assistant-drawer,
  .navbar-actions {
    display: none !important;
  }

  body {
    background: #fff;
    color: #111;
  }

  .app-shell {
    padding: 0;
  }
}
