/*
 * CPTN Shop Search – header search of the Captain Shop theme (#shop-search).
 *
 * Layers (bottom → top): goo blobs (pill + bubble, SVG goo filter) → spinning ring →
 * input + typewriter hint → submit button (the magnifier, moves into the bubble).
 * Open = focus inside the form or a typed value; pure CSS, so it also works before
 * and without search.js. search.js adds .is-ready together with the decorative layers.
 */

.header #shop-search {
  --cptn-h: 44px;
  --cptn-gap: 12px;
  /* Collapsed pill width; centred in the header slot (max 560px on desktop). */
  --cptn-cw: min(100%, 360px);
  --cptn-cl: calc((100% - var(--cptn-cw)) / 2);
  --cptn-surface: #30303b;
  --cptn-bubble: var(--cptn-surface);
  --cptn-fg: #fff;
  --cptn-hint: rgb(255 255 255 / 72%);
  --cptn-track: rgb(255 255 255 / 16%);
  --cptn-spin: 3.2s;
  --cptn-dur: 560ms;
  --cptn-spring: cubic-bezier(0.34, 1.45, 0.64, 1);

  position: relative;
  isolation: isolate;
  gap: 0;
  width: 100%;
  min-width: 0;
  height: var(--cptn-h);
  color: var(--cptn-fg);
}

@media (max-width: 599px) {
  .header #shop-search {
    --cptn-cw: 100%;
  }
}

/* Field: the input itself draws the pill until search.js takes over (no flash). */
.header #shop-search input[name='s'] {
  position: absolute;
  top: 0;
  left: var(--cptn-cl);
  right: var(--cptn-cl);
  z-index: 1;
  width: auto;
  height: var(--cptn-h);
  min-height: 0;
  margin: 0;
  padding: 0 1rem 0 var(--cptn-h);
  border: 1px solid var(--cptn-track);
  border-radius: 999px;
  background: var(--cptn-surface);
  color: var(--cptn-fg);
  font-size: 1rem; /* ≥16px: no zoom on focus in iOS Safari */
  line-height: normal;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.header #shop-search input[name='s']::placeholder {
  color: var(--cptn-hint);
  opacity: 1;
}
.header #shop-search input[name='s']::-webkit-search-decoration {
  -webkit-appearance: none;
}
.header #shop-search input[name='s']::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-left: 0.5rem;
  background: currentColor;
  opacity: 0.7;
  cursor: pointer;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M5 5l14 14M19 5 5 19'/%3E%3C/svg%3E")
    center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M5 5l14 14M19 5 5 19'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

/* Submit: a round magnifier button; "Hledat" stays as its accessible name. */
.header #shop-search button[type='submit'] {
  position: absolute;
  top: 0;
  left: var(--cptn-cl);
  z-index: 2;
  /* flex, not grid: the zero-size "Hledat" text would become a second grid row. */
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--cptn-h);
  height: var(--cptn-h);
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--cptn-fg);
  font-size: 0;
}
.header #shop-search button[type='submit']::before {
  content: '';
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7.5'/%3E%3Cpath d='m20.5 20.5-4.2-4.2'/%3E%3C/svg%3E")
    center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7.5'/%3E%3Cpath d='m20.5 20.5-4.2-4.2'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

/* Open: magnifier pops out into its own bubble on the left, the field fills the slot. */
.header
  #shop-search:is(:focus-within, :has(input[name='s']:not(:placeholder-shown)))
  input[name='s'] {
  left: calc(var(--cptn-h) + var(--cptn-gap));
  right: 0;
  padding-left: 1.15rem;
  border-color: rgb(255 255 255 / 55%);
}
.header
  #shop-search:is(:focus-within, :has(input[name='s']:not(:placeholder-shown)))
  button[type='submit'] {
  left: 0;
  background: var(--cptn-bubble);
}

/* ---- Enhanced (search.js loaded) ------------------------------------------------ */

.header #shop-search.is-ready input[name='s'],
.header
  #shop-search.is-ready:is(:focus-within, :has(input[name='s']:not(:placeholder-shown)))
  input[name='s'] {
  border-color: transparent;
  background: transparent;
}
.header
  #shop-search.is-ready:is(:focus-within, :has(input[name='s']:not(:placeholder-shown)))
  button[type='submit'] {
  background: transparent;
}
/* Collapsed: the typewriter hint replaces the static placeholder. */
.header #shop-search.is-ready:not(:focus-within) input[name='s']::placeholder {
  color: transparent;
}
.header
  #shop-search.is-ready:not(:focus-within, :has(input[name='s']:not(:placeholder-shown)))
  input[name='s'] {
  cursor: pointer;
}

.cptn-search__defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.cptn-search__goo {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  filter: url(#cptn-search-goo);
}
.cptn-search__pill,
.cptn-search__bubble {
  position: absolute;
  top: 0;
  height: var(--cptn-h);
  border-radius: 999px;
}
.cptn-search__pill {
  left: var(--cptn-cl);
  right: var(--cptn-cl);
  background: var(--cptn-surface);
}
/* Hidden inside the pill under the magnifier until the form opens. */
.cptn-search__bubble {
  left: var(--cptn-cl);
  width: var(--cptn-h);
  background: var(--cptn-bubble);
  transform: scale(0.3);
}

/* Ring: faint track + a white comet spinning around the field ("loading" light). */
.cptn-search__ring {
  position: absolute;
  top: 0;
  left: var(--cptn-cl);
  right: var(--cptn-cl);
  z-index: 1;
  height: var(--cptn-h);
  padding: 1.5px;
  border-radius: 999px;
  overflow: hidden;
  pointer-events: none;
  background: var(--cptn-track);
  -webkit-mask-image: linear-gradient(#000 0 0), linear-gradient(#000 0 0);
  -webkit-mask-clip: content-box, border-box;
  -webkit-mask-composite: xor;
  mask-image: linear-gradient(#000 0 0), linear-gradient(#000 0 0);
  mask-clip: content-box, border-box;
  mask-composite: exclude;
}
.cptn-search__ring::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 120%;
  aspect-ratio: 1;
  background: conic-gradient(
    from 0deg,
    transparent 0turn 0.6turn,
    rgb(255 255 255 / 18%) 0.8turn,
    rgb(255 255 255 / 95%) 0.97turn,
    transparent 1turn
  );
  transform: translate(-50%, -50%);
  animation: cptn-search-spin var(--cptn-spin) linear infinite;
}

/* Typewriter hint, aligned with the input text. */
.cptn-search__hint {
  position: absolute;
  top: 0;
  left: calc(var(--cptn-cl) + var(--cptn-h));
  right: calc(var(--cptn-cl) + 1rem);
  z-index: 1;
  display: flex;
  align-items: center;
  height: var(--cptn-h);
  overflow: hidden;
  white-space: nowrap;
  pointer-events: none;
  color: var(--cptn-hint);
  font-size: 1rem;
  -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
  mask-image: linear-gradient(90deg, #000 85%, transparent);
}
.cptn-search__caret {
  flex: none;
  width: 1.5px;
  height: 1.15em;
  margin-left: 2px;
  background: currentColor;
  animation: cptn-search-blink 1s steps(1) infinite;
}
.header #shop-search.is-typing .cptn-search__caret {
  animation: none;
}

/* Open state of the enhanced layers. */
.header
  #shop-search:is(:focus-within, :has(input[name='s']:not(:placeholder-shown)))
  :is(.cptn-search__pill, .cptn-search__ring) {
  left: calc(var(--cptn-h) + var(--cptn-gap));
  right: 0;
}
.header
  #shop-search:is(:focus-within, :has(input[name='s']:not(:placeholder-shown)))
  .cptn-search__bubble {
  left: 0;
  transform: scale(1);
}
/* Hidden at once on open (the real placeholder appears in the same spot), faded back in on close. */
.header
  #shop-search:is(:focus-within, :has(input[name='s']:not(:placeholder-shown)))
  .cptn-search__hint {
  left: calc(var(--cptn-h) + var(--cptn-gap) + 1.15rem);
  right: 1rem;
  opacity: 0;
  transition: none;
}
.header #shop-search:is(:focus-within, :hover) {
  --cptn-track: rgb(255 255 255 / 30%);
}
.header #shop-search:focus-within {
  --cptn-track: rgb(255 255 255 / 45%);
}
/* Submitted: the ring turns into a fast spinner until the results page loads. */
.header #shop-search.is-loading {
  --cptn-spin: 0.8s;
}
.header #shop-search.is-offscreen .cptn-search__ring::before {
  animation-play-state: paused;
}

/* Motion: springy movement only once the enhanced layers exist (no animation on load). */
.header
  #shop-search.is-ready
  :is(
    input[name='s'],
    button[type='submit'],
    .cptn-search__pill,
    .cptn-search__bubble,
    .cptn-search__ring,
    .cptn-search__hint
  ) {
  transition:
    left var(--cptn-dur) var(--cptn-spring),
    right var(--cptn-dur) var(--cptn-spring),
    padding var(--cptn-dur) var(--cptn-spring),
    transform var(--cptn-dur) var(--cptn-spring),
    opacity 180ms ease;
}
.header #shop-search.is-ready span.cptn-search__ring {
  transition:
    left var(--cptn-dur) var(--cptn-spring),
    right var(--cptn-dur) var(--cptn-spring),
    background-color 200ms ease;
}

@keyframes cptn-search-spin {
  to {
    transform: translate(-50%, -50%) rotate(1turn);
  }
}
@keyframes cptn-search-blink {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .header
    #shop-search.is-ready
    :is(
      input[name='s'],
      button[type='submit'],
      .cptn-search__pill,
      .cptn-search__bubble,
      .cptn-search__ring,
      .cptn-search__hint
    ) {
    transition-duration: 0.01ms;
  }
  .cptn-search__ring::before,
  .cptn-search__caret {
    animation: none;
  }
  .cptn-search__caret {
    opacity: 0;
  }
}

/* ---- Header tweaks (Petr, approved by Lukáš 2026-11-09) ---------------------------
 * Not search-specific: they live here only because the theme source is not in this repo.
 * Move them into captain-shop/assets/css/layout.css at the next theme release and delete
 * this block.
 */

/* No light line under the dark header. */
.header {
  border-bottom: 0;
}
/* Account and cart icons without a frame; a soft background marks hover instead. */
.header .icon-link {
  border: 0;
  transition: background-color 150ms ease;
}
.header .icon-link:hover {
  background: rgb(255 255 255 / 10%);
}
