/* ==========================================================================
   Fold-class responsive safeguards

   The Galaxy Z Fold8 has a phone-like cover display and a much wider opened
   display. Keep the existing cover layout, then let the embedded app use the
   wider canvas once at least 540 CSS pixels are available.
   ========================================================================== */

/* Modal height should follow the visible viewport as mobile browser chrome
   expands and collapses. */
body.wp-experience.wp-page-forecast #alert-modal .modal-content.alert-sheet,
body.wp-experience.wp-page-radar #alert-modal .modal-content.alert-sheet {
  height: calc(100dvh - var(--safe-top, env(safe-area-inset-top, 0px)) - 28px) !important;
  max-height: calc(100dvh - var(--safe-top, env(safe-area-inset-top, 0px)) - 28px) !important;
}

body.wp-experience.wp-page-forecast .forecast-detail-sheet {
  display: flex !important;
  flex-direction: column !important;
  max-height: calc(100dvh - 32px) !important;
  overflow: hidden !important;
}

body.wp-experience.wp-page-forecast .forecast-detail-body {
  min-height: 0 !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

body.wp-experience.wp-page-forecast .forecast-setup-card {
  max-height: calc(100dvh - 36px) !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Keep the wide community-partner popup inside either Fold display. */
body.wp-experience.wp-page-radar
  .ryan-jessop-mapbox-popup.mapboxgl-popup
  .mapboxgl-popup-content {
  width: min(560px, calc(100vw - 24px)) !important;
  max-width: calc(100vw - 24px) !important;
}

@media (min-width: 540px) {
  /* Home: remove the legacy 430px embedded phone canvas entirely on the
     unfolded display. */
  html[data-theme]
    body.wp-experience.wp-page-home.wp-shell-embedded-nav
    #main-scroll,
  html[data-theme]
    body.wp-experience.wp-page-home.wp-shell-embedded-nav
    .wp-life-home {
    width: 100% !important;
    max-width: none !important;
    margin-inline: auto !important;
  }

  /* Forecast: hero, mode switcher, and report content grow together across
     the full safe width of the unfolded display. */
  html[data-theme]
    body.wp-experience.wp-page-forecast.wp-shell-embedded-nav
    #main-scroll,
  html[data-theme]
    body.wp-experience.wp-page-forecast.wp-shell-embedded-nav
    .main-wrapper,
  html[data-theme]
    body.wp-experience.wp-page-forecast.wp-shell-embedded-nav
    .content-backdrop,
  body.wp-experience.wp-page-forecast.wp-shell-embedded-nav
    .content-container,
  body.wp-experience.wp-page-forecast.wp-shell-embedded-nav #content-grid,
  body.wp-experience.wp-page-forecast.wp-shell-embedded-nav
    .sticky-hero-block {
    width: 100% !important;
    max-width: none !important;
    margin-inline: auto !important;
  }

  html[data-theme]
    body.wp-experience.wp-page-forecast.wp-shell-embedded-nav
    #main-scroll {
    overflow-x: hidden !important;
  }

  body.wp-experience.wp-page-forecast.wp-shell-embedded-nav
    :is(.sticky-location-bar, .forecast-alert-shell, #weather-error-state),
  body.wp-experience.wp-page-forecast.wp-shell-embedded-nav
    #forecast-view-controls {
    width: calc(100% - 16px) !important;
    max-width: none !important;
    margin-inline: auto !important;
  }

  /* Keep the injected app header aligned with the newly full-width pages. */
  html[data-theme]
    body.wp-shell-embedded-nav
    .wp-embedded-topbar-inner {
    width: 100% !important;
    max-width: none !important;
  }

  /* WarnPins uses the full safe width instead of a centered 560/680px card. */
  body.wp-experience.wp-page-warnpins.wp-shell-embedded-nav
    :is(
      .main-wrapper,
      .content-backdrop,
      .content-container,
      .wpz-shell,
      .app-topbar-inner,
      .wpz-postbar
    ) {
    max-width: none !important;
    margin-inline: auto !important;
  }

  body.wp-experience.wp-page-warnpins.wp-shell-embedded-nav
    :is(.content-container, .wpz-shell) {
    padding-bottom:
      calc(142px + var(--wp-embedded-bottom-boundary, 0px)) !important;
  }

  body.wp-experience.wp-page-warnpins.wp-shell-embedded-nav .wpz-postbar {
    bottom:
      calc(var(--wp-embedded-bottom-boundary, 0px) + 10px) !important;
  }
}

/* The Forecast desktop table starts at 760px but needs 990px. Use the compact
   daily cards and a single report column on Fold-sized landscape screens. */
@media (min-width: 760px) and (max-width: 1040px) {
  body.wp-experience.wp-page-forecast #content-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.wp-experience.wp-page-forecast #content-grid > * {
    width: 100% !important;
    min-width: 0 !important;
    grid-column: 1 / -1 !important;
  }

  body.wp-experience.wp-page-forecast .forecast-daily-column-heads {
    display: none !important;
  }

  body.wp-experience.wp-page-forecast .daily-list {
    overflow: visible !important;
    border-top: 0 !important;
  }

  body.wp-experience.wp-page-forecast .forecast-day-item {
    min-width: 0 !important;
    margin-bottom: 8px !important;
    border: 1px solid var(--forecast-rule) !important;
    border-radius: 14px !important;
    background: var(--ds-paper-solid) !important;
  }

  body.wp-experience.wp-page-forecast
    #card-daily
    .forecast-day-item
    .day-row.day-row-button {
    min-height: 104px !important;
    grid-template-columns: minmax(0, 1fr) auto auto !important;
    grid-template-rows: auto auto !important;
    grid-template-areas:
      "primary range range"
      "rain wind humidity" !important;
    gap: 8px 10px !important;
    padding: 12px !important;
    overflow: hidden !important;
    border-radius: 14px !important;
  }

  body.wp-experience.wp-page-forecast #card-daily .day-primary {
    grid-area: primary !important;
    min-width: 0 !important;
  }

  body.wp-experience.wp-page-forecast #card-daily .day-condition {
    display: none !important;
  }

  body.wp-experience.wp-page-forecast #card-daily .day-range-container {
    grid-area: range !important;
    grid-column: 2 / 4 !important;
    width: auto !important;
    min-width: 90px !important;
    grid-template-columns: auto auto !important;
    gap: 6px !important;
  }

  body.wp-experience.wp-page-forecast
    #card-daily
    .day-range-container
    .range-track {
    display: none !important;
  }

  body.wp-experience.wp-page-forecast #card-daily .day-rain {
    grid-area: rain !important;
    grid-column: auto !important;
  }

  body.wp-experience.wp-page-forecast #card-daily .day-wind {
    grid-area: wind !important;
    grid-column: auto !important;
    display: inline-flex !important;
  }

  body.wp-experience.wp-page-forecast #card-daily .day-humidity {
    grid-area: humidity !important;
    grid-column: auto !important;
    display: inline-flex !important;
  }

  body.wp-experience.wp-page-forecast #card-daily .day-metric {
    min-width: 0 !important;
    gap: 3px !important;
  }
}

/* The unfolded landscape has enough width for a compact horizontal submit
   bar, saving vertical map/form space above the native navigation. */
@media (min-width: 700px) and (max-width: 920px) and (max-height: 700px) and (orientation: landscape) {
  body.wp-experience.wp-page-home .wp-life-hero {
    min-height: 0 !important;
  }

  body.wp-experience.wp-page-warnpins.wp-shell-embedded-nav
    :is(.content-container, .wpz-shell) {
    padding-bottom:
      calc(104px + var(--wp-embedded-bottom-boundary, 0px)) !important;
  }

  body.wp-experience.wp-page-warnpins.wp-shell-embedded-nav .wpz-postbar {
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 8px 10px !important;
    border-radius: 18px !important;
  }

  body.wp-experience.wp-page-warnpins.wp-shell-embedded-nav
    .sticky-submit-hint {
    padding: 0 4px !important;
    text-align: left !important;
  }

  body.wp-experience.wp-page-warnpins.wp-shell-embedded-nav
    .wpz-postbar
    #submit-button {
    flex: 0 0 220px !important;
    width: 220px !important;
    min-height: 48px !important;
  }
}

/* The app-download interstitial should stack on the open portrait display,
   not squeeze its copy and buttons into two narrow columns. */
@media (min-width: 561px) and (max-width: 700px) {
  body.wp-experience.wp-page-home .site-app-promo-inner {
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: end !important;
    min-height: 100% !important;
  }

  body.wp-experience.wp-page-home .site-app-promo-actions {
    width: 100% !important;
    justify-self: stretch !important;
  }
}
