/* Running Bug — homepage tweaks: badge grid layout and the Challenges dropdown. */

/* -------------------------------------------- "Earn badges as you run" (#gamification)
   The theme shows the badges 4 across, which leaves the 5th alone on a row.
   On desktop lay them out 3 + 2, with the second row centred. A 6-column grid
   lets each badge span 2 columns, so the last two sit in columns 2-3 and 4-5. */
@media (min-width: 1025px) {
	#gamification .trb-badges {
		grid-template-columns: repeat(6, minmax(0, 1fr));
		gap: 20px;
	}

	#gamification .trb-badges > .trb-badge {
		grid-column: span 2;
	}

	/* Exactly 5 badges: centre the last two. */
	#gamification .trb-badges > .trb-badge:nth-child(4):nth-last-child(2) {
		grid-column: 2 / span 2;
	}

	#gamification .trb-badges > .trb-badge:nth-child(5):last-child {
		grid-column: 4 / span 2;
	}
}

/* ------------------------------------------------------- Challenges dropdown */
/* Support both custom dropdown (rb-has-drop) and existing WordPress menus */
.trb-topnav .menu-item-has-children,
.trb-topnav .rb-has-drop {
	position: relative;
}

/* Style the submenu as a dropdown */
.trb-topnav .menu-item-has-children > .sub-menu,
.trb-topnav .rb-has-drop > .sub-menu {
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%) translateY(6px);
	min-width: 230px;
	margin: 0;
	padding: 8px;
	list-style: none;
	background: #ffffff;
	border-radius: 14px;
	box-shadow: 0 18px 40px -12px rgba(11, 61, 39, 0.3);
	border: 1px solid #e3e9e0;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.15s ease, transform 0.15s ease;
	z-index: 10060;
}

.trb-topnav .menu-item-has-children:hover > .sub-menu,
.trb-topnav .menu-item-has-children:focus-within > .sub-menu,
.trb-topnav .rb-has-drop:hover > .sub-menu,
.trb-topnav .rb-has-drop:focus-within > .sub-menu {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: translateX(-50%) translateY(0);
}

/* Keeps the pointer inside the menu while moving down to it. */
.trb-topnav .menu-item-has-children > .sub-menu::before,
.trb-topnav .rb-has-drop > .sub-menu::before {
	content: "";
	position: absolute;
	top: -10px;
	left: 0;
	right: 0;
	height: 10px;
}

.trb-topnav .menu-item-has-children > .sub-menu > li,
.trb-topnav .rb-has-drop > .sub-menu > li {
	margin: 0;
	padding: 0;
}

.trb-topnav .menu-item-has-children > .sub-menu > li > a,
.trb-topnav .rb-has-drop > .sub-menu > li > a {
	display: block;
	padding: 10px 14px;
	border-radius: 9px;
	color: #0b3d27 !important;
	font-size: 13.5px;
	font-weight: 700;
	letter-spacing: 0;
	line-height: 1.3;
	text-transform: none;
	white-space: nowrap;
	text-decoration: none !important;
}

.trb-topnav .menu-item-has-children > .sub-menu > li > a:hover,
.trb-topnav .menu-item-has-children > .sub-menu > li > a:focus-visible,
.trb-topnav .menu-item-has-children > .sub-menu > li.current-menu-item > a,
.trb-topnav .rb-has-drop > .sub-menu > li > a:hover,
.trb-topnav .rb-has-drop > .sub-menu > li > a:focus-visible,
.trb-topnav .rb-has-drop > .sub-menu > li.current-menu-item > a {
	background: #f1f7ec;
	color: #15803d !important;
}

/* Small caret so the dropdown is discoverable. */
.trb-topnav .menu-item-has-children > a::before,
.trb-topnav .rb-has-drop > a::before {
	content: "";
	display: inline-block;
	width: 0;
	height: 0;
	margin-right: 6px;
	vertical-align: middle;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-top: 5px solid currentColor;
	opacity: 0.75;
}

/* In the mobile drawer the children are shown as an indented list. */
.trb-nav-drawer .rb-has-drop > .sub-menu {
	list-style: none;
	margin: 6px 0 2px;
	padding: 0 0 0 14px;
	border-left: 2px solid rgba(86, 147, 65, 0.35);
}

.trb-nav-drawer .rb-has-drop > .sub-menu > li > a {
	display: block;
	padding: 8px 0;
	font-size: 15px;
	font-weight: 600;
	text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
	.trb-topnav .rb-has-drop > .sub-menu {
		transition: none;
	}
}

/* Homepage hero: the hero picture already has its own green fade, so the
   theme's 72–82% dark layer hid it almost completely. Keep only a light
   fade behind the text so the photo shows. */
.trb-hero::before {
	background: linear-gradient(90deg, rgba(18, 40, 16, 0.55) 0%, rgba(18, 40, 16, 0.25) 45%, rgba(18, 40, 16, 0) 75%);
}

.trb-hero {
	background-position: center right;
}

@media (max-width: 767px) {
	.trb-hero {
		background-position: 70% center;
	}

	.trb-hero::before {
		background: linear-gradient(180deg, rgba(18, 40, 16, 0.55), rgba(18, 40, 16, 0.35));
	}
}
