/*
 * Reading page of the price list (docs/vereinbarungen/preisliste.md): four columns that fit an
 * iPhone in portrait (390 px) without sideways scrolling, details open under the row via <details>.
 */

.price-list__subtitle,
.price-list__as-of {
  margin: 0;
  color: var(--ink-muted);
}

/* Under the list, above the notes. */
.price-list__as-of {
  margin-block-start: var(--space-4);
}

.price-list__group {
  margin-block-start: var(--space-5);
}

.price-list__group h2 {
  margin: 0 0 var(--space-2);
}

.price-list__head,
.price-list__summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2.75rem 2.75rem 5.5rem;
  align-items: center;
  column-gap: var(--space-2);
}

.price-list__head {
  padding: var(--space-1) var(--space-2);
  border-bottom: 2px solid var(--line);
  color: var(--ink-muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.price-list__head span:not(:first-child),
.price-list__maturity {
  text-align: center;
}

.price-list__row {
  border-bottom: 1px solid var(--line);
}

.price-list__summary {
  min-height: 44px;
  padding: var(--space-2);
  cursor: pointer;
  list-style: none;
}

.price-list__summary::-webkit-details-marker {
  display: none;
}

.price-list__name {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 600;
}

.price-list__name::before {
  content: "";
  flex: none;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--ink-muted);
  border-bottom: 2px solid var(--ink-muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.price-list__row[open] .price-list__name::before {
  transform: rotate(45deg);
}

.price-list__stars {
  text-align: center;
  white-space: nowrap;
  letter-spacing: 0;
  color: var(--accent);
}

.price-list__stars-empty,
.price-list__stars--none {
  color: var(--ink-muted);
}

/*
 * Two columns: what a fact is called and what it says. The first column is as wide as its longest
 * label and never more than half of the list, where a label breaks instead.
 */
.price-list__details {
  display: grid;
  grid-template-columns: fit-content(50%) minmax(0, 1fr);
  gap: var(--space-1) var(--space-4);
  margin: 0;
  padding: var(--space-1) var(--space-2) var(--space-3);
}

/* A fact (breeder, a group of properties, the remark) is a row of that grid. */
.price-list__fact {
  display: contents;
}

/*
 * A price is a line across both columns: its label in front, the amount at the right edge, the
 * amounts under each other. The labels of the price columns are typed in by the editorial team
 * ("Preise bis 15.10.2026") and are longer than those of the facts. As rows of the grid they set
 * its first column, and on a phone the value of every fact got less than half of the width. On a
 * wide screen there is room for that, and a price is a row of the grid ("Wide screens" below).
 */
.price-list__price {
  display: flex;
  grid-column: 1 / -1;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
}

.price-list__details dt {
  min-width: 0;
  color: var(--ink-muted);
  overflow-wrap: anywhere;
}

.price-list__details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* "1.082,50 €" stays in one piece beside a label that breaks. */
.price-list__price dd {
  flex: none;
  white-space: nowrap;
}

.price-list__details dd p {
  margin: 0;
}

/*
 * The notes are Markdown and may hold tables. As an item of the page's grid the section would take
 * the width of its widest table and the whole page with it: the list twice as wide as a phone.
 * Held to the column, a wide table scrolls in itself (wiki.css, `.wiki-body table`).
 */
.price-list__notes {
  min-width: 0;
  margin-block-start: var(--space-5);
}

/* --- Filter (stage 2) ------------------------------------------------------------------------ */

/* Display rules above and below must not beat `hidden`. */
.price-list__row[hidden],
.price-list__group[hidden],
.price-list-filter[hidden],
.price-list-filter [hidden],
.price-list__filtered .ui-empty[hidden] {
  display: none;
}

/* Grid items would widen the page after unbreakable content, see "Breite auf dem Handy" in wiki.css. */
.price-list__filtered,
.price-list-filter,
.price-list-filter > * {
  min-width: 0;
}

.price-list-filter {
  display: grid;
  gap: var(--space-3);
  margin-block: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
}

.price-list-filter__advanced {
  display: grid;
  gap: var(--space-3);
}

/* A link to look at, a 44 px button to tap, as wide as its text. The underline sits on the text
   only, not on the arrow. */
.price-list-filter .price-list-filter__toggle {
  justify-self: start;
  gap: var(--space-1);
  min-height: 44px;
  padding: 0;
  border: 0;
  color: var(--accent);
  background: none;
  font-size: 0.875rem;
  font-weight: 400;
}

.price-list-filter .price-list-filter__toggle:hover {
  border: 0;
  background: none;
}

.price-list-filter__toggle-label {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.price-list-filter__toggle:hover .price-list-filter__toggle-label {
  text-decoration-thickness: 2px;
}

.price-list-filter .price-list-filter__toggle::after {
  content: "▾";
}

.price-list-filter .price-list-filter__toggle[aria-expanded="true"]::after {
  transform: rotate(180deg);
}

/* How many parts of the advanced search filter, folded or not; after the arrow. A .badge (dashboard.css). */
.price-list-filter__badge {
  order: 1;
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent);
}

.price-list-filter fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.price-list-filter legend {
  padding: 0;
  color: var(--ink-muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.price-list-filter__name {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: inherit;
  font-size: 1rem; /* at least 16 px, so iOS does not zoom */
}

.price-list-filter__maturity {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: var(--space-3);
}

.price-list-filter__maturity > .price-list-filter__track {
  grid-column: 1 / -1;
}

.price-list-filter__range {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Two range inputs stacked on one track: the inputs let clicks through, only the thumbs catch them. */
.price-list-filter__track {
  position: relative;
  height: 44px;
  --from: 0%;
  --to: 100%;
}

.price-list-filter__track::before {
  content: "";
  position: absolute;
  inset-inline: 22px; /* the thumb centres run from 22 px to 22 px before the end */
  top: 50%;
  height: 4px;
  margin-top: -2px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--line) var(--from), var(--accent) var(--from), var(--accent) var(--to), var(--line) var(--to));
}

.price-list-filter__track input[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  z-index: 1;
}

.price-list-filter__track[data-top="from"] input:first-of-type {
  z-index: 2;
}

.price-list-filter__track[data-top="to"] input:last-of-type {
  z-index: 2;
}

.price-list-filter__track input[type="range"]::-webkit-slider-runnable-track {
  height: 44px;
  background: transparent;
}

.price-list-filter__track input[type="range"]::-moz-range-track {
  height: 44px;
  background: transparent;
}

/* The thumb is 44 px (touch target); a transparent border leaves the visible handle 28 px. */
.price-list-filter__track input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  box-sizing: border-box;
  width: 44px;
  height: 44px;
  border: 8px solid transparent;
  border-radius: 50%;
  background: var(--accent);
  background-clip: padding-box;
  box-shadow: inset 0 0 0 2px var(--accent-ink);
  pointer-events: auto;
  cursor: pointer;
}

.price-list-filter__track input[type="range"]::-moz-range-thumb {
  box-sizing: border-box;
  width: 44px;
  height: 44px;
  border: 8px solid transparent;
  border-radius: 50%;
  background: var(--accent);
  background-clip: padding-box;
  box-shadow: inset 0 0 0 2px var(--accent-ink);
  pointer-events: auto;
  cursor: pointer;
}

.price-list-filter__track input[type="range"]:focus-visible::-webkit-slider-thumb {
  outline: 3px solid var(--accent);
  outline-offset: -6px;
}

.price-list-filter__track input[type="range"]:focus-visible::-moz-range-thumb {
  outline: 3px solid var(--accent);
  outline-offset: -6px;
}

.price-list-filter__chips {
  display: flex;
  gap: var(--space-1);
  margin-block-start: var(--space-1);
}

.price-list-filter__chip {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
}

.price-list-filter__chip input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
}

.price-list-filter__chip > span:not(.visually-hidden) {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 var(--space-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  cursor: pointer;
}

.price-list-filter__chip:has(input:checked) > span:not(.visually-hidden) {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

/* Properties (stage 4): chips as wide as their text, on as many lines as they need. */
.price-list-filter__chips--text {
  flex-wrap: wrap;
}

.price-list-filter__chips--text .price-list-filter__chip {
  flex: 0 1 auto;
}

.price-list-filter__chips--text .price-list-filter__chip > span:not(.visually-hidden) {
  padding: 0 var(--space-3);
  text-align: center;
}

/* Outside the chip: a checked chip is filled with the accent colour. */
.price-list-filter__chip:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-m);
}

.price-list-filter__status {
  margin: 0;
  color: var(--ink-muted);
}

.price-list-filter__status:empty {
  display: none;
}

.price-list-filter .button {
  min-height: 44px;
}

/* --- Wide screens: an iPad, a desktop --------------------------------------------------------- */

/* On a phone the link is a part of the filter like the others, and the count and the reset button
   close the filter, below whatever is unfolded. */
.price-list-filter__bar {
  display: contents;
}

.price-list-filter__foot {
  display: grid;
  order: 1;
  gap: var(--space-3);
}

/* Nothing filters: no foot. */
.price-list-filter__foot:has(.price-list-filter__status:empty) {
  display: none;
}

/*
 * On a screen at least 44rem wide (the smallest iPad in portrait is 744 px) and 40rem high (a
 * phone in landscape is lower and keeps the layout of a phone) the page takes the width it gets.
 * The filter stands above the list, folded like on a phone so the list has the room: the maturity
 * range and the use side by side, under them the line of the link. Unfolded, the parts of the
 * advanced search follow side by side, each as wide as its chips, on as few lines as they need.
 */
@media (min-width: 44rem) and (min-height: 40rem) {
  .home-page:has(.price-list-page) .home-header__inner,
  .home-page:has(.price-list-page) .home-shell,
  .application-body > .home-content.price-list-page {
    width: min(calc(100% - (2 * var(--space-6))), 80rem);
  }

  .price-list-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3) var(--space-5);
  }

  /* The link's line: the count and the reset button in the rest of it, where they have their place
     whether or not something filters, so the list does not jump on the first tick. */
  .price-list-filter__bar {
    display: flex;
    flex: 0 0 100%;
    align-items: center;
    gap: var(--space-5);
  }

  .price-list-filter__foot {
    display: flex;
    flex: 1 1 0;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-1) var(--space-3);
    white-space: nowrap;
  }

  /* The parts of the advanced search line up as one row of parts. */
  .price-list-filter__advanced {
    display: contents;
  }

  .price-list-filter__name {
    flex: 0 0 20rem;
    width: auto;
  }

  .price-list-filter__maturity {
    flex: 1 1 14rem;
    max-width: 24rem;
  }

  .price-list-filter__stars .price-list-filter__chip {
    flex: 0 0 2.75rem;
  }

  .price-list__head,
  .price-list__summary {
    grid-template-columns: minmax(0, 1fr) 4.5rem 4.5rem 7rem;
  }

  /* A price is a row of the details like a fact: its amount starts where the values start. */
  .price-list__price {
    display: contents;
  }
}

/*
 * In landscape the filter is a column of its own left of the page, from the heading down, and
 * stays in sight while the list scrolls, so a tick shows its effect at once. Where the screen is
 * lower than the filter it scrolls in itself, with the count and the reset button kept at its
 * foot. Without the filter (no variety, or no JavaScript) the page keeps its one column.
 */
@media (min-width: 60rem) and (min-height: 40rem) and (orientation: landscape) {
  .price-list-page .home-section:has(.price-list-filter:not([hidden])) {
    grid-template-columns: 24rem minmax(0, 1fr);
    column-gap: var(--space-6);
    align-items: start;
  }

  .price-list-page .home-section:has(.price-list-filter:not([hidden])) > *,
  .price-list__results {
    grid-column: 2;
  }

  /* Filter and list are parts of the page's grid. */
  .price-list__filtered {
    display: contents;
  }

  /* Down the rows of everything beside it: heading, subtitle, list, date and notes. */
  .price-list-filter {
    --price-list-filter-top: calc(var(--home-header-height, 0px) + var(--space-6));
    position: sticky;
    top: var(--price-list-filter-top);
    display: grid;
    grid-column: 1;
    grid-row: 1 / span 5;
    align-items: start;
    max-height: calc(100dvh - var(--price-list-filter-top) - var(--space-4));
    margin-block: 0;
    padding-block-end: 0;
    overflow-y: auto;
  }

  /* The link and the foot are parts of the column like the others, the foot the last one. */
  .price-list-filter__bar {
    display: contents;
  }

  .price-list-filter__name {
    width: 100%;
  }

  .price-list-filter__maturity {
    max-width: none;
  }

  .price-list-filter__stars .price-list-filter__chip {
    flex: 1 1 0;
  }

  .price-list-filter__foot {
    position: sticky;
    bottom: 0;
    justify-content: space-between;
    padding-block: var(--space-2) var(--space-3);
    border-top: 1px solid var(--line);
    background: var(--surface);
  }

  /* Nothing filters: no bar at the foot. The parts above it do not move when it comes. */
  .price-list-filter:has(.price-list-filter__status:empty) {
    padding-block-end: var(--space-3);
  }

  /* The gap of the page's grid already sets the first group that shows apart from what stands above it. */
  .price-list__results > :nth-child(1 of .price-list__group:not([hidden])) {
    margin-block-start: 0;
  }
}

/* --- Backend: list and form of the varieties (stage 4) ---------------------------------------- */

/* The visually hidden heading of the action column is positioned absolutely. Without a positioned
   scroll container it escapes the clipping and the whole page scrolls sideways by as much as the
   table is wider than the window, which the properties column makes it. */
.variety-table-scroll {
  position: relative;
}

/* The priorities of the filters in the form of the head: one short number field per kind. */
.filter-priorities {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: var(--space-4);
  margin-block-start: var(--space-4);
}

.variety-properties {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: var(--space-4);
  margin-block-start: var(--space-4);
}

/* The selling point of a property, under its checkbox: there once the property is ticked, and
   while a text stands in it. */
.variety-properties__benefit {
  width: 100%;
  min-height: 0;
  margin: 0 0 var(--space-3);
  font-size: 0.9375rem;
  /* Grows with its text where the browser can; elsewhere it scrolls. */
  field-sizing: content;
}

.checkbox:not(:has(:checked)) + .variety-properties__benefit:placeholder-shown {
  display: none;
}

.variety-properties__group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.template-section .variety-properties__group legend {
  margin: 0;
  font-size: 0.86rem;
}
