/* ---------------------------------------------------------------------------
 * Rewst Status hub.
 *
 * Visual language: dark, minimal, technical. Borrows from the rewst-app
 * Storybook palette (chillTeal as brand accent; blueGrey for surface chrome).
 * Light mode flips surfaces but keeps the same accent + status semantics.
 * --------------------------------------------------------------------------- */

:root {
  /* Rewst palette — sourced from packages/app/src/storybook/constants/muiColors.ts */
  --rewst-teal-300: #71cdce;
  --rewst-teal-500: #2bb5b6;
  --rewst-teal-700: #1f8181;

  --rewst-orange-500: #f9a100;
  --rewst-orange-400: #fab433;

  --rewst-green-500: #4caf50;
  --rewst-green-400: #70bf73;

  --rewst-red-500: #f75b58;
  --rewst-red-600: #e15350;

  --rewst-bluegrey-50: #f8fafc;
  --rewst-bluegrey-200: #e2e8f0;
  --rewst-bluegrey-300: #cbd5e1;
  --rewst-bluegrey-400: #94a3b8;
  --rewst-bluegrey-500: #64748b;
  --rewst-bluegrey-700: #334155;
  --rewst-bluegrey-800: #1e293b;
  --rewst-bluegrey-900: #0f172a;
  --rewst-bluegrey-950: #020617;

  /* Semantic tokens — switch values in @media (prefers-color-scheme: light) below */
  --bg: var(--rewst-bluegrey-950);
  --bg-soft: var(--rewst-bluegrey-900);
  --surface: var(--rewst-bluegrey-800);
  --surface-hover: #243349;
  --border: var(--rewst-bluegrey-700);
  --border-strong: #3f4d65;
  --text: var(--rewst-bluegrey-50);
  --text-muted: var(--rewst-bluegrey-400);
  --text-faint: var(--rewst-bluegrey-500);
  --accent: var(--rewst-teal-500);
  --accent-hover: var(--rewst-teal-300);

  --status-green: var(--rewst-green-500);
  --status-yellow: var(--rewst-orange-500);
  --status-red: var(--rewst-red-500);
  --status-gray: var(--rewst-bluegrey-500);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-soft: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 12px 32px rgba(0, 0, 0, 0.25);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(43, 181, 182, 0.10), transparent 60%),
    var(--bg);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.6);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
}

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

.brand img {
  display: block;
  /* Horizontal rewst logo (mascot + wordmark) — 171×69 viewBox.
   * Height-only sizing so the wordmark stays legible without distortion. */
  height: 36px;
  width: auto;
}

/* ---------- Content ---------- */

.content {
  flex: 1 0 auto;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 4rem 1.5rem 3rem;
}

.hero {
  margin-bottom: 2.5rem;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 0.5rem;
}

.hero p {
  color: var(--text-muted);
  margin: 0;
  font-size: 1rem;
}

/* ---------- Region grid ---------- */

.region-grid {
  display: grid;
  /* 4 cards × ~210px + gaps fits within the 920px content max-width on
   * desktop. Auto-fit + minmax(200px,1fr) lets it gracefully wrap on
   * narrower viewports without forcing a fixed column count. */
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.region-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  min-height: 130px;
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text);
  position: relative;
  overflow: hidden;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.region-card::after {
  /* Thin accent edge that lights up on hover */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px transparent;
  transition: box-shadow 140ms ease;
}

.region-card:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.region-card:hover::after {
  box-shadow: inset 0 0 0 1px rgba(43, 181, 182, 0.5);
}

.region-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.region-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.region-app {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.region-label {
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.005em;
}

.region-status {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
}

.status-text {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  color: var(--text-muted);
}

/* ---------- Status dot ---------- */

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--status-gray);
  flex-shrink: 0;
  transition: box-shadow 200ms ease, background 200ms ease;
}

.status-dot[data-status="operational"] {
  background: var(--status-green);
  box-shadow:
    0 0 0 3px rgba(76, 175, 80, 0.16),
    0 0 14px 2px rgba(76, 175, 80, 0.55);
  animation: glow-green 2.4s ease-in-out infinite;
}

.status-dot[data-status="degraded"] {
  background: var(--status-yellow);
  box-shadow:
    0 0 0 3px rgba(249, 161, 0, 0.18),
    0 0 14px 2px rgba(249, 161, 0, 0.55);
  animation: glow-yellow 2s ease-in-out infinite;
}

.status-dot[data-status="outage"] {
  background: var(--status-red);
  box-shadow:
    0 0 0 3px rgba(247, 91, 88, 0.22),
    0 0 14px 2px rgba(247, 91, 88, 0.6);
  animation: glow-red 1.4s ease-in-out infinite;
}

.status-dot[data-status="loading"] {
  background: var(--status-gray);
  animation: pulse 1.4s ease-in-out infinite;
}

.status-dot[data-status="unknown"] { background: var(--status-gray); }

@keyframes pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

@keyframes glow-green {
  0%, 100% {
    box-shadow:
      0 0 0 3px rgba(76, 175, 80, 0.16),
      0 0 10px 2px rgba(76, 175, 80, 0.45);
  }
  50% {
    box-shadow:
      0 0 0 4px rgba(76, 175, 80, 0.26),
      0 0 18px 4px rgba(76, 175, 80, 0.7);
  }
}

@keyframes glow-yellow {
  0%, 100% {
    box-shadow:
      0 0 0 3px rgba(249, 161, 0, 0.18),
      0 0 10px 2px rgba(249, 161, 0, 0.45);
  }
  50% {
    box-shadow:
      0 0 0 4px rgba(249, 161, 0, 0.28),
      0 0 18px 4px rgba(249, 161, 0, 0.7);
  }
}

@keyframes glow-red {
  0%, 100% {
    box-shadow:
      0 0 0 3px rgba(247, 91, 88, 0.22),
      0 0 12px 2px rgba(247, 91, 88, 0.55);
  }
  50% {
    box-shadow:
      0 0 0 5px rgba(247, 91, 88, 0.34),
      0 0 22px 5px rgba(247, 91, 88, 0.8);
  }
}

/* status-text follows the dot's color when active */
.status-dot[data-status="operational"] + .status-text,
.region-card:has(.status-dot[data-status="operational"]) .status-text {
  color: var(--status-green);
}

.status-dot[data-status="degraded"] + .status-text,
.region-card:has(.status-dot[data-status="degraded"]) .status-text {
  color: var(--status-yellow);
}

.status-dot[data-status="outage"] + .status-text,
.region-card:has(.status-dot[data-status="outage"]) .status-text {
  color: var(--status-red);
}

/* ---------- Footer ---------- */

.site-footer {
  padding: 2rem 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent-hover);
}

/* ---------- Light mode ---------- */

@media (prefers-color-scheme: light) {
  :root {
    --bg: var(--rewst-bluegrey-50);
    --bg-soft: #ffffff;
    --surface: #ffffff;
    --surface-hover: var(--rewst-bluegrey-50);
    --border: var(--rewst-bluegrey-200);
    --border-strong: var(--rewst-bluegrey-300);
    --text: var(--rewst-bluegrey-900);
    --text-muted: var(--rewst-bluegrey-500);
    --text-faint: var(--rewst-bluegrey-400);
    --shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 32px rgba(15, 23, 42, 0.06);
  }

  body {
    background:
      radial-gradient(ellipse 80% 60% at 50% -10%, rgba(43, 181, 182, 0.10), transparent 60%),
      var(--bg);
  }

  .topbar {
    background: rgba(255, 255, 255, 0.85);
  }

  .brand img {
    filter: none;
  }
}

/* ---------- Mobile ---------- */

@media (max-width: 540px) {
  .topbar { padding: 1rem 1.25rem; }
  .brand img { height: 28px; }
  .content { padding: 2.5rem 1.25rem; }
  .hero h1 { font-size: 1.6rem; }
  .region-grid { grid-template-columns: 1fr; }
}
