<template>
	<div class="text-light-100 dark:text-dark-100 flex bg-light-0 dark:bg-dark-0 h-screen overflow-hidden">
		<NuxtRouteAnnouncer/>
		<TooltipProvider>
			<NuxtLayout>
				<div class="xl:px-12 xl:py-8 lg:px-8 lg:py-6 px-6 py-3 flex flex-1 justify-center overflow-auto max-h-full max-w-full relative" id="mainContainer">
					<NuxtPage />
				</div>
			</NuxtLayout>
		</TooltipProvider>
	</div>
</template>

<script setup lang="ts">
import { Content } from '#shared/content.util';
import * as Floating from '#shared/floating.util';
import { Toaster } from '#shared/components.util';

onBeforeMount(() => {
	Content.init();
	Floating.init();
	Toaster.init();

	const unmount = useRouter().afterEach((to, from, failure) => {
		if(failure) return;

		document.querySelectorAll(`a[href="${from.path}"][data-active]`).forEach(e => e.classList.remove(e.getAttribute('data-active') ?? ''));
		document.querySelectorAll(`a[href="${to.path}"][data-active]`).forEach(e => e.classList.add(e.getAttribute('data-active') ?? ''));
	});

	onUnmounted(() => {
		unmount();
	})
});
</script>

<style>
iconify-icon
{
	display: inline-block;
	width: attr(width px, 1rem);
	height: attr(height px, 1rem);
	box-sizing: content-box;
}
.ToastRoot[data-type='error'] {
	@apply border-light-red;
	@apply dark:border-dark-red;
	@apply bg-light-red;
	@apply dark:bg-dark-red;
	@apply !bg-opacity-50;
}
.ToastRoot[data-type='success'] {
	@apply border-light-green;
	@apply dark:border-dark-green;
	@apply bg-light-green;
	@apply dark:bg-dark-green;
	@apply !bg-opacity-50;
}
::-webkit-scrollbar {
	width: 12px; 
	height: 12px;
}
 
::-webkit-scrollbar-thumb {
	@apply bg-light-40;
	@apply dark:bg-dark-40;
	@apply rounded-md;
	@apply border-2;
	@apply border-solid;
	@apply border-transparent;
	@apply bg-clip-padding;
}
 
::-webkit-scrollbar-thumb:hover {
	@apply bg-light-50;
	@apply dark:bg-dark-50;
}
.callout[data-type="abstract"],
.callout[data-type="summary"],
.callout[data-type="tldr"]
{
	@apply bg-light-cyan;
	@apply dark:bg-dark-cyan;
	@apply text-light-cyan;
	@apply dark:text-dark-cyan;
}
.callout[data-type="info"]
{
	@apply bg-light-blue;
	@apply dark:bg-dark-blue;
	@apply text-light-blue;
	@apply dark:text-dark-blue;
}
.callout[data-type="todo"]
{
	@apply bg-light-blue;
	@apply dark:bg-dark-blue;
	@apply text-light-blue;
	@apply dark:text-dark-blue;
}
.callout[data-type="important"]
{
	@apply bg-light-cyan;
	@apply dark:bg-dark-cyan;
	@apply text-light-cyan;
	@apply dark:text-dark-cyan;
}
.callout[data-type="tip"],
.callout[data-type="hint"]
{
	@apply bg-light-cyan;
	@apply dark:bg-dark-cyan;
	@apply text-light-cyan;
	@apply dark:text-dark-cyan;
}
.callout[data-type="success"],
.callout[data-type="check"],
.callout[data-type="done"]
{
	@apply bg-light-green;
	@apply dark:bg-dark-green;
	@apply text-light-green;
	@apply dark:text-dark-green;
}
.callout[data-type="question"],
.callout[data-type="help"],
.callout[data-type="faq"]
{
	@apply bg-light-orange;
	@apply dark:bg-dark-orange;
	@apply text-light-orange;
	@apply dark:text-dark-orange;
}
.callout[data-type="warning"],
.callout[data-type="caution"],
.callout[data-type="attention"]
{
	@apply bg-light-orange;
	@apply dark:bg-dark-orange;
	@apply text-light-orange;
	@apply dark:text-dark-orange;
}
.callout[data-type="failure"],
.callout[data-type="fail"],
.callout[data-type="missing"]
{
	@apply bg-light-red;
	@apply dark:bg-dark-red;
	@apply text-light-red;
	@apply dark:text-dark-red;
}
.callout[data-type="danger"],
.callout[data-type="error"]
{
	@apply bg-light-red;
	@apply dark:bg-dark-red;
	@apply text-light-red;
	@apply dark:text-dark-red;
}
.callout[data-type="bug"]
{
	@apply bg-light-red;
	@apply dark:bg-dark-red;
	@apply text-light-red;
	@apply dark:text-dark-red;
}
.callout[data-type="example"]
{
	@apply bg-light-purple;
	@apply dark:bg-dark-purple;
	@apply text-light-purple;
	@apply dark:text-dark-purple;
}
.variant-cap
{
    font-variant: small-caps;
}
.cm-editor
{
    @apply bg-transparent;
    @apply flex-1 h-full;
    @apply font-sans;

    @apply text-light-100 dark:text-dark-100;
}
.cm-editor .cm-content
{
    @apply caret-light-100 dark:caret-dark-100;
}
.cm-line
{
    @apply text-base;
    @apply font-sans;
}

.cm-tooltip-autocomplete {
	@apply max-w-[400px];
	@apply !bg-light-20;
	@apply dark:!bg-dark-20;
	@apply !border-light-40;
	@apply dark:!border-dark-40;
}

/* .cm-tooltip-autocomplete > ul {
	@apply p-1;
} */

.cm-tooltip-autocomplete > ul > li {
	@apply flex;
	@apply flex-col;
	@apply !py-1;
	@apply hover:bg-light-30;
	@apply dark:hover:bg-dark-30;
}

.cm-tooltip-autocomplete > ul > li[aria-selected] {
	@apply !bg-light-35;
	@apply dark:!bg-dark-35;
}

.cm-completionIcon {
	@apply !hidden;
}

.cm-completionLabel {
	@apply px-4;
	@apply font-sans;
	@apply font-normal;
	@apply text-base;
	@apply text-light-100;
	@apply dark:text-dark-100;
}

.cm-completionMatchedText {
	@apply font-bold;
	@apply !no-underline;
}

.cm-completionDetail {
	@apply font-sans;
	@apply font-normal;
	@apply text-sm;
	@apply text-light-60;
	@apply dark:text-dark-60;
	@apply italic;
}

::-webkit-scrollbar-corner {
	@apply bg-transparent;
}
</style>