/* ==========================================================================
   Maternl Companion — Language Picker
   Mobile-first, accessible, dependency-free.
   ========================================================================== */

.mlp-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  min-height: 44px; /* comfortable tap target on iPhone */
  border: 1px solid #d8dde3;
  border-radius: 999px;
  background: #ffffff;
  color: #1f2933;
  font-size: 0.9rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.mlp-trigger:hover {
  background: #f4f6f8;
}

.mlp-trigger:focus-visible {
  outline: 2px solid #2f6feb;
  outline-offset: 2px;
}

.mlp-trigger__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* -------------------------------------------------------------------------
   Overlay + dialog
   ------------------------------------------------------------------------- */

.mlp-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 32, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.mlp-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

@media (min-width: 640px) {
  .mlp-overlay {
    align-items: center;
  }
}

.mlp-dialog {
  width: 100%;
  max-width: 480px;
  max-height: min(80vh, 640px);
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  transform: translateY(24px);
  transition: transform 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1f2933;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mlp-overlay.is-open .mlp-dialog {
  transform: translateY(0);
}

@media (min-width: 640px) {
  .mlp-dialog {
    border-radius: 20px;
    max-height: min(72vh, 600px);
  }
}

.mlp-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem 0.75rem;
  border-bottom: 1px solid #eef1f4;
}

.mlp-dialog__title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
}

.mlp-dialog__close {
  border: none;
  background: transparent;
  font-size: 1.35rem;
  line-height: 1;
  padding: 0.35rem;
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  color: #6b7684;
  cursor: pointer;
}

.mlp-dialog__close:hover {
  background: #f4f6f8;
}

.mlp-dialog__close:focus-visible {
  outline: 2px solid #2f6feb;
  outline-offset: 2px;
}

/* -------------------------------------------------------------------------
   Search
   ------------------------------------------------------------------------- */

.mlp-search {
  margin: 0.85rem 1.25rem;
  position: relative;
}

.mlp-search input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.9rem;
  font-size: 16px; /* keep >=16px so iOS Safari doesn't zoom on focus */
  border: 1px solid #d8dde3;
  border-radius: 12px;
  background: #f7f9fa;
  color: #1f2933;
}

.mlp-search input:focus-visible {
  outline: 2px solid #2f6feb;
  outline-offset: 1px;
  background: #ffffff;
}

.mlp-search input::placeholder {
  color: #9aa4b1;
}

/* -------------------------------------------------------------------------
   Language list
   ------------------------------------------------------------------------- */

.mlp-list-wrap {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  padding: 0 0.5rem 0.75rem;
}

.mlp-group-label {
  padding: 0.6rem 1rem 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9aa4b1;
}

.mlp-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mlp-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  min-height: 44px;
  border: none;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: #1f2933;
}

.mlp-option:hover {
  background: #f4f6f8;
}

.mlp-option:focus-visible {
  outline: 2px solid #2f6feb;
  outline-offset: 2px;
}

.mlp-option.is-active {
  background: #eef4ff;
}

.mlp-option__text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.mlp-option__native {
  font-size: 0.98rem;
  font-weight: 600;
}

.mlp-option__english {
  font-size: 0.8rem;
  color: #6b7684;
}

.mlp-option__check {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #2f6feb;
  visibility: hidden;
}

.mlp-option.is-selected .mlp-option__check {
  visibility: visible;
}

.mlp-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: #9aa4b1;
  font-size: 0.9rem;
}

/* -------------------------------------------------------------------------
   Footer
   ------------------------------------------------------------------------- */

.mlp-dialog__footer {
  padding: 0.75rem 1.25rem 1rem;
  border-top: 1px solid #eef1f4;
  font-size: 0.8rem;
  color: #6b7684;
  text-align: center;
}

.mlp-dialog__footer button {
  background: none;
  border: none;
  color: #2f6feb;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem;
}

/* -------------------------------------------------------------------------
   RTL support (applied to <html dir="rtl"> when Arabic is active)
   ------------------------------------------------------------------------- */

[dir="rtl"] .mlp-option {
  text-align: right;
}

[dir="rtl"] .mlp-dialog__header,
[dir="rtl"] .mlp-option {
  flex-direction: row-reverse;
}

/* -------------------------------------------------------------------------
   Reduced motion
   ------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .mlp-overlay,
  .mlp-dialog {
    transition: none;
  }
}

.mlp-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
