:root {
  --fn-col-width: 4em;
  --fn-category-col-width: 8em;
}

body [hidden] { display: none; }

dl.meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1.25rem;
  margin: 0;
  font-size: 0.95rem;
}

dl.meta dt {
  color: var(--page_color_foreground-secondary);
  font-weight: 500;
}

dl.meta dd { margin: 0; }

table td.currency.no-value::before {
  content: '-';
  color: var(--page_color_foreground-secondary);
}

table.functions col.fn-key {
  min-width: unset;
  width: var(--fn-col-width);
}

table.functions col.category {
  min-width: unset;
  width: var(--fn-category-col-width);
}

table.functions td.category {
  text-align: center;
}

table td[data-validity='invalid'] {
  color: var(--error_color);
}

table td[data-validity='invalid']::after {
  content: '≠ £' attr(data-calculated-cost);
}

#status[hidden] { display: none; }

.catalogue-filter-area label {
  display: block;
  color: var(--page_color_foreground-secondary);
}

.catalogue-filter-area .form-row {
  position: relative;
  margin: 0 0 16px;
}

.catalogue-filter-area input {
  width: 100%;
  padding: 4px 8px 4px 32px;
}

.catalogue-filter-area .accessory {
  position: absolute;
  left: 8px;
  top: 50%;
  margin-top: -8px;
  pointer-events: none;
}

.catalogue-filter-status {
  margin: 0 0 0.75rem;
  color: var(--page_color_foreground-secondary);
}

#catalogue-list {
  border-radius: var(--generic-subtle_border_radius);
  border: 1px solid var(--table-header_color_background);
  background-color: var(--table_color_background);
  box-shadow: 0 2px 4px var(--generic_color_shadow);
  overflow: hidden;
}

#catalogue-list .catalogue-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto auto;
  gap: 0 12px;
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--table-row_color_border);
  text-decoration: none;
  color: inherit;
  background: var(--table_color_background) linear-gradient(to top, transparent, var(--_color-overlay));
  transition: background-color 0.2s;
}

#catalogue-list .catalogue-item:last-child {
  border-bottom: none;
}

#catalogue-list a.catalogue-item:hover {
  background-color: var(--page-section_color_background-alternate);
}

#catalogue-list a.catalogue-item:active {
  background-color: var(--link-light_color_hover);
}

#catalogue-list .catalogue-item .item-image {
  grid-column: 1;
  grid-row: 1 / span 3;
  width: 100px;
  margin: -10px 0;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: white; /* Photos have white background */
  transition: opacity 0.2s;
}

#catalogue-list a.catalogue-item .item-image {
  opacity: 0.9;
}

#catalogue-list .catalogue-item:hover .item-image {
  opacity: 1;
}

#catalogue-list .catalogue-item .item-image img {
  width: auto;
  max-width: 100%;
  height: auto;
}

#catalogue-list .catalogue-item .item-running-number,
#catalogue-list .catalogue-item .item-model-summary,
#catalogue-list .catalogue-item .item-meta {
  grid-column: 2;
}

#catalogue-list .catalogue-item .item-running-number {
  font-weight: bold;
}

#catalogue-list .catalogue-item .item-meta {
  color: var(--page_color_foreground-secondary);
}

#catalogue-list .catalogue-item .icon {
  grid-column: 3;
  grid-row: 1 / span 3;
  display: flex;
  align-items: center;
  justify-content: center;
}

#tabs {
  max-width: 100%;
  display: inline-flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px;
  list-style-type: "";
  padding-inline-start: 0;
  border-radius: var(--button_border_radius);
  border: var(--button_border_thickness) solid var(--button-primary_color_background);
  color: var(--page_color_foreground);
  padding: 1px;
  margin: 10px auto;
  overflow: auto;
}

#tabs button {
  border: none;
  text-transform: capitalize;
}

#tabs button:hover {
  background: var(--button-primary_color_background-hover);
}

#tabs button[aria-pressed="true"] {
  background: var(--button-primary_color_background);
  color: var(--button-primary_color_foreground);
}

#tabs button .count {
  background: var(--tag_color_background);
  color: var(--tag_color_foreground);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  min-width: 24px;
  min-height: 24px;
  text-align: center;
  font-size: smaller;
  margin-left: 10px;
  padding: 2px 4px;
}

#tabs button[aria-pressed="true"] .count {
  background: var(--button-primary_color_background-active);
}

#toc-container {
  --page-section_padding_top: var(--hero-small_padding_vertical);
  --page-section_padding_bottom: var(--hero-small_padding_vertical);
}

#toc {
  border-radius: var(--generic-subtle_border_radius);
  background-color: var(--page_color_background);
  border: 1px solid var(--page_color_background);
  transition: border-color 0.2s;
  overflow: hidden;
}

#toc summary {
  font-size: small;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 12px;
  transition: background-color 0.2s, color 0.2s;
  cursor: pointer;
}

#toc summary:hover,
#toc[open] summary {
  background-color: var(--table-header_color_background);
  color: var(--table-header_color_foreground);
}

#toc summary::marker {
  content: '';
  display: none;
}

#toc .icon-open {
  transition: transform 0.2s;
}

#toc[open] {
  border-color: var(--table-header_color_background);
}

#toc[open] summary {
  background-color: var(--table-header_color_background);
  color: var(--table-header_color_foreground);
}

#toc[open] .icon-open {
  transform: rotate(90deg);
}

.scroll-table-container {
  overflow-x: auto;
  padding: 1px;
}

.heading-with-icon {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.fn-key {
  font-variant-numeric: tabular-nums;
  font-weight: bold;
  white-space: nowrap;
  vertical-align: top;
}

.notes {
  color: var(--page_color_foreground-secondary);
  font-size: small;
  margin-top: 4px;
}

.badge {
  display: inline-block;
  font-size: small;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--tag_color_background);
  color: var(--tag_color_foreground);
  text-transform: capitalize;
}

@media screen and (max-width: 40rem) {
  table.functions {
    --fn-col-width: 100%;
  }

  table.functions thead {
    display: none;
  }

  table.functions tr {
    display: grid;
    border-bottom: 1px solid var(--table-row_color_border);
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }

  table.functions tr:last-child {
    border: none;
  }

  table.functions th,
  table.functions td {
    display: block;
    border: none;
    font-weight: normal;
  }

  table.functions th::before,
  table.functions td::before {
    content: attr(data-label);
    display: block;
    color: var(--page_color_foreground-secondary);
    font-size: small;
    text-transform: uppercase;
  }

  table.functions [data-label="Key"] {
    grid-column: 1;
    grid-row: 1;
    text-align: left;
  }

  table.functions [data-label="Category"],
  table.functions td.category {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
  }

  table.functions [data-label="Label"] {
    grid-column: 1 / span 2;
    grid-row: 2;
  }

  #tabs {
    flex-wrap: nowrap;
    flex-direction: row;
    justify-content: flex-start;
  }

  #tabs li {
    flex: 0 0 max-content;
  }
}

@media print {
  html:has(#functions-panel) {
    --_print-background: white;
    --_print-foreground: black;
    --page_color_background: var(--_print-background);
    --table_color_background: var(--_print-background);
    --table_color_background-alt: var(--_print-background);
    --page_color_foreground: var(--_print-foreground);
    --page_color_foreground-secondary: var(--_print-foreground);
  }

  html:has(#functions-panel) body {
    height: auto;
    overflow: visible;
    display: block;
  }

  html:has(#functions-panel) .hide-from-print,
  html:has(#functions-panel) #page-header,
  html:has(#functions-panel) footer,
  html:has(#functions-panel) nav.breadcrumbs {
    display: none !important;
  }

  html:has(#functions-panel) .page-section,
  html:has(#functions-panel) .container {
    margin: 0;
    padding: 0;
    max-width: none;
  }

  html:has(#functions-panel) #catalogue-list {
    border: none;
    border-radius: 0;
    margin-bottom: 1rem;
  }

  html:has(#functions-panel) #catalogue-list .catalogue-item {
    background: none;
    border: none;
    padding-left: 0;
    padding-right: 0;
  }

  html:has(#functions-panel) #catalogue-list .catalogue-item .item-image {
    opacity: 1;
  }

  table.functions {
    width: 100%;
    border-collapse: collapse;
    box-shadow: none;
  }

  table.functions thead {
    display: table-header-group;
    border-bottom: 1px solid var(--_print-foreground);
  }

  table.functions tr {
    display: table-row;
    break-inside: avoid;
  }

  table.functions th,
  table.functions td {
    display: table-cell;
    background: none;
    color: #000;
    border-bottom: 1px solid var(--_print-foreground);
  }

  table.functions th::before,
  table.functions td::before {
    content: none;
  }

  table.functions [data-label="Key"],
  table.functions [data-label="Category"],
  table.functions [data-label="Label"] {
    grid-column: auto;
    grid-row: auto;
    text-align: left;
  }

  .badge {
    background: none;
    color: inherit;
    font-size: inherit;
    padding: 0;
  }

  a {
    text-decoration: none;
    color: inherit;
  }
}
