/* Root tokens (tweak to match your palette) */
:root {
  --si-bg: var(--wp--preset--color--deep-black); /* input bg */
  --si-border: rgba(255, 255, 255, 0.2); /* passive border */
  --si-border-active: var(--wp--preset--color--white); /* typing border */
  --si-text: var(--wp--preset--color--white); /* text color */
  --si-muted: rgba(255, 255, 255, 0.6); /* placeholder */
  --si-radius: 2px;
  --si-h: 40px; /* control height */
  --si-w: 300px; /* OPEN width (overridden by MQ) */
}

/* Base form wrapper */
.si-form {
  display: inline-block;
  font: inherit;
}

/* Component shell (state classes: .is-active, .is-typing) */
.si-wrap {
  margin-right: 20px;
  position: relative;
  display: inline-flex;
  align-items: center;
  height: var(--si-h);
  color: var(--si-text);

  /* Animate width via variables to avoid max-width flicker */
  --si-open: var(--si-w); /* animated-to width when active */
  --si-closed: 40px; /* animated-to width when inactive */
}

/* Trigger: only the SVG is clickable (no padding hit area) */
.si-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--si-h);
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--si-text);
  cursor: pointer;
}

.si-trigger .si-trigger-label {
  display: none;
  font-size: 14px;
}

.si-ico {
  display: block; /* remove inline whitespace */
  width: 24px;
  height: 24px;
  z-index: 3;
}

/* Input (default: closed state) */
.si-input {
  width: var(--si-closed);
  opacity: 0;
  height: var(--si-h);
  border-radius: var(--si-radius);
  border: 1px solid transparent;
  background: transparent;
  outline: none;
  color: var(--si-text);
  font-size: 14px;
  transition: width 0.3s ease, opacity 0.3s ease, border-color 0.3s ease,
    background-color 0.3s ease;
  -webkit-appearance: none;
  appearance: none;
  margin-left: 8px;
  overflow: hidden;
}

/* Clear button (X) */
.si-clear {
  position: absolute;
  right: 12px;
  height: 24px;
  width: 24px;
  border: 0;
  border-radius: 1px;
  background: transparent;
  color: var(--si-text);
  opacity: 0;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Left icon placement (keep trigger in place as the left icon) */
.si-wrap .si-trigger {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}

/* ACTIVE (selected) */
.si-wrap.is-active .si-input {
  width: var(--si-open); /* animate to the open width var */
  opacity: 1;
  background: var(--si-bg);
  border: 1px solid var(--si-border);
  padding: 0 36px 0 42px; /* room for left icon + clear button */
}

/* Typing state */
.si-wrap.is-typing .si-input {
  border-color: var(--si-border-active);
}

/* Clear button visible only when active */
.si-wrap.is-active .si-clear {
  opacity: 1;
  pointer-events: auto;
}

/* Focus styles (accessible but minimal) */
.si-input:focus-visible,
.si-clear:focus-visible,
.si-trigger:focus-visible {
  outline: none;
  outline-offset: 0;
}

/* Hide native clear + other search adornments */
.si-input::-webkit-search-cancel-button,
.si-input::-webkit-search-decoration,
.si-input::-webkit-search-results-button,
.si-input::-webkit-search-results-decoration {
  display: none;
}

.si-input::-ms-clear,
.si-input::-ms-reveal {
  display: none;
  width: 0;
  height: 0;
}

/* Responsive: reduce open width on smaller viewports */
@media (max-width: 730px) {
  :root {
    --si-w: 246px; /* open width becomes 246px below 730px */
  }
  .si-wrap.is-active .si-input {
    width: 246px;
  }

  .si-wrap {
    margin-right: 0;
  }
}

@media (max-width: 373px) {
  :root {
    --si-w: 230px;
  }
  .si-wrap.is-active .si-input {
    width: 230px;
  }
}

/* ≤360px: while search is open/closing, hide header icon(s) to free space */
@media (max-width: 360px) {
  :root {
    --si-w: 200px;
  }
  .si-wrap.is-active .si-input {
    width: 200px;
  }
}
@media (max-width: 320px) {
  :root {
    --si-w: 180px;
  }
  .si-wrap.is-active .si-input {
    width: 180px;
  }
}
