/**
 * Sunbird Styles
 * Abstract museum-poster palette: 5 pigments + white glow
 */

/* CSS Custom Properties - 8pt Grid System */
:root {
  /* Base gradient (Clear Day default) */
  --gradient-from: #FEFCF0;
  --gradient-to: #F5EDDA;

  /* Glow (sunlight diffusion) */
  --solar-color: #FFFDF7;
  --solar-glow: rgba(255,253,247,0.60);

  /* Text */
  --text-primary: #1A2A3A;
  --text-secondary: rgba(26,42,58,0.50);

  /* Rain accent */
  --rain-color: #7BA3D4;

  /* Accent (cobalt on light, text-color on dark) */
  --accent-color: #2F5EEA;
  --accent-filter: brightness(0) saturate(100%) invert(32%) sepia(60%) saturate(1800%) hue-rotate(215deg) brightness(92%) contrast(90%);

  /* Glass */
  --glass-bg: rgba(0, 0, 0, 0.06);
  --glass-border: rgba(0, 0, 0, 0.1);

  /* Typography */
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;

  /* 8pt Spacing Grid */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;

  /* Type Scale */
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 20px;
  --text-xl: 24px;
  --text-hero: 120px;
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background: linear-gradient(180deg, var(--gradient-from) 0%, var(--gradient-to) 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  transition: background 0.8s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
}

/* Grain/noise texture overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.025;
  pointer-events: none;
  z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

#app {
  max-width: 420px;
  margin: 0 auto;
  padding: var(--space-3);
  padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
  height: 100vh;
  height: 100dvh;
  display: flex;
  position: relative;
  z-index: 1;
  flex-direction: column;
  overflow: hidden;
}

.content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.middle-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}

.bottom-group {
  flex-shrink: 0;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Loading State */
.loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--glass-border);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

.loading p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Error State */
.error {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.error-message {
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  font-size: 1rem;
  opacity: 0.8;
}

/* Warning Banner */
.warning {
  background: rgba(255, 193, 7, 0.2);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  margin-bottom: var(--space-3);
  font-size: 0.8rem;
  color: var(--text-primary);
  text-align: center;
  opacity: 0.9;
}

/* ==================== HERO ZONE ==================== */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-bottom: var(--space-2);
  flex-shrink: 0;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  flex-shrink: 0;
}

.location-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: var(--font-family);
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--text-secondary);
  transition: color 0.2s;
  display: flex;
  align-items: center;
}

.location-btn:hover {
  color: var(--text-primary);
}

.hero-headline {
  font-size: var(--text-xl);
  font-weight: 500;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
  letter-spacing: -0.01em;
}

.hero-temp {
  font-size: var(--text-hero);
  font-weight: 700;
  color: var(--accent-color);
  line-height: 0.9;
  letter-spacing: -0.04em;
  margin: 0;
  position: relative;
}

/* Radial solar glow behind hero temperature */
.hero-temp::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--solar-glow) 0%, transparent 70%);
  pointer-events: none;
  z-index: -1;
}

.hero-meta {
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

/* ==================== LIGHT WINDOW (signature component) ==================== */
.light-window {
  margin-top: var(--space-1);
  padding: var(--space-1) 0;
  flex-shrink: 0;
}

.light-window-title {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  opacity: 0.6;
  margin-bottom: var(--space-1);
}

/* Light strip */
.light-strip-container {
  padding: var(--space-1) 0;
}

.light-strip {
  position: relative;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    #E8E2D4 0%,
    #FEFCF7 50%,
    #E8E2D4 100%
  );
}

.light-strip.night {
  background: linear-gradient(
    90deg,
    #2A2D52 0%,
    #5D5A7A 50%,
    #2A2D52 100%
  );
}

/* Sun/moon marker on light strip */
.light-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: left 0.3s ease, filter 0.3s ease;
  color: var(--text-primary);
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.15));
}

/* UV glow levels (sunlight diffusion behind icon) */
.light-dot.uv-0 { filter: drop-shadow(0 1px 2px rgba(0,0,0,0.12)); }
.light-dot.uv-low { filter: drop-shadow(0 0 6px rgba(191,217,246,0.5)); }
.light-dot.uv-moderate { filter: drop-shadow(0 0 8px rgba(255,253,247,0.6)); }
.light-dot.uv-high { filter: drop-shadow(0 0 10px rgba(196,101,77,0.5)) drop-shadow(0 0 4px rgba(196,101,77,0.3)); }
.light-dot.uv-very-high { filter: drop-shadow(0 0 12px rgba(196,101,77,0.7)) drop-shadow(0 0 6px rgba(196,101,77,0.4)); }

.light-dot.night {
  color: #E8E6F0;
  filter: drop-shadow(0 0 6px rgba(232,230,240,0.5));
}

/* Sunrise/Sunset labels */
.light-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}

.light-label-left,
.light-label-right {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--text-secondary);
}

/* UV legend (centered between times) */
.light-legend {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-secondary);
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ==================== BIRD ACTIVITY ==================== */
.bird-strip-title {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  opacity: 0.6;
  margin-bottom: var(--space-1);
}

.bird-strip-container {
  padding: var(--space-1) 0;
}

.bird-strip {
  position: relative;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    #1E2145 0%,
    #1E2145 18%,
    #5B7DB8 28%,
    #BFD9F6 35%,
    #2A2D52 48%,
    #2A2D52 58%,
    #BFD9F6 68%,
    #5B7DB8 75%,
    #1E2145 85%,
    #1E2145 100%
  );
}

.bird-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: left 0.3s ease, filter 0.3s ease;
  color: #E8E6F0;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.15));
}

.bird-dot.activity-high {
  filter: drop-shadow(0 0 10px rgba(160,170,212,0.6)) drop-shadow(0 0 4px rgba(160,170,212,0.3));
}

.bird-dot.activity-moderate {
  filter: drop-shadow(0 0 6px rgba(168,180,255,0.4));
}

.bird-dot.activity-low {
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}

.bird-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}

.bird-label-left,
.bird-label-right {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--text-secondary);
}

.bird-legend {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-secondary);
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Bird toggle button */
.bird-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  transition: opacity 0.2s;
  margin-left: auto;
  display: flex;
  align-items: center;
  color: var(--text-primary);
}

.bird-toggle-btn .bird-icon {
  filter: var(--accent-filter);
}

.bird-toggle-btn .weather-icon-toggle {
  filter: var(--accent-filter);
}

.bird-toggle-btn:hover {
  opacity: 0.7;
}

/* Bird view (full page - mirrors weather layout) */
.bird-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.bird-middle-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
}

.bird-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-bottom: var(--space-2);
}

.bird-hero-icon {
  width: 220px;
  height: 110px;
  object-fit: contain;
  filter: var(--accent-filter);
}

.bird-hero-headline {
  font-size: var(--text-xl);
  font-weight: 500;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
  letter-spacing: -0.01em;
}

.bird-hero-meta {
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

.bird-view-strip-section {
  padding: var(--space-1) 0;
  flex-shrink: 0;
}

.bird-notable {
  padding: var(--space-2) 0;
}

.bird-notable-title {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  opacity: 0.6;
  margin-bottom: var(--space-1);
}

.bird-notable-list {
  font-size: var(--text-base);
  color: var(--text-primary);
  font-weight: 500;
}

.bird-bottom-group {
  flex-shrink: 0;
}

.bird-species-list {
  max-height: 160px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-1) 0;
}

.bird-species-list::-webkit-scrollbar {
  width: 2px;
}

.bird-species-list::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 1px;
}

.bird-species-header {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  opacity: 0.6;
  margin-bottom: var(--space-1);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--glass-border);
}

.bird-species-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.bird-species-name {
  flex: 1;
  font-weight: 400;
}

.bird-species-count {
  width: 30px;
  text-align: right;
  color: var(--text-secondary);
  font-size: var(--text-xs);
}

.bird-species-time {
  width: 50px;
  text-align: right;
  color: var(--text-secondary);
  font-size: var(--text-xs);
}

/* ==================== SCROLLABLE 12-HOUR STRIP ==================== */
.hourly-section {
  margin-top: var(--space-2);
  margin-right: calc(-1 * var(--space-3));
  flex-shrink: 0;
}

.hourly-strip {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  padding: 0 var(--space-3) 0 0;
  scrollbar-width: none;
}

.hourly-strip::-webkit-scrollbar {
  display: none;
}

.hourly-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 52px;
  flex-shrink: 0;
  scroll-snap-align: start;
  padding: var(--space-1) 0;
}

.hourly-item.now {
  opacity: 1;
}

.hourly-time {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.hourly-item.now .hourly-time {
  color: var(--text-primary);
  font-weight: 600;
}

.hourly-icon {
  width: 22px;
  height: 22px;
  filter: var(--icon-filter, none);
}

.hourly-temp {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
}

.hourly-rain {
  font-size: 11px;
  font-weight: 600;
  color: var(--rain-color);
  min-height: 14px;
}

/* ==================== KEY MOMENTS ==================== */
.moments {
  margin-top: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex-shrink: 0;
}

.moment {
  padding: var(--space-2) 0;
  border-top: 1px solid var(--glass-border);
}

.moment:first-child {
  border-top: none;
}

.moment-time {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.moment-text {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.35;
}

.moment-detail {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

/* ==================== 3-DAY FORECAST ==================== */
.forecast-days {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding-bottom: var(--space-2);
}

.forecast-day {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) 0;
}

.forecast-day-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  width: 90px;
  flex-shrink: 0;
}

.forecast-day-icon {
  width: 24px;
  height: 24px;
  filter: var(--icon-filter, none);
}

.forecast-day-condition {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--text-secondary);
}

.forecast-day-temps {
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--text-primary);
  text-align: right;
}

.forecast-day-temps .low {
  color: var(--text-secondary);
}

/* ==================== FRESHNESS FOOTER ==================== */
.freshness {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-1) 0;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.freshness-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #6DB88A;
}

.freshness.stale .freshness-dot {
  background: #B8B6B3;
}

.freshness.old .freshness-dot {
  background: #C4654D;
}

.refresh-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--text-secondary);
  opacity: 0.7;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.refresh-btn:hover {
  opacity: 1;
}

/* ==================== BUTTONS ==================== */
.btn {
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  border: none;
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--glass-bg);
  color: var(--text-primary);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--text-primary);
  color: var(--gradient-from);
}

.btn-secondary {
  opacity: 0.7;
  font-size: 0.85rem;
}

.btn-primary:hover {
  opacity: 0.9;
}

/* ==================== MODALS ==================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-2);
}

.modal-content {
  max-width: 340px;
  width: 100%;
  text-align: center;
  background: linear-gradient(180deg, var(--gradient-from), var(--gradient-to));
  padding: var(--space-4);
  border-radius: 20px;
}

.modal-content h2 {
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  font-size: 1.3rem;
  font-weight: 600;
}

.modal-content p {
  margin-bottom: var(--space-3);
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.modal-content .btn {
  width: 100%;
  margin-bottom: 0.5rem;
}

.modal-content .btn:last-child {
  margin-bottom: 0;
}

/* Location hint text */
.location-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.7;
  margin: -0.25rem 0 0.75rem 0;
}

/* Location warning */
.location-warning {
  background: rgba(196, 101, 77, 0.15);
  color: #C4654D;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: var(--space-2);
}

/* ==================== INPUT ==================== */
.input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  font-family: var(--font-family);
  font-size: 1rem;
  margin-bottom: var(--space-2);
  background: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.input::placeholder {
  color: var(--text-secondary);
}

.input:focus {
  outline: none;
  border-color: var(--text-primary);
  background: rgba(255, 255, 255, 0.3);
}

/* ==================== COLOUR PICKER ==================== */
.colour-picker {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2000;
  background: rgba(20, 17, 21, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px 16px 0 0;
  padding: var(--space-3);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.colour-picker.visible {
  transform: translateY(0);
}

.colour-picker-header {
  display: flex;
  align-items: center;
  margin-bottom: var(--space-2);
}

.colour-picker-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #F0EDEA;
  opacity: 0.6;
  flex: 1;
}

.colour-picker-reset {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: #F0EDEA;
  font-family: var(--font-family);
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-right: var(--space-2);
}

.colour-picker-close {
  background: transparent;
  border: none;
  color: #F0EDEA;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.6;
}

.colour-picker-swatches {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.colour-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  position: relative;
}

.colour-swatch-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  cursor: pointer;
  transition: border-color 0.2s;
}

.colour-swatch-circle:hover {
  border-color: rgba(255,255,255,0.4);
}

.colour-swatch-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #F0EDEA;
  opacity: 0.5;
}

.colour-swatch input[type="color"] {
  position: absolute;
  width: 40px;
  height: 40px;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
}

/* ==================== RESPONSIVE ==================== */

/* Short phones (under 667px height) - tighter spacing */
@media (max-height: 667px) {
  .hero {
    padding-top: var(--space-1);
    padding-bottom: var(--space-1);
  }

  .hero-temp {
    font-size: 88px;
  }

  .hero-temp::before {
    width: 200px;
    height: 200px;
  }

  .bird-hero-icon {
    width: 88px;
    height: 88px;
  }
}

/* Very short phones (under 568px height) */
@media (max-height: 568px) {
  .hero {
    padding-top: 0;
    padding-bottom: 0;
  }

  .hero-temp {
    font-size: 64px;
  }

  .hero-temp::before {
    width: 160px;
    height: 160px;
  }

  .bird-hero-icon {
    width: 64px;
    height: 64px;
  }
}

/* Narrow phones */
@media (max-width: 380px) {
  #app {
    padding: var(--space-2);
  }

  .hero-temp {
    font-size: 72px;
  }
}
