/* =========================================================
   KEYPLO — Global header
   Uses only the STEP 1 design tokens.
   Breakpoints: mobile < 768 · tablet 768–1023 · desktop >= 1024
   ========================================================= */

.kp-header { position: relative; z-index: var(--kp-z-header); }
.kp-icon { width: 20px; height: 20px; flex: none; }

/* ---------- Shared icon button ---------- */
.kp-iconbtn {
	display: inline-flex; align-items: center; justify-content: center;
	width: var(--kp-control-h); height: var(--kp-control-h);
	padding: 0; border: 1px solid var(--kp-border); border-radius: var(--kp-radius-sm);
	background: var(--kp-surface); color: var(--kp-text); cursor: pointer;
	transition: border-color var(--kp-dur) var(--kp-ease), background-color var(--kp-dur) var(--kp-ease);
}
.kp-iconbtn:hover { border-color: var(--kp-border-strong); background: var(--kp-surface-2); }
.kp-iconbtn:focus-visible { outline: none; box-shadow: var(--kp-focus-ring); }
.kp-iconbtn .kp-icon { width: 22px; height: 22px; }

/* =========================================================
   1. Trust bar
   ========================================================= */
.kp-topbar {
	background: var(--kp-bg-elevated);
	border-bottom: 1px solid var(--kp-border-subtle);
	font-size: var(--kp-text-xs);
}
.kp-topbar__inner {
	min-height: 44px;
	display: flex; align-items: center; justify-content: space-between; gap: var(--kp-space-6);
}
.kp-topbar__features {
	display: flex; align-items: center; gap: var(--kp-space-8);
	margin: 0; padding: 0; list-style: none; min-width: 0;
}
.kp-feature { display: flex; align-items: center; gap: var(--kp-space-2); min-width: 0; }
.kp-feature__icon { width: 20px; height: 20px; color: var(--kp-orange); }
.kp-feature__text { display: flex; flex-direction: column; line-height: 1.2; }
.kp-feature__text strong { color: var(--kp-text); font-size: var(--kp-text-xs); font-weight: var(--kp-weight-bold); white-space: nowrap; }
.kp-feature__text small  { color: var(--kp-text-muted); font-size: 11px; white-space: nowrap; }

.kp-topbar__meta { display: flex; align-items: center; gap: var(--kp-space-5); flex: none; }
.kp-topbar__operator { color: var(--kp-text-2); white-space: nowrap; }
.kp-topbar__links { display: flex; align-items: center; gap: var(--kp-space-4); }
.kp-topbar__links a { color: var(--kp-text-2); font-weight: var(--kp-weight-medium); }
.kp-topbar__links a:hover { color: var(--kp-text); }
.kp-topbar__link-pending { color: var(--kp-text-muted); cursor: default; }

/* ---------- Currency dropdown (desktop) ---------- */
.kp-currency { position: relative; }
.kp-currency__toggle {
	display: inline-flex; align-items: center; gap: var(--kp-space-1);
	min-height: 32px; padding: 0 var(--kp-space-2) 0 var(--kp-space-3);
	border: 1px solid var(--kp-border); border-radius: var(--kp-radius-sm);
	background: var(--kp-surface); color: var(--kp-text);
	font-size: var(--kp-text-xs); font-weight: var(--kp-weight-bold); letter-spacing: 0.02em;
	cursor: pointer;
	transition: border-color var(--kp-dur) var(--kp-ease);
}
.kp-currency__toggle:hover, .kp-currency__toggle[aria-expanded="true"] { border-color: var(--kp-orange-line); }
.kp-currency__toggle:focus-visible { outline: none; box-shadow: var(--kp-focus-ring); }
.kp-currency__chevron { width: 16px; height: 16px; color: var(--kp-text-muted); transition: transform var(--kp-dur) var(--kp-ease); }
.kp-currency__toggle[aria-expanded="true"] .kp-currency__chevron { transform: rotate(180deg); }

.kp-currency__panel {
	position: absolute; right: 0; top: calc(100% + 8px); z-index: var(--kp-z-dropdown);
	width: 264px;
	padding: var(--kp-space-2);
	background: var(--kp-surface);
	border: 1px solid var(--kp-border-strong);
	border-radius: var(--kp-radius-md);
	box-shadow: var(--kp-shadow-lg);
}
.kp-currency__panel[hidden] { display: none; }
.kp-currency__title {
	margin: 0; padding: var(--kp-space-2) var(--kp-space-2) var(--kp-space-2);
	color: var(--kp-text-muted); font-size: 11px; font-weight: var(--kp-weight-bold);
	letter-spacing: var(--kp-tracking-label); text-transform: uppercase;
}
.kp-currency__list {
	max-height: 300px; overflow-y: auto; overscroll-behavior: contain;
	margin: 0; padding: 0; list-style: none; outline: none;
	scrollbar-width: thin; scrollbar-color: var(--kp-border-strong) transparent;
}
.kp-currency__option {
	display: grid; grid-template-columns: 44px 1fr 16px; align-items: center; gap: var(--kp-space-2);
	min-height: 40px; padding: 0 var(--kp-space-2);
	border-radius: var(--kp-radius-sm);
	color: var(--kp-text-2); font-size: var(--kp-text-sm); cursor: pointer;
}
.kp-currency__opt-code { color: var(--kp-text); font-weight: var(--kp-weight-bold); font-size: var(--kp-text-sm); }
.kp-currency__opt-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kp-currency__check { width: 16px; height: 16px; color: var(--kp-orange); visibility: hidden; }
.kp-currency__option:hover, .kp-currency__option.is-focused { background: var(--kp-surface-2); }
.kp-currency__option[aria-selected="true"] { background: var(--kp-orange-soft); }
.kp-currency__option[aria-selected="true"] .kp-currency__opt-code { color: var(--kp-orange); }
.kp-currency__option[aria-selected="true"] .kp-currency__check { visibility: visible; }
.kp-currency__note {
	margin: var(--kp-space-2) 0 0; padding: var(--kp-space-2) var(--kp-space-2) var(--kp-space-1);
	border-top: 1px solid var(--kp-border);
	color: var(--kp-text-muted); font-size: 11px; line-height: 1.4;
}

/* =========================================================
   2. Main header (sticky together with the nav row)
   ========================================================= */
.kp-header__sticky {
	position: sticky; top: var(--wp-admin--admin-bar--height, 0px); z-index: var(--kp-z-header);
	background: var(--kp-header-bg);
	-webkit-backdrop-filter: saturate(140%) blur(14px);
	backdrop-filter: saturate(140%) blur(14px);
}
.kp-mainbar { border-bottom: 1px solid var(--kp-border-subtle); }
.kp-mainbar__inner {
	min-height: var(--kp-header-h);
	display: flex; align-items: center; gap: var(--kp-space-6);
}
.kp-menu-toggle { display: none; }

/* Logo */
.kp-mainbar__logo { flex: none; display: flex; align-items: center; }
.kp-logo { display: inline-flex; align-items: center; border-radius: var(--kp-radius-sm); }
.kp-logo:focus-visible { outline: 2px solid var(--kp-orange); outline-offset: 4px; }
.kp-logo__img { display: block; width: auto; height: 56px; max-width: none; }
.kp-logo--text { font-family: var(--kp-font-display); font-weight: var(--kp-weight-black); font-size: 1.75rem; color: var(--kp-text); }

/* Search */
.kp-search {
	flex: 1 1 auto; min-width: 0; max-width: 860px; margin-inline: auto;
	display: flex; align-items: center;
	height: var(--kp-control-h-lg);
	padding: 4px 4px 4px var(--kp-space-4);
	background: var(--kp-surface);
	border: 1px solid var(--kp-border-strong);
	border-radius: var(--kp-radius-md);
	transition: border-color var(--kp-dur) var(--kp-ease), box-shadow var(--kp-dur) var(--kp-ease);
}
.kp-search:focus-within { border-color: var(--kp-orange-line); box-shadow: var(--kp-focus-ring); }
.kp-search__icon { width: 20px; height: 20px; color: var(--kp-text-muted); }
.kp-search__input {
	flex: 1 1 auto; min-width: 0; height: 100%;
	margin: 0; padding: 0 var(--kp-space-3);
	background: transparent; border: 0; outline: 0;
	color: var(--kp-text); font-size: var(--kp-text-sm);
	-webkit-appearance: none; appearance: none;
}
.kp-search__input::placeholder { color: var(--kp-text-muted); opacity: 1; }
.kp-search__input::-webkit-search-cancel-button { filter: invert(0.6); }
.kp-search__divider { width: 1px; height: 26px; background: var(--kp-border-strong); flex: none; }
.kp-search__cat { position: relative; flex: none; display: flex; align-items: center; }
.kp-search__select {
	height: 42px; min-width: 168px; max-width: 200px;
	padding: 0 36px 0 var(--kp-space-4);
	background: transparent; border: 0; outline: 0;
	color: var(--kp-text-2); font-size: var(--kp-text-sm); font-weight: var(--kp-weight-medium);
	-webkit-appearance: none; appearance: none; cursor: pointer;
	border-radius: var(--kp-radius-sm);
}
.kp-search__select:focus-visible { box-shadow: var(--kp-focus-ring); }
.kp-search__select option { background: var(--kp-surface-2); color: var(--kp-text); }
.kp-search__chevron { position: absolute; right: 10px; width: 16px; height: 16px; color: var(--kp-text-muted); pointer-events: none; }
.kp-search__submit {
	flex: none; display: inline-flex; align-items: center; justify-content: center; gap: var(--kp-space-2);
	height: 42px; padding: 0 var(--kp-space-6);
	border: 0; border-radius: var(--kp-radius-sm);
	background: var(--kp-orange); color: var(--kp-on-orange);
	font-size: var(--kp-text-sm); font-weight: var(--kp-weight-heavy);
	cursor: pointer;
	transition: background-color var(--kp-dur) var(--kp-ease), box-shadow var(--kp-dur) var(--kp-ease);
}
.kp-search__submit .kp-icon { width: 18px; height: 18px; }
.kp-search__submit:hover { background: var(--kp-orange-hover); box-shadow: var(--kp-glow-sm); }
.kp-search__submit:active { background: var(--kp-orange-active); }
.kp-search__submit:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--kp-surface), 0 0 0 5px var(--kp-orange); }

/* Account + cart */
.kp-actions { flex: none; display: flex; align-items: center; gap: var(--kp-space-2); }
.kp-action {
	display: flex; align-items: center; gap: var(--kp-space-3);
	min-height: var(--kp-control-h); padding: 0 var(--kp-space-3);
	border-radius: var(--kp-radius-sm);
	color: var(--kp-text);
	transition: background-color var(--kp-dur) var(--kp-ease);
}
.kp-action:hover { background: var(--kp-surface); color: var(--kp-text); }
.kp-action:focus-visible { outline: none; box-shadow: var(--kp-focus-ring); }
.kp-action__icon {
	position: relative; display: inline-flex; align-items: center; justify-content: center;
	width: 40px; height: 40px; border-radius: 50%;
	border: 1px solid var(--kp-border-strong); color: var(--kp-text);
}
.kp-action__icon .kp-icon { width: 20px; height: 20px; }
.kp-action--cart .kp-action__icon { border-color: transparent; width: 32px; }
.kp-action--cart .kp-action__icon .kp-icon { width: 26px; height: 26px; }
.kp-action__text { display: flex; flex-direction: column; line-height: 1.2; }
.kp-action__text strong { font-size: var(--kp-text-sm); font-weight: var(--kp-weight-bold); }
.kp-action__text small  { color: var(--kp-text-muted); font-size: var(--kp-text-xs); white-space: nowrap; }
.kp-action:hover .kp-action__text small { color: var(--kp-text-2); }

.kp-cart-count {
	position: absolute; top: -6px; right: -8px;
	min-width: 20px; height: 20px; padding: 0 5px;
	display: inline-flex; align-items: center; justify-content: center;
	border-radius: var(--kp-radius-pill);
	background: var(--kp-orange); color: var(--kp-on-orange);
	font-size: 11px; font-weight: var(--kp-weight-heavy); line-height: 1;
	box-shadow: 0 0 0 2px var(--kp-bg);
}
.kp-cart-count[data-count="0"] { background: var(--kp-surface-3); color: var(--kp-text-2); }

/* =========================================================
   3. Navigation
   ========================================================= */
.kp-navbar {
	position: relative;
	border-bottom: 1px solid var(--kp-border);
}
.kp-navbar::after { /* subtle orange accent line */
	content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
	background: linear-gradient(90deg, transparent 0%, var(--kp-orange-line) 20%, transparent 50%, var(--kp-orange-line) 80%, transparent 100%);
	opacity: 0.55; pointer-events: none;
}
.kp-nav { display: flex; align-items: center; gap: var(--kp-space-2); margin: 0; padding: 0; list-style: none; }
.kp-nav__link {
	position: relative;
	display: flex; align-items: center; gap: var(--kp-space-2);
	min-height: 48px; padding: 0 var(--kp-space-4);
	color: var(--kp-text); font-size: var(--kp-text-sm); font-weight: var(--kp-weight-semi);
	white-space: nowrap;
	transition: color var(--kp-dur) var(--kp-ease), background-color var(--kp-dur) var(--kp-ease);
}
.kp-nav__icon { width: 20px; height: 20px; color: var(--kp-orange); }
.kp-nav__link:hover { color: var(--kp-text); background: var(--kp-orange-soft); }
.kp-nav__link:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--kp-orange); border-radius: var(--kp-radius-sm); }
.kp-nav__link.is-active { color: var(--kp-orange); background: linear-gradient(180deg, transparent, var(--kp-orange-soft)); }
.kp-nav__link.is-active::after {
	content: ""; position: absolute; left: var(--kp-space-3); right: var(--kp-space-3); bottom: 0; height: 2px;
	background: var(--kp-orange); border-radius: 2px; box-shadow: var(--kp-glow-sm);
}

/* =========================================================
   Mobile drawer
   ========================================================= */
.kp-drawer { position: fixed; inset: 0; z-index: var(--kp-z-modal); }
.kp-drawer[hidden] { display: none; }
.kp-drawer__overlay { position: absolute; inset: 0; background: var(--kp-overlay); opacity: 0; transition: opacity var(--kp-dur-slow) var(--kp-ease); }
.kp-drawer__panel {
	position: absolute; top: 0; left: 0; bottom: 0;
	width: min(340px, 88vw);
	display: flex; flex-direction: column; gap: var(--kp-space-2);
	padding: var(--kp-space-4);
	overflow-y: auto; overscroll-behavior: contain;
	background: var(--kp-bg-elevated);
	border-right: 1px solid var(--kp-border);
	box-shadow: var(--kp-shadow-lg);
	transform: translateX(-100%);
	transition: transform var(--kp-dur-slow) var(--kp-ease);
}
.kp-drawer.is-open .kp-drawer__overlay { opacity: 1; }
.kp-drawer.is-open .kp-drawer__panel { transform: translateX(0); }
.kp-drawer__head { display: flex; align-items: center; justify-content: space-between; padding-bottom: var(--kp-space-2); border-bottom: 1px solid var(--kp-border); }
.kp-drawer__title { font-family: var(--kp-font-display); font-weight: var(--kp-weight-heavy); font-size: var(--kp-text-lg); }
.kp-drawer__nav { margin: 0; padding: var(--kp-space-2) 0; list-style: none; }
.kp-drawer__nav .kp-nav__link { min-height: 48px; border-radius: var(--kp-radius-sm); padding: 0 var(--kp-space-3); font-size: var(--kp-text-base); }
.kp-drawer__nav .kp-nav__link.is-active::after { left: 0; right: auto; top: 10px; bottom: 10px; width: 3px; height: auto; }
.kp-drawer__section { padding: var(--kp-space-4) 0; border-top: 1px solid var(--kp-border); }
.kp-drawer__account { display: flex; align-items: center; gap: var(--kp-space-3); min-height: 44px; color: var(--kp-text); font-weight: var(--kp-weight-semi); }
.kp-drawer__account .kp-icon { color: var(--kp-orange); }
.kp-drawer__company { display: flex; flex-wrap: wrap; gap: var(--kp-space-2) var(--kp-space-4); }
.kp-drawer__company a { color: var(--kp-text-2); font-size: var(--kp-text-sm); min-height: 32px; display: inline-flex; align-items: center; }
.kp-drawer__operator { width: 100%; margin: 0; color: var(--kp-text-muted); font-size: var(--kp-text-xs); }
html.kp-no-scroll, html.kp-no-scroll body { overflow: hidden; }

/* =========================================================
   Responsive
   ========================================================= */

/* Large desktop tweaks */
@media (max-width: 1279px) {
	.kp-topbar__operator { display: none; }
	.kp-nav__link { padding: 0 var(--kp-space-3); }
	.kp-search__select { min-width: 140px; }
}

/* Tablet + mobile: hamburger, drawer navigation */
@media (max-width: 1023px) {
	.kp-menu-toggle { display: inline-flex; flex: none; }
	.kp-navbar { display: none; }
	.kp-mainbar__inner { gap: var(--kp-space-3); }
	.kp-logo__img { height: 44px; }
	.kp-action__text { display: none; }
	.kp-action { padding: 0 var(--kp-space-2); }
	.kp-topbar__links { display: none; }
	.kp-topbar__features { gap: var(--kp-space-6); }
	.kp-feature__text small { display: none; }
	.kp-search__select { min-width: 0; width: 146px; padding-left: var(--kp-space-3); padding-right: 32px; }
	.kp-search__submit { width: 44px; padding: 0; }
	.kp-search__submit-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* Mobile: search moves to its own row, trust bar hidden */
@media (max-width: 767px) {
	.kp-topbar { display: none; }
	.kp-mainbar__inner {
		display: grid;
		grid-template-columns: auto 1fr auto;
		grid-template-areas:
			"menu logo actions"
			"search search search";
		row-gap: var(--kp-space-3);
		padding-block: var(--kp-space-3);
		min-height: 0;
	}
	.kp-menu-toggle { grid-area: menu; }
	.kp-mainbar__logo { grid-area: logo; justify-content: center; min-width: 0; }
	.kp-logo__img { height: 38px; }
	.kp-actions { grid-area: actions; gap: 0; }
	.kp-action__icon { width: 40px; height: 40px; }
	.kp-search { grid-area: search; max-width: none; width: 100%; height: 48px; }
	.kp-search__divider, .kp-search__cat { display: none; }
	.kp-search__input { font-size: var(--kp-text-base); } /* 16px: no iOS zoom */
	.kp-search__submit { width: 44px; padding: 0; height: 40px; }
	.kp-search__submit-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

@media (max-width: 359px) {
	.kp-logo__img { height: 32px; }
	.kp-action--account { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.kp-drawer__panel, .kp-drawer__overlay { transition: none; }
}
