/* Shared commerce components rendered by storefront.mjs: product cards and grids, the collections section,
   the trust strip, starting points and the format comparison. Load after /style.css.
   Breakpoints: mobile below 768, tablet 768 to 1023, desktop from 1024. */

/* Product grid: 2 columns on phones, 3 on tablets (with the sixth "All five books" tile), 5 from 1024.
   Cards share the grid's rows through subgrid, so the space between card rows is each card's bottom margin
   (--card-gap-y): a row gap would also open up between the rows inside every card. */
.product-grid,
.product-grid-caption {
 --card-gap-y: var(--space-6);
}
.product-grid {
 display: grid;
 grid-template-columns: repeat(2, minmax(0, 1fr));
 gap: 0 12px;
 margin: 0;
 padding: 0;
 list-style: none;
}
.product-grid-caption {
 margin: calc(var(--space-4) - var(--card-gap-y, 0px)) 0 0;
 font-size: var(--text-xs);
 line-height: 1.45;
 color: var(--muted);
}

/* Product card: one stretched title link, rows aligned across the grid through a shared subgrid. */
.product-card {
 position: relative;
 display: grid;
 grid-row: span 6;
 grid-template-rows: subgrid;
 min-width: 0;
 margin-bottom: var(--card-gap-y);
}
.product-card-media {
 aspect-ratio: 4 / 5;
 overflow: hidden;
 background: var(--paper-deep);
}
.product-card-media > img {
 width: 100%;
 height: 100%;
 object-fit: cover;
 object-position: 50% 50%;
}
.product-card-record {
 display: flex;
 align-items: flex-start;
 text-wrap: balance;
 margin: 10px 0 4px;
 font-size: 12px;
 line-height: 1.3;
 /* Two even lines in narrow cards, never a year alone on the second. */
 text-wrap: balance;
}
/* The redaction bar sits on the first line when a label wraps in a narrow card. */
.product-card-record.record-line::before {
 margin-top: calc(.65em - 2px);
}
.product-card-title {
 margin: 0 0 2px;
 font: 400 18px/1.15 var(--serif);
 letter-spacing: -.01em;
}
.product-card-link {
 text-decoration: none;
}
.product-card-link::after {
 content: "";
 position: absolute;
 inset: 0;
 z-index: 1;
}
.product-card-link:focus-visible {
 outline: none;
}
.product-card-author {
 margin: 0 0 10px;
 font-size: var(--text-s);
 line-height: 1.4;
 color: var(--muted);
}
.product-card-prices {
 margin: 0;
 padding-top: 6px;
 border-top: 1px solid var(--rule);
}
.product-card-prices div {
 display: flex;
 align-items: baseline;
 justify-content: space-between;
 gap: var(--space-2);
 min-height: 22px;
}
.product-card-prices dt {
 font-size: var(--text-s);
 line-height: 1.4;
 color: var(--muted);
}
.product-card-prices dd {
 margin: 0;
 font: 400 var(--text-m)/1.3 var(--serif);
 font-variant-numeric: lining-nums tabular-nums;
 color: var(--ink);
}
.product-card-cta {
 display: flex;
 align-items: center;
 justify-content: space-between;
 gap: var(--space-2);
 min-height: 44px;
 margin-top: 10px;
 padding: 0 12px;
 border: 1px solid var(--ink);
 font: 600 var(--text-s)/1.2 var(--sans);
 color: var(--ink);
 transition: background-color .2s, color .2s;
}
.product-card-cta svg {
 flex: none;
 transition: transform .35s var(--ease-out);
}
.product-card:hover .product-card-title,
.product-card:focus-within .product-card-title {
 color: var(--scarlet);
}
.product-card:hover .product-card-cta,
.product-card:focus-within .product-card-cta {
 background: var(--ink);
 color: var(--paper);
}
.product-card:hover .product-card-cta svg {
 transform: translateX(3px);
}
/* Keyboard focus draws one ink ring around the whole card. */
.product-card:focus-within {
 outline: 2px solid var(--ink);
 outline-offset: 4px;
}
.product-card:focus-within:not(:has(:focus-visible)) {
 outline: none;
}
@media (prefers-reduced-motion: no-preference) {
 .product-card-media > img {
  transition: transform .45s var(--ease-out);
 }
 .product-card:hover .product-card-media > img {
  transform: translateY(-4px);
 }
}

/* Sixth tile: the collections, only where it completes a 2 x 3 or 3 x 2 grid. */
.collections-card .product-card-record {
 color: var(--muted);
}
.collections-card .cover-fan {
 width: 100%;
 height: 100%;
 --fan-width: 58%;
 --fan-step: 17%;
 --fan-top: 26%;
}

/* Cover fan: the five transparent covers overlapped on a paper stage. */
.cover-fan {
 --fan-width: 32%;
 --fan-step: 50%;
 --fan-top: 24.5%;
 position: relative;
 overflow: hidden;
 background: var(--paper-deep);
}
.cover-fan img {
 position: absolute;
 top: var(--fan-top);
 left: 50%;
 width: var(--fan-width);
 height: auto;
 transform-origin: 50% 94%;
 transform: translate(calc(-50% + var(--i) * var(--fan-step) * var(--spread, 1)), var(--lift)) rotate(calc(var(--i) * 3.5deg * var(--spread, 1)));
}
/* Spines face left, so each cover sits over its right-hand neighbour's spine and the author line stays whole. */
.cover-fan img:nth-child(1) { --i: -2; --lift: 5%; z-index: 5; }
.cover-fan img:nth-child(2) { --i: -1; --lift: 1.5%; z-index: 4; }
.cover-fan img:nth-child(3) { --i: 0; --lift: 0%; z-index: 3; }
.cover-fan img:nth-child(4) { --i: 1; --lift: 1.5%; z-index: 2; }
.cover-fan img:nth-child(5) { --i: 2; --lift: 5%; z-index: 1; }

@media (min-width: 768px) {
 .product-grid,
 .product-grid-caption {
  --card-gap-y: 40px;
 }
 .product-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 16px;
 }
 .product-grid-four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
 }
 .product-card-record {
  font-size: 13px;
 }
}
@media (min-width: 1024px) {
 .product-grid,
 .product-grid-caption {
  --card-gap-y: var(--space-7);
 }
 .product-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  column-gap: 24px;
 }
 .product-grid-four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
 }
 .collections-card {
  display: none;
 }
 .product-card-title {
  font-size: 20px;
 }
}

/* Five-book collections: two tiles whose rows line up through a shared subgrid from 768. */
.collections {
 padding: var(--section) var(--gutter);
 /* Anchor jumps land with the heading 24px under the header (html scroll-padding), not with the section padding. */
 scroll-margin-top: calc(0px - var(--section));
}
.collections-head {
 margin-bottom: var(--space-7);
}
.collections-head h2,
.collections-head h3 {
 margin: 0 0 var(--space-3);
}
/* Upright serif: the italic face is kept for the h1 and h2 accents only, so pages without one never download it. */
.collections-head p {
 max-width: 60ch;
 margin: 0;
 font: 400 var(--text-xl)/1.4 var(--serif);
 color: var(--ink-soft);
}
.collections-grid {
 display: grid;
 grid-template-columns: minmax(0, 1fr);
 row-gap: var(--space-8);
}
.collection-tile {
 display: flex;
 flex-direction: column;
 min-width: 0;
}
.collection-visual {
 margin: 0 0 var(--space-5);
}
.collection-visual > img,
.collection-visual > .cover-fan {
 display: block;
 width: 100%;
 height: auto;
 aspect-ratio: 3 / 2;
}
.collection-visual > img {
 object-fit: cover;
}
.collection-visual figcaption {
 margin-top: var(--space-2);
 font-size: var(--text-xs);
 line-height: 1.45;
 color: var(--muted);
}
.collection-name {
 margin: 0;
 padding-top: var(--space-5);
 border-top: 1px solid var(--rule);
 font: 400 var(--display-3)/1.1 var(--serif);
}
.collection-price {
 display: flex;
 flex-wrap: wrap;
 align-items: baseline;
 gap: var(--space-1) var(--space-4);
 margin: var(--space-4) 0 var(--space-5);
 font: 400 clamp(40px, 4vw, 56px)/1 var(--serif);
 letter-spacing: -.025em;
 font-variant-numeric: lining-nums;
}
.collection-price span {
 font: 500 var(--text-s)/1.4 var(--sans);
 letter-spacing: 0;
 color: var(--muted);
}
.collection-contents {
 margin: 0;
 font-size: var(--text-m);
 line-height: 1.5;
}
.collection-math {
 max-width: 58ch;
 margin: var(--space-2) 0 var(--space-6);
 font-size: var(--text-s);
 line-height: 1.5;
 color: var(--muted);
}
.collection-action {
 align-self: stretch;
}
.collection-action .button {
 width: 100%;
}
/* Each tile carries its own status, so it sits under its own button and follows that product's release. */
.collection-action .checkout-status {
 margin: var(--space-3) 0 0;
}
@media (prefers-reduced-motion: no-preference) {
 .collection-visual .cover-fan img {
  transition: transform .65s var(--ease-out);
 }
 .collection-tile:hover .collection-visual .cover-fan,
 .collection-tile:focus-within .collection-visual .cover-fan {
  --spread: 1.05;
 }
}

/* Phones (home and /shop): compact tiles with a 120px image beside the name and price, then the contents,
   arithmetic, a full-width order button and its status; the caption closes the tile. Kept tight so the first
   order button sits inside the first screen after the jump to #collections (in-app browsers show about 660px).
   The set photo is contained on paper so all five books stay in the thumbnail. */
@media (max-width: 767px) {
 .collections-head {
  margin-bottom: var(--space-5);
 }
 .collections-head p {
  font-size: var(--text-m);
 }
 .collections-grid {
  row-gap: var(--space-6);
 }
 .collection-tile {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  grid-template-rows: auto auto 1fr auto auto auto auto;
  grid-template-areas:
   "visual name"
   "visual price"
   "visual ."
   "contents contents"
   "math math"
   "action action"
   "caption caption";
  column-gap: var(--space-4);
  padding-top: var(--space-5);
  border-top: 1px solid var(--rule);
 }
 .collection-visual {
  display: contents;
 }
 .collection-visual > img,
 .collection-visual > .cover-fan {
  grid-area: visual;
  width: 120px;
  height: 120px;
  aspect-ratio: 1;
  margin-bottom: var(--space-4);
 }
 .collection-visual > img {
  object-fit: contain;
  background: var(--paper-deep);
 }
 .collection-visual > .cover-fan {
  --fan-width: 52%;
  --fan-step: 18%;
  --fan-top: 22%;
 }
 .collection-visual figcaption {
  grid-area: caption;
  margin-top: var(--space-3);
 }
 .collection-name {
  grid-area: name;
  padding-top: 0;
  border-top: 0;
  font-size: 24px;
 }
 .collection-price {
  grid-area: price;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  margin: var(--space-2) 0 var(--space-4);
  font-size: 34px;
 }
 .collection-contents {
  grid-area: contents;
 }
 .collection-math {
  grid-area: math;
  margin-bottom: var(--space-5);
 }
 .collection-action {
  grid-area: action;
 }
}

/* From 768 the tiles sit side by side as subgrids. The grid's row gap would open up between the rows
   inside each tile, so it is zero here; the tiles' own margins space their rows. */
@media (min-width: 768px) {
 .collections-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(var(--space-5), 3.4vw, var(--space-8));
  row-gap: 0;
 }
 .collection-tile {
  display: grid;
  grid-row: span 6;
  grid-template-rows: subgrid;
  row-gap: 0;
 }
 .collection-action {
  align-self: start;
 }
 .collection-action .button {
  width: auto;
 }
}
/* Desktop: image left, details right, so prices, arithmetic and both buttons fit one screen after the jump
   (1024x768 and 1180x820 included). */
@media (min-width: 1024px) {
 .collection-tile {
  grid-row: span 5;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  column-gap: var(--space-5);
 }
 .collection-visual {
  grid-column: 1;
  grid-row: 1 / -1;
  margin: 0;
 }
 .collection-tile > :not(.collection-visual) {
  grid-column: 2;
 }
 .collection-name {
  padding-top: 0;
  border-top: 0;
 }
 .collection-price {
  margin-top: var(--space-3);
 }
 .collection-math {
  margin-bottom: var(--space-5);
 }
}
/* Narrow detail columns: the shipping caption goes under the price in both tiles, never in one only. */
@media (min-width: 1024px) and (max-width: 1199px) {
 .collection-price {
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
 }
}

/* Trust strip: four plain facts. 2 x 2 on phones, one row with vertical rules from 768. */
.trust-strip {
 padding: 0 var(--gutter);
}
.trust-strip ul {
 display: grid;
 grid-template-columns: repeat(2, minmax(0, 1fr));
 margin: 0;
 padding: 0;
 list-style: none;
 border-block: 1px solid var(--rule);
}
.trust-strip li {
 display: flex;
 align-items: center;
 min-height: 56px;
 padding: var(--space-3) var(--space-4) var(--space-3) 0;
 font-size: var(--text-s);
 line-height: 1.4;
 color: var(--ink-soft);
}
.trust-strip li:nth-child(2n) {
 padding-left: var(--space-4);
 border-left: 1px solid var(--rule);
}
.trust-strip li:nth-child(n + 3) {
 border-top: 1px solid var(--rule);
}
@media (min-width: 768px) {
 .trust-strip ul {
  grid-template-columns: repeat(4, minmax(0, 1fr));
 }
 .trust-strip li,
 .trust-strip li:nth-child(n) {
  min-height: 64px;
  padding: var(--space-4) var(--space-5);
  border-top: 0;
  border-left: 1px solid var(--rule);
 }
 .trust-strip li:first-child {
  padding-left: 0;
  border-left: 0;
 }
}
@media (min-width: 1024px) {
 .trust-strip li {
  font-size: 15px;
 }
}

/* Starting points: five guided rows, and the free reading guide beside them from 1024. */
.starting-points {
 padding: var(--section) var(--gutter);
 border-top: 1px solid var(--rule);
}
.starting-points h2 {
 margin: 0 0 var(--space-6);
}
.starting-points-layout {
 display: grid;
 gap: var(--space-7);
}
.start-list {
 margin: 0;
 padding: 0;
 list-style: none;
 border-top: 1px solid var(--ink);
}
.start-row {
 display: grid;
 grid-template-columns: minmax(0, 1fr) auto;
 align-items: center;
 gap: var(--space-1) var(--space-4);
 min-height: 64px;
 padding: var(--space-3) 0;
 border-bottom: 1px solid var(--rule);
 text-decoration: none;
}
.start-row > svg {
 grid-column: 2;
 grid-row: 1 / span 2;
 flex: none;
 transition: transform .35s var(--ease-out);
}
.start-label {
 grid-column: 1;
 font-size: 12px;
 color: var(--muted);
}
.start-book {
 grid-column: 1;
 display: flex;
 flex-wrap: wrap;
 align-items: baseline;
 gap: 0 var(--space-3);
}
.start-title {
 font: 400 20px/1.25 var(--serif);
 transition: color .2s;
}
.start-author {
 font-size: var(--text-s);
 line-height: 1.4;
 color: var(--muted);
}
.start-row:hover .start-title {
 color: var(--scarlet);
}
.start-row:hover > svg {
 transform: translateX(3px);
}
/* Guide block: thumbnail beside the text, button underneath on phones and beside the thumbnail on tablets. */
.guide-block {
 display: grid;
 grid-template-columns: 120px minmax(0, 1fr);
 grid-template-areas:
  "thumb text"
  "action action";
 align-items: start;
 gap: var(--space-5) var(--space-4);
 padding: var(--space-5);
 background: var(--paper-deep);
}
.guide-thumb {
 grid-area: thumb;
 width: 120px;
 height: auto;
 box-shadow: 0 12px 24px -16px rgba(29, 34, 33, .5);
}
.guide-text {
 grid-area: text;
}
.guide-text h3 {
 margin: 0 0 var(--space-2);
 font-size: var(--display-4);
}
.guide-text p {
 margin: 0;
 font-size: var(--text-s);
 line-height: 1.5;
 color: var(--ink-soft);
}
.guide-button {
 grid-area: action;
 justify-self: start;
 min-height: 44px;
 padding: 0 16px;
 gap: var(--space-3);
 font-size: var(--text-s);
}
@media (min-width: 768px) {
 .start-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  column-gap: var(--space-5);
 }
 .start-row > svg {
  grid-column: 3;
  grid-row: 1;
 }
 .start-label {
  font-size: 13px;
 }
 .start-book {
  grid-column: 2;
  grid-row: 1;
 }
 .guide-block {
  grid-template-rows: auto 1fr;
  grid-template-areas:
   "thumb text"
   "thumb action";
  column-gap: var(--space-5);
 }
 .guide-button {
  align-self: end;
 }
}
@media (min-width: 1024px) {
 .starting-points-layout {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: clamp(48px, 6vw, 96px);
  align-items: start;
 }
 .guide-block {
  grid-template-columns: 120px minmax(0, 1fr);
  grid-template-rows: auto;
  grid-template-areas:
   "thumb text"
   "action action";
 }
 .guide-button {
  align-self: start;
 }
}

/* Compare formats: a table from 768; the same rows as stacked cards below. */
.formats {
 padding: var(--section) var(--gutter);
 border-top: 1px solid var(--rule);
 scroll-margin-top: calc(0px - var(--section));
}
.formats h2,
.formats h3 {
 margin: 0 0 var(--space-6);
}
/* It states availability, so it keeps the 14px floor for availability text. */
.formats-soon {
 display: block;
 margin-top: var(--space-1);
 font-size: var(--text-s);
 letter-spacing: .08em;
 color: var(--muted);
}
.formats-table {
 display: none;
 width: 100%;
 border-collapse: collapse;
 font-size: var(--text-s);
 line-height: 1.45;
}
.formats-table th,
.formats-table td {
 padding: var(--space-4) var(--space-5) var(--space-4) 0;
 border-bottom: 1px solid var(--rule);
 text-align: left;
 vertical-align: top;
}
.formats-table thead th {
 padding-block: var(--space-3);
 border-bottom-color: var(--ink);
 font: 400 12px/1.3 var(--label);
 letter-spacing: .12em;
 text-transform: uppercase;
 color: var(--muted);
}
.formats-table tbody th {
 font: 400 var(--text-l)/1.3 var(--serif);
}
.formats-table td {
 color: var(--ink-soft);
}
/* Names, headers and shipping stay on one line; "What you get" takes the remaining width and wraps. */
.formats-table th,
.formats-table td:last-child {
 white-space: nowrap;
}
.formats-table .formats-price {
 font: 400 var(--text-l)/1.3 var(--serif);
 font-variant-numeric: lining-nums tabular-nums;
 color: var(--ink);
}
.formats-list {
 margin: 0;
 padding: 0;
 list-style: none;
 border-top: 1px solid var(--ink);
}
/* Fixed column proportions, so price and shipping line up down the list like a table column. */
.formats-card {
 display: grid;
 grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
 gap: var(--space-1) var(--space-4);
 margin: 0;
 padding: var(--space-4) 0;
 border-bottom: 1px solid var(--rule);
}
.formats-card dt {
 font: 400 var(--text-l)/1.3 var(--serif);
}
.formats-card dd {
 margin: 0;
 font-size: var(--text-s);
 line-height: 1.45;
 color: var(--ink-soft);
}
.formats-card .formats-price {
 grid-column: 2;
 grid-row: 1;
 justify-self: end;
 font: 400 var(--text-l)/1.3 var(--serif);
 font-variant-numeric: lining-nums tabular-nums;
 color: var(--ink);
}
.formats-card .formats-what {
 grid-column: 1;
}
.formats-card .formats-shipping {
 grid-column: 2;
 grid-row: 2;
 text-align: right;
 color: var(--muted);
}
@media (min-width: 768px) {
 .formats-table {
  display: table;
 }
 .formats-list {
  display: none;
 }
}
/* About four card columns wide, so each row reads as one line from format name to shipping. */
@media (min-width: 1024px) {
 .formats-table {
  max-width: 1040px;
 }
}
