/* Menu profilo ancorato all’icona — stile unificato (marketing + app SPA) */

html.spisa-logged-in .spisa-header-settings-gear {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Pill marketing in navbar: visibili solo da ospite */
html.spisa-logged-in .site-header__pill--marketing-nav,
html.spisa-logged-in nav.sticky.top-0 a.site-header__pill--marketing-nav,
html.spisa-logged-in nav.sticky.top-0 a[href*='chi-siamo.html'],
html.spisa-logged-in nav.sticky.top-0 a[href*='around_me.html'],
html.spisa-logged-in nav.sticky.top-0 a[href*='contact.html'] {
  display: none !important;
}

.profile-menu-anchor {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Trigger (avatar) */
.profile-menu__trigger,
a.profile-menu__trigger,
.home-nav-auth-link.profile-menu__trigger,
.site-header__auth.profile-menu__trigger {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0 !important;
  border-radius: var(--radius-full, 9999px);
  border: 1px solid oklch(from #00d2ff l c h / 0.35);
  background: oklch(from #00d2ff l c h / 0.12);
  color: #00d2ff;
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--transition-interactive, 180ms ease),
    border-color var(--transition-interactive, 180ms ease),
    color var(--transition-interactive, 180ms ease);
}

.profile-menu__trigger:hover,
.profile-menu__trigger:focus-visible {
  background: #00d2ff;
  color: #0b1120;
  outline: none;
}

.profile-menu__initials {
  font-size: var(--text-xs, 0.75rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
}

.profile-menu__trigger .fa-user {
  font-size: 1.125rem;
}

/* Popover ancorato sotto il trigger */
.profile-menu__popover {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  width: min(18rem, calc(100vw - var(--space-6, 1.5rem)));
  z-index: 10050;
  opacity: 0;
  transform: scale(0.95);
  transform-origin: top right;
  pointer-events: none;
  visibility: hidden;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    visibility 0s linear 0.2s;
}

.profile-menu__popover--open {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  visibility: visible;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    visibility 0s;
}

/* Portale su body: sopra navbar e senza clip overflow */
.profile-menu__popover.profile-menu__popover--portal {
  position: fixed;
  z-index: 10070;
}

.profile-menu__popover.profile-menu__popover--portal.profile-menu__popover--open {
  z-index: 10070;
  transition:
    opacity 0.1s ease,
    transform 0.1s ease,
    visibility 0s;
}

/* Freccia verso l’avatar */
.profile-menu__caret {
  position: absolute;
  top: -0.45rem;
  right: 0.85rem;
  width: 0.85rem;
  height: 0.85rem;
  transform: rotate(45deg);
  background: oklch(from #111827 l c h / 0.96);
  border-left: 1px solid oklch(from #fff l c h / 0.1);
  border-top: 1px solid oklch(from #fff l c h / 0.1);
  z-index: 0;
  pointer-events: none;
}

.profile-menu__panel {
  position: relative;
  z-index: 1;
  border-radius: 1rem;
  overflow: hidden;
  background: oklch(from #111827 l c h / 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid oklch(from #fff l c h / 0.1);
  box-shadow: 0 15px 40px oklch(0 0 0 / 0.7);
}

/* App nativa: blur costoso su GPU — pannello opaco, stesso aspetto */
html.spisa-native-app .profile-menu__panel {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: #111827;
}

.profile-menu__header {
  padding: var(--space-5, 1.25rem);
  border-bottom: 1px solid oklch(from #fff l c h / 0.06);
  background: oklch(from #fff l c h / 0.02);
}

.profile-menu__name {
  margin: 0;
  font-size: var(--text-base, 1rem);
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-menu__email {
  margin: var(--space-1, 0.25rem) 0 0;
  font-size: var(--text-xs, 0.75rem);
  font-weight: 500;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-menu__badge-incomplete {
  display: inline-block;
  margin-top: var(--space-2, 0.5rem);
  padding: 0.125rem var(--space-2, 0.5rem);
  border-radius: var(--radius-full, 9999px);
  background: oklch(from #f97316 l c h / 0.15);
  color: #fb923c;
  font-size: 0.65rem;
  font-weight: 600;
}

.profile-menu__list {
  list-style: none;
  margin: 0;
  padding: var(--space-2, 0.5rem) 0;
}

.profile-menu__item {
  margin: 0;
}

.profile-menu__btn,
a.profile-menu__btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3, 0.75rem);
  width: 100%;
  min-height: 2.75rem;
  padding: var(--space-3, 0.75rem) var(--space-5, 1.25rem);
  border: none;
  background: transparent;
  color: #cbd5e1;
  font-size: var(--text-sm, 0.875rem);
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  transition:
    background var(--transition-interactive, 180ms ease),
    color var(--transition-interactive, 180ms ease);
}

.profile-menu__btn-inner {
  display: flex;
  align-items: center;
  gap: var(--space-3, 0.75rem);
  min-width: 0;
}

.profile-menu__btn-icon {
  width: 1.25rem;
  text-align: center;
  color: #64748b;
  flex-shrink: 0;
  transition: color var(--transition-interactive, 180ms ease);
}

.profile-menu__btn-label {
  flex: 1;
  min-width: 0;
}

.profile-menu__item-badge {
  flex-shrink: 0;
  margin-left: auto;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full, 9999px);
  background: #f97316;
  color: #0b1120;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
}

[data-theme='light'] .profile-menu__item-badge,
.light .profile-menu__item-badge {
  color: #fff;
}

.profile-menu__btn-chevron {
  font-size: 0.625rem;
  color: #64748b;
  opacity: 0;
  transition: opacity var(--transition-interactive, 180ms ease);
}

.profile-menu__btn:hover,
.profile-menu__btn:focus-visible {
  background: oklch(from #fff l c h / 0.05);
  outline: none;
}

.profile-menu__btn:hover .profile-menu__btn-chevron {
  opacity: 1;
}

.profile-menu__btn--accent-teal:hover {
  color: #00d2ff;
}

.profile-menu__btn--accent-teal:hover .profile-menu__btn-icon {
  color: #00d2ff;
}

.profile-menu__btn--accent-orange:hover {
  color: #f97316;
}

.profile-menu__btn--accent-orange:hover .profile-menu__btn-icon {
  color: #f97316;
}

.profile-menu__divider {
  height: 1px;
  margin: var(--space-1, 0.25rem) var(--space-4, 1rem);
  border: none;
  background: oklch(from #fff l c h / 0.06);
}

.profile-menu__footer {
  padding: var(--space-2, 0.5rem);
  border-top: 1px solid oklch(from #fff l c h / 0.06);
  background: oklch(from #fff l c h / 0.02);
}

.profile-menu__logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2, 0.5rem);
  width: 100%;
  min-height: 2.75rem;
  padding: var(--space-3, 0.75rem);
  border: none;
  border-radius: var(--radius-lg, 0.75rem);
  background: transparent;
  color: #f87171;
  font-size: var(--text-sm, 0.875rem);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition-interactive, 180ms ease);
}

.profile-menu__logout:hover,
.profile-menu__logout:focus-visible {
  background: oklch(from #ef4444 l c h / 0.12);
  outline: none;
}

/* Shell globale (solo foglio sezione) */
.profile-menu-shell {
  position: fixed;
  inset: 0;
  z-index: 10040;
  pointer-events: none;
  visibility: hidden;
}

/* Porta header/nav sopra il contenuto quando il menu è aperto */
body.profile-menu-dropdown-open .profile-menu-anchor {
  z-index: 10055;
}

body.profile-menu-dropdown-open nav.sticky.top-0,
body.profile-menu-dropdown-open .site-header {
  z-index: 10055;
  overflow: visible;
}

nav.sticky.top-0 .profile-menu-anchor {
  overflow: visible;
}

/* Nessun overlay scuro: il menu è un dropdown, la chiusura è via pointerdown fuori */
body.profile-menu-dropdown-open::before {
  content: none;
  display: none;
}

/* Menu a foglio: non tagliato dalla navbar con overflow-x */
.profile-menu__popover.profile-menu__popover--mobile {
  position: fixed !important;
  left: 0.75rem !important;
  right: 0.75rem !important;
  bottom: calc(4.85rem + env(safe-area-inset-bottom, 0px)) !important;
  top: auto !important;
  width: auto !important;
  max-width: none !important;
  margin-top: 0 !important;
  z-index: 10056 !important;
  transform: translateY(0.75rem);
}

.profile-menu__popover.profile-menu__popover--mobile.profile-menu__popover--open {
  transform: translateY(0);
}

.profile-menu__popover.profile-menu__popover--mobile .profile-menu__caret {
  display: none;
}

.profile-menu__popover.profile-menu__popover--mobile .profile-menu__panel {
  max-height: min(70dvh, 32rem);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

html.spisa-native-app .profile-menu__popover.profile-menu__popover--mobile {
  bottom: calc(5rem + env(safe-area-inset-bottom, 0px)) !important;
}

/* Foglio sezione (fullscreen) */
.profile-menu__sheet {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: flex;
  flex-direction: column;
  background: #0b1120;
  color: #e2e8f0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition-interactive, 180ms ease);
}

.profile-menu__sheet--open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.profile-menu__sheet-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3, 0.75rem);
  padding: var(--space-3, 0.75rem) var(--space-4, 1rem);
  border-bottom: 1px solid oklch(from #fff l c h / 0.08);
  background: #111827;
}

.profile-menu__sheet-back {
  min-width: 2.75rem;
  min-height: 2.75rem;
  border: none;
  border-radius: var(--radius-md, 0.5rem);
  background: oklch(from #fff l c h / 0.06);
  color: #e2e8f0;
  cursor: pointer;
}

.profile-menu__sheet-title {
  margin: 0;
  font-size: var(--text-base, 1rem);
  font-weight: 600;
}

.profile-menu__sheet-body {
  flex: 1;
  overflow: auto;
  padding: var(--space-4, 1rem);
  background: #0b1120;
}

.profile-menu__sheet-body .profile-drawer__section-title {
  display: none;
}

.site-header__auth-badge {
  position: absolute;
  top: -0.05rem;
  right: -0.05rem;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.2rem;
  border-radius: var(--radius-full, 9999px);
  background: #f97316;
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1.1rem;
  text-align: center;
  pointer-events: none;
  z-index: 2;
}

/* Light mode */
html.light .profile-menu__caret,
[data-theme='light'] .profile-menu__caret {
  background: oklch(from #fff l c h / 0.96);
  border-left-color: oklch(from #0f172a l c h / 0.08);
  border-top-color: oklch(from #0f172a l c h / 0.08);
}

html.light .profile-menu__panel,
[data-theme='light'] .profile-menu__panel {
  background: oklch(from #fff l c h / 0.96);
  border-color: oklch(from #0f172a l c h / 0.08);
  box-shadow: 0 15px 40px oklch(0.2 0.02 260 / 0.12);
}

html.light .profile-menu__name,
[data-theme='light'] .profile-menu__name {
  color: #0f172a;
}

html.light .profile-menu__email,
[data-theme='light'] .profile-menu__email {
  color: #64748b;
}

html.light .profile-menu__btn,
[data-theme='light'] .profile-menu__btn {
  color: #334155;
}

html.light .profile-menu__btn:hover,
[data-theme='light'] .profile-menu__btn:hover {
  background: #f8fafc;
}

html.light .profile-menu__header,
[data-theme='light'] .profile-menu__header {
  background: oklch(from #f8fafc l c h / 0.8);
  border-bottom-color: #e2e8f0;
}

html.light .profile-menu__footer,
[data-theme='light'] .profile-menu__footer {
  background: oklch(from #f8fafc l c h / 0.8);
  border-top-color: #e2e8f0;
}

html.light .profile-menu__sheet,
[data-theme='light'] .profile-menu__sheet {
  background: #f8fafc;
  color: #0f172a;
}

html.light .profile-menu__sheet-bar,
[data-theme='light'] .profile-menu__sheet-bar {
  background: #fff;
  border-bottom-color: #e2e8f0;
}

html.light .profile-menu__sheet-body,
[data-theme='light'] .profile-menu__sheet-body {
  background: #f8fafc;
}

@media (max-width: 640px) {
  .profile-menu__popover {
    width: min(17rem, calc(100vw - var(--space-8, 2rem)));
    right: -0.25rem;
  }

  .profile-menu__caret {
    right: 1rem;
  }
}

/* Contenuto foglio sezione */
.profile-drawer__section-title {
  margin: 0 0 var(--space-4, 1rem);
  font-size: var(--text-lg, 1.125rem);
  font-weight: 600;
}

.profile-drawer__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2, 0.5rem);
  margin-bottom: var(--space-4, 1rem);
}

.profile-drawer__field label {
  font-size: var(--text-sm, 0.875rem);
  font-weight: 500;
  color: #94a3b8;
}

.profile-drawer__field input {
  width: 100%;
  padding: var(--space-3, 0.75rem);
  border-radius: var(--radius-md, 0.5rem);
  border: 1px solid oklch(from #fff l c h / 0.12);
  background: #111827;
  color: #f1f5f9;
  font-size: var(--text-sm, 0.875rem);
}

.profile-drawer__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2.75rem;
  margin-bottom: var(--space-4, 1rem);
  padding: var(--space-3, 0.75rem);
  border: none;
  border-radius: var(--radius-lg, 0.75rem);
  background: #00d2ff;
  color: #0b1120;
  font-size: var(--text-sm, 0.875rem);
  font-weight: 700;
  cursor: pointer;
}

.profile-drawer__cta:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.profile-drawer__card-meta {
  margin: 0;
  font-size: var(--text-sm, 0.875rem);
  color: #94a3b8;
}

.profile-drawer__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3, 0.75rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.profile-drawer__card,
.profile-drawer__row {
  padding: var(--space-4, 1rem);
  border-radius: var(--radius-lg, 0.75rem);
  border: 1px solid oklch(from #fff l c h / 0.08);
  background: #111827;
}

.profile-drawer__card-title {
  margin: 0 0 var(--space-1, 0.25rem);
  font-weight: 600;
}

.profile-drawer__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3, 0.75rem);
}

.profile-drawer__row-main {
  min-width: 0;
}

.profile-drawer__icon-btn {
  flex-shrink: 0;
  min-width: 2.25rem;
  min-height: 2.25rem;
  border: none;
  border-radius: var(--radius-md, 0.5rem);
  background: oklch(from #ef4444 l c h / 0.15);
  color: #f87171;
  cursor: pointer;
}

.profile-drawer__store-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2, 0.5rem);
  margin-bottom: var(--space-4, 1rem);
}

.profile-drawer__store-chip {
  padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
  border-radius: var(--radius-full, 9999px);
  border: 1px solid oklch(from #fff l c h / 0.12);
  background: transparent;
  color: #cbd5e1;
  font-size: var(--text-xs, 0.75rem);
  cursor: pointer;
}

.profile-drawer__store-chip--on {
  border-color: #00d2ff;
  background: oklch(from #00d2ff l c h / 0.15);
  color: #00d2ff;
}

html.light .profile-drawer__field input,
[data-theme='light'] .profile-drawer__field input {
  background: #fff;
  border-color: #e2e8f0;
  color: #0f172a;
}

html.light .profile-drawer__card,
html.light .profile-drawer__row,
[data-theme='light'] .profile-drawer__card,
[data-theme='light'] .profile-drawer__row {
  background: #fff;
  border-color: #e2e8f0;
}
