@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@100..900&display=swap');

:root {
  --background: #1E282B;
  --gold: gold;
  --common: #008DFA;
  --uncommon: #34B886;
  --rare: #F94C3F;
  --legendary: #6B3471;
  --font-family: 'Raleway';
}

* {
  box-sizing: border-box;
  margin: 0;
}

html {
  scrollbar-gutter: stable;
}
html:has(dialog[open]) {
  overflow-y: clip;
}

:is(input, button) {
  font: inherit;
}
.counter {
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.counter span {
  font-weight: 600;
}
button, label {
  cursor: pointer;
}
body {
  font-family: var(--font-family), sans-serif;
  background-color: var(--background);
  min-width: 340px;
}
.icon {
  display: block;
  fill: currentColor;
  width: 24px;
  height: 24px;
}
label.joker-label  {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  align-items: center;
  margin-inline: auto;
  max-width: 142px;
}
label[hidden] {
  display: none;
}
.joker-label [type="checkbox"] {
  appearance: none;
  position: absolute;
  inset: 0;  
}
.joker-label [type="checkbox"]:focus-visible {
  outline: none;
}
:focus-visible {
  outline: 2px solid var(--common);
  outline-offset: 1px;
}
.joker-label [type="checkbox"]:focus-visible + .joker-img img {
  outline: 3px solid var(--common);
  outline-offset: 1px;
  border-radius: 4px;
}
main {
  color: white;
  padding: 3rem 2rem;
  text-align: center;
  max-width: 838px;
  margin-inline: auto;
}

input[type="text"],
button {
  display: flex;
  padding: .5rem .75rem;
  font-size: 1rem;
  line-height: 1.25rem;
  border-color: transparent;
  border-radius: 2px;
  transition: transform .1s ease-in-out;
}
button:active {
  transform: translateY(1px);
}

.button-group {
  display: flex;
}
.view-toggle {
  display: none;
}
.button-group button {
  padding: calc(.5rem - 2px);
  background-color: var(--uncommon);
  color: white;
  filter: grayscale();
  transition: filter .1s ease-in-out;
  &:first-child {
    border-radius: 2px 0 0 2px;
  }
  &:last-child {
    border-radius: 0 2px 2px 0;
  }
  &:hover,
  &:focus-visible {
    filter: none;
  }
  &[data-active] {
    filter: none;
    background-color: var(--common);
  }
}

:is(h1, h2) {
  text-shadow: 1px 1px 1px rgb(0 0 0 / .6);
}

h1 {
  margin-block-end: 2rem;
  text-wrap: balance;
  font-weight: 900;
  span {
    color: var(--gold);
  }
}

h2 {
  font-size: .875rem;
  font-weight: 500;
}

.joker-desc {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  flex: 1;
  justify-content: space-between;
}

.effect {
  font-size: .75rem;
  padding: 0 .5rem;
  flex: 1;
  display: none;
}

[class*="rarity"] {
  border-radius: 2rem;
  font-size: .6875rem;
  font-weight: 400;
  text-align: center;
  padding: .25rem .5rem;
  display: inline-block;
}
.rarity-rare {
  background-color: var(--rare);
}
.rarity-uncommon {
  background-color: var(--uncommon);
}
.rarity-common {
  background-color: var(--common);
}
.rarity-legendary {
  background-color: var(--legendary);
}

section {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
  gap: 2rem 1rem;
}
[data-style="list"] {
  grid-template-columns: auto;
  justify-content: start;
  gap: 1rem;
}
[data-style="list"] label {
  flex-direction: row;
  gap: 2rem;
  text-align: left;
  max-width: none;
  width: 100%;
}
[data-style="list"] .joker-img img {
  width: 71px;
  height: auto;
}
[data-style="list"] :checked + .joker-img:before {
  width: 20px;
  height: 20px;
  right: 6px;
  top: 6px;
}
.reset {
  background-color: var(--rare);
  color: white;
  border-color: transparent;
  border-radius: 2px;
  filter: grayscale();
  transition: filter .1s ease-in-out;
  &:hover,
  &:focus-visible {
    filter: none;
  }
}
.joker-img {
  position: relative;
  display: inline-flex;
  filter: drop-shadow(2px 2px 4px rgb(0 0 0 / .8));
  scale: 1.025;
}
.joker-img:hover,
.joker-img:focus-visible {
  transform: translateY(-4px);
  rotate: -1deg;
  transition: all .2s ease-in-out;
}
label:focus .joker-img {
  outline: 2px solid red;
}

.joker-img:before {
  content: "";
  display: block;
  width: 32px;
  height: 32px;
  background-image: url('../images/gold-sticker.png');
  background-size: 100%;
  background-position: center center;
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  opacity: 0;
  transition: opacity .05s ease-in-out;
}

:checked + .joker-img:before {
  opacity: 1;
}

.flex,
.space-between {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.space-between {
  justify-content: space-between;
}

.stack {
  margin-block-end: 1.5rem;
}

#joker-filter {
  position: relative;
}
#joker-filter button {
  position: absolute;
  right: 2px;
  top: 2px;
  padding: calc(.5rem - 2px) calc(.75rem - 2px);
  background-color: transparent;
  border-color: transparent;
  color: rgb(0 0 0 / .4);
}

#joker-filter button:hover,
#joker-filter button:focus-visible {
  color: rgb(0 0 0 / 1);
}

div:has(.hide-checked-control) {
  text-align: left;
  margin-block-end: 1.5rem;
}
.hide-checked-control {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-size: .75rem;
}

footer {
  color: white;
  font-size: .75rem;
  text-align: center;
  padding: 2rem;
  a {
    color: inherit;
  }
}

.button-group button,
section label,
#reset-jokers,
#clear-filter,
#hide-checked + label,
#hide-checked {
  touch-action: manipulation;
}

.floating-buttons {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
}
.ghost-button {
  background-color: transparent;
  color: rgb(255 255 255 / .4);
  padding: .25rem;
  height: 2rem;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  &:hover,
  &:focus-visible {
    color: rgb(255 255 255 / 1);
    background-color: var(--uncommon);
  }
  .icon {
    width: 20px;
    height: 20px;
  }
}

dialog {
  z-index: 20;
  top: 3.25rem;
  text-align: left;
  width: min(calc(100% - 2rem), max(650px));
  max-height: calc(100% - 6.5rem);
  margin-inline: auto;
  border: 0;
  border-radius: .25rem;
  padding: 2rem;
  background-color: var(--background);
  color: white;
  box-shadow: 0px 0px 1px rgb(0 0 0 / .5), 0px 12px 20px rgb(0 0 0 / 0.5), 0px 16px 28px -8px rgb(0 0 0 / 0.5);
  :not(:last-child) {
    margin-block-end: 1rem;
  }
  &::backdrop {
    background-color: rgb(0 0 0 / .6);
  }
  p {
    line-height: 1.5;
  }
  a {
    color: inherit;
    text-underline-offset: 2px;
  }
}

mark {
  background-color: transparent;
  font-weight: 600;
  color: gold;
}

.text-sm {
  font-size: .875em;
}


.counter[hidden] { display: block; visibility: hidden; }
.sr-only { position:absolute; left:-9999px; }
.preorder-hide section { visibility: hidden; }

@media (width < 537px) {
  #joker-filter {
    flex: 1;
  }
  #joker-filter, #joker-filter input {
    width: 100%;
  }
  .flex {
    width: 100%;
  }
  .counter {
    width: 100%;
    justify-content: space-between;
  }
  h1 {
    font-size: 1.375rem;
    margin-block-end: 1rem;
  }
  main {
    padding: 3rem 1rem;
  }
  .stack {
    margin-block-end: 1rem;
  }
  dialog {
    padding: 1rem;
    font-size: .875em;
  }
}