/* BotStable status site. Builds on /assets/css/style.css (tokens, fonts, header, buttons). */

:root {
  --st-ok: #4ADE80;
  --st-minor: #E8C547;   /* under half the services had issues */
  --st-major: #F0883E;   /* half or more had issues */
  --st-down: #E5484D;    /* all had issues / service down */
  --st-none: #2E2850;    /* no data */
  --st-amber: #F5A524;   /* latency high vs its own average */
  --st-card: var(--c-surface);
}

.status-page [hidden] { display: none !important; }
.status-page main { padding-block: var(--s-6) var(--s-12); }
.st-top .nav { gap: var(--s-3); }
.st-top .brand span { white-space: nowrap; }
.st-top-link { margin-left: auto; color: var(--c-muted); font-size: 14px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.st-top-link:hover { color: var(--c-white); }

.st-muted { color: var(--c-dim); }
.st-mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.st-card-box {
  background: var(--st-card);
  border: 1px solid var(--c-line);
  border-radius: var(--r);
}

/* Status dot */
.st-dot {
  display: inline-block; flex: none;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--st-none);
}
[data-state="up"] .st-dot, .st-dot[data-state="up"],
[data-state="operational"] .st-dot, .st-dot[data-state="operational"] { background: var(--st-ok); }
[data-state="partial"] .st-dot, .st-dot[data-state="partial"] { background: var(--st-minor); }
[data-state="down"] .st-dot, .st-dot[data-state="down"],
[data-state="major"] .st-dot, .st-dot[data-state="major"] { background: var(--st-down); }
[data-state="unknown"] .st-dot, .st-dot[data-state="unknown"] { background: var(--c-dim); }

/* Banner */
.st-banner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3);
  margin-bottom: var(--s-6);
}
.st-banner-title {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px var(--s-1);
  font-size: 22px; line-height: 32px; font-weight: 500; color: var(--c-text);
}
.st-banner-title .st-dot { width: 12px; height: 12px; margin-right: 4px; }
.st-banner-uptime { font-size: 16px; font-weight: 400; color: var(--c-dim); }
.st-banner-sub { margin-top: 4px; font-size: 14px; color: var(--c-dim); }
.st-banner .btn { flex: none; }

/* Groups */
.st-group + .st-group { margin-top: var(--s-6); }
.st-group-head { display: flex; align-items: center; gap: var(--s-1); margin-bottom: var(--s-2); }
.st-group-title { margin: 0; font-size: inherit; flex: none; }
.st-group-toggle {
  display: flex; align-items: center; gap: var(--s-1);
  padding: var(--s-1) 0;
  background: none; border: 0; cursor: pointer; text-align: left;
  color: var(--c-text); font: inherit;
}
.st-group-toggle:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; border-radius: 4px; }
.st-chev {
  flex: none; width: 16px; height: 16px; color: var(--c-dim);
  transition: transform 200ms var(--ease);
}
.st-group-toggle[aria-expanded="false"] .st-chev { transform: rotate(-90deg); }
.st-group-name { font-size: 18px; line-height: 28px; font-weight: 500; }
.st-group-count {
  font-size: 13px; line-height: 20px; color: var(--c-dim);
  padding: 0 var(--s-1); border: 1px solid var(--c-line-strong); border-radius: var(--r);
}
.st-group-meta { margin-left: auto; font-size: 14px; color: var(--c-dim); white-space: nowrap; }
.st-group-meta .st-mono { color: var(--c-muted); }

/* Day / hour blocks: always one row, they get thinner on small screens */
.st-blocks { display: flex; gap: 2px; height: 36px; }
.st-block {
  flex: 1 1 0; min-width: 0;
  border-radius: 2px;
  background: var(--st-none);
  transition: opacity 120ms var(--ease);
}
.st-blocks:hover .st-block { opacity: 0.6; }
.st-blocks .st-block:hover, .st-blocks .st-block:focus-visible { opacity: 1; }
.st-block:focus-visible { outline: 2px solid var(--c-white); outline-offset: 1px; border-radius: 2px; }
.st-block[data-state="ok"] { background: var(--st-ok); }
.st-block[data-state="minor"] { background: var(--st-minor); }
.st-block[data-state="major"] { background: var(--st-major); }
.st-block[data-state="down"] { background: var(--st-down); }
a.st-block { display: block; }
.st-blocks-legend {
  display: flex; justify-content: space-between; margin-top: var(--s-1);
  font-size: 12px; line-height: 16px; color: var(--c-dim);
}

/* Tooltip */
.st-tip {
  position: fixed; z-index: 60; pointer-events: none;
  padding: 4px var(--s-1);
  background: var(--c-white); color: var(--c-dark);
  border-radius: 4px;
  font-size: 13px; line-height: 20px; font-weight: 500; white-space: nowrap;
}
.st-tip[hidden] { display: none; }

/* Service cards */
.st-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); margin-top: var(--s-3); }
.st-card {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-content: start; column-gap: var(--s-3);
  min-height: 148px;
  padding: var(--s-2) var(--s-3);
  color: inherit; text-decoration: none;
  transition: border-color 150ms var(--ease);
}
.st-card:hover { border-color: var(--c-line-strong); color: inherit; }
.st-card > :not(.st-spark) { position: relative; }
/* Sparkline fills the lower half of the card, under nothing but the card itself */
.st-spark { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 46%; }
.st-spark .area { fill: var(--st-ok); opacity: 0.12; }
.st-spark .line { fill: none; stroke: var(--st-ok); stroke-opacity: 0.55; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.st-card[data-latency="high"] .st-spark .area { fill: var(--st-amber); }
.st-card[data-latency="high"] .st-spark .line { stroke: var(--st-amber); }
.st-card-main { min-width: 0; }
.st-card-head { display: flex; align-items: center; gap: var(--s-1); }
.st-card-name { font-size: 16px; font-weight: 500; color: var(--c-text); }
.st-card-sub { margin-top: 2px; font-size: 14px; color: var(--c-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-card-stats { display: flex; gap: var(--s-3); margin: 0; text-align: right; }
.st-card-stats dt { font-size: 12px; line-height: 16px; color: var(--c-dim); }
.st-card-stats dd { margin: 2px 0 0; font-family: var(--f-mono); font-size: 16px; line-height: 24px; color: var(--c-text); font-variant-numeric: tabular-nums; }
.st-card[data-latency="high"] .st-card-latency { color: var(--st-amber); }

.st-note { margin-top: var(--s-6); font-size: 14px; color: var(--c-dim); }

/* Shared page bits (daily report, service page) */
.st-back { display: inline-block; margin-bottom: var(--s-3); color: var(--c-muted); font-size: 14px; font-weight: 500; text-decoration: none; }
.st-back:hover { color: var(--c-white); }
.st-h1 { font-size: clamp(28px, 3.2vw, 40px); line-height: 1.2; letter-spacing: -0.015em; }
.st-h2 { font-size: 20px; line-height: 28px; letter-spacing: -0.01em; }
.st-panel { padding: var(--s-3); margin-top: var(--s-4); }
.st-panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); flex-wrap: wrap; margin-bottom: var(--s-3); }
.st-inline-msg { margin-top: var(--s-2); font-size: 14px; color: var(--c-muted); }
.st-inline-msg[data-kind="error"] { color: #F2A6A8; }
.st-inline-msg[data-kind="ok"] { color: var(--st-ok); }

.st-input {
  min-height: 40px; padding: 0 var(--s-2);
  background: var(--c-dark); color: var(--c-text);
  border: 1px solid var(--c-line-strong); border-radius: var(--r);
  font: inherit; font-size: 14px;
  color-scheme: dark;
}
.st-input:hover { border-color: var(--c-accent); }

.st-day-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); flex-wrap: wrap; }
.st-date-picker { display: flex; align-items: center; gap: var(--s-1); }
button.btn-secondary { background: transparent; color: var(--c-white); cursor: pointer; }
.st-icon-btn { min-width: 40px; padding: 0 var(--s-1); }
.st-icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.st-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.st-tab {
  min-height: 32px; padding: 0 var(--s-2);
  background: transparent; border: 1px solid transparent; border-radius: var(--r);
  color: var(--c-dim); font: inherit; font-size: 14px; cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.st-tab:hover { color: var(--c-white); }
.st-tab[aria-selected="true"] { color: var(--c-white); border-color: var(--c-line-strong); background: var(--c-dark); }

.st-months { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--s-1); }
.st-month {
  display: block; padding: 12px var(--s-2);
  background: var(--c-dark); border: 1px solid var(--c-line); border-radius: var(--r);
  color: inherit; text-decoration: none;
}
a.st-month:hover { border-color: var(--c-line-strong); color: inherit; }
.st-month-name { display: block; font-size: 13px; line-height: 20px; color: var(--c-dim); }
.st-month-value { display: block; font-family: var(--f-mono); font-size: 16px; line-height: 24px; color: var(--c-text); font-variant-numeric: tabular-nums; }
.st-month[data-empty] .st-month-value { color: var(--c-dim); }

.st-stats { display: grid; gap: var(--s-2); margin-top: var(--s-2); }
.st-stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.st-stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.st-stat { padding: var(--s-2) var(--s-3); }
.st-stat-label { font-size: 13px; line-height: 20px; color: var(--c-dim); }
.st-stat-value { margin-top: 2px; font-size: 20px; line-height: 28px; font-weight: 500; color: var(--c-text); }
.st-stat-value.st-mono { font-weight: 400; }
.st-stat-sub { font-size: 13px; font-weight: 400; color: var(--c-dim); white-space: nowrap; }
.st-stats-small .st-stat { padding: var(--s-1) var(--s-2); }
.st-stat-center { text-align: center; }
.st-stat-center .st-stat-value { font-size: 18px; line-height: 26px; }
.st-stat-value.st-ok { color: var(--st-ok); }

.st-day-title { margin-top: var(--s-8); margin-bottom: var(--s-2); }
.st-hours-legend {
  display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; margin-top: var(--s-1);
  font-family: var(--f-mono); font-size: 11px; line-height: 16px; color: var(--c-dim); text-align: center;
}
.st-day-group + .st-day-group { margin-top: var(--s-3); }
.st-empty { padding: var(--s-3); color: var(--c-muted); }

/* Service page */
.st-svc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.st-svc-sub { margin-top: 4px; color: var(--c-muted); }
.st-svc-ip { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-1); }
.st-svc-ip .st-mono { font-size: 16px; color: var(--c-text); }
.st-pill {
  display: inline-flex; align-items: center; gap: 12px; flex: none;
  padding: 12px var(--s-3);
  border: 1px solid var(--c-line-strong); border-radius: 999px;
  font-family: var(--f-mono); font-size: 20px; line-height: 28px; font-weight: 500; letter-spacing: 0.04em;
  color: var(--c-muted);
}
.st-pill .st-dot { width: 12px; height: 12px; }
.st-pill[data-state="up"] { color: var(--st-ok); border-color: rgba(74, 222, 128, 0.45); background: rgba(74, 222, 128, 0.08); }
.st-pill[data-state="down"] { color: #F2A6A8; border-color: rgba(229, 72, 77, 0.55); background: rgba(229, 72, 77, 0.1); }
.st-stats + .st-stats { margin-top: var(--s-2); }

.st-chart { position: relative; height: 220px; padding-left: 56px; padding-bottom: 24px; }
.st-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.st-chart .grid { stroke: var(--c-line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.st-chart .line { fill: none; stroke: var(--st-ok); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.st-chart .downbar { fill: var(--st-down); opacity: 0.35; }
.st-chart-y, .st-chart-x { position: absolute; font-family: var(--f-mono); font-size: 12px; line-height: 16px; color: var(--c-dim); }
.st-chart-y { left: 0; width: 48px; text-align: right; transform: translateY(-50%); }
.st-chart-x { bottom: 0; transform: translateX(-50%); white-space: nowrap; }
.st-chart-x.start { transform: none; }
.st-chart-x.end { transform: translateX(-100%); }
.st-chart-empty { position: absolute; inset: 0 0 24px 56px; display: flex; align-items: center; justify-content: center; color: var(--c-dim); font-size: 14px; }
.st-chart-now { font-size: 14px; }
.st-chart { touch-action: pan-y; cursor: crosshair; -webkit-user-select: none; user-select: none; }
.st-chart-guide, .st-chart-point, .st-chart-tip { position: absolute; left: 0; top: 0; pointer-events: none; }
.st-chart-guide { width: 1px; background: var(--c-muted); opacity: 0.6; transition: transform 60ms linear; }
.st-chart-point {
  width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
  background: var(--st-ok); border: 2px solid var(--c-white);
  transition: transform 60ms linear;
}
.st-chart-tip {
  z-index: 2; display: flex; flex-direction: column; align-items: center;
  padding: 4px var(--s-1);
  background: var(--c-white); color: var(--c-dark); border-radius: 4px;
  font-size: 13px; line-height: 18px; white-space: nowrap;
}
.st-chart-tip span { font-family: var(--f-mono); font-size: 12px; opacity: 0.75; }
.st-chart [hidden] { display: none; }

/* Report form */
.st-report-sub { margin-top: 4px; margin-bottom: var(--s-3); }
.st-form { display: grid; gap: var(--s-3); max-width: 560px; }
.st-fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.st-label { display: block; margin-bottom: var(--s-1); padding: 0; font-size: 14px; font-weight: 500; color: var(--c-text); }
.st-radios { display: grid; gap: var(--s-1); }
.st-radio {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0 var(--s-2);
  background: var(--c-dark); border: 1px solid var(--c-line); border-radius: var(--r);
  cursor: pointer; color: var(--c-muted);
}
.st-radio:hover { border-color: var(--c-line-strong); }
.st-radio input { accent-color: var(--c-primary); width: 16px; height: 16px; margin: 0; }
.st-radio:has(input:checked) { border-color: var(--c-accent); color: var(--c-text); }
.st-radio:has(input:focus-visible) { outline: 2px solid var(--c-accent); outline-offset: 2px; }
select.st-input { width: 100%; }
.st-textarea { display: block; width: 100%; min-height: 104px; padding: 12px var(--s-2); resize: vertical; line-height: 24px; }
.st-counter { margin-top: 4px; font-size: 12px; color: var(--c-dim); text-align: right; }
.st-counter[data-full] { color: #F2A6A8; }
.st-turnstile { min-height: 65px; }
.st-form-actions .btn { cursor: pointer; }
.st-form-actions .btn:disabled { opacity: 0.6; cursor: progress; }
.st-error { padding: var(--s-3); color: var(--c-muted); }

@media (max-width: 860px) {
  .st-cards { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .st-months { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .st-stats-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .st-svc-head { flex-direction: column; }
}
@media (max-width: 640px) {
  .st-months { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .st-stats-3 { grid-template-columns: minmax(0, 1fr); }
  .st-hours-legend { gap: 1px; }
  .st-hours-legend span:not(:nth-child(6n+1)) { visibility: hidden; }
  .st-hours-legend span:last-child { visibility: visible; }
  .status-page main { padding-block: var(--s-4) var(--s-10); }
  .st-banner { flex-direction: column; align-items: flex-start; }
  .st-banner-title { font-size: 20px; line-height: 28px; }
  .st-blocks { gap: 1px; height: 32px; }
  .st-group-head { flex-wrap: wrap; }
  .st-group-meta { margin-left: 24px; width: 100%; }
  .st-card-sub { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
  .st-chev, .st-block, .st-card { transition: none; }
}
