/* Hair Harvester — catalogue: the first screen, the filters and the lot cards. Loaded after the core stylesheet; scope every rule to this area's pages. */

/* Every rule below starts with .home (the wrapper of templates/catalog/index.html) or with .cards
   (the lot cards of templates/catalog/_cards.html, also shown on a person's public page). */

/* ---------- the page: order of its parts ----------
   The markup order is hero, the steps at a glance, «Як це працює», the catalogue. On a phone the full
   «Як це працює» moves below the catalogue (the row at a glance links to it); on a desktop it stays above
   and the row at a glance is not shown. Only the catalogue has controls, so the tab order is not disturbed. */
.home { display: flex; flex-direction: column; }
.home > * { min-width: 0; }
.home > .hero { order: 1; }
.home > .howrow { order: 2; }
.home > .catsec { order: 3; }
.home > .howsec { order: 4; }

/* ---------- the first screen: the two doors and the reassurance line ---------- */
.home .hero { padding: 0 0 var(--s5); }
.home .door .ico { display: block; flex: none; margin-left: auto; }
.home .door .ico svg { width: 36px; height: 36px; }
.home .door:focus-visible { outline-offset: 2px; }
/* three short promises beside the doors; the fuller list stays in «Як це працює» */
.home .assure { display: grid; gap: 3px; margin: var(--s3) 0 0; font-size: 1rem; line-height: 1.35; color: var(--ink); }
.home .assure span { position: relative; padding-left: 24px; }
.home .assure span::before { content: ""; position: absolute; left: 1px; top: 5px; width: 14px; height: 12px; background: var(--i-check-ink) center / 14px 12px no-repeat; }

/* ---------- the legend plate: how to read the stitched ribbon ---------- */
.home .plate { --u: 2px; margin: var(--s5) 0 0; }
.home .plate svg { width: calc(140 * var(--u)); max-width: 100%; height: calc(104 * var(--u)); margin: 0 auto; background: var(--weave), var(--ground); background-size: 3px 3px, 3px 3px, auto; overflow: visible; }
.home .plate .cap { font: 700 6.4px var(--serif); fill: var(--ink); }
.home .plate figcaption { margin: var(--s3) auto 0; max-width: 30em; font-size: 1rem; line-height: 1.4; color: var(--ink-2); text-align: center; }
.home .plate figcaption b { color: var(--ink); }

/* ---------- the three steps at a glance (phones and tablets) ---------- */
.home .howrow { display: block; padding: 16px 0 2px; color: var(--ink); text-decoration: none; background: var(--run) top / auto 2px repeat-x, var(--run) bottom / auto 2px repeat-x; }
.home .howrow ol { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.home .howrow ol::before { content: ""; position: absolute; top: 19px; left: 16.6%; right: 16.6%; height: 2px; background: var(--run-red); }
.home .howrow li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 1rem; line-height: 1.2; text-align: center; overflow-wrap: anywhere; hyphens: auto; }
.home .howrow .n { display: grid; place-items: center; width: 39px; height: 39px; background: var(--linen) var(--i-num) center / 39px 39px no-repeat; font: 700 1.0625rem/1 var(--serif); }
.home .howrow .more { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; margin-top: 4px; font-weight: 700; text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
/* the arrow points on, to the page «Як це працює» */
.home .howrow .more .ico { width: 18px; height: auto; color: var(--red); }
.home .howrow:hover { color: var(--ink); }
.home .howrow:hover .more { color: var(--red); }

/* ---------- «Як це працює» and the promises ---------- */
.home .howsec { margin-top: var(--s7); padding-top: var(--s6); background: var(--run) top / auto 2px repeat-x; }
.home .howsec > h2 { margin-top: 0; margin-bottom: var(--s5); }
.home .howsec .how { margin-bottom: 0; }
.home .howsec .promise { margin: var(--s6) 0 0; }
.home .howsec .howmore { margin: var(--s4) 0 0; font-weight: 700; }

/* ---------- the catalogue: heading, search, categories ---------- */
.home .catsec { padding-top: var(--s6); }
.home-back .catsec { padding-top: 0; }
.home .sectionhead { margin-top: 0; }
.home .sectionhead h1 { margin: 0; }
.home .search input { text-overflow: ellipsis; }
/* on a phone the field takes the whole row and the button stands under it: beside the button the hint was cut
   before its useful half («Що шукаєте? Наприклад, …») */
@media (max-width: 639.98px) {
  .home .search { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 389.98px) {
  .home .search input::placeholder { font-size: 1rem; }
}
@media (max-width: 359.98px) {
  .home .search input { padding-inline: 14px; }
}
.home .chips { margin-bottom: var(--s2); }
/* what the search found, and a label for each filter that is set: a press on a label takes that filter off */
.home .found { margin: 0 0 var(--s2); font-size: 1.0625rem; }
.home .unsets { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 var(--s4); padding: 0; list-style: none; }
.home .unsets .chip { gap: 10px; max-width: 100%; overflow-wrap: anywhere; }
.home .unsets .chip::after { content: ""; flex: none; width: 12px; height: 12px; background: var(--i-cross) center / 12px 12px no-repeat; }
/* the folded filter line names what is chosen, or what can be chosen while nothing is */
.home details.more > summary .set + .set::before { content: ", "; }
.home details.more > summary:has(.set) .unset { display: none; }
/* the filter block ends with a running stitch, so the empty state does not draw a second one right under it */
.home .empty { margin-top: 0; background: var(--run) bottom / auto 2px repeat-x; }

/* ---------- where a submitted filter, a category chip and the pager land ----------
   Their links end in #lots, an empty mark in front of the lot cards. While «Уточнити» is closed the mark is
   taken to the head of the catalogue, so the page lands on the heading, the search and the chips, as it does
   for #catalog. While the block is open (the page was rendered with a filter set) the mark stays where it is
   in the markup and the page lands on the lots, with the «Показати» button just pressed still in sight: the
   open block is taller than a phone screen and the answer would otherwise lie a screen and a half below.
   A browser without :has() keeps the first behaviour. */
.home .catsec { position: relative; }
.home .landmark { position: absolute; left: 0; top: 0; width: 1px; height: 1px; pointer-events: none; }
.home .catsec:has(details.more[open]) .landmark { position: static; display: block; width: auto; height: 0; scroll-margin-top: 86px; }

/* ---------- the filter block ---------- */
.home details.more > summary { font-weight: 400; color: var(--ink-2); }
.home details.more > summary b { color: var(--ink); }
.home details.more > summary:hover b { text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.home details.more .inner {
  grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4) var(--s3); align-items: end;
  grid-template-areas: "city city" "len sort" "tint tint" "pmin pmax" "cur note" "go go";
}
.home details.more .inner .f-city { grid-area: city; }
.home details.more .inner .f-len { grid-area: len; }
.home details.more .inner .f-sort { grid-area: sort; }
/* the line about currencies under a sort by price takes a row of its own, so the length and the sort stay side by side */
.home details.more .inner .f-sortnote { grid-area: snote; margin: calc(-1 * var(--s2)) 0 0; }
.home details.more .inner:has(> .f-sortnote) { grid-template-areas: "city city" "len sort" "snote snote" "tint tint" "pmin pmax" "cur note" "go go"; }
.home details.more .inner .tintfield { grid-area: tint; min-width: 0; }
/* without the script the colour is two numbers and two check marks: the numbers side by side, each mark on its own line */
.home details.more .inner .tintfield .plain { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.home details.more .inner .tintfield .plain .check { grid-column: 1 / -1; }
.home details.more .inner .f-pmin { grid-area: pmin; }
.home details.more .inner .f-pmax { grid-area: pmax; }
.home details.more .inner .f-cur { grid-area: cur; }
.home details.more .inner .f-note { grid-area: note; align-self: center; margin: 0; padding-top: 22px; }
.home details.more .inner .f-go { grid-area: go; }

/* ---------- the pager: the way back on the left, the way on on the right, the page number between ---------- */
.home .pager { display: grid; grid-template-columns: minmax(max-content, 1fr) minmax(0, auto) minmax(max-content, 1fr); align-items: center; gap: var(--s2); }
.home .pager .prev { grid-column: 1; justify-self: start; }
.home .pager .muted { grid-column: 2; text-align: center; line-height: 1.25; }
.home .pager .next { grid-column: 3; justify-self: end; }
.home .pager .btn { padding-inline: 12px; white-space: nowrap; }

/* ---------- the lot card ----------
   A photograph on its mount; under it a hem of ground cloth with the measuring ribbon, sewn up to the length
   from the description (one stitch is one centimetre, the ribbon ends at 100 cm); then the title, the colour,
   the place, the price and the moderator's mark. The ribbon never lies over the photograph. */
/* one thin line frames the mount and the hem together */
.cards .card .pic { display: block; outline: 1px solid var(--line); }
.cards .card .ph { --mm: 6px; --mc: 7.5px; padding: var(--mm); }
/* the mount itself: lighter cloth with a stitch in every corner. The core paints the ground cloth on every
   .card .ph (two classes beat .mount), so the mount is restated here. The stitches are as large as the margin
   allows without slipping under the photograph (a rhombus of side d clears a margin m while d <= 4m / 3). */
.cards .card .ph.mount {
  background: var(--i-rhomb) left top / var(--mc) var(--mc) no-repeat, var(--i-rhomb) right top / var(--mc) var(--mc) no-repeat,
    var(--i-rhomb) left bottom / var(--mc) var(--mc) no-repeat, var(--i-rhomb) right bottom / var(--mc) var(--mc) no-repeat, var(--cloth);
  box-shadow: none;
}
/* the ground under the photograph: seen while it loads and when a lot has no photograph */
.cards .card .ph::before { content: ""; position: absolute; inset: var(--mm); background: var(--i-node) center / 27px 27px no-repeat, var(--weave), var(--ground); background-size: 27px 27px, 3px 3px, 3px 3px, auto; }
.cards .card .ph img { position: relative; }
.cards .card .badge { left: auto; top: auto; right: var(--mm); bottom: var(--mm); }

.cards .hem { container-type: inline-size; display: block; padding: 6px 6px 7px; overflow: visible; }
/* the ribbon takes the whole width of the hem: its 105 stitches set the width of one centimetre.
   --mf is for a browser without container query units (the ribbon would have no height there): the width
   of a card worked out from the page grid (two, three or four cards per row) less the hem's padding. */
.cards .hem { --mf: calc((50vw - 34px) / 105); }
.cards .hem .ribbon { --m: var(--mf); width: 100%; }
@supports (width: 1cqw) {
  .cards .hem .ribbon { --m: calc(100cqw / 105); }
}
.cards .hem .len { display: block; margin-top: 6px; font-size: 1rem; line-height: 1.15; color: var(--ink); }
.cards .hem b { margin: 0; font-size: 1.0625rem; letter-spacing: 0; }
/* hair longer than the ribbon: sewn to the end, and a plate that says so instead of the end mark */
.cards .hem.over .fill::after { display: none; }
.cards .hem .plus { position: absolute; inset: 0 0 0 auto; display: grid; place-items: center; padding: 0 5px; background: var(--ink); color: var(--cloth); font: 700 .78125rem/1 var(--sans); letter-spacing: .04em; }

.cards .card .body { gap: 4px; }
/* a title made of one very long word breaks instead of running out of the card */
.cards .card .body b { overflow-wrap: anywhere; }
/* two cards side by side on a phone: three lines of title, so the words that matter at the end («не фарбована»)
   are not cut off */
@media (max-width: 399.98px) {
  .cards .card .body b { -webkit-line-clamp: 3; }
}
.cards .card .spec { font-size: 1rem; line-height: 1.3; overflow-wrap: anywhere; }
.cards .card .where { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
/* the price and, on a line of its own, the moderator's mark: the same place on every card, whatever the price is */
.cards .card .cfoot { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: auto; padding-top: 6px; }
.cards .card .price { margin: 0; padding: 0; white-space: normal; }
/* An amount never breaks inside itself (its spaces are non-breaking), and a card is a half of a phone screen: with text
   set very large the sum would run out of it. So the price keeps its size against the system's text multiplier;
   a larger default text size of the browser (rem) is followed, with the cards one per row then (see .cards below). */
.cards .card .price { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* the two words of the mark wrap inside a narrow card; the mark keeps its 14 px against the system's text multiplier */
.cards .card .stamp { margin-bottom: 2px; max-width: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* the narrowest phones: a six-digit price keeps a little air */
@media (max-width: 359.98px) {
  .cards .card .price { font-size: 1.375rem; }
}

/* two cards per row on a phone; one when a half row is narrower than 8.5rem (a browser set to a large default text) */
@media (max-width: 639.98px) {
  .cards { grid-template-columns: repeat(auto-fill, minmax(max(min(100%, 8.5rem), (100% - 13px) / 2), 1fr)); }
}

/* ---------- 640 px: wide phone and tablet ---------- */
@media (min-width: 640px) {
  .home .hero { display: grid; grid-template-columns: minmax(0, 1fr) 280px; grid-template-areas: "head head" "entry plate"; column-gap: var(--s5); align-items: start; }
  .home .hero-head { grid-area: head; }
  .home .entry { grid-area: entry; }
  .home .doors { grid-template-columns: 1fr; max-width: 560px; }
  .home .plate { grid-area: plate; margin: 0; }
  .home .plate figcaption { margin-left: 0; text-align: left; }

  .home details.more .inner { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; grid-template-areas: "city city len sort" "tint tint tint tint" "pmin pmax cur note" "go go go go"; }
  .home details.more .inner:has(> .f-sortnote) { grid-template-areas: "city city len sort" "city city snote snote" "tint tint tint tint" "pmin pmax cur note" "go go go go"; }
  .home details.more .inner .f-go { justify-self: end; min-width: 220px; }

  .cards .card .ph { --mm: 8px; --mc: 10px; }
  .cards .hem { --mf: calc(((100vw - 72px) / 3 - 16px) / 105); padding: 7px 8px 8px; }
  .cards .card .where { -webkit-line-clamp: 2; }
}

/* ---------- 960 px: desktop ---------- */
@media (min-width: 960px) {
  .home > .howsec { order: 2; }
  .home > .howrow { display: none; }

  /* up to 1200 px the head still runs across and the doors stand beside the plate: two columns here would
     squeeze the headline into a column of 264-400 px and push the doors off the first screen */
  .home .hero { grid-template-columns: minmax(0, 1fr) 420px; column-gap: var(--s7); padding: 4px 0 var(--s7); }
  .home .hero h1 { max-width: none; text-wrap: balance; }
  /* the red words stay on one line */
  .home .hero h1 em { white-space: nowrap; }
  .home .door .ico svg { width: 48px; height: 48px; }
  .home .doors { gap: 12px; }
  .home .assure { margin-top: var(--s4); font-size: 1.0625rem; }
  .home .assure span::before { top: 6px; }
  .home .plate { --u: 3px; }
  .home .plate .cap { font-size: 5.4px; }
  .home .plate figcaption { max-width: none; font-size: 1.0625rem; }

  .home .howsec { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 24px; margin-top: 0; padding-top: var(--s5); }
  .home .howsec > h2 { margin: 6px 0 0; }
  .home .howsec .how { grid-column: 2 / -1; gap: 24px; }
  .home .howsec .how p { font-size: 1.0625rem; line-height: 1.4; }
  .home .howsec .promise { grid-column: 1 / -1; margin-top: var(--s5); font-size: 1.0625rem; line-height: 1.4; }
  .home .howsec .howmore { grid-column: 1 / -1; }

  .home .catsec { padding-top: var(--s6); }
  .home-back .catsec { padding-top: 0; }
  .home .sectionhead { margin-bottom: var(--s5); }
  .home .catalog-tools { display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: var(--s5); align-items: start; }
  .home .catalog-tools .search, .home .catalog-tools .chips { margin: 0; }
  .home .catalog-tools .chips { justify-content: flex-end; }
  .home details.more { margin-top: var(--s2); }
  /* here the button shares its rows with the colour box, so only the closing stitch of the block stays in sight */
  .home .catsec:has(details.more[open]) .landmark { scroll-margin-top: 20px; }

  .home details.more .inner { gap: var(--s4) 24px; padding-top: 8px; grid-template-areas: "city city len sort" "tint tint pmin pmax" "tint tint cur note" "tint tint . go"; }
  .home details.more .inner:has(> .f-sortnote) { grid-template-areas: "city city len sort" "city city snote snote" "tint tint pmin pmax" "tint tint cur note" "tint tint . go"; }
  .home details.more .inner .f-go { align-self: end; justify-self: stretch; min-width: 0; }

  /* on a wide screen the pager stays together in the middle; its three places keep their positions on every page */
  .home .pager { grid-template-columns: 150px auto 150px; justify-content: center; gap: var(--s5); }

  .cards .hem { --mf: calc(((min(100vw - 16px, 1232px) - 136px) / 4 - 16px) / 105); }
  .cards .hem .len { font-size: 1.0625rem; }
  .cards .hem b { font-size: 1.1875rem; }
  .cards .hem .plus { font-size: .875rem; padding: 0 8px; }
  .cards .card .spec { font-size: 1.0625rem; }
}

/* ---------- 1200 px: wide desktop ----------
   A third breakpoint, for the two-column first screen (the text column is at least 504 px here). The moderator's
   mark stays on a line of its own under the price: its two words do not fit beside the price label. */
@media (min-width: 1200px) {
  .home .hero { grid-template-columns: minmax(0, 1fr) 560px; grid-template-areas: "head plate" "entry plate"; grid-template-rows: auto 1fr; column-gap: 72px; }
  .home .hero h1 { max-width: 14em; text-wrap: wrap; }
  .home .plate { --u: 4px; align-self: center; }
  .home .plate .cap { font-size: 4.6px; }
}

/* ---------- sample lots (load_samples) ----------
   A sample's card carries its own mark on the top edge of the mount, laid over it: red cloth and a cloth rhombus with
   the inner stitch of the red button, as wide as the card, so that it is read before the picture on any phone. Laid
   over rather than set above, so that the photograph of a sample starts at the same height as its real neighbours'
   in a row. No real card has anything there, so a real card never looks like a sample and a sample never like a real one. */
.cards .card.sample .pic { position: relative; }
.cards .card .samplemark { position: absolute; top: 0; left: 0; right: 0; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 32px; padding: 6px 10px 5px; background: var(--red); color: var(--cloth); font: 700 .9375rem/1.2 var(--sans); letter-spacing: .18em; text-transform: uppercase; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.cards .card .samplemark::before { content: ""; flex: none; width: 10px; height: 10px; background: var(--i-rhomb-cloth) center / 10px 10px no-repeat; }
.cards .card .samplemark::after { content: ""; position: absolute; inset: 3px; border: 1px dashed rgba(248, 244, 234, .6); pointer-events: none; }
/* the line above the grid: the core's rhombus and sentence, with its two links on the same line when they fit. The links
   stay inline (an inline-flex box would count their touch padding into the line and push the sentence off its rhombus). */
.home .sampleline { margin: 0 0 var(--s4); }
.home .sampleline .sampleways a { margin-right: 18px; white-space: nowrap; }
