/* component_card: the page editor's components (partials/websites/page/
   _components with shared/_component), each a row that opens into its editor.
   The row holds the drag handle, the name (the button that opens the editor),
   the status, the move buttons and the ⋯ menu. The editor sits beneath it.
   Rows are divided by hairlines inside the Components surface, with no box of
   their own (RULES §2: whitespace inside a section, not boxes). The class
   names are the ones websites/components.js, websites/component_order.js and
   websites/ui/page.js read. */
#website_page_components {
  /* The drag handle's and each move button's target, and the editor's inset. */
  --block-component-card-target: var(--ui-touch-target);
  --block-component-card-inset: var(--ui-space-4);

  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  container-type: inline-size;
}

.website_page_component {
  min-width: 0;
  border-block-end: 1px solid var(--color-border-subtle);
  list-style: none;
}

.website_page_component:first-child {
  border-block-start: 1px solid var(--color-border-subtle);
}

.website_page_component.sortable-chosen {
  background-color: var(--color-card-background);
  box-shadow: 0 4px 12px rgb(0 0 0 / 15%);
}

.website_page_component > .header {
  display: flex;
  align-items: center;
  gap: var(--ui-space-2);
  min-height: var(--block-component-card-target);
  padding-block: var(--ui-space-2);
}

.website_page_component .component_drag_handle {
  display: grid;
  flex: 0 0 var(--block-component-card-target);
  place-items: center;
  height: var(--block-component-card-target);
  color: var(--color-text-secondary);
  cursor: grab;
  touch-action: none;
}

.component_drag_handle::before {
  font: var(--ui-icon-weight) var(--ui-icon-size)/1 var(--ui-icon-font-family);
  content: var(--ui-icon-grip-vertical) var(--ui-icon-alt,);
}

#main .website_page_component > .header .title {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.website_page_component .header .expand {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--ui-space-3);
  width: 100%;
  min-height: var(--block-component-card-target);
  padding: 0;
  color: var(--color-text);
  font: inherit;
  text-align: start;
  background: none;
  border: 0;
  cursor: pointer;
}

.website_page_component .header .expand::after {
  font: var(--ui-icon-weight) var(--ui-icon-size)/1 var(--ui-icon-font-family);
  transition: transform var(--ui-duration-feedback) var(--ui-ease-feedback);
  content: var(--ui-icon-angle-right) var(--ui-icon-alt,);
}

.website_page_component.expanded > .header .expand::after {
  transform: rotate(90deg);
}

.website_page_component .component_status {
  display: inline-flex;
  align-items: center;
  min-height: var(--block-component-card-target);
}

/* Move up and down, side by side in the row. */
.website_page_component .component_order {
  display: flex;
  gap: var(--ui-space-1);
}

.website_page_component .component_order_button {
  display: grid;
  place-items: center;
  width: var(--block-component-card-target);
  height: var(--block-component-card-target);
  padding: 0;
  color: var(--color-text);
  background: transparent;
  border: 1px solid var(--color-border-light);
  border-radius: var(--ui-radius-control);
  cursor: pointer;
}

.component_order_button::before {
  font: var(--ui-icon-weight) var(--ui-icon-size)/1 var(--ui-icon-font-family);
  content: var(--ui-icon-arrow-up) var(--ui-icon-alt,);
}

.component_order_button[data-reorder='down']::before {
  content: var(--ui-icon-arrow-down) var(--ui-icon-alt,);
}

.component_order_button:disabled {
  opacity: 0.35;
  cursor: default;
}

.component_order_status:empty {
  display: none;
}

/* The editor, shown while the row is open. */
.website_page_component .content {
  display: none;
  box-sizing: border-box;
  margin: 0;
  padding: 0 0 var(--block-component-card-inset);
}

.website_page_component.expanded .content {
  display: block;
}

@container (width < 600px) {
  .website_page_component > .header {
    gap: var(--ui-space-1);
  }

  .website_page_component .component_drag_handle {
    flex-basis: var(--ui-space-6);
  }
}
