/* The page is set like a journal figure: white ground, black ink, and one
   highlight color that only ever means "matches the filters". */
:root {
  --ink: #000;
  --paper: #fff;
  --quiet: #595959;
  --base: #7c6fcf;
  --match: #d6176b;
  --recommended: #f5b800;
  --excluded: #c8c8c8;
  --soft: #f3f3f5;
  --soft-hover: #e8e8ec;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

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

html,
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
}

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

/* Title block */
.masthead {
  padding: 28px 32px 20px;
  text-align: center;
}
.masthead h1 {
  margin: 0;
  /* shrinks with the window so the title stays on one line */
  font-size: min(30px, calc((100vw - 64px) / 41.5));
  white-space: nowrap;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.nowrap {
  white-space: nowrap;
}
.authors {
  margin: 10px 0 0;
  font-weight: 700;
}
.authors a {
  text-decoration: none;
}
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  justify-content: center;
  margin: 6px 0 0;
  color: var(--quiet);
  font-size: 13px;
}

/* Figure */
#app {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 32px;
  margin: 0;
  padding: 0 32px;
}

/* Matches the height of the default matrix, not the live one, so the feature
   lists keep their size when the selection changes */
#controls {
  display: flex;
  flex-direction: column;
  align-self: start;
  height: 706px;
}

.panel {
  margin: 0 0 24px;
}
.panel:first-child {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}
.panel:last-child {
  margin-bottom: 0;
}

.panel-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
}

.panel-letter {
  font-size: 22px;
  line-height: 1;
}

/* Controls */
.axis-panel {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  margin: 0 0 16px;
}
.axis-panel:last-child {
  flex: 1.4;
  margin-bottom: 0;
}
.axis-panel h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
}

.group-row {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 10px;
  justify-content: start;
  margin-bottom: 6px;
  font-size: 12px;
}

label {
  cursor: pointer;
}

input[type="checkbox"] {
  width: 12px;
  height: 12px;
  margin: 0 5px 0 0;
  vertical-align: -1px;
  accent-color: var(--ink);
}

input[type="range"] {
  flex: 1;
  min-width: 0;
  margin: 0;
  accent-color: var(--ink);
}

.overflow {
  flex: 1 1 92px;
  min-height: 92px;
  overflow: auto;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--soft);
  font-size: 12px;
}

/* Lists of short names only, such as elements */
.overflow.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 0 10px;
}

#list-x label,
#list-y label {
  display: flex;
  align-items: flex-start;
  padding: 1px 0;
  overflow-wrap: anywhere;
}
#list-x input,
#list-y input {
  flex: none;
  margin-top: 2px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.row.small {
  margin-top: 4px;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

#selected-count,
#knn-delta-value {
  font-variant-numeric: tabular-nums;
}
#selected-count {
  color: var(--quiet);
  font-size: 12px;
}

/* Buttons */
button {
  font-family: inherit;
  cursor: pointer;
}

.btn {
  padding: 7px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}
.btn:hover {
  background: var(--soft-hover);
}
.btn.is-on {
  background: var(--ink);
  color: var(--paper);
}
.btn.wide {
  width: 100%;
  margin-bottom: 12px;
}

.text-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--quiet);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.text-btn:hover {
  color: var(--ink);
}

.threshold label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
}

/* Matrix */
#main {
  min-width: 0;
}

.matrix-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 24px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
}
.legend li {
  display: flex;
  align-items: center;
  gap: 5px;
}
.key {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.key.base {
  background: var(--base);
}
.key.match {
  background: var(--match);
}
.key.recommended {
  background: var(--recommended);
}
.key.excluded {
  background: var(--excluded);
}
.key.curve {
  width: 16px;
  height: 0;
  border-top: 1.5px solid var(--ink);
  border-radius: 0;
}

#plot-info {
  margin-bottom: 8px;
  color: var(--quiet);
}
#plot-info:empty {
  display: none;
}

#splom {
  min-height: 320px;
  max-width: 100%;
}

/* Caption */
.caption {
  columns: 2;
  column-gap: 32px;
  max-width: 1120px;
  margin: 8px 0 0;
  padding: 16px 32px 40px;
  font-size: 12.5px;
  line-height: 1.45;
}
.caption b {
  font-weight: 700;
}

/* Walkthrough: a liquid glass panel floating over the figure */
.glass-defs {
  position: absolute;
}

.tour-blocker {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.tour-spotlight {
  position: fixed;
  z-index: 1001;
  border-radius: 16px;
  box-shadow:
    0 0 0 1.5px rgba(255, 255, 255, 0.85),
    0 0 0 200vmax rgba(24, 26, 44, 0.2);
  pointer-events: none;
  transition:
    left 0.25s ease,
    top 0.25s ease,
    width 0.25s ease,
    height 0.25s ease;
}

.tour-panel {
  position: fixed;
  z-index: 1002;
  width: min(320px, calc(100vw - 24px));
  padding: 4px;
  border-radius: 28px;
  background: linear-gradient(
    140deg,
    rgba(255, 255, 255, 0.72),
    rgba(255, 255, 255, 0.5)
  );
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  backdrop-filter: blur(14px) saturate(180%);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.95),
    inset 1px 0 1px rgba(255, 255, 255, 0.5),
    inset 0 -1px 1px rgba(255, 255, 255, 0.4),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35),
    0 20px 50px rgba(24, 26, 44, 0.24),
    0 2px 8px rgba(24, 26, 44, 0.1);
  transition:
    left 0.25s ease,
    top 0.25s ease;
}

.has-refraction .tour-panel {
  backdrop-filter: url(#glass-refract) blur(1.5px) saturate(160%);
}

/* Light catching the top corner of the glass */
.tour-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    120% 80% at 12% 0%,
    rgba(255, 255, 255, 0.55),
    rgba(255, 255, 255, 0) 55%
  );
  pointer-events: none;
}

.tour-panel > * {
  position: relative;
}

.tour-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 0;
}

.tour-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

.tour-skip {
  padding: 0;
  border: 0;
  background: none;
  color: rgba(0, 0, 0, 0.62);
  font-size: 13px;
  line-height: 1.45;
}
.tour-skip:hover {
  color: var(--ink);
}

#tour-text {
  margin: 0;
  padding: 6px 16px 12px;
  font-size: 13.5px;
  line-height: 1.4;
}

.tour-progress {
  height: 3px;
  margin: 0 16px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.12);
}
.tour-progress span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--match);
  transition: width 0.25s ease;
}

.tour-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px;
}

.tour-btn {
  padding: 7px 16px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
}
.tour-btn:hover {
  background: rgba(255, 255, 255, 0.8);
}
.tour-btn[hidden] {
  display: none;
}

.tour-next {
  background: rgba(0, 0, 0, 0.84);
  box-shadow: none;
  color: var(--paper);
}
.tour-next:hover {
  background: var(--ink);
}

.tour-panel :focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.3);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .tour-spotlight,
  .tour-panel,
  .tour-progress span {
    transition: none;
  }
}

/* Readers who turn off transparency, or browsers without blur, get solid */
@media (prefers-reduced-transparency: reduce) {
  .tour-panel,
  .has-refraction .tour-panel {
    background: var(--paper);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .tour-panel {
    background: var(--paper);
  }
}

/* Guide page */
.guide {
  max-width: 44em;
  margin: 0 auto;
  padding: 32px;
  font-size: 15px;
  line-height: 1.5;
}
.guide h1 {
  margin: 16px 0 6px;
  font-size: 30px;
  line-height: 1.12;
}
.guide ol {
  margin: 28px 0 0;
  padding-left: 1.4em;
}
.guide li {
  margin-bottom: 18px;
}
.guide li::marker {
  font-weight: 700;
}
.guide h2 {
  margin: 0 0 2px;
  font-size: 15px;
}
.guide p {
  margin: 0;
}
.guide .lede {
  color: var(--quiet);
}

@media (max-width: 900px) {
  .masthead {
    padding: 20px 16px 16px;
  }
  #app {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 0 16px;
  }
  #main {
    order: -1;
  }
  #controls {
    height: auto;
  }
  .caption {
    columns: 1;
    padding: 12px 16px 32px;
  }
}

/* One line would be too small to read on a phone */
@media (max-width: 700px) {
  .masthead h1 {
    font-size: 24px;
    white-space: normal;
  }
}
