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

@font-face {
  font-family: Snap;
  src: url(/assets/snap.ttf);
}

:root {
  --size: 3rem;
  --red: #cd1a1a;
  --light: #3220AC;
  --dark: #0D0B38;
  --skyblue: #94E3FF;
}

body {
  margin: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  place-items: center;
  place-content: stretch;
  background: var(--light);
  font-family: 'Snap', sans-serif;
  font-size: 1.5rem;
  line-height: 1.5;
  text-align: center;
  text-wrap: balance;
}

@media (min-width: 48rem) {
  body {
    display: grid;
    grid-template-columns: minmax(24rem, 33.33333333vw) 1fr;
    place-items: flex-start;
  }
}

button {
  padding: 0;
  color:white;
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
}

.hex {
  position: relative;
  display: flex;
  place-content: center;
  min-height: var(--size);
  transition: all ease-in-out 0.2s;
}

.hex.hexagon {
  width: calc(var(--size)* 1.1547005);
}

.hex.hexagon:before,
.hex.hexagon span {
  padding: 0;
}

.hex:has(svg):before,
.hex:has(svg) span {
  padding-left: calc(var(--size) / 3);
}

.hex:before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #0161C1 1.96%, #01DDFF 50%, #0161C1 98.04%);
  z-index: -2;
  --sizeL: calc(var(--size) + 8px);
  clip-path: polygon(0 50%,calc(var(--sizeL) / 4) 0,calc(100% - (var(--sizeL) / 4)) 0,100% 50%,calc(100% - (var(--sizeL) / 4)) 100%,calc(var(--sizeL) / 4) 100%);
  box-shadow: inset 0px 0px 4px #110000;
}

.hex:after {
  content: "";
  position: absolute;
  inset: 2px;
  background: var(--bg);
  z-index: -1;
  --sizeM: calc(var(--size) + 4px);
  clip-path: polygon(0 50%,calc(var(--sizeM) / 4) 0,calc(100% - (var(--sizeM) / 4)) 0,100% 50%,calc(100% - (var(--sizeM) / 4)) 100%,calc(var(--sizeM) / 4) 100%);
}

.hex span {
  flex: 1;
  margin: 4px;
  color: white;
  font-size: calc(var(--size) / 2);
  font-weight: bold;
  white-space: nowrap;
  padding: 0 calc(var(--size) / 2);
  line-height: calc(var(--size) - 8px);
  clip-path: polygon(0 50%,calc(var(--size) / 4) 0,calc(100% - (var(--size) / 4)) 0,100% 50%,calc(100% - (var(--size) / 4)) 100%,calc(var(--size) / 4) 100%);
  background: linear-gradient(180deg, #000D1A 0%, #00336D 100%);
  box-shadow: inset 0 0 calc(var(--size) / 2) #007EFF;
  transition: all ease-in-out 0.2s;
}

.hex span:has(svg) {
  display: flex;
  place-content: center;
  place-items: center;
}

.hex svg {
  width: calc(var(--size) - 8px);
  height: calc(var(--size) - 8px);
  fill: white;
  display: block;
}

.hex em {
  font-style: unset;
}

.hex.red:before,
.hex.red span {
  filter: hue-rotate(140deg);
}

.hex:active {
  transform: scale(0.9);
}

.hex:hover span {
  box-shadow: inset 0 0 calc(var(--size) / 3 * 2) #007EFF;
}

.stack {
  display: flex;
  flex-direction: column;
  place-items: center;
  gap: 1.5rem;
}

main {
  width: 100%;
  container-type: inline-size;
  z-index: 2;
  padding-bottom: 1rem;
}

header {
  display: flex;
  place-items: center;
  width: 100%;
  padding: 1rem;
}

header button {
  flex: 0 0 auto;
  --bg: var(--light);
}

.circle {
  --size: 2.25rem;
  margin: 0.375rem;
  width: var(--size);
  height: var(--size);
  font-size: calc(var(--size) / 3 * 2);
  border-radius: 50%;
  background: linear-gradient(180deg, #FFFFFF 0%, #CFEDFF 100%);
  color: #003C62;
}

.dropdown {
  position: relative;
}

.actions {
  position: absolute;
  right: 0;
  top: 50%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  max-height: 10rem; /* magic number */
  overflow: hidden;
  transition: all ease-in-out 0.2s;
}

.actions[hidden] {
  max-height: 0;
}

.action {
  --size: 2.5rem;
  display: flex;
  place-items: center;
  padding: .25rem 0.75rem .25rem 0;
  background: linear-gradient(to bottom, #000, #00122C);
  border-image-source: linear-gradient(to bottom, #2A2A2C, #2B4977);
  border-style: solid;
  border-width: 2px;
  border-image-slice: 1;
  color: white;
}

.action svg {
  display: block;
  width: var(--size);
  height: var(--size);
  fill: currentColor;
}

.action em {
  font-style: unset;
  font-size: calc(var(--size) / 2);
  white-space: nowrap;
}

@container (min-width: 24rem) {
  .dropdown {
    display: contents;
  }

  #menu-trigger {
    display: none;
  }

  .actions {
    display: contents;
  }

  .action {
    --size: 3rem;
    border: none;
    background: none;
    padding: 0;
    filter: drop-shadow(0 0 0.25rem var(--skyblue));
    transition: all ease-in-out 0.2s;
  }

  .actions button:hover {
    filter: drop-shadow(0 0 0.1rem var(--skyblue));
    transform: scale(1.1);
  }

  .action em {
    display: none;
  }
}

#deck-name {
  flex: 1;
  width: 0;
  height: var(--size);
  text-align: center;
  font-size: calc(var(--size) / 3 * 2);
  clip-path: polygon(0 100%, calc(var(--size) / 2) 0, 100% 0, calc(100% - (var(--size) / 2)) 100%);
  background: var(--dark);
  border: none;
  color: white;
  font-family: 'Snap', sans-serif;
}

#deck-name:focus {
  outline: none;
}

#deck {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  place-content: start;
  place-items: start;  
  aspect-ratio: 12 / 5;
}

#deck:before {
  content: "";
  position: absolute;
  inset: 0;
  background: url(/assets/placeholder.svg);
  background-size: calc(100% / 6);
  mix-blend-mode: screen;
  opacity: .25;
}

#deck .card {
  display: flex;
  width: calc(100% / 6);
  aspect-ratio: 4 / 5;
  position: relative;
  padding: 0;
  transition: all ease-in-out 0.2s;
}

.card-image {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

.card-description {
  position: absolute;
  top: 100%;
  background: var(--dark);
  width: 150%;
  left: -25%;
  padding: 0.5rem;
  margin: 0;
  display: none;
  font-family: sans-serif;
}

@media not all and (hover: none) {
  #deck .card:hover {
    filter: drop-shadow(0 0 1rem var(--dark));
    transform-origin: center;
    transform: scale(1.1);
    z-index: 1;
  }

  .card:hover .card-description {
    display: block;
  }
}

@media (min-width: 48rem) {
  #deck {
    aspect-ratio: 16 / 15;
    padding: 1rem;;
  }

  #deck:before {
    background-size: calc(100% / 4);
    inset: 1rem;
  }

  #deck .card {
    width: calc(100% / 4);
  }
}

footer {
  align-self: stretch;
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  place-content: flex-start;
  place-items: stretch;
  background: var(--dark);
  color: white;
  overflow-y: scroll;
  padding-bottom: 1rem;
  overflow-x: hidden;
}

.search-bar {
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--dark) 75%, transparent);
  backdrop-filter: blur(1rem);
  display: flex;
  place-content: center;
  place-items: center;
  --size: 3rem;
  padding: 1rem;
  z-index: 2;
}

@media (min-width: 48rem) {
  .search-bar {
    --size: 6rem;
  }
}

#search {
  all: unset;
  flex: 1;
  width: 0%;
  height: var(--size) ;
  font-size: calc(var(--size) / 3 * 2);
  line-height: 1;
  text-align: left;
  color: white;
  text-indent: .5rem;
}

#search::placeholder {
  color: white;
  opacity: .75;
}

#search::-webkit-search-cancel-button {
  -webkit-appearance: none;
  opacity: 0;
}

#clear-search {
  width: var(--size);
  height: var(--size);
  padding: calc(var(--size) / 4);
}

#clear-search[disabled] {
  display: none;
}

#clear-search svg {
  width: 100%;
  height: 100%;
  color: white;
  display: block;
}

#printout {
  padding: 0 1rem;
}

#search-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(calc(100vw / 4), 1fr));
}

@media (min-width: 48rem) {
  #search-results {
    grid-template-columns: repeat(auto-fill, minmax(calc(100vw / 13), 1fr));
    padding: 0 1rem;
  }
}

#search-results .card {
  transition: all ease-in-out 0.2s;
}

#search-results .card:hover,
#search-results .card:hover.selected {
  transform: scale(1.1);
  z-index: 1;
}

#search-results .card.selected .card-image {
  opacity: 0.75;
  transform: scale(0.9);
}

#captions {
  color: white;
  position: absolute;
  top: 0;
  padding: 1rem;
  text-transform: capitalize;
}

#listen {
  position: relative;
  background: none;
  color:white;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  padding: 0;
  border: calc(var(--size) / 18) solid white;
}

#listen:before {
  content: "";
  display: block;
  position: absolute;
  inset: calc(var(--size) / 12);
  background: var(--red);
  border-radius: 50%;
  transition: all ease-in-out 0.2s;
}

#listen.active:before {
  inset: calc(var(--size) / 5);
  border-radius: .5rem;
}

#listen svg {
  width: 100%;
  height: 100%;
  fill: white;
  position: absolute;
  inset: 0;
  padding: calc(var(--size) / 6);
  transition: all ease-in-out 0.2s;
  user-select: none;
}

#listen.active svg {
  opacity: 0;
}

::backdrop {
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(1rem);
}

dialog {
  width: 100%;
  max-width: 32rem;
  height: 100%;
  max-height: unset;
  margin: 0 auto;
  padding: 1rem;
  background: linear-gradient(9deg, #020A0B 70.42%, #2B3638 70.42%, #55696E 100%);
  color:white;
  border: 4px outset #7a999f;
  container-type: inline-size;
  --bg: #020A0B;
  --size: 4rem;
}

dialog h1 {
  font-size: clamp(1rem, 11vw, 3rem);
  width: 100%;
  margin: 0;
  text-align: center;
  background: linear-gradient(#FFF, #CFEDFF);
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

dialog p {
  margin: 1.5rem 0;
  font-family: sans-serif;
  font-style: italic;
  font-size: 1.25rem;
}

dialog form {
  display: flex;
  place-content: center;
  gap: .5rem;
}

dialog form button {
  --bg: #020A0B;
}

dialog form button:focus {
  outline: none;
}
