/* Palette and layout follow grub's own static "temporarily unavailable" page
   (grub/frontend/src/grub-static-pages/index.html). */
:root {
  --bg-1: #F1F6F7;
  --bg-2: #E4EFF2;
  --ink-1: #0E0E0E;
  --ink-2: #5F6063;
  --card: #FFFFFF;
  --line: #E4EAEC;
  --shadow: 0 24px 60px rgba(1, 51, 69, 0.16);

  --up: #12805C;
  --up-tint: rgba(18, 128, 92, 0.12);
  --down: #D92D20;
  --down-tint: rgba(217, 45, 32, 0.12);
  --unknown: #8A8C90;
  --unknown-tint: rgba(138, 140, 144, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Public Sans", "Trebuchet MS", "Gill Sans", "Calibri", sans-serif;
  color: var(--ink-1);
  background:
    radial-gradient(1200px 600px at 10% 0%, #FFFFFF 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 10%, #D3E5E9 0%, transparent 55%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.card {
  width: min(640px, 100%);
  background: var(--card);
  border-radius: 24px;
  padding: 40px 36px 28px;
  box-shadow: var(--shadow);
}

header {
  margin-bottom: 28px;
}

/* The logo is the page heading */
h1 {
  margin: 0;
}

.logo {
  display: block;
  width: 120px;
  height: auto;
}

p {
  margin: 0;
  line-height: 1.5;
}

/* State colours: every element with data-health sets --state/--state-tint for its children */
[data-health="up"] {
  --state: var(--up);
  --state-tint: var(--up-tint);
}

[data-health="down"] {
  --state: var(--down);
  --state-tint: var(--down-tint);
}

[data-health="unknown"],
[data-health="loading"] {
  --state: var(--unknown);
  --state-tint: var(--unknown-tint);
}

.dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--state);
}

[data-health="down"] .dot {
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 var(--down-tint);
  }
  50% {
    box-shadow: 0 0 0 7px var(--down-tint);
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-health="down"] .dot {
    animation: none;
  }
}

.summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: 16px;
  background: var(--state-tint);
  font-size: 1.15rem;
  font-weight: 600;
}

.monitors {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
}

.monitor {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 12px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

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

.monitor-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.badge {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--state-tint);
  color: var(--state);
  font-size: 0.875rem;
  font-weight: 600;
}

/* Grey on its light tint is too faint to read */
[data-health="unknown"] .badge {
  color: var(--ink-2);
}

.detail {
  grid-column: 1 / -1;
  padding-left: 20px;
  font-size: 0.875rem;
  color: var(--ink-2);
}

.notice {
  margin-top: 16px;
  color: var(--ink-2);
}

footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 20px;
  font-size: 0.8125rem;
  color: var(--ink-2);
}

.next-check {
  position: relative;
  display: flex;
  margin-left: auto;
  /* A larger target than the ring itself */
  padding: 4px;
  border-radius: 50%;
  cursor: default;
}

.next-check:focus-visible {
  outline: 2px solid var(--ink-2);
  outline-offset: 1px;
}

/* The countdown text, shown above the ring on hover or focus (also a tap on touch screens) */
.tooltip {
  position: absolute;
  right: -4px;
  bottom: calc(100% + 6px);
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--ink-1);
  color: var(--card);
  /* Keeps the text from shifting as the countdown digits change */
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.next-check:hover .tooltip,
.next-check:focus .tooltip {
  opacity: 1;
}

.next-check[hidden] {
  display: none;
}

.ring {
  width: 16px;
  height: 16px;
  /* Start filling at 12 o'clock */
  transform: rotate(-90deg);
}

.ring circle {
  fill: none;
  stroke-width: 3;
}

.ring-track {
  stroke: var(--line);
}

/* Filled by app.js through stroke-dashoffset: 100 is empty, 0 is full */
.ring-progress {
  stroke: var(--ink-2);
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

/* While a check is due, app.js shows a quarter arc that spins until the result is in */
.next-check[data-state="checking"] .ring {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(-90deg);
  }
  to {
    transform: rotate(270deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .next-check[data-state="checking"] .ring {
    animation-duration: 3s;
  }
}

@media (max-width: 540px) {
  .card {
    padding: 32px 20px 24px;
  }

  .logo {
    width: 100px;
  }
}
