/* POC v3 — dark, high-contrast; scope colors redundant with text labels */

:root {
  --bg: #070a0f;
  --surface: #101620;
  --surface2: #151c2e;
  --text: #e8ecf4;
  --muted: #8b95a8;
  --border: #252d3f;
  --focus: #7dd3fc;
  --scope-green: #34d399;
  --scope-yellow: #fbbf24;
  --scope-red: #f87171;
  --bar-track: #1e2838;
  --font-display: "Syne", system-ui, sans-serif;
  --font-body: "Source Sans 3", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 999;
  padding: 0.5rem 1rem;
  background: var(--surface);
  color: var(--text);
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

.wrap {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}

header.page-head {
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
}

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem;
}

.sub {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Headline */
.headline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.headline-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem 1rem;
}

.scope-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.55rem;
  border-radius: 0.35rem;
  border: 1px solid var(--border);
}

.scope-badge--GREEN {
  color: var(--scope-green);
  border-color: color-mix(in srgb, var(--scope-green) 45%, var(--border));
}

.scope-badge--YELLOW {
  color: var(--scope-yellow);
  border-color: color-mix(in srgb, var(--scope-yellow) 45%, var(--border));
}

.scope-badge--RED {
  color: var(--scope-red);
  border-color: color-mix(in srgb, var(--scope-red) 45%, var(--border));
}

.headline-msg {
  margin: 0;
  flex: 1;
  min-width: min(100%, 16rem);
  font-size: 1.05rem;
}

.headline-detail {
  margin: 0.75rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Place */
.place-line {
  margin: 0 0 1.5rem;
  font-size: 1rem;
  color: var(--muted);
}

.place-line strong {
  color: var(--text);
  font-weight: 600;
}

.place-line .place-emoji {
  margin-left: 0.25em;
  white-space: nowrap;
  font-style: normal;
}

.rain-summary {
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.35;
}

.rain-strip-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.rain-strip-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.25rem;
  margin: 0 -0.25rem;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

.rain-strip {
  display: grid;
  grid-template-columns: repeat(var(--strip-cols, 24), minmax(2.25rem, 1fr));
  gap: 0.2rem;
  min-width: min(100%, calc(var(--strip-cols, 24) * 2.35rem));
}

.rain-strip-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-height: 2.75rem;
  padding: 0.35rem 0.15rem 0.3rem;
  border-radius: 0.35rem;
  border: 1px solid var(--border);
  background: var(--surface2);
  background: color-mix(in srgb, #38bdf8 calc(var(--pop, 0) * 1%), var(--surface2));
  font-size: 0.7rem;
  line-height: 1.15;
  text-align: center;
}

.rain-strip-hour {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.rain-strip-pct {
  margin-top: 0.2rem;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Chart */
/* Section titles use body font: Syne’s webfont metrics can clip descenders in WebKit at this size. */
.chart-section h2,
.satellite-section h2,
.seven-section h2 {
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
  line-height: 1.35;
  overflow: visible;
}

.satellite-section {
  margin-top: 2rem;
  overflow: visible;
}

.satellite-meta {
  margin-bottom: 0.65rem;
}

.satellite-block {
  max-width: min(100%, 36rem);
  margin-inline: 0 auto;
}

.satellite-frame {
  display: block;
  position: relative;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--surface2);
  width: 100%;
  aspect-ratio: 625 / 375;
  min-height: 0;
  touch-action: none;
  cursor: grab;
}

.satellite-frame:active {
  cursor: grabbing;
}

.satellite-frame:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.satellite-pan {
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  will-change: transform;
}

.satellite-geo {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
}

.satellite-frame--error {
  aspect-ratio: auto;
  height: auto;
  min-height: 4rem;
  cursor: default;
}

.satellite-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  user-select: none;
  -webkit-user-drag: none;
}

.satellite-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.satellite-btn {
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  min-width: 2.25rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
}

.satellite-btn--text {
  min-width: unset;
  font-size: 0.85rem;
  font-weight: 600;
}

.satellite-btn:hover {
  border-color: color-mix(in srgb, var(--focus) 45%, var(--border));
}

.satellite-source-link {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--focus);
  text-decoration: none;
}

.satellite-source-link:hover {
  text-decoration: underline;
}

.satellite-block--error .satellite-controls {
  display: none;
}

.satellite-note {
  margin: 0.65rem 0 0;
  padding: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.35;
}

.seven-section {
  margin-top: 2rem;
  overflow: visible;
}

.chart-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.chart-range-note {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.45rem;
  line-height: 1.35;
}

.chart-hours-toggle-wrap {
  margin: 0 0 0.5rem;
}

.chart-hours-toggle {
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
}

.chart-hours-toggle:hover {
  border-color: color-mix(in srgb, var(--focus) 50%, var(--border));
  color: var(--focus);
}

.chart-hours-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.chart-scroll-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.45rem;
  line-height: 1.3;
}

/* Shrink-wrap to grid when chart is narrower than the page (e.g. collapsed nights); cap at 100% when wide. */
.chart-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  width: max-content;
  max-width: 100%;
}

/* Fixed column width × hour count = intrinsic width; scroll horizontally (no squashing into empty space). */
.chart-grid {
  --label-width: 3.95rem;
  /* Snug to 24h digits + bars; scroll for full range */
  --hour-col-min: 1.22rem;
  display: grid;
  grid-template-columns: var(--label-width) repeat(var(--hour-count, 72), var(--hour-col-min));
  width: max-content;
  max-width: none;
}

@media (max-width: 380px) {
  .chart-grid {
    --label-width: 3.65rem;
    --hour-col-min: 1.1rem;
  }
}

.chart-grid .chart-cell[title] {
  cursor: help;
}

.chart-row {
  display: contents;
}

.chart-label {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 0.12rem 0.22rem;
  font-size: 0.65rem;
  color: var(--muted);
  text-align: right;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.chart-cell {
  border-bottom: 1px solid var(--border);
  min-height: 1.2rem;
  padding: 0;
  font-size: 0.62rem;
  background: var(--surface);
}

.chart-row--time .chart-cell {
  background: var(--surface2);
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 0.1rem 0.02rem;
}

.time-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  min-height: 1.62rem;
  white-space: nowrap;
}

.time-day {
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.05;
  letter-spacing: 0.02em;
}

.time-day--spacer {
  display: block;
  min-height: 0.55rem;
  line-height: 0.55rem;
}

.time-hour {
  font-size: 0.58rem;
  color: var(--text);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.chart-cell--col-start {
  border-left: 1px solid color-mix(in srgb, var(--focus) 35%, var(--border));
}

/* Placeholder column when daytime hours are collapsed (see buildChartColumns). */
.chart-cell--daygap {
  background: color-mix(in srgb, #fbbf24 12%, var(--surface));
  border-left: 1px dashed color-mix(in srgb, #fbbf24 45%, var(--border));
  border-right: 1px dashed color-mix(in srgb, #fbbf24 45%, var(--border));
}

.chart-row--time .chart-cell--daygap {
  background: color-mix(in srgb, #fbbf24 16%, var(--surface2));
}

.daygap-sun {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  line-height: 1;
  min-height: 1.4rem;
}

.chart-cell--scope.chart-cell--daygap,
.chart-cell.bar-cell.chart-cell--daygap {
  background: color-mix(in srgb, #fbbf24 10%, var(--surface));
}

.chart-row--time .chart-label {
  background: var(--surface2);
}

.chart-cell--day {
  background: color-mix(in srgb, var(--surface) 70%, #1a2235);
}

.chart-cell--scope {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.48rem;
  line-height: 1;
}

.scope-cell--GREEN {
  color: var(--scope-green);
}

.scope-cell--YELLOW {
  color: var(--scope-yellow);
}

.scope-cell--RED {
  color: var(--scope-red);
}

.scope-cell--blank {
  color: var(--border);
}

.bar-cell {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.bar {
  width: 0.5rem;
  max-width: 100%;
  min-height: 2px;
  border-radius: 1px;
  background: linear-gradient(
    to top,
    color-mix(in srgb, var(--bar-fill, #94a3b8) 90%, transparent),
    var(--bar-fill, #94a3b8)
  );
}

.bar--empty {
  opacity: 0.15;
  background: var(--muted);
}

/* Seven-day */
.seven-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.65rem;
}

.day-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.65rem 0.75rem;
}

.day-card time {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.day-scope {
  font-size: 1.25rem;
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.day-rain {
  font-size: 0.85rem;
  color: var(--muted);
}

.day-rain strong {
  color: var(--text);
  font-weight: 600;
}

/* States */
.status-panel {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
}

.status-panel--error {
  color: var(--scope-red);
}

.skeleton {
  animation: pulse 1.2s ease-in-out infinite;
  background: var(--surface2);
  border-radius: 0.35rem;
  min-height: 4rem;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 0.9;
  }
}

footer.meta-foot {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
}

footer.meta-foot kbd {
  font-family: ui-monospace, monospace;
  font-size: 0.78em;
  background: var(--surface2);
  padding: 0.1em 0.35em;
  border-radius: 0.25rem;
}

.hidden {
  display: none !important;
}
