/*
 * New design "Signal" (D-030), served under /new/ next to the classic page until it replaces
 * it. Dark is the default whatever the system setting is; the toggle switches to light.
 * The variable names --color-* are the ones charts.js reads.
 */

@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/JetBrainsMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --font-sans: "Inter", system-ui, sans-serif;

  --color-bg: #07090d;
  --color-bg-secondary: #0b0f15;
  --color-surface: #0e131b;
  --color-border: #1b2230;
  --color-track: #1b2230;
  --color-text: #e8edf5;
  --color-text-muted: #a7b3c4;
  --color-label: #7d8ba0;
  --color-link: #8ab8ff;
  --color-accent: #4c8dff;
  --color-accent-text: #07090d;
  --color-ok: #38d39f;
  --color-ok-strong: #6ee7b7;
  --color-warn: #ffb020;
  --color-warn-text: #ffc266;
  --color-crit: #ff5c63;
  --color-crit-text: #ff9a9d;
  --color-unknown: #7d8ba0;
  --color-cell: #1b2230;
}

:root[data-theme="light"] {
  --color-bg: #f4f7fb;
  --color-bg-secondary: #eaf0f7;
  --color-surface: #ffffff;
  --color-border: #d9e2ee;
  --color-track: #dce6f2;
  --color-text: #0e1726;
  --color-text-muted: #45556d;
  --color-label: #5a6a80;
  --color-link: #1f5bc4;
  --color-accent: #2a6ae0;
  --color-accent-text: #ffffff;
  --color-ok: #138a5e;
  --color-ok-strong: #0f6b49;
  --color-warn: #b7791f;
  --color-warn-text: #8a5a00;
  --color-crit: #c53030;
  --color-crit-text: #a61b1b;
  --color-unknown: #5a6a80;
  --color-cell: #dce6f2;
}

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

html {
  background: var(--color-bg);
}

body.n {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
}

a {
  color: var(--color-link);
}

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

.n-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.n-main {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* --- Labels and states ---------------------------------------------------- */

.n-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-label);
}

.n-muted {
  margin: 0;
  color: var(--color-text-muted);
}

.n-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-unknown);
  flex: none;
}

.n-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 500;
}

.n-state--green,
.n-state--normal,
.n-state--decentral-green { color: var(--color-ok-strong); }
.n-state--yellow,
.n-state--degraded,
.n-state--decentral-yellow { color: var(--color-warn-text); }
.n-state--red,
.n-state--incident,
.n-state--decentral-red { color: var(--color-crit-text); }

.n-state--green .n-dot,
.n-state--normal .n-dot,
.n-state--decentral-green .n-dot,
.n-dot--green { background: var(--color-ok); }
.n-state--yellow .n-dot,
.n-state--degraded .n-dot,
.n-state--decentral-yellow .n-dot,
.n-dot--yellow { background: var(--color-warn); }
.n-state--red .n-dot,
.n-state--incident .n-dot,
.n-state--decentral-red .n-dot,
.n-dot--red { background: var(--color-crit); }

/* --- Header ----------------------------------------------------------------- */

.n-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.n-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
  color: var(--color-text);
  text-decoration: none;
}

.n-logo__mark {
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-accent);
  border-radius: 3px;
}

.n-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.n-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: none;
  color: var(--color-text-muted);
  font: 500 0.8125rem/1 var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
}

.n-pill:hover {
  color: var(--color-text);
  border-color: var(--color-accent);
}

.n-pill--active,
.chart-range.pill--active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-accent-text);
  font-weight: 700;
}

.n-pill:focus-visible,
.n-ring:focus-visible,
.n-decentral:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

/* --- Banners, cards, intro ------------------------------------------------------ */

.n-banner {
  margin: 0;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

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

.n-banner--info {
  border-color: var(--color-accent);
}

.n-card {
  padding: 24px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.n-intro {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.n-title {
  margin: 0;
  font-size: 2rem;
  line-height: 1.2;
}

.n-section-title {
  margin: 0;
}

/* --- Hero ------------------------------------------------------------------------- */

.n-hero {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  align-items: center;
  justify-content: space-between;
  padding: 32px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.n-hero__main {
  flex: 1 1 420px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.n-hero__height {
  font-family: var(--font-mono);
  font-size: clamp(3rem, 9vw, 4.75rem);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.n-hero__text {
  margin: 0;
  color: var(--color-text-muted);
}

.n-hero__side {
  flex: 0 1 480px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.n-stats {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.n-stats dd {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
}

.n-decentral {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
}

/* --- Confirmations and verdicts ------------------------------------------------------ */

.n-confirm {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.n-confirm__item {
  padding: 6px 10px;
  border: 1px solid var(--color-ok);
  border-radius: 8px;
  font: 500 0.8125rem/1.3 var(--font-mono);
  color: var(--color-ok-strong);
}

.n-confirm__item--differs {
  border-color: var(--color-warn);
  color: var(--color-warn-text);
}

.n-verdicts {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.n-verdicts__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.n-verdict {
  padding: 22px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-unknown);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.n-verdict--green { border-top-color: var(--color-ok); }
.n-verdict--yellow { border-top-color: var(--color-warn); }
.n-verdict--red { border-top-color: var(--color-crit); }

.n-verdict__title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.n-verdict p {
  margin: 0;
}

.n-verdict__reasons {
  font-size: 0.875rem;
}

/* 30-day strip: one cell per day in the worst level of that day */
.n-days {
  display: grid;
  grid-template-columns: repeat(30, minmax(0, 1fr));
  gap: 2px;
  margin-top: 4px;
}

.n-day {
  height: 22px;
  border-radius: 2px;
  background: var(--color-unknown);
  opacity: 0.35;
}

.n-day--green { background: var(--color-ok); opacity: 1; }
.n-day--yellow { background: var(--color-warn); opacity: 1; }
.n-day--red { background: var(--color-crit); opacity: 1; }

/* --- Rings and halving ------------------------------------------------------------- */

.n-rings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.n-ring {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: inherit;
  text-align: center;
  text-decoration: none;
}

.n-ring svg circle {
  fill: none;
  stroke-width: 12;
}

.n-ring__track {
  stroke: var(--color-track);
}

.n-ring__value {
  stroke: var(--color-accent);
  stroke-linecap: round;
}

.n-ring--green .n-ring__value { stroke: var(--color-ok); }
.n-ring--yellow .n-ring__value { stroke: var(--color-warn); }
.n-ring--red .n-ring__value { stroke: var(--color-crit); }

.n-ring__note {
  font-size: 0.875rem;
}

.n-ring__number {
  position: absolute;
  top: 80px;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  pointer-events: none;
}

.n-halving {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  padding: 28px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.n-halving__value {
  margin: 6px 0;
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.n-halving__grid {
  flex: 1 1 420px;
  display: grid;
  grid-template-columns: repeat(25, minmax(0, 1fr));
  gap: 3px;
}

.n-cell {
  height: 36px;
  border-radius: 2px;
  background: var(--color-cell);
}

.n-cell--done {
  background: var(--color-accent);
}

/* --- Jump navigation, tiles, sections ------------------------------------------------- */

.n-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.n-jump ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.n-glance {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.n-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.n-tile {
  padding: 18px;
  border-radius: 16px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.n-tile p {
  margin: 0;
}

.n-tile__value {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
}

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

.n-section {
  padding: 20px 24px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.n-section > summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
}

.n-section > summary::-webkit-details-marker,
.n-info > summary::-webkit-details-marker,
.n-more > summary::-webkit-details-marker,
.metric__chart > summary::-webkit-details-marker {
  display: none;
}

.n-metrics {
  margin: 16px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.n-metric {
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--color-bg-secondary);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.n-metric--wide {
  grid-column: 1 / -1;
}

.n-metric dt {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
}

.n-metric__title {
  font-weight: 600;
}

.n-metric dd {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
}

.n-metric__value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
}

.n-info > summary {
  cursor: pointer;
  list-style: none;
  color: var(--color-label);
}

.n-info p {
  margin: 6px 0 0;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.n-link {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.n-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.n-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.n-table th,
.n-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  white-space: nowrap;
}

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

/* --- Timeline ---------------------------------------------------------------------------- */

.n-timeline {
  margin: 12px 0 0;
  padding: 0 0 0 16px;
  list-style: none;
  border-left: 2px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.n-timeline__item {
  position: relative;
  display: flex;
  flex-direction: column;
}

.n-timeline__item::before {
  content: "";
  position: absolute;
  left: -23px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-accent);
}

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

.n-more > summary {
  margin-top: 12px;
  cursor: pointer;
  list-style: none;
}

/* --- Charts (classes used by charts.js) ----------------------------------------------------- */

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

.chart-panel {
  margin-top: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  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);
}

.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;
}

/* --- Auto refresh switch (used by page.js) -------------------------------------------------- */

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

.switch[hidden] {
  display: none;
}

.switch__track {
  position: relative;
  width: 2rem;
  height: 1.1rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg-secondary);
}

.switch__knob {
  position: absolute;
  top: 0.1rem;
  left: 0.1rem;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: var(--color-text-muted);
}

.switch[aria-checked="true"] .switch__track {
  background: var(--color-ok);
  border-color: var(--color-ok);
}

.switch[aria-checked="true"] .switch__knob {
  background: var(--color-surface);
  transform: translateX(0.9rem);
}

.switch:focus-visible .switch__track {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

/* --- Help, changes, ecosystem ---------------------------------------------------------------- */

.n-input {
  display: block;
  width: 100%;
  padding: 10px;
  font: 0.8125rem/1.5 var(--font-mono);
  color: var(--color-text);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 10px;
}

.n-result:not(:empty) {
  margin: 0;
  padding: 10px 14px;
  border-left: 3px solid var(--color-unknown);
}

.n-result[data-verdict="in_sync"] { border-left-color: var(--color-ok); }
.n-result[data-verdict="syncing"],
.n-result[data-verdict="ahead"] { border-left-color: var(--color-warn); }
.n-result[data-verdict="stuck"],
.n-result[data-verdict="stuck_known"],
.n-result[data-verdict="other_network"] { border-left-color: var(--color-crit); }

.n-case + .n-case {
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

.n-case h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.n-case ol,
.n-list {
  margin: 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 6px;
}

.n-releases {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 16px;
}

.n-release__version {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 1.35rem;
}

.n-projects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.n-project__name {
  margin: 0;
  font-size: 1.15rem;
}

.n-facts {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.n-facts dd {
  margin: 2px 0 0;
}

.n-project__links {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

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

.n-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--color-border);
  font-size: 0.875rem;
  color: var(--color-text-muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.n-footer p {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

@media (max-width: 640px) {
  .n-hero,
  .n-halving {
    padding: 20px;
  }

  .n-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .n-halving__grid {
    grid-template-columns: repeat(13, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
