/*
  FTN Platform Website — Country switcher (v1.6 Caribbean Executive Identity pass).
  Architecture scaffold: a first-visit welcome dialog and a small header control, both
  reusing the accessible-dialog shell pattern already established by trust-card.css.
*/

.country-switcher-trigger {
  /* Hidden below 1024px -- reachable via the mobile nav panel instead
     (.mobile-nav__country-switcher below), matching how the rest of the header already
     defers to the mobile nav under that breakpoint. From 1024px it's icon-only (just the
     pin) to stay inside the documented 1024px nav-wrap budget (RELEASE_NOTES_v1.4.md) --
     adding a full text pill here caused real horizontal overflow, not just the
     already-accepted item-wrap. The country name only appears once there's real room, at
     >=1440px. */
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--text-small-size);
  font-weight: 600;
  color: var(--color-graphite);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

/* Base state: hidden everywhere the label could show it (mobile nav gets its own always-visible
   override below). Must come before the 1440px media query below it in source order -- an
   unscoped rule appearing AFTER a media-query rule of equal specificity wins the cascade
   regardless of the media query, which previously made this permanently display:none at every
   viewport width including >=1440px (a real bug: fixed here, engineering pass). */
.country-switcher-trigger__label {
  display: none;
}

@media (min-width: 1024px) {
  .country-switcher-trigger {
    display: inline-flex;
  }
}

@media (min-width: 1440px) {
  .country-switcher-trigger {
    width: auto;
    gap: var(--space-8);
    padding: var(--space-8) var(--space-12);
  }

  .country-switcher-trigger__label {
    display: inline;
  }
}

.mobile-nav__country-switcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8);
  width: 100%;
  padding: var(--space-12) var(--space-16);
  background: var(--color-tint);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-8);
  font-size: var(--text-small-size);
  font-weight: 600;
  color: var(--color-black);
  cursor: pointer;
}

/* The mobile nav panel is a full-width list, not a compact header pill -- there's always room
   for the label here, unlike the header trigger's viewport-gated version above. */
.mobile-nav__country-switcher .country-switcher-trigger__label {
  display: inline;
}

@media (min-width: 1024px) {
  .mobile-nav__country-switcher {
    display: none;
  }
}

.country-switcher-trigger:hover {
  border-color: var(--color-black);
  color: var(--color-black);
}

.country-switcher-trigger__pin {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-red);
  flex-shrink: 0;
}

/* Dialog shell */
.country-switcher-dialog {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: var(--space-24);
}

.country-switcher-dialog.is-open {
  display: flex;
}

.country-switcher-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 11, 11, 0.6);
}

.country-switcher-dialog__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--color-white);
  border-radius: var(--radius-16);
  box-shadow: var(--shadow-xl);
  padding: var(--space-32);
}

.country-switcher-dialog__header {
  position: relative;
  margin-bottom: var(--space-24);
}

.country-switcher-dialog__header h2 {
  font-size: var(--text-h2-size);
  line-height: var(--text-h2-line);
  letter-spacing: -0.01em;
  max-width: 24ch;
  margin-bottom: var(--space-12);
}

.country-switcher-dialog__header p {
  color: var(--color-graphite);
  font-size: var(--text-small-size);
  max-width: 48ch;
}

.country-switcher-dialog__close {
  position: absolute;
  top: 0;
  right: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-graphite);
}

.country-switcher-dialog__close:hover {
  color: var(--color-black);
  border-color: var(--color-black);
}

.country-switcher__grid {
  display: grid;
  gap: var(--space-8);
  grid-template-columns: 1fr;
}

@media (min-width: 480px) {
  .country-switcher__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.country-switcher__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8);
  text-align: left;
  padding: var(--space-12) var(--space-16);
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-8);
  font-size: var(--text-small-size);
  font-weight: 600;
  color: var(--color-black);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.country-switcher__option:hover {
  border-color: var(--color-red);
  background: var(--color-tint);
}

.country-switcher__option.is-selected {
  border-color: var(--color-red);
  background: rgba(225, 6, 19, 0.04);
}

.country-switcher__option-tag {
  font-size: var(--text-caption-size);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--color-red);
  white-space: nowrap;
}

/* First-visit variant: no visible close affordance (a real selection is the only exit), but
   still keyboard-operable via Tab through the options -- Escape is deliberately suppressed
   only for this variant (js/country-switcher.js), never for the reopened header version. */
.country-switcher-dialog--first-visit .country-switcher-dialog__backdrop {
  cursor: default;
}
