/* Tamandua public status page: Pelican panel look, same tokens as the internal page. */

@font-face {
  font-family: "Finger Paint";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/finger-paint-latin-400-normal.woff2") format("woff2");
}

:root {
  --gray-200: #eedcf0;
  --gray-300: #e3c7e7;
  --gray-400: #ce9ed5;
  --gray-500: #b974c3;
  --gray-900: #5b3960;
  --gray-950: #38233b;
  --primary-400: #7c86ff;
  --primary-500: #615fff;
  --primary-600: #4f39f6;

  /* state colors (fills) */
  --ok: #00bba7;
  --ok-text: #00d5be;
  --lime: #9ae600;
  --warn: #fe9a00;
  --warn-text: #ffb900;
  --orange: #ff6900;
  --bad: #ff2056;
  --bad-text: #ff637e;
  --none: #ffffff1f;

  --ring: #ffffff1a;
  --ring-strong: #ffffff33;
  --fill: #ffffff0d;
  --fill-hover: #ffffff1a;

  --radius-xl: 0.75rem;
  --radius-lg: 0.5rem;
  --radius-md: 0.375rem;
  --shadow-sm: 0 1px 2px 0 #0000000d;

  --bg: var(--gray-950);
  --surface: var(--gray-900);
  --text: #fff;
  --tip-bg: #1f1321;

  --font: "Finger Paint", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

/* Light mode, chosen by theme.js (html[data-theme=light]). Text colors moved darker
   for >= 4.5:1 contrast on white. */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #fcf8fc;
  --surface: #ffffff;
  --text: #38233b;
  --ring: #38233b14;
  --ring-strong: #38233b29;
  --fill: #f8f1f9;
  --fill-hover: #eedcf0;
  --shadow-sm: 0 1px 2px 0 #38233b14;
  --gray-200: #6f4675;
  --gray-300: #6f4675;
  --gray-400: #8b5792;
  --gray-500: #a768b0;
  --ok-text: #00786f;
  --warn-text: #bb4d00;
  --bad-text: #c70036;
  --none: #38233b1f;
  --tip-bg: #38233b;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: 2rem 1.5rem 1.5rem;
}

.wrap { max-width: 56rem; margin: 0 auto; }
.muted { color: var(--gray-400); }
.small { font-size: 0.75rem; }

/* ---------- header ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
}
.brand { display: flex; align-items: center; gap: 0.75rem; }
.logo { height: 2.5rem; width: 2.5rem; border-radius: var(--radius-lg); }
.brand h1 { margin: 0; font-size: 1.5rem; font-weight: 400; letter-spacing: 0.01em; }
.brand h1 .sub { color: var(--gray-400); }

/* ---------- overall banner ---------- */
.overall {
  --c: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--ring), inset 0.3rem 0 0 var(--c);
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}
.overall::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 18%, transparent), transparent 70%);
  pointer-events: none;
}
.overall > * { position: relative; }
.overall.operational { --c: var(--ok); }
.overall.degraded { --c: var(--warn); }
.overall.partial_outage { --c: var(--orange); }
.overall.major_outage { --c: var(--bad); }
.overall.unknown, .overall.stale { --c: var(--gray-500); }

.overall-icon {
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 0.35rem color-mix(in srgb, var(--c) 22%, transparent),
    0 0 1.25rem color-mix(in srgb, var(--c) 60%, transparent);
  display: grid;
  place-items: center;
}
/* check mark / exclamation / question drawn with CSS, no images */
.overall-icon::after {
  content: "";
  display: block;
  width: 0.55rem;
  height: 1rem;
  border: solid #fff;
  border-width: 0 0.2rem 0.2rem 0;
  transform: translateY(-0.1rem) rotate(45deg);
}
.overall.degraded .overall-icon::after,
.overall.partial_outage .overall-icon::after,
.overall.major_outage .overall-icon::after {
  width: 0.22rem;
  height: 1.1rem;
  border: 0;
  transform: none;
  background: linear-gradient(#fff 0 68%, transparent 68% 80%, #fff 80%);
  border-radius: 0.1rem;
}
.overall.unknown .overall-icon::after,
.overall.stale .overall-icon::after {
  width: 0.9rem;
  height: 0.22rem;
  border: 0;
  transform: none;
  background: #fff;
  border-radius: 0.1rem;
}
.overall-text { min-width: 0; }
.overall h2 { margin: 0; font-size: 1.25rem; font-weight: 400; line-height: 1.3; }
.overall-sub { margin: 0.2rem 0 0; color: var(--gray-400); font-size: 0.75rem; }
.overall-sub:empty { display: none; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--ring);
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--ring);
}
.card-head h2 { margin: 0; font-size: 1.05rem; font-weight: 400; }

.range-30 { display: none; }

/* ---------- components ---------- */
.comp { padding: 1.25rem 1.5rem 1rem; border-bottom: 1px solid var(--ring); }
.comp-head {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.comp-name { margin: 0; font-size: 0.95rem; font-weight: 400; }
.comp-ms { font-family: var(--mono); font-size: 0.7rem; color: var(--gray-400); }
.comp-uptime { margin-left: auto; font-size: 0.75rem; color: var(--gray-300); white-space: nowrap; }
.comp-uptime b { font-weight: 400; font-family: var(--mono); font-size: 0.85rem; color: var(--text); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-md);
  font-size: 0.7rem;
  line-height: 1.5;
  white-space: nowrap;
  --c: var(--gray-500);
  --t: var(--gray-400);
  color: var(--t);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 32%, transparent);
}
.pill::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--c);
}
.pill.online { --c: var(--ok); --t: var(--ok-text); }
.pill.degraded { --c: var(--warn); --t: var(--warn-text); }
.pill.offline { --c: var(--bad); --t: var(--bad-text); }
.is-stale .pill { --c: var(--gray-500); --t: var(--gray-400); }
.is-stale .comp-ms { display: none; }

.bars {
  display: flex;
  gap: 2px;
  height: 2.125rem;
  align-items: stretch;
}
.bar {
  flex: 1 1 0;
  min-width: 2px;
  border-radius: 2px;
  background: var(--none);
  cursor: default;
  transition: transform 80ms ease, filter 80ms ease;
  outline: none;
}
.bar.u100, .bar-swatch.u100 { background: var(--ok); }
.bar.u995, .bar-swatch.u995 { background: var(--lime); }
.bar.u95, .bar-swatch.u95 { background: var(--warn); }
.bar.ulow, .bar-swatch.ulow { background: var(--bad); }
.bar.unone, .bar-swatch.unone { background: var(--none); }
.bar:hover, .bar.active { transform: scaleY(1.12); filter: brightness(1.15); }
.bar:focus-visible { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--primary-400); }

.bar-axis {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.68rem;
  color: var(--gray-400);
}
.bar-axis .line { flex: 1; height: 1px; background: var(--ring); }
.bar-axis .from-30 { display: none; }

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem 1rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.68rem;
  color: var(--gray-400);
  background: var(--fill);
}
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.bar-swatch { display: inline-block; width: 0.5rem; height: 0.75rem; border-radius: 2px; }

.empty { padding: 1.5rem; color: var(--gray-400); text-align: center; }

/* ---------- incidents ---------- */
.inc-day { padding: 1rem 1.5rem; border-bottom: 1px solid var(--ring); }
.inc-day:last-child { border-bottom: 0; }
.inc-date { margin: 0 0 0.625rem; font-size: 0.8rem; font-weight: 400; color: var(--gray-300); }
.inc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.inc {
  --c: var(--bad);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.25rem 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-lg);
  background: var(--fill);
  box-shadow: inset 0 0 0 1px var(--ring), inset 0.2rem 0 0 var(--c);
}
.inc.degraded { --c: var(--warn); }
.inc-mark { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--c); }
.inc-title { min-width: 0; }
.inc-title .what { color: var(--gray-400); }
.inc-dur { font-family: var(--mono); font-size: 0.75rem; color: var(--gray-300); white-space: nowrap; }
.inc-time { grid-column: 2 / -1; font-size: 0.7rem; color: var(--gray-400); }
.inc.ongoing .inc-dur { color: var(--bad-text); }
.inc.ongoing.degraded .inc-dur { color: var(--warn-text); }
.no-inc { display: flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 1.5rem; color: var(--gray-400); }
.no-inc::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--ok);
}

/* ---------- tooltip ---------- */
.tip {
  position: absolute;
  z-index: 10;
  min-width: 10rem;
  max-width: 15rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-lg);
  background: var(--tip-bg);
  color: #fff;
  box-shadow: 0 8px 24px #00000059, 0 0 0 1px #ffffff1a;
  font-size: 0.72rem;
  line-height: 1.45;
  pointer-events: none;
}
.tip .t-date { display: block; margin-bottom: 0.25rem; color: #e3c7e7; }
.tip .t-row { display: flex; justify-content: space-between; gap: 1rem; }
.tip .t-row b { font-weight: 400; font-family: var(--mono); }
.tip .t-up { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.15rem; }
.tip .t-up i { width: 0.5rem; height: 0.5rem; border-radius: 2px; flex: none; }

/* ---------- footer ---------- */
.foot {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  font-size: 0.7rem;
  text-align: center;
}
.foot .stale-note { color: var(--warn-text); }

/* ---------- theme switch (same as the internal page) ---------- */
.theme-switch {
  display: inline-flex;
  padding: 0.125rem;
  border-radius: var(--radius-lg);
  background: var(--fill);
  box-shadow: inset 0 0 0 1px var(--ring);
}
.theme-switch button {
  font-family: inherit;
  font-size: 0.7rem;
  color: var(--gray-400);
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  padding: 0.2rem 0.55rem;
  cursor: pointer;
}
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--primary-600); color: #fff; }
.theme-switch button:focus-visible { outline: 2px solid var(--primary-400); outline-offset: 1px; }

/* ---------- narrow screens: last 30 days ---------- */
@media (max-width: 40rem) {
  body { padding: 1.25rem 0.875rem; }
  .overall { padding: 1rem 1.125rem; gap: 0.875rem; }
  .overall h2 { font-size: 1.05rem; }
  .overall-icon { width: 1.875rem; height: 1.875rem; }
  .card-head, .comp, .inc-day, .legend { padding-left: 1rem; padding-right: 1rem; }
  .bar.old { display: none; }
  .bars { gap: 3px; }
  .range-90, .bar-axis .from-90 { display: none; }
  .range-30, .bar-axis .from-30 { display: inline; }
  .comp-ms, .comp-uptime .word { display: none; }
  .brand h1 { font-size: 1.3rem; }
  .legend { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .bar { transition: none; }
}
