.language-page {
  background:
    linear-gradient(112deg, transparent 0 57%, rgb(245 243 238 / 38%) 57% 100%),
    var(--color-page);
}

.language-workbench {
  position: relative;
  min-block-size: 100vh;
  min-block-size: 100svh;
  padding: 4.25rem var(--page-gutter) clamp(2rem, 4vw, 3.75rem);
}

.language-layout {
  position: relative;
  display: grid;
  inline-size: min(100%, 56rem);
  margin-inline: auto;
  grid-template-columns: minmax(0, 1fr);
  row-gap: 1.5rem;
  align-items: center;
}

.flags-panel {
  min-inline-size: 0;
  inline-size: min(100%, 28rem);
  block-size: clamp(15rem, 56vw, 20rem);
  justify-self: center;
  container-type: size;
}

.map-panel {
  position: relative;
}

.map-country-overlay {
  position: absolute;
  z-index: 2;
  inset-block-start: var(--space-4);
  inset-inline-start: var(--space-4);
  margin: 0;
  max-inline-size: calc(100% - var(--space-8));
  color: var(--color-on-structure);
  font-family: var(--font-technical);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.25;
  overflow-wrap: anywhere;
  pointer-events: none;
  text-transform: uppercase;
  word-break: normal;
}

.language-options {
  --language-flag-height: min(23cqb, 69cqi);
  --language-flag-width: calc(var(--language-flag-height) * 4 / 3);
  --language-flag-gap: calc(
    (100cqb - var(--language-flag-height) - var(--language-flag-height) - var(--language-flag-height) - var(--language-flag-height)) / 3
  );

  display: grid;
  inline-size: 100%;
  block-size: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  align-content: start;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(4, var(--language-flag-height));
  row-gap: var(--language-flag-gap);
  list-style: none;
}

.language-option-row {
  inline-size: var(--language-flag-width);
  max-inline-size: 100%;
  min-block-size: 0;
  justify-self: center;
}

.language-option {
  position: relative;
  display: grid;
  inline-size: 100%;
  block-size: 100%;
  min-inline-size: 0;
  min-block-size: 0;
  padding: 0;
  border: var(--border-subtle);
  background: rgb(245 243 238 / 28%);
  place-items: center;
}

.language-flag {
  position: relative;
  display: grid;
  inline-size: 100%;
  block-size: 100%;
  place-items: center;
}

.language-flag[data-flag-asset-state="missing"] {
  background: rgb(103 109 113 / 17%);
}

.language-option__flag {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: contain;
}

.language-option--available .language-option__flag {
  object-position: center;
  opacity: 0.25;
}

.language-option--available[aria-pressed="true"] .language-option__flag {
  opacity: 1;
}

.language-option--unavailable .language-option__flag {
  filter: grayscale(1);
  opacity: 1;
}

.language-option--unavailable::after {
  position: absolute;
  inset-block-start: var(--space-1);
  inset-inline-end: var(--space-1);
  display: grid;
  inline-size: 1.5rem;
  block-size: 1.5rem;
  border: 1px solid rgb(245 243 238 / 62%);
  background: rgb(32 36 39 / 84%);
  color: var(--color-on-structure);
  content: "\2692";
  font-family: var(--font-technical);
  font-size: 0.875rem;
  line-height: 1;
  pointer-events: none;
  place-items: center;
}

.map-panel,
.map-frame,
.europe-map {
  inline-size: 100%;
  min-inline-size: 0;
}

.map-frame {
  position: relative;
  max-inline-size: 56rem;
  max-block-size: 34rem;
  aspect-ratio: 56 / 34;
  border: 1px solid rgb(245 243 238 / 18%);
  background:
    radial-gradient(circle at 52% 46%, rgb(103 109 113 / 17%), transparent 55%),
    linear-gradient(145deg, #34393c, #202427 72%);
  box-shadow: 0 1.5rem 3.5rem rgb(17 19 21 / 16%);
  overflow: hidden;
}

.europe-map {
  block-size: 100%;
  user-select: none;
  touch-action: pan-y;
}

.europe-map[data-zoomed="true"] {
  touch-action: none;
}

.europe-map__grid path {
  fill: none;
  stroke: rgb(245 243 238 / 6%);
  stroke-width: 1;
}

.europe-country {
  color: rgb(245 243 238 / 78%);
  outline: none;
}

.europe-country__shape {
  fill: #555c60;
  stroke: rgb(231 228 222 / 42%);
  stroke-width: 0.85;
  transition:
    fill var(--motion-fast) linear,
    stroke var(--motion-fast) linear;
}

.europe-country__locator {
  fill: var(--color-accent);
  stroke: #202427;
  stroke-width: 1.5;
  pointer-events: none;
}

.europe-country__locator-leader {
  stroke: var(--color-accent);
  stroke-width: 1;
  opacity: 0.72;
  pointer-events: none;
}

.europe-country__hit-target {
  fill: transparent;
  stroke: transparent;
  stroke-width: 34;
  pointer-events: all;
}

.europe-country[data-selected="true"] .europe-country__shape {
  fill: var(--color-accent);
  stroke: var(--color-on-structure);
  stroke-width: 1.8;
}

.europe-country[data-selected="true"] .europe-country__locator {
  fill: var(--color-on-structure);
  stroke: var(--color-accent);
  stroke-width: 3;
}

.europe-country:focus-visible .europe-country__shape {
  fill: #777d80;
  stroke: var(--color-on-structure);
  stroke-width: 2.2;
}

.map-controls {
  position: absolute;
  z-index: 3;
  inset-inline-start: 1rem;
  inset-block-end: 1rem;
  display: flex;
  flex-direction: column;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.map-controls button {
  appearance: none;
  min-inline-size: 2.75rem;
  min-block-size: 2.75rem;
  padding: 0.45rem 0.65rem;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--color-on-structure);
  font-family: var(--font-technical);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
}

@media (hover: hover) {
  .europe-country:hover .europe-country__shape {
    fill: #737a7e;
    stroke: var(--color-on-structure);
    stroke-width: 1.4;
  }

  .europe-country[data-selected="true"]:hover .europe-country__shape {
    fill: var(--color-accent);
  }

  .language-option--available:not([aria-pressed="true"]):hover .language-option__flag {
    opacity: 0.5;
  }

  .language-option--available[aria-pressed="true"]:hover .language-option__flag {
    opacity: 1;
  }
}

@media (min-width: 48rem) and (min-height: 40rem) and (orientation: landscape) and (max-aspect-ratio: 11 / 5) {
  .language-workbench {
    display: grid;
    block-size: 100vh;
    block-size: 100svh;
    min-block-size: 0;
    padding: 0;
    align-items: center;
  }

  .language-layout {
    inline-size: 100%;
    aspect-ratio: 140 / 51;
    grid-template-columns: 20% 60% 20%;
    grid-template-rows: minmax(0, 1fr);
    row-gap: 0;
    --language-side-inset: clamp(1rem, 2vw, 2rem);
  }

  .flags-panel {
    inline-size: calc(100% - var(--language-side-inset) - var(--language-side-inset));
    block-size: 100%;
    padding-inline: 0;
  }

  .map-panel {
    block-size: 100%;
  }

  .map-frame {
    max-inline-size: none;
    max-block-size: none;
    block-size: 100%;
    aspect-ratio: auto;
  }
}

@media (max-width: 36rem) {
  .language-page {
    block-size: 100vh;
    block-size: 100dvh;
    min-block-size: 0;
    overflow: hidden;
  }

  .language-workbench {
    block-size: 100%;
    min-block-size: 0;
    padding: 4.25rem max(1rem, env(safe-area-inset-right))
      max(0.5rem, env(safe-area-inset-bottom))
      max(1rem, env(safe-area-inset-left));
  }

  .language-layout {
    inline-size: 100%;
    margin-inline: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    row-gap: 0.4rem;
    align-items: start;
  }

  .map-panel {
    display: grid;
    min-block-size: 0;
    grid-row: 1;
    align-items: start;
    justify-items: start;
  }

  .flags-panel {
    inline-size: 100%;
    block-size: auto;
    justify-self: start;
    container-type: inline-size;
  }

  .flags-panel--available {
    grid-row: 2;
  }

  .flags-panel--unavailable {
    grid-row: 3;
  }

  .language-options {
    --language-phone-flag-gap: 0.4rem;
    --language-phone-slot-width: calc(
      (100cqi - (3 * var(--language-phone-flag-gap))) / 4
    );
    --language-phone-vertical-flag-width: max(
      0rem,
      calc(
        (
          100dvh
          - 4.25rem
          - max(0.5rem, env(safe-area-inset-bottom))
          - (100cqi * 34 / 56)
          - (2 * var(--language-phone-flag-gap))
        ) * 2 / 3
      )
    );
    --language-phone-flag-width: min(
      var(--language-phone-slot-width),
      var(--language-phone-vertical-flag-width)
    );
    --language-phone-flag-height: calc(var(--language-phone-flag-width) * 3 / 4);
    --language-flag-height: var(--language-phone-flag-height);
    --language-flag-width: var(--language-phone-flag-width);
    --language-flag-gap: var(--language-phone-flag-gap);

    block-size: var(--language-phone-flag-height);
    grid-template-columns: repeat(4, var(--language-phone-flag-width));
    grid-template-rows: var(--language-phone-flag-height);
    column-gap: var(--language-phone-flag-gap);
    row-gap: 0;
  }

  .language-option-row {
    justify-self: start;
  }

  .map-frame {
    block-size: auto;
    max-block-size: none;
    aspect-ratio: 56 / 34;
  }
}

@media (max-width: 36rem) and (orientation: landscape) {
  .language-layout {
    block-size: 100%;
    grid-template-rows: minmax(0, 1fr) auto auto;
  }

  .map-panel {
    block-size: 100%;
  }

  .flags-panel {
    inline-size: min(
      100%,
      calc(
        (
          100dvh
          - 4.25rem
          - max(0.5rem, env(safe-area-inset-bottom))
          - (2 * 3.45rem)
          - (2 * 0.4rem)
        ) * 56 / 34
      )
    );
    block-size: 3.45rem;
  }

  .map-frame {
    inline-size: auto;
    max-inline-size: 100%;
    block-size: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .europe-country__shape {
    transition-duration: 1ms;
  }
}
