/* Learny Status. Colors, radii and motion follow the ui-lab components used
   across Learny AI and Learny Code (see app/web/lab-ui.css). */

@font-face {
  font-family: "Google Sans";
  font-style: normal;
  font-weight: 100 1000;
  font-display: swap;
  src: url("/fonts/google-sans-flex-latin.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --background: #0a0a0a;
  --foreground: #ededed;
  --surface: #161616;
  --border: #262626;
  --muted: #8f8f8f;
  --operational: #3dd68c;
  --degraded: #ffc53d;
  --down: #e5484d;
  --paused: #8da4ef;
  --none: #262626;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --shadow-raised:
    0 0 0 1px oklch(1 0 0 / 0.08),
    0 1px 2px oklch(0 0 0 / 0.4),
    0 6px 16px -6px oklch(0 0 0 / 0.6);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--background);
  color: var(--foreground);
  font-family: "Google Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
p {
  margin: 0;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid oklch(0.95 0 0 / 0.45);
  outline-offset: 2px;
  border-radius: 6px;
}

.page {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 32px 16px 48px;
}

/* ------------------------------------------------------------------ Header */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 40px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand img {
  width: 32px;
  height: 32px;
}

.brand-muted {
  color: var(--muted);
  font-weight: 500;
}

.back-link {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 9999px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 150ms ease-out, scale 150ms ease-out;
}

.back-link:hover {
  background: var(--border);
}

.back-link:active {
  scale: 0.96;
}

/* ------------------------------------------------------------------ Overall */
.overall {
  --tone: var(--muted);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  border-radius: 22px;
  background: color-mix(in oklab, var(--tone) 9%, var(--background));
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--tone) 22%, transparent);
  transition: background-color 300ms var(--ease-out), box-shadow 300ms var(--ease-out);
}

.overall[data-state="operational"] { --tone: var(--operational); }
.overall[data-state="degraded"] { --tone: var(--degraded); }
.overall[data-state="down"] { --tone: var(--down); }
.overall[data-state="paused"] { --tone: var(--paused); }

.overall-mark {
  position: relative;
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--tone);
  transition: background-color 300ms var(--ease-out);
}

/* A slow ring for live states; nothing pulses while paused or unknown. */
.overall:is([data-state="operational"], [data-state="degraded"], [data-state="down"]) .overall-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--tone);
  animation: ping 2.4s var(--ease-out) infinite;
}

@keyframes ping {
  from { opacity: 0.55; scale: 1; }
  to { opacity: 0; scale: 2.6; }
}

.overall h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.overall p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 14px;
}

.overall[data-state="loading"] h1,
.overall[data-state="loading"] p {
  color: var(--muted);
}

/* ------------------------------------------------------------------ Components */
.components {
  margin-top: 40px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 12px;
  padding: 0 6px;
}

.section-head h2 {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--tone);
}

[data-state="operational"] { --tone: var(--operational); }
[data-state="degraded"] { --tone: var(--degraded); }
[data-state="down"] { --tone: var(--down); }
[data-state="paused"] { --tone: var(--paused); }
[data-state="none"],
[data-state="unknown"] { --tone: var(--none); }

.component-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.component {
  padding: 18px 20px 16px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.04);
}

.component-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.component-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.component-description {
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 11px;
  border-radius: 9999px;
  background: color-mix(in oklab, var(--tone) 13%, transparent);
  color: color-mix(in oklab, var(--tone) 80%, var(--foreground));
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 250ms var(--ease-out), color 250ms var(--ease-out);
}

.pill[data-state="unknown"] {
  --tone: var(--muted);
}

.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tone);
}

.component-since {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.bars {
  display: grid;
  grid-template-columns: repeat(90, minmax(0, 1fr));
  gap: 2px;
  height: 34px;
  margin-top: 14px;
}

.bar {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--tone);
  transform-origin: bottom;
  transition: opacity 150ms ease-out, scale 150ms var(--ease-out);
  animation: bar-in 420ms var(--ease-out) both;
  animation-delay: calc(var(--i) * 4ms);
}

.bar[data-state="none"] {
  background: color-mix(in oklab, var(--foreground) 7%, transparent);
}

@keyframes bar-in {
  from { scale: 1 0.3; opacity: 0; }
}

.bars:hover .bar {
  opacity: 0.55;
}

.bars .bar:hover {
  opacity: 1;
  scale: 1 1.12;
}

.bars-scale {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.bars-scale strong {
  color: var(--foreground);
  font-weight: 500;
}

.range-short {
  display: none;
}

/* Thirty days fit a phone; the uptime figure stays the 90-day one. */
@media (max-width: 560px) {
  .bars {
    grid-template-columns: repeat(30, minmax(0, 1fr));
    gap: 3px;
  }

  .bar:nth-child(-n + 60) {
    display: none;
  }

  .range-long {
    display: none;
  }

  .range-short {
    display: inline;
  }

  .overall {
    padding: 18px;
  }

  .component {
    padding: 16px 16px 14px;
  }
}

/* ------------------------------------------------------------------ Skeleton */
.component.is-skeleton {
  display: grid;
  gap: 10px;
  min-height: 132px;
}

.component.is-skeleton span {
  display: block;
  border-radius: 6px;
  background: linear-gradient(90deg,
    color-mix(in oklab, var(--foreground) 6%, transparent) 0%,
    color-mix(in oklab, var(--foreground) 11%, transparent) 50%,
    color-mix(in oklab, var(--foreground) 6%, transparent) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.8s linear infinite;
}

.component.is-skeleton span:nth-child(1) { width: 38%; height: 18px; }
.component.is-skeleton span:nth-child(2) { width: 24%; height: 12px; }
.component.is-skeleton span:nth-child(3) { width: 100%; height: 34px; margin-top: 8px; }

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

/* ------------------------------------------------------------------ Tooltip */
.bar-tip {
  position: fixed;
  z-index: 10;
  min-width: 150px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--background);
  box-shadow: var(--shadow-raised);
  font-size: 13px;
  pointer-events: none;
  transform-origin: bottom center;
  animation: tip-in 150ms var(--ease-out) both;
}

.bar-tip strong {
  display: block;
  font-weight: 500;
}

.bar-tip span {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  color: var(--muted);
}

.bar-tip span::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tone);
}

@keyframes tip-in {
  from { opacity: 0; scale: 0.96; }
}

/* ------------------------------------------------------------------ Footer */
.footer {
  display: grid;
  gap: 4px;
  margin-top: 32px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }

  .overall-mark::after {
    display: none;
  }
}
