/*
 * The quick look, and the platform sheet it replaces.
 *
 * Loaded beside catalog.css, which is the stylesheet whose scope is already
 * "pages that print product cards" -- the category grid, the product page's two
 * shelves, the picker's results, a shared list. The panel cannot appear on a
 * page with no cards on it, so it is not carried by one.
 *
 * Deliberately not the landing page's .featured-sheet, which this is plainly a
 * sibling of. That one lives in styles-content.css and styles-content.css is
 * loaded by index.html alone; the choice was between hauling the home page's
 * whole content sheet onto four more pages, or pulling one dialog out of it and
 * re-testing the 3D shelf that opens it. Neither is worth it for a polish item,
 * so this is written to match it -- cream ground, three-pixel ink border, hard
 * offset shadow, a degree of tilt -- and the two are only related by eye.
 */

/*
 * The press has to be ours, and on a phone that means taking the platform's.
 *
 * iOS answers a long press on a link with a preview card and a share menu, and
 * the only way to decline it is to say so before the press -- there is no event
 * to refuse. -webkit-touch-callout does that, and user-select stops the text
 * magnifier that otherwise appears over the product name at the same moment.
 *
 * Scoped to the card's link and nothing else: every other link on the site,
 * including the ones inside the panel this opens, keeps the platform's menu.
 * The trade is only worth making where something better is on the other side.
 */
.catalog-compact-link {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* [hidden] is a UA display:none, which a display:grid here would silently beat
   and leave the scrim over the page for good. */
#productPeekMount[hidden] { display: none; }
#productPeekMount {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(12, 11, 14, .58);
  animation: product-peek-scrim .18s ease both;
}

.product-peek {
  position: relative;
  display: grid;
  grid-template-columns: .8fr 1.2fr;
  width: min(560px, 100%);
  max-height: 100%;
  overflow: hidden;
  /* Grid children floor at their content size unless told not to, and without
     this the copy column pushes the panel past the screen instead of scrolling
     inside it -- which is what a long description and a run of sizes together
     do on a phone. */
  min-height: 0;
  color: var(--ink);
  border: 3px solid var(--ink);
  background: #fff;
  box-shadow: 10px 12px 0 var(--ink);
  transform: rotate(-.7deg);
  animation: product-peek-open .26s cubic-bezier(.2, 1.35, .4, 1) both;
}

/*
 * The card's own colour, not the page's. These panels open from grids that mix
 * categories -- the shelf under a poster, the picker's results -- so the body
 * theme is the wrong answer for every card but one. Same seven rows the compact
 * card carries in catalog.css, for the same reason.
 */
.product-peek[data-theme="purple"] { --accent: var(--brand); --accent-ink: var(--ink); }
.product-peek[data-theme="red"]    { --accent: var(--red); --accent-ink: #fff; }
.product-peek[data-theme="ink"]    { --accent: #343139; --accent-ink: #fff; }
.product-peek[data-theme="gold"]   { --accent: var(--gold); --accent-ink: var(--ink); }
.product-peek[data-theme="blue"]   { --accent: var(--blue); --accent-ink: var(--ink); }
.product-peek[data-theme="green"]  { --accent: var(--green); --accent-ink: #fff; }
.product-peek[data-theme="paper"]  { --accent: var(--brand-tint-deep); --accent-ink: var(--ink); }

.product-peek-art {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 14px;
  border-right: 3px solid var(--ink);
  background-color: var(--accent);
  /* The same halftone the featured sheet's cover panel wears, so the two read
     as printed on one press. */
  background-image: radial-gradient(circle, rgba(12, 11, 14, .25) 1px, transparent 1.7px);
  background-size: 8px 8px;
}
/*
 * A photo fills the panel; the BOOM pack placeholder does not. The pack is a
 * drawn object with its own proportions -- stretched to the box it stops being
 * a pack and becomes a smear -- so it is sized like the one on the featured
 * sheet and left to sit in the middle of the halftone.
 */
.product-peek-art img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
}
.product-peek-art .catalog-pack {
  width: min(78%, 190px);
  max-height: 100%;
  min-height: 0;
  margin: auto;
}
/*
 * The word on the pack is sized in vw everywhere else, which is right for a
 * card that is a share of the screen and wrong in a column that is not: at a
 * desktop width "BOOM" was set to seventy-nine pixels inside a pack a hundred
 * and seventy wide, and ran out of both sides of it. Sized off the pack here
 * instead, so it is the same object at every viewport.
 */
.product-peek-art .catalog-pack span { font-size: 2.3rem; }
.product-peek-art .catalog-pack::before { margin-bottom: 6px; font-size: 1.5rem; }
.product-peek-issue {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 8px;
  padding: 2px 7px;
  border: 2px solid var(--ink);
  background: #fff;
  color: var(--ink);
  font-size: .62rem;
  font-weight: 900;
  letter-spacing: .08em;
}

.product-peek-copy {
  display: grid;
  align-content: start;
  gap: 10px;
  /* The one scroll in the panel, and only when a long description and a row of
     sizes together outgrow the screen. The scrim above does not scroll. */
  overflow-y: auto;
  min-height: 0;
  padding: clamp(15px, 3vw, 24px);
}
.product-peek-copy > small {
  color: #6e6871;
  font-size: .56rem;
  font-weight: 900;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.product-peek-copy h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 400;
  line-height: .95;
  text-transform: uppercase;
}
.product-peek-copy > p {
  margin: 0;
  font-size: .82rem;
  line-height: 1.45;
}

.product-peek-close {
  position: absolute;
  z-index: 5;
  top: 6px;
  right: 6px;
  width: 34px;
  height: 34px;
  border: 2px solid var(--ink);
  background: #fff;
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

/*
 * The buy block, at the panel's scale.
 *
 * The markup is the poster's -- the same cartControlsMarkup, the same hooks,
 * the same size chips -- because there is one store path and a second one that
 * looked slightly different would be a second one to keep correct. What it is
 * not is the poster's SIZE: those controls are edge-to-edge bars ninety-two
 * pixels tall down a column that is the whole page, and dropped into a panel
 * this wide they overlap. Everything below re-scales the same object and
 * changes nothing about what it does.
 */
.product-peek .cart-controls {
  display: grid;
  margin-top: 2px;
  border: var(--line);
  background: #fff;
}
.product-peek .product-price-options,
.product-peek .product-color-options { padding: 12px; border-top: 0; }
.product-peek .cart-controls > * + * { border-top: var(--line); }
.product-peek .product-price-options legend,
.product-peek .product-color-options legend { font-size: .58rem; }
/*
 * Two chips to a row, and both allowed to shrink. auto-fit at the poster's
 * minimum fits three across a phone and then each one is narrower than the
 * words in it -- "PRICE PENDING" is longer than any weight label and it was
 * running out of the side of the panel. minmax(0, 1fr) is the half of this
 * that matters: a grid track's floor is its content otherwise.
 */
.product-peek .product-price-options > div {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.product-peek .product-price-options label { padding: 8px; }
.product-peek .product-price-options label strong,
.product-peek .product-price-options label span {
  min-width: 0;
  font-size: .8rem;
  overflow-wrap: anywhere;
}
.product-peek .product-pick { padding: 9px 12px; border-top: var(--line); }
.product-peek .product-pick strong { font-size: 1.15rem; }
.product-peek .cart-sold-out { padding: 12px; }
.product-peek .cart-sold-out strong { font-size: 1.2rem; }

.product-peek-add {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  border: 0;
  color: #fff;
  background: var(--ink);
  text-align: left;
  cursor: pointer;
}
.product-peek-add span { display: grid; gap: 2px; }
.product-peek-add small {
  font-size: .5rem;
  font-weight: 900;
  letter-spacing: .13em;
  text-transform: uppercase;
  opacity: .78;
}
.product-peek-add strong {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 400;
  text-transform: uppercase;
}
.product-peek-add b { font-size: 1.15rem; }
.product-peek .cart-inline-stepper { justify-content: space-between; padding: 4px; }
/* The confirmed bar, scaled the way the add button above it is. */
.product-peek .cart-added { gap: 10px; padding: 12px; }
.product-peek .cart-added-line strong { font-size: 1.2rem; }

.product-peek-actions {
  display: grid;
  gap: 8px;
  margin-top: 2px;
}
.product-peek-story {
  display: grid;
  gap: 2px;
  padding: 9px 12px;
  border: var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.product-peek-story small {
  font-size: .52rem;
  font-weight: 900;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: #6e6871;
}
.product-peek-story strong { font-size: .84rem; }
.product-peek-story[disabled] { opacity: .6; cursor: progress; }
.product-peek-open {
  font-size: .74rem;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.product-peek-status { margin: 0; font-size: .72rem; }
.product-peek-status.is-error { color: #a82c31; }
.product-peek :focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/*
 * One column below the width where two would leave the picture a stripe. The
 * art keeps a fixed height there rather than a fraction of the panel, so a long
 * description pushes the buttons down the scroll instead of squeezing the
 * product's photo out of existence.
 */
@media (max-width: 460px) {
  .product-peek { grid-template-columns: 1fr; }
  .product-peek-art {
    height: 148px;
    border-right: 0;
    border-bottom: 3px solid var(--ink);
  }
}

@keyframes product-peek-scrim {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes product-peek-open {
  from { opacity: 0; transform: rotate(-.7deg) scale(.94); }
  to { opacity: 1; transform: rotate(-.7deg) scale(1); }
}

/*
 * The panel still arrives -- it is the answer to a press, and an answer that
 * does not appear reads as a press that did not work. It simply arrives at
 * once, without the scrim fading or the card springing up under the thumb.
 */
@media (prefers-reduced-motion: reduce) {
  #productPeekMount,
  .product-peek { animation-duration: .01ms; }
}
