/* Lines Police CAD status page.
 *
 * A status page is read in a hurry by someone who wants one fact, so the page
 * spends its weight on that: the banner and the strips carry the colour, and
 * everything around them stays quiet. Light by default, dark when the reader's
 * system or the toggle says so.
 */

:root {
  --bg: #faf9f5;
  --surface: #ffffff;
  --line: #e7e4da;
  --line-strong: #d9d5c8;
  --text: #16160f;
  --muted: #6f6d62;
  --faint: #8d8a7e;

  --up: #3f8f34;
  --up-soft: #e4f0dc;
  --minor: #b99a1f;
  --moderate: #d98324;
  --major: #e0652c;
  --down: #cf3b30;
  --down-soft: #fbe6e3;
  --nodata: #ddd9cd;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(22, 22, 15, 0.05);
  --wrap: 60rem;
}

:root:not([data-theme="light"]) {
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #15150f;
    --surface: #1d1d16;
    --line: #2e2e24;
    --line-strong: #3b3b2f;
    --text: #f3f1e9;
    --muted: #a5a294;
    --faint: #8a8779;

    --up: #68b355;
    --up-soft: #23301d;
    --minor: #d2b440;
    --moderate: #e2984a;
    --major: #e8784a;
    --down: #e4584c;
    --down-soft: #33201d;
    --nodata: #33332a;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15150f;
  --surface: #1d1d16;
  --line: #2e2e24;
  --line-strong: #3b3b2f;
  --text: #f3f1e9;
  --muted: #a5a294;
  --faint: #8a8779;

  --up: #68b355;
  --up-soft: #23301d;
  --minor: #d2b440;
  --moderate: #e2984a;
  --major: #e8784a;
  --down: #e4584c;
  --down-soft: #33201d;
  --nodata: #33332a;
  --shadow: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Outfit, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h2,
h3,
h4 {
  margin: 0;
  font-weight: 500;
  letter-spacing: -0.01em;
}

a {
  color: inherit;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 1rem;
}

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 2;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

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

.masthead {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.masthead-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
}

.brand-logo {
  width: 2.5rem;
  height: 2.5rem;
  display: block;
}

/* The dot carries the overall state, so a tab left open on the page still
   says something at a glance. */
.brand-dot {
  width: 0.5rem;
  height: 0.5rem;
  margin-left: 0.125rem;
  border-radius: 50%;
  background: var(--up);
}

.mark-degraded {
  background: var(--moderate);
}

.mark-down {
  background: var(--down);
}

.brand-name {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.brand-name span {
  font-weight: 400;
  color: var(--muted);
}

.masthead-nav {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.masthead-nav > a {
  padding: 0.4rem 0.625rem;
  border-radius: 7px;
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
}

.masthead-nav > a:hover {
  color: var(--text);
  background: var(--surface);
}

.masthead-nav .btn {
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: var(--surface);
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.125rem;
  height: 2.125rem;
  margin-left: 0.25rem;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--text);
}

.theme-toggle svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

.theme-toggle .icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun {
    display: none;
  }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon {
    display: block;
  }
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

/* --------------------------------------------------------------- banner -- */

main {
  padding: 2.5rem 0 3.5rem;
}

.banner {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  background: var(--up);
  color: #fff;
}

.banner h2 {
  font-size: 1.25rem;
  font-weight: 500;
}

.banner-degraded {
  background: var(--moderate);
}

.banner-down {
  background: var(--down);
}

.caption {
  margin: 1.75rem 0 0.625rem;
  text-align: right;
  font-size: 0.8125rem;
  color: var(--faint);
}

/* ------------------------------------------------------------- services -- */

.services {
  display: grid;
  gap: 0.625rem;
}

.service {
  display: block;
  padding: 1rem 1.125rem 0.875rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.12s ease;
}

a.service:hover {
  border-color: var(--line-strong);
}

a.service:hover .service-name {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.service-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.875rem;
}

.service-name {
  font-size: 1rem;
  font-weight: 500;
}

.pill {
  flex: none;
  font-size: 0.8125rem;
  color: var(--up);
}

.pill-degraded {
  color: var(--moderate);
}

.pill-down {
  color: var(--down);
}

/* The 90 bars share the width rather than scrolling, so the strip reads the
   same on a phone as on a desktop: narrower bars, same 90 days. */
.strip {
  display: flex;
  gap: 2px;
  height: 2.125rem;
}

.bar {
  flex: 1 1 0;
  min-width: 2px;
  border-radius: 1px;
  background: var(--up);
}

.bar-minor {
  background: var(--minor);
}

.bar-moderate {
  background: var(--moderate);
}

.bar-major {
  background: var(--major);
}

.bar-down {
  background: var(--down);
}

.bar-nodata {
  background: var(--nodata);
}

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

.strip-legend .rule {
  flex: 1 1 auto;
  height: 1px;
  background: var(--line);
}

.strip-legend .uptime {
  flex: none;
  color: var(--muted);
}

/* ------------------------------------------------------------ incidents -- */

.section-title {
  margin: 3rem 0 0.5rem;
  font-size: 1.5rem;
}

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

.day h3 {
  margin-bottom: 0.5rem;
  font-size: 1.0625rem;
}

.muted {
  margin: 0;
  color: var(--faint);
}

.incident + .incident {
  margin-top: 1.25rem;
}

.incident h4 {
  font-size: 1rem;
  font-weight: 600;
}

.incident-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--faint);
}

.incident-meta .outcome {
  font-weight: 500;
  color: var(--up);
}

.incident-meta .outcome-open {
  color: var(--down);
}

.updates {
  margin: 0.75rem 0 0;
  padding: 0 0 0 0.9375rem;
  list-style: none;
  border-left: 1px solid var(--line);
}

.updates li + li {
  margin-top: 0.75rem;
}

.updates p {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--muted);
}

.updates time {
  display: block;
  margin-top: 0.125rem;
  font-size: 0.8125rem;
  color: var(--faint);
}

.update-label {
  font-weight: 500;
  color: var(--text);
}

.incident-link {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--faint);
}

/* --------------------------------------------------- one service's page -- */

.back {
  display: inline-block;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
}

.back::before {
  content: "\2190";
  margin-right: 0.375rem;
}

.back:hover {
  color: var(--text);
}

.service-hero {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.service-hero h2 {
  font-size: 1.75rem;
}

.service-sub {
  margin: 0.25rem 0 1.5rem;
  font-size: 0.875rem;
  color: var(--faint);
}

.service-sub .host {
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.625rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 1.375rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--faint);
}

.panel {
  margin-top: 0.625rem;
  padding: 1rem 1.125rem 1.125rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel h3 {
  margin-bottom: 0.875rem;
  font-size: 0.9375rem;
  color: var(--muted);
}

/* Horizontal bars: label, track, figure. Used for response times and for the
   days that had downtime, which are the two things there is real data for. */
.chart-rows {
  display: grid;
  gap: 0.5rem;
}

.chart-row {
  display: grid;
  grid-template-columns: 6.5rem 1fr 4.5rem;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
}

.chart-label {
  color: var(--muted);
}

.chart-track {
  height: 0.625rem;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.chart-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--up);
}

.chart-fill-minor {
  background: var(--minor);
}

.chart-fill-moderate {
  background: var(--moderate);
}

.chart-fill-major {
  background: var(--major);
}

.chart-fill-down {
  background: var(--down);
}

.chart-value {
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------- uptime and incident history -- */

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

.tabs {
  display: flex;
  gap: 0.25rem;
  margin: 0 0 1.5rem;
  border-bottom: 1px solid var(--line);
}

.tab {
  padding: 0.5rem 0.875rem;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  margin-bottom: -1px;
  font-size: 0.9375rem;
  color: var(--muted);
  text-decoration: none;
}

.tab:hover {
  color: var(--text);
}

.tab-on {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

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

.field select,
.filter > summary {
  appearance: none;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
}

.field select {
  padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 1rem) 1.15rem, calc(100% - 0.7rem) 1.15rem;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.filter {
  position: relative;
}

.filter > summary {
  list-style: none;
  display: inline-block;
}

.filter > summary::-webkit-details-marker {
  display: none;
}

.filter-menu {
  position: absolute;
  z-index: 5;
  margin-top: 0.375rem;
  min-width: 14rem;
  padding: 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(22, 22, 15, 0.12);
}

.filter-menu label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  border-radius: 6px;
  font-size: 0.9375rem;
  cursor: pointer;
}

.filter-menu label:hover {
  background: var(--bg);
}

.window-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  color: var(--muted);
}

.window-nav button,
.window-nav a,
.window-nav .disabled {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
}

.window-nav button[disabled],
.window-nav .disabled {
  color: var(--faint);
  cursor: default;
  opacity: 0.55;
}

/* Month calendars: one square per day, weeks running Sunday to Saturday. */
.months {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.month-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
}

.month-head h3 {
  font-size: 1rem;
}

.month-head span {
  font-size: 0.8125rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--up);
}

.cell-minor {
  background: var(--minor);
}

.cell-moderate {
  background: var(--moderate);
}

.cell-major {
  background: var(--major);
}

.cell-down {
  background: var(--down);
}

.cell-nodata {
  background: var(--nodata);
}

.cell-pad {
  background: transparent;
}

.month-incidents {
  padding: 1.25rem 0;
  border-top: 1px solid var(--line);
}

.month-incidents h3 {
  margin-bottom: 0.75rem;
  font-size: 1.25rem;
}

.more {
  margin-top: 1.25rem;
}

.more > summary {
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.875rem;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  text-align: center;
}

.more > summary::-webkit-details-marker {
  display: none;
}

.more > summary:hover {
  color: var(--text);
}

.more[open] > summary {
  margin-bottom: 1.25rem;
}

.page-count {
  margin-top: 1.5rem;
  font-size: 0.8125rem;
}

.more-link {
  margin: 1.5rem 0 0;
  font-size: 0.9375rem;
}

/* ------------------------------------------------------------- tooltip -- */

.tip {
  position: absolute;
  z-index: 10;
  min-width: 11rem;
  max-width: 17rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(22, 22, 15, 0.12);
  pointer-events: none;
}

.tip[hidden] {
  display: none;
}

.tip p {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.tip .tip-date {
  margin-bottom: 0.125rem;
  font-weight: 500;
  color: var(--text);
}

.tip::after {
  content: "";
  position: absolute;
  left: var(--arrow, 50%);
  bottom: -5px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  background: var(--surface);
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  transform: rotate(45deg);
}

.tip-below::after {
  bottom: auto;
  top: -5px;
  border: 1px solid var(--line-strong);
  border-right: 0;
  border-bottom: 0;
}

/* --------------------------------------------------------------- footer -- */

.footer {
  border-top: 1px solid var(--line);
  padding: 1.5rem 0 2.5rem;
  font-size: 0.8125rem;
  color: var(--faint);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer p {
  margin: 0;
}

.footer nav {
  display: flex;
  gap: 1rem;
}

@media (max-width: 40rem) {
  main {
    padding: 1.75rem 0 2.5rem;
  }

  .masthead-inner {
    flex-wrap: wrap;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .banner h2 {
    font-size: 1.125rem;
  }

  .caption {
    text-align: left;
  }

  .strip {
    gap: 1px;
    height: 1.75rem;
  }

  .strip-legend {
    justify-content: space-between;
  }

  .strip-legend .rule,
  .strip-legend .since {
    display: none;
  }

  .strip-legend .uptime {
    order: -1;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .chart-row {
    grid-template-columns: 5.5rem 1fr 3.75rem;
    gap: 0.5rem;
    font-size: 0.8125rem;
  }

  .service-hero h2 {
    font-size: 1.375rem;
  }

  .months {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .controls {
    gap: 0.75rem;
  }
}
