/* --- Side Panel Toggle & Offcanvas Panel --- */

/*
 Sticky tab, rotated 90deg counter-clockwise so the label reads bottom to top.

 Positioning: rotating about the bottom-right corner keeps the rotated
 box's right edge exactly where the unrotated one was (right: 0), so it sits
 flush against the viewport edge. translateY(-100%) (applied after the
 rotation) then lifts it by its own height so the visible top of the tab
 lands at 40% of the viewport.

 Corners: after a counter-clockwise rotation the unrotated *top* edge faces
 into the page and the bottom edge sits against the screen edge. So the
 16px radius goes on the top corners, which makes the rounded corners visible
 on the left and keeps the right-hand side flush.

 z-index sits just below the global UI overlay (9998) so the tab dims with the
 rest of the page while the panel is open.
*/
.itx-side-panel-toggle {
	position: fixed;
	top: 40%;
	right: 0;
	z-index: 9997;
	box-sizing: border-box;
	margin: 0;
	padding: 1rem 1.5rem;
	border: 0;
	border-radius: 16px 16px 0 0;
	/* Brand Contact purple, a shade darker so white text passes WCAG AA
	   (about 5.2:1; on the exact purple it's 4.4:1). */
	background: color-mix(in srgb, var(--color-brand-contact, #7771b1) 90%, black);
	color: #fff;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.2;
	white-space: nowrap;
	cursor: pointer;
	transform-origin: bottom right;
	transform: translateY(-100%) rotate(-90deg);
	transition: background-color .18s ease;
}

.itx-side-panel-toggle:hover,
.itx-side-panel-toggle:focus-visible,
.itx-side-panel-toggle[aria-expanded="true"] {
	background: color-mix(in srgb, var(--color-brand-contact, #7771b1) 78%, black);
}

.itx-side-panel-toggle:focus-visible {
	outline: 2px solid #000;
	outline-offset: 2px;
}

/*
 Offcanvas panel. Parked off-screen to the right and slid in by .is-active.
 The visibility delay on close keeps it hidden from focus and assistive tech
 once the slide-out has finished, as .itx-search-panel does.
*/
.itx-side-panel {
	position: fixed;
	top: 5vh;
	right: 0;
	z-index: 9999;
	height: 90vh;
	width: min(480px, 100%);
	border-radius: var(--site-border-radius) 0 0 var(--site-border-radius);
	background: #fff;
	box-shadow: -8px 0 24px 0 rgba(0, 0, 0, .08);
	transform: translateX(100%);
	visibility: hidden;
	transition: transform .3s ease, visibility 0s linear .3s;
}

.itx-side-panel.is-active {
	transform: translateX(0);
	visibility: visible;
	transition: transform .3s ease;
}

.itx-side-panel__inner {
	display: flex;
	flex-direction: column;
	height: 100%;
}

.itx-side-panel__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1.5rem 2rem;
	border-bottom: 1px solid #eee;
}

.itx-side-panel__title {
	margin: 0;
	padding: 0;
	font-size: 1.5rem;
}

/* Mirrors .itx-search-panel__close. */
.itx-side-panel__close {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2em;
	height: 2em;
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
	font-size: 1.2rem;
	color: inherit;
}

.itx-side-panel__close:hover,
.itx-side-panel__close:focus-visible {
	opacity: .7;
}

/* The body scrolls on its own, so long content never pushes the header away. */
.itx-side-panel__body {
	flex: 1 1 auto;
	padding: 1.5rem 2rem;
	overflow-y: auto;
	overscroll-behavior: contain;
}

/* Locks page scroll behind the panel, matching body.itx-search-is-open. */
body.itx-side-panel-is-open {
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.itx-side-panel,
	.itx-side-panel.is-active {
		transition: none;
	}
}
