/* Testata della sola app: menu del profilo, icona del profilo e contenitore
   dei bottoni. Solo l'app la carica, subito dopo ds-layout.css da cui viene
   (ADR-022 A1); la testata documentata dal design system (.app-header) resta
   in ds-layout. Le regole che il menu ora segue (navigazione, sezione,
   griglie, accesso) non toccano i suoi elementi. */

/* ===========================================
   MENU DEL PROFILO
   ===========================================
   Un bottone nella testata ("D · Demo") e un pannello che si apre sotto. Il
   pannello e' una superficie chiara dentro una testata scura: i controlli al
   suo interno prendono i token di una card, non quelli della testata. Il
   pannello resta dentro lo stacking context della testata (z-sticky), quindi
   --z-dropdown ordina solo cio' che sta li' dentro. */
.profile-menu {
  position: relative;
  min-width: 0;
}

.profile-menu__trigger {
  gap: var(--space-2);
  max-width: 100%;
}

.profile-menu__initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-full);
  background-color: var(--header-chip);
  color: var(--header-fill);
  font-weight: var(--font-bold);
  font-size: var(--type-caption-size);
}

.profile-menu__name {
  min-width: 0;
  max-width: 7rem;
}

.profile-menu__chevron {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  transition: transform var(--duration-fast) ease;
}

.profile-menu__trigger[aria-expanded="true"] .profile-menu__chevron {
  transform: rotate(180deg);
}

.profile-menu__panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: var(--z-dropdown);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: max-content;
  min-width: 16rem;
  max-width: calc(100vw - 2 * var(--space-4));
  padding: var(--space-3);
  background-color: var(--surface-raised);
  color: var(--fg-default);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--elevation-3);
}

.profile-menu__panel[hidden] {
  display: none;
}

.profile-menu__who {
  margin: 0;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--type-small-size);
  font-weight: var(--font-semibold);
}

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

.profile-menu__label {
  font-size: var(--type-small-size);
  color: var(--fg-muted);
}

.profile-menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 2.75rem;
  padding: var(--space-2) var(--space-3);
  background: transparent;
  color: var(--fg-default);
  border: 0;
  border-radius: var(--radius-md);
  font: inherit;
  font-size: var(--type-small-size);
  font-weight: var(--font-semibold);
  text-align: left;
  cursor: pointer;
}

.profile-menu__item:hover {
  background-color: var(--surface-sunken);
}

.profile-menu__item #profile-icon-content {
  width: 1.5rem;
  height: 1.5rem;
}

/* La testata ridefinisce l'anello di focus per il fondo scuro: nel pannello,
   che e' chiaro, quello chiaro non si vedrebbe. */
.app-header .profile-menu__panel :focus-visible {
  box-shadow: var(--focus-ring);
}

/* Sotto i 640px la testata resta su una riga: il nome nel bottone cede spazio
   al marchio, che e' gia' troncato, e il pannello non esce dallo schermo. */
@media (max-width: 640px) {
  .profile-menu__name {
    max-width: 5rem;
  }
}

/* On a phone the name was squeezed to one letter ("D D…") next to the same
   initial, and the brand lost its last word: only the initial stays. */
@media (max-width: 480px) {
  .profile-menu__name {
    display: none;
  }
}

#profile-icon-content {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.profile-icon-svg.hidden {
  display: none;
}

/* Header buttons container */
.header-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
}
