/* ============================================================
   CANOPY — search focus expand (Affiche)
   Soft organic widen on click/focus. No drips, no dark capsule.
   ============================================================ */

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 100%;
  margin-inline: auto;
  background: transparent;
  border: none;
  border-bottom: 2.5px solid var(--espresso);
  border-radius: 0;
  padding: 0 0 0.35rem;
  transform-origin: center center;
  transition:
    max-width 0.55s var(--ease-alive, cubic-bezier(0.22, 1, 0.36, 1)),
    padding 0.45s var(--ease-alive, cubic-bezier(0.22, 1, 0.36, 1)),
    gap 0.45s var(--ease-alive, cubic-bezier(0.22, 1, 0.36, 1)),
    border-bottom-color 0.35s var(--ease),
    background 0.35s var(--ease);
  will-change: max-width, transform;
}

/* Rest a touch narrower so focus can bloom */
body:not(.is-browsing) .home-stage .search-wrap {
  max-width: 92%;
}

body:not(.is-browsing) .home-stage .search-wrap.is-open,
body:not(.is-browsing) .home-stage .search-wrap:focus-within {
  max-width: 100%;
  padding: 0.15rem 0.85rem 0.55rem;
  gap: 0.9rem;
  border-bottom-color: var(--terre);
  background: color-mix(in srgb, var(--surface, #fff8f2) 70%, transparent);
  border-radius: var(--radius-ui, 0.75rem) var(--radius-ui, 0.75rem) 0 0;
}

.search-wrap::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 3px;
  background: var(--terre);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.55s var(--ease-alive, cubic-bezier(0.22, 1, 0.36, 1));
  pointer-events: none;
  border-radius: 999px;
}
.search-wrap.is-open::after,
.search-wrap:focus-within::after {
  transform: scaleX(1);
}

#search {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--espresso);
  font: 500 clamp(1.15rem, 2vw + 0.6rem, 1.5rem) / 1.3 'Familjen Grotesk', sans-serif;
  padding: 0.55rem 0;
  transition: padding 0.45s cubic-bezier(0.22, 1.2, 0.36, 1);
  -webkit-appearance: none;
  appearance: none;
}
.search-wrap.is-open #search,
.search-wrap:focus-within #search {
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
}
#search::placeholder {
  color: var(--espresso-30);
  font-weight: 400;
}
#search::-webkit-search-decoration,
#search::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search-clear {
  flex: none;
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: var(--line);
  font-size: 1rem;
  color: var(--espresso);
  background: var(--milk);
}
.search-clear.on { display: flex; }
.search-clear:hover { background: var(--miel); }

.search-go {
  flex: none;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: var(--terre);
  color: var(--milk);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transform-origin: center;
  transition:
    transform 0.55s cubic-bezier(0.22, 1.2, 0.36, 1),
    background var(--t-fast) var(--ease),
    width 0.45s cubic-bezier(0.22, 1.2, 0.36, 1),
    height 0.45s cubic-bezier(0.22, 1.2, 0.36, 1);
}
.search-go svg { width: 20px; height: 20px; }
.search-wrap.is-open .search-go,
.search-wrap:focus-within .search-go {
  width: 50px;
  height: 50px;
  transform: translateX(2px);
}
.search-go:hover {
  background: var(--espresso);
}

.search-leaf { display: none !important; }

/* Kill leftover ripple pseudo from fluide — expand owns focus now */
.search-wrap::before {
  content: none !important;
  display: none !important;
}

@media (max-width: 720px) {
  body:not(.is-browsing) .home-stage .search-wrap {
    max-width: 96%;
  }
  .search-go { width: 42px; height: 42px; }
  .search-wrap.is-open .search-go,
  .search-wrap:focus-within .search-go {
    width: 46px;
    height: 46px;
  }
  #search { font-size: clamp(1.05rem, 4.2vw, 1.25rem); }
}

@media (max-width: 380px) {
  .search-go { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .search-wrap,
  .search-wrap::after,
  #search,
  .search-go {
    transition: none !important;
  }
}
