/* The craft list: each kind of craft is a fabric-edged card. A tap opens it in place (a <details>: no script, no other
   page) and its items rise in; another tap folds it away. The colours and the .photo spot come from style.css. */
.patches { list-style: none; padding: 0; display: grid; gap: 14px; max-width: 760px; margin: 0 auto; }
.patches > li {
  padding: 10px; border-radius: 16px; background: var(--fabric); box-shadow: 0 14px 18px -12px var(--shade);
  transition: transform .25s ease, box-shadow .25s ease;
}
/* Six fabrics in turn. Each also names its shirt button: the fabric's own colour, a deeper shade for the button's edge,
   and a thread that shows on it (cream on the dark buttons, ink on the light ones: 3:1 or more). */
.patches > li:nth-child(6n+1) {
  --fabric: linear-gradient(90deg, rgba(16, 102, 106, .45) 50%, transparent 0) var(--check),
    linear-gradient(rgba(16, 102, 106, .45) 50%, transparent 0) var(--check), var(--aqua);
  --button: #4A8E8F; --button-deep: #2F6869; --thread: var(--cream);
}
.patches > li:nth-child(6n+2) {
  --fabric: radial-gradient(circle, var(--cream) 2.6px, transparent 3.2px) 0 0 / 14px 14px, var(--teal);
  --button: var(--teal); --button-deep: #0A4649; --thread: var(--cream);
}
.patches > li:nth-child(6n+3) {
  --fabric: repeating-linear-gradient(45deg, var(--clay) 0 7px, #C56A43 7px 14px);
  --button: var(--clay); --button-deep: #7C3519; --thread: var(--cream);
}
.patches > li:nth-child(6n+4) {
  --fabric: radial-gradient(circle, var(--cream) 2.6px, transparent 3.2px) 0 0 / 14px 14px, var(--mustard);
  --button: var(--mustard); --button-deep: #A9781F; --thread: var(--ink);
}
.patches > li:nth-child(6n+5) {
  --fabric: repeating-linear-gradient(-45deg, var(--turq) 0 7px, #7ED3CB 7px 14px);
  --button: var(--turq); --button-deep: #23877E; --thread: var(--ink);
}
.patches > li:nth-child(6n+6) {
  --fabric: linear-gradient(90deg, rgba(58, 42, 32, .2) 50%, transparent 0) var(--check),
    linear-gradient(rgba(58, 42, 32, .2) 50%, transparent 0) var(--check), var(--sage);
  --button: var(--sage); --button-deep: #66754D; --thread: var(--ink);
}
.patches details { background: var(--cream); border-radius: 9px; outline: 2px dashed rgba(253, 247, 234, .95); outline-offset: 2px; }

/* The card's face: her photo of the craft, its name, and a shirt button whose thread is sewn as a plus. */
.patches summary {
  display: grid; grid-template-columns: 64px 1fr 40px; align-items: center; gap: 14px; padding: 10px 12px;
  border-radius: 9px; cursor: pointer; list-style: none; -webkit-tap-highlight-color: transparent;
}
.patches summary::-webkit-details-marker { display: none; }
.patches summary .photo { font-size: 10px; line-height: 1.3; text-align: center; }
.patches .made { background: var(--aqua); }
.patches .made .heart { width: 30px; margin: 0; }
.patches h3 { font: 800 19px/1.2 var(--round); }
/* The button, drawn here: a light from the upper left, a well inside a raised rim, a deeper edge and a little
   thickness below. Its four holes and its thread are a layer of their own: while the card is open that layer turns
   until the plus reads as a cross, and the button, its light and its shadow stay put. */
.plus {
  --d: 40px; position: relative; width: var(--d); height: var(--d); border-radius: 50%;
  background: radial-gradient(circle at 32% 26%, rgba(255, 255, 255, .5), transparent 48%),
    radial-gradient(closest-side, rgba(0, 0, 0, .12) 0 61%, rgba(0, 0, 0, .28) 62% 67%, transparent 68%), var(--button);
  box-shadow: 0 0 0 2px var(--button-deep), 0 3px 0 2px var(--button-deep), 0 9px 8px -4px var(--shade);
}
.plus::before {
  --hole: rgba(58, 42, 32, .75) 0 calc(var(--d) * .055), transparent calc(var(--d) * .07);
  content: ""; position: absolute; inset: 0; border-radius: 50%; transition: transform .45s cubic-bezier(.3, 1.4, .5, 1);
  background: linear-gradient(var(--thread) 0 0) center / calc(var(--d) * .075) calc(var(--d) * .34) no-repeat,
    linear-gradient(var(--thread) 0 0) center / calc(var(--d) * .34) calc(var(--d) * .075) no-repeat,
    radial-gradient(circle at 50% 33%, var(--hole)), radial-gradient(circle at 50% 67%, var(--hole)),
    radial-gradient(circle at 33% 50%, var(--hole)), radial-gradient(circle at 67% 50%, var(--hole));
}
.patches details[open] .plus::before { transform: rotate(135deg); }
/* A card lifts under a mouse and dips under a finger. */
@media (hover: hover) {
  .patches > li:hover { transform: translateY(-3px); box-shadow: 0 20px 22px -12px var(--shade); }
}
.patches > li:has(summary:active) { transform: scale(.985); }

/* The fold. Where the browser knows ::details-content it grows from nothing and shrinks back: it is always laid out,
   and its one row goes from 0fr to 1fr. Closed, it is hidden from sight, from the Tab key and from screen readers;
   `visibility` waits for the row to finish closing (WebKit drops a closing `content-visibility` at once, so that
   property is not used). Elsewhere the card opens at once. Its items rise in either way. */
.patches details::details-content {
  content-visibility: visible; visibility: hidden; display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows .45s ease, visibility .45s;
}
.patches details[open]::details-content { visibility: visible; grid-template-rows: 1fr; }
.fold { min-height: 0; overflow: hidden; }
/* A closed card's photos must not load. WebKit leaves them; Chrome fetched 12 of 19 with every card shut and the list
   on screen. So a closed card's lists wait far below it (Chrome: 0 of 19), and go there only once the fold has shut. */
.patches :is(.items, .shots) { transform: translateY(9999px); transition: transform 0s .45s; }
.patches details[open] :is(.items, .shots) { transform: none; transition: none; }
/* Inside a card. Items with one photo each stand two abreast (.items): photo, name, price. An item with many photos
   is its name and price, a line of her words about it (.note), then its photos (.shots): two abreast, a last odd one
   in the middle; a stitched line parts it from the item before. Her photos are 3:4 (tools/web-photo.py); each holds
   its place before it has loaded. */
.items {
  list-style: none; padding: 6px 12px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; text-align: center;
}
.items .photo { aspect-ratio: 3 / 4; }
.patches img { display: block; width: 100%; height: auto; object-fit: cover; border-radius: 6px; background: var(--sand); }
.items h4, .fold > h4 { font: 800 17px/1.2 var(--round); margin-top: 8px; }
.fold > h4 { padding: 2px 16px 0; text-align: center; }
.shots + h4 { margin: 0 12px; padding-top: 18px; border-top: 2px dashed var(--kraft); }
.price { font: 800 19px/1.3 var(--round); color: var(--clay); }
.fold > p { padding: 4px 16px 0; }
.fold > :is(.price, .note) { text-align: center; }
.fold > .actions { margin: 14px 0 22px; }
.shots { list-style: none; padding: 12px 12px 18px; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.shots > li { flex: 0 0 calc(50% - 6.5px); }
/* A craft sold by size shows a price for each (.sizes): a small table, a stitched line between its rows. A craft's
   one photo stands wide (.shots.wide). */
.sizes { width: calc(100% - 32px); max-width: 400px; margin: 4px auto 6px; border-collapse: collapse; }
.sizes caption { font: 800 17px/1.2 var(--round); padding: 4px 0 8px; }
.sizes th, .sizes td { padding: 9px 4px; font: 800 17px/1.3 var(--round); text-align: left; }
.sizes td { text-align: right; font-size: 19px; color: var(--clay); }
.sizes tr + tr > * { border-top: 2px dashed var(--kraft); }
.shots.wide > li { flex-basis: 100%; }
.patches details[open] :is(.items, .shots) > li, .patches details[open] .fold > :is(p, h4, table) { animation: rise .5s both; }
.patches details[open] :is(.items, .shots) > li:nth-child(2), .patches details[open] .fold > p:nth-child(2) { animation-delay: .08s; }
.patches details[open] :is(.items, .shots) > li:nth-child(3) { animation-delay: .16s; }
.patches details[open] :is(.items, .shots) > li:nth-child(4) { animation-delay: .24s; }
.patches details[open] :is(.items, .shots) > li:nth-child(n+5) { animation-delay: .32s; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

/* A visitor who asked their device for less motion gets none: the card opens at once. */
@media (prefers-reduced-motion: reduce) {
  .patches > li, .plus::before, .patches :is(.items, .shots) { transition: none; }
  .patches details::details-content { transition: none; }
  .patches details[open] :is(.items, .shots) > li, .patches details[open] .fold > :is(p, h4, table) { animation: none; }
}

@media (min-width: 900px) {
  .patches { gap: 18px; }
  .patches > li { padding: 13px; }
  .patches summary { grid-template-columns: 84px 1fr 46px; gap: 20px; padding: 12px 20px 12px 12px; }
  .patches summary .photo { font-size: 12px; }
  .patches h3 { font-size: 23px; }
  .plus { --d: 46px; }
  .items { grid-template-columns: repeat(auto-fit, minmax(150px, 221px)); justify-content: center; gap: 16px; padding: 8px 18px 24px; }
  .shots { gap: 16px; padding: 14px 18px 24px; }
  .shots > li { flex-basis: calc((100% - 32px) / 3 - .5px); }
  /* Four photos stand two by two, not three and one: the list narrows to two photos of the same size. */
  .shots:has(> :nth-child(4):last-child) { padding-inline: calc(18px + (100% - 68px) / 6 + 8px); }
  .shots:has(> :nth-child(4):last-child) > li { flex-basis: calc(50% - 8.5px); }
  .shots.wide > li { flex-basis: 460px; }
  .shots + h4 { margin: 0 18px; }
}
