/* ==========================================================================
   Popup tìm kiếm toàn màn hình (nút kính lúp trên header).

   VIẾT TAY. Popup in ở wp_footer, NGOÀI `.tbtc-page`, nên không scope theo
   class đó — mọi selector dùng tiền tố `tbtc-search`.

   Cỡ chữ / màu lấy từ tokens.css, cùng thang với trang chủ.
   ========================================================================== */

.tbtc-search {
  position: fixed;
  inset: 0;
  z-index: 100000; /* trên header dính và mọi nút nổi bên phải */
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh var(--gutter) var(--sp-10);
  font-family: var(--font-sans);
}

.tbtc-search[hidden] {
  display: none;
}

.tbtc-search__backdrop {
  position: absolute;
  inset: 0;
  background: var(--c-navy-overlay);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}

.tbtc-search__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 720px;
  padding: var(--sp-8);
  border-radius: var(--r-2xl);
  background: var(--c-white);
  box-shadow: 0 24px 64px rgba(111, 46, 125, 0.28);
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.tbtc-search.is-open .tbtc-search__backdrop {
  opacity: 1;
}

.tbtc-search.is-open .tbtc-search__panel {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .tbtc-search__backdrop,
  .tbtc-search__panel {
    transition: none;
  }
}

/* ---- Nút đóng ------------------------------------------------------------ */

.tbtc-search__close {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
  width: 40px;
  height: 40px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--c-border-2);
  border-radius: var(--r-pill);
  background: var(--c-white);
  box-shadow: none !important;
  color: var(--c-text);
  cursor: pointer;
}

.tbtc-search__close svg {
  width: 20px;
  height: 20px;
  fill: none;
}

.tbtc-search__close:hover {
  border-color: var(--c-blue);
  background: var(--c-blue-50);
  color: var(--c-blue);
}

/* ---- Tiêu đề ------------------------------------------------------------- */

.tbtc-search__title {
  margin: 0 0 var(--sp-5);
  padding-right: 48px; /* chừa chỗ nút đóng */
  color: var(--c-navy);
  font-size: var(--fs-display-4);
  line-height: var(--lh-display-4);
  font-weight: var(--fw-bold);
  text-transform: none;
  letter-spacing: normal;
}

/* ---- Ô nhập -------------------------------------------------------------- */

.tbtc-search__form {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0;
  padding: var(--sp-2);
  border: 1px solid var(--c-border-2);
  border-radius: var(--r-lg);
  background: var(--c-white);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.tbtc-search__form:focus-within {
  border-color: var(--c-blue);
  box-shadow: 0 0 0 4px var(--c-blue-100);
}

.tbtc-search__icon {
  display: flex;
  flex-shrink: 0;
  padding-left: var(--sp-2);
  opacity: 0.55;
}

.tbtc-search__input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  height: 48px;
  margin: 0;
  padding: 0 var(--sp-2);
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none !important;
  color: var(--c-text);
  font-family: inherit;
  font-size: var(--fs-body-lg);
  line-height: var(--lh-body-lg);
}

.tbtc-search__input[type="search"]:focus {
  outline: none;
}

.tbtc-search__submit {
  flex: 0 0 auto;
  height: 48px;
  min-height: 0;
  min-width: 0;
  margin: 0;
  padding: 0 var(--sp-6);
  border: 0;
  border-radius: var(--r-md);
  background-image: linear-gradient(77deg, #6f2e7d 0%, #913791 69.862%, #b151bf 100%);
  box-shadow: var(--sh-button);
  color: var(--c-white);
  font-family: inherit;
  font-size: var(--fs-body-md);
  line-height: var(--lh-body-md);
  font-weight: var(--fw-semibold);
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}

.tbtc-search__submit:hover {
  filter: brightness(1.06);
}

/* ---- Chú thích + liên kết gợi ý ------------------------------------------ */

.tbtc-search__hint {
  margin: var(--sp-3) 0 0;
  color: var(--c-desc);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
}

.tbtc-search__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
}

.tbtc-search__links-label {
  color: var(--c-desc);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
}

.tbtc-search__link {
  padding: 6px var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--r-pill);
  background: var(--c-blue-50);
  color: var(--c-blue);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  text-decoration: none;
}

.tbtc-search__link:hover {
  border-color: var(--c-blue);
  background: var(--c-blue-100);
  color: var(--c-blue);
}

/* --------------------------------------------------------------------------
   Mobile
   -------------------------------------------------------------------------- */

@media only screen and (max-width: 48em) {
  .tbtc-search {
    padding: var(--sp-16) var(--gutter) var(--sp-8);
  }

  .tbtc-search__panel {
    padding: var(--sp-6) var(--sp-5) var(--sp-5);
  }

  .tbtc-search__title {
    font-size: var(--fs-h1);
    line-height: var(--lh-h1);
  }

  /* Khổ 393px: kính lúp + ô nhập chung một hàng, nút xuống hàng dưới.
     Phải cho ô nhập `flex: 1 1 0` — để `auto` thì nó lấy bề rộng theo chữ gợi ý
     và tự rớt xuống dòng riêng, nhìn rời rạc. */
  .tbtc-search__form {
    flex-wrap: wrap;
  }

  .tbtc-search__input[type="search"] {
    flex: 1 1 0;
    height: 44px;
  }

  .tbtc-search__submit {
    flex: 1 1 100%;
    height: 44px;
  }
}
