---
import CartFlyout from '../components/CartFlyout';
import CartFlyoutToggle from '../components/CartFlyoutToggle';
import { withBase } from '../utils';

interface Props {
	title: string;
}

const { title } = Astro.props;
---

<!doctype html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width" />
		<meta name="generator" content={Astro.generator} />
		<link rel="icon" type="image/svg+xml" href={withBase('/favicon.svg')} />
		<link rel="icon" href={withBase('/favicon.ico')} />
		<title>{title}</title>
	</head>
	<body>
		<header>
			<nav>
				<a href={withBase('/')} class="nav-header">
					<span style="color: var(--astro-blue)">Astro</span> storefront
				</a>
				<CartFlyoutToggle client:load />
			</nav>
		</header>
		<slot />
		<CartFlyout client:load />
	</body>
</html>

<style is:global>
	:root {
		--font-family: system-ui, sans-serif;
		--font-size-base: clamp(1rem, 0.34vw + 0.91rem, 1.19rem);
		--font-size-lg: clamp(1.2rem, 0.7vw + 1.2rem, 1.5rem);
		--font-size-xl: clamp(2rem, 1.75vw + 1.35rem, 2.75rem);

		--color-text: hsl(12, 5%, 4%);
		--color-bg: hsl(17, 20%, 97%);
		--color-bg-2: hsl(17, 20%, 94%);
		--color-bg-3: hsl(17, 20%, 88%);
		--astro-blue: #4f39fa;
		--astro-pink: #da62c4;

		--content-max-width: 90ch;
		--nav-height: clamp(2.44rem, 2.38vw + 1.85rem, 3.75rem);
	}

	h1 {
		font-size: var(--font-size-xl);
	}

	button {
		border: none;
		color: var(--astro-blue);
		border: 2px solid var(--astro-blue);
		transition:
			color 0.2s,
			background-color 0.2s;
		background-color: transparent;
		padding: 0.4rem 0.8rem;
		border-radius: 0.4rem;
		font-family: var(--font-family);
		font-size: var(--font-size-base);
		font-weight: bold;
		cursor: pointer;
	}

	button:hover {
		background-color: var(--astro-blue);
		color: white;
	}
</style>

<style>
	html {
		font-family: var(--font-family);
		font-size: var(--font-size-base);
		color: var(--color-text);
		background-color: var(--color-bg);
	}

	body {
		margin: 0;
	}

	header {
		background: var(--color-bg-2);
	}

	nav {
		max-width: var(--content-max-width);
		height: var(--nav-height);
		margin: auto;
		padding-inline: 1rem;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.nav-header,
	.nav-header:visited {
		font-size: var(--font-size-base);
		font-weight: bold;
		color: inherit;
		text-decoration: none;
	}
</style>
