/* =========================================================================
   Trans Nation DT Sacco — custom child-theme header
   Styling for the markup in header.php (.tn-site-header). Brand variables
   come from style.css (:root). Mobile-first with a desktop breakpoint.
   ========================================================================= */

/* --- Top contact bar (brand gradient, matches the nav underline) ------ */
.tn-topbar {
	background: linear-gradient(90deg, var(--tn-green) 0%, var(--tn-teal) 100%);
	color: #fff;
	font-size: 0.85rem;
	letter-spacing: 0.01em;
}

.tn-topbar-inner {
	max-width: 1200px;
	margin: 0 auto;
	padding: 9px 24px;
	display: flex !important;
	justify-content: space-between !important;
	align-items: center;
	gap: 28px;
}

/* Contacts grouped on the far left */
.tn-topbar__contacts {
	display: flex;
	align-items: center;
	gap: 28px;
	flex: 1 1 auto; /* take all available left space */
}

/* Search anchored on the far right */
.tn-topbar__search {
	position: relative;
	flex: 0 0 auto;
}

.tn-search-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	background: none;
	border: 0;
	color: #fff;
	cursor: pointer;
}

.tn-search-toggle .tn-topbar__icon {
	background: rgba(255, 255, 255, 0.18);
}

.tn-search-toggle:hover .tn-topbar__icon,
.tn-search-toggle[aria-expanded="true"] .tn-topbar__icon {
	background: rgba(255, 255, 255, 0.32);
}

/* Dropdown search panel — display:none so Elementor can't reset visibility */
.tn-search-panel {
	display: none;
	position: absolute;
	top: calc(100% + 10px);
	right: 0;
	z-index: 20;
	min-width: 280px;
	padding: 12px;
	background: #fff;
	border-radius: 10px;
	box-shadow: var(--tn-shadow-strong);
}

.tn-topbar__search.is-open .tn-search-panel {
	display: flex;
	flex-direction: column;
	gap: 8px;
	animation: tn-panel-in 0.2s var(--tn-ease) both;
}

@keyframes tn-panel-in {
	from { opacity: 0; transform: translateY(-6px); }
	to   { opacity: 1; transform: translateY(0); }
}

.tn-search-panel form {
	display: flex;
	gap: 8px;
	width: 100%;
}

.tn-search-panel input[type="search"],
.tn-search-panel .search-field {
	flex: 1 1 auto;
	min-width: 0;
	padding: 9px 12px;
	border: 1px solid rgba(31, 41, 55, 0.2) !important;
	border-radius: 8px !important;
	font-size: 0.9rem;
	background: #fff !important;
	color: var(--tn-ink) !important;
	box-shadow: none !important;
}

.tn-search-panel input[type="search"]:focus,
.tn-search-panel .search-field:focus {
	outline: none !important;
	border-color: var(--tn-teal) !important;
	box-shadow: 0 0 0 3px rgba(22, 182, 196, 0.15) !important;
}

/* !important beats Elementor's global button colour (often pink/magenta) */
.tn-search-panel input[type="submit"],
.tn-search-panel .search-submit,
.tn-search-panel button[type="submit"] {
	padding: 9px 16px !important;
	background: var(--tn-teal) !important;
	background-color: var(--tn-teal) !important;
	color: #fff !important;
	border: 0 !important;
	border-radius: 8px !important;
	font-weight: 700 !important;
	cursor: pointer;
	transition: background-color 0.25s var(--tn-ease);
	box-shadow: none !important;
}

.tn-search-panel input[type="submit"]:hover,
.tn-search-panel .search-submit:hover,
.tn-search-panel button[type="submit"]:hover {
	background: var(--tn-teal-dark) !important;
	background-color: var(--tn-teal-dark) !important;
}

.tn-topbar__item {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: #fff;
	text-decoration: none;
	transition: opacity 0.25s var(--tn-ease);
}

.tn-topbar__item:hover {
	opacity: 0.85;
}

/* Icon sits in a soft translucent chip so it reads on the gradient */
.tn-topbar__icon {
	flex: 0 0 auto;
	padding: 4px;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	color: #fff;
	transition: background-color 0.25s var(--tn-ease);
}

.tn-topbar__item:hover .tn-topbar__icon {
	background: rgba(255, 255, 255, 0.32);
}

.tn-topbar__label {
	font-weight: 600;
	opacity: 0.9;
}

.tn-topbar__value {
	font-weight: 700;
}

/* Subtle divider between the contact items */
.tn-topbar__item + .tn-topbar__item {
	position: relative;
}

.tn-topbar__item + .tn-topbar__item::before {
	content: "";
	position: absolute;
	left: -14px;
	top: 50%;
	height: 16px;
	width: 1px;
	background: rgba(255, 255, 255, 0.35);
	transform: translateY(-50%);
}

/* --- Main header ------------------------------------------------------ */
.tn-site-header {
	position: sticky;
	top: 0;
	z-index: 999;
	background: #fff;
	transition: box-shadow 0.35s var(--tn-ease), background-color 0.35s var(--tn-ease);
}

.tn-site-header.tn-scrolled {
	box-shadow: var(--tn-shadow);
}

.tn-header-inner {
	display: flex;
	align-items: center;
	gap: 18px;
	max-width: 1200px;
	margin: 0 auto;
	padding: 18px 24px;
	transition: padding 0.35s var(--tn-ease);
}

.tn-site-header.tn-scrolled .tn-header-inner {
	padding-top: 8px;
	padding-bottom: 8px;
}

/* --- Logo ------------------------------------------------------------- */
.tn-header-logo {
	flex: 0 0 auto;
}

.tn-header-logo img,
.tn-header-logo .custom-logo {
	display: block;
	height: auto;
	width: 150px;
	transition: transform 0.35s var(--tn-ease), filter 0.35s var(--tn-ease);
	transform-origin: left center;
}

.tn-header-logo a:hover img {
	transform: scale(1.05);
	filter: drop-shadow(0 4px 10px rgba(26, 168, 76, 0.25));
}

.tn-site-header.tn-scrolled .tn-header-logo img {
	transform: scale(0.85);
}

.tn-site-title {
	font-size: 1.4rem;
	font-weight: 800;
	color: var(--tn-green);
	text-decoration: none;
}

/* --- Primary navigation ---------------------------------------------- */
.tn-primary-nav {
	flex: 1 1 auto;
}

.tn-menu,
.tn-menu .sub-menu {
	list-style: none;
	margin: 0;
	padding: 0;
}

.tn-menu {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 6px;
}

.tn-menu li {
	position: relative;
}

.tn-menu a {
	display: block;
	padding: 10px 14px;
	font-weight: 600;
	font-size: 0.85rem;
	color: var(--tn-ink);
	text-decoration: none;
	border-radius: 8px;
	transition: color 0.25s var(--tn-ease);
}

/* Animated underline grows from the centre (background keeps ::after free
   for the dropdown caret) */
.tn-menu > li > a {
	background-image: linear-gradient(90deg, var(--tn-green), var(--tn-teal));
	background-repeat: no-repeat;
	background-position: 50% calc(100% - 4px);
	background-size: 0% 2px;
	transition: color 0.25s var(--tn-ease), background-size 0.3s var(--tn-ease);
}

.tn-menu > li > a:hover,
.tn-menu > li.current-menu-item > a {
	color: var(--tn-teal);
}

.tn-menu > li > a:hover,
.tn-menu > li.current-menu-item > a {
	background-size: 70% 2px;
}

/* Caret injected as a real <span> by JS — guaranteed after the label text */
.tn-caret {
	display: inline-block;
	width: 0;
	height: 0;
	margin-left: 6px;
	vertical-align: middle;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-top: 5px solid currentColor;
	transition: transform 0.25s var(--tn-ease);
}

.tn-menu .menu-item-has-children:hover > a .tn-caret {
	transform: rotate(180deg);
}

/* JS-injected mobile submenu toggle — hidden on desktop (hover is used there) */
.tn-submenu-toggle {
	display: none;
}

/* --- Desktop dropdowns ----------------------------------------------- */
.tn-menu .sub-menu {
	position: absolute;
	top: 100%;
	left: 0;
	min-width: 220px;
	background: #fff;
	border-radius: 10px;
	box-shadow: var(--tn-shadow-strong);
	padding: 8px;
	opacity: 0;
	visibility: hidden;
	transform: translateY(8px);
	transition: opacity 0.25s var(--tn-ease), transform 0.25s var(--tn-ease),
		visibility 0.25s var(--tn-ease);
	z-index: 10;
}

.tn-menu li:hover > .sub-menu,
.tn-menu li:focus-within > .sub-menu {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.tn-menu .sub-menu a {
	padding: 9px 12px;
	border-radius: 6px;
}

.tn-menu .sub-menu a:hover {
	background: rgba(22, 182, 196, 0.08);
	color: var(--tn-teal);
}

/* Nested submenu flies out to the side on desktop */
.tn-menu .sub-menu .sub-menu {
	top: 0;
	left: 100%;
}

/* --- Call-to-action buttons + customer care -------------------------- */
.tn-header-actions {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 12px;
}

.tn-btn {
	display: inline-block;
	padding: 11px 22px;
	font-weight: 700;
	font-size: 0.95rem;
	text-decoration: none;
	border-radius: 999px;
	border: 2px solid transparent;
	transition: transform 0.25s var(--tn-ease), box-shadow 0.25s var(--tn-ease),
		background-color 0.25s var(--tn-ease), color 0.25s var(--tn-ease);
}

.tn-btn--primary {
	background: var(--tn-teal);
	color: #fff;
}

.tn-btn--primary:hover {
	background: var(--tn-teal-dark);
	transform: translateY(-2px);
	box-shadow: 0 10px 22px rgba(22, 182, 196, 0.35);
}

.tn-btn--outline {
	background: transparent;
	color: var(--tn-ink);
	border-color: var(--tn-ink);
}

.tn-btn--outline:hover {
	background: var(--tn-ink);
	color: #fff;
	transform: translateY(-2px);
}

/* --- Hamburger toggle (hidden on desktop) ---------------------------- */
.tn-nav-toggle {
	display: none;
	margin-left: auto;
	background: none;
	border: 0;
	padding: 10px;
	cursor: pointer;
	color: var(--tn-ink);
}

.tn-nav-toggle__bars,
.tn-nav-toggle__bars span {
	display: block;
}

.tn-nav-toggle__bars {
	width: 26px;
	height: 20px;
	position: relative;
}

.tn-nav-toggle__bars span {
	position: absolute;
	left: 0;
	width: 100%;
	height: 3px;
	border-radius: 3px;
	background: currentColor;
	transition: transform 0.3s var(--tn-ease), opacity 0.3s var(--tn-ease), top 0.3s var(--tn-ease);
}

.tn-nav-toggle__bars span:nth-child(1) { top: 0; }
.tn-nav-toggle__bars span:nth-child(2) { top: 8px; }
.tn-nav-toggle__bars span:nth-child(3) { top: 16px; }

/* Morph into an X when open */
.tn-nav-open .tn-nav-toggle__bars span:nth-child(1) { top: 8px; transform: rotate(45deg); }
.tn-nav-open .tn-nav-toggle__bars span:nth-child(2) { opacity: 0; }
.tn-nav-open .tn-nav-toggle__bars span:nth-child(3) { top: 8px; transform: rotate(-45deg); }

/* ── Mobile drawer + backdrop (hidden on desktop) ──────────────────────── */
.tn-mobile-drawer,
.tn-drawer-backdrop {
	display: none;
}

/* --- Mobile layout (<= 1024px) --------------------------------------- */
@media (max-width: 1024px) {

	/* Show hamburger, push logo left */
	.tn-nav-toggle {
		display: block;
		order: 3;
	}

	.tn-header-logo {
		margin-right: auto;
	}

	/* Hide the desktop nav and action buttons — they live in the drawer now */
	.tn-primary-nav,
	.tn-header-actions {
		display: none !important;
	}

	/* ── Side drawer ──────────────────────────────────────────────────── */
	.tn-mobile-drawer {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		display: flex;
		flex-direction: column;
		width: 300px;
		max-width: 85vw;
		background: #fff;
		z-index: 1001;
		transform: translateX(100%);
		transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
		overflow: hidden;
		box-shadow: -10px 0 48px rgba(16, 23, 42, 0.18);
	}

	/* Brand gradient stripe at the top of the drawer */
	.tn-mobile-drawer::before {
		content: '';
		display: block;
		height: 4px;
		flex-shrink: 0;
		background: linear-gradient(90deg, var(--tn-green), var(--tn-teal));
	}

	.tn-nav-open .tn-mobile-drawer {
		transform: translateX(0);
	}

	/* Drawer header row: logo + close button */
	.tn-drawer__head {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 18px 20px;
		border-bottom: 1px solid rgba(31, 41, 55, 0.08);
		flex-shrink: 0;
	}

	.tn-drawer__logo img,
	.tn-drawer__logo .custom-logo {
		width: 110px;
		height: auto;
		display: block;
	}

	.tn-drawer__logo .tn-site-title {
		font-size: 1.1rem;
		font-weight: 800;
		color: var(--tn-green);
		text-decoration: none;
	}

	.tn-drawer__close {
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 8px;
		margin: -8px -8px -8px 0;
		background: none;
		border: 0;
		cursor: pointer;
		color: var(--tn-ink);
		border-radius: 8px;
		transition: background-color 0.2s ease, color 0.2s ease;
		flex-shrink: 0;
	}

	.tn-drawer__close:hover {
		background: rgba(31, 41, 55, 0.06);
		color: var(--tn-teal);
	}

	/* Scrollable nav area */
	.tn-drawer__nav {
		flex: 1 1 auto;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
	}

	/* ── Drawer menu ──────────────────────────────────────────────────── */
	.tn-drawer-menu,
	.tn-drawer-menu .sub-menu {
		list-style: none;
		margin: 0;
		padding: 0;
	}

	.tn-drawer-menu li {
		position: relative;
	}

	.tn-drawer-menu a {
		display: block;
		padding: 14px 20px;
		font-size: 0.925rem;
		font-weight: 600;
		color: var(--tn-ink);
		text-decoration: none;
		border-bottom: 1px solid rgba(31, 41, 55, 0.06);
		transition: color 0.2s ease, background-color 0.2s ease;
	}

	.tn-drawer-menu a:hover,
	.tn-drawer-menu .current-menu-item > a {
		color: var(--tn-teal);
		background: rgba(22, 182, 196, 0.05);
	}

	/* Extra right padding for items that have a submenu toggle */
	.tn-drawer-menu .menu-item-has-children > a {
		padding-right: 52px;
	}

	/* Accordion toggle button (injected by JS) */
	.tn-drawer-menu .tn-submenu-toggle {
		display: flex;
		align-items: center;
		justify-content: center;
		position: absolute;
		top: 0;
		right: 0;
		width: 52px;
		height: 100%;
		min-height: 48px;
		background: none;
		border: 0;
		cursor: pointer;
		color: var(--tn-muted);
	}

	.tn-drawer-menu .tn-submenu-toggle::before {
		content: '';
		width: 0;
		height: 0;
		border-left: 5px solid transparent;
		border-right: 5px solid transparent;
		border-top: 6px solid currentColor;
		transition: transform 0.25s var(--tn-ease);
	}

	.tn-drawer-menu .menu-item-has-children.is-open > .tn-submenu-toggle::before {
		transform: rotate(180deg);
	}

	/* Accordion sub-menu */
	.tn-drawer-menu .sub-menu {
		max-height: 0;
		overflow: hidden;
		transition: max-height 0.3s var(--tn-ease);
		background: rgba(31, 41, 55, 0.025);
	}

	.tn-drawer-menu .menu-item-has-children.is-open > .sub-menu {
		max-height: 600px;
	}

	.tn-drawer-menu .sub-menu a {
		padding: 11px 20px 11px 34px;
		font-size: 0.875rem;
		font-weight: 500;
		color: var(--tn-muted);
	}

	/* CTA buttons pinned at drawer foot */
	.tn-drawer__actions {
		padding: 18px 20px;
		border-top: 1px solid rgba(31, 41, 55, 0.08);
		display: flex;
		flex-direction: column;
		gap: 10px;
		flex-shrink: 0;
	}

	.tn-drawer__actions .tn-btn {
		width: 100%;
		text-align: center;
		padding: 13px 22px;
	}

	/* ── Semi-transparent backdrop ────────────────────────────────────── */
	.tn-drawer-backdrop {
		position: fixed;
		inset: 0;
		background: rgba(0, 0, 0, 0);
		z-index: 1000;
		pointer-events: none;
		transition: background-color 0.36s ease;
	}

	.tn-nav-open .tn-drawer-backdrop {
		background: rgba(0, 0, 0, 0.45);
		pointer-events: all;
	}

	/* Center the contact bar on small screens */
	.tn-topbar-inner {
		justify-content: center;
		flex-wrap: wrap;
		gap: 6px 18px;
		text-align: center;
	}

	.tn-topbar__contacts {
		flex-wrap: wrap;
		justify-content: center;
		gap: 6px 18px;
	}

	.tn-topbar__search {
		margin-left: 0;
	}

	/* Stop the search dropdown overflowing the viewport */
	.tn-topbar__search.is-open .tn-search-panel {
		min-width: 0;
		width: calc(100vw - 32px);
		max-width: 320px;
		right: 50%;
		transform: translateX(50%);
	}
}

/* --- Reduced motion --------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	.tn-site-header,
	.tn-site-header * {
		transition: none !important;
	}
}
