/**
 * Weather Modal Styles
 *
 * Full-screen modal displaying current weather, hourly forecast, and 3-day forecast.
 * Triggered by anchor links with href="#ewp-weather"
 * Modal is mounted inside #siteWrapper when available.
 *
 * ─── Customization ────────────────────────────────────────────────────
 * The component exposes CSS custom properties so consumers can theme it
 * without overriding selectors. Each property is unset by default and
 * falls back to a Squarespace section color theme variable, so the
 * component automatically respects the active section theme.
 *
 * Colors
 *   --weather-modal-bg                 Panel background
 *   --weather-modal-card-bg            Section card / close button background
 *   --weather-modal-backdrop           Backdrop overlay color
 *   --weather-modal-border             Border / scrollbar color
 *   --weather-modal-shadow             Panel drop shadow
 *   --weather-modal-heading            Temperature / heading color
 *   --weather-modal-text               Primary body text color
 *   --weather-modal-text-muted         Secondary / label text color
 *   --weather-modal-accent             Accent color (focus ring, precip, spinner)
 *   --weather-modal-accent-muted       Muted accent (close hover, bar track)
 *   --weather-modal-bar-gradient       Day high/low temperature bar gradient
 * 
 * Sizes
 *   --weather-modal-padding            Outer modal padding
 *   --weather-modal-content-padding    Content container padding
 *   --weather-modal-max-width          Panel max width
 *   --weather-modal-max-height         Panel max height
 *   --weather-modal-radius             Panel border radius
 *   --weather-modal-backdrop-blur      Backdrop blur radius
 *   --weather-modal-close-size         Close button dimensions
 *   --weather-modal-temp-size          Current temperature font size
 *   --weather-modal-icon-size          Current weather icon font size
 *   --weather-modal-location-size      Location label font size
 *   --weather-modal-condition-size     Condition label font size
 *   --weather-modal-detail-size        Detail row font size
 *   --weather-modal-section-title-size Section title font size
 *   --weather-modal-hour-min-width     Hourly column min width
 *   --weather-modal-hour-time-size     Hourly time label font size
 *   --weather-modal-hour-icon-size     Hourly icon font size
 *   --weather-modal-hour-temp-size     Hourly temperature font size
 *   --weather-modal-day-name-size      Day-of-week label font size
 *   --weather-modal-day-icon-size      Daily icon font size
 *   --weather-modal-day-bar-height     Daily high/low bar height
 *   --weather-modal-day-temp-size      Daily high/low font size
 *   --weather-modal-spinner-size       Loading spinner dimensions
 */

/* =============================================================================
   Modal Overlay & Backdrop
   ============================================================================= */

.ewp-weather-modal {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--weather-modal-padding, 1rem);

  /* Inherit site typography */
  font-family: var(--body-font-font-family, inherit);
  color: var(--weather-modal-text, var(--paragraphMediumColor, inherit));
}

/* Backdrop with blur */
.ewp-weather-modal__backdrop {
  position: absolute;
  inset: 0;
  background: var(--weather-modal-backdrop, hsla(var(--darkAccent-hsl, 0, 0%, 0%), 0.75));
  backdrop-filter: blur(var(--weather-modal-backdrop-blur, 8px));
  -webkit-backdrop-filter: blur(var(--weather-modal-backdrop-blur, 8px));
  cursor: pointer;

  /* Animation */
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

.ewp-weather-modal--open .ewp-weather-modal__backdrop {
  opacity: 1;
}

/* =============================================================================
   Modal Panel
   ============================================================================= */

.ewp-weather-modal__panel {
  position: relative;
  width: 100%;
  max-width: var(--weather-modal-max-width, 480px);
  max-height: var(--weather-modal-max-height, 90vh);
  overflow-y: auto;
  background: var(--weather-modal-bg, var(--siteBackgroundColor, var(--offwhite)));
  border-radius: var(--weather-modal-radius, 0);
  box-shadow: var(--weather-modal-shadow, 0 25px 50px -12px hsla(var(--darkAccent-hsl, 0, 0%, 0%), 0.4));

  /* Animation */
  opacity: 0;
  transform: scale(0.95) translateY(10px);
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;

  /* Scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: var(--weather-modal-border, var(--section-divider-stroke-color, rgba(122, 142, 163, 0.15))) transparent;
}

.ewp-weather-modal__panel::-webkit-scrollbar {
  width: 6px;
}

.ewp-weather-modal__panel::-webkit-scrollbar-track {
  background: transparent;
}

.ewp-weather-modal__panel::-webkit-scrollbar-thumb {
  background: var(--weather-modal-border, var(--section-divider-stroke-color, rgba(122, 142, 163, 0.15)));
}

.ewp-weather-modal--open .ewp-weather-modal__panel {
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* Close button */
.ewp-weather-modal__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--weather-modal-close-size, 36px);
  height: var(--weather-modal-close-size, 36px);
  padding: 0;
  background: var(--weather-modal-card-bg, rgba(155, 189, 60, 0.09));
  border: none;
  border-radius: 50%;
  color: var(--weather-modal-text-muted, var(--paragraphSmallColor, inherit));
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.ewp-weather-modal__close:hover {
  background: var(--weather-modal-accent-muted, hsla(var(--accent-hsl, 210, 60%, 50%), 0.15));
  transform: scale(1.05);
}

.ewp-weather-modal__close:focus-visible {
  outline: 2px solid var(--weather-modal-accent, hsla(var(--accent-hsl, 210, 60%, 50%), 1));
  outline-offset: 2px;
}

/* =============================================================================
   Content Container
   ============================================================================= */

.ewp-weather-modal__content {
  padding: var(--weather-modal-content-padding, 1.5rem);
}

/* =============================================================================
   Hero Section - Current Weather
   ============================================================================= */

.ewp-weather-modal__hero {
  text-align: center;
  padding: 2rem 1rem;
  margin-bottom: 1.5rem;
}

.ewp-weather-modal__location {
  margin: 0 0 0.5rem;
  font-size: var(--weather-modal-location-size, 0.875rem);
  font-weight: 600;
  color: var(--weather-modal-text-muted, var(--paragraphSmallColor, inherit));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ewp-weather-modal__current {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.ewp-weather-modal__icon {
  font-size: var(--weather-modal-icon-size, 4rem);
  line-height: 1;
}

.ewp-weather-modal__temp {
  font-size: var(--weather-modal-temp-size, 4.5rem);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--weather-modal-heading, var(--headingLargeColor, inherit));
}

.ewp-weather-modal__temp sup {
  font-size: 0.4em;
  vertical-align: super;
  margin-left: 0.1em;
  font-weight: 400;
  color: var(--weather-modal-text-muted, var(--paragraphSmallColor, inherit));
}

.ewp-weather-modal__condition {
  margin: 0;
  font-size: var(--weather-modal-condition-size, 1.25rem);
  font-weight: 400;
  color: var(--weather-modal-text, var(--paragraphMediumColor, inherit));
}

.ewp-weather-modal__details {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1rem;
  font-size: var(--weather-modal-detail-size, 0.875rem);
  color: var(--weather-modal-text-muted, var(--paragraphSmallColor, inherit));
}

.ewp-weather-modal__detail {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

/* =============================================================================
   Section Cards
   ============================================================================= */

.ewp-weather-modal__section {
  margin-bottom: 1rem;
  background: var(--weather-modal-card-bg, rgba(155, 189, 60, 0.09));
  padding: 1rem;
  overflow: hidden;
}

.ewp-weather-modal__section:last-child {
  margin-bottom: 0;
}

.ewp-weather-modal__section-header {
  display: flex;
  align-items: center;
  margin-bottom: 0.75rem;
}

.ewp-weather-modal__section-title {
  margin: 0;
  font-size: var(--weather-modal-section-title-size, 0.8125rem);
  font-weight: 600;
  color: var(--weather-modal-text-muted, var(--paragraphSmallColor, inherit));
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* =============================================================================
   Hourly Forecast Section
   ============================================================================= */

.ewp-weather-modal__hourly {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding: 0.5rem 1rem;
  margin-left: -1rem;
  margin-right: -1rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;

  /* Hide scrollbar */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.ewp-weather-modal__hourly::-webkit-scrollbar {
  display: none;
}

.ewp-weather-modal__hour {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: var(--weather-modal-hour-min-width, 3.5rem);
  scroll-snap-align: start;
}

.ewp-weather-modal__hour--sun {
  .ewp-weather-modal__hour-time {
    font-size: 0.6875rem;
  }
}

.ewp-weather-modal__hour-time {
  font-size: var(--weather-modal-hour-time-size, 0.8125rem);
  font-weight: 500;
  color: var(--weather-modal-text-muted, var(--paragraphSmallColor, inherit));
}

.ewp-weather-modal__hour-icon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  min-height: 2.5rem;
}

.ewp-weather-modal__hour-icon {
  font-size: var(--weather-modal-hour-icon-size, 1.5rem);
  line-height: 1;
}

.ewp-weather-modal__hour-precip {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--weather-modal-accent, hsla(var(--accent-hsl, 210, 60%, 50%), 1));
}

.ewp-weather-modal__hour-temp {
  font-size: var(--weather-modal-hour-temp-size, 1.125rem); 
  font-weight: 500;
  color: var(--weather-modal-heading, var(--headingLargeColor, inherit));
}

/* =============================================================================
   3-Day Forecast Section
   ============================================================================= */

.ewp-weather-modal__daily {
  display: flex;
  flex-direction: column;
}

.ewp-weather-modal__day {
  display: grid;
  grid-template-columns: 5.5rem 3rem 2.5rem 1fr 2.5rem;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
}

.ewp-weather-modal__day-name {
  font-size: var(--weather-modal-day-name-size, 1.125rem);
  font-weight: 500;
  color: var(--weather-modal-text, var(--paragraphMediumColor, inherit));
}

.ewp-weather-modal__day-icon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-self: center;
}

.ewp-weather-modal__day-icon {
  font-size: var(--weather-modal-day-icon-size, 1.5rem);
  line-height: 1;
}

.ewp-weather-modal__day-precip {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--weather-modal-accent, hsla(var(--accent-hsl, 210, 60%, 50%), 1));
}

.ewp-weather-modal__day-low {
  font-size: var(--weather-modal-day-temp-size, 1.125rem);
  font-weight: 500;
  color: var(--weather-modal-text-muted, var(--paragraphSmallColor, inherit));
  text-align: right;
}

.ewp-weather-modal__day-bar-container {
  position: relative;
  height: var(--weather-modal-day-bar-height, 4px);
  background: var(--weather-modal-accent-muted, hsla(var(--accent-hsl, 210, 60%, 50%), 0.15));
}

.ewp-weather-modal__day-bar {
  height: 100%;
  background: var(
    --weather-modal-bar-gradient,
    linear-gradient(
      to right,
      var(--blue),
      var(--green),
      var(--yellow),
      var(--red)
    )
  );
  min-width: 20px;
}

.ewp-weather-modal__day-high {
  font-size: var(--weather-modal-day-temp-size, 1.125rem);
  font-weight: 500;
  color: var(--weather-modal-heading, var(--headingLargeColor, inherit));
  text-align: left;
}

/* =============================================================================
   Loading & Error States
   ============================================================================= */

.ewp-weather-modal__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
}

.ewp-weather-modal__spinner {
  width: var(--weather-modal-spinner-size, 40px);
  height: var(--weather-modal-spinner-size, 40px);
  border: 3px solid var(--weather-modal-border, var(--section-divider-stroke-color, rgba(122, 142, 163, 0.15)));
  border-top-color: var(--weather-modal-accent, hsla(var(--accent-hsl, 210, 60%, 50%), 1));
  border-radius: 50%;
  animation: ewp-modal-spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

.ewp-weather-modal__loading-text {
  font-size: 1rem;
  color: var(--weather-modal-text-muted, var(--paragraphSmallColor, inherit));
}

.ewp-weather-modal__error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
}

.ewp-weather-modal__error-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.ewp-weather-modal__error-text {
  font-size: 1rem;
  color: var(--weather-modal-text-muted, var(--paragraphSmallColor, inherit));
  margin: 0;
}

/* =============================================================================
   Animations
   ============================================================================= */

@keyframes ewp-modal-spin {
  to {
    transform: rotate(360deg);
  }
}

/* =============================================================================
   Responsive Adjustments
   ============================================================================= */

@media (max-width: 500px) {
  .ewp-weather-modal__panel {
    max-width: 100%;
    max-height: 95vh;
  }

  .ewp-weather-modal__content {
    padding: 1rem;
  }

  .ewp-weather-modal__hero {
    padding: 1.5rem 0.5rem;
  }

  .ewp-weather-modal__icon {
    font-size: 3rem;
  }

  .ewp-weather-modal__temp {
    font-size: 3.5rem;
  }

  .ewp-weather-modal__condition {
    font-size: 1rem;
  }

  .ewp-weather-modal__details {
    gap: 1rem;
    font-size: 0.8125rem;
  }

  .ewp-weather-modal__day {
    grid-template-columns: 4rem 2.5rem 2rem 1fr 2rem;
    gap: 0.5rem;
  }

  .ewp-weather-modal__day-name {
    font-size: 0.9375rem;
  }

  .ewp-weather-modal__day-icon {
    font-size: 1.25rem;
  }

  .ewp-weather-modal__day-low,
  .ewp-weather-modal__day-high {
    font-size: 1rem;
  }
}

@media (max-width: 360px) {
  .ewp-weather-modal__day {
    grid-template-columns: 3.5rem 2rem 2rem 1fr 2rem;
    gap: 0.375rem;
  }

  .ewp-weather-modal__day-name {
    font-size: 0.8125rem;
  }

  .ewp-weather-modal__day-bar-container {
    display: none;
  }
}

/* =============================================================================
   Reduced Motion
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
  .ewp-weather-modal__backdrop,
  .ewp-weather-modal__panel {
    transition: none;
  }

  .ewp-weather-modal__spinner {
    animation: none;
    border-top-color: var(--weather-modal-accent, hsla(var(--accent-hsl, 210, 60%, 50%), 1));
  }

  .ewp-weather-trigger__loading {
    animation: none;
    opacity: 0.5;
  }
}

/* =============================================================================
   Trigger Link Styles
   ============================================================================= */

.ewp-weather-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
}

.ewp-weather-trigger__temp {
  font-weight: 500;
}

.ewp-weather-trigger__icon {
  font-size: 1.1em;
}

.ewp-weather-trigger__loading {
  display: inline-block;
  animation: ewp-trigger-pulse 1.2s ease-in-out infinite;
}

@keyframes ewp-trigger-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
