/*
 * PureCSS.com
 * https://purecss.com/frosted-nav/
 * A sticky bar frosted with backdrop-filter over a thin fill, so the content scrolling under it turns to colored mist.
 */

.demo-frosted-nav {
	--fn-fill: rgba(12, 12, 13, .52);
	--fn-solid: rgba(12, 12, 13, .94);
	--fn-ink: #fff;
	--fn-line: rgba(255, 255, 255, .22);
}

body:has(#theme-toggle:checked) .demo-frosted-nav {
	--fn-fill: rgba(255, 255, 255, .42);
	--fn-solid: rgba(255, 255, 255, .94);
	--fn-ink: #1a1a1a;
	--fn-line: rgba(0, 0, 0, .18);
}

.demo-frosted-nav .fn-window {
	width: 100%;
	max-width: 36rem;
	height: 22rem;
	overflow-y: auto;
	border: 1px solid var(--border);
	border-radius: 12px;
	background: var(--surface-2);
}

.demo-frosted-nav .fn-window:focus-visible {
	outline: 2px solid var(--text);
	outline-offset: 3px;
}

/* the whole effect: sticky, a thin fill, and the blur behind it */
.demo-frosted-nav .fn-bar {
	position: sticky;
	top: 0;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: .8rem 1rem;
	border-bottom: 1px solid var(--fn-line);
	font-weight: 600;
	color: var(--fn-ink);
	background: var(--fn-fill);
	-webkit-backdrop-filter: blur(1rem);
	backdrop-filter: blur(1rem);
}

.demo-frosted-nav .fn-logo {
	font-size: 1.05rem;
	font-weight: 800;
}

.demo-frosted-nav .fn-links {
	display: flex;
	gap: 1rem;
	font-size: .9rem;
}

.demo-frosted-nav .fn-links a {
	color: inherit;
	text-decoration: none;
}

.demo-frosted-nav .fn-links a:hover {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.demo-frosted-nav .fn-links a:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* bright blocks with large words: sharp edges are what make the blur easy to see */
.demo-frosted-nav .fn-block {
	display: grid;
	place-items: center;
	min-height: 13rem;
	font-size: 3.6rem;
	font-weight: 800;
	line-height: 1;
	color: var(--bg);
}

/* the first block starts behind the bar with its word half under it, so the frost shows at load */
.demo-frosted-nav .fn-bar + .fn-block {
	align-items: start;
	margin-top: -3.2rem;
	padding-top: 1.5rem;
}

/* the bar is the first div, so the colors start at 2, with the brightest first */
.demo-frosted-nav .fn-block:nth-of-type(6n + 2) { background: var(--yellow); }
.demo-frosted-nav .fn-block:nth-of-type(6n + 3) { background: var(--rose); }
.demo-frosted-nav .fn-block:nth-of-type(6n + 4) { background: var(--sky); }
.demo-frosted-nav .fn-block:nth-of-type(6n + 5) { background: var(--coral); }
.demo-frosted-nav .fn-block:nth-of-type(6n) { background: var(--teal); }
.demo-frosted-nav .fn-block:nth-of-type(6n + 1) { background: var(--violet); }

/* as tall as the window, so even the last color can reach the bar */
.demo-frosted-nav .fn-block:last-child {
	min-height: 100%;
}

/* no blur at all: a nearly solid fill keeps the text readable */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
	.demo-frosted-nav .fn-bar {
		background: var(--fn-solid);
	}
}

/* home card: the window is a picture, not a scroller, and the blocks drift under the bar on their own */
.card-preview .demo-frosted-nav {
	width: 100%;
	height: 100%;
}

.card-preview .demo-frosted-nav .fn-window {
	position: relative;
	max-width: none;
	height: 100%;
	overflow: hidden;
	border: 0;
	border-radius: 0;
}

.card-preview .demo-frosted-nav .fn-bar {
	position: absolute;
	inset: 0 0 auto;
	padding: .6rem .9rem;
}

.card-preview .demo-frosted-nav .fn-logo {
	font-size: .95rem;
}

.card-preview .demo-frosted-nav .fn-links {
	gap: .8rem;
	font-size: .75rem;
}

.card-preview .demo-frosted-nav .fn-drift {
	animation: fn-drift 12s ease-in-out infinite alternate;
}

.card-preview .demo-frosted-nav .fn-bar + .fn-block {
	margin-top: 0;
	padding-top: 0;
}

.card-preview .demo-frosted-nav .fn-block,
.card-preview .demo-frosted-nav .fn-block:last-child {
	min-height: 7rem;
	font-size: 2.6rem;
}

@keyframes fn-drift {
	from { transform: translateY(-.6rem); }
	to { transform: translateY(-14rem); }
}

@media (prefers-reduced-motion: reduce) {
	.card-preview .demo-frosted-nav .fn-drift {
		animation: none;
		transform: translateY(-3.4rem);
	}
}

/* ── Variant: a slide-in menu panel ── */
.demo-frosted-nav .fn-frame {
	position: relative;
	isolation: isolate;
	width: 100%;
	max-width: 36rem;
	overflow: hidden;
	border-radius: 12px;
}

.demo-frosted-nav .fn-frame .fn-window {
	display: block;
	max-width: none;
}

/* the frame clips the window's own ring, so the frame draws it */
.demo-frosted-nav .fn-frame .fn-window:focus-visible {
	outline: none;
}

.demo-frosted-nav .fn-frame:has(.fn-window:focus-visible) {
	outline: 2px solid var(--text);
	outline-offset: 3px;
}

.demo-frosted-nav .fn-menu {
	display: inline-flex;
	align-items: center;
	gap: .4rem;
	min-height: 1.5rem;
	font-size: .9rem;
	cursor: pointer;
}

/* the box stays focusable, it is only moved out of sight */
.demo-frosted-nav .fn-menu input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.demo-frosted-nav .fn-menu:has(:focus-visible) {
	outline: 2px solid currentColor;
	outline-offset: 3px;
	border-radius: 3px;
}

.demo-frosted-nav .fn-menu svg {
	width: .95rem;
	height: .95rem;
}

/* the panel sits outside the scroller, so it stays put while the page moves behind it, and under the bar,
   so the Menu control stays reachable. visibility keeps its links out of the tab order while it is closed */
.demo-frosted-nav .fn-panel {
	position: absolute;
	inset: 0 0 0 auto;
	z-index: 0;
	display: grid;
	align-content: start;
	gap: .2rem;
	width: 62%;
	max-width: 15rem;
	padding: 4rem .9rem .9rem;
	border-left: 1px solid var(--fn-line);
	color: var(--fn-ink);
	background: var(--fn-fill);
	-webkit-backdrop-filter: blur(1rem);
	backdrop-filter: blur(1rem);
	transform: translateX(100%);
	visibility: hidden;
	transition: transform .3s ease, visibility 0s linear .3s;
}

.demo-frosted-nav .fn-frame:has(.fn-menu input:checked) .fn-panel {
	transform: none;
	visibility: visible;
	transition: transform .3s ease;
}

.demo-frosted-nav .fn-panel a {
	padding: .55rem .6rem;
	border-radius: 6px;
	font-weight: 600;
	color: inherit;
	text-decoration: none;
}

.demo-frosted-nav .fn-panel a:hover {
	background: var(--fn-line);
}

.demo-frosted-nav .fn-panel a:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -2px;
}

/* ── Variant: a dropdown inside the bar ── */
.demo-frosted-nav .fn-pair {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
	gap: 1rem;
	width: 100%;
	max-width: 44rem;
}

.demo-frosted-nav .fn-case {
	display: grid;
	gap: .45rem;
}

.demo-frosted-nav .fn-case-name {
	font-family: var(--font-mono);
	font-size: .78rem;
	color: var(--text);
}

.demo-frosted-nav .fn-case .fn-window {
	height: 17rem;
}

/* hard stripes under the dropdown: the failure is obvious on them */
.demo-frosted-nav .fn-case .fn-block {
	min-height: 11rem;
	font-size: 2.4rem;
	background: repeating-linear-gradient(90deg, #fff 0 8px, #101014 8px 16px);
	color: #fff;
	text-shadow: 0 0 .6rem #000, 0 0 .2rem #000;
}

.demo-frosted-nav .fn-drop {
	position: relative;
	font-size: .9rem;
}

.demo-frosted-nav .fn-drop summary {
	cursor: pointer;
}

.demo-frosted-nav .fn-drop summary:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
	border-radius: 3px;
}

.demo-frosted-nav .fn-sheet {
	position: absolute;
	top: calc(100% + 1rem);
	right: -.4rem;
	display: grid;
	gap: .1rem;
	width: 9.5rem;
	padding: .4rem;
	border: 1px solid var(--fn-line);
	border-radius: 8px;
	background: var(--fn-fill);
	-webkit-backdrop-filter: blur(1rem);
	backdrop-filter: blur(1rem);
}

.demo-frosted-nav .fn-sheet a {
	padding: .4rem .55rem;
	border-radius: 5px;
	color: inherit;
	text-decoration: none;
}

.demo-frosted-nav .fn-sheet a:hover {
	background: var(--fn-line);
}

.demo-frosted-nav .fn-sheet a:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -2px;
}

/* the fix: the bar's frost moves to a pseudo-element, so the bar itself has no filter and the dropdown can see the page */
.demo-frosted-nav .fn-fixed .fn-bar {
	background: none;
	-webkit-backdrop-filter: none;
	backdrop-filter: none;
}

.demo-frosted-nav .fn-fixed .fn-bar::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: var(--fn-fill);
	-webkit-backdrop-filter: blur(1rem);
	backdrop-filter: blur(1rem);
}

@media (prefers-reduced-motion: reduce) {
	.demo-frosted-nav .fn-panel,
	.demo-frosted-nav .fn-frame:has(.fn-menu input:checked) .fn-panel {
		transition: none;
	}
}
