/* Components panel: the panel, its splitter and its side (left, or right with
   main.panelRight), the component tiles with their animated previews, and the details
   under the panel (js/ui/componentsPanel.js, componentsPanelLayout.js). */

main {
  flex: 1;
  display: grid;
  --panelWidth: 148px;
  grid-template-columns: var(--panelWidth) 2px minmax(0, 1fr);
  min-height: 0
}

#componentsPanel {
  background: var(--panel);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0
}

#componentTiles {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  padding: 6px 0 14px 8px
}

#detailsSplitter {
  flex: none;
  height: 2px;
  background: var(--divider);
  cursor: row-resize;
  touch-action: none;
  position: relative;
  z-index: 2
}

#detailsSplitter[hidden] {
  display: none
}

#detailsSplitter::after {
  content: '';
  position: absolute;
  inset: -4px 0
}

#detailsSplitter:hover,
#detailsSplitter.active,
#detailsSplitter:focus-visible {
  background: var(--accent);
  outline: none
}

main.panelCollapsed #detailsSplitter {
  display: none
}

#componentDetails {
  flex: none;
  background: var(--info);
  padding: 8px 8px 10px;
  height: var(--detailsHeight, 260px);
  overflow-y: auto;
  display: flex;
  flex-direction: column
}

#componentDetails[hidden] {
  display: none
}

.componentTitle {
  font: 600 14px/1.25 'Space Grotesk', sans-serif;
  margin: 0 0 6px;
  min-height: 2.5em;
  flex: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden
}

main.panelCollapsed #componentDetails {
  display: none
}

#componentDetails .componentPreview {
  height: 110px;
  flex: none;
  margin: 0 0 6px
}

#componentDetails .componentPreview svg {
  width: 80%;
  height: 80%
}

#componentsPanel h2 {
  font: 600 12px Inter, sans-serif;
  color: var(--mutedText);
  margin: 12px 2px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.tileGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--tile, 60px));
  justify-content: start;
  gap: 6px
}

.componentsHeading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px
}

.componentsHeading span {
  font: 600 13px 'Space Grotesk', sans-serif;
  white-space: nowrap;
  overflow: hidden
}

main.panelCollapsed {
  --panelWidth: 46px !important
}

/* Components panel on the right: the sheet first, then the splitter and panel. */
main.panelRight {
  grid-template-columns: minmax(0, 1fr) 2px var(--panelWidth)
}

main.panelRight #sheetArea {
  grid-column: 1;
  grid-row: 1
}

main.panelRight #panelSplitter {
  grid-column: 2;
  grid-row: 1
}

main.panelRight #componentsPanel {
  grid-column: 3;
  grid-row: 1
}

main.panelCollapsed #componentTiles {
  padding: 6px 7px
}

main.panelCollapsed .componentsHeading span,
main.panelCollapsed #componentsPanel h2,
main.panelCollapsed .tileGrid {
  display: none
}

#panelSplitter {
  cursor: col-resize;
  background: var(--divider);
  touch-action: none;
  position: relative;
  z-index: 2
}

#panelSplitter::after {
  content: '';
  position: absolute;
  inset: 0 -4px
}

#panelSplitter:hover,
#panelSplitter.active,
#panelSplitter:focus-visible {
  background: var(--accent);
  outline: none
}

#componentDetails .componentPreview .previewPlayButton svg {
  width: 18px;
  height: 18px
}

@media(max-width:1000px) {
  main {
    --panelWidth: 136px
  }
}

@media(max-width:640px) {
  main {
    --panelWidth: 72px
  }

  #componentsPanel h2 {
    font-size: 11px;
    margin: 8px 0 4px
  }
}

/* Component tiles, their animated previews, and the details under the panel
   (js/ui/componentsPanel.js). */

.tile {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  display: grid;
  place-items: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  color: var(--text);
  height: var(--tile, 60px)
}

.tile#draggedTile {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  box-shadow: var(--popshadow);
  border-color: var(--accent);
  color: var(--accent);
  background: var(--pop);
  opacity: .95;
  cursor: grabbing
}

.tile.drag {
  opacity: .45;
  border-style: dashed;
  cursor: grabbing
}

.tile:hover {
  border-color: var(--accent);
  color: var(--accent)
}

.tile.active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--bg))
}

.componentPreview {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  height: 110px;
  margin: 6px 0 8px;
  color: var(--text)
}

.componentPreview svg {
  width: 120px;
  height: 90px
}

.componentPreview .twoStateOn {
  opacity: 0
}

.componentPreview .threeStateFirst,
.componentPreview .threeStateSecond {
  opacity: 0
}

@media(prefers-reduced-motion:no-preference) {
  .componentPreview .threeStateFirst {
    animation: ph1 6s step-end infinite
  }

  .componentPreview .threeStateSecond {
    animation: ph2 6s step-end infinite
  }

  .componentPreview .threeStateOff {
    animation: ph0 6s step-end infinite
  }
}

@keyframes ph1 {
  0% {
    opacity: 1
  }

  33.33% {
    opacity: 0
  }

  100% {
    opacity: 0
  }
}

@keyframes ph2 {
  0% {
    opacity: 0
  }

  33.33% {
    opacity: 1
  }

  66.66% {
    opacity: 0
  }

  100% {
    opacity: 0
  }
}

@keyframes ph0 {
  0% {
    opacity: 0
  }

  66.66% {
    opacity: 1
  }

  100% {
    opacity: 1
  }
}

.previewStateLabel.threeStateFirst,
.previewStateLabel.threeStateSecond {
  color: var(--accent)
}

.componentPreview.paused .twoStateOff,
.componentPreview.paused .twoStateOn,
.componentPreview.paused .threeStateOff,
.componentPreview.paused .threeStateFirst,
.componentPreview.paused .threeStateSecond {
  animation-play-state: paused !important
}

.componentPreview.paused .twoStateOn,
.componentPreview.paused .threeStateFirst,
.componentPreview.paused .threeStateSecond {
  opacity: 0 !important
}

.componentPreview.paused .twoStateOff,
.componentPreview.paused .threeStateOff {
  opacity: 1 !important
}

.componentPreview .previewBall {
  fill: #2f7fd0
}

.componentPreview .previewBall.pushing {
  fill: #e2553f
}

.componentPreview {
  position: relative;
  cursor: grab;
  touch-action: none
}

.componentPreview .previewPlayButton {
  cursor: pointer
}

.previewStateLabel {
  position: absolute;
  left: 8px;
  top: 7px;
  font: 600 12px Inter, sans-serif;
  color: var(--mutedText);
  letter-spacing: .02em
}

.previewStateLabel.twoStateOn {
  color: var(--accent)
}

.previewPlayArea {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 4px
}

.previewPlayButton {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--mutedText);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0
}

.previewPlayButton svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round
}

.previewPlayButton:hover {
  background: var(--panel);
  color: var(--accent)
}

@media(prefers-reduced-motion:reduce) {
  .componentPreview .previewBall {
    display: none
  }
}

@media(prefers-reduced-motion:no-preference) {
  .componentPreview .twoStateOff {
    animation: act0 4s step-end infinite
  }

  .componentPreview .twoStateOn {
    animation: act1 4s step-end infinite
  }
}

@keyframes act0 {
  0% {
    opacity: 0
  }

  50% {
    opacity: 1
  }

  100% {
    opacity: 0
  }
}

@keyframes act1 {
  0% {
    opacity: 1
  }

  50% {
    opacity: 0
  }

  100% {
    opacity: 1
  }
}

.componentDescription {
  font-size: 13px;
  color: var(--mutedText);
  margin: 4px 0
}

/* A component's properties in the details (componentsPanel.js libraryPropertyCards) */
.choiceCards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 6px
}

.choiceCard {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
  color: var(--mutedText);
  line-height: 1.4
}

.choiceCard ul {
  margin: 2px 0 0;
  padding-left: 16px
}

.choiceCard > span {
  white-space: pre-line
}

.choiceCard b {
  color: var(--text);
  font-weight: 600
}

.choiceCard b i {
  font-style: normal;
  font-weight: 400;
  color: var(--mutedText)
}

.curveGraph {
  width: 100%;
  max-width: 170px;
  height: auto;
  margin-bottom: 2px
}

.curveGraph .curveAxis,
.curveGraph .curveTick {
  fill: none;
  stroke: var(--mutedText);
  stroke-width: 1
}

.curveGraph .curveLine {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linejoin: round
}

.curveGraph text {
  font: 8px Inter, sans-serif;
  fill: var(--mutedText);
  text-anchor: middle
}

.curveGraph text.curveLabel {
  font-size: 8px
}

.curveGraph .curveSubscript {
  font-size: 5.5px
}

.tile svg {
  width: calc(var(--tile, 60px)*.8);
  height: calc(var(--tile, 60px)*.73)
}

.previewStateLabel.actuatorStateLabel {
  opacity: 1;
  font-size: 11.5px
}

.previewStateLabel.actuatorStateLabel.active {
  color: var(--accent)
}

.previewPlayButton,
.previewPlayButton:hover {
  color: var(--startGreen)
}

.previewPlayButton[aria-pressed=true],
.previewPlayButton[aria-pressed=true]:hover {
  color: var(--stop)
}
