@layer application {
	/* ===== Guide TOC Toggle ===== */
	#toc-toggle {
		position: fixed;
		top: 50%;
		transform: translateY(-50%);

		background: var(--main-bg-accent);
		border: 1px solid var(--wash-subtle);
		color: var(--main-text-color);

		padding: 0.75rem 0.25rem;
		height: 6rem;
		cursor: pointer;
		box-shadow: 2px 2px 8px var(--wash-accent);

		transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
		z-index: 50;
		display: none;

		left: 0;
		border-left: none;
		border-top-right-radius: 4px;
		border-bottom-right-radius: 4px;
		clip-path: polygon(0 0, 100% 3%, 100% 97%, 0 100%);

		svg {
			display: block;
			width: 20px;
			height: 20px;
		}

		&:has(~ #guide-toc.open) {
			transform: translateY(-50%) translateX(280px);
		}

		&:hover {
			box-shadow: 3px 3px 12px var(--wash-accent);
		}
	}

	/* ===== Guide TOC Sidebar ===== */
	#guide-toc {
		position: sticky;
		align-self: stretch;
		min-height: calc(var(--visible-content, 0px) - 4rem);
		max-height: calc(100vh - 4rem - var(--visible-chrome, 96px));
		order: 0;
		flex: 0 0 240px;
		top: 0;
		border-right: 1px solid var(--wash-subtle);
		background: transparent;
		overflow-y: auto;
		display: flex;
		flex-direction: column;

		h2 {
			font-size: 0.85rem;
			font-weight: 700;
			text-transform: uppercase;
			letter-spacing: 0.05em;
			line-height: 1.2;
			padding: 1.5rem 1.25rem 0.75rem;
			margin: 0;
			color: var(--main-text-muted);
		}

		ul {
			list-style: none;
			margin: 0;
			padding: 0 0.75rem 1.5rem;

			li {
				margin-bottom: 0.125rem;

				a {
					display: block;
					padding: 0.4rem 0.5rem;
					border-radius: 4px;
					color: var(--main-text-color);
					text-decoration: none;
					font-size: 0.9rem;
					transition: background 0.2s, color 0.2s;

					&:hover {
						background: var(--wash-subtle);
						color: var(--main-link-accent);
					}

					&[aria-current='page'] {
						background: var(--wash-subtle);
						color: var(--main-link-color);
						font-weight: 600;
						border-left: 2px solid var(--main-link-color);
						padding-left: calc(0.5rem - 2px);
					}
				}

				ul {
					margin-top: 0.125rem;
					padding: 0 0 0 0.75rem;
				}
			}
		}
	}

	@media (max-width: 1500px) {
		#toc-toggle {
			display: block;
		}

		#guide-toc {
			position: fixed;
			inset: 0 auto 0 0;
			min-height: none;
			max-height: none;
			width: 280px;
			padding: 2rem 0.5rem;
			background: var(--main-bg-texture);
			z-index: 40;

			opacity: 0;
			visibility: hidden;
			transform: translateX(-2rem);
			transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

			&.open {
				opacity: 1;
				visibility: visible;
				transform: translateX(0);
			}
		}
	}

	/* ===== Guide Article ===== */
	article.fundos-guide {
		flex: 1 1 auto;
		max-width: clamp(320px, 90vw, 1200px);

		header {
			margin-bottom: 2rem;

			h1 {
				font-size: 2rem;
				font-weight: 700;
				color: var(--main-text-accent);
				margin: 0 0 0.75rem;
				padding-bottom: 0.75rem;
				border-bottom: 1px solid var(--main-border);
			}
		}
	}

	/* ===== Home Page ===== */
	article#fundos-home {
		flex: 1 1 auto;
		max-width: clamp(320px, 90vw, 960px);
		display: flex;
		flex-direction: column;

		header#hero {
			display: flex;
			flex-direction: column;
			align-items: center;
			text-align: center;
			gap: 1rem;

			img {
				width: 96px;
				height: 96px;
			}

			h1 {
				font-size: 3rem;
				font-weight: 700;
				color: var(--main-text-accent);
				margin: 0;
			}

			.tagline {
				font-size: 1.25rem;
				color: var(--main-text-accent);
				margin: 0;
			}

			.subtagline {
				font-size: 1rem;
				color: var(--main-text-muted);
				margin: 0;
			}

			.button-group {
				margin-top: 0.5rem;

				a {
					display: inline-block;
					text-decoration: none;
					font-weight: 600;
					border-radius: 8px;
					padding: 0.75rem 1.5rem;
					transition: all 0.2s ease;

					&.primary {
						background: var(--main-link-color);
						color: var(--main-link-on-color);

						&:hover {
							background: var(--main-link-accent);
							box-shadow: 0 4px 12px var(--wash-accent);
						}
					}

					&.secondary {
						background: var(--main-bg-accent);
						color: var(--main-text-accent);
						border: 1px solid var(--main-border);

						&:hover {
							background: var(--main-bg-secondary);
							box-shadow: 0 4px 12px var(--wash-accent);
						}
					}

					&.large {
						font-size: 1.1rem;
						padding: 0.875rem 2rem;
					}
				}
			}
		}

		section#screenshot {
			display: flex;
			justify-content: center;
			margin: 2rem 0;

			.carousel {
				width: 100%;
				overflow: hidden;
			}

			.carousel-track {
				display: flex;
				transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
			}

			.carousel-track figure {
				min-width: 100%;
				flex-shrink: 0;
				display: flex;
				flex-direction: column;
				gap: 1rem;
				align-items: center;
				margin: 0;
				height: 700px;
				background-color: transparent;
			}

			.carousel-track figure img {
				height: calc(100% - 5rem);
				width: auto;
				border-radius: 6px;
			}

			.carousel-track figure figcaption {
				display: flex;
				flex-direction: column;
				width: 100%;
				gap: 0.5rem;
			}

			.carousel-track figure figcaption .carousel-header {
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: space-between;
				width: 100%;
			}

			.carousel-track figure figcaption h2 {
				margin: 0;
				font-size: 1.1rem;
				text-align: center;
				flex: 1;
			}

			.carousel-track figure figcaption p {
				margin: 0;
				font-size: 0.95rem;
				color: var(--main-text-muted);
				text-align: center;
			}

			.carousel-track figure figcaption button {
				display: inline-flex;
				align-items: center;
				justify-content: center;
				width: 2.25rem;
				height: 2.25rem;
				font-size: 1.25rem;
				border: 1px solid var(--main-border);
				border-radius: 6px;
				background: var(--main-bg-accent);
				color: var(--main-text-color);
				cursor: pointer;
				transition: all 0.2s ease;

				&:hover {
					background: var(--main-bg-secondary);
					border-color: var(--main-link-color);
					color: var(--main-link-color);
					box-shadow: 0 2px 8px var(--wash-accent);
				}
			}
		}

		section#why,
		section#how-it-works,
		section#platforms {
			h2 {
				font-size: 1.5rem;
				font-weight: 600;
				color: var(--main-text-accent);
				margin-bottom: 1rem;
			}
		}

		footer#home-footer {
			text-align: center;
			padding-bottom: 1rem;
			font-size: 0.9rem;

			a {
				color: var(--main-link-color);
				text-decoration: none;

				&:hover {
					color: var(--main-link-accent);
					text-decoration: underline;
				}
			}
		}
	}

	/* ===== About Page ===== */
	article#fundos-about {
		flex: 1 1 auto;
		max-width: clamp(320px, 90vw, 900px);

		pre.license {
			width: max-content;
			max-width: 100%;
			margin-left: auto;
			margin-right: auto;
			border: 1px solid var(--main-border);
			border-radius: 8px;
			padding: 1.25rem;
			overflow-x: auto;
			background: var(--main-bg-accent);
			color: var(--main-text-muted);
			font-family: var(--font-code);
			font-size: 0.8rem;
			line-height: 1.6;
			white-space: pre-wrap;
		}
	}

	/* ===== Download Page ===== */
	article#fundos-download {
		flex: 1 1 auto;
		max-width: clamp(320px, 90vw, 900px);

		ul.download-list {
			list-style: none;
			margin: 0 0 1.5rem 0;
			padding: 0;
			display: flex;
			flex-direction: column;
			gap: 0.75rem;

			li {
				display: flex;
				align-items: center;
				gap: 1rem;
				flex-wrap: wrap;
			}

			a.download-button {
				display: inline-flex;
				align-items: center;
				gap: 0.5rem;
				padding: 0.6rem 1.1rem;
				background: var(--main-link-color);
				color: var(--main-link-on-color);
				text-decoration: none;
				border-radius: 6px;
				font-family: var(--font-code);
				font-size: 0.9rem;
				font-weight: 600;
				transition: all 0.2s ease;
				white-space: nowrap;

				&:hover {
					background: var(--main-link-accent);
					box-shadow: 0 4px 12px var(--wash-accent);
				}
			}
		}
	}
}
