/* ============================================================
   ATMOS — page-specific styles
   kzick.dev/weather
   Depends on kzick-styles.css for tokens (--bg, --surface, --accent, etc).
   Mobile-first: base rules are the small-screen layout, not a fallback.
   ============================================================ */

:root {
  /* kzick-styles.css has no amber token - added locally for alert-state glow */
  --alert-amber: #fbbf24;
  /* Distinct warm gold for the sun icon - intentionally NOT --alert-amber,
     so sun color never gets confused with an active-alert state. */
  --sun-gold: #f5b942;
}

html {
  background-color: var(--bg);
}

/* ── HEADER ── */

.atmos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.atmos-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.atmos-icon {
  border-radius: 8px;
  display: block;
}

.atmos-title {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

/* ── MAIN LAYOUT ── */

.atmos-main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.25rem;
  max-width: 720px;
  margin: 0 auto;
}

/* ── ALERT BANNER ── */

.atmos-alert {
  border: 1px solid var(--danger);
  background: rgba(248, 113, 113, 0.1);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  color: var(--text-primary);
  font-weight: 600;
}

/* ── HERO ── */

.atmos-hero {
  position: relative;
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--accent-dark);
  border-radius: 16px;
  padding: 1.75rem 1.5rem;
  text-align: center;
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.15);
  transition: border-color 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.atmos-hero.alert-amber {
  border-color: var(--alert-amber);
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.35);
  animation: hero-glow-pulse-amber 2.4s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}

.atmos-hero.alert-severe {
  border-color: var(--danger);
  box-shadow: 0 0 20px rgba(248, 113, 113, 0.35);
  animation: hero-glow-pulse-red 2.4s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}

@keyframes hero-glow-pulse-amber {
  0%, 100% { box-shadow: 0 0 20px rgba(251, 191, 36, 0.35); }
  50% { box-shadow: 0 0 32px rgba(251, 191, 36, 0.6); }
}

@keyframes hero-glow-pulse-red {
  0%, 100% { box-shadow: 0 0 20px rgba(248, 113, 113, 0.35); }
  50% { box-shadow: 0 0 32px rgba(248, 113, 113, 0.6); }
}

/* No separate prefers-reduced-motion guard needed here - the global rule in
   kzick-styles.css already zeroes animation-duration and transition-duration site-wide. */

/* ── CARDS (shared: aqi, player, summary) ── */

.atmos-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
}

.atmos-card h2 {
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  text-align: center;
}

/* Audio Forecast header keeps title left / timestamp right - the general
   .atmos-card h2 centering rule above doesn't apply inside this flex row. */
.atmos-player-header h2 {
  text-align: left;
  margin-bottom: 0;
}

/* ── AUDIO PLAYER ── */

.atmos-player {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.atmos-player-toggle {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  background-color: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.atmos-player-toggle:hover:not(:disabled) {
  background-color: var(--accent-light);
}

.atmos-player-toggle:disabled {
  background-color: var(--surface-raised);
  opacity: 0.6;
}

.atmos-player-track {
  flex: 1;
  height: 6px;
  background-color: var(--surface-raised);
  border-radius: 3px;
  overflow: hidden;
}

.atmos-player-progress {
  height: 100%;
  width: 0%;
  background-color: var(--accent);
  border-radius: 3px;
  transition: width 0.1s linear;
}

.atmos-player-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
  min-width: 2.5rem;
  text-align: right;
}

.atmos-player-empty {
  margin-top: 0.75rem;
  color: var(--text-tertiary);
  font-size: 0.875rem;
}

.atmos-player-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.atmos-broadcast-timestamp {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* Sits below the timestamp via insertAdjacentElement("afterend", ...) in JS -
   .atmos-player-header stays a flex row for the title/timestamp pair, and
   this pill lives outside that row entirely so it never disrupts the
   title-left / timestamp-right layout. */
.atmos-stale-pill {
  display: block;
  width: fit-content;
  margin-top: 0.35rem;
  background-color: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

/* Three-way segmented control, replacing the prior two-way checkbox switch.
   Pill-shaped track matching the design system's rounded-control language;
   each option is its own button so aria-pressed state and per-option
   generating text are both native rather than derived from a single input. */
.atmos-voice-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.atmos-voice-option {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background-color 0.2s ease-out, color 0.2s ease-out;
}

.atmos-voice-option:hover:not(:disabled):not(.is-active) {
  color: var(--text-secondary);
}

.atmos-voice-option.is-active {
  background-color: var(--accent);
  color: var(--bg);
}

.atmos-voice-option:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Generating state on an individual option - dims and swaps cursor rather
   than resizing the pill, so the segmented control doesn't jump around
   while a background generation is in flight. */
.atmos-voice-option.is-generating {
  opacity: 0.6;
  cursor: wait;
}

.atmos-spinner {
  animation: atmos-spin 0.8s linear infinite;
  margin-right: 0.4rem;
  vertical-align: -3px;
}

/* Icon-only buttons (force-regenerate) have no adjacent label text,
   so the spinner doesn't need the text-clearance right margin. */
.atmos-icon-btn .atmos-spinner {
  margin-right: 0;
}

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

/* No separate prefers-reduced-motion guard needed here - the global rule in
   kzick-styles.css already zeroes animation-duration site-wide. */

/* ── DISCLOSURE BUTTON ── */

.atmos-disclosure {
  margin-top: 0.75rem;
  background-color: var(--surface-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
}

.atmos-disclosure:hover:not(:disabled) {
  background-color: var(--surface);
  border-color: var(--accent);
  color: var(--text-primary);
}

/* ── ICON BUTTON (force regenerate) ── */

.atmos-icon-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background-color: var(--surface-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0.75rem auto 0;
}

/* Hero refresh sits absolutely, bottom-right of the hero card - needs no
   auto-centering margin from the base .atmos-icon-btn rule above. */
.atmos-hero-refresh {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  margin: 0;
  width: 28px;
  height: 28px;
  min-width: 28px;
}

.atmos-icon-btn:hover:not(:disabled) {
  background-color: var(--surface);
  border-color: var(--accent);
  color: var(--text-primary);
}

.atmos-icon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── SCROLL SECTIONS (five-day, hourly) ── */

.atmos-scroll-section h2 {
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  padding: 0 0.25rem;
  text-align: center;
}

#summary {
  text-align: center;
}

.atmos-scroll-track {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.25rem 0.25rem 0.75rem;
  scroll-snap-type: x proximity;
  /* Desaturated cyan, distinct from the full-saturation --accent used by the
     global ::-webkit-scrollbar-thumb rule in kzick-styles.css, so this reads
     as an intentional muted variant rather than an accidental mismatch. */
  scrollbar-color: #4a8a94 transparent;
}

.atmos-scroll-track::-webkit-scrollbar-thumb {
  background: #4a8a94;
}

.atmos-scroll-track::-webkit-scrollbar-thumb:hover {
  background: #5a9aa4;
}

.atmos-scroll-track > * {
  scroll-snap-align: start;
  flex: 0 0 auto;
  min-width: 84px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 0.75rem;
  text-align: center;
}

/* ── DISCUSSION TEXT ── */

.atmos-summary-text {
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.atmos-discussion-raw {
  white-space: pre-wrap;
  color: var(--text-tertiary);
  font-size: 0.8rem;
  margin-top: 0.75rem;
  max-height: 320px;
  overflow-y: auto;
}

/* ── FOCUS VISIBILITY ── */

.atmos-disclosure:focus-visible,
.atmos-player-toggle:focus-visible,
.atmos-icon-btn:focus-visible,
.atmos-voice-option:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

/* ── ALERT ROWS (Phase 4) ── */

.atmos-alert-row + .atmos-alert-row {
  margin-top: 0.5rem;
}

/* ── HERO CONTENT (Phase 4) ── */

.atmos-hero-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 0.25rem;
}

.atmos-hero-temp {
  font-size: 3rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.atmos-hero-feels {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.atmos-hero-location {
  color: var(--text-primary);
  font-weight: 600;
  margin-top: 0.75rem;
}

.atmos-hero-updated {
  color: var(--text-tertiary);
  font-size: 0.8rem;
  margin-top: 0.25rem;
  font-family: 'JetBrains Mono', monospace;
}

/* ── AQI CARD CONTENT (Phase 4) ── */

.atmos-aqi-value {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 0.5rem;
}

#aqi-card {
  text-align: center;
}

.atmos-aqi-pollutants {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.atmos-aqi-pollutant-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin-bottom: 0.15rem;
}

/* ── DAY / HOUR CARDS (Phase 4) ── */

.atmos-day-name,
.atmos-hour-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.atmos-day-icon,
.atmos-hour-icon {
  display: flex;
  justify-content: center;
}

.atmos-day-icon svg,
.atmos-hour-icon svg {
  width: 32px;
  height: 32px;
}

.atmos-day-temp,
.atmos-hour-temp {
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 0.4rem;
  font-size: 0.9rem;
}

.atmos-day-meta,
.atmos-hour-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.35rem;
  font-size: 0.7rem;
  color: var(--text-tertiary);
  font-family: 'JetBrains Mono', monospace;
}

.atmos-meta-precip,
.atmos-meta-uv {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.atmos-meta-precip svg,
.atmos-meta-uv svg {
  width: 11px;
  height: 11px;
}

/* ── BREAKPOINT: 768px ── */

@media (min-width: 768px) {
  .atmos-main {
    max-width: 900px;
  }

  #aqi-card,
  #summary {
    display: inline-block;
    vertical-align: top;
    width: calc(50% - 0.625rem);
  }

  #aqi-card {
    margin-right: 1.25rem;
  }

  /* five-day / hourly scroll sections stay horizontal-scroll regardless of width - no override here */
}
