/*
 * Your shelf on the wishlist page.
 *
 * The comics are the same painted covers the home page's 3D rack carries, drawn
 * on plain canvases -- so this stylesheet's whole job is to stand them up, put a
 * board under them, and stay out of the artwork's way. Nothing here recolours a
 * cover: the category colour, the masthead and the issue number are printed
 * into the canvas by featured-comic-art.mjs, and a tint laid over the top would
 * be the site disagreeing with itself about what a Boom comic looks like.
 */

/* A plain block with no display of its own, so `hidden` already wins. Stated
   because a later `display` here would unhide an empty shelf. */
.comic-shelf-section[hidden] { display: none; }

.comic-shelf-section {
  margin: 0 0 clamp(30px, 4vw, 48px);
}
.comic-shelf-head { margin-bottom: clamp(16px, 2vw, 24px); }
.comic-shelf-head h2 {
  margin: 6px 0 10px;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  line-height: .92;
}
.comic-shelf-head p { max-width: 52ch; margin: 0; }

/*
 * The board.
 *
 * A row that scrolls sideways rather than wrapping, because a shelf is a line
 * of things and a shelf that reflows into a grid is a grid. The rule under it
 * is the board edge, and it runs the full scroll width so a shelf you have
 * pushed along still has something to stand on.
 */
.comic-shelf {
  display: flex;
  gap: clamp(12px, 1.6vw, 20px);
  align-items: flex-end;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 0 2px 14px;
  border-bottom: 6px solid var(--ink, #0c0b0e);
  scrollbar-width: thin;
}

.comic-shelf-slot {
  flex: 0 0 auto;
  display: block;
  width: clamp(96px, 15vw, 150px);
  /* Set by comic-shelf.mjs off the artwork's own canvas size, so the slot can
     never disagree with the cover standing in it. */
  aspect-ratio: var(--cover-ratio, 460 / 651);
  position: relative;
  text-decoration: none;
  color: inherit;
  /* Comics on a shelf lean. Undone on hover, which is the whole animation. */
  transform: rotate(-1.1deg);
  transition: transform .28s cubic-bezier(.22, 1.4, .36, 1);
}
.comic-shelf-slot:nth-child(even) { transform: rotate(1.4deg); }
.comic-shelf-slot:hover,
.comic-shelf-slot:focus-visible { transform: rotate(0deg) translateY(-8px); }
.comic-shelf-slot:focus-visible { outline: 3px solid var(--brand, #877ebc); outline-offset: 3px; }

.comic-shelf-cover {
  display: block;
  width: 100%;
  height: 100%;
  border: 2px solid var(--ink, #0c0b0e);
  box-shadow: 4px 5px 0 rgba(0, 0, 0, .35);
  background: var(--paper, #f2efe9);
}

/*
 * The product's name, for a reader who cannot see the cover it is printed on.
 *
 * Off-screen rather than `display: none`, which would take it out of the
 * accessibility tree as well and leave a row of links called nothing.
 */
.comic-shelf-name {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The gap at the end. Dashed, and empty, because it is a space rather than a
   thing -- it should not read as a comic whose cover failed to load. */
.comic-shelf-slot.is-empty {
  display: grid;
  place-items: center;
  transform: none;
  border: 3px dashed color-mix(in srgb, var(--ink, #0c0b0e) 35%, transparent);
  background: color-mix(in srgb, var(--brand, #877ebc) 8%, transparent);
}
.comic-shelf-slot.is-empty:hover,
.comic-shelf-slot.is-empty:focus-visible {
  transform: translateY(-4px);
  border-style: solid;
}
.comic-shelf-plus {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
  color: color-mix(in srgb, var(--ink, #0c0b0e) 45%, transparent);
}

.comic-shelf-share {
  display: inline-block;
  margin-top: 16px;
  font-weight: 800;
  font-size: .86rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}

@media (prefers-reduced-motion: reduce) {
  .comic-shelf-slot { transform: none; transition: none; }
  .comic-shelf-slot:nth-child(even) { transform: none; }
  .comic-shelf-slot:hover,
  .comic-shelf-slot:focus-visible { transform: none; }
}

/*
 * On the two-column checkout layout the shelf takes the whole width and sits
 * on top.
 *
 * Explicit placement rather than moving it up the document, and the difference
 * matters: the page's <h1> is "Where should it land?" in .checkout-intro, and a
 * section headed <h2> written above it in the source would put an h2 before the
 * h1 on the page it belongs to. So it stays after the intro in the DOM, where
 * the heading order is right, and is placed on row 1 here. Nothing in
 * .checkout-intro can take focus, so nothing is reordered for a keyboard.
 *
 * catalog.css:2492 is the grid this is placing into; the breakpoint is its.
 */
@media (min-width: 760px) {
  .comic-shelf-section { grid-column: 1 / -1; grid-row: 1; }
  .checkout-intro { grid-row: 2; grid-column: 1; }
  .fulfillment-form { grid-row: 2; grid-column: 2; }
  /* Room to be a shelf now that it has the page's width. */
  .comic-shelf-slot { width: clamp(120px, 12vw, 176px); }
}
