/* Reset */

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

* {
  margin: 0;
  padding: 0;
}

html {
  color-scheme: dark light;
}

body {
  min-height: 100vh;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
}

/* Colors */

:root {
  --color-dark: #1f2123;
  --color-light: #e8e6e3;
}

:root {
  /* separated since these are used by the actual script */
  --highlight: var(--color-light);
  --background: var(--color-dark);
  --shadow-component: 255;
  --shadow: rgb(
    var(--shadow-component),
    var(--shadow-component),
    var(--shadow-component),
    0.2
  );
}

/* Font */

body {
  font-family: Arial, Helvetica, sans-serif;
}

/* Composition */

.flex {
  display: flex;
  gap: var(--gap, 1rem);
}

.even {
  justify-content: space-between;
  align-items: stretch;
}

.wrap {
  flex-wrap: wrap;
}

.col {
  flex-direction: column;
}

.grid {
  display: grid;
  gap: var(--gap, 1rem);
}

.full-grid-row {
  grid-column: 1 / -1;
}

.flow > * + * {
  margin-block-start: var(--flow-space, 1rem);
}

.no-gap {
  --gap: 0px;
}

.small-gap {
  --gap: 0.5rem;
}

.big-gap {
  --gap: 1.5rem;
}

.small-flow-space {
  --flow-space: 0.5rem;
}

.section {
  padding-block-start: var(--flow-space, 1rem);
  padding-inline: var(--flow-space-inline, 1ch);
}

/* Utility */

.emphasis {
  font-size: 1.125rem;
  font-weight: 600;
}

.smaller {
  font-size: 0.875rem;
}

.smallest {
  font-size: 0.75rem;
}

.center {
  text-align: center;
  margin-inline: auto;
}

.block-center {
  margin-block: auto;
}

.right {
  text-align: end;
}

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.margin-after {
  margin-block-end: 0.5rem;
}

.pill-shape {
  border-radius: 100vmax;
}

input.pill-shape {
  text-align: center;
  padding: 0.25rem 1ch;
}

.highlight-border {
  border: 1px solid var(--highlight);
}

@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+Math&display=swap");
.math-font {
  font-family: "Noto Sans Math", sans-serif;
}

/* Block */

body {
  color: var(--highlight);
  background-color: var(--background);
  accent-color: var(--highlight);
  transition: accent-color 250ms, color 250ms, background-color 250ms;

  display: grid;
  grid-template-columns: 14rem 1fr 7rem;
}

body > * + :not(:last-child) {
  border-inline-end: 1px solid var(--highlight);
}

hr {
  color: var(--highlight);
}

button,
select,
label,
input[type="radio"],
input[type="checkbox"] {
  cursor: pointer;
}

button {
  border-radius: 100vmax;
  padding-block: 0.25rem;
  border: 1px solid var(--highlight);
  transition: background-color 100ms;
}

button:hover {
  box-shadow: 0 0 4px 2px var(--shadow);
}

button.color-select {
  color: var(--highlight);
  background-color: var(--background);
}

button.color-select:hover {
  box-shadow: 0px 0px 4px 2px var(--shadow), inset 100vmax 100vmax rgb(255 255 255 / 0.2);
}

#prevColors button {
  width: 100%;
  margin-block-end: 0.5ch;
}

.color-inputs input[type="text"] {
  min-width: 0px;
}

.color-inputs input[type="color"] {
  flex: 0 0 2rem;
}

.color-inputs input[type="radio"] {
  display: none;
}

#cls-title,
#cls-fn,
#cls-metric-mount {
  transition: opacity 200ms;
}

[data-faded="true"] {
  opacity: 25%;
}

#color-results,
#name-results {
  margin-inline-start: 1ch;
}

.toggle-label {
  padding: 0 0.625ch 0.125rem;
  opacity: 50%;
  transition: opacity 200ms, color 200ms, border-color 200ms, background-color 200ms;
}

:is(input[type="checkbox"], input[type="radio"]):checked + .toggle-label {
  opacity: 100%;
  background-color: var(--highlight);
  color: var(--background);
  border-color: var(--highlight);
}

/* Pokemon Tiles */

.pkmn-tile {
  width: 28ch;
  padding-inline: 0.5ch;
  --tile-block-padding: 0.25rem;
  --tile-border-radius: 8px;
  transition: transform 250ms ease-out;
}

.pkmn-tile:hover .ellipsis {
  overflow: visible;
  width: fit-content;
  background-color: var(--background);
  box-shadow: 0px 0px 2px 4px var(--background);
}

.pkmn-tile .pkmn-info {
  /* no block-start padding here, this makes the 
     images look like they go right up to the border */
  padding: 0 0.5ch var(--tile-block-padding);
  border-radius: var(--tile-border-radius);
  box-shadow: 4px 4px 2px var(--shadow);
  margin-block-start: 0.25rem;
}

.pkmn-tile .pkmn-info-main {
  flex: 1;
  --gap: 0.125rem;
}

.pkmn-tile .cluster-buttons {
  position: relative;
  --gap: 0.125rem;
  justify-content: center;

  /* but here we put the block-start padding back to
     fix the vertical centering of the cluster buttons */
  margin-block-start: var(--tile-block-padding);
  margin-inline-start: 0.5ch;
  padding-inline: 0.25ch;
  border-radius: var(--tile-border-radius);
  background-color: var(--shadow);
  box-shadow: 0px 0px 8px var(--shadow);
}

.pkmn-tile a {
  height: 64px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.pkmn-tile img {
  max-height: 100%;
}

.pkmn-tile button {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.125rem 1ch 0.125rem 2ch;
  white-space: nowrap;
}

.pkmn-tile button[data-included="true"] {
  position: relative;
}

.pkmn-tile button[data-included="true"]::before {
  position: absolute;
  content: "·";
  inset: 50% auto auto 0.375ch;
  font-size: 1.5rem;
  /* slightly nicer than a normal vertical centering */
  transform: translateY(-48%);
}

.pkmn-tile :is(.cluster-info, .total-info) {
  visibility: hidden;
  position: absolute;
  opacity: 0%;
  inset: 100% auto auto 50%;
  transform: translateX(-50%);
  transition: visibility 200ms, opacity 200ms ease-out, transform 200ms ease-out;
  font-size: 0.75rem;

  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: min-content;
  column-gap: 0.5ch;
  row-gap: 0.125rem;

  padding: var(--tile-block-padding) 0.5ch;
  border-radius: var(--tile-border-radius);
  border: 1px solid var(--background);
  box-shadow: 2px 2px 2px var(--shadow);
  background-color: var(--highlight);
  color: var(--background);
}

.pkmn-tile .pkmn-data-separator {
  height: 1px;
  background-color: var(--background);
}

.pkmn-tile .pkmn-data-size {
  grid-column: 1 / 3;
}

.pkmn-tile:hover {
  z-index: 10;
}

.pkmn-tile button:hover + :is(.cluster-info, .total-info),
:is(.cluster-info, .total-info):hover {
  visibility: visible;
  opacity: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  .pkmn-tile:hover {
    /* TODO fix total */
    transform: scale(105%) translateX(-3%) translateY(-5%);
  }

  .pkmn-tile button:hover + :is(.cluster-info, .total-info) {
    transform: translateX(-50%) translateY(5%);
  }
}

/* Sort Function Controls */

.fn-control .fn-minmax label span {
  padding: 0.125rem 0.75ch;
}

.fn-control .fn-body {
  --gap: 0.25ch;
  margin-block: 0.5rem;
  justify-content: center;
  align-items: center;
}

.fn-control :is(input[type="checkbox"], input[type="radio"]) {
  display: none;
}

.fn-control .toggle-label:first-child {
  /* only affects the fake label on the cluster function */
  opacity: inherit;
  color: inherit;
  background-color: inherit;
  border: none;
  padding: 0;
}

.fn-fraction > *:first-child {
  /* this feels a little fragile */
  padding-bottom: 6px;
  margin-bottom: 4px;
  border-block-end: 1px solid var(--highlight);
}

/* Metric Controls */

.metric-fields {
  border: none;
}

.metric-fields :is(select:disabled, input[type="radio"]) {
  display: none;
}

.metric-fields select {
  width: 100%;
  padding: 0.25rem 1ch;
}
