/*
 * Product pages (11 October 2026): a product's own page, the products page, a maker's page and a kind's page.
 *
 *   design-system/buildbatch/pages/product-pages.md   what this implements, and why
 *
 * Loaded after app.css by those pages only. Tokens from site.css only, never a raw colour. No shadows, nothing sticky,
 * no motion of its own. Phone first: a table of rooms or of products is one block a row below 40rem, so nothing is read
 * by scrolling sideways, and the page never scrolls sideways.
 */

/* ---- the top of a product's page: what it is, the one-line answer, the way into the planner ---- */
.product-hero {
  display: grid;
  gap: var(--space-lg);
  align-items: start;
  margin-top: var(--space-sm);
}

.product-hero h1 {
  margin-top: var(--space-xs);
}

.product-hero__kind {
  margin: 0;
  color: var(--color-muted-foreground);
  font-size: var(--text-sm);
}

.product-hero__kind a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

.product-hero__answer {
  margin-top: var(--space-smd);
  font-size: var(--text-lg);
  line-height: 1.45;
}

.product-hero__source {
  margin-top: var(--space-sm);
  max-width: 42rem;
}

.product-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-md);
  align-items: center;
  margin-top: var(--space-md);
}

.product-hero__actions a:not(.button) {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  font-weight: 600;
}

/* The tin is decoration beside the words: a plain tin with the names as text, never the maker's packaging. */
.product-hero__art {
  display: none;
  margin: 0;
}

.product-hero__art .ill {
  width: 10rem;
}

.product-hero__art figcaption {
  max-width: 10rem;
  margin-top: var(--space-xs);
  color: var(--color-muted-foreground);
  font-size: var(--text-xs);
  line-height: 1.35;
}

@media (min-width: 48rem) {
  .product-hero {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-2xl);
  }

  .product-hero__art {
    display: block;
    padding-top: var(--space-sm);
  }
}

/* ---- the figures, as a row to scan: the number is the loudest thing, whose figure it is sits under it ---- */
.figure-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
  margin: var(--space-lg) 0 0;
}

.figure-row__item {
  min-width: 0;
  padding: var(--space-smd) var(--space-md);
  border: var(--border-thin) solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-card);
}

/* The answer for a room is the result: it carries the lime edge a result has, and nothing else on the row does. */
.figure-row__item--result {
  border-color: var(--color-primary);
  border-left: 0.375rem solid var(--color-accent);
}

.figure-row dt {
  color: var(--color-muted-foreground);
  font-size: var(--text-sm);
  font-weight: 600;
}

.figure-row dd {
  margin: var(--space-xs) 0 0;
}

.figure-row__value {
  display: block;
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.figure-row__value--long {
  font-size: var(--text-lg);
  line-height: 1.25;
}

.figure-row__unit {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
}

.figure-row__note {
  display: block;
  margin-top: var(--space-xs);
  color: var(--color-muted-foreground);
  font-size: var(--text-sm);
  line-height: 1.35;
}

@media (min-width: 48rem) {
  .figure-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-md);
  }

  .figure-row--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .figure-row__value {
    font-size: var(--text-2xl);
  }

  .figure-row__value--long {
    font-size: var(--text-xl);
  }
}

/* ---- a section of a product's page ---- */
.product-section {
  margin-top: var(--space-2xl);
}

.product-section > h2 {
  font-size: var(--text-xl);
}

.product-section > .maker-quote {
  margin-top: var(--space-md);
}

.product-section > h2 + p,
.product-section__lead {
  max-width: 42rem;
  margin-top: var(--space-sm);
}

.product-section h3 {
  margin-top: var(--space-lg);
  font-size: var(--text-lg);
}

.product-section__notes {
  max-width: 46rem;
  margin: var(--space-md) 0 0;
  padding-left: var(--space-lg);
  color: var(--color-muted-foreground);
  font-size: var(--text-sm);
}

.product-section__notes li {
  margin-top: var(--space-xs);
}

.product-split {
  display: grid;
  gap: var(--space-lg);
  margin-top: var(--space-md);
}

@media (min-width: 56rem) {
  .product-split {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: var(--space-xl);
    align-items: start;
  }
}

/* The maker's own words, quoted, with where they were read. A graphite rule on the left says "quoted"; no colour does. */
.maker-quote {
  max-width: 46rem;
  margin: 0;
  padding: var(--space-md);
  border: var(--border-thin) solid var(--color-border);
  border-left: 0.25rem solid var(--color-primary);
  border-radius: var(--radius);
  background: var(--color-card);
}

.maker-quote blockquote {
  margin: 0;
  font-size: var(--text-lg);
  line-height: 1.4;
}

.maker-quote figcaption {
  margin-top: var(--space-sm);
  color: var(--color-muted-foreground);
  font-size: var(--text-sm);
}

.maker-quote + .maker-quote {
  margin-top: var(--space-md);
}

/* "When the figure runs short": a short name and a sentence each. */
.short-list {
  margin: 0;
}

.short-list dt {
  margin-top: var(--space-md);
  font-weight: 600;
}

.short-list dt:first-child {
  margin-top: 0;
}

.short-list dd {
  max-width: 42rem;
  margin: var(--space-xs) 0 0;
}

/* ---- a table of facts: rooms, tins, products. A table from 40rem; below it, one block a row ---- */
.fact-table-wrap {
  margin-top: var(--space-md);
  border: var(--border-thin) solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-card);
  overflow: hidden;
}

.fact-table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.fact-table caption {
  padding: var(--space-smd) var(--space-md) var(--space-sm);
  text-align: left;
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.2;
}

.fact-table th,
.fact-table td {
  padding: var(--space-sm) var(--space-md);
  border: 0;
  border-top: var(--border-thin) solid var(--color-border);
  text-align: left;
  vertical-align: top;
}

.fact-table thead th {
  border-top: 0;
  border-bottom: var(--border-control) solid var(--color-primary);
  background: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.3;
}

.fact-table thead th a {
  color: inherit;
}

.fact-table tbody th {
  font-weight: 600;
}

.fact-table__sub {
  display: block;
  color: var(--color-muted-foreground);
  font-size: var(--text-sm);
  font-weight: 400;
}

.fact-table__buy {
  display: block;
  font-weight: 600;
}

.fact-table a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

.fact-table tbody th a {
  min-height: 0;
}

/* The row the page's first sentence reads aloud. */
.fact-table tr.is-typical > * {
  background: var(--color-background);
}

.fact-table tr.is-typical > th {
  border-left: 0.25rem solid var(--color-primary);
}

@media (max-width: 39.99rem) {
  .fact-table--stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .fact-table--stack,
  .fact-table--stack tbody,
  .fact-table--stack tr,
  .fact-table--stack th,
  .fact-table--stack td {
    display: block;
  }

  .fact-table--stack tr {
    padding: var(--space-smd) var(--space-md);
    border-top: var(--border-thin) solid var(--color-border);
  }

  .fact-table--stack caption {
    display: block;
  }

  .fact-table--stack th,
  .fact-table--stack td {
    padding: 0;
    border: 0;
  }

  .fact-table--stack tbody th {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: 700;
  }

  .fact-table--stack tbody th .fact-table__sub {
    display: inline;
    margin-left: var(--space-sm);
    font-family: var(--font-body);
  }

  .fact-table--stack td {
    display: grid;
    grid-template-columns: minmax(0, 9.5rem) minmax(0, 1fr);
    gap: var(--space-sm);
    margin-top: var(--space-xs);
  }

  .fact-table--stack td::before {
    content: attr(data-label);
    color: var(--color-muted-foreground);
    font-size: var(--text-sm);
  }

  .fact-table--stack td[data-label=""]::before {
    content: none;
  }

  .fact-table--stack td[data-label=""] {
    display: block;
  }

  .fact-table--stack tr.is-typical > th {
    border-left: 0;
  }

  .fact-table--stack tr.is-typical {
    border-left: 0.25rem solid var(--color-primary);
    background: var(--color-background);
  }
}

/* ---- where to buy it: the links a list would give, said plainly. A panel like any other, never a banner ---- */
.buy {
  margin-top: var(--space-md);
  padding: var(--space-md);
  border: var(--border-thin) solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-card);
}

.buy h3 {
  margin-top: 0;
  font-size: var(--text-lg);
}

.buy__tins {
  margin: var(--space-smd) 0 0;
  padding: 0;
  list-style: none;
}

.buy__tin {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-sm) var(--space-md);
  align-items: center;
  padding: var(--space-smd) 0;
  border-top: var(--border-thin) solid var(--color-border);
}

.buy__tin:first-child {
  border-top: 0;
  padding-top: 0;
}

/* The shop's own picture of the product (ADR 0026): small, square, on white as the network gives it, beside the words that name it. */
.buy__picture {
  flex: none;
  width: 3rem;
  height: 3rem;
  object-fit: contain;
  border: var(--border-thin) solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-card);
}

.buy__tin--pictured {
  grid-template-columns: auto minmax(0, 1fr);
}

.buy__words {
  min-width: 0;
}

.buy__size {
  font-weight: 600;
}

.buy__name {
  display: block;
  color: var(--color-muted-foreground);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.buy__price {
  display: block;
  margin-top: var(--space-xs);
}

.buy__amount {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.buy__go {
  grid-column: 1 / -1;
}

.buy__go .button {
  width: 100%;
  justify-content: flex-start;
  gap: var(--space-sm);
  text-decoration: none;
}

.buy__terms,
.buy__disclosure,
.buy__sentence {
  max-width: 46rem;
  margin: var(--space-smd) 0 0;
  color: var(--color-muted-foreground);
  font-size: var(--text-sm);
}

.buy__searches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
  margin: var(--space-smd) 0 0;
  padding: 0;
  list-style: none;
}

.buy__searches .button {
  width: 100%;
  gap: var(--space-xs);
  padding-inline: var(--space-sm);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.buy h3.buy__search-title {
  margin-top: var(--space-lg);
}

.buy > h3.buy__search-title:first-child {
  margin-top: 0;
}

@media (min-width: 40rem) {
  .buy__tin {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .buy__tin--pictured {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .buy__go {
    grid-column: auto;
  }

  .buy__go .button {
    width: auto;
  }

  .buy__searches {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 64rem) {
  .buy__searches {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* ---- a product as a card: its name, and the maker's figures as words ---- */
.product-cards {
  display: grid;
  gap: var(--space-smd);
  margin: var(--space-md) 0 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 40rem) {
  .product-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 64rem) {
  .product-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-md);
  }
}

.product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: var(--space-md);
  border: var(--border-thin) solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-card);
  transition: border-color var(--duration-state) var(--ease-out);
}

.product-card__name {
  margin: 0;
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.2;
}

.product-card__name a {
  color: var(--color-primary);
  text-decoration: none;
}

/* The whole card is the link, so it is an easy tap. */
.product-card__name a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}

.product-card:has(a:hover) {
  border-color: var(--color-primary);
}

.product-card:has(a:focus-visible) {
  outline: 3px solid var(--color-ring);
  outline-offset: 2px;
}

.product-card__name a:focus-visible {
  outline: none;
}

.product-card__kind {
  margin: var(--space-xs) 0 0;
  color: var(--color-muted-foreground);
  font-size: var(--text-sm);
}

.product-card__facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-xs) var(--space-md);
  margin: var(--space-smd) 0 0;
  padding-top: var(--space-smd);
  border-top: var(--border-thin) solid var(--color-border);
  font-size: var(--text-sm);
}

.product-card__facts dt {
  color: var(--color-muted-foreground);
}

.product-card__facts dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.product-card__coverage {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.15;
}

/* On a page that lists many products, a card on a phone is its name and one line of its figures: a hundred cards of five lines
   each were forty screens. The labels stay for a screen reader; from 40rem the card is the full one. */
@media (max-width: 39.99rem) {
  .product-cards--brief {
    gap: var(--space-sm);
  }

  .product-cards--brief .product-card {
    padding: var(--space-smd) var(--space-md);
  }

  .product-cards--brief .product-card__kind {
    display: none;
  }

  .product-cards--brief .product-card__facts {
    display: block;
    margin-top: var(--space-xs);
    padding-top: 0;
    border-top: 0;
    color: var(--color-muted-foreground);
  }

  .product-cards--brief .product-card__facts dt {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .product-cards--brief .product-card__facts dd {
    display: inline;
    font-weight: 400;
  }

  .product-cards--brief .product-card__facts dd + dt + dd::before {
    content: " · ";
  }

  .product-cards--brief .product-card__coverage {
    color: var(--color-foreground);
    font-family: var(--font-body);
    font-size: inherit;
    font-weight: 600;
  }

  /* A row of the products table on a phone: the name, then its figures on one or two lines. */
  .fact-table--brief.fact-table--stack td {
    display: inline;
    margin: 0;
    color: var(--color-muted-foreground);
    font-size: var(--text-sm);
  }

  .fact-table--brief.fact-table--stack td::before {
    content: none;
  }

  .fact-table--brief.fact-table--stack td + td::before {
    content: " · ";
    color: var(--color-muted-foreground);
  }

  /* A figure that says nothing alone ("2", "1 × 5 L") keeps its heading in front of it. */
  .fact-table--brief.fact-table--stack td.fact-table__labelled::before {
    content: " · " attr(data-label) ": ";
  }

  .fact-table--brief.fact-table--stack td .fact-table__buy,
  .fact-table--brief.fact-table--stack td .fact-table__sub {
    display: inline;
    font-weight: 400;
  }

  .fact-table--brief.fact-table--stack td .fact-table__sub::before {
    content: " (";
  }

  .fact-table--brief.fact-table--stack td .fact-table__sub::after {
    content: ")";
  }

  .fact-table--brief.fact-table--stack tbody th {
    font-size: var(--text-base);
  }
}

/* ---- the products page: the ways in, and the groups ---- */
.products-jump {
  margin-top: var(--space-lg);
}

.products-jump__title {
  margin: 0;
  color: var(--color-muted-foreground);
  font-size: var(--text-sm);
  font-weight: 600;
}

.products-jump ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin: var(--space-sm) 0 0;
  padding: 0;
  list-style: none;
}

.products-jump a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: 2.75rem;
  padding: 0 var(--space-smd);
  border: var(--border-thin) solid var(--color-control-border);
  border-radius: var(--radius);
  background: var(--color-card);
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  transition: background-color var(--duration-state) var(--ease-out);
}

.products-jump a:hover {
  background: var(--color-muted);
}

.products-jump a[aria-current] {
  border: var(--border-control) solid var(--color-primary);
  background: var(--color-muted);
}

.products-jump__count {
  color: var(--color-muted-foreground);
  font-weight: 400;
}

.product-kind {
  margin-top: var(--space-2xl);
}

.product-kind > h2 {
  font-size: var(--text-xl);
}

.product-kind > h2 a,
.product-brand > h3 a {
  color: inherit;
}

.product-brand {
  margin-top: var(--space-lg);
}

.product-brand > h3 {
  font-size: var(--text-lg);
}

/* From 64rem a maker's name stands beside its products, so a maker with one product does not take a row of its own height twice. */
@media (min-width: 64rem) {
  .product-brand {
    display: grid;
    grid-template-columns: 11rem minmax(0, 1fr);
    gap: var(--space-lg);
    align-items: start;
    padding-top: var(--space-lg);
    border-top: var(--border-thin) solid var(--color-border);
  }

  .product-brand > h3 {
    margin-top: var(--space-md);
  }

  .product-brand > .product-cards {
    margin-top: 0;
  }
}

.products-sort {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
  margin: var(--space-md) 0 0;
  font-size: var(--text-sm);
}

.products-sort__note {
  max-width: 46rem;
  margin: var(--space-sm) 0 0;
  color: var(--color-muted-foreground);
  font-size: var(--text-sm);
}

/* ---- the ways on from a page: the guides that explain its figures, and where they were read ---- */
.product-links {
  max-width: 46rem;
  margin: var(--space-md) 0 0;
  padding-left: var(--space-lg);
}

.product-links li {
  margin-top: var(--space-sm);
}

.product-sources {
  max-width: 46rem;
  margin: var(--space-md) 0 0;
  padding-left: var(--space-lg);
}

.product-sources li {
  margin-top: var(--space-sm);
}

.product-status {
  max-width: 42rem;
  margin: var(--space-md) 0 0;
  padding-left: var(--space-smd);
  border-left: var(--border-control) solid var(--color-accent);
  font-size: var(--text-sm);
}

@media print {
  .product-hero__art,
  .buy,
  .products-jump,
  .products-sort {
    display: none;
  }
}
