/* Layout and components. Colours and fonts come exclusively from tokens.css. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0 auto;
  max-width: 72rem;
  padding: 0 1rem 3rem;
}

a {
  color: var(--color-link);
  text-decoration: none;
}

a:hover,
a:focus-visible {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.mono-label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0;
  overflow-wrap: anywhere;
}

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

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--color-border);
}

.wordmark {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  color: var(--color-text);
}

.wordmark span {
  color: var(--color-text-muted);
}

.topbar__nav {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
}

.pill {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
}

.pill--active {
  border-color: var(--color-text);
}

/* --- Banners and overall status ----------------------------------------- */

.banner {
  margin: 1.25rem 0 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  background: var(--color-bg-secondary);
}

.banner--warning {
  border-color: var(--color-warn);
}

.overall {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  margin: 1.5rem 0 2rem;
  padding: 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  background: var(--color-surface);
}

.overall__light {
  flex: none;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--color-unknown);
}

.overall--normal .overall__light {
  background: var(--color-ok);
  box-shadow: 0 0 2rem var(--color-ok);
}

.overall--degraded .overall__light {
  background: var(--color-warn);
  box-shadow: 0 0 2rem var(--color-warn);
}

.overall--incident .overall__light {
  background: var(--color-crit);
  box-shadow: 0 0 2rem var(--color-crit);
}

.overall__title {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  letter-spacing: -0.055em;
  line-height: 1;
  margin: 0 0 0.4rem;
}

.overall__text {
  margin: 0 0 0.5rem;
  color: var(--color-text-muted);
}

.section-label {
  margin: 0 0 1rem;
}

/* --- Tiles -------------------------------------------------------------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.tile {
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  background: var(--color-surface);
}

.tile__label {
  margin-bottom: 0.5rem;
}

.tile__value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.75rem;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin: 0 0 0.4rem;
  overflow-wrap: anywhere;
}

.tile__sub {
  margin: 0 0 0.3rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* --- Traffic light (never colour alone: icon + text) -------------------- */

.level {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.level__icon::before {
  display: inline-block;
  width: 1em;
  text-align: center;
}

.level--green { color: var(--color-ok); }
.level--green .level__icon::before { content: "●"; }
.level--yellow { color: var(--color-warn); }
.level--yellow .level__icon::before { content: "▲"; }
.level--red { color: var(--color-crit); }
.level--red .level__icon::before { content: "■"; }
.level--unknown { color: var(--color-unknown); }
.level--unknown .level__icon::before { content: "?"; }

/* --- Sections and metric list ------------------------------------------- */

.section {
  border-top: 1px solid var(--color-border);
  padding: 1.25rem 0;
}

.section > summary {
  cursor: pointer;
  list-style: none;
}

.section > summary::-webkit-details-marker {
  display: none;
}

.section > summary h2 {
  display: inline;
}

.metrics {
  margin: 1rem 0 0;
}

.metric {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.5rem 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}

.metric__title {
  font-weight: 500;
}

.metric__value {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-end;
  gap: 0.75rem;
  text-align: right;
}

.metric__number {
  font-family: var(--font-mono);
  font-weight: 700;
}

.metric--planned .metric__title,
.metric__planned,
.metric__empty {
  color: var(--color-text-muted);
}

.metric__info {
  display: inline;
}

.metric__source {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

.metric__info > summary {
  display: inline;
  cursor: pointer;
  list-style: none;
  color: var(--color-text-muted);
  margin-left: 0.25rem;
}

.metric__info > summary::-webkit-details-marker {
  display: none;
}

.metric__info p {
  margin: 0.4rem 0 0;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: left;
}

.data-table th,
.data-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

/* --- Event log timeline ------------------------------------------------- */

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  text-align: left;
}

.timeline__item {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 1rem;
  padding: 0 0 0.9rem 1.4rem;
  font-size: 0.9rem;
}

/* Vertical line connecting the dots. */
.timeline__item::before {
  content: "";
  position: absolute;
  left: 0.3rem;
  top: 0.9rem;
  bottom: 0;
  width: 1px;
  background: var(--color-border);
}

.timeline__item:last-child::before { display: none; }

.timeline__dot {
  position: absolute;
  left: 0;
  top: 0.3rem;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--color-link);
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent);
  color: var(--color-link);
}

.timeline__item--green .timeline__dot { background: var(--color-ok); color: var(--color-ok); }
.timeline__item--yellow .timeline__dot { background: var(--color-warn); color: var(--color-warn); }
.timeline__item--red .timeline__dot { background: var(--color-crit); color: var(--color-crit); }

.timeline__time { white-space: nowrap; padding-top: 0.1rem; }

@media (max-width: 40rem) {
  .timeline__item { grid-template-columns: 1fr; }
}

.events {
  margin-bottom: 2.5rem;
}

.events__intro {
  margin: 0 0 1.25rem;
  max-width: 48rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.events__more > summary {
  cursor: pointer;
  margin-bottom: 1rem;
  color: var(--color-link);
}

/* --- Charts ------------------------------------------------------------- */

.sparkline {
  height: 40px;
  margin-top: 0.4rem;
}

.metric__chart {
  grid-column: 1 / -1;
}

.metric__chart > summary {
  cursor: pointer;
  list-style: none;
  color: var(--color-link);
}

.metric__chart > summary::-webkit-details-marker {
  display: none;
}

.metric__chart > summary::before {
  content: "\25B8\00a0";
}

.metric__chart[open] > summary::before {
  content: "\25BE\00a0";
}

.chart-panel {
  margin-top: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  background: var(--color-surface);
}

.chart-ranges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.chart-range[disabled] {
  opacity: 0.35;
  cursor: default;
}

.chart {
  min-height: 240px;
}

.chart-empty {
  margin: 0.5rem 0 0;
  color: var(--color-text-muted);
}

/* uPlot legend and tooltip values in the page style */
.chart .u-legend {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-align: left;
}

.chart .u-legend .u-value {
  color: var(--color-text);
  font-weight: 700;
}

.chart .u-select {
  background: rgba(96, 165, 250, 0.12);
}

.explorer-link {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* --- Ecosystem page ----------------------------------------------------- */

.page-intro {
  margin: 1.5rem 0 2rem;
}

.projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  gap: 1rem;
}

.project {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  background: var(--color-surface);
}

.project__name {
  margin: 0;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.04em;
}

.project__description,
.project__note {
  margin: 0;
  color: var(--color-text-muted);
}

.project__facts {
  margin: 0;
  display: grid;
  gap: 0.3rem;
}

.project__facts > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--color-border);
}

.project__facts dt {
  color: var(--color-text-muted);
}

.project__facts dd {
  margin: 0;
  font-family: var(--font-mono);
  font-weight: 700;
  text-align: right;
  overflow-wrap: anywhere;
}

.project__links {
  margin: auto 0 0;
  display: flex;
  gap: 1rem;
}

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

.footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.footer a {
  margin-right: 1rem;
}

/* --- Small screens ------------------------------------------------------ */

@media (max-width: 40rem) {
  .tiles {
    grid-template-columns: minmax(0, 1fr);
  }

  .metric {
    grid-template-columns: 1fr;
  }

  .metric__value {
    justify-content: flex-start;
    text-align: left;
  }

  .overall {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .overall__light {
    transition: background-color 0.4s ease, box-shadow 0.4s ease;
  }
}
