/* ============================================================
   WEATHER DUCK — STARGAZING PAGE (Night-Sky Redesign)
   Unified styles for all astronomy tab components
============================================================ */

/* ------------------------------------------------------------
   NIGHT SKY DESIGN TOKENS
------------------------------------------------------------ */
:root {
  --sky-deep:    #0c1425;
  --sky-mid:     #131d35;
  --sky-surface: #1a2744;
  --sky-border:  rgba(100, 140, 200, 0.15);
  --sky-text:    #c8d6e5;
  --sky-text-bright: #e8eef5;
  --sky-accent:  #5b9bd5;
  --sky-accent-dim: rgba(91, 155, 213, 0.35);
  --sky-muted:   rgba(200, 214, 229, 0.5);
}

/* ============================================================
   DARK CARD — shared base for night-sky sections
============================================================ */
.sg-dark-card {
  background: var(--sky-deep);
  border: 1px solid var(--sky-border);
  border-radius: var(--wd-radius-md, 12px);
  padding: 20px;
  color: var(--sky-text);
  position: relative;
  overflow: hidden;
  font-family: var(--wd-font);
}

/* Subtle star field texture */
.sg-dark-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 15%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 65%, rgba(255,255,255,0.2) 0%, transparent 100%),
    radial-gradient(1px 1px at 55% 25%, rgba(255,255,255,0.25) 0%, transparent 100%),
    radial-gradient(1px 1px at 72% 80%, rgba(255,255,255,0.15) 0%, transparent 100%),
    radial-gradient(1px 1px at 88% 40%, rgba(255,255,255,0.2) 0%, transparent 100%),
    radial-gradient(1px 1px at 45% 90%, rgba(255,255,255,0.18) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 20% 50%, rgba(255,255,255,0.12) 0%, transparent 100%),
    radial-gradient(1px 1px at 65% 10%, rgba(255,255,255,0.22) 0%, transparent 100%),
    radial-gradient(1px 1px at 92% 70%, rgba(255,255,255,0.16) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

.sg-dark-card > * { position: relative; z-index: 1; }

/* Light card variant */
.sg-light-card {
  background: var(--wd-bg-card, #ffffff);
  border: 1px solid var(--wd-border, rgba(0,0,0,0.08));
  border-radius: var(--wd-radius-md, 12px);
  padding: 20px;
  font-family: var(--wd-font);
}

/* Section header */
.sg-section-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.sg-section-icon {
  font-size: 18px;
  line-height: 1;
}

.sg-section-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sg-dark-card .sg-section-title { color: var(--sky-text-bright); }

.sg-section-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(91, 155, 213, 0.15);
  color: var(--sky-accent);
}

/* ============================================================
   1. STARGAZING OUTLOOK — Cloud Cover Bars + Night Cycling
============================================================ */

/* Nav arrows */
.sg-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.sg-nav__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--sky-accent);
  min-width: 11em;
  text-align: center;
}

.sg-nav__arrow {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--sky-border);
  border-radius: 6px;
  background: var(--sky-surface);
  color: var(--sky-accent);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.sg-outlook--js .sg-nav__arrow {
  display: inline-flex;
}

.sg-nav__arrow:hover:not(:disabled) {
  background: rgba(91, 155, 213, 0.2);
  border-color: var(--sky-accent);
}

.sg-nav__arrow:disabled {
  opacity: 0.25;
  cursor: default;
}

/* Hide per-row day label when JS nav active */
.sg-outlook--js .sg-night-day { display: none; }

/* Night row layout */
.sg-night-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  align-items: start;
}

.sg-night-row[hidden] { display: none !important; }

/* Left info panel */
.sg-night-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sg-night-day {
  font-size: 14px;
  font-weight: 700;
  color: var(--sky-text-bright);
}

.sg-moon-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sg-moon-icon { font-size: 22px; }

.sg-moon-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--sky-text-bright);
}

.sg-moon-illum {
  font-size: 11px;
  color: var(--sky-muted);
  font-weight: 500;
}

.sg-time-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11.5px;
  color: var(--sky-muted);
}

.sg-time-row span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* Score ring */
.sg-score-wrap {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sg-score-ring {
  width: 48px;
  height: 48px;
  position: relative;
}

.sg-score-ring svg {
  width: 48px;
  height: 48px;
  transform: rotate(-90deg);
}

.sg-score-ring circle {
  fill: none;
  stroke-width: 4;
}

.sg-score-ring .ring-bg {
  stroke: var(--sky-surface);
}

.sg-score-ring .ring-fg {
  stroke: var(--sky-accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

.sg-score-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--sky-text-bright);
  font-family: var(--wd-mono, monospace);
}

.sg-score-caption {
  font-size: 11px;
  color: var(--sky-muted);
  line-height: 1.3;
}

.sg-score-caption strong {
  color: var(--sky-text-bright);
  font-weight: 600;
}

/* Cloud bars */
.sg-bars-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sg-cloud-avg {
  font-size: 12px;
  font-weight: 600;
  color: var(--sky-accent);
}

.sg-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
}

.sg-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.sg-bar-pct {
  font-size: 9px;
  font-weight: 600;
  color: var(--sky-muted);
  margin-bottom: 3px;
  font-family: var(--wd-mono, monospace);
  height: 13px;
  display: flex;
  align-items: flex-end;
}

.sg-bar {
  width: 100%;
  height: 80px;
  border-radius: 3px 3px 0 0;
  position: relative;
  overflow: hidden;
  background: var(--sky-surface);
}

.sg-bar-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, #6b7b8d, #8a9bae);
  border-radius: 3px 3px 0 0;
  transition: height 0.4s ease;
}

.sg-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30%;
  background: linear-gradient(to bottom, rgba(91,155,213,0.08), transparent);
  pointer-events: none;
}

.sg-bar-hour {
  margin-top: 4px;
  font-size: 10px;
  color: var(--sky-muted);
  font-family: var(--wd-mono, monospace);
  font-weight: 500;
}

/* ============================================================
   2. KP 3-DAY FORECAST
============================================================ */
.sg-kp-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sg-kp-chart {
  display: flex;
  gap: 4px;
  align-items: flex-end;
}

.sg-kp-yaxis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 120px;
  padding-bottom: 22px;
  flex-shrink: 0;
  width: 18px;
}

.sg-kp-yaxis span {
  font-size: 9px;
  font-family: var(--wd-mono, monospace);
  color: var(--sky-muted);
  text-align: right;
}

.sg-kp-bars {
  display: flex;
  gap: 2px;
  flex: 1;
  align-items: flex-end;
  position: relative;
}

.sg-kp-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.sg-kp-bar {
  width: 100%;
  max-width: 28px;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.4s ease;
  position: relative;
}

.sg-kp-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 50%;
  bottom: 0;
  background: linear-gradient(to right, rgba(255,255,255,0.12), transparent);
  border-radius: 3px 0 0 0;
}

.sg-kp-time {
  margin-top: 4px;
  font-size: 9px;
  font-family: var(--wd-mono, monospace);
  color: var(--sky-muted);
  writing-mode: vertical-lr;
  text-orientation: mixed;
  height: 18px;
  overflow: hidden;
}

.sg-kp-day-labels {
  display: flex;
  gap: 2px;
  margin-top: 2px;
  padding-left: 22px;
}

.sg-kp-day-label {
  flex: 1;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--sky-muted);
  padding-top: 6px;
  border-top: 1px solid var(--sky-border);
}

.sg-kp-legend {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.sg-kp-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--sky-muted);
}

.sg-kp-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ============================================================
   3. AURORA OVERVIEW
============================================================ */
.sg-aurora-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.sg-aurora-metric {
  background: var(--sky-surface);
  border-radius: 8px;
  padding: 12px;
}

.sg-aurora-metric--full {
  grid-column: 1 / -1;
}

.sg-metric-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sky-muted);
  margin-bottom: 4px;
}

.sg-metric-value {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--wd-mono, monospace);
  color: var(--sky-text-bright);
  line-height: 1;
}

.sg-metric-value .unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--sky-muted);
}

.sg-metric-sub {
  font-size: 11px;
  color: var(--sky-muted);
  margin-top: 2px;
}

.sg-aurora-bar {
  height: 6px;
  background: var(--sky-surface);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 8px;
  border: 1px solid var(--sky-border);
}

.sg-aurora-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #4caf50, #ffc107, #ff5722);
  transition: width 0.5s ease;
}

.sg-kp-blocks {
  display: flex;
  gap: 3px;
  margin-top: 8px;
}

.sg-kp-block {
  width: 12px;
  height: 6px;
  border-radius: 2px;
  background: rgba(100,140,200,0.15);
  transition: background 0.3s;
}

.sg-kp-block.active {
  background: #ffa726;
}

.sg-sw-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.sg-sw-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
}

.sg-sw-key {
  color: var(--sky-muted);
}

.sg-sw-val {
  font-weight: 600;
  font-family: var(--wd-mono, monospace);
  color: var(--sky-text-bright);
}

.sg-aurora-updated {
  text-align: center;
  margin-top: 10px;
  font-size: 11px;
  color: var(--sky-muted);
}

/* ============================================================
   4. AURORA MAP
============================================================ */
.sg-aurora-maps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.sg-map-panel {
  text-align: center;
}

.sg-map-panel img {
  width: 100%;
  border-radius: 8px;
  display: block;
}

.sg-map-panel canvas {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  display: block;
  background: #000;
}

.sg-map-label {
  font-size: 11px;
  color: var(--sky-muted);
  margin-top: 6px;
}

.sg-map-footer {
  text-align: center;
  font-size: 11px;
  color: var(--sky-muted);
  margin-top: 10px;
  line-height: 1.4;
}

/* ============================================================
   5. LIGHT POLLUTION MAP
============================================================ */
.sg-lp-embed iframe {
  width: 100%;
  height: 380px;
  border: none;
  border-radius: 8px;
  display: block;
}

/* ============================================================
   6. STAR MAP
============================================================ */
.sg-starmap-wrap {
  width: 100%;
  min-height: 300px;
  border-radius: 8px;
  overflow: hidden;
}

/* ============================================================
   LOADING STATE
============================================================ */
.sg-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--sky-muted);
  font-size: 12px;
}

@keyframes sg-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.sg-loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sky-accent);
  animation: sg-pulse 1.2s ease-in-out infinite;
}

.sg-loading-dot:nth-child(2) { animation-delay: 0.2s; }
.sg-loading-dot:nth-child(3) { animation-delay: 0.4s; }

/* ============================================================
   SOURCE FOOTER
============================================================ */
.sg-source {
  font-size: 11px;
  color: var(--sky-muted);
  text-align: center;
  margin-top: 6px;
}

.sg-source a {
  color: var(--sky-accent);
  text-decoration: none;
}

.sg-source a:hover { text-decoration: underline; }

/* ============================================================
   MOBILE
============================================================ */
@media (max-width: 680px) {
  .sg-night-row {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .sg-night-row[hidden] { display: none !important; }

  .sg-aurora-grid {
    grid-template-columns: 1fr;
  }

  .sg-aurora-maps {
    grid-template-columns: 1fr;
  }

  .sg-bar { height: 56px; }

  .sg-kp-time { font-size: 8px; }

  .sg-metric-value { font-size: 22px; }
}
