* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* The following 2 lines can be removed if the "mini reset"
   above using the * selector is removed.
*/
dt {margin-bottom: .2em;}
dd {margin-bottom: 1em; margin-left: 2em;}

header {
  width: 100%;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
}

.logo-container {
  position: absolute;
  left: 0;
  top: 0;
  height: 100px; /* Default height for large screens */
  display: flex;
  z-index: 10;
}

.logo {
  display: block;
}

#main_logo img {
  height: 100px; /* Default height for large screens */
  width: auto;
  display: block;
}

.top-header {
  background-color: #7ebed0;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
}

.search-form {
  display: flex;
  flex-grow: 0;
  width: 500px;
  margin: 0 auto;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.search-input {
  padding: 9px 16px;
  border: 2px solid #fff;
  border-radius: 20px 0 0 20px;
  width: 100%;
  font-size: 14px;
}

.search-button{
  background-color: #4C8FA8;
  color: white;
  border: none;
  padding: 0px 24px;
  border-radius: 0 20px 20px 0;
  cursor: pointer;
  font-weight: bold;
  font-size: 16px;
  text-align: center;
}

.donate-container {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-left: auto;
  z-index: 5;
}

.paypal-link {
  display: flex;
  align-items: center;
}

.paypal-img {
  height: 25px;
  width: auto;
}

.donbtn {
  height: 25px;
  vertical-align: middle;
  transition: height 0.2s ease;
}

.donate-container .donate-link {
  background-color: #4C8FA8;
  color: white;
  text-decoration: none;
  font-weight: bold;
  padding: 5px 22px;
  border: 2px solid #4C8FA8;
  border-radius: 4px;
  transition:
    opacity 0.2s ease,
    padding 0.2s ease,
    font-size 0.2s ease;
}

.donate-container .donate-link:hover {
  opacity: 0.9;
}

.lower-header {
  background-color: #c7dde3;
  padding: 0 8px;
  display: flex;
  justify-content: center;
  height: 60px;
  align-items: center;
}

/* Dropdown overlay */
.dropdown-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: transparent;
  z-index: 0;
  display: none;
  cursor: default;
}

/* Display dropdown when focused with keyboard */
.dropdown:focus-within .dropdown-content {
  display: block;
}

#about-toggle:checked ~ .dropdown-overlay {
  display: block;
  z-index: 900;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-button {
  background-color: transparent;
  color: black;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-weight: bold;
  display: flex;
  align-items: center;
  margin: 0 20px;
  font-size: 16px;
  font-family: inherit;
  padding: 0;
}

.dropdown-icon {
  font-size: 12px;
  margin-left: 8px;
  display: inline-block;
  color: black;
  transition: transform 0.2s ease;
}

.dropdown:hover .dropdown-icon {
  transform: rotate(180deg);
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: white;
  min-width: 200px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 910;
  border-radius: 4px;
  overflow: hidden;
}

.dropdown-content a {
  color: black;
  padding: 10px 16px;
  text-decoration: none;
  display: block;
  font-weight: bold;
  font-size: 14px;
}

.dropdown-content a:hover {
  background-color: #f1f1f1;
  text-decoration: underline;
}

.dropdown:hover .dropdown-content {
  display: block;
}

/* About dropdown toggle */
#about-toggle:checked ~ .lower-header .dropdown .dropdown-content {
  display: block;
}

#about-toggle:checked ~ .lower-header .dropdown .dropdown-icon {
  transform: rotate(180deg);
}

.main-links {
  display: flex;
  align-items: center;
  overflow-x: auto;
  flex-wrap: nowrap;
}

.main-links a {
  color: black;
  text-decoration: none;
  margin: 0 20px;
  font-weight: bold;
  font-size: 16px;
  white-space: nowrap;
  flex-shrink: 0;
}

.main-links a:hover,
.dropdown-button:hover {
  text-decoration: underline;
}

.tertiary-header {
  background-color: #e0ecf0;
  padding: 0 20px;
  display: none;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  height: 60px;
  min-height: 60px;
}

.tertiary-header a,
.tertiary-header::before,
.tertiary-header::after {
  color: black;
  text-decoration: none;
  font-weight: bold;
  font-size: 16px;
  white-space: nowrap;
  flex-shrink: 0;
}

.tertiary-header a:hover,
.tertiary-header::before:hover,
.tertiary-header::after:hover {
  text-decoration: underline;
}

.tertiary-header .tertiary-link {
  display: none;
  color: black;
  text-decoration: none;
  font-weight: bold;
  font-size: 16px;
  white-space: nowrap;
  flex-shrink: 0;
}

.tertiary-header .tertiary-link:hover {
  text-decoration: underline;
}

.search-icon-btn, .search-close-btn {
  display: none;
}

@media (max-width: 1400px) {
  .donbtn {
    height: 20px;
  }

  .donate-link {
    padding: 4px 18px;
    font-size: 14px;
  }
}

@media (max-width: 1200px) {
  .logo-container {
    height: 85px; /* Smaller logo for medium screens */
  }

  #main_logo img {
    height: 85px; /* Smaller logo for medium screens */
  }
}

@media (max-width: 1110px) {
  .logo-container {
    height: 60px; /* Match top header height */
  }

  #main_logo img {
    height: 60px; /* Match top header height */
  }
}

/*
Remove sticky header at this breakpoint.
*/
@media (max-width: 1024px) {
  header {
    position: relative;
  }

  body {
    padding-top: 0;
  }

  .logo-container {
    height: 100px; /* Restore original logo height */
  }

  #main_logo img {
    height: 100px; /* Restore original logo height */
  }

  .search-form {
    width: 300px;
  }

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

  .tertiary-header {
    display: flex;
  }

  .lower-header .main-links .link-freq-downloaded,
  .lower-header .main-links .link-main-categories {
    display: none;
  }

  .lower-header,
  .tertiary-header {
    padding-left: 10px;
    padding-right: 10px;
  }

  .lower-header .dropdown-button,
  .lower-header .main-links a {
    margin: 0 15px;
  }

  .tertiary-header .tertiary-link {
    display: inline-block;
    margin: 0 15px;
  }
}

/* For touch devices, use click/tap instead of hover */
@media (hover: none) {
  .dropdown:hover .dropdown-content {
    display: none;
  }
}

@media (max-width: 935px) {
  .logo-container {
    height: 90px; /* Smaller logo for medium screens */
  }

  #main_logo img {
    height: 90px; /* Smaller logo for medium screens */
  }
}

@media (max-width: 835px) {
  .logo-container {
    height: 85px; /* Smaller logo for medium screens */
  }

  #main_logo img {
    height: 85px; /* Smaller logo for medium screens */
  }
}

@media (max-width: 735px) {
  .logo-container {
    height: 60px; /* Smaller logo for medium screens */
  }

  #main_logo img {
    height: 60px; /* Smaller logo for medium screens */
  }
}

@media (max-width: 768px) {
  .donbtn {
    height: 15px;
  }

  .donate-link {
    padding: 3px 15px;
    font-size: 13px;
  }
}

@media (max-width: 715px) {
  .donatelink {
    display: none;
  }

  .donate-link {
    padding: 5px 22px;
    font-size: 16px;
  }
}

@media (max-width: 620px) {
  .donbtn {
    height: 12px;
  }

  .donate-link {
    padding: 3px 12px;
    font-size: 12px;
  }
}

@media (max-width: 500px) {
  .search-form {
    width: auto;
    justify-content: center;
  }

  .search-input,
  .search-button {
    display: none;
  }

  .search-icon-btn {
    display: inline-block;
    background-color: #4C8FA8;
    color: white;
    border: 2px solid #4C8FA8;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 16px;
    transition: opacity 0.2s ease;
    line-height: 1;
  }

  .search-close-btn {
    display: none;
    background-color: #4C8FA8;
    color: white;
    border: 2px solid #4C8FA8;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 16px;
    transition: opacity 0.2s ease;
    margin: 8px;
    margin-top: auto;
    margin-bottom: auto;
  }

  .search-icon-btn:hover {
    opacity: 0.9;
  }

  .search-icon-btn .search-icon {
    display: inline-block;
    width: 2em;
    height: 2em;
    vertical-align: middle;
    fill: currentColor;
  }

  /* Toggle Search Bar on Small Screens */
  #search-toggle:checked ~ .logo-container,
  #search-toggle:checked ~ .top-header .donate-container,
  #search-toggle:checked ~ .top-header .search-form label.search-icon-btn {
    display: none; /* Hide logo, donate, search icon when active */
  }

  #search-toggle:checked ~ .top-header .search-close-btn {
    display: inline-block; /* Show close button when active */
  }

  #search-toggle:checked ~ .top-header .search-form {
    width: calc(100% - 120px); /* Further reduced width */
    position: absolute; /* Keep absolute positioning */
    left: 60px; /* Adjust position based on new padding */
    transform: none; /* Remove centering */
    justify-content: flex-start; /* Align items left */
    display: flex; /* Ensure form is flex container */
  }

  #search-toggle:checked ~ .top-header .search-form .search-input,
  #search-toggle:checked ~ .top-header .search-form .search-button {
    display: block; /* Show input and button */
  }

  #search-toggle:checked ~ .top-header .search-form .search-input {
    flex-grow: 1; /* Allow input to grow */
  }

  #search-toggle:checked ~ .top-header {
    justify-content: flex-start; /* Align the form within the header */
  }
}

@media (max-width: 550px) {
  .search-form {
    width: 200px;
  }
}

@media (max-width: 435px) {
  .lower-header .dropdown-button,
  .lower-header .main-links a,
  .tertiary-header .tertiary-link {
    font-size: 15px;
    margin: 0 10px; /* Also reduce margin slightly */
  }

  .lower-header,
  .tertiary-header {
    padding-left: 5px;
    padding-right: 5px;
  }

  .search-icon-btn {
    padding: 3px 6px; /* Reduce padding */
  }
}

@media (max-width: 400px) {
  .donate-container .donate-link {
    padding: 5px 18px;
    font-size: 11px;
  }
}
