/* Ongoing Storm Analysis page -- supplements styles.css (shared shell/hero/
   system-list rules) with the parts unique to this page: the stats/chart
   pane and the track-history dots/line themselves. */

.history-pane {
  flex: 1; position: relative; overflow: hidden; overflow-y: auto;
  margin: 14px 14px 14px 0; border-radius: 14px; border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.history-empty-state {
  height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 14px; text-align: center; padding: 20px;
}
.history-empty-state[hidden] { display: none; }

.history-detail[hidden] { display: none; }
.history-detail { display: flex; flex-direction: column; height: 100%; }

.history-stats {
  display: flex; flex-wrap: wrap; gap: 1px; background: var(--border);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.history-stat {
  flex: 1 1 120px; background: #0d1b30; padding: 12px 16px;
}
.history-stat__label {
  display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); margin-bottom: 3px;
}
.history-stat__value { font-size: 17px; font-weight: 700; }

/* On desktop, .history-chart-surface is position:absolute;inset:0 --
   this wrap's only job is to hold it (a no-op for the flex column
   below, since an absolutely-positioned child ignores flex layout
   entirely). Below the 860px breakpoint (see .storm-panel below for
   why that's a different number than this page's other 760px
   breakpoint), .storm-panel becomes a normal-flow child here too, and
   the column layout is what stacks it above the surface. */
.history-chart-wrap { flex: 1; position: relative; min-height: 300px; display: flex; flex-direction: column; gap: 12px; }
.history-chart-surface { position: absolute; inset: 0; background: var(--water); }
#history-chart { width: 100%; height: 100%; display: block; user-select: none; }

.storm-panel {
  position: absolute; top: 12px; left: 12px; z-index: 6; width: 226px;
  border-radius: 12px; overflow: hidden; background: rgba(10, 22, 40, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.16); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}
.storm-panel[hidden] { display: none; }

.storm-panel__header { padding: 10px 14px 12px; }
.storm-panel__kind {
  display: block; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
}
.storm-panel__name { display: block; font-size: 20px; font-weight: 800; line-height: 1.15; margin-top: 1px; }

.storm-panel__hero { display: flex; border-top: 1px solid rgba(255, 255, 255, 0.1); border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.storm-panel__hero-stat { flex: 1; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.storm-panel__hero-stat + .storm-panel__hero-stat { border-left: 1px solid rgba(255, 255, 255, 0.1); }
.storm-panel__hero-value { font-size: 23px; font-weight: 800; color: var(--text); line-height: 1.1; }
.storm-panel__hero-label {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
}

.storm-panel__row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); font-size: 11.5px; }
.storm-panel__row:last-child { border-bottom: none; }
.storm-panel__row-label { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); white-space: nowrap; }
.storm-panel__row-value { font-weight: 700; color: var(--text); text-align: right; }

.point-popup {
  position: absolute; z-index: 7; width: 190px;
  background: rgba(10, 22, 40, 0.95); border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4); padding: 10px 12px;
}
.point-popup[hidden] { display: none; }
.point-popup__time { font-weight: 700; font-size: 12px; color: var(--text); margin-bottom: 4px; padding-right: 16px; }
.point-popup__close {
  position: absolute; top: 4px; right: 6px; background: none; border: none;
  color: var(--text-muted); font-size: 17px; line-height: 1; cursor: pointer; padding: 3px 5px;
}
.point-popup__close:hover { color: var(--text); }
.point-popup .storm-panel__row { padding: 5px 0; }

.history-chart-tabs {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  display: flex; gap: 3px; background: rgba(10, 22, 40, 0.82);
  border: 1px solid var(--border); border-radius: 10px; padding: 4px;
}
.history-chart-tab {
  font: inherit; font-size: 12px; font-weight: 600; color: var(--text-muted);
  background: none; border: none; border-radius: 7px; padding: 6px 12px;
  cursor: pointer; transition: background .15s, color .15s;
}
.history-chart-tab:hover { background: var(--panel-hover); color: var(--text); }
.history-chart-tab.is-active { background: var(--accent); color: var(--bg-deep); }

/* windHistoryRenderer.js builds each of these as many small, densely
   interpolated rings along the track (not one shape per recorded point)
   -- fully opaque and identically colored, so the overlapping rings
   read as one seamless solid swath, matching the real NHC wind-swath
   product this is modeled on, rather than a translucent stack. */
.wind-history-envelope-gale, .wind-history-envelope-hfw { pointer-events: none; }
.wind-history-envelope-gale { fill: #f0bc4a; }
.wind-history-envelope-hfw { fill: #d64545; }

/* Track History and Wind History are mutually-exclusive full-chart views,
   toggled by the tabs above; both layers are always kept rendered
   current, only visibility switches, via .is-wind-view on the svg. */
#history-chart:not(.is-wind-view) #wind-history-layer { display: none; }
#history-chart.is-wind-view #track-history-layer { display: none; }
/* The category legend only labels Track History's colored dots -- hide it
   in Wind History, where nothing on screen refers to it. */
#history-chart.is-wind-view ~ .history-legend { display: none; }

.history-legend {
  position: absolute; top: 50%; right: 14px; z-index: 5; transform: translateY(-50%);
  display: flex; flex-direction: column; width: 30px; border-radius: 9px;
  overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.history-scale__seg {
  height: 27px; display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.28);
}
.history-scale__seg:last-child { border-bottom: none; }
.history-scale__label {
  font-size: 11px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.track-history-line {
  fill: none; stroke: #111820; stroke-width: 3.2px; stroke-linecap: round; vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.55));
}
.track-history-dot {
  stroke: #0a1628; stroke-width: 2.2px; vector-effect: non-scaling-stroke;
  transform-box: fill-box; transform-origin: center; cursor: pointer;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}
.track-history-dot--current { stroke: #fff; stroke-width: 3px; }

@keyframes history-dot-pop {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes history-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .track-history-dot, .wind-history-envelope-gale, .wind-history-envelope-hfw { animation: none !important; }
}

.history-list-badge {
  font-size: 10.5px; color: var(--text-muted); white-space: nowrap;
}

@media (max-width: 760px) {
  .history-pane { margin: 14px; }
}

/* Deliberately NOT 760px, the breakpoint everywhere else on this page
   uses -- .storm-panel (226px) and .history-chart-tabs (~225px) are
   both pinned to the same top corner strip, and the two only stop
   touching once the chart area has roughly 495px to give them both
   room; with the sidebar (330px) beside the content, that only holds
   true above ~840px of viewport width, not 760px. 761-840px is real
   "desktop-mode but narrow" territory (e.g. a laptop split-screen)
   where the general breakpoint alone would still leave them
   overlapping. Rounded up to 860 for margin against the tabs' own
   measured-width uncertainty -- don't merge this into the 760px rule
   above, the two breakpoints are solving different problems. */
@media (max-width: 860px) {
  /* flex-shrink:0 is required, not decorative -- .history-chart-wrap's
     column flex otherwise has nothing stopping a short viewport from
     squeezing the panel's height toward zero (surface's min-height:300px
     is a floor that protects IT, not the panel, so all the shrink
     pressure would land here instead), collapsing it to a sliver that
     .storm-panel's own overflow:hidden then clips to invisible. */
  .storm-panel { position: static; width: auto; margin: 0 12px; flex-shrink: 0; }
  /* .history-chart-tabs was the other absolutely-positioned layer pinned
     to this same top corner strip as .storm-panel (see the comment above
     this block) -- completes the same fix by dropping it into normal
     flow too, directly below the now-stacked panel, instead of leaving it
     floating over a surface that's much narrower here than on desktop.
     Stays a child of .history-chart-surface (point-popup's own
     positioning math keys off that element's rect, so nothing here is
     safe to move out of it in the DOM) -- a flex column on the surface
     itself achieves the same "tabs above, chart fills the rest" result
     purely in CSS, no restructuring needed. .history-legend and
     .point-popup are untouched (still position:absolute) -- confirmed via
     live testing that the legend's existing small, narrow-column
     treatment already reads fine at phone width once the tabs/panel
     collision above it is resolved -- see this change's own verification
     pass for the live-width check that confirmed this. */
  .history-chart-surface {
    position: relative; display: flex; flex-direction: column;
    flex: 1; min-height: 300px;
  }
  #history-chart { order: 2; flex: 1; width: 100%; height: auto; }
  .history-chart-tabs {
    order: 1; position: static; align-self: stretch;
    margin: 0 0 10px; display: flex;
  }
  .history-chart-tab { flex: 1; text-align: center; padding: 10px 12px; }
}

/* Small-phone tightening -- same 480px tier as styles.css's own pass,
   covering this page's own stat-heavy panel (flagged during the mobile
   audit as a plausible tight fit at 23px hero numbers, not confirmed
   until this pass's live check). */
@media (max-width: 480px) {
  .storm-panel__name { font-size: 17px; }
  .storm-panel__hero-value { font-size: 19px; }
  .storm-panel__hero-stat { padding: 8px 10px; }
  .history-stat { padding: 10px 12px; }
  .history-stat__value { font-size: 15px; }
}
