/* ===========================================================================
   Search — the dialog on every page, and the results page behind it.

   Both are one file because they are one thing to a visitor and share their
   vocabulary: the same three groups in the same order, with the paintings
   given the most room.

   That order is the whole design. This is a painter's website, so a search is
   usually for a painting: those get a picture big enough to recognise. A
   product is a thing whose name does most of the work, so it gets a smaller
   one. A page is words, and gets none.
   =========================================================================== */

/* ===========================================================================
   The link in the nav
   =========================================================================== */

.menu__search {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

/* A magnifier, drawn rather than fetched: two rules beat an svg file, and in
   currentColor it lights up with the word instead of being a second thing that
   has to be told what colour to be. */
.menu__magnifier {
  position: relative;
  width: 9px;
  height: 9px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  /* Sitting a little above the baseline rather than on it: the word beside it
     is Garamond at 18px, whose x-height is low, and a glyph-sized circle level
     with the letters reads as having fallen. */
  align-self: center;
  transform: translateY(-1px);
}
.menu__magnifier:after {
  content: '';
  position: absolute;
  right: -3px;
  bottom: -1px;
  width: 5px;
  height: 1.5px;
  background: currentColor;
  transform: rotate(45deg);
  transform-origin: left center;
}

/* ===========================================================================
   The dialog
   =========================================================================== */

.search-modal__scrim {
  position: fixed;
  inset: 0;
  background: rgba(11, 21, 30, 0.7);
  z-index: 90;
}

.search-modal__panel {
  position: fixed;
  z-index: 91;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(680px, calc(100vw - 36px));
  max-height: min(80vh, 760px);
  margin-top: 60px;
  display: flex;
  flex-direction: column;
  background: var(--color-1);
  border: 1px solid var(--color-3);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
}

/* Both are hidden by the attribute; the rules above would otherwise outrank
   the browser's own display:none for [hidden]. */
.search-modal .search-modal__panel[hidden],
.search-modal .search-modal__scrim[hidden] { display: none; }

/* --- the box -------------------------------------------------------------- */

.search-modal__form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 18px;
  border-bottom: 1px solid var(--color-3);
}
.search-modal__form input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 14px 0;
  background: none;
  border: 0;
  color: var(--color-2);
  font-family: var(--font-family-2);
  font-size: var(--font-size-7);
}
.search-modal__form input:focus { outline: none; }
.search-modal__form input::placeholder { color: var(--color-4); }

/* The browser draws its own clear button inside a type="search" box, which put
   a second × an inch from the one that closes the dialog. Kept on the results
   page, where nothing sits beside it; gone here. The type is still search for
   the keyboard it brings up on a phone. */
.search-modal__form input::-webkit-search-cancel-button,
.search-modal__form input::-webkit-search-decoration { -webkit-appearance: none; display: none; }

.search-modal__close {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  background: none;
  border: 0;
  border-radius: 3px;
  color: var(--color-4);
  font-size: var(--font-size-2);
  line-height: 1;
  cursor: pointer;
}
.search-modal__close:hover { color: var(--color-2); }

/* --- results -------------------------------------------------------------- */

.search-modal__results {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 0 0;
}

/* The results stay put while the next answer is fetched — see search.js —
   and only lose a little of their weight to say so. */
.search-modal.is-busy .search-modal__results { opacity: 0.55; }

.search-modal__hint {
  font-family: var(--font-family-2);
  font-size: var(--font-size-4);
  color: var(--color-4);
  padding: 22px 18px 26px;
  margin: 0;
}
/* The suggested searches: a click fills the box with them. */
.search-modal__hint a {
  color: var(--color-2);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.search-modal__hint a:hover { color: var(--color-5); }

/* Above the first group, saying what was searched for instead. */
.search-modal__corrected {
  font-family: var(--font-family-2);
  font-size: var(--font-size-3);
  color: var(--color-4);
  padding: 12px 18px 0;
  margin: 0;
}

.search-modal__status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.search-group { padding-bottom: 6px; }
.search-group__heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: var(--font-size-3);
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-4);
  padding: 14px 18px 8px;
  margin: 0;
}
.search-group__heading span { color: var(--color-3); letter-spacing: 0; }

/* --- a row ---------------------------------------------------------------- */

.search-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 18px;
  text-decoration: none;
  color: var(--color-2);
}
.search-row.is-active { background: var(--color-8); }

.search-row__figure {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 3px;
  background: var(--color-8);
}
.search-row__figure img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* --- paintings, as a grid of tiles ----------------------------------------
   Six paintings across two rows are taken in at a glance in a way that six
   lines of a list are not — they are all picture and almost no text, and the
   picture is how you know it is the one you meant. */

.search-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 0 12px 8px;
}

.search-tile {
  display: block;
  padding: 8px;
  border-radius: 4px;
  text-decoration: none;
  color: var(--color-2);
}
.search-tile.is-active { background: var(--color-8); }

.search-tile__figure {
  display: flex;
  align-items: center;
  justify-content: center;
  /* The frame drawings are landscape or portrait depending on the painting, so
     the box is fixed and the picture sits inside it whichever way up it is. */
  height: 118px;
  margin-bottom: 8px;
}
.search-tile__figure img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.search-tile__text {
  display: block;
  text-align: center;
}
.search-tile__title {
  display: block;
  font-size: var(--font-size-4);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-tile__meta {
  display: block;
  font-family: var(--font-family-2);
  font-size: var(--font-size-3);
  color: var(--color-4);
}
.search-tile:hover .search-tile__title,
.search-tile.is-active .search-tile__title { color: var(--color-5); }
/* A thing with a name — smaller than a painting, since the name does more of
   the work here, but big enough to tell a puzzle from a note card without
   reading either. */
.search-row--products .search-row__figure {
  width: 76px;
  height: 76px;
}

.search-row__text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.search-row__title {
  font-size: var(--font-size-8);
  line-height: 1.3;
  /* Product names run to a dozen words and would push the price out of sight;
     a row is one line, and the rest is on the page it goes to. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-row--paintings .search-row__title { font-size: var(--font-size-7); }

.search-row__meta {
  font-family: var(--font-family-2);
  font-size: var(--font-size-4);
  color: var(--color-4);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-row:hover .search-row__title,
.search-row.is-active .search-row__title { color: var(--color-5); }

/* Pages are mostly words, and their picture is the smallest of the three —
   enough to tell About from Visit at a glance, not enough to compete with the
   paintings above. */
.search-row--pages .search-row__figure {
  width: 56px;
  height: 42px;
}
.search-row--pages .search-row__figure img { object-fit: cover; }
.search-row--pages { padding-top: 7px; padding-bottom: 7px; }

/* --- the way out ---------------------------------------------------------- */

.search-modal__all {
  display: block;
  position: sticky;
  bottom: 0;
  padding: 14px 18px;
  border-top: 1px solid var(--color-3);
  background: var(--color-1);
  font-family: var(--font-family-2);
  font-size: var(--font-size-4);
  color: var(--color-2);
  text-decoration: none;
}
.search-modal__all:hover,
.search-modal__all.is-active {
  background: var(--color-8);
  color: var(--color-5);
}

@media (max-width: 600px) {
  .search-modal__panel {
    margin-top: 0;
    width: 100vw;
    /* dvh, so the bottom of the results is not hidden behind a phone's
       toolbar — 100vh there is the height with the toolbars put away. */
    max-height: 100dvh;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }
  .search-grid { grid-template-columns: repeat(2, 1fr); }
  .search-tile__figure { height: 100px; }
}

/* ===========================================================================
   The results page
   =========================================================================== */

.search {
  max-width: var(--page-width);
  margin: 0 auto 100px;
}

.search .page-title {
  text-transform: uppercase;
  font-size: var(--font-size-2);
  letter-spacing: 1px;
  margin: 40px 0 24px;
}

.search__form {
  display: flex;
  gap: 10px;
  max-width: 620px;
  margin-bottom: 22px;
}
.search__form input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 12px 14px;
  background: var(--color-8);
  border: 1px solid var(--color-3);
  border-radius: 3px;
  color: var(--color-2);
  font-family: var(--font-family-2);
  font-size: var(--font-size-7);
}
.search__form input::placeholder { color: var(--color-4); }
.search__form input:focus {
  outline: none;
  border-color: var(--color-7);
}
.search__form input::-webkit-search-cancel-button { filter: invert(0.6); }

.search__form button {
  padding: 12px 22px;
  background: none;
  border: 1px solid var(--color-4);
  border-radius: 3px;
  color: var(--color-2);
  font-family: var(--font-family-2);
  font-size: var(--font-size-8);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.search__form button:hover {
  background: var(--color-8);
  border-color: var(--color-5);
}

.search__hint,
.search__count,
.search__more {
  font-family: var(--font-family-2);
  font-size: var(--font-size-4);
  color: var(--color-4);
  max-width: 620px;
  margin-bottom: 10px;
}
.search__hint a,
.search__more a { color: var(--color-2); }
.search__count { margin-bottom: 40px; }
.search__more { margin-top: -20px; }

.search__group { margin-bottom: 70px; }

.search__heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: var(--font-size-4);
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-4);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-3);
  margin-bottom: 30px;
}
.search__heading span {
  font-size: var(--font-size-3);
  color: var(--color-3);
  letter-spacing: 0;
}

/* --- paintings, given the room --------------------------------------------
   Uncropped, as on the artworks grid: a painting's proportions are part of it,
   and a result that crops them is showing a different picture. */

.search-paintings {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 45px 35px;
  margin: 0;
  padding: 0;
}
.search-paintings a {
  text-decoration: none;
  display: block;
}
.search-paintings figure {
  margin: 0 0 12px;
  height: 260px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.search-paintings img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.search-paintings a:hover img { opacity: 0.85; }

.search-paintings__title {
  display: block;
  font-size: var(--font-size-7);
  color: var(--color-2);
  line-height: 1.3;
}
.search-paintings a:hover .search-paintings__title { color: var(--color-5); }
.search-paintings__year {
  display: block;
  font-family: var(--font-family-2);
  font-size: var(--font-size-4);
  color: var(--color-4);
}

/* --- products, smaller ----------------------------------------------------
   Same card as the shop's, at two thirds the size: below the paintings they
   are the second answer, and sizing them the same made the page read as two
   equal halves. */

.search-products {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 40px 28px;
  margin: 0;
  padding: 0;
}
/* The shop's card, carried here because the shop itself is still on Shopify
   and its stylesheet is not on this site. Pictured uncropped and sitting on a
   common floor, so every name is on the same line whatever shape the box. */
.search-products .shop-card a {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.search-products .shop-card__figure {
  margin: 0 0 12px;
  height: 200px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.search-products .shop-card__figure img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.search-products .shop-card a:hover .shop-card__figure img { opacity: 0.85; }
.search-products .shop-card__title {
  display: block;
  font-size: var(--font-size-8);
  color: var(--color-2);
  line-height: 1.35;
}
.search-products .shop-card a:hover .shop-card__title { color: var(--color-5); }
.search-products .shop-card__price {
  display: block;
  font-family: var(--font-family-2);
  font-size: var(--font-size-4);
  color: var(--color-4);
  margin-top: 4px;
}

/* --- pages, last ---------------------------------------------------------- */

.search-pages {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 720px;
}
.search-pages li { border-bottom: 1px solid var(--color-8); }
.search-pages li:last-child { border-bottom: 0; }
.search-pages a {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  text-decoration: none;
}
.search-pages__figure {
  flex: 0 0 auto;
  width: 90px;
  height: 68px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--color-8);
}
.search-pages__figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.search-pages__text { min-width: 0; }
.search-pages__title {
  display: block;
  font-size: var(--font-size-7);
  color: var(--color-2);
}
.search-pages a:hover .search-pages__title { color: var(--color-5); }
.search-pages__summary {
  display: block;
  font-family: var(--font-family-2);
  font-size: var(--font-size-4);
  color: var(--color-7);
  line-height: 1.5;
  margin-top: 3px;
}
.search-pages__url {
  display: block;
  font-family: var(--font-family-2);
  font-size: var(--font-size-3);
  color: var(--color-4);
  margin-top: 5px;
}

@media (max-width: 600px) {
  .search__form { flex-direction: column; }
  .search-paintings {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 30px 20px;
  }
  .search-paintings figure { height: 140px; }
  .search-products { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .search-products .shop-card__figure { height: 150px; }
}
