/*
 * Sayli status page — "Signal".
 * A monochrome instrument for a voice product. Uptime history reads as an audio
 * waveform, not generic blocks. A live pulse breathes in the hero. The whole
 * canvas is tinted by the current state. Built on the app's design tokens; the
 * only added hues are the status semantics below, used as glow accents.
 */

/* ── Status semantics ── */
:root {
  --st-operational: var(--win);
  --st-degraded: #e0b341;
  --st-down: var(--error);
  --st-maintenance: #7f9cba;
  --st-none: var(--ink-faint);
  /* the current overall accent, re-pointed per state by JS on <body data-state> */
  --accent-state: var(--st-operational);
}
:root[data-theme="light"] {
  --st-degraded: #b7791f;
  --st-maintenance: #5b7794;
}
body[data-state="degraded"]    { --accent-state: var(--st-degraded); }
body[data-state="downtime"],
body[data-state="down"]        { --accent-state: var(--st-down); }
body[data-state="maintenance"] { --accent-state: var(--st-maintenance); }

[data-status="operational"] { --dot: var(--st-operational); }
[data-status="degraded"]    { --dot: var(--st-degraded); }
[data-status="downtime"],
[data-status="down"]        { --dot: var(--st-down); }
[data-status="maintenance"] { --dot: var(--st-maintenance); }
[data-status="not_monitored"],
[data-status="no_data"],
[data-status="unknown"]     { --dot: var(--st-none); }

/* ── Reset / base ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-canvas);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--type-body);
  font-weight: var(--weight-regular);
  line-height: var(--leading-body);
  letter-spacing: -0.005em;
  font-feature-settings: "kern", "ss01", "cv11", "tnum" 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background var(--dur-slow) var(--ease), color var(--dur-base) var(--ease);
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent-glow); outline-offset: 3px; border-radius: var(--radius-sm); }

.mono {
  font-family: var(--font-code);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

/* ── Ambient atmosphere: state-tinted aurora + fine grain ── */
.aura {
  position: fixed;
  inset: -25%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(38% 40% at 22% 12%, rgba(255, 255, 255, 0.055), transparent 70%),
    radial-gradient(34% 44% at 84% 20%, rgba(255, 255, 255, 0.04), transparent 72%),
    radial-gradient(54% 48% at 58% 108%, color-mix(in srgb, var(--accent-state) 22%, transparent), transparent 68%);
  filter: blur(40px) saturate(120%);
  opacity: 0.75;
  animation: drift 46s var(--ease) infinite alternate;
  transition: background var(--dur-slow) var(--ease);
}
.grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.04;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}
:root[data-theme="light"] .grain { opacity: 0.06; mix-blend-mode: multiply; }
:root[data-theme="light"] .aura { opacity: 0.5; }

.page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-7);
}

/* #app is <main>; its sections (hero, services, incidents) need the same
   deliberate rhythm as the rest of the column, or the section labels glue to
   the block above them. */
#app {
  display: flex;
  flex-direction: column;
  gap: var(--space-7);
}

/* ── Masthead ── */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: inline-flex; align-items: center; gap: 9px; }
.brand-mark { display: inline-flex; width: 22px; height: 22px; color: var(--ink); filter: drop-shadow(0 0 14px rgba(255, 255, 255, 0.1)); }
:root[data-theme="light"] .brand-mark { filter: none; }
.brand-mark svg { width: 100%; height: 100%; }
.brand-word {
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  font-size: 20px;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.masthead-right { display: inline-flex; align-items: center; gap: var(--space-2); }
.ghost-link {
  font-family: var(--font-code);
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--ink-quiet);
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.ghost-link:hover { color: var(--ink); background: var(--tintw-06); }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  background: var(--tintw-06);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  color: var(--ink-muted);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.theme-toggle:hover { background: var(--tintw-10); color: var(--ink); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ── Hero ── */
.hero { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-4) 0 0; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-code);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-quiet);
}
.eyebrow::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-state);
  box-shadow: 0 0 10px 1px color-mix(in srgb, var(--accent-state) 70%, transparent);
  animation: breathe 2.6s var(--ease-settle) infinite;
}
.headline {
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  font-size: clamp(38px, 8vw, 62px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  max-width: 15ch;
}
.headline .accent { color: var(--accent-state); }
.hero-sub {
  font-family: var(--font-code);
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--ink-quiet);
  display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.hero-sub .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-faint); }

/* live signal pulse — a calm equalizer that breathes when operational */
.pulse {
  display: flex; align-items: center; gap: 3px;
  height: 40px; margin-top: var(--space-3);
  --amp: 0.32;
}
body[data-state="degraded"] .pulse { --amp: 0.6; }
body[data-state="downtime"] .pulse,
body[data-state="down"] .pulse { --amp: 0.85; }
.pulse .p {
  flex: 1 1 0; min-width: 0;
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent-state) 78%, transparent), color-mix(in srgb, var(--accent-state) 30%, transparent));
  transform: scaleY(var(--rest, 0.14));
  transform-origin: center;
  animation: pulse-bar 2.8s var(--ease-settle) infinite;
  animation-delay: var(--d, 0ms);
  opacity: 0.9;
}

.announcement {
  padding: var(--space-3) var(--space-4);
  background: var(--tintw-04);
  border: 1px solid var(--hairline);
  border-left: 2px solid var(--accent-state);
  border-radius: var(--radius-lg);
  font-size: var(--type-caption);
  color: var(--ink-muted);
}

/* ── Services (2: sayli.ai / api.sayli.ai) ── */
.services { display: flex; flex-direction: column; gap: var(--space-4); }
.section-label {
  font-family: var(--font-code);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: calc(-1 * var(--space-2));
}
.service {
  position: relative;
  padding: var(--space-5);
  background: var(--bg-tile);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft), var(--highlight-top);
  overflow: hidden;
  transition: border-color var(--dur-fast) var(--ease);
}
.service::after { content: ""; position: absolute; inset: 0; background: var(--glass-sheen); pointer-events: none; }
.service:hover { border-color: var(--hairline-strong); }

.service-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); position: relative; z-index: 1; }
.service-id { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.status-dot {
  flex: 0 0 auto;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--dot, var(--st-none));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--dot, var(--st-none)) 14%, transparent),
              0 0 14px 1px color-mix(in srgb, var(--dot, var(--st-none)) 55%, transparent);
}
.service-name { font-family: var(--font-display); font-size: var(--type-title-sm); font-weight: var(--weight-semibold); letter-spacing: -0.02em; }
.service-explain { display: block; font-family: var(--font-code); font-size: 11px; letter-spacing: 0.03em; text-transform: uppercase; color: var(--ink-quiet); margin-top: 4px; }
.service-meta { text-align: right; flex: 0 0 auto; }
.status-label { display: block; font-size: var(--type-caption); font-weight: var(--weight-medium); color: var(--dot, var(--ink-muted)); }
.uptime-pct { display: block; font-family: var(--font-code); font-variant-numeric: tabular-nums; font-size: var(--type-title); color: var(--ink); margin-top: 2px; }

/* ── Uptime as an audio waveform (mirrored bars around a center line) ── */
.wave { position: relative; z-index: 1; margin-top: var(--space-5); }
.wave-bars {
  display: flex; align-items: center; gap: 2px;
  height: 58px;
}
.wb {
  flex: 1 1 0; min-width: 0;
  height: var(--h, 30%);
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, color-mix(in srgb, var(--dot, var(--st-none)) 82%, transparent), color-mix(in srgb, var(--dot, var(--st-none)) 34%, transparent));
  transform: scaleY(0);
  transform-origin: center;
  animation: wb-in var(--dur-base) var(--ease) forwards;
  animation-delay: var(--d, 0ms);
  transition: filter var(--dur-fast) var(--ease);
  cursor: default;
}
.wb:hover { filter: brightness(1.4); }
.wave-legend {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: var(--space-3);
  font-family: var(--font-code);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.wave-legend .mid { color: var(--ink-quiet); }

/* ── Incidents ── */
.incidents { display: flex; flex-direction: column; gap: var(--space-3); }
.incidents-title {
  font-family: var(--font-code);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: var(--space-1);
}
.incident {
  padding: var(--space-4) var(--space-5);
  background: var(--bg-tile);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
}
.incident-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.incident-title { font-family: var(--font-display); font-size: var(--type-title); font-weight: var(--weight-medium); letter-spacing: -0.01em; }
.incident-when { font-family: var(--font-code); font-size: 10px; letter-spacing: 0.04em; color: var(--ink-faint); white-space: nowrap; }
.incident-badge {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 5px;
  font-family: var(--font-code); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--dot, var(--ink-quiet));
}
.incident-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--dot, var(--ink-quiet)); box-shadow: 0 0 8px 1px color-mix(in srgb, var(--dot, var(--ink-quiet)) 55%, transparent); }
.incident-updates { margin-top: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); border-left: 1px solid var(--hairline); padding-left: var(--space-4); }
.update { position: relative; }
.update::before { content: ""; position: absolute; left: calc(-1 * var(--space-4) - 3.5px); top: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-faint); }
.update-msg { font-size: var(--type-caption); color: var(--ink-muted); }
.update-time { display: block; margin-top: 2px; font-family: var(--font-code); font-size: 10px; letter-spacing: 0.04em; color: var(--ink-faint); }
.empty {
  padding: var(--space-6);
  text-align: center;
  color: var(--ink-quiet);
  font-size: var(--type-caption);
  background: var(--tintw-03);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
}
.empty strong { display: block; color: var(--ink); font-family: var(--font-display); font-weight: var(--weight-medium); margin-bottom: 3px; }

/* ── States ── */
.state { padding: var(--space-8) var(--space-6); text-align: center; color: var(--ink-quiet); font-size: var(--type-caption); }
.state .spinner {
  width: 22px; height: 22px; margin: 0 auto var(--space-3);
  border: 2px solid var(--tintw-12); border-top-color: var(--ink-muted); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.state.error strong { display: block; color: var(--ink); font-family: var(--font-display); font-weight: var(--weight-medium); margin-bottom: 4px; }
.retry {
  margin-top: var(--space-4); height: 38px; padding: 0 var(--space-5);
  background: var(--ink); color: var(--on-accent);
  font-family: var(--font-ui); font-size: var(--type-caption); font-weight: var(--weight-semibold);
  border: none; border-radius: var(--radius-button); cursor: pointer;
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.retry:hover { opacity: 0.92; }
.retry:active { transform: scale(0.985); }

/* ── Footer ── */
.foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  flex-wrap: wrap;
  padding-top: var(--space-5);
  border-top: 1px solid var(--hairline);
  font-family: var(--font-code);
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--ink-quiet);
}
.foot a { color: var(--ink-muted); }
.foot a:hover { color: var(--ink); }
.foot-meta { color: var(--ink-faint); }

/* ── Tooltip ── */
#tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  padding: 7px 10px;
  background: var(--bg-glass-solid);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-glass);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  font-family: var(--font-code); font-size: 10px; line-height: 1.5; letter-spacing: 0.03em;
  color: var(--ink);
  opacity: 0; transform: translateY(4px);
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  white-space: nowrap;
}
#tooltip.show { opacity: 1; transform: translateY(0); }
#tooltip .tt-day { color: var(--ink-quiet); }
#tooltip .tt-status { text-transform: uppercase; color: var(--dot, var(--ink)); }

/* ── Entrance ── */
.reveal { opacity: 0; animation: stage-in var(--dur-slow) var(--ease) forwards; animation-delay: var(--rd, 0ms); }

@keyframes stage-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes wb-in { to { transform: scaleY(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }
@keyframes drift {
  0% { transform: translate3d(-3%, -2%, 0) scale(1); }
  100% { transform: translate3d(3%, 2%, 0) scale(1.08); }
}
@keyframes pulse-bar {
  0%, 100% { transform: scaleY(var(--rest, 0.14)); opacity: 0.7; }
  50% { transform: scaleY(calc(var(--rest, 0.14) + var(--amp))); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal, .wb { animation: none; opacity: 1; transform: none; }
  .aura, .eyebrow::before, .state .spinner { animation: none; }
  .pulse .p { animation: none; transform: scaleY(var(--rest, 0.3)); }
}

/* ── Responsive ── */
@media (max-width: 560px) {
  .page { padding: var(--space-5) var(--space-4) var(--space-7); gap: var(--space-6); }
  #app { gap: var(--space-6); }
  .service { padding: var(--space-4); }
  .service-head { gap: var(--space-3); }
  .wave-bars { height: 48px; }
  .pulse { height: 32px; }
}
