/* Space weather (views/space-weather.js), and the line charts (chart.js) it draws, which the
   profile's height chart uses too. */

/* ---- Charts (chart.js) ------------------------------------------------------------------------ */
/* Drawn at the size shown, so 12 px here is 12 px on screen, at any width. */
.chart { position: relative; margin: 0; }
.chart-plot { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font-text); }
.chart svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: var(--radius-xs); }
.chart .axis text { fill: var(--muted); font-size: var(--step--2); font-variant-numeric: tabular-nums; }
.chart .end-labels text { fill: var(--ink-2); font-weight: 650; }
.chart .grid line { stroke: var(--hairline); }
/* The axis and its ticks say where the scale is, so they meet 3:1 (WCAG 1.4.11); the gridlines
   behind the lines are only a guide, and stay faint. */
.chart .baseline, .chart .tick { stroke: var(--field-border); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.dashed { stroke-dasharray: 6 4; }
.chart circle.end { stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }
.chart .marker { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .marker-label { fill: var(--ink-2); font-size: var(--step--2); font-weight: 650; }
/* A shaded part of the scale (storm levels): a tint and a dashed edge, named in words. */
.chart .band { fill: color-mix(in srgb, var(--serious) 9%, transparent); }
.chart .band-edge { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 4 3; opacity: 0.7; }
.chart .band-label { fill: var(--ink-2); font-size: var(--step--2); font-weight: 600; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); font-size: var(--step--1); color: var(--ink-2); margin-bottom: var(--space-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: var(--space-2); }
.chart-legend i { width: 18px; height: 2px; border-radius: 1px; display: inline-block; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 3; background: var(--raised); border: 1px solid var(--hairline); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2); padding: var(--space-2) var(--space-3); font-size: var(--step--1); white-space: nowrap;
}
.chart-tip-time { color: var(--ink-2); font-size: var(--step--2); font-weight: 600; margin-bottom: 2px; }
.chart-tip b { font-variant-numeric: tabular-nums; }
.chart-tip .row { display: flex; align-items: center; gap: var(--space-2); }
.chart-tip i { width: 12px; height: 2px; display: inline-block; }
.chart-legend i.dash, .chart-tip i.dash { height: 0; background: none; border-top: 2px dashed currentColor; }
.chart figcaption { max-width: var(--measure); font-size: var(--step--1); line-height: 1.45; color: var(--ink-2); margin-top: var(--space-3); }
details.table-view { margin-top: var(--space-3); font-size: var(--step--1); }
details.table-view .table-wrap { max-height: 280px; overflow-y: auto; }

/* ---- The page --------------------------------------------------------------------------------- */
.sw-body > * + * { margin-top: var(--space-6); }
.sw-body > .card + .card { margin-top: var(--space-6); }

/* The answer: the level now, its figure, the scale and the words. */
.card.answer > h2.sw-eyebrow, .sw-now .sw-eyebrow { margin: 0 0 var(--space-2); font: 700 var(--step--2)/1.3 var(--font-text); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.sw-headline { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-2) var(--space-6); }
.sw-level {
  display: flex; align-items: center; gap: var(--space-3); margin: 0;
  font-family: var(--font-display); font-size: clamp(var(--step-4), 1.4rem + 2vw, 3.25rem); font-weight: 600; line-height: var(--leading-tight);
}
/* The level's mark differs in shape as well as colour, beside the words. */
.sw-mark { flex: none; width: 0.42em; height: 0.42em; border-radius: 50%; background: var(--good); }
.sw-level.unsettled .sw-mark, .sw-level.active .sw-mark { background: var(--warning); border-radius: 3px; transform: rotate(45deg) scale(0.86); }
.sw-level.storm .sw-mark { background: var(--critical); border-radius: 2px; }
.sw-level.unknown .sw-mark { background: transparent; border: 3px dashed var(--muted); }
.sw-figure { display: grid; grid-template-columns: auto auto; align-items: baseline; column-gap: var(--space-2); margin: 0; color: var(--ink-2); white-space: nowrap; }
.sw-figure-label { grid-column: 1 / -1; font-size: var(--step--2); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.sw-figure-value { font: 600 var(--step-4)/1 var(--font-display); color: var(--ink); }
.sw-figure-unit { font-size: var(--step--1); font-weight: 650; }
.sw-reading { margin: var(--space-3) 0 0; font-size: var(--step--1); }
.sw-answer { margin: var(--space-4) 0 0; font-size: var(--step-1); line-height: 1.5; color: var(--ink); }
.sw-fold { margin-top: var(--space-4); }
.sw-terms { max-width: var(--measure); }
.sw-term { margin: 0 0 var(--space-2); font-size: var(--step--1); color: var(--ink-2); max-width: var(--measure); }
.sw-terms .sw-term { margin: 0; }
.sw-term dfn { font-style: normal; font-weight: 700; color: var(--ink); }

/* The meter: ten cells in four labelled parts, the part now drawn strong, a pointer at the value.
   Each part is tinted; the label of the part now is bold and underlined, so colour is never alone. */
.kp-meter {
  --kp-cell-gap: 3px;
  position: relative; display: grid; gap: 6px; max-width: 760px; margin: var(--space-8) 0 0; padding-top: 4px;
  container-type: inline-size;
}
.kp-track, .kp-numbers, .kp-groups { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); column-gap: var(--kp-cell-gap); }
.kp-cell { height: 14px; border-radius: 3px; background: color-mix(in srgb, var(--kp-tone) 28%, var(--surface-2)); }
.kp-cell:first-child { border-radius: 7px 3px 3px 7px; }
.kp-cell:last-child { border-radius: 3px 7px 7px 3px; }
.kp-cell.here { background: var(--kp-tone); }
.kp-cell.quiet, .kp-group.quiet { --kp-tone: var(--good); }
.kp-cell.unsettled, .kp-cell.active, .kp-group.unsettled, .kp-group.active { --kp-tone: var(--warning); }
.kp-cell.storm, .kp-group.storm { --kp-tone: var(--serious); }
.kp-numbers span { text-align: center; font-size: var(--step--2); font-variant-numeric: tabular-nums; color: var(--muted); }
.kp-groups { margin-top: 2px; }
.kp-group {
  display: block; padding-top: 6px; border-top: 2px solid color-mix(in srgb, var(--kp-tone) 55%, var(--hairline));
  font-size: var(--step--1); line-height: 1.3; color: var(--ink-2); text-align: center; min-width: 0;
}
.kp-group.here { color: var(--ink); font-weight: 700; border-top-color: var(--ink); }
.kp-group.here .kp-group-name { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.25em; }
.kp-group-range { display: none; }
.kp-group-g { font-weight: 400; color: var(--ink-2); }
/* The pointer: a short ink bar with the value above, standing on the track. */
.kp-pointer {
  position: absolute; top: -22px; z-index: 1; width: 0; height: calc(22px + 14px + 6px);
  transform: translateX(-50%); pointer-events: none;
}
.kp-pointer::after {
  content: ""; position: absolute; left: -2px; top: 18px; bottom: 0; width: 4px; border-radius: 2px;
  background: var(--ink); box-shadow: 0 0 0 2px var(--raised);
}
.kp-pointer-value {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%);
  font: 700 var(--step--1)/1 var(--font-text); font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap;
}
/* Narrow: the part names would not fit under one cell, so they become a key with their ranges. */
@container (max-width: 520px) {
  .kp-groups { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); }
  .kp-group { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; text-align: left; }
  .kp-group::before { content: ""; width: 10px; height: 10px; border-radius: 2px; background: var(--kp-tone); flex: none; }
  .kp-group-range { display: inline; font-weight: 400; color: var(--ink-2); }
  .kp-group-g { display: none; }
}

/* NOAA's forecast: a line, then the three days as small tiles, then the chart. */
.sw-forecast-line { font-size: var(--step-0); max-width: var(--measure); margin-bottom: var(--space-4); }
.sw-days-heading { margin: 0 0 var(--space-2); font: 650 var(--step--1)/1.3 var(--font-text); color: var(--ink-2); }
.sw-days { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); margin: 0 0 var(--space-6); padding: 0; list-style: none; max-width: 720px; }
.sw-day { display: grid; gap: 2px; padding: var(--space-3) var(--space-4); border: 1px solid var(--hairline); border-radius: var(--radius-sm); background: var(--surface-2); }
.sw-day-name { font-size: var(--step--1); font-weight: 650; color: var(--ink-2); }
.sw-day-level { display: inline-flex; align-items: center; gap: var(--space-2); font: 600 var(--step-1)/1.25 var(--font-display); }
.sw-day.storm { background: var(--surface); border-color: var(--border); }
/* A storm level's mark: a ring for none, a diamond for G1 and G2, a square from G3. */
.g-mark { flex: none; display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--muted); }
.g-mark.low { border: 0; border-radius: 2px; background: var(--warning); transform: rotate(45deg); }
.g-mark.high { border: 0; border-radius: 1px; background: var(--critical); }
.sw-chart { padding-top: var(--space-5); border-top: 1px solid var(--hairline); }
.sw-chart-heading { margin: 0 0 var(--space-1); font-size: var(--step-0); }
.sw-chart-note { font-size: var(--step--1); margin-bottom: var(--space-4); }

/* What this means for…: four short entries, two by two where there is room. */
.sw-for-intro { font-size: var(--step--1); margin: 0 0 var(--space-3); }
.sw-for-caveat { margin: 0 0 var(--space-5); padding: var(--space-3) var(--space-4); border-left: 3px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-size: var(--step--1); color: var(--ink); }
/* NOAA's words, quoted: the marks come from here alone, never typed into the text. */
.sw-for q { quotes: "\201C" "\201D" "\2018" "\2019"; }
.sw-for-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 28rem), 1fr)); gap: var(--space-5) var(--space-8); }
.sw-for-entry { min-width: 0; padding-top: var(--space-4); border-top: 1px solid var(--hairline); }
.sw-for-entry h3 { margin: 0; font: 600 var(--step-1)/1.25 var(--font-display); }
.sw-for-entry p { margin: var(--space-2) 0 0; }
.sw-for-who { font-size: var(--step--1); }
.sw-for-now { font-size: var(--step-0); color: var(--ink); }
.sw-for-forecast, .sw-for-gloss, .sw-for-why { font-size: var(--step--1); }
.sw-for-more { margin-top: var(--space-3); font-size: var(--step--1); }
.sw-guide, .sw-for-entry .sw-for-guide { margin: var(--space-3) 0 0; font-size: var(--step--1); color: var(--ink-2); }
.sw-guide a, .sw-for-guide a { display: inline-block; padding: 3px 0; }
.sw-for-note { margin: var(--space-6) 0 0; }
.sw-scales .sw-scale-value { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 650; color: var(--ink); }

/* NOAA's notices: one card each. */
.sw-notices .section-head { margin-bottom: var(--space-1); }
.sw-notices-intro { font-size: var(--step--1); margin-bottom: var(--space-4); }
.sw-alerts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: var(--space-4); margin: 0; padding: 0; list-style: none; }
.sw-alerts > .card + .card { margin-top: 0; }
.sw-alert { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-5); }
.sw-alert h3 { font-size: var(--step-0); line-height: 1.35; }
.sw-alert p { margin: 0; }
.sw-alert-kind { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.sw-alert-g { font-size: var(--step--2); font-weight: 650; color: var(--ink-2); }
.chip.sw-kind { font-weight: 700; letter-spacing: 0.02em; }
.sw-alert[data-kind="warning"] .chip.sw-kind, .sw-alert[data-kind="alert"] .chip.sw-kind { border-color: var(--field-border); color: var(--ink); }
.sw-gloss { font-size: var(--step-0); }
.sw-issued { font-size: var(--step--1); }
.sw-message { margin-top: auto; font-size: var(--step--1); }
.sw-message pre {
  max-height: 320px; overflow-y: auto; margin: 0; padding: var(--space-3); border-radius: var(--radius-sm); background: var(--surface-2);
  white-space: pre-wrap; overflow-wrap: anywhere; font: var(--step--2)/1.5 var(--font-mono);
}
.sw-flux .sw-term { margin-bottom: var(--space-4); }
.sw-note { margin: var(--space-6) 0 0; }

@media (max-width: 640px) {
  .sw-figure-value { font-size: var(--step-3); }
  .kp-meter { margin-top: var(--space-8); }
  .sw-answer { font-size: var(--step-0); }
  .sw-days { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: var(--space-2); }
  .sw-day { padding: var(--space-2) var(--space-3); }
  .sw-day-level { font-size: var(--step-0); }
}
