/* Flex display */
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

/* Container stlying */
.container {
  display: flex;
  flex-flow: column;
  height: 100%;
}

.container>.container-header {
  align-items: center;

  header {
    background-color: var(--tds-color--tertiary);
  }

  .global-search {
    width: 300px;
  }

  .header-schematics-page{
    display: block;
    padding: 4px 16px;
    text-align: center;
  }
}

.container>.container-header>.filter-div {
  padding: 5px 0px 5px;
  border-bottom: 1px solid var(--tds-theme-border);
}

.container>.container-body {
  flex: 1 1 auto;
  height: 85%;

  .explorer-match-highlight-all{
    font-weight: bold;
  }

  .explorer-match-highlight-selected{
    fill: var(--tds-color--blue30);
    text-decoration: underline;
    font-weight: bold;
  }
}

.container-body>.container-schematics {
  width: 100%;
  height: 95%;

  svg {  
    position: relative;
    left: 0;
    top: 0;
  
    width: 100%;
    height: 100%;

    .pin-highlight {
      cursor: pointer;
      font-weight: bold;
      fill: var(--tds-theme-primary);
      filter: drop-shadow(0px 0px 150px var(--tds-theme-primary));
    }
  }
}

.container>.container-footer {
  position: absolute;
  bottom: 0%;
  height: 36px;
  border-top: 1px solid var(--tds-theme-border);
}

/* Dark mode support */
.tds-scrim--black {
  .container-schematics, .connector-terminal-faceview {
    filter: invert(1);
  }
  .connector-connector-location {
    filter: brightness(0.8);
  }
}

/* Header modal */
.page-list-nav-title {
  padding-top: 0px;
  padding-bottom: 20px;
  text-decoration: underline;
}

.page-list-nav-link-container {
  padding-bottom: 7px;
}

.user-tutorial-section {
  li {
    padding: 3px 0px;
  }

  .keyboard-shortcuts {
    padding-left: 40px;
    padding-right: 100px;

    li {
      display: flex; 
      justify-content: space-between;
    }
  }
}

/* Header filter menu */

.filter-cell-text-center {
  text-align: center;
}
.filter-cell-text-right {
  text-align: right;
  padding: 0 10px;
}
.filter-table {
  margin: auto;
}

/* Explorer modal */
.explorer-modal {
  position: absolute;
  margin-top: 3px;
  max-height: 170px;

  background-color: var(--tds-theme-background-dialog);
  border-bottom-left-radius: 5px;
  border-bottom-right-radius: 5px;
  opacity: 0.99;
  padding: 5px 40px 5px 0px;

  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  z-index: 1;

  .explorer-nav{
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;

    padding: 5px 0px;

    .tds-modal-close {
      position: absolute;
      margin-left: 10px;
      margin-right: 10px;
      right: 0px;
      width: 40px;
      z-index: 5;
    }
  }

  .explorer-progress {
    padding: 0px 15px 0px 15px;
    width: 90px;

    font-size: 12px;
    font-weight: bold;
    line-height: 15px;
    text-align: center;
  }

  .explorer-error {
    /* Overlap explorer navigation */
    position: absolute;
    left: 0;
    top: 0;
    width: 86%;
    height: 60px;
    background-color: var(--tds-theme-background-dialog);
    z-index: 5;

    /* Align text in the center */
    display: none;
    justify-content: center;
    align-items: center;
    text-align: center;

    font-size: 16px;
    font-weight: bold;
    white-space: pre;
    color: var(--tds-color--error);
  }

  .explorer-pages {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;

    width: 300px;
    /* manually center */
    margin-left: 40px;
    margin-top: 5px;
    padding: 5px 5px 0px 5px;

    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
    border-top: 1px solid var(--tds-theme-border);
  
    overflow-y: auto;
    font-size: 11px;

    .explorer-pages-list-div {
      padding-bottom: 5px;
      a {
        cursor: pointer;
      }
    }
  }
}

/* Connector modal (popup) */

.connector-modal{
  max-height: 600px;
  width: 350px;
  padding: 5px;

  background-color: var(--tds-theme-background-dialog);
  border: 1px solid var(--tds-theme-border);
  border-radius: 3px;

  font-size: 15px;
  text-align: center;

  .connector-pin-number {
    font-weight: bold;
    border-bottom: 1px solid var(--tds-theme-border);
    padding: 5px;
  }

  .connector-terminal-faceview img {
    max-height: 150px;
    max-width: 340px;
    padding-top: 10px
  }

  .connector-connector-location img {
    height: 250px;
    max-width: 340px;
    padding-bottom: 10px;
  }

  .connector-connector-information, .connector-terminal-information {
    line-height: 15px;
    text-align: left;
    padding: 6px 10px;
    border-top: 1px solid var(--tds-theme-border);
    p {
      padding-bottom: 3px;
      font-weight: 500;
    }
    div {
      font-size: 12px;
      padding-left: 20px;
    }
  }
  .connector-terminal-information, .connector-diagnostic-information {
    border-top: 1px solid var(--tds-theme-border);
  }
}

/* SVG view control */
.svg-controls {
  position: absolute;
  top: 120px;
  left: 1%;
  z-index: 5;
  opacity: 0.9;
}

/* Schematics page control */
.schematics-controls {
  z-index: 5;
  opacity: 0.9;
  font-size: 12px;

  span {
    line-height: 15px;
  }

  #schematics-next, #schematics-prev{
    position: absolute;
    bottom: 45px;
    width: 250px;
    height: 45px;
  }

  #schematics-next{
    right: 1%;
    padding-left: 50px;
    padding-right: 20px;
  }

  #schematics-prev{
    left: 1%;
    padding-left: 20px;
    padding-right: 50px;
  }

  .schematics-next-icon, .schematics-prev-icon {
    position: absolute;
    width: 30px;
  }

  .schematics-next-icon {
    left: 10px;
  }

  .schematics-prev-icon {
    right: 10px;
  }
}

/* Search highlight style */
g > text.search-highlight {
  fill: var(--tds-theme-primary);;
  font-weight: bold;
}

g > path.search-highlight {
  fill: var(--tds-theme-primary);
  fill-opacity: 0.4;
}

/* Hover over styles */
path.connector-block-shadow {
  fill: var(--tds-theme-primary);
  fill-opacity: 0.2;
  stroke: var(--tds-theme-primary-highlight);
  filter: drop-shadow(0px 0px 100px var(--tds-theme-primary));
  cursor: pointer;
}

/* Connector pinout grid (same layout and colours as EDST) */
:root {
  --pinout-cell-height: 2.25rem;
}

.tds-scrim--black .connector-terminal-faceview:has(.image-placeholder) {
  filter: none;
}

.pinout-grid {
  display: grid;
  gap: 3px;
  width: min(100%, calc(var(--pinout-columns) * 96px));
  margin: 0 auto;
  padding: 4px 8px;
}

.pinout-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: var(--pinout-cell-height);
  padding: 2px 3px;
  overflow: hidden;
  border: 1px solid #89898c;
  border-radius: 3px;
  font-size: 0.85rem;
  line-height: 1.15;
}

.pinout-cell-name {
  font-weight: 700;
}

.pinout-cell-color {
  font-size: 0.7rem;
}

.pinout-cell--striped .pinout-cell-name,
.pinout-cell--striped .pinout-cell-color {
  padding: 0 3px;
  border-radius: 2px;
  background-color: rgba(0, 0, 0, 0.65);
  color: #fff;
}

.pinout-cell--wired,
.pinout-cell--no-color {
  cursor: pointer;
}

.pinout-cell--no-color {
  background: repeating-linear-gradient(45deg, #d4d4d8, #d4d4d8 3px, #9e9ea3 3px, #9e9ea3 6px);
  color: #202024;
  border: 1.5px solid #c2410c;
}

/* Hollow and faded, so an unused cavity can't pass for a gray wire */
.pinout-cell--unassigned {
  background: none;
  border-color: var(--tds-theme-foreground-low-contrast);
  color: var(--tds-theme-foreground-low-contrast);
  opacity: 0.55;
}

.pinout-cell--hover,
.pinout-cell--wired:hover,
.pinout-cell--no-color:hover {
  outline: 2px dashed var(--tds-theme-foreground);
  outline-offset: 1px;
}

.pinout-cell:focus-visible {
  outline: 2px solid var(--tds-theme-foreground);
  outline-offset: 1px;
}

/* "Clicked" colour of the connector pop-up: the pin clicked on the schematic, in the title, grid and table */
:root {
  --cp-clicked: #3e6ae1;
  --cp-clicked-soft: color-mix(in srgb, var(--cp-clicked) 9%, var(--tds-theme-background-container));
}

.tds-scrim--black {
  --cp-clicked: #7b9af5;
  --cp-clicked-soft: color-mix(in srgb, var(--cp-clicked) 15%, var(--tds-theme-background-container));
}

/* The clicked pin. The gap in the dialog background colour keeps the ring visible on any wire colour. */
.pinout-cell--selected {
  position: relative;
  z-index: 5;
  box-shadow: 0 0 0 2px var(--tds-theme-background-dialog), 0 0 0 4px var(--cp-clicked);
}

/* A cavity whose row is open, other than the clicked pin */
.pinout-cell--open:not(.pinout-cell--selected) {
  position: relative;
  z-index: 4;
  outline: 2px dashed var(--tds-theme-foreground-high-contrast);
  outline-offset: 2px;
}

.wire-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  border-radius: 3px;
  border: 1px solid rgba(128, 128, 128, 0.6);
  vertical-align: -2px;
}

.wire-swatch--unknown {
  background: repeating-linear-gradient(135deg, transparent 0 3px, rgba(128, 128, 128, 0.5) 3px 5px);
}

.image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 160px;
  min-height: 120px;
  padding: 10px;
  border: 1px dashed var(--tds-theme-border);
  border-radius: 6px;
  font-size: var(--tds-font-size-20);
  opacity: 0.7;
}

/* Connector pop-up (opened by clicking a pin or a connector block) */
.connector-overlay-modal {
  width: min(1180px, 94vw);
}

.connector-overlay-modal .connector-title {
  width: 100%;
}

.cp-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-right: 48px;
}

.cp-heading {
  min-width: 0;
}

.cp-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 26px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--tds-theme-foreground-high-contrast);
}

.cp-title-pin {
  color: var(--cp-clicked);
}

.cp-subtitle {
  margin-top: 2px;
  font-size: 15px;
  color: var(--tds-theme-foreground);
}

/* Connector card: labelled groups split by thin lines, like the cavity rows */
.cp-facts {
  display: flex;
  flex-wrap: wrap;
  row-gap: 12px;
}

.cp-fact {
  flex: 1 1 160px;
  min-width: 0;
  padding: 0 18px;
  border-left: 1px solid var(--tds-theme-border-low-contrast);
}

.cp-fact:first-child {
  padding-left: 0;
  border-left: 0;
}

.cp-fact .cp-label {
  margin-bottom: 4px;
}

.cp-value .wire-swatch {
  width: 12px;
  height: 12px;
  vertical-align: -1px;
}

.cp-icon-btn {
  display: inline-flex;
  padding: 6px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--tds-theme-foreground-low-contrast);
  cursor: pointer;
}

.cp-icon-btn:hover,
.cp-ref:hover {
  background: var(--tds-theme-background-container-highlight);
  color: var(--tds-theme-foreground-high-contrast);
}

.cp-ref {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--tds-theme-border);
  border-radius: 999px;
  font-size: 14px;
  white-space: nowrap;
  text-decoration: none;
  color: var(--tds-theme-foreground-high-contrast);
}

/* The bottom padding keeps the last cavities clear of the dialog's edge */
.cp-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 32px;
}

.cp-card {
  min-width: 0;
  padding: 16px 20px;
  border: 1px solid var(--tds-theme-border-low-contrast);
  border-radius: 12px;
  background: var(--tds-theme-background-container);
  box-sizing: border-box;
}

.cp-label {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tds-theme-foreground-low-contrast);
}

.cp-hint {
  margin-left: 10px;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  opacity: 0.8;
}

.cp-dim {
  color: var(--tds-theme-foreground-low-contrast);
}

.cp-color-name {
  white-space: nowrap;
  color: var(--tds-theme-foreground-low-contrast);
}

.cp-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  text-align: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--tds-theme-foreground-low-contrast);
  text-underline-offset: 3px;
}

.cp-link.cp-dim {
  color: var(--tds-theme-foreground-low-contrast);
}

.cp-link:hover {
  color: var(--tds-theme-foreground-high-contrast);
  text-decoration-color: currentColor;
}

/* Centred as a box too: TDS caps the width of paragraphs */
.cp-caption {
  margin: 8px auto 0;
  font-size: 12px;
  text-align: center;
  color: var(--tds-theme-foreground-low-contrast);
}

/* Pinout and pictures */
.cp-visuals {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 16px;
}

.cp-visuals--no-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
}

/* Big pinouts are unreadable in a third of the width: they get a full row under the pictures */
.cp-visuals--wide-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
}

.cp-visuals--wide-grid .cp-pinout {
  grid-column: 1 / -1;
}

.cp-pinout-missing {
  grid-column: 1 / -1;
  margin: -8px 0 0 4px;
  font-size: 12px;
  color: var(--tds-theme-foreground-low-contrast);
}

.cp-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
}

.cp-visual img {
  display: block;
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
}

.cp-visual .pinout-grid {
  --pinout-cell-height: 3.2rem;
}

.tds-scrim--black .cp-faceview img {
  filter: invert(1);
}

.tds-scrim--black .cp-location img {
  filter: brightness(0.8);
}

.cp-zoom {
  position: relative;
  cursor: zoom-in;
}

.cp-zoom:hover {
  border-color: var(--tds-theme-foreground-low-contrast);
}

.cp-zoom:focus-visible,
.cp-info:focus-visible,
.cp-link:focus-visible,
.cp-row-action:focus-visible,
.cp-table tr[data-cavity]:focus-visible {
  outline: 2px solid var(--tds-theme-foreground-high-contrast);
  outline-offset: 2px;
}

.cp-zoom-icon {
  position: absolute;
  top: 12px;
  right: 14px;
  color: var(--tds-theme-foreground-low-contrast);
}

.cp-zoom:hover .cp-zoom-icon {
  color: var(--tds-theme-foreground-high-contrast);
}

/* Repair kit tooltip: hover or focus, click keeps it open */
.cp-info {
  position: relative;
  display: inline-flex;
  margin-left: 2px;
  vertical-align: middle;
  color: var(--tds-theme-foreground-low-contrast);
  cursor: help;
}

.cp-info:hover,
.cp-info:focus,
.cp-info.is-open {
  color: var(--tds-theme-foreground-high-contrast);
}

.cp-tip {
  display: none;
  position: absolute;
  top: 22px;
  left: -12px;
  z-index: 10;
  width: min(320px, 70vw);
  padding: 12px 14px;
  border: 1px solid var(--tds-theme-border-low-contrast);
  border-radius: 10px;
  background: var(--tds-theme-background-dialog);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  font-size: 13px;
  line-height: 1.45;
  letter-spacing: normal;
  text-transform: none;
  color: var(--tds-theme-foreground);
}

.cp-tip b {
  font-weight: 500;
  color: var(--tds-theme-foreground-high-contrast);
}

.cp-info:hover .cp-tip,
.cp-info:focus .cp-tip,
.cp-info.is-open .cp-tip {
  display: block;
}

/* Cavities table */
/* Each re-render restores the scroll positions: they must jump, not animate (TDS makes all scrolling smooth) */
.connector-overlay-modal,
.connector-overlay-modal .tds-modal-content,
.cp-table-wrapper {
  scroll-behavior: auto;
}

/* Scrolls past 8 rows: the pop-up sets max-height, and scroll-padding-top for the sticky header */
.cp-table-wrapper {
  overflow: auto;
}

/* min-width: on narrow screens the table scrolls sideways instead of squeezing Function and Goes to */
.cp-table {
  width: 100%;
  min-width: 48rem;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 13px;
}

/* Sticky: the divider is a shadow, a collapsed border would scroll away */
.cp-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  overflow: hidden;
  padding: 8px 10px;
  text-align: left;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--tds-theme-foreground-low-contrast);
  background: var(--tds-theme-background-container);
  box-shadow: inset 0 -1px 0 var(--tds-theme-border-low-contrast);
}

/* Cav, Wire, Terminal and Circuit get fixed widths; Function and Goes to share the rest */
.cp-table th:nth-child(1) { width: 3.5rem; }
.cp-table th:nth-child(3) { width: 7.5rem; }
.cp-table th:nth-child(4) { width: 8rem; }
.cp-table th:nth-child(5) { width: 6.5rem; }

/* Wire: the longest codes (YE/LTBU, DKGN/WH) just fit with this gap; Terminal: 0.64x0.64FS fits */
.cp-table td .wire-swatch {
  margin-right: 4px;
}

.cp-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--tds-theme-border-low-contrast);
}

/* One line per cavity: longer values end with an ellipsis, the full text is in the cell's tooltip */
.cp-table tr[data-cavity] td {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Goes to: the pin always shows in full; the device name is cut only where it runs out of room */
.cp-goes {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cp-goes .cp-link {
  flex: none;
  max-width: 100%;
}

.cp-goes .cp-link.cp-dim {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
}

.cp-goes .cp-link.cp-dim span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cp-table tr[data-cavity] {
  cursor: pointer;
}

.cp-table tr.is-open td,
.cp-detail td {
  background: var(--tds-theme-background-container-alt);
  color: var(--tds-theme-foreground-high-contrast);
}

/* The clicked pin's row, and its details when open: tinted, with a bar in the clicked colour */
.cp-table tr.is-clicked td,
.cp-table tr.is-clicked + .cp-detail td {
  background: var(--cp-clicked-soft);
}

.cp-table tr.is-clicked td:first-child,
.cp-table tr.is-clicked + .cp-detail td:first-child {
  box-shadow: inset 3px 0 0 var(--cp-clicked);
}

.cp-table tr.is-clicked td:first-child {
  font-weight: 500;
}

/* After the open and clicked tints, so hovering a row (or its grid cell) always shows */
.cp-table tr[data-cavity]:hover td,
.cp-table tr.is-hover td {
  background: var(--tds-theme-background-container-highlight);
}

.cp-table tr.is-open td {
  border-bottom-color: transparent;
}

.cp-table .cp-detail td {
  padding: 0;
}

/* Open row: part-card groups side by side, split by thin lines, the row's action at the end */
.cp-detail-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  row-gap: 14px;
  padding: 14px 18px 14px 42px;
}

.cp-detail-group {
  flex: 1 1 170px;
  min-width: 0;
  padding: 0 20px;
  border-left: 1px solid var(--tds-theme-border-low-contrast);
}

.cp-detail-group:first-child {
  padding-left: 0;
  border-left: 0;
}

/* Wire and circuit are short; the terminal's part numbers and size get the room */
.cp-detail-group--wire,
.cp-detail-group--circuit {
  flex: 0 1 auto;
}

.cp-detail-group--terminal {
  flex: 1 1 240px;
}

.cp-detail-group .cp-label {
  margin-bottom: 6px;
}

/* A group's value (Tesla PN, destination pin, colour) and the small lines under it */
.cp-value {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
  color: var(--tds-theme-foreground-high-contrast);
}

.cp-value.cp-dim {
  font-weight: 400;
  color: var(--tds-theme-foreground-low-contrast);
}

.cp-value-sub,
.cp-value-line {
  margin-top: 2px;
  font-size: 12.5px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.cp-value-sub {
  color: var(--tds-theme-foreground-low-contrast);
}

.cp-kits {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Boxes in the card colour, so they stand out on the open row's tint */
.cp-kit {
  padding: 4px 9px;
  border-radius: 7px;
  background: var(--tds-theme-background-container);
  box-shadow: inset 0 0 0 1px var(--tds-theme-border-low-contrast);
}

.cp-kit span {
  display: block;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tds-theme-foreground-low-contrast);
}

.cp-kit b {
  font-size: 13px;
  font-weight: 500;
  color: var(--tds-theme-foreground-high-contrast);
}

.cp-kit b.cp-dim {
  font-weight: 400;
  color: var(--tds-theme-foreground-low-contrast);
}

.cp-size {
  font-weight: 500;
  color: var(--tds-theme-foreground-high-contrast);
}

/* Open row: the function, then the row's action on the right */
.cp-open-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -3px 0;
}

.cp-open-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cp-row-action {
  flex: none;
  padding: 3px 12px;
  border: 1px solid var(--tds-theme-border);
  border-radius: 999px;
  background: none;
  font: inherit;
  font-size: 12px;
  line-height: 18px;
  color: var(--tds-theme-foreground-high-contrast);
  cursor: pointer;
}

.cp-row-action:hover {
  background: var(--tds-theme-background-container-highlight);
}

/* Enlarged faceview or location picture */
.cp-lightbox {
  max-width: 92vw;
  max-height: 92vh;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
  cursor: zoom-out;
}

.cp-lightbox::backdrop {
  background: rgba(0, 0, 0, 0.82);
}

.cp-lightbox img {
  display: block;
  max-width: 90vw;
  max-height: 80vh;
  margin: 0 auto;
  border-radius: 10px;
  object-fit: contain;
}

.cp-lightbox--faceview img {
  padding: 24px;
  background: #fff;
}

/* A white faceview would flash a dark-mode screen */
.tds-scrim--black .cp-lightbox--faceview img {
  filter: invert(1);
}

/* Location photos can't be inverted, so they are dimmed instead */
.tds-scrim--black .cp-lightbox:not(.cp-lightbox--faceview) img {
  filter: brightness(0.7);
}

.cp-lightbox-bar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 12px;
  font-size: 15px;
  color: #fff;
}

.cp-lightbox-hint {
  font-size: 13px;
  opacity: 0.7;
}

@media (max-width: 900px) {
  .cp-header {
    flex-direction: column;
  }

  .cp-visuals,
  .cp-visuals--no-grid,
  .cp-visuals--wide-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Page loader */
.page-loader {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  pointer-events: none;
}

.container-body.is-loading .page-loader {
  display: block;
}

.page-loader-spinner {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--tds-theme-border);
  border-top-color: var(--tds-theme-primary);
  animation: page-loader-spin 0.8s linear infinite;
}

@keyframes page-loader-spin {
  to { transform: rotate(360deg); }
}

/* Responsive display */

@media screen and (max-width: 1500px) {
  .filter-option-code {
    display: none !important;
  }
}

@media screen and (max-width:960px) {
  .filter-device-pin {
    display: none !important;
  }
}

@media screen and (max-width:800px) {
  .list-schematics-title {
    display: none !important;
  }
}

@media screen and (max-width: 600px) {
  .svg-controls {
    display: none !important;
  }
}



/* Connector Reference pages (connector_ref.html): the program's connectors in a list beside the selected connector.
   Cards, facts, pinout and pictures are the connector pop-up's (cp-*). */
html.cr-page,
html.cr-page body {
  height: 100%;
  overflow: hidden;
  background: var(--tds-theme-background);
  color: var(--tds-theme-foreground);
}

#cr-root {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.cr-dim {
  color: var(--tds-theme-foreground-low-contrast);
}

.cr-header {
  flex: none;
  gap: 16px;
  padding-inline: 24px;
  background: var(--tds-theme-background-container);
  border-bottom: 1px solid var(--tds-theme-border-low-contrast);
}

.cr-search {
  align-self: center;
  max-inline-size: 460px;
}

.cr-search .tds-form-input {
  inline-size: 100%;
}

.cr-split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}

/* List of connectors */
.cr-aside {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px 12px 0;
  border-right: 1px solid var(--tds-theme-border-low-contrast);
  background: var(--tds-theme-background-container);
}

.cr-filters {
  flex: none;
  inline-size: 100%;
}

.cr-filters .tds-tab {
  flex: 1;
  gap: 4px;
  padding-inline: 6px;
  font-size: 12px;
}

.cr-aside-count {
  margin: 10px 4px 6px;
  font-size: 12px;
  color: var(--tds-theme-foreground-low-contrast);
}

.cr-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0;
  padding: 0 0 16px;
  list-style: none;
}

.cr-list li[hidden],
.cr-empty[hidden] {
  display: none;
}

.cr-list a {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--tds-theme-foreground-high-contrast);
  text-decoration: none;
  font-size: 13px;
}

.cr-list a b {
  font-weight: 500;
}

.cr-list a .cr-dim {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
}

.cr-list a:hover {
  background: var(--tds-theme-background-container-highlight);
}

/* The open connector, marked like the pop-up's clicked pin */
.cr-list a.is-active {
  background: var(--cp-clicked-soft);
  box-shadow: inset 3px 0 0 var(--cp-clicked);
}

.cr-chip-small {
  --tds-chip--height: 20px;
  padding-inline: 8px;
  font-size: 11px;
}

.cr-empty {
  padding: 12px 8px;
  color: var(--tds-theme-foreground-low-contrast);
}

.cr-footer {
  flex: none;
  padding: 10px 4px 12px;
  border-top: 1px solid var(--tds-theme-border-low-contrast);
  font-size: 12px;
  color: var(--tds-theme-foreground-low-contrast);
}

/* The open connector: fits the window, the cavities take the remaining height and scroll on their own */
.cr-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.cr-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 24px;
  box-sizing: border-box;
}

.cr-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.cr-heading-main {
  min-width: 0;
}

.cr-title-line {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cr-title {
  margin: 0;
  padding: 0;
  font-size: 28px;
  line-height: 32px;
  font-weight: 500;
  color: var(--tds-theme-foreground-high-contrast);
}

/* As tall as the title line, centred on it */
.cr-title-btn {
  --tds-height--pill: 32px;
  flex: none;
  gap: 6px;
  text-decoration: none;
}

/* One step quieter than the connector ID, with room under the title line */
.cr-device {
  margin: 10px 0 0;
  padding: 0;
  font-size: 16px;
  line-height: 22px;
  color: var(--tds-theme-foreground);
}

/* Its height is kept while the "Drawn on" chips load, so the table below doesn't move */
.cr-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  min-height: 26px;
  margin-top: 14px;
  font-size: 12px;
}

.cr-mate {
  margin-right: 8px;
  color: var(--tds-theme-foreground);
}

.cr-sheets {
  display: contents;
}

.cr-sheets .tds-chip {
  --tds-chip--height: 26px;
  font-size: 12px;
  text-decoration: none;
  border: 1px solid var(--tds-theme-border-low-contrast);
}

.cr-sheets .tds-chip:hover {
  background: var(--tds-theme-background-container-highlight);
}

.cr-facts-card {
  flex: 0 1 auto;
  padding: 12px 18px;
}

.cr-facts-card .cp-facts {
  flex-wrap: nowrap;
}

.cr-facts-card .cp-fact {
  flex: 0 0 auto;
  white-space: nowrap;
}

.cr-main .cp-card {
  padding: 14px 18px;
}

.cr-main .cp-visual {
  min-height: 0;
  height: 170px;
}

.cr-main .cp-visual img {
  max-height: 170px;
}

.cr-main .cp-visual .pinout-grid {
  --pinout-cell-height: 2.2rem;
}

.cr-main .cp-visuals--wide-grid .cp-pinout .cp-visual {
  height: auto;
}

.cr-main .cp-visuals--wide-grid .cp-faceview .cp-visual,
.cr-main .cp-visuals--wide-grid .cp-location .cp-visual {
  height: 140px;
}

.cr-main .cp-visuals--wide-grid .cp-visual img {
  max-height: 140px;
}

/* Cavities: two lines per row at most, 8 rows shown (fewer when the window is short), the rest scrolled under a
   sticky header; long functions and device names are cut, their full text in the tooltip */
.cr-card-table {
  flex: 0 1 auto;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  padding: 14px 0 4px !important;
}

/* One line: a long list of free cavities is cut, in full in the tooltip */
.cr-card-table > .cp-label {
  flex: none;
  padding: 0 18px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cr-cavities-wrapper {
  flex: 0 1 auto;
  min-height: 0;
  position: relative;
  overflow: auto;
  overscroll-behavior: contain;
}

.cr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  line-height: 1.45;
}

.cr-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px;
  text-align: left;
  font-weight: 500;
  white-space: nowrap;
  color: var(--tds-theme-foreground-low-contrast);
  background: var(--tds-theme-background-container);
  box-shadow: inset 0 -1px 0 var(--tds-theme-border-low-contrast);
}

.cr-table td {
  padding: 8px 12px;
  vertical-align: top;
  white-space: nowrap;
  border-bottom: 1px solid var(--tds-theme-border-low-contrast);
  color: var(--tds-theme-foreground-high-contrast);
}

.cr-table th:first-child,
.cr-table td:first-child {
  padding-left: 18px;
}

.cr-table tr:last-child td {
  border-bottom: 0;
}

.cr-table b {
  font-weight: 500;
}

.cr-table a {
  color: var(--tds-theme-foreground-high-contrast);
}

.cr-table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--tds-theme-foreground) 3%, transparent);
}

.cr-table tbody tr.is-selected td {
  background: var(--cp-clicked-soft);
}

.cr-table tr.is-selected td:first-child {
  box-shadow: inset 3px 0 0 var(--cp-clicked);
}

/* The action column stays in view when a wide table scrolls sideways; its cells are opaque in every row state */
.cr-table th:last-child,
.cr-table td.cr-actions {
  position: sticky;
  right: 0;
  background: var(--tds-theme-background-container);
  box-shadow: inset 1px 0 0 var(--tds-theme-border-low-contrast);
}

.cr-table th:last-child {
  z-index: 2;
  box-shadow: inset 1px 0 0 var(--tds-theme-border-low-contrast), inset 0 -1px 0 var(--tds-theme-border-low-contrast);
}

.cr-table tbody tr:nth-child(even) td.cr-actions {
  background: color-mix(in srgb, var(--tds-theme-foreground) 3%, var(--tds-theme-background-container));
}

.cr-table tbody tr.is-selected td.cr-actions {
  background: var(--cp-clicked-soft);
}

.cr-table tbody tr:hover td.cr-actions,
.cr-table tbody tr.is-hover td.cr-actions {
  background: var(--tds-theme-background-container-highlight);
}

.cr-table tbody tr:focus-visible {
  outline: 2px solid var(--cp-clicked);
  outline-offset: -2px;
}

.cr-table tbody tr:hover td,
.cr-table tbody tr.is-hover td {
  background: var(--tds-theme-background-container-highlight);
}

.cr-cav {
  width: 3rem;
  font-weight: 500;
}

.cr-fn {
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cr-goes .cr-sub {
  max-width: 13rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cr-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--tds-theme-foreground-low-contrast);
}

.cr-kit span {
  display: inline-block;
  min-width: 1.6rem;
  margin-right: 6px;
  font-size: 11px;
  color: var(--tds-theme-foreground-low-contrast);
}

.cr-not-drawn {
  font-size: 12px;
}

.cr-unused {
  margin-left: 4px;
}

.cr-actions {
  width: 1rem;
  text-align: right;
  vertical-align: middle !important;
}

/* On a card, a tertiary button takes the page background, as TDS does in its own cards */
.cr-row-btn {
  --tds-btn--background-color: var(--tds-theme-background);
  gap: 4px;
  padding-inline: 10px;
  text-decoration: none;
}

@media (max-height: 860px) {
  .cr-main .cp-visual {
    height: 130px;
  }

  .cr-main .cp-visual img {
    max-height: 130px;
  }

  .cr-main .cp-visual .pinout-grid {
    --pinout-cell-height: 1.9rem;
  }
}

/* Narrow windows: the list above the connector, each scrolling on its own */
@media (max-width: 900px) {
  .cr-header {
    padding-inline: 16px;
  }

  .cr-search {
    order: 3;
    flex-basis: 100%;
    max-inline-size: none;
    padding-bottom: 10px;
  }

  .cr-split {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 38% 62%;
  }

  .cr-aside {
    border-right: 0;
    border-bottom: 1px solid var(--tds-theme-border-low-contrast);
  }

  .cr-filters .tds-tab {
    flex: 1 1 0;
    min-width: 0;
  }

  .cr-main {
    padding: 12px 16px;
  }

  .cr-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .cr-title-line {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .cr-facts-card .cp-facts {
    flex-wrap: wrap;
  }

  .cr-facts-card .cp-fact {
    flex: 1 1 140px;
    white-space: normal;
  }
}

@media (max-width: 600px) {
  .cr-main .cp-visuals,
  .cr-main .cp-visuals--no-grid,
  .cr-main .cp-visuals--wide-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
