/* The category picker, search input, and cart toggle live inline
   in `.topbar__inner` — see layout.css for the row's layout. The
   toggle stays in the same spot whether the cart is open or
   closed; when the cart is open, hovering the button morphs the
   cart glyph into an × (mirrors the magnifier → × treatment on a
   non-empty search input). */
/* Bare cart toggle — no glass pill; just a 48×48 hit area. */
.cart-toggle {
  flex-shrink: 0;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--ink);
  transition: background .12s ease;
}
.cart-toggle:hover { background: color-mix(in oklch, var(--ink) 6%, transparent); border-radius: var(--r-md); }
.cart-toggle .icon { width: 32px; height: 32px; }
.cart-toggle__cart,
.cart-toggle__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cart-toggle__close { display: none; }
html[data-rail-right="expanded"] .cart-toggle:hover .cart-toggle__cart {
  display: none;
}
html[data-rail-right="expanded"] .cart-toggle:hover .cart-toggle__close {
  display: inline-flex;
}

/* Inline suggestion chips below the search row — most-frequent
   words across the active category's products. Clicking a chip
   patches q= so it folds into the existing search flow. */
.suggestions {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 0 0 40px;
}
.suggestion-chip {
  display: inline-flex; align-items: center;
  background: color-mix(in oklch, var(--surface) 70%, transparent);
  backdrop-filter: saturate(140%) blur(18px);
  -webkit-backdrop-filter: saturate(140%) blur(18px);
  box-shadow: 0 0 0 1px var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12.5px;
  color: var(--ink-2);
  text-decoration: none;
  transition: background .12s ease, color .12s ease;
  text-transform: capitalize;
}
.suggestion-chip:hover {
  background: var(--surface);
  color: var(--ink);
}

/* The category dropdown sits to the left of the search input. The
   shell carries the same glass treatment as `.search`. When a
   category is active a leading × link clears the filter; when not,
   only the toggle button is rendered. */
.search-cat-button {
  display: inline-flex; align-items: stretch;
  background: color-mix(in oklch, var(--surface) 70%, transparent);
  backdrop-filter: saturate(140%) blur(18px);
  -webkit-backdrop-filter: saturate(140%) blur(18px);
  border-radius: var(--r-md);
  box-shadow: 0 0 0 1px var(--border), 0 12px 32px rgba(0, 0, 0, 0.06);
  min-height: 48px;
  white-space: nowrap;
}

.search-cat-button__toggle {
  appearance: none; cursor: pointer;
  background: transparent; border: 0; outline: none;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0 10px 0 16px;
  font: inherit; font-size: 15px; font-weight: 400;
  letter-spacing: .005em;
  color: var(--ink);
  border-radius: inherit;
}
.search-cat-button--filtered .search-cat-button__toggle {
  padding-left: 4px;
}

/* The leading × and the trailing chevron share a 28px circular
   tap-target with the same hover treatment, so they feel like
   matching ornaments on either end of the pill. */
.search-cat-button__x,
.search-cat-button__chev {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  margin: 0 4px; align-self: center;
  border-radius: 50%;
  transition: background .12s ease, color .12s ease;
}
.search-cat-button__x {
  color: var(--ink-2); text-decoration: none;
  font-size: 18px; line-height: 1; font-weight: 400;
}
.search-cat-button__x:hover,
.search-cat-button__toggle:hover .search-cat-button__chev {
  background: var(--soft); color: var(--ink);
}
.search-cat-button__chev::before {
  content: "";
  width: 8px; height: 8px;
  border-right: 1.5px solid var(--ink-3);
  border-bottom: 1.5px solid var(--ink-3);
  transform: translateY(-2px) rotate(45deg);
  transition: transform .12s ease;
}
.cat-picker[data-open] .search-cat-button__chev::before {
  transform: translateY(2px) rotate(-135deg);
}

.picker {
  position: relative;
  display: inline-block;
}
.picker__trigger {
  appearance: none; background: transparent; border: 0; outline: none;
  font: inherit;
  cursor: pointer;
  display: inline-flex; align-items: baseline; gap: 4px;
  color: var(--ink); font-weight: 600;
  padding: 0 14px 0 0;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
  text-decoration-color: var(--ink-3);
  position: relative;
}
.picker__trigger:hover { text-decoration-color: var(--ink); }
.picker__trigger::after {
  content: ""; position: absolute; right: 0; top: 50%;
  width: 7px; height: 7px;
  border-right: 1.5px solid var(--ink-3);
  border-bottom: 1.5px solid var(--ink-3);
  transform: translateY(-75%) rotate(45deg);
  transition: transform .12s ease;
}
.picker[data-open] .picker__trigger::after { transform: translateY(-25%) rotate(-135deg); }

.picker__panel {
  display: none;
  /* The cat picker now sits on the right side of the search row,
     so anchor the panel from the right edge — otherwise it
     overflows past the layout container. */
  position: absolute; right: 0; top: calc(100% + 8px);
  z-index: 20;
  background: var(--surface);
  border-radius: 14px;
  box-shadow:
    0 0 0 1px var(--border),
    0 18px 48px rgba(0, 0, 0, .12);
  padding: 8px;
  font-size: 14px; line-height: 1.3;
  color: var(--ink);
  letter-spacing: 0;
  font-weight: 400;
  min-width: 240px;
}
.picker[data-open] .picker__panel { display: block; }

/* Chain panel: simple vertical list of links. */
.chain-panel { min-width: 220px; display: flex; flex-direction: column; }
.chain-panel__row {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
}
.chain-panel__row:hover { background: var(--soft); }
.chain-panel__row.is-active { background: var(--bg-selected); font-weight: 600; }

/* Category panel: bento — one full-width "Todas las categorías"
   tile at the top, then a 3-column grid where each tile is a
   category header with its subcategories listed underneath. */
.cat-panel { width: min(1100px, 90vw); }
.cat-panel__all {
  display: block;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--soft);
  text-decoration: none;
  color: var(--ink); font-weight: 600;
  margin-bottom: 8px;
  text-align: left;
}
.cat-panel__all:hover { background: var(--bg-selected); }
.cat-panel__all.is-active { background: var(--bg-selected); }
.cat-panel__grid {
  column-count: 4;
  column-gap: 8px;
}
.cat-tile {
  break-inside: avoid;
  background: var(--soft);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.cat-tile__head {
  display: block;
  color: var(--ink); font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  padding: 4px 6px;
  border-radius: 6px;
  margin: -4px -6px 2px;
}
.cat-tile__head:hover { background: var(--surface); }
.cat-tile__head.is-active { background: var(--bg-selected); }
.cat-tile__subs {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column;
}
.cat-tile__sub {
  display: block;
  color: var(--ink-2); font-weight: 400;
  font-size: 12.5px;
  text-decoration: none;
  padding: 3px 6px;
  border-radius: 5px;
}
.cat-tile__sub:hover { background: var(--surface); color: var(--ink); }
.cat-tile__sub.is-active { background: var(--bg-selected); color: var(--ink); font-weight: 500; }


/* Glass treatment matches the rail asides — same border-radius,
   translucent surface, blur backdrop, and outset 1px border via
   box-shadow. Content scrolls under and gets blurred.

   The magnifier icon and the ⌘K hint float over the input so the
   <input> can stretch edge-to-edge and capture clicks across the
   full bar (including the icon and kbd regions). The input's
   `padding-left` / `padding-right` reserves visual space so typed
   text doesn't run under either ornament. */
.search {
  display: block;
  position: relative;
  flex: 1; min-width: 0;
  background: color-mix(in oklch, var(--surface) 70%, transparent);
  backdrop-filter: saturate(140%) blur(18px);
  -webkit-backdrop-filter: saturate(140%) blur(18px);
  border-radius: var(--r-md);
  box-shadow: 0 0 0 1px var(--border), 0 12px 32px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  transition: box-shadow .14s ease;
}

/* Phoenix LiveView adds `phx-change-loading` to the form while a
   change event is in flight. We use that to glow the border in the
   brand red and slide a thin gradient bar across the bottom edge —
   the input feels alive while results are coming back. */
.search.phx-change-loading {
  box-shadow:
    0 0 0 1.5px #e14a2b,
    0 12px 32px rgba(225, 74, 43, 0.12);
}
.search::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    #e14a2b 30%,
    #ffd43b 70%,
    transparent 100%);
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}
.search.phx-change-loading::after {
  opacity: 1;
  animation: search-progress 1.05s ease-in-out infinite;
}
@keyframes search-progress {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Magnifier — same 36×36 footprint and 20×20 glyph as the rail-toggle
   button, floated over the input so it doesn't steal clicks. */
.search .mag {
  position: absolute;
  top: 6px; left: 12px;
  pointer-events: none;
  width: 36px; height: 36px;
  box-sizing: border-box;
}
.search .mag::before {
  content: "";
  position: absolute;
  top: 8px; left: 8px;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1.8px solid var(--ink-2);
}
.search .mag::after {
  content: "";
  position: absolute;
  top: 23px; left: 23px;
  width: 1.8px; height: 7px;
  background: var(--ink-2);
  transform: rotate(-45deg);
  border-radius: 2px;
}

/* Clearable variant — when there's a query, the magnifier becomes
   a clickable link that morphs into an × on hover and clears `q`
   on click. The magnifier glyph is rebuilt from the same two
   pseudo-elements: on hover both turn into a 16px line crossed at
   ±45° to read as an ×. */
.search .mag--clearable {
  pointer-events: auto;
  cursor: pointer;
  display: block;
}
.search .mag--clearable:hover::before {
  top: 17px; left: 10px;
  width: 16px; height: 1.8px;
  border: 0; border-radius: 2px;
  background: var(--ink-2);
  transform: rotate(45deg);
}
.search .mag--clearable:hover::after {
  top: 17px; left: 10px;
  width: 16px; height: 1.8px;
  background: var(--ink-2);
  transform: rotate(-45deg);
  border-radius: 2px;
}

/* Input fills the bar edge-to-edge so any click anywhere inside the
   pill focuses it. Padding leaves room for the floating icon on the
   left and the kbd hint on the right. */
.search input {
  display: block;
  width: 100%;
  border: 0; outline: none; background: transparent;
  padding: 6px 64px 6px 56px;
  min-height: 48px;
  box-sizing: border-box;
  font-size: 15px;
  letter-spacing: .005em;
}
.search input::placeholder { color: var(--ink-3); }

/* ⌘K hint — floated like the magnifier so it doesn't intercept
   clicks meant for the input. */
.search .kbd {
  position: absolute;
  top: 50%; right: 12px;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--ink-3); font-size: 12px; padding: 3px 8px;
  background: var(--soft); border-radius: 6px;
}
