/***********************************************************************
*  Nav Bar main
**********************************************************************/

/*Drop down over 666px*/
.main-nav {
	display: flex;
	justify-content: center;
	height: 80px;
	padding: 0px;
	margin: 0px;
	font-family: "Nanum Gothic", sans-serif;
	perspective: 200px;
	transform-style: preserve-3d;
	z-index: 9999;
}

.sub-menu {
	transform-style: preserve-3d;
}

:root {
	--nav-dur: 300ms;
	--nav-ease: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/***********************************************************************
*  Nav Bar over 666px page width
**********************************************************************/

@media (min-width: 880px) {
	.main-nav {
		width: 100%;
		position: absolute;
		background: #1e1f24;
		margin: 0px;
		max-width: 100%;
		z-index: 9999;
	}

	.main-nav ol {
		width: 100%;
		display: flex;
		justify-content: space-around;
		padding: 0px;
		margin: 0px;
		transition: all var(--nav-dur) var(--nav-ease);
	}

	.main-nav ol li {
		display: inline-block;
		padding: 30px;
		flex-grow: 1;
		text-align: center;
		position: relative;
		transition: all var(--nav-dur) var(--nav-ease);
	}

	/* Make the clickable/hover area match the full slot (safe) */
	.main-nav > ol > li > a {
		display: block;
		width: 100%;
		height: 100%;
	}

	.main-nav ol li:before {
		content: "";
		position: absolute;
		width: 100%;
		height: 100%;
		top: 0;
		left: 0;
		z-index: -1;
		transition: all var(--nav-dur) var(--nav-ease);
		transform: translateY(-125%) rotate(-5deg);
	}

	.main-nav ol li:hover:before {
		transform: translateY(0) rotate(0deg);
	}

	/* Keep submenu link text white */
	.main-nav ol li:hover ol li a {
		color: #fff;
	}

	.main-nav ol li:hover ol:before {
		content: "";
		position: absolute;
		width: 20px;
		height: 20px;
		display: block;
		bottom: -30px;
		left: -15px;
		transform: rotate(45deg) scale(0.5);
		border: 3px solid orange;
		border-color: orange transparent transparent orange;
		background: linear-gradient(
			45deg,
			transparent -50%,
			transparent 45%,
			orange 45%,
			orange 55%,
			transparent 55%,
			transparent 125%
		);
		background-repeat: no-repeat;
		animation: clipin 0.4s ease-in 1 forwards;
		animation-delay: 0.2s;
		clip-path: polygon(35% 35%, 35% 0, 35% 0, 35% 35%, 0 35%, 0 35%);
	}

	.main-nav ol li:hover li {
		position: relative;
	}

	.main-nav ol li:hover li:first-of-type:before {
		display: none;
	}

	.main-nav ol li:hover li:before {
		content: "";
		position: absolute;
		width: 20px;
		height: 20px;
		display: block;
		right: -30px;
		top: -15px;
		left: auto;
		transform: rotate(-45deg) scale(0.5);
		border: 3px solid red;
		border-color: red transparent transparent red;
		background: linear-gradient(
			45deg,
			transparent -50%,
			transparent 45%,
			red 45%,
			red 55%,
			transparent 55%,
			transparent 125%
		);
		background-repeat: no-repeat;
		animation: clipin 0.4s ease-in 1 forwards;
		clip-path: polygon(35% 35%, 35% 0, 35% 0, 35% 35%, 0 35%, 0 35%);
	}

	/* This is the little burst animation*/
	@keyframes clipin {
		0% {
			-webkit-clip-path: polygon(35% 35%, 35% 0, 35% 0, 35% 35%, 0 35%, 0 35%);
			clip-path: polygon(35% 35%, 35% 0, 35% 0, 35% 35%, 0 35%, 0 35%);
		}
		50% {
			-webkit-clip-path: polygon(35% 35%, 35% 0, 35% 0, 35% 35%, 0 35%, 0 35%);
			clip-path: polygon(35% 35%, 35% 0, 35% 0, 35% 35%, 0 35%, 0 35%);
		}
		75% {
			-webkit-clip-path: polygon(
				35% 35%,
				35% 0,
				100% 0,
				100% 100%,
				0 100%,
				0 35%
			);
			clip-path: polygon(35% 35%, 35% 0, 100% 0, 100% 100%, 0 100%, 0 35%);
		}
		100% {
			-webkit-clip-path: polygon(
				100% 100%,
				100% 0,
				100% 0,
				100% 100%,
				0 100%,
				0 100%
			);
			clip-path: polygon(100% 100%, 100% 0, 100% 0, 100% 100%, 0 100%, 0 100%);
		}
	}

	/* Top-level colour blocks via one variable */
	.main-nav ol li:before {
		background: var(--c);
	}

	.main-nav ol li:nth-of-type(1) {
		--c: #ff2b00;
	}
	.main-nav ol li:nth-of-type(2) {
		--c: #ff5500;
	}
	.main-nav ol li:nth-of-type(3) {
		--c: #ff8000;
	}
	.main-nav ol li:nth-of-type(4) {
		--c: #ffaa00;
	}
	.main-nav ol li:nth-of-type(5) {
		--c: #ffd500;
	}
	.main-nav ol li:nth-of-type(6) {
		--c: yellow;
	}
	.main-nav ol li:nth-of-type(7) {
		--c: #d5ff00;
	}
	.main-nav ol li:nth-of-type(8) {
		--c: #aaff00;
	}
	.main-nav ol li:nth-of-type(9) {
		--c: #80ff00;
	}
	.main-nav ol li:nth-of-type(10) {
		--c: #55ff00;
	}

	/* keep translateX(-50%) when opening the submenu */
	.main-nav ol li:hover ol {
		transform: translateX(-50%) translateY(0) translateZ(-1px);
	}

	.main-nav ol li:hover ol:after {
		transform: rotate(0deg);
	}

	/* Do not remove, this breaks the animation if you do */
	.main-nav ol li:hover ol li:nth-of-type(1n) {
		transform: none;
		margin: 0px;
		padding: 30px;
	}

	/* Submenu hover overlay (restores “hovered item highlight”) */
	.main-nav ol li ol li {
		position: relative;
	}
	.main-nav ol li ol li:after {
		content: "";
		position: absolute;
		left: 0;
		right: 0;
		top: 1vh;
		bottom: 0;
		opacity: 0;
		background: rgba(255, 255, 255, 0.14);
		transition: opacity 180ms ease, top 180ms ease;
		pointer-events: none;
	}
	.main-nav ol li:hover ol li:nth-of-type(1n):hover:after {
		opacity: 1;
		top: 0vh;
	}

	.main-nav ol li a {
		color: #fff;
		text-decoration: none;
		text-transform: uppercase;
		letter-spacing: 2px;
		font-weight: 900;
		white-space: nowrap;
	}

	/* Dropdown base (centred under parent) */
	.main-nav ol li ol {
		display: block;
		position: absolute;
		top: 100%;
		left: 50%;
		transform: translateX(-50%) translateY(-125%) translateZ(-5px);
		transform-origin: top center;
		z-index: -1;
		min-width: 100%;
		width: max-content;
		max-width: 320px;
	}

	/* keep dropdown above content when open */
	.main-nav ol li:hover > ol {
		z-index: 3;
	}

	.main-nav ol li ol:hover li:nth-of-type(1n):hover {
		padding: 40px 30px;
	}

	.main-nav ol li ol li {
		display: block;
		margin: 20px 0;
	}

	/* Submenu: drive colour + spark gradient from one variable */
	.main-nav ol li ol li {
		background: var(--c);
	}

	.main-nav ol li ol li:before {
		background: linear-gradient(
			45deg,
			transparent -50%,
			transparent 45%,
			var(--c) 45%,
			var(--c) 55%,
			transparent 55%,
			transparent 125%
		);
		background-repeat: no-repeat;
		border-color: var(--c) transparent transparent var(--c);
	}

	.main-nav ol li ol li a {
		font-size: 14px;
		white-space: normal;
	}

	.main-nav ol li ol li:before {
		display: block;
	}

	/* Animation-delay timing */
	.main-nav ol li ol li:nth-of-type(1):before {
		animation-delay: 0.05s;
	}
	.main-nav ol li ol li:nth-of-type(2):before {
		animation-delay: 0.1s;
	}
	.main-nav ol li ol li:nth-of-type(3):before {
		animation-delay: 0.15s;
	}
	.main-nav ol li ol li:nth-of-type(4):before {
		animation-delay: 0.2s;
	}
	.main-nav ol li ol li:nth-of-type(5):before {
		animation-delay: 0.25s;
	}
	.main-nav ol li ol li:nth-of-type(6):before {
		animation-delay: 0.3s;
	}
	.main-nav ol li ol li:nth-of-type(7):before {
		animation-delay: 0.35s;
	}
	.main-nav ol li ol li:nth-of-type(8):before {
		animation-delay: 0.4s;
	}
	.main-nav ol li ol li:nth-of-type(9):before {
		animation-delay: 0.45s;
	}
	.main-nav ol li ol li:nth-of-type(10):before {
		animation-delay: 0.5s;
	}

	/* One line per item: sets colour + transition-delay */
	.main-nav ol li ol li:nth-of-type(1) {
		--c: #ff2b00;
		transition-delay: 0.1s;
	}
	.main-nav ol li ol li:nth-of-type(2) {
		--c: #ff5500;
		transition-delay: 0.2s;
	}
	.main-nav ol li ol li:nth-of-type(3) {
		--c: #ff8000;
		transition-delay: 0.3s;
	}
	.main-nav ol li ol li:nth-of-type(4) {
		--c: #ffaa00;
		transition-delay: 0.4s;
	}
	.main-nav ol li ol li:nth-of-type(5) {
		--c: #ffd500;
		transition-delay: 0.5s;
	}
	.main-nav ol li ol li:nth-of-type(6) {
		--c: yellow;
		transition-delay: 0.6s;
	}
	.main-nav ol li ol li:nth-of-type(7) {
		--c: #d5ff00;
		transition-delay: 0.7s;
	}
	.main-nav ol li ol li:nth-of-type(8) {
		--c: #aaff00;
		transition-delay: 0.8s;
	}
	.main-nav ol li ol li:nth-of-type(9) {
		--c: #80ff00;
		transition-delay: 0.9s;
	}
	.main-nav ol li ol li:nth-of-type(10) {
		--c: #55ff00;
		transition-delay: 1s;
	}

	.main-nav ol li ol li:first-of-type {
		margin-top: 0;
	}
	.main-nav ol li ol li:nth-of-type(even) {
		transform-origin: top left;
		transform: rotate(5deg);
	}
	.main-nav ol li ol li:nth-of-type(odd) {
		transform-origin: top right;
		transform: rotate(-5deg);
	}

	/* Top-level hover text colour (replaces the 10-item selector list) */
	.main-nav > ol > li:hover > a {
		color: #222;
	}
}

/***********************************************************************
*  Nav Bar over 666px page width
**********************************************************************/
@media (max-width: 880px) {
	.main-nav {
		position: absolute;
		top: 0;
		height: 45px;
		left: 0;
		background: #1e1f24;
		width: 100%;
		z-index: 9999;
	}

	/* Mobile: carry the same colour per slot */
	.main-nav ol li:nth-of-type(1) {
		--c: #ff2b00;
		--i: 1;
	}
	.main-nav ol li:nth-of-type(2) {
		--c: #ff5500;
		--i: 2;
	}
	.main-nav ol li:nth-of-type(3) {
		--c: #ff8000;
		--i: 3;
	}
	.main-nav ol li:nth-of-type(4) {
		--c: #ffaa00;
		--i: 4;
	}
	.main-nav ol li:nth-of-type(5) {
		--c: #ffd500;
		--i: 5;
	}
	.main-nav ol li:nth-of-type(6) {
		--c: yellow;
		--i: 6;
	}
	.main-nav ol li:nth-of-type(7) {
		--c: #d5ff00;
		--i: 7;
	}
	.main-nav ol li:nth-of-type(8) {
		--c: #aaff00;
		--i: 8;
	}
	.main-nav ol li:nth-of-type(9) {
		--c: #80ff00;
		--i: 9;
	}
	.main-nav ol li:nth-of-type(10) {
		--c: #55ff00;
		--i: 10;
	}

	.main-nav:hover ol li:nth-of-type(1n) {
		transform: rotate(0deg);
		margin: 0px;
		transition: all var(--nav-dur) var(--nav-ease);
	}

	.main-nav:hover ol li {
		transition-delay: calc(var(--i, 0) * 0.0666666667s);
	}
	.main-nav:hover ol li:hover > a {
		color: var(--c);
	}

	/* Hamburger animation */
	.main-nav:hover:before {
		transform: rotate(45deg);
		box-shadow: 0 0 0 0;
	}
	.main-nav:hover:after {
		transform: rotate(-45deg);
	}

	.main-nav:before,
	.main-nav:after {
		content: "";
		position: absolute;
		width: 30px;
		height: 3px;
		background: #fff;
		top: 10px;
		left: calc(50% - 15px);
		border-radius: 5px;
		box-shadow: 0 10px 0 0 #fff;
		transition: transform 300ms cubic-bezier(0.175, 0.885, 0.32, 1.275),
			box-shadow 100ms ease-in-out;
		transition-delay: 0.1s, 0s;
		transform-origin: 0% 50%;
	}

	.main-nav:after {
		box-shadow: none;
		top: 30px;
	}

	.main-nav:hover ol ol {
		transform: none;
	}
	.main-nav ol li:nth-of-type(even) {
		transform: rotate(-5deg);
	}
	.main-nav ol li:nth-of-type(odd) {
		transform: rotate(5deg);
	}

	/* Hack required for slim windows on PC */
	.main-nav:hover ol,
	.main-nav:focus-within ol {
		transform: translateY(0) translateZ(-1px);
		opacity: 1;
	}

	.main-nav ol {
		position: absolute;
		width: 100%;
		top: 0px;
		display: table;
		left: 0;
		margin: 0px;
		transform: translateY(calc(-125% - 45px)) translateZ(-1px);
		text-align: center;
		transition: all var(--nav-dur) var(--nav-ease);
		background: #000;
		padding: 60px 0 20px;
		height: 100vh;
	}

	.main-nav ol li {
		position: relative;
		display: inline-block;
		width: 100%;
		clear: both;
		height: 50px;
		padding: 10px 0;
		margin: 10px 0;
		transition: all var(--nav-dur) var(--nav-ease);
		background: #000;
	}

	.main-nav ol li:hover ol {
		height: auto;
		transition: opacity 0.2s ease-in-out;
		opacity: 1;
	}

	.main-nav ol li a {
		color: #fff;
		text-decoration: none;
		display: block;
		width: 100%;
		height: 100%;
	}

	/* Mobile active/hover indicator */
	.main-nav ol li:hover > a,
	.main-nav ol li:focus-within > a {
		text-decoration: underline;
		text-underline-offset: 8px;
		text-decoration-thickness: 3px;
	}

	/* If active class is on <li>, force underline on mobile */
	.main-nav ol li.active > a {
		text-decoration-thickness: 4px;
	}

	.main-nav ol ol {
		position: relative;
		transform: none;
		background: transparent;
		display: inline-block;
		width: 100%;
		top: auto;
		padding: 0;
		height: 0;
		overflow: hidden;
		opacity: 0;
		transition: opacity 0.2s ease-in-out;
	}

	.main-nav ol ol li {
		font-size: 12px;
		height: auto;
	}

	.main-nav ol ol li:first-of-type {
		padding-top: 20px;
	}
}

/***********************************************************************
*  Nav Bar final tid-bits
**********************************************************************/
.active {
	border-bottom: 5px solid var(--accent);
	color: var(--accent);
	padding-bottom: 1px;
}

.sticky {
	position: fixed;
	top: 0;
	width: 100%;
}

/* Forces the nav bar to go invisible, and then re-apear on hover */
@media (min-width: 880px) {
	.main-nav ol li > .sub-menu li {
		display: none;
		margin: 0;
	}
	.main-nav ol li:hover > .sub-menu li {
		display: block;
		margin: 20px 0;
	}
}

/* Make the whole coloured nav slot clickable (desktop) */
@media (min-width: 880px) {
	.main-nav > ol > li {
		position: relative;
	}

	.main-nav > ol > li > a {
		position: absolute;
		inset: 0;
		display: flex;
		align-items: center;
		justify-content: center;
		z-index: 1;
	}
}

/* Same idea for submenu “buttons” (desktop) */
@media (min-width: 880px) {
	.main-nav ol li ol li {
		position: relative;
	}

	.main-nav ol li ol li > a {
		position: absolute;
		inset: 0;
		display: flex;
		align-items: center;
		justify-content: center;
		z-index: 1;
	}
}

/* Keep checkbox invisible */
.nav-toggle {
	position: absolute;
	left: -9999px;
}

@media (max-width: 880px) {
	/* IMPORTANT: stop hover/focus-within from opening the menu on mobile */
	.main-nav:hover ol,
	.main-nav:focus-within ol {
		transform: translateY(calc(-125% - 45px)) translateZ(-1px);
		opacity: 0;
	}

	/* Top bar tap area (clicking this toggles checkbox open/close) */
	.main-nav .nav-toggle-hit {
		position: absolute;
		inset: 0;
		height: 45px;
		z-index: 10001;
		cursor: pointer;
		background: transparent;
	}

	/* Keep burger bars above the hit area */
	.main-nav:before,
	.main-nav:after {
		z-index: 10002;
	}

	/* Menu closed by default */
	.main-nav ol {
		pointer-events: none;
	}

	/* Menu OPEN when checked */
	.main-nav .nav-toggle:checked ~ ol {
		transform: translateY(0) translateZ(-1px);
		opacity: 0.95;
		pointer-events: auto;
	}

	/* Optional: burger -> X when open (works on modern Safari/Chrome) */
	.main-nav:has(.nav-toggle:checked):before {
		transform: rotate(45deg);
		box-shadow: 0 0 0 0;
	}

	.main-nav:has(.nav-toggle:checked):after {
		transform: rotate(-45deg);
	}

	/* Bring back broken hover colours and links */
	.main-nav .nav-toggle:checked ~ ol a {
		pointer-events: auto;
	}

	/* Remove the underline that gets generated */
	.main-nav ol li.active {
		border-bottom: none;
	}

	/* Add a centred “pill” behind the active link text */
	.main-nav ol li.active > a {
		position: relative;
		z-index: 0;
	}

	/* Colouring for an active link that is on the first line (index, about, etc) */
	.main-nav ol li.active > a::before {
		content: "";
		position: absolute;
		left: 50%;
		top: 50%;
		transform: translate(-50%, -55%);
		width: min(520px, 86vw);
		height: 115%; /* Somewhat hacky, but highest value height that doesn't deform, and covers the line generated next (marker for active page) */
		border-radius: 999px;
		background: color-mix(in srgb, #ffb703 14%, transparent);
		z-index: -1;
		pointer-events: none;
	}

	/* Small red marker under current page (disappears with hover colours when hovered due to height set above) */
	.main-nav ol li.active > a::after {
		content: "";
		display: block;
		width: 40px;
		height: 3px;
		margin: auto;
		background: var(--accent);
		border-radius: 2px;
	}

	/* If it's a submenu item get a smaller, different coloured pill */
	.main-nav ol ol li.active > a::before {
		width: min(420px, 76vw);
		height: 115%;
		background: color-mix(in srgb, #ffd166 16%, transparent);
	}

	/* Makes the burger specifically "unclickable" (drawn with pseudo elements, so hard to utilise) */
	.main-nav:before,
	.main-nav:after {
		pointer-events: none;
	}
}
