/* ==========================================================================
   Global site search  -  Roadmap IT Solutions
   Paired with /assets/js/site-search.js. All selectors are namespaced `rms-`
   so nothing here can leak into the existing header, menus or page layouts.
   Theme tokens mirror assets/css/style.css (--primary / --dark / Urbanist).
   ========================================================================== */

.rms-root {
  --rms-primary: var(--primary, #ff9103);
  --rms-dark: var(--dark, #011a41);
  --rms-text: #0e191e;
  --rms-muted: #6b6b6b;
  --rms-border: #e6e8ec;
  --rms-surface: #fff;
  --rms-backdrop: rgba(1, 26, 65, 0.45);
  --rms-radius: 16px;
  --rms-shadow: 0 24px 60px rgba(1, 26, 65, 0.18);
  --rms-font: 'Urbanist', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* --------------------------------------------------- header trigger button */
.rms-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  margin: 0 10px 0 auto; /* below lg: sits beside the burger with a small gap */
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--rms-text, #0e191e);
  cursor: pointer;
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
  -webkit-appearance: none;
  appearance: none;
}
.rms-trigger svg { width: 21px; height: 21px; display: block; }
.rms-trigger:hover,
.rms-trigger[aria-expanded='true'] {
  background: #fff6e9;
  border-color: var(--primary, #ff9103);
  color: var(--dark, #011a41);
}
.rms-trigger:focus-visible {
  outline: 2px solid var(--primary, #ff9103);
  outline-offset: 2px;
}
@media (min-width: 1024px) {
  /* The header is justify-between, so a fourth child would otherwise claim an
     equal share of the free space and float mid-header (and push the nav left).
     Two auto margins instead keep the original logo | nav | buttons rhythm and
     glue the icon to the SignUp / Free Trial pair. The 4px top margin matches
     the CTA group's own mt-1, so all three sit on one centre line. */
  /* !important only because the template's own ms-5 utility is !important */
  #stickyHeader > header > .gap-6 { margin-inline-start: auto !important; }
  .rms-trigger { margin: 4px 16px 0 auto; }
}

/* ------------------------------------------------------------- the overlay */
.rms-root {
  position: fixed;
  inset: 0;
  z-index: 2147483000; /* above #dotCanvas and the sticky header */
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: clamp(16px, 9vh, 110px) 16px 24px;
  font-family: var(--rms-font);
  background: var(--rms-backdrop);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  /* visibility flips instantly on open and only after the fade on close, so the
     input is focusable the moment the dialog is shown */
  transition: opacity 0.22s ease, visibility 0s linear 0.22s;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.rms-root[data-open='true'] {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.22s ease, visibility 0s linear 0s;
}

.rms-dialog {
  width: 100%;
  max-width: 640px;
  transform: translateY(-10px) scale(0.985);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
.rms-root[data-open='true'] .rms-dialog { transform: none; }

/* --------------------------------------------------------------- the input */
.rms-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--rms-surface);
  border: 2px solid var(--rms-border);
  border-radius: var(--rms-radius);
  box-shadow: var(--rms-shadow);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.rms-field:focus-within {
  border-color: var(--rms-primary);
  box-shadow: var(--rms-shadow), 0 0 0 4px rgba(255, 145, 3, 0.18);
}
.rms-field__icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: var(--rms-muted);
}
.rms-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 16px 0;
  font-family: inherit;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--rms-text);
  -webkit-appearance: none;
  appearance: none;
}
.rms-input::placeholder { color: #9aa1ab; font-weight: 400; }
.rms-input::-webkit-search-cancel-button { display: none; }

.rms-clear {
  flex: 0 0 auto;
  display: none;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #e9ecf1;
  color: #5d6773;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.rms-clear svg { width: 13px; height: 13px; display: block; }
.rms-clear:hover { background: var(--rms-dark); color: #fff; }
.rms-clear:focus-visible { outline: 2px solid var(--rms-primary); outline-offset: 2px; }
.rms-root[data-filled='true'] .rms-clear { display: inline-flex; }

/* --------------------------------------------------------------- the panel */
.rms-panel {
  margin-top: 14px;
  background: var(--rms-surface);
  border: 1px solid var(--rms-border);
  border-radius: var(--rms-radius);
  box-shadow: var(--rms-shadow);
  overflow: hidden;
}
.rms-results {
  margin: 0;
  padding: 8px;
  list-style: none;
  max-height: min(52vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.rms-group {
  padding: 12px 12px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #98a1ad;
}
.rms-option { border-radius: 12px; }
.rms-option > a {
  display: block;
  padding: 11px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
}
.rms-option[aria-selected='true'] > a,
.rms-option > a:hover {
  background: #fff6e9;
  box-shadow: inset 0 0 0 1px rgba(255, 145, 3, 0.35);
}
.rms-option__top {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.rms-option__title {
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--rms-dark);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rms-option__tag {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f2f4f7;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6b7482;
}
.rms-option__desc {
  margin: 3px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--rms-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.rms-option__url {
  margin: 4px 0 0;
  font-size: 11.5px;
  color: #9aa1ab;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rms-option mark {
  padding: 0 1px;
  border-radius: 3px;
  background: rgba(255, 145, 3, 0.26);
  color: inherit;
  font-weight: 700;
}

/* ------------------------------------------------- empty / loading / error */
.rms-state {
  position: relative;
  padding: 54px 24px 58px;
  text-align: center;
}
.rms-state::before,
.rms-state::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  border: 1px solid #f0f2f5;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.rms-state::before { width: 190px; height: 190px; }
.rms-state::after { width: 300px; height: 300px; }
.rms-state__icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  margin-bottom: 18px;
  border: 1px solid var(--rms-border);
  border-radius: 14px;
  background: #fff;
  color: #98a1ad;
}
.rms-state__icon svg { width: 22px; height: 22px; }
.rms-state__title {
  position: relative;
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--rms-dark);
}
.rms-state__text {
  position: relative;
  margin: 6px auto 0;
  max-width: 340px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--rms-muted);
}
.rms-state__action {
  position: relative;
  margin-top: 18px;
  padding: 9px 18px;
  border: 1px solid var(--rms-border);
  border-radius: 10px;
  background: #fff;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--rms-dark);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
.rms-state__action:hover { border-color: var(--rms-primary); background: #fff6e9; }
.rms-state__action:focus-visible { outline: 2px solid var(--rms-primary); outline-offset: 2px; }

.rms-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid #e6e8ec;
  border-top-color: var(--rms-primary);
  border-radius: 50%;
  animation: rms-spin 0.7s linear infinite;
}
@keyframes rms-spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- the hints */
.rms-footer {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 14px;
  border-top: 1px solid var(--rms-border);
  background: #fbfcfd;
  font-size: 12px;
  color: #8b94a1;
}
.rms-hint { display: inline-flex; align-items: center; gap: 6px; }
.rms-hint:last-child { margin-left: auto; }
.rms-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border: 1px solid var(--rms-border);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: #fff;
  font-size: 11px;
  font-weight: 600;
  color: #5d6773;
}

.rms-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

html.rms-locked,
body.rms-locked { overflow: hidden !important; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 767px) {
  .rms-root { padding: 14px 14px 20px; align-items: stretch; }
  .rms-dialog { max-width: none; }
  .rms-input { font-size: 16px; padding: 14px 0; } /* 16px avoids iOS zoom */
  .rms-results { max-height: calc(100vh - 250px); }
  @supports (height: 100dvh) {
    .rms-results { max-height: calc(100dvh - 250px); }
  }
  .rms-state { padding: 40px 16px 44px; }
  .rms-state::after { display: none; }
  .rms-footer { font-size: 11px; gap: 12px; padding: 9px 12px; }
  .rms-hint--nav { display: none; }
}
@media (max-width: 420px) {
  .rms-option__tag { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .rms-root,
  .rms-dialog,
  .rms-trigger,
  .rms-clear { transition: none; }
  .rms-spinner { animation-duration: 2s; }
}

@media print {
  .rms-root, .rms-trigger { display: none !important; }
}
