/*
 * Side drawers (native <dialog>), shared drawer buttons and carousel rails.
 * Colours come from the theme tokens (--njf-*) with neutral fallbacks.
 */

dialog.njf-drawer {
	--njf-d-bg: var(--njf-bg, #fff);
	--njf-d-fg: var(--njf-fg, #111);
	--njf-d-line: color-mix(in srgb, var(--njf-d-fg) 15%, transparent);
	--njf-d-muted: color-mix(in srgb, var(--njf-d-fg) 65%, transparent);

	position: fixed;
	inset: 0 0 0 auto;
	width: min(480px, 100vw);
	max-width: 100vw;
	height: 100dvh;
	max-height: 100dvh;
	margin: 0;
	padding: 0;
	border: 0;
	background: var(--njf-d-bg);
	color: var(--njf-d-fg);
	font-family: var(--e-global-typography-text-font-family, inherit), sans-serif;
	transform: translateX(100%);
	transition: transform 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
}

dialog.njf-drawer[open] {
	transform: translateX(0);
}

dialog.njf-drawer.is-closing {
	transform: translateX(100%);
}

@starting-style {
	dialog.njf-drawer[open] {
		transform: translateX(100%);
	}
}

dialog.njf-drawer::backdrop {
	background: rgb(0 0 0 / 60%);
}

html:has(dialog.njf-drawer[open]) {
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	dialog.njf-drawer {
		transition: none;
	}
}

.njf-drawer__inner {
	display: flex;
	flex-direction: column;
	height: 100%;
}

.njf-drawer__head {
	position: relative;
	display: flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: space-between;
	min-height: 64px;
	padding: 14px 20px;
	border-bottom: 1px solid var(--njf-d-line);
}

.njf-drawer__head--center {
	justify-content: center;
	text-align: center;
}

.njf-drawer .njf-drawer__title {
	margin: 0;
	color: inherit;
	font-family: var(--e-global-typography-primary-font-family, inherit), sans-serif;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.njf-drawer .njf-drawer__sub {
	margin: 2px 0 0;
	color: var(--njf-d-muted);
	font-size: 12px;
	line-height: 1.4;
}

.njf-drawer .njf-drawer__sub:empty {
	display: none;
}

.njf-drawer .njf-drawer__close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: inherit;
	cursor: pointer;
}

.njf-drawer .njf-drawer__close:hover,
.njf-drawer .njf-drawer__close:focus {
	background: var(--njf-d-line);
	color: inherit;
}

.njf-drawer .njf-drawer__head--center .njf-drawer__close {
	position: absolute;
	top: 50%;
	right: 12px;
	transform: translateY(-50%);
}

.njf-drawer__close svg {
	width: 20px;
	height: 20px;
}

.njf-drawer__body {
	flex: 1;
	min-height: 0;
	padding: 20px;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.njf-drawer ins {
	background: none;
	text-decoration: none;
}

/* Shared drawer buttons: solid = text colour fill, outline = border only. */
.njf-drawer .njf-dbtn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 48px;
	padding: 12px 20px;
	border: 1px solid var(--njf-d-fg, currentcolor);
	border-radius: var(--njf-radius-button, 0);
	font-size: 12px;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: 0.2em;
	text-align: center;
	text-decoration: none;
	text-transform: uppercase;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.njf-drawer .njf-dbtn--solid {
	background: var(--njf-d-fg, currentcolor);
	color: var(--njf-d-bg, #fff);
}

.njf-drawer .njf-dbtn--outline {
	background: transparent;
	color: var(--njf-d-fg, currentcolor);
}

.njf-drawer .njf-dbtn:hover,
.njf-drawer .njf-dbtn:focus-visible {
	border-color: var(--njf-accent, currentcolor);
	background: var(--njf-accent, var(--njf-d-fg));
	color: #fff;
}

/* Horizontal carousels. */
.njf-rail {
	display: grid;
	grid-auto-columns: 128px;
	grid-auto-flow: column;
	gap: 12px;
	padding-bottom: 6px;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
}

.njf-rail::-webkit-scrollbar {
	display: none;
}

.njf-rail > * {
	scroll-snap-align: start;
}

.njf-rail__arrows {
	display: flex;
	gap: 4px;
}

.njf-drawer .njf-rail__arrow {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 1px solid var(--njf-d-line, currentcolor);
	border-radius: 50%;
	background: transparent;
	color: inherit;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
}

.njf-drawer .njf-rail__arrow:hover,
.njf-drawer .njf-rail__arrow:focus {
	border-color: currentcolor;
	background: transparent;
	color: inherit;
}

.njf-visually-hidden {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}
