/* Everything is scoped to the selector, so the page around it keeps its own
   variables and margins. */
.product-selector {
  --primary-color: #e27f46;
  --border-color: #e5e7eb;
  --text-main: #1f2937;
  --text-sub: #4b5563;
  --bg-card: #ffffff;
  /* Diagram sizing */
  --diagram-icon-size: 80px;
  --diagram-gap: 12px;
  --diagram-font-size: 1rem;
}

.product-selector {
  font-family: Inter, system-ui, sans-serif;
  background: #f8fafc;
  min-height: 100vh;
  color: #1f2937;
  padding: 1rem;
}

.product-selector header {
  display: flex;
  flex-wrap: wrap;
  row-gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.product-selector #selections {
  display: flex;
  flex-direction: column;
}
  
.product-selector #buttons {
  display: flex;
  gap: 6px;
  margin-left: 0.75rem;
}

.product-selector.diagram-page-open {
  overflow: hidden;
}

.product-selector .button {
  align-self: flex-start;
  padding: 0.5rem 0.8rem;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  font-size: .95rem;
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.1s ease;
}

.product-selector .button:hover,
.product-selector .button:focus-visible {
  border-color: var(--primary-color);
}

.product-selector .copy-button-labels {
  display: grid;
}

.product-selector .copy-button-labels > span {
  grid-area: 1 / 1;
}

.product-selector .copy-button-labels .text-success,
.product-selector .copy-button.is-copied .text-default {
  visibility: hidden;
}

.product-selector .copy-button.is-copied .text-success {
  visibility: visible;
}

.product-selector h1 {
  color: #444;
  margin: 0;
}

.product-selector h2 {
  display: flex;
  align-items: center;
  margin: 0 0 0.75rem 0;
  color: #555;
}

.product-selector .question-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
}

.product-selector .question-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.product-selector .question-toggle:hover {
  color: #111;
}

.product-selector .question-toggle:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.product-selector .question-chevron {
  display: inline-block;
  width: auto;
  text-align: center;
  color: var(--text-sub);
  line-height: 1;
}

.product-selector .option {
  padding: .5rem 1rem 1rem 1rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 6px;
}

.product-selector .option:hover {
  background: #eee;
}

.product-selector section:nth-child(odd) > h2 {
  color: #555;
}

.product-selector section:nth-child(even) > h2 {
  color: #555;
}

.product-selector .option-collapsed {
  margin-bottom: 0.5rem;
}

.product-selector .option-collapsed h2 {
  margin-bottom: 0;
}

.product-selector .selected-value {
  font-weight: 400;
  color: #606060;
  margin-left: .5rem;
}

/* The answer shows while its question is closed. It is as wide as the
   question's longest answer: each answer is there, hidden, in the same place. */
.product-selector .option:not(.option-collapsed) .question-answer {
  display: none;
}

.product-selector .selected-value {
  display: inline-grid;
}

.product-selector .selected-value > * {
  grid-area: 1 / 1;
}

.product-selector .selected-value-size {
  visibility: hidden;
}

.product-selector .card-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  width: max-content;
  max-width: 100%;
  font-family: system-ui, sans-serif;
  box-sizing: border-box;
  user-select: none;
}

.product-selector .card-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.product-selector .radio-card-input,
.product-selector .checkbox-card-input,
.product-selector .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.product-selector .card {
  background-color: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  outline: 5px solid transparent;
  padding: 18px;
  cursor: pointer;
  position: relative;
  transition: all 0.1s ease-in-out;
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
}

.product-selector .card:hover {
  border-color: #cbd5e1;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* An answer that can't be chosen now, and a question with nothing to choose:
   shown faded, in their place. The card's content fades, not the card, so that
   its reason doesn't. */
.product-selector .card.disabled {
  cursor: not-allowed;
}

.product-selector .card.disabled > * {
  opacity: 0.45;
}

/* Why it can't be chosen, while hovered (and pressed, where the page adds
   .show-reason). */
.product-selector .card.disabled[data-reason]:is(:hover, .show-reason)::after {
  content: attr(data-reason);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  z-index: 10;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(16rem, 80vw);
  padding: 4px 8px;
  border-radius: 6px;
  background: #333;
  color: #fff;
  font-size: 12px;
  line-height: 1.3;
  pointer-events: none;
}

.product-selector .option-not-needed {
  margin: 0;
  color: var(--text-sub);
  font-style: italic;
}

.product-selector .card.disabled:hover {
  border-color: var(--border-color);
  transform: none;
  box-shadow: none;
}

.product-selector .option-disabled .question-toggle {
  opacity: 0.45;
}

.product-selector .radio-card-input:checked + .card,
.product-selector .checkbox-card-input:checked + .card {
  border-color: var(--primary-color);
  outline: 5px solid color-mix(in srgb, var(--primary-color) 50%, transparent);
  background-color: #f8fafc;
}

.product-selector .radio-card-input:checked + .card::before {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 12px;
  height: 12px;
  background-color: var(--primary-color);
  border-radius: 50%;
}

.product-selector .checkbox-indicator {
  position: absolute;
  top: 10px;
  right: 10px;

  width: 12px;
  height: 12px;

  border-radius: 4px;

  background: #efefef;
  border: 1px solid #ccc;

  display: flex;
  align-items: center;
  justify-content: center;
}

.product-selector .checkbox-tick {
  width: 12px;
  height: 12px;

  color: white;

  opacity: 0;
  transition: opacity .1s ease;
}

.product-selector .checkbox-card-input:checked + .checkbox-card .checkbox-indicator {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.product-selector .checkbox-card-input:checked + .checkbox-card .checkbox-tick {
  opacity: 1;
}

.product-selector .radio-card-input:focus-visible + .card,
.product-selector .checkbox-card-input:focus-visible + .checkbox-card {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.product-selector .card-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.product-selector .card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-selector .card-description {
  font-size: 0.9rem;
  color: var(--text-sub);
  margin: 0;
  line-height: 1.4;
}

/* Diagram */

.product-selector .diagram {
  display: flex;
  align-items: center;
  width: fit-content;
  gap: var(--diagram-gap);
}

.product-selector .banner {
  padding: 8px;
  border-radius: 4px;
}


/* Diagram legend */

.product-selector .square {
  width: 30px;
  height: 30px;
  border-radius: 4px;
}

.product-selector .ownership-legend {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: 2rem;
}

.product-selector .legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: default;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.product-selector .legend-item[hidden] {
  display: none;
}

.product-selector .legend-item:hover,
.product-selector .legend-item:focus-visible {
  transform: translateY(-1px);
}

.product-selector .legend-color {
  width: 24px;
  height: 24px;
  border-radius: 4px;
}

.product-selector .legend-color.clampon {
  background: var(--clampon-color);
}

.product-selector .legend-color.customer {
  background: var(--customer-color);
}

.product-selector .legend-color.shared {
  background: var(--shared-color);
}

/* Diagram */

.product-selector.diagram-actions {
  margin-top: 1rem;
}

.product-selector #diagram {
  display: flex;
  align-items: center;
  gap: var(--diagram-gap);
  min-height: 14rem;
  width: max-content;
  box-sizing: content-box;
  padding: 4rem 4rem 5rem 2rem;
}

/* The diagram scales down to fit (main.js, ui/diagramViewport.js) and scrolls
   sideways in here for the rest, never the page. */
.product-selector .diagram-frame {
  min-width: 0;
  max-width: 100%;
}

.product-selector .diagram-viewport {
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.product-selector .diagram-viewport:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Scaled down, the labels keep a size that can be read: 12px, 11px for the zones. */
.product-selector #diagram .diagram-label {
  font-size: max(0.95rem, calc(12px / var(--diagram-scale, 1)));
  line-height: 1.25;
}

.product-selector #diagram .connector-zone-label {
  font-size: max(0.75rem, calc(11px / var(--diagram-scale, 1)));
}

.product-selector .diagram-scroll-hint {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--text-sub);
}

.product-selector #diagram.diagram-grid-container {
  display: grid;
  grid-auto-columns: max-content;
  
  row-gap: 50px; 
  column-gap: 20px;
  align-items: center; 
  justify-items: center;
}

.product-selector .diagram-matrix-node {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: opacity 0.15s ease;
}

.product-selector #diagram[data-highlight-ownership="clampon"] .diagram-matrix-node:not([data-ownership="clampon"]),
.product-selector #diagram[data-highlight-ownership="customer"] .diagram-matrix-node:not([data-ownership="customer"]),
.product-selector #diagram[data-highlight-ownership="shared"] .diagram-matrix-node:not([data-ownership="shared"]) {
  opacity: 0.5;
}

.product-selector #diagram[data-highlight-ownership="clampon"] .diagram-matrix-node[data-ownership="clampon"] .outline,
.product-selector #diagram[data-highlight-ownership="customer"] .diagram-matrix-node[data-ownership="customer"] .outline,
.product-selector #diagram[data-highlight-ownership="shared"] .diagram-matrix-node[data-ownership="shared"] .outline {
  opacity: 1;
}

.product-selector .connector-zone-label {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  white-space: pre;
}

.product-selector .diagram-label {
  display: flex;
  align-items: center;
  margin-top: 6px;
  font-size: 0.95rem;
  max-width: 160px;
  white-space: pre-line;
}

.product-selector .matrix-connector {
  position: relative;
  width: 60px;
  height: 4px;
  background: #ccc;
}

.product-selector .matrix-connector.straight {
  flex: 0 0 auto;
  align-self: center;
}

.product-selector .matrix-connector.diagonal {
  justify-self: start;
  align-self: start;
  transform: rotate(45deg);
}

.product-selector .matrix-connector-diagonal .connector-zone-label {
  transform: translateX(-50%) rotate(-45deg);
}

.product-selector path.outline {
  transition: opacity 0.15s ease;
}

.product-selector .diagram-svg {
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-selector .diagram-svg svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.product-selector .diagram-svg svg:not(:hover) path.outline {
  opacity: 0.7;
}

.product-selector .diagram-label {
  position: absolute;
  top: 100%;
  width: max-content;
  max-width: 160px;
  margin-top: 12px;
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-main);
  white-space: pre-line;
  user-select: none;
}

.product-selector .wireless-connector {
  position: relative;
  width: 40px;
  height: 40px;
  margin: 0 10px;
  flex: 0 0 auto;

  background-image: url("./svgs/wireless-signal.5c8d8f1b7914.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.product-selector .diagram-svg-error {
  color: #b91c1c;
  font-size: 0.85rem;
  text-align: center;
}

.product-selector .diagram-and-remarks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3rem;
  padding-bottom: 3rem;
}

.product-selector .diagram-section {
  margin-top: 1rem;
}

.product-selector .diagram-actions {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-start;
  margin: 0 0 0.75rem 0;
}

.product-selector #selection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.product-selector .diagram-actions #buttons {
  margin-left: 0;
}

.product-selector #diagram-fullscreen-toggle {
  margin-left: auto;
}

.product-selector .diagram-shell {
  position: relative;
}

.product-selector .diagram-shell.is-expanded {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 1rem 1.5rem 0;
  box-sizing: border-box;
  background: #fff;
}

.product-selector .diagram-shell.is-expanded .diagram-and-remarks {
  min-height: 0;
  max-width: 100%;
  overflow: auto;
}

.product-selector .diagram-shell.is-expanded .remarks-panel {
  flex: 0 0 auto;
  padding: 0 2rem 2rem;
}

.product-selector .diagram-shell.is-expanded .ownership-legend {
  flex: 0 0 auto;
  padding: 0.75rem 0 1rem;
}

.product-selector .diagram-close {
  display: none;
}

.product-selector .diagram-shell.is-expanded .diagram-close {
  display: block;
  align-self: flex-end;
}

.product-selector .remarks-list {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.product-selector .remark-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  line-height: 1.4;
  transition: opacity 0.18s ease;
}

.product-selector .remark-item.is-selected {
  opacity: 1;
}

.product-selector .remark-item.is-faded {
  opacity: 0.25;
}

.product-selector .remark-link {
  margin-left: 0.2rem;
  color: #2563eb;
  text-decoration: underline;
  font-size: 0.9rem;
  white-space: nowrap;
}

.product-selector .remark-link:hover,
.product-selector .remark-link:focus-visible {
  color: #1d4ed8;
}

.product-selector .remark-icon,
.product-selector .remark-indicator {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  user-select: none;
}

.product-selector .remark-icon.remark-info,
.product-selector .remark-indicator.remark-info {
  background: #7193dd;
}

.product-selector .remark-icon.remark-exclamation,
.product-selector .remark-indicator.remark-exclamation {
  background: #d97706;
}

/* A dual measurement: "••" in the primary colour, on its answer and before its
   remark. */
.product-selector .remark-icon.remark-dual {
  background: none;
  color: var(--primary-color);
  font-size: 0.875rem;
  letter-spacing: -0.1em;
}

.product-selector .card-dual {
  position: absolute;
  top: 4px;
  right: 28px;
  color: var(--primary-color);
  font-size: 0.875rem;
  line-height: 1;
  letter-spacing: -0.1em;
}

.product-selector .remark-indicator {
  display: inline-grid;
  margin-left: 0.4rem;
  vertical-align: middle;
  font-size: 0.7rem;
}

.product-selector .inline-remark {
  display: inline-flex;
  align-items: center;
  margin-left: 0.75rem;
  vertical-align: middle;
}
