/* Saving the search above the list (frontend/src/components/catalog/SavedSearchCard.tsx). A wide screen: one row —
   the title, the ways the new listings come, the button. Narrower: the ways under the title row. A phone: the title
   row and the button, the ways opened under them (KeepToggle). */

.search-keep {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0 16px;
  margin: 0 0 22px;
  padding: 12px 14px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--white);
}
.search-keep.is-on { border-color: rgba(var(--accent-rgb), .2); }

.search-keep-body { display: contents; }
.search-keep-head { grid-column: 1; grid-row: 1; position: relative; display: flex; align-items: center; gap: 12px; min-width: 0; }
.search-keep-act { grid-column: 2; grid-row: 1; display: flex; justify-content: flex-end; }
.search-keep-more { grid-column: 1 / -1; grid-row: 2; min-width: 0; }
.search-keep-more-in { margin-top: 12px; padding: 12px 0 0 48px; border-top: 1px solid var(--line-soft); }

.search-keep-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(var(--accent-rgb), .1);
  color: var(--accent);
  font-size: 18px;
}
.search-keep-titles { display: grid; gap: 2px; min-width: 0; }
.search-keep-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
  white-space: nowrap;
}
.search-keep-sub {
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The caret after the title; the whole title row answers the click. */
.search-keep-toggle {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink-3);
  font-size: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, color .15s;
}
.search-keep-toggle::after { content: ""; position: absolute; inset: -4px; }
.search-keep-toggle i { transition: transform .2s; }
.search-keep.is-open .search-keep-toggle i { transform: rotate(180deg); }
.search-keep-toggle:focus-visible { outline: 2px solid rgba(var(--accent-rgb), .5); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) {
  .search-keep-head:hover .search-keep-toggle { background: var(--paper); color: var(--ink); }
}

/* How it works: closed to no height, opened smoothly (the row grows from 0fr to 1fr, the hairline inside it). */
.search-keep-info { grid-column: 1 / -1; grid-row: 3; display: grid; grid-template-rows: 0fr; min-width: 0; transition: grid-template-rows .22s ease; }
.search-keep.is-open .search-keep-info { grid-template-rows: 1fr; }
.search-keep-info-in { min-height: 0; overflow: hidden; padding-left: 48px; }
.search-keep-info-in::before { content: ""; display: block; height: 1px; margin: 12px 0 12px -48px; background: var(--line-soft); }
.search-keep-steps {
  display: grid;
  gap: 6px;
  max-width: 720px;
  margin: 0 0 2px;
  padding: 0;
  list-style: none;
  counter-reset: keep;
}
.search-keep-steps li {
  position: relative;
  padding-left: 26px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-2);
  counter-increment: keep;
}
.search-keep-steps li::before {
  content: counter(keep);
  position: absolute;
  left: 0;
  top: 1px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
}
@media (prefers-reduced-motion: reduce) {
  .search-keep-info, .search-keep-toggle i { transition: none; }
}

/* The ways the new listings come, as tiles: each its colour, its name and where it stands. */
.search-keep-ways { display: flex; flex-wrap: wrap; row-gap: 8px; }
/* A hairline between the ways, each after the first set off from it. */
.search-keep-way + .search-keep-way { padding-left: 14px; border-left: 1px solid var(--line-soft); }
.search-keep-way:not(:last-child) { padding-right: 14px; }
.search-keep-way {
  --c: var(--accent-rgb);
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
  min-width: 0;
  padding-block: 1px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  text-decoration: none;
}
.search-keep-way[data-c="push"] { --c: 224, 145, 43; }
.search-keep-way[data-c="tg"] { --c: 42, 171, 238; }

.search-keep-ico {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(var(--c), .12);
  color: rgb(var(--c));
  font-size: 15px;
}
.search-keep-way-text { display: grid; min-width: 0; line-height: 1.2; }
.search-keep-way-text b {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-keep-way-text small {
  font-size: 11.5px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* On: a small green tick on the tile's icon. */
.search-keep-way[data-on] .search-keep-ico::after {
  content: "";
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--white);
  background: #2f9e5f url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 6.2l2 2 4-4.4' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
}
.search-keep-way[data-on] small { color: #2f9e5f; }
:root[data-theme=dark] .search-keep-way[data-on] small { color: #7ed4a0; }

/* To press: the word under the name in the way's own colour. */
.search-keep-way[data-act] { cursor: pointer; }
.search-keep-way[data-act] small { color: rgb(var(--c)); font-weight: 600; }
.search-keep-way[data-act] small::after { content: " →"; }
.search-keep-way[data-act]:disabled { opacity: .6; cursor: default; }
@media (hover: hover) and (pointer: fine) {
  .search-keep-way[data-act]:hover small { text-decoration: underline; text-underline-offset: 2px; }
}
.search-keep-way[data-mood="denied"] { opacity: .7; }

.search-keep-btn { height: 36px; padding: 0 16px; font-size: 13.5px; border-radius: 10px; white-space: nowrap; box-shadow: none; }
.search-keep-act .saved-search-submit.is-saved { height: 36px; }
.search-keep-short { display: none; }

/* Wide: one row, the ways set off from the title by a hairline. */
@media (min-width: 1100px) {
  .search-keep { grid-template-columns: auto minmax(0, 1fr) auto; gap: 0 24px; }
  .search-keep-more { grid-column: 2; grid-row: 1; }
  .search-keep-more-in { margin: 0; padding: 2px 0 2px 24px; border-top: 0; border-left: 1px solid var(--line-soft); }
  .search-keep-act { grid-column: 3; }
  .search-keep-info { grid-row: 2; }
}

/* A phone: the ways behind the title row, opened by a tap on it. */
@media (max-width: 760px) {
  .search-keep { margin-bottom: 16px; padding: 8px; gap: 0 8px; border-radius: 12px; }
  .search-keep-head { gap: 9px; min-height: 36px; }
  .search-keep-mark { width: 32px; height: 32px; border-radius: 9px; font-size: 16px; }
  .search-keep-title { font-size: 14.5px; }
  .search-keep-sub { display: none; }

  .search-keep-toggle { margin-left: -4px; }

  /* Closed to no height and opened smoothly: the row grows from 0fr to 1fr, the hairline inside it. */
  .search-keep-more { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .22s ease; }
  .search-keep.is-open .search-keep-more { grid-template-rows: 1fr; }
  .search-keep-more-in { min-height: 0; overflow: hidden; margin: 0; padding: 0; border: 0; }
  .search-keep-more-in::before { content: ""; display: block; height: 1px; margin: 8px 0 10px; background: var(--line-soft); }
  .search-keep-ways { flex-wrap: nowrap; margin-bottom: 2px; }
  .search-keep-info-in { padding-left: 0; }
  .search-keep-info-in::before { margin: 10px 0; }
  .search-keep-steps li { font-size: 12.5px; padding-left: 24px; }

  .search-keep-way { flex: 1 1 0; gap: 7px; }
  .search-keep-way + .search-keep-way { padding-left: 10px; }
  .search-keep-way:not(:last-child) { padding-right: 8px; }
  .search-keep-way[data-on] .search-keep-ico::after { width: 11px; height: 11px; right: -3px; bottom: -3px; }
  .search-keep-ico { width: 26px; height: 26px; border-radius: 8px; font-size: 14px; }
  .search-keep-way-text b { font-size: 12.5px; }
  .search-keep-way-text small { font-size: 11px; }

  .search-keep-btn { height: 34px; padding: 0 12px; font-size: 13px; }
  .search-keep-full { display: none; }
  .search-keep-short { display: inline; }
  .search-keep-act .saved-search-submit.is-saved { height: 34px; padding: 0 10px; }
}
@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
  .search-keep-more { transition: none; }
}
