@use "../kit-deps" as *;
@use "typography" as *;

.drawer {
	position: fixed;
	inset: 0;
	z-index: 1000;
	display: flex;
	justify-content: flex-end;
	pointer-events: none;

	.drawer-backdrop {
		position: fixed;
		inset: 0;
		z-index: 1010;
		background: $color-black;
		opacity: 0;
		transition-duration: $motion-slow;
		transition-timing-function: $motion-ease;
		transition-property: opacity;
		pointer-events: auto;
	}

	.drawer-panel {
		position: relative;
		z-index: 1020;
		width: min(460px, calc(100vw - #{$space-5}));
		min-height: 100vh;
		display: flex;
		flex-direction: column;
		gap: $space-4;
		background: $surface-page;
		border-left: $border-width-base solid $color-text-light;
		box-shadow: -18px 0 42px rgba($color-black, 0.38);
		opacity: 0;
		transform: translateX(100%);
		transition-duration: $motion-slow;
		transition-timing-function: $motion-ease;
		transition-property: opacity, transform;
		pointer-events: auto;
	}

	.drawer-header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding-right: $space-4;
		border-bottom: $border-width-base solid $border-color-muted;
	}

	.drawer-title {
		margin: 0;
		padding: $space-3 $space-4;
		background: $color-text-light;
		color: $color-black;
		text-transform: uppercase;
		letter-spacing: $letter-spacing-wide;
	}

	.drawer-body {
		flex: 1;
		overflow-y: auto;
		padding: $space-5;
	}

	.drawer-footer {
		padding: $space-5;
		border-top: $border-width-base solid $border-color-muted;

		.actions {
			display: flex;
			flex-wrap: wrap;
			justify-content: flex-end;
			gap: $space-3;
			width: 100%;
		}
	}

	&.drawer-left {
		justify-content: flex-start;

		.drawer-panel {
			border-left: 0;
			border-right: $border-width-base solid $color-text-light;
			box-shadow: 18px 0 42px rgba($color-black, 0.38);
			transform: translateX(-100%);
		}
	}

	&.a-show {
		.drawer-backdrop {
			opacity: 0.82;
		}

		.drawer-panel {
			opacity: 1;
			transform: translateX(0);
		}
	}

	&.a-hide {
		.drawer-backdrop {
			opacity: 0;
		}

		.drawer-panel {
			opacity: 0;
			transform: translateX(100%);
		}

		&.drawer-left .drawer-panel {
			transform: translateX(-100%);
		}
	}
}

.drawer-preview {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(180px, 280px);
	gap: $space-5;
	align-items: stretch;
	padding: $space-5;
	border: $border-width-base solid $border-color-muted;
	border-left-width: $border-width-accent;
	background: $surface-panel-muted;

	.drawer-preview-content {
		display: flex;
		flex-direction: column;
		gap: $space-3;
	}

	.drawer-preview-panel {
		display: flex;
		flex-direction: column;
		gap: $space-3;
		padding: $space-4;
		border: $border-width-base solid $color-secondary;
		background: $surface-panel;
	}

	.drawer-preview-title {
		margin: 0;
		color: $color-secondary;
		font-size: $font-size-md;
		text-transform: uppercase;
	}

	.drawer-preview-text {
		margin: 0;
		color: $color-text-medium;
		font-size: $font-size-sm;
		line-height: $line-height-relaxed;
	}
}

@media (max-width: 720px) {
	.drawer-preview {
		grid-template-columns: 1fr;
	}
}
