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

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

@font-face {
  font-display: swap;
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  src: url("font/IBMPlexMono-Medium.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --color-bg: #fff;
  --color-surface: #f7f7f8;
  --color-surface-transparent: rgba(247, 247, 248, 0);
  --color-text: #111217;
  --color-text-muted: #5f6773;
  --color-border: #d8dde3;
  --color-best: #1f7a1f;
  --color-warn: #b7791f;
  --color-slow: #c53030;
  --color-cedar: #fb773e;
  --color-cedar-soft: rgba(251, 119, 62, 0.08);
  --color-postgres: #2f6fed;
  --color-postgres-soft: rgba(47, 111, 237, 0.08);
  --space-page-top: 0.75rem;
  --space-page-x: 1rem;
  --space-page-bottom: 0.75rem;
  --space-section: 1.5rem;
  --space-grid: 1rem;
  --space-panel: 1px;
  --section-width: 100%;
  --section-width-compact: 100%;
  --layout-width: 100%;
  --panel-stack-min-height: 24rem;
  --panel-stack-min-height-large: 20rem;
  --font-display: "Sora", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

@media (min-width: 600px) {
  :root {
    --space-page-top: 1.5rem;
    --space-page-x: 2.5rem;
    --space-page-bottom: 1.5rem;
    --space-section: 2rem;
    --space-grid: 1.25rem;
  }
}

@media (min-width: 768px) {
  :root {
    --space-page-top: 2rem;
    --space-page-x: 3rem;
    --space-page-bottom: 2rem;
    --space-section: 2.5rem;
    --space-grid: 1.5rem;
  }
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  box-sizing: border-box;
  font-family: var(--font-body);
}

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

body {
  padding: var(--space-page-top) var(--space-page-x) var(--space-page-bottom);
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.controls,
.layout {
  width: var(--layout-width);
  margin-inline: auto;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem var(--space-grid);
  margin-bottom: var(--space-section);
}

.control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 12.25rem;
}

/* Shared mono style for both the label and the value */
.control span,
.control select {
  font-family: var(--font-mono);
  font-weight: 500;
}

.control span {
  flex: 0 0 auto;
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1.25;
  text-transform: uppercase;
  white-space: nowrap;
}

.control select {
  flex: 1 1 auto;
  min-height: 2.25rem;
  padding: 0.25rem 1rem 0.25rem 0;
  border: 0;
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-size: 1.5rem;
  line-height: 1.2;
  direction: rtl;
  text-align: right;
  text-align-last: right;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

/* Custom downward-triangle indicator, colored to match the select's text */
.control {
  position: relative;
  z-index: 10;
}

.control::after {
  content: "\25BE";
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text);
  font-size: 0.9rem;
  line-height: 1;
  pointer-events: none;
}

.control:hover::after {
  color: var(--color-cedar);
}

.control select:hover {
  color: var(--color-cedar);
}

.control select:focus {
  outline: none;
  border-bottom-color: currentColor;
}

.control select option {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-mono);
  direction: rtl;
  text-align: right;
}

@media (max-width: 640px) {
  .control {
    min-width: 100%;
  }
}

.help-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(10, 12, 16, 0.6);
  cursor: pointer;
  animation: help-overlay-in 150ms ease;
}

.help-overlay[hidden] {
  display: none;
}

@keyframes help-overlay-in {
  from {
    background-color: rgba(10, 12, 16, 0);
  }
  to {
    background-color: rgba(10, 12, 16, 0.6);
  }
}

.help-toggle {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  margin-left: auto;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.help-toggle:hover {
  color: var(--color-cedar);
  border-color: var(--color-cedar);
}

.help-arrows {
  position: absolute;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  overflow: visible;
}

.help-arrow-path {
  fill: none;
  stroke: var(--color-cedar);
  stroke-width: 2;
}

#help-arrowhead path {
  fill: var(--color-cedar);
}

.help-callout {
  position: absolute;
  z-index: 100;
  max-width: 10rem;
  padding: 0.5rem 0.5rem;
  background: var(--color-bg);
  color: var(--color-cedar);
  border: 1px solid var(--color-cedar);
  border-radius: 0.2rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  font-family: var(--font-mono);
  text-transform: uppercase;
  text-align: center;
  cursor: default;
}

.help-callout p {
  margin: 0;
}

.help-hint {
  position: fixed;
  left: 50%;
  top: 20rem;
  z-index: 100;
  transform: translateX(-50%);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 500;
  text-transform: uppercase;
  opacity: 0.75;
  white-space: nowrap;
}

.layout,
.row {
  display: flex;
  flex-wrap: wrap;
}

.layout {
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-section);
}

.hw-note {
  display: block;
  width: var(--layout-width);
  margin-inline: auto;
  padding-top: var(--space-grid);
  color: var(--color-text-muted);
  text-align: right;
}

.column {
  display: flex;
  flex-direction: column;
  gap: var(--space-panel);
  flex: 0 1 var(--section-width);
  width: var(--section-width);
  padding: 1rem;
  border: 1px solid var(--color-border);
  background:
    linear-gradient(
      180deg,
      var(--column-tint),
      var(--color-surface-transparent) 6rem
    ),
    var(--color-surface);
}

.column[data-database="cedar"] {
  --column-accent: var(--color-cedar);
  --column-tint: var(--color-cedar-soft);
}

.column[data-database="postgres"] {
  --column-accent: var(--color-postgres);
  --column-tint: var(--color-postgres-soft);
}

.row {
  container-type: inline-size;
  gap: var(--space-panel);
  width: 100%;
}

.panel-stack {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 calc((100% - var(--space-panel)) / 2);
  height: max(var(--panel-stack-min-height), calc(60cqw / 4));
  gap: var(--space-panel);
  padding-bottom: 0.5rem;
}

.row > .panel-stack:only-child {
  flex: 1 1 100%;
}

.grafana-iframe {
  display: block;
  border: 0;
  width: 100%;
  background-image: url("grafana.svg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: min(4.5rem, 20%);
}

.panel-stack > .grafana-iframe {
  flex: 7 1 0;
  min-height: 0;
  margin-bottom: 0.25rem;
}

.panel-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  z-index: 1;
  background-color: rgb(
    from color-mix(in srgb, var(--color-bg) 40%, black) r g b / 50%
  );
}

.panel-loading-overlay::after {
  content: "";
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 5px solid #ddd;
  border-top-color: #777;
  animation: panel-spinner 0.8s linear infinite;
}

@keyframes panel-spinner {
  to {
    transform: rotate(360deg);
  }
}

.panel-stack[data-stale] .panel-loading-overlay,
.panel-stack[data-warming] .panel-loading-overlay {
  opacity: 1;
}

.panel-runtime {
  position: relative;
  flex: 1 0 0;
  width: 100%;
  min-height: 0;
  padding: 0.5rem 0.75rem;
  background: var(--color-surface);
  color: var(--color-text);
  pointer-events: none;
}

.panel-runtime__body {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

/* Shared baseline for the timing number and its label */
.panel-runtime__label,
.panel-runtime__info {
  line-height: 1;
  white-space: nowrap;
}

.panel-runtime__label {
  font-family: var(--font-body);
  font-size: 2rem;
  font-weight: 500;
}

.panel-runtime__info {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--color-text-muted);
  visibility: hidden;
}

.panel-runtime[data-ready="true"] .panel-runtime__info {
  visibility: visible;
}

.panel-runtime[data-compare="best"] {
  color: var(--color-best);
}
.panel-runtime[data-compare="warn"] {
  color: var(--color-warn);
}
.panel-runtime[data-compare="slow"] {
  color: var(--color-slow);
}

h1 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  min-height: 4rem;
  margin: 0 0 calc(0.75rem - var(--space-panel));
  padding-bottom: 0.75rem;
  color: var(--column-accent, var(--color-text));
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 2vw, 2.5rem);
  font-weight: 400;
  line-height: 0.95;
  text-wrap: balance;
  border-bottom: 1px solid
    color-mix(
      in srgb,
      var(--column-accent, var(--color-border)) 35%,
      transparent
    );
}

.column__lag {
  margin-left: auto;
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.column__logo {
  max-height: calc(100% - 0.75rem);
  flex: 0 0 auto;
  object-fit: contain;
}

.column[data-database="cedar"] .column__logo {
  height: 1.1em;
}

.column[data-database="postgres"] .column__logo {
  height: 0.9em;
}

html[data-theme="dark"],
html[data-theme="dark"] body {
  color-scheme: dark;
  --color-bg: #0d222d;
  --color-surface: #181b1f;
  --color-surface-transparent: rgba(24, 27, 31, 0);
  --color-text: #d8d9da;
  --color-text-muted: #aeb6c2;
  --color-border: #2b3037;
  --color-best: #68d391;
  --color-warn: #f6ad55;
  --color-slow: #fc8181;
}

@media (max-width: 1100px) {
  :root {
    --section-width: var(--section-width-compact);
  }

  .layout {
    justify-content: center;
  }

  .column {
    flex-basis: min(var(--section-width), 100%);
    width: var(--section-width);
    padding: 0.75rem;
  }
}

@media (min-width: 1751px) {
  body {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .layout {
    align-items: stretch;
  }

  .column {
    min-height: 100%;
  }

  .row {
    flex-wrap: nowrap;
  }

  .column > .row:only-child {
    flex: 1 1 0;
    min-height: 0;
  }

  .panel-stack {
    min-height: var(--panel-stack-min-height-large);
  }

  .panel-stack[data-width-ratio] {
    flex: var(--stack-width-ratio) 1 0;
  }
}
