/* ===== EUTOPIIIA — LANG PICKER (standalone) ===== */

.euto-topbar__row { position: relative; }

.euto-lang{
  position: absolute;
  right: clamp(10px, 2vw, 24px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 9999;
  --size: 34px;     /* diametro pallino */
  --ring: 1px;     /* bordo pallino */
  --shadow: 0 6px 18px rgba(0,0,0,.35);
}

.euto-lang * { pointer-events: auto; }

/* Pallino */
.euto-lang__current{
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  border: var(--ring) solid rgba(255,255,255,.22);
  background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.04));
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
  display: grid; place-items: center;
  cursor: pointer; padding: 0; outline: 0; appearance: none;
}
.euto-lang__current:focus-visible{
  box-shadow: 0 0 0 6px rgba(229,229,229,.14), 0 0 0 1px rgba(229,229,229,.55) inset;
}

/* Bandiera nel pallino (JS imposta image) */
.euto-lang__flag{
  width: calc(var(--size) - 10px);
  height: calc(var(--size) - 10px);
  border-radius: 50%;
  background-size: 100% 100%;   /* <— evita “cover” e ridimensionamenti strani */
  background-position: center;
  background-repeat: no-repeat;
  border: 1px solid rgba(0,0,0,.12);
}

/* Badge IT/EN */
.euto-lang__badge{
  position: absolute;
  right: 0;
  top: -26px;  /* sopra quando chiuso */
  font: 800 11px/1 Inter, system-ui, sans-serif;
  letter-spacing: .04em;
  color: #000; background: #fff;
  border-radius: 999px; padding: 6px 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
  pointer-events: none;
}

/* Dropdown */
.euto-lang__dropdown{
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 140px; padding: 6px; margin: 0; list-style: none;
  background: rgba(20,20,20,.92);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px; box-shadow: 0 14px 40px rgba(0,0,0,.45);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.euto-lang__dropdown[hidden]{ display: none; }

.euto-lang__option{
  width: 100%;
  display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: center;
  padding: 8px 10px; background: transparent; border: 0; color: #eee;
  font: 600 13px/1 Inter, system-ui, sans-serif; text-align: left;
  border-radius: 10px; cursor: pointer;
}
.euto-lang__option:hover{ background: rgba(255,255,255,.06); }
.euto-lang__option:focus-visible{ outline: 0; box-shadow: inset 0 0 0 2px rgba(229,229,229,.55); border-radius: 10px; }

/* Icona bandiera nel menu (EN inline) */
.euto-lang__option .euto-lang__flag{
  width: 22px; height: 22px; border-radius: 50%;
  background-size: cover; background-position: center; background-repeat: no-repeat;
  border: 1px solid rgba(0,0,0,.12);
}
.euto-lang__flag--en{
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'><defs><clipPath id='c'><circle cx='9' cy='9' r='9'/></clipPath></defs><g clip-path='url(%23c)'><rect width='18' height='18' fill='%23012169'/><line x1='0' y1='0' x2='18' y2='18' stroke='%23ffffff' stroke-width='5'/><line x1='0' y1='18' x2='18' y2='0' stroke='%23ffffff' stroke-width='5'/><rect x='7' y='0' width='4' height='18' fill='%23ffffff'/><rect x='0' y='7' width='18' height='4' fill='%23ffffff'/><line x1='0' y1='0' x2='18' y2='18' stroke='%23c8102e' stroke-width='3'/><line x1='0' y1='18' x2='18' y2='0' stroke='%23c8102e' stroke-width='3'/><rect x='7.5' y='0' width='3' height='18' fill='%23c8102e'/><rect x='0' y='7.5' width='18' height='3' fill='%23c8102e'/></g></svg>");
}

/* Mobile */
@media (max-width:640px){
  .euto-lang{ --size: 30px; right: 10px; }
  .euto-lang__dropdown{ min-width: 128px; }
}
/* disattiva la badge lingua */
.euto-lang__badge{ display:none !important; }
.euto-lang, .euto-lang * { pointer-events: auto; z-index: 9999; }
/* Opzione corrente evidenziata e non cliccabile */
.euto-lang__option.is-active{
  background: rgba(255,255,255,.10);
  cursor: default;
}
.euto-lang__option.is-active:focus-visible{
  box-shadow: none;
}
/* --- Pallino: bandiera dalla lingua attiva (usa i file in /assets/ui/) --- */
.euto-lang[data-active="it"] .euto-lang__current .euto-lang__flag{
  background-image: url("/assets/ui/flag-it.svg");   /* o .png se preferisci */
  background-size: 100% 100%;
}
.euto-lang[data-active="en"] .euto-lang__current .euto-lang__flag{
  background-image: url("/assets/ui/flag-en.svg");
  background-size: 100% 100%;
}

/* --- Menu: bandierine file-based --- */
.euto-lang__flag--it{
  background-image: url("/assets/ui/flag-it.svg");
  background-size: 100% 100%;
}
.euto-lang__flag--en{
  background-image: url("/assets/ui/flag-en.svg");
  background-size: 100% 100%;
}
/* Fallback: prima immagine = IT */
.euto-lang .euto-lang__current .euto-lang__flag{
  background-image: url("/assets/ui/flag-it.svg");
  background-size: 100% 100%;
}
/* ===== Mobile XXL for Lang Picker ===== */
@media (max-width: 640px){
  .euto-lang{
    --size: 44px;                /* pallino più grande (min 44px touch) */
    right: 12px;
  }

  .euto-lang__current{
    border-width: 1.5px;
    background: rgba(15,15,15,.95);
    backdrop-filter: none;       /* iOS fix */
    -webkit-backdrop-filter: none;
    box-shadow: 0 8px 24px rgba(0,0,0,.45);
  }

  .euto-lang__current .euto-lang__flag{
    width: calc(var(--size) - 10px);
    height: calc(var(--size) - 10px);
    background-size: 100% 100%;
  }

  /* Dropdown più comodo al tatto */
  .euto-lang__dropdown{
    min-width: 180px;
    padding: 10px;
    top: calc(100% + 10px);
    border-radius: 14px;
  }

  .euto-lang__option{
    grid-template-columns: 28px 1fr;
    gap: 12px;
    padding: 12px 12px;          /* area tap maggiore */
    font-size: 15px;
    border-radius: 12px;
  }

  .euto-lang__option .euto-lang__flag{
    width: 28px;
    height: 28px;
    background-size: 100% 100%;
  }
}
/* il dropdown non deve essere tagliato */
.euto-topbar__row,
.euto-lang { overflow: visible !important; }

/* i click/tap devono passare SEMPRE al picker */
.euto-lang, .euto-lang * { pointer-events: auto !important; }

/* sopra a eventuali overlay della topbar */
.euto-lang { z-index: 9999 !important; }

/* su iOS evita problemi di blur che “mangia” i tap sul contenuto */
@media (max-width: 640px){
  .euto-lang__current{
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}
/* ===== Bandiera full-bleed nel pallino ===== */

/* il bottone resta rotondo e con il bordo/ombra */
.euto-lang__current{
  --ring: 1px;
  position: relative;
  overflow: hidden;            /* ritaglia perfettamente in cerchio */
  border-radius: 50%;
}

/* la bandiera occupa 100% del pallino (senza margini interni) */
.euto-lang__current .euto-lang__flag{
  position: absolute;
  inset: 0;                    /* top:0 right:0 bottom:0 left:0 */
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-size: 100% 100%;  /* niente “cover”: riempie esatto */
  background-position: center;
  background-repeat: no-repeat;
  border: 0;                   /* niente bordino interno */
}

/* opzionale: su iOS evita artefatti quando c’è blur */
@supports (-webkit-touch-callout: none){
  .euto-lang__current{ backdrop-filter: none; -webkit-backdrop-filter: none; }
}
