/* Header avatar → off-canvas account drawer */

.itm-header-user-menu {
	position: relative;
	display: inline-flex;
	align-items: center;
	flex-shrink: 0;
	overflow: visible;
	z-index: 10040;
}

.header-actions {
	overflow: visible;
}

.header-actions .itm-header-user-menu,
.header-actions .header-avatar {
	flex-shrink: 0;
}

.itm-header-avatar-trigger {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
	line-height: 1;
	min-width: 42px;
	min-height: 42px;
}

.itm-header-avatar-trigger.header-avatar {
	text-decoration: none;
}

.itm-header-avatar-trigger:focus-visible {
	outline: 2px solid var(--itm-accent);
	outline-offset: 3px;
	border-radius: var(--itm-btn-radius, 4px);
}

.itm-header-avatar-ring {
	position: relative;
	display: inline-flex;
	border-radius: 50%;
	padding: 2px;
	background: conic-gradient(var(--itm-accent) 0 65%, rgba(var(--itm-accent-rgb), 0.2) 0 100%);
	transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.itm-header-avatar-ring--level-2 { background: conic-gradient(var(--itm-accent) 0 72%, rgba(var(--itm-accent-rgb), 0.2) 0 100%); }
.itm-header-avatar-ring--level-3 { background: conic-gradient(#eab308 0 78%, rgba(234, 179, 8, 0.2) 0 100%); }
.itm-header-avatar-ring--level-4,
.itm-header-avatar-ring--level-5 { background: conic-gradient(#52525b 0 85%, rgba(82, 82, 91, 0.2) 0 100%); }
.itm-header-avatar-ring--level-6,
.itm-header-avatar-ring--level-7,
.itm-header-avatar-ring--level-8,
.itm-header-avatar-ring--level-9 { background: conic-gradient(#eab308, #52525b, #eab308); background-size: 200% 200%; animation: itm-header-ring-shine 3s ease infinite; }

@keyframes itm-header-ring-shine {
	0%, 100% { background-position: 0% 50%; }
	50% { background-position: 100% 50%; }
}

.itm-header-avatar-ring img.avatar {
	border-radius: 50% !important;
	border: 2px solid var(--itm-bg-card) !important;
	display: block;
	width: 42px !important;
	height: 42px !important;
}

.itm-header-avatar-burger {
	position: absolute;
	right: -1px;
	bottom: -1px;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	min-width: 18px;
	min-height: 18px;
	aspect-ratio: 1 / 1;
	padding: 0;
	border-radius: 50%;
	border: 2px solid var(--itm-bg-card, #fff);
	background: var(--itm-heading, #111);
	color: #fff;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
	pointer-events: none;
	box-sizing: border-box;
	line-height: 0;
	overflow: hidden;
}

.itm-header-avatar-burger i {
	font-size: 0.55rem;
	line-height: 1;
	width: 1em;
	height: 1em;
	display: block;
}

.itm-header-user-menu.is-open .itm-header-avatar-burger,
.itm-header-user-menu:hover .itm-header-avatar-burger,
.header-avatar:hover .itm-header-avatar-burger {
	background: var(--itm-accent);
}

.header-avatar,
.itm-header-avatar-fallback {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 0;
	overflow: visible;
}

.header-avatar img,
.itm-header-avatar-trigger img.avatar {
	border-radius: 50%;
	border: 2px solid var(--itm-accent);
	display: block;
}

.itm-header-avatar-caret {
	display: none;
}

.itm-header-user-menu.is-open .itm-header-avatar-ring {
	transform: scale(1.04);
	box-shadow: 0 8px 22px rgba(var(--itm-accent-rgb), 0.28);
}

/* ---- Off-canvas shell ---- */

.itm-header-user-drawer {
	position: fixed;
	inset: 0;
	z-index: 100080;
	display: block;
	visibility: hidden;
	pointer-events: none;
}

.itm-header-user-drawer.is-open,
.itm-header-user-menu.is-open .itm-header-user-drawer {
	visibility: visible;
	pointer-events: auto;
}

.itm-header-user-drawer__backdrop {
	position: absolute;
	inset: 0;
	border: 0;
	padding: 0;
	margin: 0;
	cursor: pointer;
	background:
		radial-gradient(120% 80% at 100% 0%, rgba(var(--itm-accent-rgb), 0.22), transparent 55%),
		rgba(10, 12, 16, 0.42);
	opacity: 0;
	backdrop-filter: blur(0px) saturate(1);
	-webkit-backdrop-filter: blur(0px) saturate(1);
	transition:
		opacity 0.35s ease,
		backdrop-filter 0.45s ease,
		-webkit-backdrop-filter 0.45s ease;
}

.itm-header-user-drawer.is-open .itm-header-user-drawer__backdrop,
.itm-header-user-menu.is-open .itm-header-user-drawer__backdrop {
	opacity: 1;
	backdrop-filter: blur(10px) saturate(1.15);
	-webkit-backdrop-filter: blur(10px) saturate(1.15);
}

.itm-header-user-panel {
	position: absolute;
	top: 0;
	right: 0;
	height: 100%;
	width: min(360px, calc(100vw - 28px));
	max-width: 100%;
	z-index: 1;
	transform: translate3d(104%, 0, 0) skewX(-1.5deg);
	opacity: 0.85;
	transition:
		transform 0.48s cubic-bezier(0.22, 1, 0.36, 1),
		opacity 0.35s ease;
	will-change: transform, opacity;
}

.itm-header-user-drawer.is-open .itm-header-user-panel,
.itm-header-user-menu.is-open .itm-header-user-panel {
	transform: translate3d(0, 0, 0) skewX(0);
	opacity: 1;
}

.itm-header-user-panel-inner {
	position: relative;
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
	background:
		linear-gradient(165deg, rgba(255, 255, 255, 0.97) 0%, rgba(248, 250, 252, 0.96) 48%, rgba(255, 255, 255, 0.98) 100%);
	border-left: 1px solid rgba(15, 23, 42, 0.08);
	box-shadow:
		-24px 0 60px rgba(15, 23, 42, 0.18),
		-2px 0 0 rgba(255, 255, 255, 0.4) inset;
	color: var(--itm-heading, #111);
}

.itm-header-user-panel-inner::before {
	content: '';
	position: absolute;
	top: -20%;
	right: -30%;
	width: 70%;
	height: 45%;
	border-radius: 50%;
	background: radial-gradient(circle, rgba(var(--itm-accent-rgb), 0.16), transparent 68%);
	pointer-events: none;
	animation: itm-drawer-orb 8s ease-in-out infinite alternate;
}

@keyframes itm-drawer-orb {
	from { transform: translate3d(0, 0, 0) scale(1); }
	to { transform: translate3d(-18px, 28px, 0) scale(1.12); }
}

.itm-header-user-drawer__close {
	position: absolute;
	top: 14px;
	right: 14px;
	z-index: 3;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	padding: 0;
	border: 1px solid rgba(15, 23, 42, 0.08);
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.72);
	box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
	cursor: pointer;
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	transition: transform 0.22s ease, background 0.22s ease, border-color 0.22s ease;
}

.itm-header-user-drawer__close:hover,
.itm-header-user-drawer__close:focus-visible {
	transform: rotate(90deg) scale(1.04);
	background: #fff;
	border-color: rgba(var(--itm-accent-rgb), 0.35);
	outline: none;
}

.itm-header-user-drawer__close-icon,
.itm-header-user-drawer__close-icon::before,
.itm-header-user-drawer__close-icon::after {
	display: block;
	width: 14px;
	height: 2px;
	border-radius: 2px;
	background: var(--itm-heading, #111);
}

.itm-header-user-drawer__close-icon {
	position: relative;
	background: transparent;
}

.itm-header-user-drawer__close-icon::before,
.itm-header-user-drawer__close-icon::after {
	content: '';
	position: absolute;
	left: 0;
	top: 0;
}

.itm-header-user-drawer__close-icon::before { transform: rotate(45deg); }
.itm-header-user-drawer__close-icon::after { transform: rotate(-45deg); }

/* Hero */

.itm-header-user-hero {
	position: relative;
	display: grid;
	grid-template-columns: 76px minmax(0, 1fr);
	gap: 14px;
	align-items: center;
	padding: 28px 56px 22px 22px;
	flex-shrink: 0;
	overflow: hidden;
}

.itm-header-user-hero__glow {
	position: absolute;
	inset: 0;
	background:
		linear-gradient(135deg, rgba(var(--itm-accent-rgb), 0.14), transparent 55%),
		linear-gradient(180deg, rgba(15, 23, 42, 0.03), transparent 70%);
	pointer-events: none;
}

.itm-header-user-hero__avatar {
	position: relative;
	z-index: 1;
	width: 76px;
	height: 76px;
	padding: 3px;
	box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
	animation: itm-drawer-avatar-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
	animation-play-state: paused;
}

.itm-header-user-drawer.is-open .itm-header-user-hero__avatar,
.itm-header-user-menu.is-open .itm-header-user-hero__avatar {
	animation-play-state: running;
}

@keyframes itm-drawer-avatar-in {
	from {
		opacity: 0;
		transform: scale(0.72) rotate(-8deg);
	}
	to {
		opacity: 1;
		transform: scale(1) rotate(0);
	}
}

.itm-header-user-hero__avatar img.avatar {
	width: 70px !important;
	height: 70px !important;
	border-width: 3px !important;
}

.itm-header-user-hero__avatar.itm-verified-avatar::after {
	max-width: 22px;
	min-width: 16px;
	top: 2px;
	right: 2px;
	bottom: auto;
	transform: translate(12%, -12%);
}

.itm-header-user-hero__copy {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
	min-width: 0;
}

.itm-header-user-name {
	display: block;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 1.2rem;
	font-weight: 780;
	letter-spacing: -0.02em;
	color: var(--itm-heading);
	line-height: 1.2;
	opacity: 0;
	transform: translateY(10px);
}

.itm-header-user-drawer.is-open .itm-header-user-name,
.itm-header-user-menu.is-open .itm-header-user-name {
	animation: itm-drawer-fade-up 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.08s forwards;
}

@keyframes itm-drawer-fade-up {
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.itm-header-user-verified {
	color: #1da1f2;
	font-size: 0.9rem;
}

.itm-header-user-type {
	display: inline-flex;
	padding: 3px 9px;
	border-radius: 999px;
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	color: var(--itm-accent);
	background: rgba(var(--itm-accent-rgb), 0.12);
	opacity: 0;
	transform: translateY(8px);
}

.itm-header-user-drawer.is-open .itm-header-user-type,
.itm-header-user-menu.is-open .itm-header-user-type {
	animation: itm-drawer-fade-up 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.14s forwards;
}

.itm-header-user-level {
	display: grid;
	gap: 5px;
	width: 100%;
	margin-top: 4px;
	opacity: 0;
	transform: translateY(8px);
}

.itm-header-user-drawer.is-open .itm-header-user-level,
.itm-header-user-menu.is-open .itm-header-user-level {
	animation: itm-drawer-fade-up 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.2s forwards;
}

.itm-header-user-level__label {
	font-size: 0.72rem;
	font-weight: 700;
	color: color-mix(in srgb, var(--itm-heading) 70%, transparent);
}

.itm-header-user-level__track {
	display: block;
	width: 100%;
	height: 6px;
	border-radius: 999px;
	background: rgba(15, 23, 42, 0.08);
	overflow: hidden;
}

.itm-header-user-level__fill {
	display: block;
	height: 100%;
	width: 0;
	border-radius: inherit;
	background: linear-gradient(90deg, var(--itm-accent), color-mix(in srgb, var(--itm-accent) 70%, #111));
	box-shadow: 0 0 12px rgba(var(--itm-accent-rgb), 0.45);
	transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.28s;
}

.itm-header-user-drawer.is-open .itm-header-user-level__fill,
.itm-header-user-menu.is-open .itm-header-user-level__fill {
	width: var(--itm-level-progress, 0%);
}

/* Links */

.itm-header-user-section {
	position: relative;
	z-index: 1;
	padding: 8px 14px 12px;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	flex: 1 1 auto;
	min-height: 0;
	scrollbar-width: thin;
}

.itm-header-user-links {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.itm-header-user-item {
	position: relative;
	opacity: 0;
	transform: translateX(18px);
}

.itm-header-user-drawer.is-open .itm-header-user-item,
.itm-header-user-menu.is-open .itm-header-user-item {
	animation: itm-drawer-item-in 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
	animation-delay: calc(0.12s + (var(--itm-stagger, 0) * 0.045s));
}

@keyframes itm-drawer-item-in {
	from {
		opacity: 0;
		transform: translateX(18px);
	}
	to {
		opacity: 1;
		transform: translateX(0);
	}
}

.itm-header-user-actions {
	position: relative;
	z-index: 1;
	padding: 0 14px;
	flex-shrink: 0;
}

.itm-header-user-link,
button.itm-header-user-link,
a.itm-header-user-link {
	display: grid;
	grid-template-columns: 40px minmax(0, 1fr) auto 12px;
	align-items: center;
	justify-items: start;
	column-gap: 10px;
	row-gap: 0;
	box-sizing: border-box;
	width: 100%;
	margin: 0;
	padding: 11px 12px;
	border-radius: 14px;
	text-decoration: none;
	text-align: left;
	font: inherit;
	line-height: 1.25;
	color: var(--itm-heading);
	background: rgba(255, 255, 255, 0.55);
	border: 1px solid transparent;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
	transition:
		background 0.18s ease,
		border-color 0.18s ease,
		transform 0.18s ease,
		box-shadow 0.18s ease;
}

.itm-header-user-meta {
	display: inline-flex;
	align-items: center;
	justify-content: flex-end;
	min-height: 1.35rem;
}

.itm-header-user-chevron--spacer {
	display: block;
	width: 12px;
	height: 12px;
	visibility: hidden;
	pointer-events: none;
}

.itm-header-user-link:hover,
.itm-header-user-item.is-expanded > .itm-header-user-link {
	background: #fff;
	border-color: rgba(15, 23, 42, 0.06);
	transform: translateX(2px);
	box-shadow: 0 10px 24px rgba(15, 23, 42, 0.07);
}

.itm-header-user-link:active {
	transform: translateX(1px) scale(0.995);
}

.itm-header-user-link-icon {
	width: 40px;
	height: 40px;
	border-radius: 12px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 0.95rem;
	color: var(--itm-item-accent, var(--itm-accent));
	background:
		linear-gradient(160deg, color-mix(in srgb, var(--itm-item-accent, var(--itm-accent)) 18%, #fff), color-mix(in srgb, var(--itm-item-accent, var(--itm-accent)) 8%, #fff));
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
	transition: transform 0.2s ease;
}

.itm-header-user-link:hover .itm-header-user-link-icon {
	transform: scale(1.06) rotate(-3deg);
}

.itm-header-user-link-text strong {
	font-size: 0.92rem;
	line-height: 1.25;
	font-weight: 680;
}

.itm-header-user-chevron {
	width: 12px;
	justify-self: center;
	font-size: 0.65rem;
	color: color-mix(in srgb, var(--itm-heading) 55%, transparent);
	transition: transform 0.22s ease;
}

.itm-header-user-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.35rem;
	height: 1.35rem;
	padding: 0 5px;
	border-radius: 999px;
	font-size: 0.68rem;
	font-weight: 700;
	line-height: 1;
	color: #fff;
	background: var(--itm-accent);
	box-shadow: 0 4px 10px rgba(var(--itm-accent-rgb), 0.35);
}

.itm-header-user-actions--bottom {
	padding-top: 8px;
	padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
	border-top: 1px solid rgba(15, 23, 42, 0.06);
	margin-top: 2px;
	background: linear-gradient(180deg, transparent, rgba(248, 250, 252, 0.9));
}

.itm-header-user-action {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 10px;
	width: 100%;
	padding: 12px 14px;
	border-radius: 14px;
	font-size: 0.9rem;
	font-weight: 700;
	text-decoration: none;
	text-align: left;
	color: var(--itm-heading);
	background: rgba(255, 255, 255, 0.7);
	border: 1px solid rgba(15, 23, 42, 0.08);
	transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.itm-header-user-nav,
.itm-header-user-list,
.itm-header-user-subnav {
	align-items: stretch;
	text-align: left;
}

.itm-header-user-action i {
	color: color-mix(in srgb, var(--itm-heading) 70%, transparent);
}

.itm-header-user-action--logout {
	color: #b91c1c;
}

.itm-header-user-action--logout i {
	color: #b91c1c;
}

.itm-header-user-action--logout:hover {
	border-color: rgba(185, 28, 28, 0.35);
	background: rgba(185, 28, 28, 0.06);
	transform: translateY(-1px);
	box-shadow: 0 10px 22px rgba(185, 28, 28, 0.1);
}

.itm-header-user-item.is-expanded > .itm-header-user-accordion .itm-header-user-chevron,
li.has-children.is-expanded > .itm-header-user-accordion .itm-header-user-chevron {
	transform: rotate(180deg);
}

.itm-header-user-accordion-panel {
	padding: 2px 4px 8px 50px;
}

.itm-header-user-accordion-panel[hidden],
.itm-header-user-subnav[hidden] {
	display: none !important;
}

.itm-header-user-subnav {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.itm-header-user-subnav a,
.itm-header-user-subnav .itm-header-user-accordion {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	padding: 8px 10px;
	font-size: 0.84rem;
	font-weight: 600;
	font-family: inherit;
	color: var(--itm-text);
	text-decoration: none;
	text-align: left;
	border: 0;
	border-radius: 10px;
	background: transparent;
	cursor: pointer;
	transition: background 0.15s ease, transform 0.15s ease;
}

.itm-header-user-subnav a:hover,
.itm-header-user-subnav .itm-header-user-accordion:hover {
	background: rgba(15, 23, 42, 0.05);
	color: var(--itm-heading);
	transform: translateX(2px);
}

.itm-header-user-subnav a i,
.itm-header-user-subnav .itm-header-user-accordion > i:first-child {
	width: 16px;
	text-align: center;
	font-size: 0.75rem;
	color: color-mix(in srgb, var(--itm-heading) 70%, transparent);
}

.itm-header-user-subnav .itm-header-user-chevron {
	margin-left: auto;
}

.itm-header-user-subnav .itm-header-user-count {
	margin-left: auto;
	margin-right: 4px;
}

.itm-header-user-subnav .itm-header-user-count + .itm-header-user-chevron {
	margin-left: 0;
}

.itm-header-user-subnav--nested {
	margin: 0 0 4px;
	padding-left: 18px;
}

.itm-header-user-subnav--nested a {
	font-size: 0.78rem;
	padding: 6px 10px;
}

body.itm-header-user-drawer-open {
	overflow: hidden;
}

body.itm-dark-mode .itm-header-user-panel-inner {
	background:
		linear-gradient(165deg, rgba(28, 28, 32, 0.98) 0%, rgba(18, 18, 22, 0.98) 100%);
	border-left-color: rgba(255, 255, 255, 0.08);
	color: #f3f4f6;
	box-shadow: -24px 0 60px rgba(0, 0, 0, 0.45);
}

body.itm-dark-mode .itm-header-user-link,
body.itm-dark-mode .itm-header-user-action {
	background: rgba(255, 255, 255, 0.04);
	color: #f3f4f6;
}

body.itm-dark-mode .itm-header-user-link:hover,
body.itm-dark-mode .itm-header-user-item.is-expanded > .itm-header-user-link {
	background: rgba(255, 255, 255, 0.08);
	border-color: rgba(255, 255, 255, 0.08);
}

body.itm-dark-mode .itm-header-user-drawer__close {
	background: rgba(255, 255, 255, 0.06);
	border-color: rgba(255, 255, 255, 0.1);
}

body.itm-dark-mode .itm-header-user-drawer__close-icon::before,
body.itm-dark-mode .itm-header-user-drawer__close-icon::after {
	background: #f3f4f6;
}

body.itm-dark-mode .itm-header-user-level__track {
	background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 900px) {
	.main-navigation-drawer .itm-drawer-toolbar .itm-header-user-menu,
	.main-navigation-drawer .itm-drawer-toolbar .itm-header-avatar-trigger,
	.main-navigation-drawer .itm-drawer-toolbar .header-avatar {
		width: 36px;
		height: 36px;
		min-width: 36px;
		min-height: 36px;
	}

	.main-navigation-drawer .itm-drawer-toolbar .itm-header-avatar-ring img.avatar {
		width: 32px !important;
		height: 32px !important;
	}

	.itm-header-user-panel {
		width: min(100vw, 380px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.itm-header-user-panel,
	.itm-header-user-drawer__backdrop,
	.itm-header-user-drawer__close,
	.itm-header-user-link,
	.itm-header-user-level__fill,
	.itm-header-user-panel-inner::before {
		transition: none !important;
		animation: none !important;
	}

	.itm-header-user-item,
	.itm-header-user-name,
	.itm-header-user-type,
	.itm-header-user-level,
	.itm-header-user-hero__avatar {
		opacity: 1 !important;
		transform: none !important;
		animation: none !important;
	}

	.itm-header-user-drawer.is-open .itm-header-user-level__fill,
	.itm-header-user-menu.is-open .itm-header-user-level__fill {
		width: var(--itm-level-progress, 0%);
	}
}
