/*
 * The status page look: the same neutral grayscale tokens as the Tillcast web
 * apps (web/ui/src/theme.css, OKLCH, shadcn names), with no brand colour. Status
 * colours appear on small dots, always next to a word, and on the bars, which
 * also differ in height and have their words in the title and the table. The
 * bars' colour is HSL, a hue from the availability, with the saturation and the
 * lightness range below (--bar-*) per theme.
 *
 * The dark tokens are written twice because plain CSS cannot share them between
 * a media query and an attribute: the media block serves visitors who chose
 * nothing, the attribute block those who chose dark. test/theme.test.ts keeps
 * the two identical and checks the contrast of every pair in both themes.
 */

@font-face {
  font-family: "Geist Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("geist-latin-ext-wght-normal-824f485b5d.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Geist Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("geist-latin-wght-normal-19f9c92546.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --radius: 0.5rem;
  --background: oklch(1 0 0);
  --foreground: oklch(0.16 0 0);
  --card: oklch(0.985 0 0);
  --muted: oklch(0.965 0 0);
  --muted-foreground: oklch(0.47 0 0);
  --border: oklch(0.92 0 0);
  --input: oklch(0.62 0 0);
  --ring: oklch(0.16 0 0);
  --link: oklch(0.16 0 0);
  --mark: oklch(0.42 0 0);
  --success: oklch(0.45 0.12 150);
  --warning: oklch(0.47 0.1 70);
  --destructive: oklch(0.5 0.19 27);
  --info: oklch(0.45 0.09 235);
  --bar-sat: 85%;
  --bar-l-min: 31%;
  --bar-l-max: 50%;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --background: oklch(0.16 0 0);
    --foreground: oklch(0.97 0 0);
    --card: oklch(0.2 0 0);
    --muted: oklch(0.25 0 0);
    --muted-foreground: oklch(0.72 0 0);
    --border: oklch(0.3 0 0);
    --input: oklch(0.55 0 0);
    --ring: oklch(0.97 0 0);
    --link: oklch(0.97 0 0);
    --mark: oklch(0.8 0 0);
    --success: oklch(0.78 0.16 150);
    --warning: oklch(0.82 0.14 85);
    --destructive: oklch(0.72 0.16 27);
    --info: oklch(0.78 0.1 235);
    --bar-sat: 75%;
    --bar-l-min: 52%;
    --bar-l-max: 58%;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: oklch(0.16 0 0);
  --foreground: oklch(0.97 0 0);
  --card: oklch(0.2 0 0);
  --muted: oklch(0.25 0 0);
  --muted-foreground: oklch(0.72 0 0);
  --border: oklch(0.3 0 0);
  --input: oklch(0.55 0 0);
  --ring: oklch(0.97 0 0);
  --link: oklch(0.97 0 0);
  --mark: oklch(0.8 0 0);
  --success: oklch(0.78 0.16 150);
  --warning: oklch(0.82 0.14 85);
  --destructive: oklch(0.72 0.16 27);
  --info: oklch(0.78 0.1 235);
  --bar-sat: 75%;
  --bar-l-min: 52%;
  --bar-l-max: 58%;
}

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

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

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: "Geist Variable", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

.wrap {
  width: 100%;
  max-width: 46rem;
  margin-inline: auto;
  padding-inline: 1rem;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

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

main:focus-visible {
  outline-offset: -2px;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  padding: 0.5rem 0.75rem;
  background: var(--background);
  border: 1px solid var(--input);
  border-radius: var(--radius);
}

.skip:focus {
  top: 0.5rem;
}

.site-header {
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.5rem;
}

.wordmark {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.wordmark-sub {
  font-weight: 400;
  color: var(--muted-foreground);
}

/* The theme switch: a small, quiet icon. It shows the current choice (system, light or dark); the name is in aria-label and title. */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  color: var(--muted-foreground);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}

.icon-button[hidden] {
  display: none;
}

.icon-button:hover {
  color: var(--foreground);
  background: var(--muted);
}

.icon-button .icon {
  display: none;
}

.icon-button[data-state="system"] .icon-system,
.icon-button[data-state="light"] .icon-light,
.icon-button[data-state="dark"] .icon-dark {
  display: block;
}

/* The wordmark is two links: "Tillcast" goes to the product site, "Status" stays on this page. */
.wordmark-link {
  color: inherit;
  text-decoration: none;
}

.wordmark-link.wordmark-sub {
  color: var(--muted-foreground);
}

.wordmark-link:hover,
.wordmark-link:focus-visible {
  text-decoration: underline;
}

h1 {
  margin: 2rem 0 1rem;
  font-size: 1.75rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.3;
}

h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.4;
}

section {
  margin-top: 2.5rem;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.muted {
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

.notice {
  padding: 0.75rem 1rem;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  background: var(--card);
}

.button {
  min-height: 2.5rem;
  padding: 0.25rem 0.875rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--foreground);
  background: var(--background);
  border: 1px solid var(--input);
  border-radius: var(--radius);
  cursor: pointer;
}

.button[aria-pressed="true"] {
  background: var(--foreground);
  color: var(--background);
  border-color: var(--foreground);
}

#period {
  display: flex;
  gap: 0.5rem;
}

#period[hidden] {
  display: none;
}

.banner {
  display: flex;
  align-items: center;
  min-height: 3.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  font-size: 1.125rem;
  font-weight: 550;
}

.state {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.dot {
  flex: none;
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: var(--muted-foreground);
}

.dot-operational {
  background: var(--success);
}

.dot-maintenance {
  background: var(--info);
}

.dot-degraded,
.dot-partial_outage {
  background: var(--warning);
}

.dot-major_outage {
  background: var(--destructive);
}

.dot-unknown {
  background: var(--muted-foreground);
}

.services,
.corrections,
.updates {
  margin: 0;
  padding: 0;
  list-style: none;
}

.service {
  padding: 1rem 0;
  border-top: 1px solid var(--border);
}

.service:last-child {
  border-bottom: 1px solid var(--border);
}

.service-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.availability {
  margin: 0.25rem 0 0.75rem;
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

/* One bar per day, or per hour in the 7-day view, each its own mark with a gap
 * around it. The numbers a bar is drawn from come from the page's script
 * (format.ts, lookAt) as custom properties set through the CSSOM, which the
 * content security policy allows (an inline style attribute it does not):
 *   --fill   its height as a share of the bar, 1 for all up, 0.14 for none up
 *   --hue    the HSL hue, 130 green through orange to 0 red
 *   --lift   where between --bar-l-min and --bar-l-max this hue is lit, so that
 *            every hue keeps the same contrast with the page (test/theme.test.ts)
 * Height follows the colour, so a bar reads without it; the words are in the
 * title and the table under the bar. */
.bar {
  display: flex;
  align-items: flex-end;
  gap: var(--bar-gap, 2px);
  height: 3.5rem;
}

.day {
  flex: 1 1 0;
  min-width: 1px;
  height: calc(var(--fill, 1) * 100%);
  border-radius: 2px 2px 0 0;
  background: var(--mark);
}

.day-scale {
  background: hsl(var(--hue, 0) var(--bar-sat) calc(var(--bar-l-min) + (var(--bar-l-max) - var(--bar-l-min)) * var(--lift, 0)));
}

/* No data at all (a thin line, lower than the lowest red bar) and much of it without data (half height): neutral grey, which no coloured bar is. */
.day-none,
.day-gap {
  background: var(--input);
}

/* The gaps shrink with the number of bars: 30 days are wide bars, 90 days narrower, 168 hours the narrowest. */
.bar-30 {
  --bar-gap: 3px;
}

.bar-90 {
  --bar-gap: 2px;
}

/* The hours do not shrink below --bar-min: 168 bars with a gap each are 503px at 2px, 671px at 3px, and the strip is
 * exactly that wide when its box is narrower, so it scrolls inside its own box and the page itself never does, at
 * whatever size the text is. --count is the number of bars, written by the script. Where the box is wide enough the bar
 * fills it and nothing scrolls. The script starts a strip at the newest hour, at the right, and makes it a region a
 * keyboard can reach only while it does scroll (view.ts, fitStrip). */
.bar-scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.bar-7 {
  --bar-gap: 1px;
  --bar-min: 2px;
  min-width: calc(var(--count, 168) * var(--bar-min) + (var(--count, 168) - 1) * var(--bar-gap));
  /* Bars that share a width with a fraction of a pixel can end a pixel past the box; clipped, that cannot make a strip scroll that fits. */
  overflow: hidden;
}

.bar-7 .day {
  flex: 1 0 var(--bar-min);
  border-radius: 1px 1px 0 0;
}

/* On a phone the hours are wider (3px), the 90 days closer. */
@media (max-width: 36rem) {
  .bar-7 {
    --bar-min: 3px;
  }

  .bar-90 {
    --bar-gap: 1px;
  }
}

/* Shown by the script while a strip of hours scrolls, which is the only time the reader needs it. */
.strip-hint {
  display: none;
  margin: 0 0 0.5rem;
}

section:has(.services[data-scrolls="true"]) .strip-hint {
  display: block;
}

details {
  margin-top: 0.75rem;
  font-size: 0.875rem;
}

summary {
  cursor: pointer;
  min-height: 1.5rem;
}

.table-scroll {
  max-height: 16rem;
  margin-top: 0.5rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

caption {
  padding: 0.5rem;
  text-align: left;
  color: var(--muted-foreground);
}

th,
td {
  padding: 0.375rem 0.5rem;
  text-align: left;
  border-top: 1px solid var(--border);
  font-weight: 400;
}

thead th {
  font-weight: 600;
}

/* A date such as 2026-10-11 must not break at its hyphens on a phone: the table scrolls inside its region. */
tbody th[scope="row"] {
  white-space: nowrap;
}

.incident {
  padding: 1rem 0;
  border-top: 1px solid var(--border);
}

.incident-meta {
  margin: 0.25rem 0 0;
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

.updates {
  margin-top: 0.75rem;
}

.updates li {
  padding: 0.5rem 0 0.5rem 0.75rem;
  border-left: 2px solid var(--border);
}

.update-head,
.update-text {
  margin: 0;
}

.update-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.corrections li {
  margin-top: 0.5rem;
  font-size: 0.875rem;
}

.site-footer {
  margin-top: 3rem;
  padding-block: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}

.site-footer p {
  margin: 0.25rem 0;
}

@media (prefers-reduced-motion: no-preference) {
  .button {
    transition: background-color 120ms ease-out;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 30rem) {
  h1 {
    font-size: 1.5rem;
  }

  .banner {
    font-size: 1rem;
  }
}

.banner:empty {
  display: none;
}

/* Text typed by an operator can hold a long word or address; it must wrap, not
 * push the page sideways (WCAG 1.4.10 reflow, 1.4.4 resize text). */
.incident h3,
.incident-meta,
.corrections li,
.service-head h3 {
  overflow-wrap: anywhere;
}

/* Windows high contrast: the marks are backgrounds, which forced colours would
 * flatten. Keep their shape and give them the system's text colour. */
@media (forced-colors: active) {
  .day,
  .dot {
    forced-color-adjust: none;
    background: CanvasText;
  }

  .day-none,
  .day-gap {
    background: GrayText;
  }
}

@media print {
  :root {
    color-scheme: light;
    --background: oklch(1 0 0);
    --foreground: oklch(0 0 0);
    --card: oklch(1 0 0);
    --muted-foreground: oklch(0.35 0 0);
    --border: oklch(0.7 0 0);
    --input: oklch(0.5 0 0);
    --mark: oklch(0.3 0 0);
    --bar-sat: 85%;
    --bar-l-min: 31%;
    --bar-l-max: 50%;
  }

  .day,
  .dot {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  /* A page cannot be scrolled: all 168 hours are drawn, the page's width shared between them. */
  .bar-scroll {
    overflow: visible;
  }

  .strip-hint {
    display: none !important;
  }

  .bar-7 {
    --bar-min: 0px;
  }

  #theme,
  #period,
  .skip {
    display: none;
  }
}
