/* /assets/css/header.css */
/* compact, clean header styles that keep nav small & mobile panel left-aligned under close button */

/* header-specific tokens */
:root{
  --nav-bg: #000;
  --nav-text: #ffffff;
  --nav-height: 56px;
  --nav-gap: 10px;
  --nav-logo-size: 34px;
  --menu-width-mobile: 320px; /* mobile menu width */
}

/* Topnav wrapper */
.topnav {
  background: var(--nav-bg);
  color: var(--nav-text);
  position: sticky;
  top: 0;
  z-index: 120;
  box-shadow: 0 1px 6px rgba(2,6,23,0.04);
}

/* Align inner container */
.topnav .nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--nav-gap);
  padding: 6px 14px;
  height: var(--nav-height);
  max-width: var(--max-width, 1100px);
  margin: 0 auto;
}

/* Brand area */
.topnav .brand a {
  color: var(--nav-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
}
.topnav .logo {
  display:inline-grid;
  place-items:center;
  width:var(--nav-logo-size);
  height:var(--nav-logo-size);
  background:#fff;color:#000;border-radius:6px;font-weight:700;
  font-size:13px;
}

/* Nav links (desktop) */
.topnav .nav-links {
  display:flex;
  align-items:center;
  gap:14px;
}
.topnav .nav-links a {
  color: var(--nav-text);
  text-decoration: none;
  font-weight:600;
  font-size:14px;      /* ensure small desktop size */
  padding:6px 8px;
  border-radius:8px;
}
.topnav .nav-links a:hover { background: rgba(255,255,255,0.06); outline: none; }

/* Hamburger button (mobile) */
.nav-toggle {
  display: none;
  background: transparent;
  border: none;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--nav-text);
  z-index: 140;               /* make sure it's clickable above other content */
}
.nav-toggle:focus { outline: 2px solid rgba(255,255,255,0.12); outline-offset:2px; }

/* Hamburger icon */
.hamburger {
  display:inline-block;
  width:18px;
  height:2px;
  background:currentColor;
  position:relative;
  border-radius:2px;
}
.hamburger::before,
.hamburger::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius:2px;
}
.hamburger::before { top:-5px; }
.hamburger::after  { top:5px; }

/* Mobile panel (hidden by default) */
#primary-menu {
  display:flex;
  gap:10px;
  align-items:center;
  position: absolute;
  top: calc(var(--nav-height) + 8px);
  right: 14px;
  min-width: 220px;
  background: transparent;
  color: #fff;
  padding: 0;
  border-radius: 10px;
  pointer-events: none; /* prevents accidental clicks when closed */
}

/* Hide when aria-hidden true */
#primary-menu[aria-hidden="true"] { display: none; pointer-events: none; }

/* Open panel (mobile) */
#primary-menu.open {
  display: block;
  pointer-events: auto;
  position: absolute;
  top: calc(var(--nav-height) + 10px);
  right: 16px;               /* keep panel visually at the right edge */
  width: var(--menu-width-mobile);
  max-width: calc(100vw - 32px);
  background: linear-gradient(180deg, rgba(9,20,27,0.98) 0%, rgba(6,14,18,0.98) 100%);
  color: #fff;
  padding: 18px 18px 28px;
  border-radius: 8px;
  box-shadow: 0 20px 40px rgba(2,6,23,0.45);
  z-index: 200;
  -webkit-tap-highlight-color: none; /* avoid flash on tap */
  will-change: transform, opacity;
  transform-origin: right top;
  transition: transform 180ms ease, opacity 180ms ease;
}

/* Panel close button (placed at top-left inside panel) */
#primary-menu .menu-close {
  background: transparent;
  color: #fff;
  border: none;
  font-size: 24px;
  line-height: 1;
  padding: 6px;
  margin: -6px 0 12px -6px; /* pull slightly left to sit near panel edge */
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#primary-menu .menu-close:focus { outline: none; box-shadow: none; }

/* Panel links: left aligned under the close button */
#primary-menu a {
  display: block;
  width: 100%;
  text-align: left;     /* left aligned as requested */
  padding: 16px 18px;
  margin: 8px 0;
  font-size: 20px;      /* comfortable size for tap */
  font-weight: 700;
  color: #fff;
  border-radius: 8px;
  background: transparent;
  transition: background 140ms ease, transform 120ms ease;
}
#primary-menu a:hover {
  background: rgba(255,255,255,0.04);   /* subtle hover */
  transform: translateY(-1px);
}

/* Remove default focused/active background flash (mobile) */
#primary-menu a,
#primary-menu button,
.nav-toggle,
.hamburger {
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
}

/* Prevent the "first link highlighted" effect: make focus styling subtle */
#primary-menu a:focus {
  outline: none;
  background: rgba(255,255,255,0.03);
}

/* Desktop: keep primary menu inline and small */
@media (min-width: 561px) {
  .nav-toggle { display: none; }
  #primary-menu {
    display: flex !important;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 18px;
    padding: 0;
    background: transparent;
    box-shadow: none;
    pointer-events: auto;
  }
  #primary-menu a {
    padding: 6px 10px;
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    background: transparent;
  }
  /* hide the close button on desktop */
  #primary-menu .menu-close { display: none; }
}

/* Mobile breakpoint: show hamburger and hide inline links */
@media (max-width: 560px) {
  .topnav .nav-links { display: none; }  /* fallback if any other rule shows it */
  .nav-toggle { display: inline-flex; align-items:center; justify-content:center; }
  /* ensure desktop nav is not visible behind the panel */
  #primary-menu[aria-hidden="true"] { display: none; }
}

/* ===== tap-highlight & flash safety for header / nav (add at end of header.css) ===== */

/* Apply to the interactive header elements that were flashing */
.topnav,
.topnav .brand a,
.topnav .logo,
.nav-toggle,
#primary-menu,
#primary-menu a,
#primary-menu button,
.topnav .nav-links a,
.topnav .nav-links button {
  /* webkit fallback color & newer keyword fallback */
  -webkit-tap-highlight-color: transparent; /* common approach */
  -webkit-tap-highlight-color: none;        /* some browsers accept 'none' */
  tap-highlight-color: transparent;

  /* avoid accidental text selection on fast taps */
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;

  /* make sure we don't block pointer events (we still want clicks) */
  pointer-events: auto;
}

/* Keep keyboard & accessibility focus visible for keyboard users */
.topnav .brand a:focus-visible,
.nav-toggle:focus-visible,
#primary-menu a:focus-visible,
#primary-menu button:focus-visible,
.topnav .nav-links a:focus-visible {
  outline: 3px solid rgba(37,99,235,0.18);
  outline-offset: 3px;
}

/* Defensive: remove background glow applied by UA on active states */
.topnav .brand a:active,
.nav-toggle:active,
#primary-menu a:active,
#primary-menu button:active {
  background: transparent !important;
  box-shadow: none !important;
}

/* Keep mobile panel stacking correct (brand above panel) */
.topnav .brand { position: relative; z-index: 350; }
#primary-menu.open { z-index: 300; }

/* Optional: if you still see a flash on the brand square, try forcing its background */
.topnav .logo { background: #fff !important; color: #000 !important; }
