/* /status only. The class names here are a contract with status.js, which builds
   the cards in JS: .svc[data-state] > .svc-main(.svc-left > .state-ic/.name/.ping,
   .pct[.na|.bad], .svc-right > .bars > .bar[.up|.down], .scale, .caret)
   + .svc > .detail, plus .skel/.skel-lines/.skel-line.wNN, .error-card > button
   and .spinning on #refresh. Renaming a rule here silently unstyles the page. */

.status-banner {
  display: flex; align-items: center; gap: .9rem;
  padding: 1.05rem 1.2rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card);
}
.status-banner[data-state="up"] { border-color: rgba(34, 229, 132, .3); }
.status-banner[data-state="down"] { border-color: rgba(240, 82, 82, .4); }
.status-banner .bdot { width: 10px; height: 10px; border-radius: 50%; background: #71717a; flex: none; }
.status-banner[data-state="up"] .bdot { background: var(--up); animation: pulse-up 2.2s ease-out infinite; }
.status-banner[data-state="down"] .bdot { background: var(--down); animation: pulse-down 2.2s ease-out infinite; }
.banner-text { display: grid; gap: .1rem; min-width: 0; }
.banner-text strong { font-size: 1.02rem; font-weight: 650; letter-spacing: -.01em; }
.banner-text span { font-size: .78rem; color: var(--faint); font-variant-numeric: tabular-nums; }

/* Reserve the height the finished cards take: the list is rendered after a fetch
   that averages ~1 s, and the old page shifted 0.376 CLS when it landed. */
.list { display: grid; gap: .7rem; margin-top: 1.1rem; min-height: 276px; }

/* .svc is a block with two children: the summary row and the hidden detail. */
.svc {
  display: block; min-height: 84px; padding: 1rem 1.15rem;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.svc:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.svc[aria-expanded="true"] { border-color: var(--line-strong); }
@media (hover: hover) and (pointer: fine) { .svc:hover { background: var(--card-hover); } }
.svc[data-state="down"] { border-color: rgba(240, 82, 82, .38); }

.svc-main { display: flex; align-items: center; gap: 1.1rem; }
.svc-left { display: flex; align-items: center; gap: .65rem; min-width: 0; flex: 1 1 auto; }
.svc-left .state-ic { width: 9px; height: 9px; border-radius: 50%; background: var(--nodata); flex: none; }
.svc[data-state="up"] .state-ic { background: var(--up); }
.svc[data-state="down"] .state-ic { background: var(--down); box-shadow: 0 0 7px rgba(240, 82, 82, .7); }
.svc[data-state="degraded"] .state-ic, .svc[data-state="nodata"] .state-ic { background: var(--warn); }
.svc-left .name { font-weight: 600; font-size: .96rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.svc-left .ping { font-family: var(--mono); font-size: .74rem; color: var(--faint); white-space: nowrap; }

.svc-main .pct { font-family: var(--mono); font-size: .8rem; color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.svc-main .pct.na { color: var(--faint); }
.svc-main .pct.bad { color: var(--down); }

.svc-right { display: grid; gap: .3rem; justify-items: end; flex: none; min-width: 0; }
.bars { display: flex; gap: 2px; justify-content: flex-end; overflow: hidden; }
.bars .bar { width: 4px; height: 22px; border-radius: 2px; background: var(--nodata); }
.bars .bar.up { background: color-mix(in srgb, var(--up) 72%, transparent); }
.bars .bar.down { background: var(--down); }
@media (hover: hover) and (pointer: fine) {
  .bars .bar:hover { outline: 1px solid rgba(255, 255, 255, .5); outline-offset: 1px; }
}
.scale { display: flex; justify-content: space-between; width: 100%; font-family: var(--mono); font-size: .64rem; color: var(--faint); }

/* Collapsed until status.js adds .open (it does that itself for any down service). */
.detail { display: none; margin-top: .9rem; padding-top: .7rem; border-top: 1px solid var(--line); font-size: .86rem; color: var(--muted); line-height: 1.6; }
.svc.open .detail { display: block; }
.detail dl { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: .25rem .8rem; margin: 0; }
.detail dt { color: var(--faint); font-family: var(--mono); font-size: .76rem; }
.detail dd { margin: 0; color: var(--muted); word-break: break-word; user-select: text; -webkit-user-select: text; }

/* 90-day rollup: one cell per UTC day, built from status_daily rather than the raw
   samples, so it reaches further back than the bars above it. */
.hist { margin-top: .85rem; }
.hist-head { display: flex; justify-content: space-between; gap: .8rem; font-family: var(--mono); font-size: .7rem; color: var(--faint); margin-bottom: .4rem; }
.hist-head b { color: var(--muted); font-weight: 600; }
.days { display: flex; gap: 1px; }
.days .day { flex: 1 1 0; min-width: 0; height: 18px; background: var(--nodata); }
.days .day:first-child { border-radius: 2px 0 0 2px; }
.days .day:last-child { border-radius: 0 2px 2px 0; }
.days .day.ok { background: color-mix(in srgb, var(--up) 72%, transparent); }
.days .day.part { background: color-mix(in srgb, var(--warn) 82%, transparent); }
.days .day.bad { background: var(--down); }
@media (hover: hover) and (pointer: fine) {
  .days .day:hover { outline: 1px solid rgba(255, 255, 255, .5); outline-offset: 1px; }
}

.caret { flex: none; width: 14px; height: 14px; color: var(--faint); transition: transform .15s ease; }
.svc.open .caret { transform: rotate(90deg); }

.skel { display: flex; align-items: center; gap: 1rem; min-height: 84px; padding: 1rem 1.15rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); pointer-events: none; }
.skel-lines { display: grid; gap: .45rem; flex: 1; }
.skel-line { height: 10px; border-radius: 5px; background: rgba(255, 255, 255, .07); animation: skel 1.4s ease-in-out infinite; }
.skel-line.w40 { width: 40%; }
.skel-line.w60 { width: 60%; }
.skel-line.w80 { width: 80%; }
@keyframes skel { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

.error-card { border: 1px solid rgba(240, 82, 82, .38); border-radius: var(--radius); background: rgba(240, 82, 82, .06); padding: 1.3rem 1.15rem; text-align: center; color: var(--muted); font-size: .9rem; }
.error-card button { margin-top: .9rem; background: none; border: 1px solid rgba(240, 82, 82, .5); border-radius: 999px; color: #fff; font: inherit; font-size: .8rem; padding: .45rem 1.1rem; cursor: pointer; touch-action: manipulation; }
@media (hover: hover) and (pointer: fine) { .error-card button:hover { background: rgba(240, 82, 82, .15); } }
.error-card button:active { background: rgba(240, 82, 82, .15); }

.toolbar { display: flex; align-items: center; gap: .9rem; margin-top: 1.2rem; }
.countdown { font-family: var(--mono); font-size: .76rem; color: var(--faint); font-variant-numeric: tabular-nums; }
#refresh[disabled] { opacity: .65; cursor: progress; }
/* status.js puts .spinning on the button itself, so the spinner is a pseudo
   element — there is no svg in the markup for it to rotate. */
#refresh.spinning::before {
  content: ""; display: inline-block; width: 10px; height: 10px;
  border: 2px solid rgba(255, 255, 255, .25); border-top-color: #fff; border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 620px) {
  .svc-main { flex-wrap: wrap; gap: .6rem 1.1rem; }
  .svc-right { justify-items: start; width: 100%; }
  .bars .bar { height: 20px; }
  .detail dl { grid-template-columns: 1fr; gap: .1rem 0; }
  .detail dd { margin-bottom: .5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .skel-line { animation: none; opacity: .8; }
  .svc { transition: none; }
  .caret { transition: none; }
  #refresh.spinning::before { animation: none; }
  .status-banner[data-state="up"] .bdot, .status-banner[data-state="down"] .bdot { animation: none; }
}
