/* =========================================================
   Shared topnav styles — linked from every page.
   Page-skeleton rules (body reset, sticky footer) live in
   layout.css; footer rules live in footer.css.
   ========================================================= */

/* ===== Topnav container ===== */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #272c6d;
}

.topnav .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 16px;
  padding: 0;
  flex-shrink: 0;
  align-self: center;
  text-decoration: none;
}

.brand-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
  display: none;
  flex-shrink: 0;
}

/* Light-on-dark mark shows on the navy bar; swaps for the blue mark
   once the bar goes white at the mobile breakpoint below. */
.brand-icon-light {
  display: block;
}

.brand-text {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  color: #f2f2f2;
}

.nav-links {
  display: flex;
  align-items: center;
}

.topnav a {
  float: left;
  display: block;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
  white-space: nowrap;
}

.topnav a.active {
  background-color: #2666ff;
  color: white;
}

/* Mobile menu toggle button (hamburger / close) */
.icon {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: #f2f2f2;
  padding: 12px 16px;
}

.icon svg {
  display: block;
  width: 24px;
  height: 24px;
}

/* Search toggle reuses .icon's button reset/color rules, but (unlike
   the hamburger) should stay visible at every width. */
.search-toggle {
  display: flex;
}

.search-toggle svg {
  width: 20px;
  height: 20px;
}

.dropdown {
  position: relative;
  float: left;
}

.dropdown .dropbtn {
  display: block;
  font-size: 17px;
  border: none;
  outline: none;
  color: white;
  padding: 14px 16px;
  background-color: inherit;
  font-family: inherit;
  text-decoration: none;
  margin: 0;
  white-space: nowrap;
  cursor: pointer;
}

.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background-color: #b3d3f3;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 500;
}

.dropdown-content a {
  float: none;
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  text-align: left;
}

.topnav a:not(.brand):hover, .dropdown:hover .dropbtn {
  background-color: #ffeb85;
  color: #111827;
}

.topnav .brand:hover {
  background-color: transparent;
}

.dropdown-content a:hover {
  background-color: #ffeb85;
  color: black;
}

/* Desktop: hover opens the dropdown */
.dropdown:hover .dropdown-content {
  display: block;
}

/* Mobile (and click-to-toggle, since touch has no hover): .open opens the dropdown */
.dropdown.open .dropdown-content {
  display: block;
}

/* ===== 901px-1100px: shrink slightly before switching to the mobile menu ===== */
@media screen and (max-width: 1100px) and (min-width: 901px) {
  .topnav a, .dropdown .dropbtn {
    padding: 12px 10px;
    font-size: 14px;
  }
  .brand {
    margin: 0 10px;
    gap: 8px;
  }
  .brand-icon {
    width: 26px;
    height: 26px;
  }
  .brand-text {
    font-size: 14px;
  }
}

/* ===== <=900px: collapsed mobile bar ===== */
@media screen and (max-width: 900px) {
  .nav-links a:not(.icon), .dropdown .dropbtn {
    display: none;
  }
  .icon {
    display: flex;
  }
  .brand {
    margin: 0 12px;
  }
  .brand-icon {
    width: 26px;
    height: 26px;
  }
  /* Bar goes white here, so swap to the blue mark for contrast */
  .brand-icon-light {
    display: none;
  }
  .brand-icon-dark {
    display: block;
  }

  /* White bar so it sits flush with the page when collapsed */
  .topnav {
    background-color: #ffffff;
  }
  .brand-text {
    color: #272c6d;
  }
  .topnav a, .dropdown .dropbtn, .icon {
    color: #272c6d;
  }
  .topnav a.active {
    color: #ffffff;
  }
  .topnav a:not(.brand):hover, .dropdown:hover .dropbtn {
    color: #111827;
  }
}

/* ===== Open state: full-screen takeover — only the menu and close button show ===== */
@media screen and (max-width: 900px) {
  .topnav.responsive {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    overflow-y: auto;
    z-index: 1000;
  }
  .topnav.responsive .brand {
    display: none;
  }
  .topnav.responsive .nav-links {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  /* Give the close button its own full-width row at the top, so the link
     list starts below it instead of underneath/overlapping it */
  .topnav.responsive .icon {
    display: flex;
    justify-content: flex-end;
    padding: 14px 16px;
    border-bottom: 1px solid #e5e7eb;
  }
  .topnav.responsive .icon svg {
    width: 28px;
    height: 28px;
  }
  /* Hide search while the full-screen menu is open — the close
     button owns that top row; search is reachable once it's closed. */
  .topnav.responsive .search-toggle {
    display: none;
  }
  .topnav.responsive a {
    float: none;
    display: block;
    text-align: left;
  }
  .topnav.responsive .dropdown { float: none; }
  .topnav.responsive .dropdown-content { position: relative; top: auto; left: auto; }
  .topnav.responsive .dropdown .dropbtn {
    display: block;
    width: 100%;
    text-align: left;
  }
}
