@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-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: 45vw;
  --section-width-compact: 95vw;
  --layout-width: min(
    100%,
    calc((2 * var(--section-width)) + var(--space-section))
  );
  --panel-stack-height: 30vh;
  --panel-stack-min-height: 21.5rem;
  --panel-stack-min-height-large: 14rem;
  --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;
  width: 100%;
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-text);
  box-sizing: border-box;
  font-family: var(--font-body);
  transition:
    background-color 150ms ease,
    color 150ms ease;
}

*,
*::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: transparent;
  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 chevron drawn as a two-line gradient stripe */
  background-image: linear-gradient(
    to bottom,
    transparent 0,
    transparent 35%,
    currentColor 35%,
    currentColor 50%,
    transparent 50%,
    transparent 100%
  );
  background-position: right 2px center;
  background-size: 0.5rem 0.5rem;
  background-repeat: no-repeat;
  transition:
    border-color 150ms ease,
    color 150ms ease,
    background-color 150ms ease;
}

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

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

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

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

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

.column {
  --column-width: min(
    var(--section-width),
    calc((100vw - (2 * var(--space-page-x)) - var(--space-section)) / 2)
  );
  display: flex;
  flex-direction: column;
  gap: var(--space-panel);
  flex: 0 1 var(--column-width);
  width: var(--column-width);
  max-width: 100%;
  min-width: 0;
  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 {
  gap: var(--space-panel);
  min-width: 0;
  width: 100%;
}

.panel-stack {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 calc((100% - var(--space-panel)) / 2);
  min-width: min(100%, 20rem);
  min-height: var(--panel-stack-min-height);
  height: var(--panel-stack-height);
  gap: var(--space-panel);
}

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

.grafana-iframe {
  display: block;
  border: 0;
  width: 100%;
  min-width: 0;
  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;
  transition: opacity 100ms ease;
  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;
  align-items: center;
  gap: 0.75rem;
  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__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-bg: #111217;
  --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;
}

html[data-theme="dark"] .control select {
  background: var(--color-surface);
}

@media (max-width: 1750px) {
  .panel-stack {
    flex: 1 1 100%;
    max-width: 100%;
  }

  .row[data-flip-order-on-small-screens="true"] > .panel-stack:first-child {
    order: 2;
  }

  .row[data-flip-order-on-small-screens="true"] > .panel-stack:last-child {
    order: 1;
  }
}

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

  .layout {
    justify-content: center;
  }

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

@media (min-width: 1751px) {
  html,
  body {
    height: 100dvh;
    min-height: 100dvh;
  }

  body {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  .layout {
    height: 100%;
    min-height: 0;
    align-items: stretch;
  }

  .column {
    height: 100%;
    min-height: 0;
  }

  .row {
    flex: 1 1 0;
    flex-wrap: nowrap;
    min-height: 0;
  }

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

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

  .panel-stack > .grafana-iframe {
    min-height: 0;
  }
}
