/* 540 frame. A white sheet on tomato red, centred, so it is a picture closed (header over the three
   photographs side by side, 250 px high) and fills the frame open (508 px high).
   Header 82, three rows of 114 (photograph 110), sums 84. */
.co {
  --red: #e7341e;
  --ink: #1d1311;
  --soft: #75625d;
  --rule: #e6d9d5;
  --head: 82px;
  --row: 114px;
  --photo: 110px;
  /* closed: three photographs of 148 px on a 160 px pitch, 20 px of sheet under them */
  --peek-photo: 148px;
  --peek-pitch: 160px;
  --peek: 168px;
  --open: 560ms cubic-bezier(0.35, 0, 0.15, 1);
  position: relative;
  display: grid;
  place-items: center;
  width: 540px;
  height: 540px;
  overflow: hidden;
  background: var(--red);
  color: var(--ink);
  font-family: "Archivo Variable", sans-serif;
  font-variant-numeric: tabular-nums lining-nums;
  user-select: none;
}

.co * {
  box-sizing: border-box;
}

.co-sheet {
  width: 508px;
  background: #fff;
}

.co-trigger {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  outline: none;
  cursor: pointer;
}

.co-trigger:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: -3px;
}

/* header: label over count, total, chevron */
.co-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: 32px 24px;
  align-content: center;
  align-items: center;
  column-gap: 12px;
  height: var(--head);
  padding: 0 20px;
}

.co-label {
  grid-area: 1 / 1;
  font-size: 27px;
  line-height: 32px;
  font-weight: 640;
  font-stretch: 92%;
  letter-spacing: -0.014em;
  white-space: nowrap;
}

.co-count {
  grid-area: 2 / 1;
  color: var(--soft);
  font-size: 18px;
  line-height: 24px;
  font-weight: 480;
}

.co-total {
  grid-area: 1 / 3 / 3 / 4;
  font-size: 34px;
  line-height: 40px;
  font-weight: 340;
  font-stretch: 96%;
  letter-spacing: -0.035em;
}

.co-chevron {
  grid-area: 1 / 2;
  width: 28px;
  height: 28px;
  margin: 2px 0 0 -4px;
  color: var(--red);
  stroke-width: 2.75;
  stroke-linecap: square;
  stroke-linejoin: miter;
  transition: rotate 420ms cubic-bezier(0.3, 0, 0.1, 1);
}

.co-trigger[data-open] .co-chevron {
  rotate: 180deg;
}

.co-photo {
  display: block;
  width: var(--photo);
  height: var(--photo);
}

/* closed: the photographs stand in a row. Gone the moment the panel is in the page, which starts
   at the same height with its photographs in the same places. */
.co-peek {
  position: relative;
  display: block;
  height: var(--peek);
}

.co-peek .co-photo {
  position: absolute;
  top: 0;
  left: calc(20px + var(--i) * var(--peek-pitch));
  width: var(--peek-photo);
  height: var(--peek-photo);
}

.co-sheet:has(.co-panel) .co-peek {
  display: none;
}

.co-panel {
  height: var(--collapsible-panel-height);
  overflow: hidden;
  transition: height var(--open);
}

.co-panel[data-starting-style] {
  height: var(--peek);
  transition: none;
}

.co-panel[data-ending-style] {
  height: var(--peek);
}

.co-items {
  margin: 0;
  padding: 0;
  list-style: none;
}

.co-item {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: 32px 24px 24px;
  align-content: center;
  column-gap: 12px;
  height: var(--row);
  padding: 0 20px 4px 146px;
}

.co-item .co-photo {
  position: absolute;
  top: 0;
  left: 20px;
  z-index: 1;
  transform-origin: 0 0;
  transition: transform var(--open);
}

/* each photograph starts where it stood in the closed row */
.co-panel:is([data-starting-style], [data-ending-style]) .co-item .co-photo {
  transform: translate(calc(var(--i) * var(--peek-pitch)), calc(var(--i) * var(--row) * -1)) scale(calc(148 / 110));
}

.co-panel[data-starting-style] .co-item .co-photo {
  transition: none;
}

.co-name,
.co-detail,
.co-qty,
.co-price {
  transition:
    opacity 100ms linear calc(260ms + var(--i) * 40ms),
    translate 260ms cubic-bezier(0.2, 0.7, 0.2, 1) calc(250ms + var(--i) * 40ms);
}

.co-panel[data-starting-style] :is(.co-name, .co-detail, .co-qty, .co-price) {
  opacity: 0;
  translate: 20px 0;
  transition: none;
}

.co-panel[data-ending-style] :is(.co-name, .co-detail, .co-qty, .co-price) {
  opacity: 0;
  transition: opacity 120ms linear;
}

.co-name {
  grid-area: 1 / 1;
  font-size: 26px;
  line-height: 32px;
  font-weight: 620;
  font-stretch: 92%;
  letter-spacing: -0.014em;
  white-space: nowrap;
}

.co-detail,
.co-qty {
  grid-column: 1;
  color: var(--soft);
  font-size: 18px;
  line-height: 24px;
  font-weight: 480;
  white-space: nowrap;
}

.co-price {
  grid-area: 1 / 2;
  font-size: 26px;
  line-height: 32px;
  font-weight: 480;
  letter-spacing: -0.015em;
}

.co-sums {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  height: 84px;
  margin: 0 20px;
  padding-bottom: 3px;
  border-top: 1px solid var(--rule);
}

.co-sums dl,
.co-sums dd {
  margin: 0;
}

.co-parts {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 14px;
  font-size: 18px;
  line-height: 25px;
  font-weight: 480;
}

.co-parts dt {
  color: var(--soft);
}

.co-parts dd {
  text-align: right;
}

.co-grand {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  justify-items: end;
  column-gap: 10px;
  line-height: 42px;
}

.co-grand dt {
  font-size: 18px;
  font-weight: 640;
  font-stretch: 92%;
}

.co-grand dd {
  font-size: 40px;
  font-weight: 560;
  letter-spacing: -0.035em;
}

.co-grand .co-tax {
  grid-column: 1 / 3;
  color: var(--soft);
  font-size: 18px;
  line-height: 22px;
  font-weight: 480;
  letter-spacing: 0;
}
