/* =========================================
   Header — km-header, navigation, search, mobile menu
   ========================================= */

/* -----------------------------------------
   Header container
   ----------------------------------------- */
.km-header {
  position: relative;
  z-index: 99999;
  font-family: 'Open Sans', sans-serif;
  background: #fff;
}

.km-header-top {
  max-width: 1200px;
  margin: 0 auto;
  padding: 25px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  position: relative;
}

.km-header-top.has-ad {
  justify-content: space-between;
}

/* -----------------------------------------
   Logo
   ----------------------------------------- */
.km-logo {
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  flex-shrink: 0;
}

.km-logo:hover {
  text-decoration: none;
}

.km-logo-text {
  font-family: 'Arial Black', Arial, sans-serif;
  font-weight: 900;
  font-size: 2.8rem;
  color: #808080;
  letter-spacing: -1px;
  line-height: 1;
}

.km-logo-colon {
  font-family: 'Times New Roman', serif;
  font-weight: 700;
  font-size: 3.1rem;
  color: #1a1a1a;
  line-height: 1;
}

/* -----------------------------------------
   Header ad slot (beside logo)
   ----------------------------------------- */
.km-header-ad {
  flex-shrink: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

.km-header-ad img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* -----------------------------------------
   Desktop navigation
   ----------------------------------------- */
.km-nav {
  background: #fff;
  border-bottom: 1px solid var(--km-border);
}

.km-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 60px 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.km-nav-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
}

.km-nav-menu > li {
  position: relative;
}

.km-nav-menu > li > a {
  display: block;
  color: var(--km-text);
  text-decoration: none;
  padding: 14px 18px;
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color 0.2s;
  white-space: nowrap;
}

.km-nav-menu > li > a:hover,
.km-nav-menu > li.active > a {
  color: var(--km-accent);
}

/* -----------------------------------------
   Desktop dropdown
   ----------------------------------------- */
.km-nav-menu .km-dropdown {
  list-style: none;
  margin: 0;
  padding: 0;
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  min-width: 200px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s;
  z-index: 100;
}

.km-nav-menu > li:hover > .km-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.km-dropdown li {
  border-bottom: 1px solid #f5f5f5;
}

.km-dropdown li:last-child {
  border-bottom: none;
}

.km-dropdown a {
  display: block;
  padding: 12px 18px;
  color: #333;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
}

.km-dropdown a:hover {
  background: #f8f8f8;
  color: var(--km-accent);
}

.km-has-dropdown > a::after {
  content: '';
  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: 4px solid currentColor;
}

/* -----------------------------------------
   Search button (desktop nav)
   ----------------------------------------- */
.km-search-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 14px 15px;
  display: flex;
  align-items: center;
  position: absolute;
  right: 20px;
}

.km-search-btn svg {
  color: #999;
  transition: color 0.2s;
}

.km-search-btn:hover svg {
  color: var(--km-accent);
}

/* -----------------------------------------
   Desktop search bar (slide-down)
   ----------------------------------------- */
.km-search-bar {
  background: #f8f8f8;
  border-bottom: 1px solid #eee;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s;
}

.km-search-bar.active {
  max-height: 80px;
}

.km-search-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 15px 20px;
  display: flex;
  align-items: center;
}

.km-search-bar form {
  display: flex;
  flex: 1;
  max-width: 500px;
}

.km-search-bar input {
  flex: 1;
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-right: none;
  border-radius: 3px 0 0 3px;
  font-size: 14px;
  outline: none;
}

.km-search-bar input:focus {
  border-color: var(--km-accent);
}

.km-search-bar button[type="submit"] {
  padding: 10px 18px;
  background: #333;
  border: 1px solid #333;
  border-radius: 0 3px 3px 0;
  cursor: pointer;
  transition: background 0.2s;
}

.km-search-bar button[type="submit"]:hover {
  background: var(--km-accent);
  border-color: var(--km-accent);
}

.km-search-bar button svg {
  color: #fff;
  display: block;
}

.km-search-close {
  background: none;
  border: none;
  margin-left: 20px;
  cursor: pointer;
  font-size: 28px;
  color: #999;
  padding: 5px 10px;
  line-height: 1;
}

.km-search-close:hover {
  color: #333;
}

/* -----------------------------------------
   Mobile controls
   ----------------------------------------- */
.km-mobile-controls {
  display: none;
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  align-items: center;
}

.km-hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 44px;
  height: 44px;
  cursor: pointer;
  padding: 10px;
  background: none;
  border: none;
}

.km-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #333;
  margin: 3px 0;
  transition: all 0.3s;
}

.km-hamburger.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.km-hamburger.active span:nth-child(2) {
  opacity: 0;
}

.km-hamburger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* -----------------------------------------
   Mobile menu (slide-down overlay)
   ----------------------------------------- */
.km-mobile-menu {
  display: none;
  background: #fff;
  border-bottom: 1px solid #eee;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.km-mobile-menu.active {
  display: block;
}

/* Mobile search inside menu */
.km-mobile-search {
  padding: 15px 20px;
  background: #f8f8f8;
  border-bottom: 1px solid #eee;
}

.km-mobile-search form {
  display: flex;
}

.km-mobile-search input {
  flex: 1;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-right: none;
  border-radius: 3px 0 0 3px;
  font-size: 14px;
}

.km-mobile-search button {
  padding: 12px 18px;
  background: #333;
  border: none;
  border-radius: 0 3px 3px 0;
  cursor: pointer;
}

.km-mobile-search button svg {
  color: #fff;
}

/* Mobile nav list */
.km-mobile-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 70vh;
  overflow-y: auto;
}

.km-mobile-nav li {
  border-bottom: 1px solid #f0f0f0;
}

.km-mobile-nav > li > a {
  display: block;
  padding: 15px 20px;
  color: #333;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  text-transform: uppercase;
}

.km-mobile-nav > li > a:hover {
  background: #f8f8f8;
  color: var(--km-accent);
}

.km-mobile-nav > li.km-has-dropdown {
  position: relative;
}

.km-mobile-nav > li.km-has-dropdown > a {
  padding-right: 50px;
}

/* Mobile dropdown toggle button */
.km-dropdown-toggle {
  position: absolute;
  right: 0;
  top: 0;
  width: 50px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-left: 1px solid #f0f0f0;
  cursor: pointer;
  font-size: 20px;
  color: #999;
}

.km-dropdown-toggle::after {
  content: '+';
}

.km-has-dropdown.open .km-dropdown-toggle::after {
  content: '\2212'; /* minus sign */
}

/* Mobile dropdown list */
.km-mobile-nav .km-dropdown {
  list-style: none;
  margin: 0;
  padding: 0;
  background: #fafafa;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s;
}

.km-mobile-nav .km-has-dropdown.open .km-dropdown {
  max-height: 500px;
}

.km-mobile-nav .km-dropdown a {
  display: block;
  padding: 12px 20px 12px 35px;
  color: #666;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 1px solid #f0f0f0;
}

.km-mobile-nav .km-dropdown li:last-child a {
  border-bottom: none;
}

.km-mobile-nav .km-dropdown a:hover {
  color: var(--km-accent);
}

/* -----------------------------------------
   Responsive breakpoints
   ----------------------------------------- */

/* Large desktop: ensure header ad has room */
@media (min-width: 1200px) {
  .km-header-ad {
    min-width: 728px;
  }
}

/* Medium screens */
@media (max-width: 1100px) {
  .km-logo-text {
    font-size: 2.4rem;
  }

  .km-logo-colon {
    font-size: 2.6rem;
  }

  .km-nav-menu > li > a {
    padding: 14px;
    font-size: 0.8rem;
  }
}

/* Tablet: switch to mobile nav */
@media (max-width: 950px) {
  .km-nav,
  .km-search-bar {
    display: none;
  }

  .km-mobile-controls {
    display: flex;
  }

  .km-header-top {
    padding-right: 70px;
  }

  .km-header-top.has-ad {
    flex-direction: column;
    gap: 15px;
    padding: 15px 20px;
  }
}

@media (max-width: 850px) {
  .km-header-top {
    padding: 15px 70px 15px 15px;
  }

  .km-header-top.has-ad {
    padding: 15px;
  }

  .km-header-ad {
    width: 100%;
    max-width: none;
    justify-content: center;
  }

  .km-header-ad img,
  .km-header-ad > * {
    width: 100%;
    max-width: 100%;
    height: auto;
  }

  .km-mobile-controls {
    top: 20px;
    transform: none;
  }
}

@media (max-width: 768px) {
  .km-logo-text {
    font-size: 2rem;
  }

  .km-logo-colon {
    font-size: 2.2rem;
  }
}

@media (max-width: 480px) {
  .km-logo-text {
    font-size: 1.6rem;
  }

  .km-logo-colon {
    font-size: 1.8rem;
  }

  .km-header-top {
    padding: 12px 60px 12px 12px;
  }

  .km-mobile-controls {
    right: 10px;
  }
}

@media (max-width: 380px) {
  .km-logo-text {
    font-size: 1.4rem;
  }

  .km-logo-colon {
    font-size: 1.55rem;
  }
}
