/* Make sticky-header also use flex with order */
#sticky-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 9998;
  background-color: #000000 !important;
  padding: 12px 24px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

/* On desktop, make create-btn appear after legend-top */
#sticky-header #headline {
  order: 1;
  margin-right: auto; /* Push everything else to the right */
}

#sticky-header #legend-top {
  order: 2;
}

#sticky-header .create-btn {
  order: 3; /* Puts it after legend-top on desktop */
  margin-left: 1rem;
}

#sticky-header #headline {
  width: 260px;
}

#headline {
  display: flex;
}

.headline-img {
  transition: filter 0.3s ease;
}

/* .headline-img:hover {
  filter: brightness(0) saturate(100%) invert(73%) sepia(17%) saturate(634%)
    hue-rotate(358deg) brightness(93%) contrast(88%);
} */

#headline:hover .headline-img {
  filter: brightness(0) saturate(100%) invert(73%) sepia(17%) saturate(634%)
    hue-rotate(358deg) brightness(93%) contrast(88%);
}
/* ---------------------------------------------------
   Top Controls: Filter, View/Trace, Gender Legend
--------------------------------------------------- */

.create-btn {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  padding: 8px 12px;
  background-color: rgba(109, 109, 109, 0.4);
  color: #d5d5d5;
  /* border: 1px solid #858585; */
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 400;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  /* box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); */
}

.create-btn::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  background-image: url("assets/camera.svg");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* if there's a link inside, make it inherit */
.create-btn a {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.create-btn:hover {
  background-color: rgba(60, 60, 60, 0.95);
  color: #ffffff;
  border: none;
  transform: translateY(-1px);
}

.create-btn:active {
  transform: translateY(0);
}

/* container from gallery.html */
#legend-top {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap; /* keep a single horizontal row on wide screens */
  gap: 0.75rem;
  /* width: 100%; */
}

.icon-group {
  gap: 0rem;
}

/* filter select */
#filter,
.legend-select-mobile {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  display: inline-block;
  min-width: 145px;
  padding: 8px 38px 8px 12px;
  font-size: 0.7rem;
  font-weight: 400;
  color: #fff;
  background-color: rgb(174, 2, 2);
  border-radius: 4px;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path d='M6 8l4 4 4-4' stroke='%23ffffff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' fill='none'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
  border: none;
  transition: background-color 0.3s ease, transform 0.2s ease,
    box-shadow 0.3s ease;
}

#filter:hover,
.legend-select-mobile:hover {
  background-color: rgb(200, 10, 10);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(174, 2, 2, 0.4);
}

#filter:active,
.legend-select-mobile:active {
  transform: translateY(0);
  box-shadow: none;
}

/* gender dropdown: hidden by default, shown only on small screens */
.legend-select-mobile {
  display: none;
}

/* Identify button - positioned top right above gallery */
.identify-btn {
  padding: 8px 14px;
  background-color: rgb(174, 2, 2);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 400;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: auto;
  transition: background-color 0.3s ease, transform 0.2s ease,
    box-shadow 0.3s ease;
}

.identify-btn:hover {
  transform: translateY(-1px);
}

.identify-btn:disabled,
.identify-btn[disabled] {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

/* view / trace buttons */
.view-btn {
  padding: 8px 14px;
  background-color: rgb(174, 2, 2);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 400;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: auto;
  transition: background-color 0.3s ease, transform 0.2s ease,
    box-shadow 0.3s ease;
}

.view-btn:disabled,
.view-btn[disabled] {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

.view-btn:hover {
  background-color: rgb(200, 10, 10);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(174, 2, 2, 0.4);
}

.view-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

/* gender legend icon buttons */
.legend-btn {
  color: #d7d7d7;
  background: transparent;
  border: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.3s ease, transform 0.2s ease;
}

.legend-btn:hover {
  color: #cab084;
  transform: scale(1.05);
}

.legend-btn:active {
  transform: scale(0.98);
  color: #cab084;
}

.legend-btn.active {
  color: #cab084;
}

.legend-btn[title]::after {
  content: attr(title);
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.9);
  color: #ffffff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.legend-btn:hover::after {
  opacity: 1;
}

.legend-icon {
  display: inline-block;
  width: 50px;
  height: 50px;
  background-color: currentColor;
  transition: background-color 0.3s ease;
}

.legend-icon.icon-men {
  -webkit-mask: url("assets/icon-men.svg") no-repeat center / contain;
  mask: url("assets/icon-men.svg") no-repeat center / contain;
}

.legend-icon.icon-women {
  -webkit-mask: url("assets/icon-women.svg") no-repeat center / contain;
  mask: url("assets/icon-women.svg") no-repeat center / contain;
}

.legend-icon.icon-children {
  -webkit-mask: url("assets/icon-children.svg") no-repeat center / contain;
  mask: url("assets/icon-children.svg") no-repeat center / contain;
}

@media (max-width: 1100px) {
  #gallery {
    padding-top: 0;
    padding-bottom: 80px; /* Add extra padding to push gallery items up */
  }

  /* Remove gallery top offset scroll */
  .scroll-card {
    bottom: 90px;
  }

  .scroll-card.visible {
    transform: translateX(-50%) translateY(0);
  }

  /* Force all gallery items below the bottom nav */
  #gallery .item,
  #gallery .item img,
  #gallery .item canvas {
    position: relative;
    z-index: 1 !important;
  }

  #sticky-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
  }

  .hamburger {
    display: none;
  }

  /* Keep dropdowns in header on mobile */
  #legend-top #filter,
  #legend-top .legend-select-mobile {
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
    /* background-color: rgba(89, 89, 89, 0.9); */
    font-size: 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 20px 6px 8px;
    min-width: 0;
    width: 120px;
    flex: 0 0 auto;
  }

  #legend-top #filter:hover,
  #legend-top .legend-select-mobile:hover,
  #legend-top #filter:focus,
  #legend-top .legend-select-mobile:focus {
    /* background-color: rgba(60, 60, 60, 0.95); */
    /* border-color: rgba(255, 255, 255, 0.2); */
    box-shadow: none;
    transform: none;
  }

  .legend-select-mobile {
    display: inline-block;
  }

  #legend-top .legend-btn {
    display: none;
  }

  /* Single bottom nav background */
  .bottom-nav-bar {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 50px;
    background-color: #ae0202;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
    z-index: 9000;
  }

  /* Move only buttons to bottom of screen */
  #legend-top .view-btn,
  #legend-top .identify-btn {
    position: fixed;
    bottom: 8px;
    background-color: transparent;
    color: #ffffff;
    padding: 10px 4px;
    font-size: 0.65rem;
    border: none;
    justify-content: center;
    align-items: center;
    min-width: 0;
    white-space: nowrap;
    overflow: visible;
    z-index: 999999 !important;
    height: 34px;
    pointer-events: auto; /* Ensure buttons can receive clicks */
  }

  /* Move create-btn to bottom too */
  .create-btn {
    position: fixed;
    bottom: 8px;
    background-color: transparent;
    color: #ffffff;
    padding: 10px 4px;
    font-size: 0.65rem;
    border: none;
    justify-content: center;
    align-items: center;
    min-width: 0;
    white-space: nowrap;
    overflow: visible;
    z-index: 999999 !important;
    height: 34px;
    order: 4;
    pointer-events: auto; /* Ensure button can receive clicks */
  }

  .create-btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
  }

  /* Style links inside buttons */
  #legend-top .identify-btn a {
    color: #ffffff;
    text-decoration: none;
  }

  /* Position each button */
  #legend-top #identify-btn {
    left: 4px;
    width: calc(25% - 8px);
  }

  #legend-top #view-btn {
    left: calc(25% + 0px);
    width: calc(25% - 8px);
  }

  #legend-top #morph-btn {
    left: calc(50% - 4px);
    width: calc(25% - 8px);
  }

  .create-btn {
    left: calc(75% - 20px);
    width: calc(25% - 8px);
  }

  /* Shorten "View Collection" to "View" */
  #legend-top #view-btn {
    font-size: 0;
  }
  #legend-top #view-btn::after {
    content: "View";
    font-size: 0.85rem;
    color: #ffffff;
  }

  /* Shorten "Reveal a face" to "Reveal" */
  #legend-top #identify-btn a {
    font-size: 0;
  }
  #legend-top #identify-btn a::after {
    content: "Reveal";
    font-size: 0.85rem;
    color: #ffffff;
  }

  /* "Trace" stays as is */
  #legend-top #morph-btn {
    font-size: 0.85rem;
    color: #ffffff;
  }

  #legend-top .view-btn:hover,
  #legend-top .identify-btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
    transform: none;
    box-shadow: none;
  }

  #legend-top .view-btn:disabled,
  #legend-top .identify-btn:disabled,
  #legend-top #morph-btn:disabled {
    opacity: 0.4 !important;
    background-color: transparent !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
  }

  /* .create-btn {
    padding: 6px 8px;
    font-size: 0.65rem;
    position: relative;
    order: 3;
  } */
  #sticky-header #headline {
    width: 180px;
    order: 1;
    margin-right: 0;
  }

  #sticky-header #legend-top {
    order: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    position: relative;
    background: transparent;
    padding: 0;
    border: none;
    box-shadow: none;
  }

  body {
    padding-bottom: 60px;
  }
}

@media (max-width: 640px) {
  .headline-img {
    content: url("assets/icon-logo.svg");
    width: 20%;
    height: auto;
  }
  #headline {
    flex: 1;
  }
}
