/* ─── Design Tokens ──────────────────────────────────────────────────────── */
:root {
  --font-display: 'Syne', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* Status colors — same in both themes */
  --c-up:        #22c55e;
  --c-up-dim:    #16a34a40;
  --c-degraded:  #f97316;
  --c-degraded-dim: #f9731630;
  --c-down:      #ef4444;
  --c-down-dim:  #ef444430;
  --c-nodata:    #3f3f46;

  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  --transition: 180ms ease;
}

/* ─── Dark Theme ─────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:           #09090b;
  --bg-card:      #111113;
  --bg-card-2:    #18181b;
  --border:       #27272a;
  --border-hi:    #3f3f46;
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted:   #52525b;
  --accent:       #6ee7b7;
  --accent-dim:   #6ee7b720;
  --grid-color:   rgba(255,255,255,0.025);
  --shadow:       0 4px 32px rgba(0,0,0,0.6);
  --shadow-card:  0 2px 16px rgba(0,0,0,0.4);
}

/* ─── Light Theme ────────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:           #f4f4f5;
  --bg-card:      #ffffff;
  --bg-card-2:    #f8f8f9;
  --border:       #e4e4e7;
  --border-hi:    #d4d4d8;
  --text-primary: #09090b;
  --text-secondary: #52525b;
  --text-muted:   #a1a1aa;
  --accent:       #059669;
  --accent-dim:   #05966920;
  --grid-color:   rgba(0,0,0,0.04);
  --shadow:       0 4px 32px rgba(0,0,0,0.08);
  --shadow-card:  0 2px 12px rgba(0,0,0,0.06);
}

/* ─── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-display);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}

/* ─── Background Grid ────────────────────────────────────────────────────── */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

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

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition);
}

.brand-dot:nth-child(1) { background: var(--c-down); }
.brand-dot:nth-child(2) { background: var(--c-degraded); animation: pulse-dot 2s ease-in-out infinite; }
.brand-dot:nth-child(3) { background: var(--c-up); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.last-updated {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: border-color var(--transition), background var(--transition), transform 80ms;
  color: var(--text-secondary);
}

.theme-toggle:hover {
  border-color: var(--border-hi);
  transform: scale(1.05);
}

/* ─── Main Layout ────────────────────────────────────────────────────────── */
.main {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ─── Hero ───────────────────────────────────────────────────────────────── */
.hero {
  padding: 56px 0 40px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.hero-title {
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text-primary);
}

.hero-sub {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.overall-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 4px;
  transition: all var(--transition);
}

.overall-badge.all-up {
  border-color: var(--c-up);
  background: var(--c-up-dim);
  color: var(--c-up);
}
.overall-badge.has-degraded {
  border-color: var(--c-degraded);
  background: var(--c-degraded-dim);
  color: var(--c-degraded);
}
.overall-badge.has-down {
  border-color: var(--c-down);
  background: var(--c-down-dim);
  color: var(--c-down);
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* ─── Legend ─────────────────────────────────────────────────────────────── */
.timeline-legend {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.legend-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.legend-items {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.pill-sample {
  display: inline-block;
  width: 20px;
  height: 10px;
  border-radius: 3px;
}
.pill-sample.up       { background: var(--c-up); }
.pill-sample.degraded { background: var(--c-degraded); }
.pill-sample.down     { background: var(--c-down); }
.pill-sample.no-data  { background: var(--c-nodata); }

/* ─── Servers Grid ───────────────────────────────────────────────────────── */
.servers-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ─── Server Card ────────────────────────────────────────────────────────── */
.server-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition), transform 120ms ease;
  animation: card-in 300ms ease both;
}

.server-card:hover {
  border-color: var(--border-hi);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.card-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.server-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.server-icon svg {
  width: 18px;
  height: 18px;
  stroke: var(--text-secondary);
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.server-info {
  min-width: 0;
}

.server-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.server-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: 0.02em;
}

.card-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.uptime-stat {
  text-align: right;
}

.uptime-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1;
}

.uptime-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.status-pill {
  padding: 4px 10px;
  border-radius: 100px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.status-pill.up       { background: var(--c-up-dim); color: var(--c-up); border-color: var(--c-up); }
.status-pill.degraded { background: var(--c-degraded-dim); color: var(--c-degraded); border-color: var(--c-degraded); }
.status-pill.down     { background: var(--c-down-dim); color: var(--c-down); border-color: var(--c-down); }
.status-pill.no-data  { background: transparent; color: var(--text-muted); border-color: var(--border); }

/* ─── Timeline ───────────────────────────────────────────────────────────── */
.timeline-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.timeline-bar {
  display: flex;
  gap: 2px;
  height: 28px;
  align-items: stretch;
}

.pill {
  flex: 1;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  transition: transform 80ms ease, filter 80ms ease;
  min-width: 0;
}

.pill:hover {
  transform: scaleY(1.15);
  filter: brightness(1.25);
  z-index: 10;
}

.pill.up       { background: var(--c-up); }
.pill.degraded { background: var(--c-degraded); }
.pill.down     { background: var(--c-down); }
.pill.no-data  { background: var(--c-nodata); }

/* ─── Tooltip ────────────────────────────────────────────────────────────── */
.tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
  min-width: 160px;
}

.tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.tooltip-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.tooltip-status {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.tooltip-status.up       { color: var(--c-up); }
.tooltip-status.degraded { color: var(--c-degraded); }
.tooltip-status.down     { color: var(--c-down); }
.tooltip-status.no-data  { color: var(--text-muted); }

.tooltip-latency {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ─── Loading State ──────────────────────────────────────────────────────── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  gap: 16px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 13px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Empty State ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-muted);
}

.empty-state h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.empty-state p {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  margin-top: 60px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.footer-sep { color: var(--border-hi); }

.footer-link {
  color: var(--accent);
  text-decoration: none;
  transition: opacity var(--transition);
}
.footer-link:hover { opacity: 0.75; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .header-inner { padding: 0 16px; }
  .last-updated { display: none; }
  .main { padding: 0 16px 60px; }
  .hero { padding: 36px 0 28px; }
  .server-card { padding: 16px; }
  .card-right { gap: 10px; }
  .uptime-value { font-size: 15px; }
  .timeline-bar { height: 22px; gap: 1.5px; }
  .pill { border-radius: 2px; }
}
