/*
 * Briko status page (SCRUM-769, redesigned in SCRUM-772): system fonts only,
 * no external assets (the CSP forbids them). Colours are tokens on :root;
 * the dark theme applies with prefers-color-scheme unless the header's
 * toggle chose light, and always under [data-theme="dark"] (theme.js). The
 * two dark blocks must stay identical.
 */
:root {
  --page: #faf6f5;
  --card: #fbf6f6;
  --card-strong: #fffdfd;
  --card-head: #f5eded;
  --border: #ead2d6;
  --divider: #f0e2e4;
  --text: #211a1b;
  --muted: #5e5355;
  --accent: #7f1626;
  --header: #4f0d15;
  --header-text: #ffffff;
  --header-border: transparent;
  --header-divider: rgb(255 255 255 / 35%);
  --logo-mark: #ffffff;
  --logo-word: #ffffff;
  --toggle-border: rgb(255 255 255 / 55%);
  --toggle-active-bg: #fbeef0;
  --toggle-active-text: #4f0d15;
  --radius: 12px;
  --ok-bar: #3b8f45;
  --degraded-bar: #e0a838;
  --down-bar: #c42a2a;
  --nodata-bar: #ded1d4;
  --ok-bg: #e2f1e4;
  --ok-text: #1d6a2b;
  --degraded-bg: #fcf0cc;
  --degraded-text: #714d00;
  --down-bg: #fde3e3;
  --down-text: #a1151b;
  --unknown-bg: #ebe4e5;
  --unknown-text: #3a3234;
  --unknown-dot: #85797b;
  --banner-unknown: #ece6e7;
  --banner-unknown-border: #d6cbcd;
  --banner-unknown-icon: #6b5b5e;
  --banner-operational: #e7f3e8;
  --banner-operational-border: #b9dabd;
  --banner-degraded: #fcf3dc;
  --banner-degraded-border: #ecd193;
  --banner-degraded-icon: #a87300;
  --banner-down: #fbe6e6;
  --banner-down-border: #eab3b3;
  --button-bg: #7f1626;
  --button-text: #ffffff;
  --focus: #7f1626;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #161616;
    --card: #1e1e1e;
    --card-strong: #1e1e1e;
    --card-head: #232323;
    --border: #2a2a2a;
    --divider: #2a2a2a;
    --text: #ededed;
    --muted: #9a9a9a;
    --accent: #e5677a;
    --header: #121212;
    --header-text: #ededed;
    --header-border: #2a2a2a;
    --header-divider: #3a3a3a;
    --logo-mark: #c8394d;
    --logo-word: #ffffff;
    --toggle-border: #3a3a3a;
    --toggle-active-bg: #a3192e;
    --toggle-active-text: #ffffff;
    --radius: 8px;
    --ok-bar: #4caf50;
    --degraded-bar: #e0a030;
    --down-bar: #e04a4a;
    --nodata-bar: #3a3a3a;
    --ok-bg: rgb(76 175 80 / 16%);
    --ok-text: #81cf84;
    --degraded-bg: rgb(224 160 48 / 16%);
    --degraded-text: #edbd62;
    --down-bg: rgb(224 74 74 / 16%);
    --down-text: #ff8f8f;
    --unknown-bg: #2a2a2a;
    --unknown-text: #cfcfcf;
    --unknown-dot: #8a8a8a;
    --banner-unknown: #1e1e1e;
    --banner-unknown-border: #3a3a3a;
    --banner-unknown-icon: #5a5a5a;
    --banner-operational: #1e1e1e;
    --banner-operational-border: #2f6b32;
    --banner-degraded: #1e1e1e;
    --banner-degraded-border: #7a5a1e;
    --banner-degraded-icon: #a87300;
    --banner-down: #1e1e1e;
    --banner-down-border: #8a2a32;
    --button-bg: #a3192e;
    --button-text: #ffffff;
    --focus: #e5677a;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --page: #161616;
  --card: #1e1e1e;
  --card-strong: #1e1e1e;
  --card-head: #232323;
  --border: #2a2a2a;
  --divider: #2a2a2a;
  --text: #ededed;
  --muted: #9a9a9a;
  --accent: #e5677a;
  --header: #121212;
  --header-text: #ededed;
  --header-border: #2a2a2a;
  --header-divider: #3a3a3a;
  --logo-mark: #c8394d;
  --logo-word: #ffffff;
  --toggle-border: #3a3a3a;
  --toggle-active-bg: #a3192e;
  --toggle-active-text: #ffffff;
  --radius: 8px;
  --ok-bar: #4caf50;
  --degraded-bar: #e0a030;
  --down-bar: #e04a4a;
  --nodata-bar: #3a3a3a;
  --ok-bg: rgb(76 175 80 / 16%);
  --ok-text: #81cf84;
  --degraded-bg: rgb(224 160 48 / 16%);
  --degraded-text: #edbd62;
  --down-bg: rgb(224 74 74 / 16%);
  --down-text: #ff8f8f;
  --unknown-bg: #2a2a2a;
  --unknown-text: #cfcfcf;
  --unknown-dot: #8a8a8a;
  --banner-unknown: #1e1e1e;
  --banner-unknown-border: #3a3a3a;
  --banner-unknown-icon: #5a5a5a;
  --banner-operational: #1e1e1e;
  --banner-operational-border: #2f6b32;
  --banner-degraded: #1e1e1e;
  --banner-degraded-border: #7a5a1e;
  --banner-degraded-icon: #a87300;
  --banner-down: #1e1e1e;
  --banner-down-border: #8a2a32;
  --button-bg: #a3192e;
  --button-text: #ffffff;
  --focus: #e5677a;
  color-scheme: dark;
}

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

/* A display rule below must never reveal a hidden element (the report form). */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font:
    15px/1.5 system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

.wrap {
  max-width: 1032px;
  margin: 0 auto;
  padding: 0 16px;
}

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

.skip:focus {
  left: 16px;
  top: 8px;
  z-index: 1;
  color: var(--text);
  background: var(--page);
  padding: 4px 8px;
}

/* Header */

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

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  min-height: 60px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: block;
  height: 28px;
  width: auto;
  aspect-ratio: 300 / 71;
}

.logo-mark {
  fill: var(--logo-mark);
}

.logo-word {
  fill: var(--logo-word);
}

.brand-divider {
  width: 1px;
  height: 22px;
  background: var(--header-divider);
}

.brand-title {
  font-weight: 600;
  font-size: 1rem;
}

.theme-toggle {
  display: flex;
  gap: 6px;
}

.theme-toggle button {
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--header-text);
  background: transparent;
  border: 1px solid var(--toggle-border);
  border-radius: 999px;
  padding: 3px 11px;
  cursor: pointer;
}

.theme-toggle button[aria-pressed="true"] {
  color: var(--toggle-active-text);
  background: var(--toggle-active-bg);
  border-color: var(--toggle-active-bg);
}

.site-header :focus-visible {
  outline-color: var(--header-text);
}

main.wrap {
  display: grid;
  gap: 22px;
  padding-top: 28px;
  padding-bottom: 24px;
}

/* Cards */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card h2 {
  font-size: 1.0625rem;
  font-weight: 600;
}

.card-intro {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Banner */

.banner {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 22px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--banner-unknown-border);
  background: var(--banner-unknown);
}

.banner-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--banner-unknown-icon);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}

.banner-text {
  flex: 1;
  min-width: 0;
}

.banner h1 {
  font-size: 1.375rem;
  line-height: 1.3;
  font-weight: 700;
}

.banner-text p {
  margin-top: 4px;
  font-size: 0.9375rem;
  max-width: 40rem;
}

.banner-check {
  flex: none;
  text-align: right;
  color: var(--muted);
  font-size: 0.8125rem;
}

.banner-check .banner-checked {
  margin: 2px 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
}

/* Refresh (SCRUM-792): the button, the "updated N s ago" text and the
   inline error, under "Checked every minute". */

.refresh {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 8px;
}

.refresh-age {
  font-variant-numeric: tabular-nums;
}

.refresh-button {
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  background: var(--card-strong);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 14px;
  min-height: 32px;
  cursor: pointer;
}

.refresh-button:hover {
  border-color: var(--muted);
}

.refresh-button[aria-disabled="true"] {
  opacity: 0.6;
  cursor: progress;
}

.refresh-error {
  margin-top: 6px;
  color: var(--down-text);
  font-weight: 600;
}

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

/* The Refresh button's easter egg: 30 clicks in 3 minutes. */

.coffee {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-strong);
  animation: coffee-in 0.3s ease-out;
}

.coffee[hidden] {
  display: none;
}

.coffee-cup {
  position: relative;
  flex: none;
  font-size: 1.5rem;
  line-height: 1;
}

.coffee-steam {
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 6px;
  height: 10px;
  margin-left: -3px;
  border-left: 2px solid var(--muted);
  border-radius: 50%;
  opacity: 0;
  animation: coffee-steam 2s ease-in-out infinite;
}

.coffee-text {
  flex: 1;
  min-width: 0;
  font-size: 0.9375rem;
}

.coffee-close {
  flex: none;
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  width: 32px;
  height: 32px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;
  cursor: pointer;
}

.coffee-close:hover {
  color: var(--text);
  border-color: var(--border);
}

@keyframes coffee-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

@keyframes coffee-steam {
  0% {
    opacity: 0;
    transform: translateY(4px);
  }
  50% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
    transform: translateY(-6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .coffee,
  .coffee-steam {
    animation: none;
  }
}

.banner-operational {
  background: var(--banner-operational);
  border-color: var(--banner-operational-border);
}

.banner-operational .banner-icon {
  background: var(--ok-bar);
}

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

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

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

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

/* Summary */

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  padding: 16px 16px 14px;
}

.card .stat-label {
  font-size: 0.875rem;
  font-weight: 400;
}

.stat-value {
  margin: 8px 0 4px;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-note {
  color: var(--muted);
  font-size: 0.8125rem;
}

/* Services */

.services {
  padding: 0;
  overflow: hidden;
  background: var(--card-strong);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 16px;
  padding: 18px 20px;
  background: var(--card-head);
  border-bottom: 1px solid var(--border);
}

.card-head p {
  color: var(--muted);
  font-size: 0.8125rem;
}

.components,
.team,
.legend,
.bars,
.incident-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.component {
  padding: 18px 20px 16px;
}

.component + .component {
  border-top: 1px solid var(--divider);
}

.component-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.component-name {
  font-size: 1rem;
  font-weight: 600;
}

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

.pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.component-head .pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentcolor;
}

.pill-operational {
  color: var(--ok-text);
  background: var(--ok-bg);
}

.pill-degraded {
  color: var(--degraded-text);
  background: var(--degraded-bg);
}

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

.pill-unknown {
  color: var(--unknown-text);
  background: var(--unknown-bg);
}

.component-head .pill-unknown::before {
  background: var(--unknown-dot);
}

.bars {
  display: grid;
  grid-template-columns: repeat(90, minmax(0, 1fr));
  gap: 3px;
  margin: 12px 0 8px;
}

.bars li {
  display: flex;
}

.bar {
  display: block;
  width: 100%;
  height: 34px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: var(--nodata-bar);
  cursor: pointer;
}

.bars .bar:hover,
.bars .bar:focus-visible {
  opacity: 0.75;
}

.bar-operational {
  background: var(--ok-bar);
}

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

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

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

.component-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.component-foot > span:first-child,
.component-foot > span:last-child {
  flex: none;
}

.uptime {
  color: var(--text);
  font-weight: 600;
  text-align: center;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 12px 20px;
  border-top: 1px solid var(--divider);
  color: var(--text);
  font-size: 0.8125rem;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

/* Incidents and contacts */

.columns {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.incident-list {
  margin-top: 10px;
}

.incident {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
  font-size: 0.9375rem;
}

.incident-date {
  color: var(--muted);
}

.incident-empty {
  display: block;
  color: var(--muted);
}

.incident .pill {
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
}

.team {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.member {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
  background: var(--down-bg);
}

.avatar-initials {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 700;
}

.member-name {
  font-weight: 600;
}

.member-role {
  color: var(--muted);
  font-size: 0.8125rem;
}

.member-email {
  font-size: 0.875rem;
  word-break: break-all;
}

/* Report form (SCRUM-770) */

.report-form {
  display: grid;
  gap: 16px;
  max-width: 40rem;
  margin-top: 8px;
}

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

.field {
  display: grid;
  gap: 4px;
}

.field label {
  font-weight: 600;
  font-size: 0.875rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--card-strong);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}

.field textarea {
  resize: vertical;
}

.field [aria-invalid="true"] {
  border-color: var(--down-bar);
}

.field-hint {
  color: var(--muted);
  font-size: 0.8125rem;
}

.field-error {
  color: var(--down-text);
  font-size: 0.8125rem;
}

.captcha {
  min-height: 65px;
}

.button {
  justify-self: start;
  font: inherit;
  font-weight: 600;
  color: var(--button-text);
  background: var(--button-bg);
  border: 0;
  border-radius: 8px;
  padding: 10px 20px;
  cursor: pointer;
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.report-status {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-strong);
}

.report-status-success {
  border-color: var(--ok-bar);
}

.report-status-invalid,
.report-status-captcha,
.report-status-rate-limited,
.report-status-unavailable {
  border-color: var(--down-bar);
}

/* Footer */

.site-footer {
  padding-bottom: 40px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.site-footer p {
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Narrow screens: cards stack, bars shrink. */

@media (max-width: 760px) {
  .summary,
  .columns {
    grid-template-columns: minmax(0, 1fr);
  }

  .banner {
    flex-wrap: wrap;
  }

  .banner-check {
    flex-basis: 100%;
    text-align: left;
    padding-left: 62px;
  }

  .refresh {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .bars {
    gap: 1px;
  }

  .bar {
    height: 28px;
    border-radius: 1px;
  }

  .banner {
    padding: 16px;
    gap: 12px;
  }

  .banner-icon {
    width: 36px;
    height: 36px;
  }

  .banner-check {
    padding-left: 0;
  }

  .incident {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .incident-date {
    grid-column: 1 / -1;
    font-size: 0.8125rem;
  }

  .theme-toggle button {
    padding: 2px 8px;
  }
}
