/* HSAF notifications: cold paper, polar ink, one glacier accent. */

:root {
  color-scheme: light;
  --snowfield: #f2f6f8;
  --surface: #ffffff;
  --ink: #15283a;
  --ink-soft: #4b5f70;
  --rime: #d3dee5;
  --glacier: #2d6e96;
  --glacier-strong: #1f5476;
  --thaw: #b7791f;
  --alert: #b4442e;
  --ok: #3f8f6b;

  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-display: "IBM Plex Sans Condensed", "Arial Narrow", "IBM Plex Sans", sans-serif;
  --gutter: clamp(1rem, 4vw, 3rem);
  --measure: 1320px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --snowfield: #0f1d2a;
    --surface: #152636;
    --ink: #e4ecf1;
    --ink-soft: #9db0bf;
    --rime: #2a3e50;
    --glacier: #6fb1d9;
    --glacier-strong: #9ccbe8;
    --thaw: #e0a84a;
    --alert: #e58370;
    --ok: #6cc59b;
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--snowfield);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--glacier);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1rem var(--gutter);
  border-bottom: 1px solid var(--rime);
}

.wordmark {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-width: 0;
}

.topbar-end form {
  margin: 0;
}

.sync {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.875rem;
  white-space: nowrap;
}

.sync::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--ok);
}

.sync[data-tone="stale"]::before {
  background: var(--thaw);
}

.sync[data-tone="alert"] {
  color: var(--alert);
}

.sync[data-tone="alert"]::before {
  background: var(--alert);
}

.text-button {
  padding: 0.25rem 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--rime);
  text-underline-offset: 0.25em;
}

.text-button:hover {
  color: var(--ink);
  text-decoration-color: currentColor;
}

/* ---------- masthead ---------- */

.page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter) 4rem;
}

.masthead {
  padding: clamp(1.75rem, 4vw, 3rem) 0 1.5rem;
}

.masthead-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem 2rem;
}

.when-context {
  margin: 0 0 0.25rem;
  color: var(--ink-soft);
  font-size: 1rem;
}

.when-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 1.4rem + 4vw, 4.5rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums lining-nums;
}

.sets {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.5rem;
}

.set {
  position: relative;
  padding: 0.5rem 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}

.set::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: transparent;
}

.set:hover {
  color: var(--ink);
}

.set[aria-selected="true"] {
  color: var(--ink);
  font-weight: 600;
}

.set[aria-selected="true"]::after {
  background: var(--glacier);
}

/* ---------- availability timeline ---------- */

.timeline {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  margin-top: clamp(1.5rem, 3vw, 2.25rem);
}

.timeline-strip {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(var(--cells, 60), minmax(0, 1fr));
  column-gap: 2px;
  padding-bottom: 1.5rem;
}

.tick-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 3.5rem;
}

.tick {
  display: block;
  width: 100%;
  height: 0.5rem;
  padding: 0;
  border: 0;
  border-radius: 1px;
  background: var(--rime);
  cursor: pointer;
  transition: height 120ms ease-out, background-color 120ms ease-out;
}

.tick.has-report {
  height: 1.75rem;
  background: var(--glacier);
  opacity: 0.55;
}

.tick:hover {
  height: 2.5rem;
  opacity: 1;
}

.tick.is-selected {
  height: 3.5rem;
  background: var(--ink);
  opacity: 1;
}

.tick.is-selected:not(.has-report) {
  background: var(--thaw);
}

/* A clear hit area for touch without widening the bars. */
.tick::before {
  content: "";
  position: absolute;
  inset: 0;
}

.tick-label {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.25rem;
  padding: 0.125rem 0 0 0.25rem;
  border-left: 1px solid var(--rime);
  color: var(--ink-soft);
  font-size: 0.8125rem;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
}

.timeline-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-top: 1rem;
}

.step {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--rime);
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
}

.step svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.step:hover:not(:disabled) {
  border-color: var(--glacier);
  color: var(--glacier-strong);
}

.step:disabled {
  opacity: 0.35;
  cursor: default;
}

.jump input,
.jump select {
  height: 2.5rem;
  padding: 0 0.75rem;
  border: 1px solid var(--rime);
  border-radius: 6px;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
}

.jump input:hover,
.jump select:hover {
  border-color: var(--glacier);
}

.legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.8125rem;
}

.legend-key {
  display: inline-block;
  width: 0.375rem;
  border-radius: 1px;
}

.legend-key.has-report {
  height: 0.875rem;
  background: var(--glacier);
  opacity: 0.55;
}

.legend-key.no-report {
  height: 0.375rem;
  margin-left: 1rem;
  background: var(--rime);
}

/* ---------- report ---------- */

.report {
  border-top: 1px solid var(--rime);
  padding-top: 1.5rem;
}

.report-frame {
  display: block;
  width: 100%;
  min-height: 24rem;
  border: 0;
  background: transparent;
  transition: opacity 160ms ease-out;
}

.report-frame.is-loading {
  opacity: 0.4;
}

.report-frame.is-anomaly {
  height: 50rem;
  border: 1px solid var(--rime);
  border-radius: 8px;
  background: #f7f8fb;
}

/* The anomaly pages report their own height (postMessage), so the frame grows instead of scrolling. */
.report-frame.is-anomaly.is-sized {
  min-height: 0;
}

.views {
  margin: -0.5rem 0 1rem;
  align-items: center;
}

.view-download {
  margin-left: auto;
  color: var(--glacier);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}

.view-download:hover {
  color: var(--glacier-strong);
  text-decoration: underline;
}

.view-download[hidden] {
  display: none;
}

.set:disabled {
  color: var(--rime);
  cursor: not-allowed;
}

@media (prefers-color-scheme: dark) {
  .report-frame.is-anomaly {
    background: #0d0d0d;
  }
}

.report-message {
  max-width: 38rem;
  padding: 2.5rem 0 3rem;
}

.report-message h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.2;
}

.report-message p {
  margin: 0;
  color: var(--ink-soft);
}

.report-message[data-tone="alert"] h2 {
  color: var(--alert);
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.action {
  padding: 0.625rem 1rem;
  border: 1px solid var(--glacier);
  border-radius: 6px;
  background: var(--surface);
  color: var(--glacier-strong);
  font-weight: 500;
  cursor: pointer;
}

.action:hover {
  background: var(--glacier);
  color: var(--surface);
}

/* ---------- small screens ---------- */

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
  }

  .sync {
    font-size: 0.8125rem;
  }

  .timeline {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .timeline-controls {
    padding-top: 0;
  }

  .jump {
    flex: 1;
  }

  .jump input,
  .jump select {
    width: 100%;
  }

  .report-frame.is-anomaly {
    height: 40rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tick,
  .report-frame {
    transition: none;
  }
}
