/**
 * Header / global navigation — before-live reference
 * (Latest Change/before-live-changes, "NAV (updated — single row, thinner,
 * mega menu next to logo)" + STICKY HEADER + TS-MOBILE-NAV v3 blocks).
 *
 * Desktop (>1190px): logo + buttons on row one, "Home / For Teachers / For
 * Homeschoolers" stacked under the logo; each mega panel opens from the
 * header's left edge with four labelled columns.
 * ≤1190px (#360; was 960, where the cart icon ran off screen and the labels
 * wrapped up to ~1190px): links hide, a ☰ button opens the full-screen .ts-mnav menu built by
 * assets/js/mega-menu.js from the desktop panels.
 */

/* ── Sticky wrapper ── */
.sticky-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
}
.admin-bar .sticky-header { top: 32px; }
@media (max-width: 782px) { .admin-bar .sticky-header { top: 46px; } }
@media (max-width: 600px) { .admin-bar .sticky-header { top: 0; } }

.nav {
  position: relative;
  z-index: 2;
  background: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 40px;
  border-bottom: 1px solid var(--border);
  transition: box-shadow 0.2s var(--ease-out);
}
/* Shadow only once the page is scrolled — `.is-scrolled` comes from main.js. */
.nav.is-scrolled { box-shadow: 0 0 3px rgba(0, 0, 0, 0.4); }

.nav-top-row {
  display: flex;
  align-items: center;
  gap: 40px;
  width: 100%;   /* full width like the reference — only the nav's 40px side padding, no container cap */
  position: relative;
}
.nav-logo-link { display: flex; align-items: center; text-decoration: none; }
.nav-logo-img { display: block; width: 236px; height: auto; }
.nav-logo-text { font-family: var(--ff-display); font-size: 22px; font-weight: 700; color: var(--ink); }

/* ── Top-level links: Home + mega triggers share one size and baseline ── */
.nav-links { display: flex; align-items: center; gap: 28px; }
.nav-links > a,
.nav-links .mega-trigger-btn {
  font-family: var(--ff-body);
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  font-weight: 400;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-decoration: none;
  position: relative;
  transition: color 0.2s;
}
.nav-links > a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--ink);
  transition: width 0.3s var(--ease-out);
}
.nav-links > a:hover { color: var(--ink); font-weight: 700; }
.nav-links > a:hover::after { width: 100%; }

.nav-right {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-shrink: 0;
  margin-left: auto;
}

/* ── Log In (ghost) + Become a Seller (solid): all caps, black ── */
.nav-cta-ghost,
.nav-cta-solid {
  display: inline-block;
  border-radius: 4px;
  padding: 8px 18px;
  font-family: var(--ff-body);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: normal;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}
.nav-cta-ghost { background: #fff; color: var(--ink); border: 1px solid var(--ink); }
/* #365: our outline-button rule — hover to cream, keep the black outline, never
   solid black (it sat black beside the black Become a Seller and flickered). */
.nav-cta-ghost:hover,
.nav-cta-ghost:focus-visible { background: #FAF7F2; color: var(--ink); border-color: var(--ink); transform: none; box-shadow: none; }
.nav-cta-solid { background: var(--ink); color: #fff !important; border: 1px solid var(--ink); }
.nav-cta-solid:hover { background: #bc886d; border-color: #bc886d; color: #fff !important; }
/* Become an Affiliate (DESIGN-CHANGES BR): Mascot tan, white caps; hidden on
   phones, where it is in the menu under "Sell on TeacherStore.io". */
.nav-cta-aff { display: inline-block; line-height: normal; background: #B48970; color: #fff !important; border: 1px solid #B48970; border-radius: 4px; padding: 8px 18px; font-family: var(--ff-body); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; text-decoration: none; white-space: nowrap; transition: all 0.2s var(--ease-out); }
.nav-cta-aff:hover { background: #bc886d; border-color: #bc886d; color: #fff !important; }
@media (max-width: 760px) { .nav-cta-aff { display: none !important; } }

/* ── Logged-in user avatar + dropdown ───────────────────────────────────
 * Avatar is a circular trigger that opens a small dropdown card on hover
 * (desktop) and on click (covers touch + keyboard). Click navigates to the
 * role-based primary URL (vendor dashboard for sellers, my-account for
 * customers); the dropdown surfaces all the supporting actions. */
.nav-user { position: relative; display: inline-flex; align-items: center; }
.nav-user-avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	overflow: hidden;
	background: var(--gold-light, #F6EFE1);
	border: 1.5px solid #ECE7E0;
	color: var(--brown, #8A6F4B);
	font-size: 16px;
	cursor: pointer;
	transition: border-color 0.2s, transform 0.18s, box-shadow 0.2s;
	text-decoration: none;
}
.nav-user-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nav-user-avatar i { line-height: 1; }
.nav-user-avatar:hover, .nav-user-avatar:focus-visible {
	border-color: var(--terra);
	transform: scale(1.04);
	box-shadow: 0 4px 14px rgba(196,115,90,0.18);
	outline: none;
}

/* Dropdown card — invisible by default, fades in on hover/focus/click. */
.nav-user-menu {
	position: absolute;
	top: calc(100% + 10px);
	right: 0;
	min-width: 240px;
	background: #fff;
	border: 1px solid #ECE7E0;
	border-radius: 14px;
	box-shadow: 0 12px 36px rgba(28,26,24,0.12);
	padding: 14px 0 8px;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-6px);
	pointer-events: none;
	transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
	z-index: 60;
}
/* Tiny tail pointing at the avatar so the card feels anchored. */
.nav-user-menu::before {
	content: '';
	position: absolute;
	top: -5px;
	right: 12px;
	width: 10px;
	height: 10px;
	background: #fff;
	border-top: 1px solid #ECE7E0;
	border-left: 1px solid #ECE7E0;
	transform: rotate(45deg);
}
/* Hover-bridge — keeps the gap between avatar and menu clickable so the
 * card doesn't dismiss the moment the cursor leaves the avatar. */
.nav-user-menu::after {
	content: '';
	position: absolute;
	top: -14px;
	left: 0;
	right: 0;
	height: 14px;
}
.nav-user:hover .nav-user-menu,
.nav-user:focus-within .nav-user-menu,
.nav-user.is-open .nav-user-menu {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	pointer-events: auto;
}

/* Head — name + email block. */
.nav-user-head {
	padding: 4px 18px 12px;
	border-bottom: 1px solid #F1ECE4;
	margin-bottom: 8px;
}
.nav-user-name {
	font-family: var(--ff-display, 'Playfair Display'), Georgia, serif;
	font-size: 16px;
	font-weight: 500;
	color: var(--ink);
	line-height: 1.2;
	margin-bottom: 2px;
}
.nav-user-email {
	font-size: 11px;
	color: var(--dust, #8A8276);
	letter-spacing: 0.02em;
	word-break: break-all;
}

/* Points row — bigger than the menu items so it reads as a highlight. */
.nav-user-points {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 12px 8px;
	padding: 10px 12px;
	border-radius: 10px;
	background: linear-gradient(135deg, #F5E8E2 0%, #F6EFE1 100%);
	color: var(--ink);
	text-decoration: none;
	font-family: var(--ff-body, 'Inter'), sans-serif;
	transition: transform 0.18s ease, box-shadow 0.2s ease;
}
.nav-user-points i { color: var(--terra); font-size: 18px; }
.nav-user-points-value { font-weight: 700; font-size: 14px; }
.nav-user-points-label {
	font-size: 10px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--dust);
	font-weight: 600;
}
.nav-user-points:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(196,115,90,0.15); }

/* Menu items list. */
.nav-user-list { list-style: none; padding: 0; margin: 0; }
.nav-user-list li { margin: 0; }
.nav-user-list a {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 18px;
	font-size: 13px;
	font-weight: 500;
	color: var(--ink);
	text-decoration: none;
	transition: background 0.15s, color 0.15s;
	letter-spacing: 0.01em;
}
.nav-user-list a i {
	font-size: 16px;
	color: var(--dust, #8A8276);
	transition: color 0.15s;
	width: 18px;
	text-align: center;
}
.nav-user-list a:hover {
	background: var(--cream, #FAF8F4);
	color: var(--terra);
}
.nav-user-list a:hover i { color: var(--terra); }
.nav-user-logout {
	border-top: 1px solid #F1ECE4;
	margin-top: 6px;
	padding-top: 12px !important;
}

/* Tighten the dropdown on narrow viewports so it doesn't slip off the
 * right edge of the screen. */
@media (max-width: 480px) {
	.nav-user-menu { right: -8px; min-width: 220px; }
}

/* ── Cart trigger + badge ── */
.nav-icon {
  color: var(--stone);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s;
  position: relative;
  background: none;
  border: none;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-icon:hover { color: var(--ink); }
.nav-icon i { display: inline-flex; }
.nav-cart-badge {
  position: absolute;
  top: -6px;
  right: -8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ff-body);
  transition: transform 0.2s var(--ease-out), opacity 0.2s var(--ease-out);
}
.nav-cart-badge.is-empty { opacity: 0; transform: scale(0.6); }
.nav-cart-trigger.bump .nav-cart-badge { animation: tsCartBump 0.4s var(--ease-out); }
@keyframes tsCartBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* ══════════════════════════════════════
   MEGA MENU — "For Teachers" / "For Homeschoolers" (inc/mega-menu.php)
══════════════════════════════════════ */
.mega-trigger { position: static; }
.mega-trigger-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  gap: 5px;
  cursor: pointer;
}
.mega-trigger-btn::after { content: ''; position: absolute; bottom: -4px; left: 0; width: 0; height: 1px; background: var(--ink); transition: width 0.3s var(--ease-out); }
.mega-trigger:hover .mega-trigger-btn,
.mega-trigger:focus-within .mega-trigger-btn { font-weight: 700; }
.mega-trigger:hover .mega-trigger-btn::after,
.mega-trigger:focus-within .mega-trigger-btn::after { width: 100%; }
.mega-caret { width: 9px; height: 9px; flex-shrink: 0; transition: transform 0.2s var(--ease-out); }
.mega-trigger:hover .mega-caret,
.mega-trigger:focus-within .mega-caret { transform: rotate(180deg); }

/* Both panels open from the header's left edge and span its width, so four columns fit. */
.mega-panel {
  position: absolute;
  top: calc(100% + 14px);
  left: 0;
  width: min(1280px, 100%);
  transform: translateY(6px);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 30px 36px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 32px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 200;
  transition: opacity 0.16s var(--ease-out), transform 0.16s var(--ease-out), visibility 0.16s;
}
.mega-trigger:hover .mega-panel,
.mega-trigger:focus-within .mega-panel { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0); }
/* Invisible bridge over the gap so the menu stays open while the mouse travels down to it. */
.mega-panel::before { content: ''; position: absolute; left: 0; right: 0; top: -24px; height: 24px; }
@media (max-width: 1180px) { .mega-panel { gap: 22px; padding: 26px 24px; } }

.mega-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.mega-col-head { font-size: 9px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; color: var(--stone); padding-bottom: 10px; border-bottom: 1px solid rgba(28,26,24,.08); margin-bottom: 4px; }
.mega-item { display: flex; align-items: flex-start; gap: 12px; text-decoration: none; }
.mega-item-icon { width: 34px; height: 34px; color: var(--ink); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mega-item-icon svg { width: 18px; height: 18px; }
.mega-item-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mega-item-title { font-family: var(--ff-body); font-size: 13.5px; font-weight: 700; color: var(--ink); line-height: 1.3; text-transform: none; transition: color 0.15s; }
.mega-item-desc { font-size: 10.5px; font-weight: 400; color: var(--stone); line-height: 1.3; text-transform: none; }
.mega-item:hover .mega-item-title { color: var(--fri-yay); }
/* "Coming Soon" tag + "Join the Waitlist" / "Start Selling Today" links */
.mega-item-soon { align-self: flex-start; margin-top: 4px; font-size: 9px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--stone); background: transparent; border: 1px solid rgba(28,26,24,.14); border-radius: 999px; padding: 2px 8px; line-height: 1.4; }
.mega-item-waitlist { margin-top: 4px; font-size: 11px; font-weight: 700; text-transform: none; letter-spacing: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.mega-item:hover .mega-item-waitlist { color: #bc886d; }
/* Paused features: look like every other item, but can't be clicked (inc/feature-flags.php). */
.mega-item[data-coming-soon] { pointer-events: none; cursor: default; }

/* ── Desktop: links stacked under the logo, buttons centred on the logo row ── */
@media (min-width: 1191px) {
  .sticky-header .nav { padding-top: 24px; padding-bottom: 12px; }
  .sticky-header .nav-top-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    /* The links row spans the whole header (#360): in the logo's column alone
       it was squeezed by the buttons beside the logo, so its labels wrapped
       near 1191px (and much wider when signed in, with the avatar menu). */
    grid-template-areas: "logo . right" "links links links";
    row-gap: 12px;
    column-gap: 40px;
    align-items: center;
  }
  .sticky-header .nav-logo-link { grid-area: logo; justify-self: start; }
  .sticky-header .nav-links { grid-area: links; justify-self: start; }
  .sticky-header .nav-right { grid-area: right; }
}

/* ── Tablet & phone: links collapse into the ☰ menu ── */
@media (max-width: 1190px) {
  .sticky-header .nav-links { display: none; }
  .sticky-header .nav-top-row { justify-content: space-between; gap: 16px; }
  .sticky-header .nav-logo-link { margin-right: auto; }
  .nav { padding: 14px 20px; }
}
/* Phones: Log In and Become a Seller side by side squeezed the logo, so the
   header keeps only Become a Seller (hidden for vendors) + the avatar/cart;
   logged-out visitors find "Log In" at the top of the ☰ menu instead. */
@media (max-width: 600px) {
  .sticky-header .nav { padding: 10px 16px; }
  .sticky-header .nav-top-row { gap: 6px; }
  .sticky-header .nav-logo-img { width: 132px; }
  /* Log In / Log Out and Become a Seller stay next to the logo and menu
     button on a phone, just smaller (#224, DESIGN-CHANGES BR). */
  .sticky-header .nav-right { gap: 6px; }
  .sticky-header .nav-cta-ghost,
  .sticky-header .nav-cta-solid { padding: 7px 8px; font-size: 9.5px; letter-spacing: 0.03em; white-space: nowrap; }
}

/* ══════════════════════════════════════
   TS-MOBILE-NAV — phone + tablet menu (≤1190px, #360), built by assets/js/mega-menu.js
══════════════════════════════════════ */
.ts-mnav-btn { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; margin-left: -8px; border: 0; background: none; color: var(--ink); cursor: pointer; border-radius: 8px; flex-shrink: 0; }
.ts-mnav-btn:hover { background: var(--cream); }
.ts-mnav-btn svg { width: 22px; height: 22px; }
.ts-mnav { position: fixed; inset: 0; z-index: 100000; background: var(--white); display: flex; flex-direction: column; transform: translateX(-100%); transition: transform .22s var(--ease-out, ease); visibility: hidden; }
.ts-mnav.is-open { transform: none; visibility: visible; }
.ts-mnav-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.ts-mnav-head img { width: 128px; height: auto; display: block; }
.ts-mnav-close { width: 44px; height: 44px; margin-right: -10px; border: 0; background: none; color: var(--ink); font-size: 22px; cursor: pointer; border-radius: 8px; }
.ts-mnav-close:hover { background: var(--cream); }
.ts-mnav-body { flex: 1; overflow-y: auto; padding: 4px 16px 32px; -webkit-overflow-scrolling: touch; }
.ts-mnav-home { display: flex; align-items: center; min-height: 52px; font-size: 15px; font-weight: 700; color: var(--ink); text-decoration: none; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); }
.ts-mnav-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 16px 0 8px; background: var(--cream); border: 1px solid var(--border); border-radius: 999px; }
.ts-mnav-seg button { min-height: 44px; border: 0; border-radius: 999px; background: none; font-family: var(--ff-body); font-size: 15px; font-weight: 600; color: var(--ink); cursor: pointer; }
.ts-mnav-seg button.is-on { background: var(--ink); color: var(--white); }
.ts-mnav-sec { border-bottom: 1px solid var(--border); }
.ts-mnav-sec-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; min-height: 52px; border: 0; background: none; padding: 0; font-family: var(--ff-body); font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink); cursor: pointer; text-align: left; }
.ts-mnav-sec-btn svg { width: 16px; height: 16px; transition: transform .2s; flex-shrink: 0; }
.ts-mnav-sec.is-open .ts-mnav-sec-btn svg { transform: rotate(180deg); }
.ts-mnav-items { display: none; padding: 0 0 10px; }
.ts-mnav-sec.is-open .ts-mnav-items { display: block; }
.ts-mnav-item { display: block; min-height: 44px; padding: 11px 0 11px 12px; color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 600; line-height: 1.35; border-left: 2px solid var(--border); }
.ts-mnav-item:hover, .ts-mnav-item:active { border-left-color: var(--ink); background: var(--cream); }
.ts-mnav-item .mega-item-soon, .ts-mnav-item .mega-item-waitlist { display: block; width: fit-content; margin-top: 5px; }
.ts-mnav-item.is-soon { cursor: default; }
.ts-mnav-item.is-soon:hover, .ts-mnav-item.is-soon:active { border-left-color: var(--border); background: none; }
.ts-mnav-panel[hidden] { display: none; }
@media (max-width: 1190px) { .sticky-header .ts-mnav-btn { display: inline-flex; } }
@media (max-width: 600px) { .sticky-header .ts-mnav-btn { width: 36px; margin-left: -6px; } }
body.ts-mnav-lock { overflow: hidden; }
