/* ==========================================================================
   IonixCore profile menu — the ONE account menu of every Ionix product.
   Behaviour: shell/profileMenu.js. Tokens are scoped to the menu so it looks
   identical in every host; the product colours and the neutral symbol token
   are the central product selector's (@ionix/core-access).
   Light/dark follows the host: html[data-theme] (Ledger) or
   html[data-appearance] (Admin, Core access, website).
   ========================================================================== */

.ixp-trigger,
.ixp-layer {
  --ixp-surface: #FFFFFF;
  --ixp-fg: #111110;
  --ixp-text-2: #4A463F;
  --ixp-text-3: #5E5A52;
  --ixp-text-4: #6F6A61;
  --ixp-line: rgba(17, 17, 16, .1);
  --ixp-line-2: rgba(17, 17, 16, .16);
  --ixp-tint: rgba(17, 17, 16, .04);
  --ixp-tint-2: rgba(17, 17, 16, .065);
  --ixp-tint-3: rgba(17, 17, 16, .1);
  --ixp-shadow: 0 1px 2px rgba(17, 17, 16, .06), 0 14px 36px -10px rgba(17, 17, 16, .24);
  --ixp-danger: #A23A22;
  --ixp-scrim: rgba(17, 17, 16, .32);
  --ixp-ease: cubic-bezier(.22, .75, .2, 1);
  --ixl-fg-soft: #3A3833;
  --ixl-symbol-neutral: #111110;
  font-family: inherit;
}

html[data-theme="dark"] .ixp-trigger, html[data-theme="dark"] .ixp-layer,
html[data-appearance="dark"] .ixp-trigger, html[data-appearance="dark"] .ixp-layer {
  --ixp-surface: #1A1A18;
  --ixp-fg: #FCFBF9;
  --ixp-text-2: #B8B3AB;
  --ixp-text-3: #A5A099;
  --ixp-text-4: #8A857D;
  --ixp-line: rgba(252, 251, 249, .09);
  --ixp-line-2: rgba(252, 251, 249, .15);
  --ixp-tint: rgba(252, 251, 249, .045);
  --ixp-tint-2: rgba(252, 251, 249, .075);
  --ixp-tint-3: rgba(252, 251, 249, .12);
  --ixp-shadow: 0 18px 44px -10px rgba(0, 0, 0, .65);
  --ixp-danger: #F0A08C;
  --ixp-scrim: rgba(0, 0, 0, .55);
  --ixl-fg-soft: #CFCBC4;
  --ixl-symbol-neutral: #FFFFFF;
}

/* ── Trigger: a 32 px avatar inside a 44 px target ───────────────────────── */

.ixp-mount { display: inline-flex; }

.ixp-trigger {
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  color: var(--ixp-fg);
  -webkit-tap-highlight-color: transparent;
}
/* Hover answers like every other top-bar trigger: the host's accent ring
   (--ixp-trigger-accent / --ixp-trigger-accent-soft, set on the host bar),
   falling back to the neutral tint where the host declares none. */
.ixp-trigger .ixp-avatar { transition: box-shadow .12s ease; }
@media (hover: hover) {
  .ixp-trigger:hover .ixp-avatar { box-shadow: 0 0 0 2px var(--ixp-trigger-accent, var(--ixp-tint-3)), 0 0 0 5px var(--ixp-trigger-accent-soft, transparent); }
}
.ixp-trigger[aria-expanded="true"] .ixp-avatar { box-shadow: 0 0 0 2px var(--ixp-surface), 0 0 0 4px var(--ixp-fg); }
.ixp-trigger:focus { outline: none; }
.ixp-trigger:focus-visible .ixp-avatar { box-shadow: 0 0 0 2px var(--ixp-surface), 0 0 0 4px var(--ixp-fg); }

/* ── Avatar: initials underneath, the photo fades in over them once decoded ─ */

.ixp-avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  overflow: hidden;
  border-radius: 50%;
  background: var(--ixp-tint-3);
  color: var(--ixp-fg);
  font-weight: 600;
  line-height: 1;
  letter-spacing: .01em;
  user-select: none;
}
.ixp-avatar--sm { width: 32px; height: 32px; font-size: 12px; }
.ixp-avatar--lg { width: 44px; height: 44px; font-size: 15px; }
.ixp-avatar__initials { display: block; }
.ixp-avatar__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
}
.ixp-avatar__img.is-loaded { opacity: 1; }

/* ── Layer and panel ──────────────────────────────────────────────────────── */

.ixp-layer {
  position: fixed;
  inset: 0;
  z-index: var(--z-global-menu-popover, 1260);
  pointer-events: none;
}
.ixp-scrim { display: none; }

.ixp-panel {
  position: fixed;
  top: 0;
  right: 12px;
  width: 320px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background: var(--ixp-surface);
  color: var(--ixp-fg);
  border: 1px solid var(--ixp-line-2);
  border-radius: 14px;
  box-shadow: var(--ixp-shadow);
  font-size: 14px;
  line-height: 1.4;
  text-align: left;
  overflow: hidden;
  pointer-events: auto;
  transform-origin: top right;
  /* closed: invisible, not hit-testable, and its visibility flips only after the fade */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px) scale(.98);
  transition: opacity .1s ease, transform .1s ease, visibility 0s linear .1s;
}
.ixp-layer[data-state="open"] .ixp-panel {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .14s var(--ixp-ease), transform .14s var(--ixp-ease), visibility 0s;
}
.ixp-layer[data-state="closed"] .ixp-panel { pointer-events: none; }
.ixp-panel:focus { outline: none; }
.ixp-panel.is-swapping .ixp-body { animation: ixp-swap .16s var(--ixp-ease); }
@keyframes ixp-swap { from { opacity: 0; transform: translateX(16px); } }

.ixp-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ── Header ───────────────────────────────────────────────────────────────── */

.ixp-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 14px; }
.ixp-who { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.ixp-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ixp-sub { font-size: 13px; color: var(--ixp-text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Sections and rows ────────────────────────────────────────────────────── */

.ixp-section { border-top: 1px solid var(--ixp-line); padding: 6px; }
.ixp-label { margin: 0; padding: 8px 10px 4px; font-size: 12.5px; font-weight: 500; color: var(--ixp-text-4); }

.ixp-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  margin: 0;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ixp-fg);
  font: inherit;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .12s ease;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
  .ixp-row:hover { background: var(--ixp-tint); }
}
.ixp-row:active { background: var(--ixp-tint-2); }
.ixp-row:focus { outline: none; }
.ixp-row:focus-visible { outline: 2px solid var(--ixp-fg); outline-offset: -2px; background: var(--ixp-tint); }
.ixp-row.is-current { background: var(--ixp-tint-2); }
.ixp-row.is-unavailable { cursor: default; color: var(--ixp-text-4); }
.ixp-row.is-unavailable .ixp-tile { filter: grayscale(1); opacity: .45; }
.ixp-row__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ixp-row__meta { font-size: 12.5px; font-weight: 400; color: var(--ixp-text-4); }
.ixp-row__icon { width: 28px; height: 28px; display: grid; place-items: center; flex: none; color: var(--ixp-text-3); }
.ixp-icon { width: 18px; height: 18px; display: block; }
.ixp-check { width: 18px; height: 18px; flex: none; color: var(--ixp-fg); }
.ixp-chevron { width: 16px; height: 16px; flex: none; color: var(--ixp-text-4); }
.ixp-row--signout, .ixp-row--signout .ixp-row__icon { color: var(--ixp-danger); }

.ixp-tile {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--ixp-product, var(--ixl-fg-soft));
  background: color-mix(in srgb, var(--ixp-product, var(--ixl-fg-soft)) 14%, transparent);
}
.ixp-tile svg { width: 14px; height: 14px; display: block; }
.ixp-chip { font-size: 11.5px; font-weight: 500; padding: 2px 8px; border-radius: 99px; background: var(--ixp-tint-2); color: var(--ixp-text-2); }

.ixp-switch { position: relative; flex: none; width: 34px; height: 20px; border-radius: 99px; background: var(--ixp-tint-3); transition: background-color .14s ease; }
.ixp-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #FFFFFF; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .14s var(--ixp-ease); }
.ixp-switch.is-on { background: var(--ixp-fg); }
.ixp-switch.is-on::after { transform: translateX(14px); background: var(--ixp-surface); }

/* ── Messages, skeleton, buttons ──────────────────────────────────────────── */

.ixp-message { padding: 6px 10px 10px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.ixp-message p { margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--ixp-text-2); }
.ixp-message b { display: block; margin-bottom: 2px; font-size: 14px; font-weight: 600; color: var(--ixp-fg); }
.ixp-message--quiet { padding-bottom: 6px; }

.ixp-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--ixp-line-2);
  border-radius: 8px;
  background: var(--ixp-surface);
  color: var(--ixp-fg);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.ixp-button--primary { background: var(--ixp-fg); border-color: var(--ixp-fg); color: var(--ixp-surface); }
.ixp-button:focus-visible { outline: 2px solid var(--ixp-fg); outline-offset: 2px; }

.ixp-skeleton { display: flex; flex-direction: column; opacity: 0; animation: ixp-appear .2s ease .4s forwards; }
.ixp-skeleton i { display: block; height: 44px; position: relative; }
.ixp-skeleton i::before { content: ""; position: absolute; left: 10px; top: 8px; width: 28px; height: 28px; border-radius: 7px; background: var(--ixp-tint-2); }
.ixp-skeleton i::after { content: ""; position: absolute; left: 50px; top: 16px; width: 40%; height: 12px; border-radius: 6px; background: var(--ixp-tint-2); }
.ixp-skeleton i:nth-child(2)::after { width: 52%; }
.ixp-skeleton i:nth-child(3)::after { width: 32%; }
@keyframes ixp-appear { to { opacity: 1; } }

/* ── Switch product ───────────────────────────────────────────────────────── */

.ixp-switch-head { display: flex; align-items: center; gap: 4px; min-height: 52px; padding: 4px 10px 4px 4px; border-bottom: 1px solid var(--ixp-line); font-weight: 600; }
.ixp-switch-title { flex: 1; min-width: 0; }
.ixp-iconbutton { width: 44px; height: 44px; flex: none; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--ixp-fg); cursor: pointer; }
@media (hover: hover) { .ixp-iconbutton:hover { background: var(--ixp-tint); } }
.ixp-iconbutton:focus { outline: none; }
.ixp-iconbutton:focus-visible { outline: 2px solid var(--ixp-fg); outline-offset: -2px; }
.ixp-find { position: relative; margin: 8px 6px 2px; }
.ixp-find .ixp-icon { position: absolute; left: 10px; top: 12px; width: 16px; height: 16px; color: var(--ixp-text-4); pointer-events: none; }
.ixp-find input {
  width: 100%;
  height: 40px;
  box-sizing: border-box;
  padding: 0 10px 0 34px;
  border: 1px solid var(--ixp-line-2);
  border-radius: 8px;
  background: transparent;
  color: var(--ixp-fg);
  font: inherit;
}
.ixp-find input::placeholder { color: var(--ixp-text-4); }
.ixp-find input:focus { outline: none; border-color: var(--ixp-fg); box-shadow: 0 0 0 3px var(--ixp-tint-2); }
.ixp-section--list { border-top: 0; }
.ixp-empty { margin: 0; padding: 12px 10px; color: var(--ixp-text-3); font-size: 13.5px; }

.ixp-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ixp-grabber, .ixp-close { display: none; }

/* ── Phones: the same component as a bottom sheet ─────────────────────────── */

@media (max-width: 600px) {
  .ixp-layer[data-presentation="sheet"] .ixp-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--ixp-scrim);
    opacity: 0;
    transition: opacity .16s ease;
  }
  .ixp-layer[data-presentation="sheet"][data-state="open"] { pointer-events: auto; }
  .ixp-layer[data-presentation="sheet"][data-state="open"] .ixp-scrim { opacity: 1; transition: opacity .22s var(--ixp-ease); }
  .ixp-layer[data-presentation="sheet"] .ixp-panel {
    top: auto !important;
    right: 0 !important;
    left: 0;
    bottom: 0;
    width: auto !important;
    max-height: 85dvh !important;
    padding: 0 8px env(safe-area-inset-bottom, 0px);
    border-width: 1px 0 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, .18);
    font-size: 15px;
    transform: translateY(100%);
    transition: transform .16s ease, visibility 0s linear .16s;
    opacity: 1;
  }
  .ixp-layer[data-presentation="sheet"][data-state="open"] .ixp-panel { transform: none; transition: transform .22s var(--ixp-ease), visibility 0s; }
  .ixp-layer[data-presentation="sheet"] .ixp-grabber { display: block; width: 36px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: var(--ixp-line-2); flex: none; }
  .ixp-layer[data-presentation="sheet"] .ixp-close { display: grid; background: var(--ixp-tint-2); border-radius: 50%; }
  .ixp-layer[data-presentation="sheet"] .ixp-head { padding: 12px 8px 14px 10px; }
  .ixp-layer[data-presentation="sheet"] .ixp-name { font-size: 16px; }
  .ixp-layer[data-presentation="sheet"] .ixp-section { padding: 6px 0; }
  .ixp-layer[data-presentation="sheet"] .ixp-row { min-height: 48px; gap: 14px; }
  .ixp-layer[data-presentation="sheet"] .ixp-find input { height: 48px; font-size: 16px; }   /* 16 px: no iOS zoom */
  .ixp-layer[data-presentation="sheet"] .ixp-find .ixp-icon { top: 16px; }
}

/* ── Reduced motion: no movement, a short fade only ───────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .ixp-panel,
  .ixp-layer[data-state="open"] .ixp-panel,
  .ixp-layer[data-presentation="sheet"] .ixp-panel,
  .ixp-layer[data-presentation="sheet"][data-state="open"] .ixp-panel {
    transform: none !important;
    transition: opacity .08s linear, visibility 0s linear .08s !important;
  }
  .ixp-layer[data-presentation="sheet"] .ixp-panel { opacity: 0; }
  .ixp-layer[data-state="open"] .ixp-panel { opacity: 1; transition: opacity .08s linear, visibility 0s !important; }
  .ixp-panel.is-swapping .ixp-body { animation: none; }
  .ixp-switch, .ixp-switch::after, .ixp-row, .ixp-trigger .ixp-avatar { transition: none; }
  .ixp-skeleton { animation-duration: .01s; }
}

/* Optional canonical product logo assets supplied by the account endpoint. */
.ixp-tile img { width: 20px; height: 20px; display: block; }
.ixp-tile .ixp-logo-light { display: none; }
html[data-appearance="light"] .ixp-tile:has(.ixp-logo-light) .ixp-logo-dark { display: none; }
html[data-appearance="light"] .ixp-tile .ixp-logo-light { display: block; }
.ixp-row--signout .ixp-icon path:last-child { transition: transform .25s cubic-bezier(.22,.75,.2,1); }
.ixp-row--signout:is(:hover, :focus-visible) .ixp-icon path:last-child { transform: translateX(2px); }
