/*******************************
 Country Modal
 ******************************/

body:has(dialog.country-modal[open]) {
  overflow: hidden;
}

.country-modal {
  position: fixed;
  background-color: transparent;

  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  z-index: 1;

  transition: overlay 250ms allow-discrete;
  animation: close 250ms forwards;
}

.country-modal::backdrop {
  background-color: rgb(var(--mineral-container-inverse));
  opacity: 0.8;
}

.country-modal[open] {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;

  animation: open 250ms forwards;
}

@keyframes open {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes close {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.country-modal-wrapper {
  background-color: rgb(var(--light-container-primary));
  max-width: min(750px, calc(100% - (2 * var(--bleed))));
}

.country-modal-header {
  background: repeat url("/images/CountryModal.png");
  display: flex;
  justify-content: flex-end;
  height: 188px;
}

.country-modal-header button {
  padding: 0.5rem;
  margin: 2rem;
  outline: none;
}

.country-modal-header button .svg {
  width: 1.5rem;
  height: 1.5rem;
}

.country-modal-header button:focus-visible .svg {
  outline: auto;
  outline-offset: 0.5rem;
}

.country-modal-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  margin: 3rem 2rem;
}

.country-modal-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.country-modal-terms {
  border-width: 1px;
  border-color: rgb(var(--light-border-default));
  border-radius: var(--border-radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (max-width: 38rem) {
  .country-modal-title div:first-of-type {
    font-size: 2rem;
  }

  .country-modal-wrapper {
    position: absolute;
    top: 0;
  }
}

@media (max-width: 34rem) {
  .country-modal-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
}

@media (max-width: 32rem) {
  .country-modal-wrapper {
    max-width: min(646px, calc(100% - (2 * 0.75rem)));
  }
}

/*******************************
 Select
 ******************************/

.country-select select {
  appearance: none;
  background-color: transparent;
  border: none;
  padding: 0 1em 0 0;
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: inherit;
  font-size: inherit;
  cursor: inherit;
  line-height: inherit;
  padding-inline: 0.75rem;
}

.country-select {
  width: 100%;
  min-width: 15ch;
  max-width: 30ch;
  border-radius: var(--border-radius);
  border: 1px solid rgb(var(--light-border-default));
  padding: 0.8em 1em;
  cursor: pointer;
  line-height: 1.1;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
}

.country-select::before {
  content: "";
  width: 1.5rem;
  height: 1.5rem;
  background-repeat: no-repeat;
  justify-self: start;
  background-size: 1.5rem 1.5rem;
}

.country-select:has(select > option[value="de-de"]:checked)::before {
  background-image: url("/svgs/flags/de-de.svg");
}

.country-select:has(select > option[value="it-it"]:checked)::before {
  background-image: url("/svgs/flags/it-it.svg");
}

.country-select:has(select > option[value="fr-fr"]:checked)::before {
    background-image: url("/svgs/flags/fr-fr.svg");
}

.country-select:has(select > option[value="en-gb"]:checked)::before {
  background-image: url("/svgs/flags/en-gb.svg");
}

.country-select:has(select > option[value="en-us"]:checked)::before {
  background-image: url("/svgs/flags/en-us.svg");
}

.country-select::after {
  content: "";
  width: 0.8em;
  height: 0.5em;
  background-color: rgb(var(--light-text-primary));
  clip-path: polygon(100% 0%, 0 0%, 50% 100%);
  justify-self: end;
}

@media (max-width: 34rem) {
  .country-select {
    max-width: initial;
  }
}

@media (max-width: 480px) {
    .country-modal-header {
        height: 90px;
    }
}
