/* ============================================================
   theme/css/header-base.css
   Shared by BOTH theme/header.php (tools) and theme/blog-header.php
   (blog). Section-specific nav styling (the tools mega-menu, or any
   future blog-only styling) lives in header.css / blog-header.css,
   loaded ON TOP of this file so nothing here is duplicated per-section.
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
}

/* ── Skip link (accessibility) ─────────────────────────────── */
.skip-link {
  position: absolute;
  top: -60px;
  left: 12px;
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 0 0 10px 10px;
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  z-index: 2000;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 0;
  outline: 2px solid #f4a261;
  outline-offset: 2px;
}

/* ── Consistent keyboard focus ──────────────────────────────── */
.nav-menu > li > a:focus-visible,
.submenu a:focus-visible,
.logo a:focus-visible,
.nav-toggle:focus-visible,
.search-toggle:focus-visible,
.search-head-submit:focus-visible,
.breadcrumb a:focus-visible {
  outline: 2px solid #f4a261;
  outline-offset: 2px;
}
#main-content:focus {
  outline: none;
}

/* ── Sticky header bar ─────────────────────────────────────── */
.header {
  background: linear-gradient(135deg, rgba(39,76,119,0.95), rgba(96,150,186,0.95));
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  color: #fff;
  padding: 0;
  box-shadow: 0 4px 30px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  width: 100%;
  max-width: 100%;
  left: 0;
  right: 0;
  z-index: 1000;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  transition: all 0.3s ease;
}
.header.scrolled {
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  background: linear-gradient(135deg, rgba(39,76,119,0.98), rgba(96,150,186,0.98));
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1320px;
  margin: 0;
  padding: 0 20px;
  height: 64px;
}

/* ── Brand wordmark (original) ─────────────────────────────── */
.logo { display: flex; align-items: center; gap: 10px; }
.logo a {
  color: #fff;
  text-decoration: none;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
  position: relative;
}
.logo a::before {
  content: "𓄿";
  font-size: 1.4rem;
  opacity: 0.9;
  transition: transform 0.3s ease;
}
.logo a:hover { color: #a3cef1; }
.logo a:hover::before { transform: rotate(-5deg) scale(1.1); }

/* ── Primary nav ────────────────────────────────────────────── */
.nav-menu {
  list-style: none;
  display: flex;
  gap: 0.25rem;
  align-items: center;
  margin: 0;
  padding: 0;
}
.nav-menu > li { position: relative; }
.nav-menu > li > a {
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  padding: 0.5rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.25s ease;
  border-radius: 8px;
  white-space: nowrap;
}
.nav-menu > li > a:hover,
.nav-menu > li > a:focus {
  background: rgba(255,255,255,0.12);
  color: #fff;
  transform: translateY(-1px);
}
.nav-menu > li > a.is-active {
  background: rgba(255,255,255,0.16);
  color: #fff;
}
.nav-menu > li > a .nav-chevron {
  font-size: 0.7rem;
  opacity: 0.6;
  transition: transform 0.25s ease;
}
.nav-menu > li:hover > a .nav-chevron { transform: rotate(180deg); opacity: 1; }

/* ── Simple dropdown panel (used for "Popular / PDF / Audio…" on
   tools, and "Tools / Categories" on blog) ─────────────────── */
.dropdown { position: relative; }
.submenu {
  display: block;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(255,255,255,0.98);
  list-style: none;
  padding: 0.5rem;
  min-width: 220px;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 4px 12px rgba(0,0,0,0.08);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  border: 1px solid rgba(0,0,0,0.06);
}
.dropdown:hover .submenu {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.submenu::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: rgba(255,255,255,0.98);
  border-top: 1px solid rgba(0,0,0,0.06);
  border-left: 1px solid rgba(0,0,0,0.06);
}
.submenu li { margin: 2px 0; }
.submenu a {
  padding: 0.65rem 0.9rem;
  color: #334155;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  text-decoration: none;
}
.submenu a:hover {
  background: linear-gradient(135deg, rgba(39,76,119,0.08), rgba(96,150,186,0.08));
  color: #274c77;
  transform: translateX(3px);
}
.submenu a .sub-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(39,76,119,0.08);
  color: #274c77;
  font-size: 0.7rem;
}
.submenu .submenu-footer {
  margin-top: 0.35rem;
  padding-top: 0.5rem;
  border-top: 1px solid #f1f5f9;
  text-align: center;
}
.submenu .submenu-footer a {
  color: #274c77;
  font-size: 0.82rem;
  font-weight: 600;
  justify-content: center;
}

/* ── Header search ──────────────────────────────────────────── */
.header-search {
  position: relative;
  display: flex;
  align-items: center;
  margin-left: 0.5rem;
  height: 40px;
}
.search-toggle-checkbox { display: none; }
.search-toggle {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255,255,255,0.85);
  font-size: 1rem;
  transition: all 0.3s ease;
  border-radius: 10px;
  z-index: 100;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
}
.search-toggle:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
  transform: scale(1.05);
}
.search-form-container {
  position: absolute;
  right: 0;
  top: calc(100% + 12px);
  width: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px);
  transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 99;
  background: rgba(255,255,255,0.98);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  border: 1px solid rgba(0,0,0,0.06);
}
.search-form {
  display: flex;
  padding: 12px;
  width: 340px;
  gap: 8px;
}
.search-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  outline: none;
  font-size: 0.9rem;
  background: #f8fafc;
  color: #1e293b;
  font-family: inherit;
  transition: all 0.2s ease;
}
.search-input:focus {
  border-color: #274c77;
  box-shadow: 0 0 0 3px rgba(39,76,119,0.1);
  background: #fff;
}
.search-input::placeholder { color: #94a3b8; }
.search-head-submit {
  background: linear-gradient(135deg, #274c77, #6096ba);
  color: white;
  border: none;
  padding: 0 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}
.search-head-submit:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(39,76,119,0.3);
}
.search-toggle-checkbox:checked ~ .search-form-container {
  width: 340px;
  opacity: 1;
  transform: translateY(0);
}

/* ── Mobile hamburger ───────────────────────────────────────── */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  transition: all 0.3s ease;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  align-items: center;
  justify-content: center;
}
.nav-toggle:hover { background: rgba(255,255,255,0.12); }

.hamburger {
  display: block;
  width: 22px;
  height: 2.5px;
  background-color: #fff;
  position: relative;
  border-radius: 2px;
  transition: all 0.3s ease;
}
.hamburger::before,
.hamburger::after {
  content: '';
  width: 22px;
  height: 2.5px;
  background-color: #fff;
  position: absolute;
  left: 0;
  border-radius: 2px;
  transition: all 0.3s ease;
}
.hamburger::before { top: -7px; }
.hamburger::after { top: 7px; }
.nav-toggle.active .hamburger { background: transparent; }
.nav-toggle.active .hamburger::before { top: 0; transform: rotate(45deg); }
.nav-toggle.active .hamburger::after { top: 0; transform: rotate(-45deg); }

/* ── Breadcrumb trail ───────────────────────────────────────── */
.breadcrumb {
  margin: 14px 0 10px;
  position: relative;
  font-size: 14px;
  line-height: 1.4;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.breadcrumb::-webkit-scrollbar { display: none; }
.breadcrumb ol {
  display: flex;
  gap: 0;
  flex-wrap: nowrap;
  list-style: none;
  padding: 0;
  margin: 0;
  white-space: nowrap;
  min-width: min-content;
}
.breadcrumb li {
  color: #64748b;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.breadcrumb li + li::before {
  content: "/";
  margin: 0 8px;
  color: #cbd5e1;
  font-weight: 300;
  font-size: 13px;
}
.breadcrumb a {
  color: #274c77;
  text-decoration: none;
  transition: all 0.2s ease;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 500;
}
.breadcrumb a:hover {
  color: #1e3a5f;
  background: rgba(39,76,119,0.06);
}
.breadcrumb .active {
  color: #0f172a;
  font-weight: 600;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Ad slots ────────────────────────────────────────────────── */
.ad-container {
  margin: 16px auto;
  text-align: center;
  max-width: 1200px;
  padding: 0 20px;
}
.ad-top { margin-top: 6px; }
.ad-bottom { margin-bottom: 6px; }

/* ── Utility ─────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .nav-menu > li > a { padding: 0.5rem 0.6rem; font-size: 0.85rem; }
}

@media (max-width: 768px) {
  .header { border-radius: 0; }
  .header-container { padding: 0 16px; height: 60px; }
  .logo a { font-size: 1.4rem; }
  .nav-toggle { display: flex; }
  .nav-menu {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: linear-gradient(180deg, rgba(39,76,119,0.98), rgba(96,150,186,0.98));
    position: absolute;
    top: 60px;
    left: 0;
    padding: 1rem;
    margin: 0;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease-in-out;
    max-height: calc(100vh - 60px);
    max-height: calc(100dvh - 60px);
    overflow-y: auto;
    gap: 0.25rem;
    border-radius: 0 0 16px 16px;
  }
  .nav-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  .nav-menu > li { width: 100%; }
  .nav-menu > li > a {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    border-radius: 10px;
    justify-content: space-between;
  }
  .dropdown .submenu {
    position: static;
    display: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    background: rgba(255,255,255,0.1);
    box-shadow: none;
    border: 1px solid rgba(255,255,255,0.1);
    width: 100%;
    min-width: auto;
    margin-top: 4px;
    border-radius: 10px;
    padding: 0.5rem;
    transition: none;
    pointer-events: auto;
  }
  .dropdown .submenu::before { display: none; }
  .dropdown.open .submenu { display: block; transform: none !important; }

  /* Force hover effects off on touch/mobile */
  .dropdown:hover .submenu {
    opacity: 1;
    visibility: visible;
    transform: none;
    display: none;
  }
  .dropdown.open:hover .submenu { display: block; }

  .dropdown.open .submenu li { display: block; margin: 2px 0; }
  .dropdown.open .submenu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.65rem 0.9rem;
    color: rgba(255,255,255,0.9);
    border-radius: 8px;
    transition: none;
  }
  .dropdown.open .submenu a:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
  }
  .submenu a { color: rgba(255,255,255,0.9); }
  .submenu a:hover { background: rgba(255,255,255,0.15); color: #fff; }
  .submenu .submenu-footer { border-color: rgba(255,255,255,0.1); }
  .submenu .submenu-footer a { color: #a3cef1; }

  .search-form { width: 100%; }
  .search-toggle-checkbox:checked ~ .search-form-container {
    width: calc(100vw - 32px);
    right: -10px;
    left: auto;
  }
  .breadcrumb { margin: 12px 16px; font-size: 13px; }
  .breadcrumb li + li::before { margin: 0 6px; }
  .breadcrumb .active { max-width: 150px; }
}

@media (max-width: 480px) {
  .header-container { padding: 0 12px; height: 56px; }
  .logo a { font-size: 1.25rem; }
  .search-form { padding: 10px; }
  .search-form-container { border-radius: 12px; }
  .breadcrumb { margin: 10px 12px; font-size: 12px; }
}

@media (prefers-reduced-motion: no-preference) {
  .submenu,
  .search-form-container {
    will-change: transform, opacity;
  }
}

@media (hover: none) and (pointer: coarse) and (min-width: 769px) {
  .dropdown:hover .submenu {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-8px);
    display: none;
  }
  .dropdown.open .submenu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    display: block;
  }
}

@media (prefers-color-scheme: dark) {
  .submenu,
  .search-form-container {
    background: rgba(30,41,59,0.98);
    border-color: rgba(255,255,255,0.08);
  }
  .submenu::before {
    background: rgba(30,41,59,0.98);
    border-color: rgba(255,255,255,0.08);
  }
  .submenu a { color: #cbd5e1; }
  .submenu a:hover { background: rgba(255,255,255,0.08); color: #fff; }
  .search-input { background: #0f172a; border-color: #334155; color: #e2e8f0; }
  .search-input:focus { background: #1e293b; }
  .breadcrumb li { color: #94a3b8; }
  .breadcrumb li + li::before { color: #475569; }
  .breadcrumb a { color: #60a5fa; }
  .breadcrumb a:hover { background: rgba(96,165,250,0.1); }
  .breadcrumb .active { color: #f1f5f9; }
}
