/* ==========================================================================
   cart.css — the cart (js/cart.js): templates as blocks, the cart button,
   the drawer, and the flight from a card into the cart. The blocks are also
   drawn on the payment page (css/checkout.css sets their size there).
   ========================================================================== */

/* --- a block: the cover on top; four sides of stacked page edges in its category's colour.
   The stack is seen from above at an angle (iso); each block sits on the one below, a little askew. */
.iso-host { --bw: 132px; --bd: 99px; --bh: 12px; --gap: 1px; position: relative; display: grid; place-items: center; perspective: 1600px; }
.iso { position: relative; width: var(--bw); height: var(--bd); transform-style: preserve-3d; transform: rotateX(58deg) rotateZ(-40deg);
  margin-top: calc(var(--n, 1) * var(--bh) * .9); }
.blk { position: absolute; inset: 0; transform-style: preserve-3d; transform: translateZ(calc(var(--z) * (var(--bh) + var(--gap)))) rotateZ(var(--tw, 0deg));
  transition: transform .55s var(--e-spring); }
.blk i { position: absolute; display: block; }
.b-t { inset: 0; transform: translateZ(var(--bh)); border-radius: 2px; background: var(--sheet) center / cover no-repeat; box-shadow: inset 0 0 0 1px rgba(15, 15, 15, .1); }
/* the sides: page edges, the paper's colour between lines of the category's colour */
.b-f, .b-b, .b-l, .b-r { background: repeating-linear-gradient(0deg, var(--side) 0 2px, color-mix(in srgb, var(--side) 55%, var(--sheet)) 2px 3px); }
.b-f { left: 0; top: 100%; width: 100%; height: var(--bh); transform-origin: top; transform: rotateX(90deg); }
.b-b { left: 0; bottom: 100%; width: 100%; height: var(--bh); transform-origin: bottom; transform: rotateX(-90deg); filter: brightness(.86); }
.b-l { right: 100%; top: 0; width: var(--bh); height: 100%; transform-origin: right; transform: rotateY(90deg); filter: brightness(.84); }
.b-r { left: 100%; top: 0; width: var(--bh); height: 100%; transform-origin: left; transform: rotateY(-90deg); filter: brightness(.9); }
.b-l, .b-r { background: repeating-linear-gradient(90deg, var(--side) 0 2px, color-mix(in srgb, var(--side) 55%, var(--sheet)) 2px 3px); }
/* a soft shadow on the ground under the stack */
.iso::before { content: ""; position: absolute; inset: -8%; border-radius: 12%; background: rgba(15, 15, 15, .14); filter: blur(10px); transform: translateZ(-1px); }
:root[data-theme="dark"] .iso::before { background: rgba(0, 0, 0, .45); }
.iso-mini { --bw: 30px; --bd: 22px; --bh: 4px; --gap: .5px; }
.iso-mini .b-f, .iso-mini .b-b, .iso-mini .b-l, .iso-mini .b-r { background: var(--side); }
.iso-mini .iso::before { filter: blur(4px); }
/* a block arriving drops onto the stack, settles with a little bounce; one taken out lifts off and fades */
.blk.drop { animation: blk-drop .7s var(--e-out) both; }
@keyframes blk-drop { 0% { translate: 0 0 calc(var(--bh) * 10); opacity: 0; } 50% { translate: 0 0 0; opacity: 1; } 68% { translate: 0 0 calc(var(--bh) * .9); } 84% { translate: 0 0 0; } 92% { translate: 0 0 calc(var(--bh) * .2); } 100% { translate: 0 0 0; } }
.blk.lift { animation: blk-lift .32s var(--e-soft) forwards; }
@keyframes blk-lift { to { translate: 0 0 calc(var(--bh) * 8); opacity: 0; } }

/* --- the cart button: bottom right, the stack in miniature, the count and the total -------------------
   Solid ink, so it stands out on any page (the pages are light paper); it only exists once something is in
   the cart. On a phone it is a round button above the dock, so it covers as little of the page as it can. */
.ct-fab { position: fixed; right: clamp(14px, 2.2vw, 28px); bottom: calc(22px + env(safe-area-inset-bottom, 0px)); z-index: 250;
  display: flex; align-items: center; gap: 10px; height: 62px; padding: 0 16px 0 7px; border-radius: 20px;
  background: var(--ink); color: var(--on-ink);
  box-shadow: 0 0 0 3px var(--paper), 0 12px 26px rgba(15, 15, 15, .26), 0 26px 54px rgba(15, 15, 15, .2);
  text-align: left; opacity: 0; transform: translateY(130%) scale(.9); pointer-events: none;
  transition: transform .55s var(--e-spring), opacity .3s, box-shadow .3s; }
.ct-fab.on { opacity: 1; transform: none; pointer-events: auto; }
/* switching light/dark draws named parts (the nav, the cards) above the page's picture: the cart is named too, so
   it stays on top of the cards instead of sinking under them for the moment of the switch */
.ct-fab { view-transition-name: cart; } .ct { view-transition-name: cart-drawer; }
.ct-fab:hover { transform: translateY(-2px); box-shadow: 0 0 0 3px var(--paper), 0 16px 32px rgba(15, 15, 15, .3), 0 32px 64px rgba(15, 15, 15, .22); }
.ct-fab:hover .iso { --gap: 2px; }
/* the little stack sits on its own light tile, so the covers read against the ink */
.ct-mini { width: 48px; height: 48px; overflow: visible; border-radius: 14px; background: var(--paper); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1); }
.ct-mini .iso { margin-top: calc(var(--n, 1) * 3px); }
.ct-fab-t { display: grid; gap: 3px; line-height: 1.1; }
.ct-fab-t b { font-size: 14.5px; font-weight: 650; }
.ct-fab-t small { font: 600 13px/1 var(--f-ui); color: color-mix(in srgb, var(--on-ink) 70%, transparent); font-variant-numeric: tabular-nums; }
.ct-fab-go { width: 15px; height: 15px; margin-left: 2px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .35s var(--e-spring); }
.ct-fab:hover .ct-fab-go { transform: translateX(3px); }
.ct-fab.say .ct-fab-go { display: none; }
.ct-fab-n { position: absolute; top: -8px; left: -8px; display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 12px;
  background: var(--focus); color: #fff; font: 700 12.5px/1 var(--f-ui); box-shadow: 0 0 0 3px var(--paper); }
.ct-fab.bump { animation: fab-bump .55s var(--e-spring); }
@keyframes fab-bump { 0% { transform: none; } 30% { transform: translateY(3px) scale(.96, 1.03); } 60% { transform: translateY(-3px) scale(1.03, .98); } 100% { transform: none; } }
.ct-fab.bump .ct-fab-n { animation: n-pop .5s var(--e-spring); }
@keyframes n-pop { 40% { transform: scale(1.35); } }
/* the moment after adding: it says what was added, and offers Checkout */
.ct-fab-say { display: flex; align-items: center; gap: 10px; max-width: 0; overflow: hidden; opacity: 0; white-space: nowrap; transition: max-width .55s var(--e-out), opacity .3s, margin .55s var(--e-out); }
.ct-fab.say .ct-fab-say { max-width: 340px; opacity: 1; margin-left: 2px; }
.ct-say-t { max-width: 190px; overflow: hidden; text-overflow: ellipsis; font-size: 13px; color: color-mix(in srgb, var(--on-ink) 75%, transparent); }
.ct-say-go { padding: 9px 12px; border-radius: 10px; background: var(--on-ink); color: var(--ink); font-size: 13px; font-weight: 650; }

/* --- the flight: the cover lifts off the card and arcs into the cart, turning into a block --------------- */
.ct-fly { position: fixed; left: 0; top: 0; z-index: 420; pointer-events: none; will-change: transform; }
.ct-fly span { display: block; width: 100%; height: 100%; border-radius: 10px; background: center / cover no-repeat;
  box-shadow: 0 1px 0 var(--side), 0 2px 0 var(--side), 0 3px 0 var(--side), 0 4px 0 var(--side), 0 5px 0 var(--side), 0 6px 0 var(--side), 0 18px 34px rgba(15, 15, 15, .28); }

/* --- the drawer: slides in from the right, like Side Peek (a sheet from the bottom on a phone) ------------ */
html.carting { overflow: hidden; }
.ct-veil { position: fixed; inset: 0; z-index: 330; background: rgba(15, 15, 15, .22); opacity: 0; transition: opacity .35s; }
.ct-veil.open { opacity: 1; }
.ct { position: fixed; top: 0; right: 0; bottom: 0; z-index: 340; display: flex; flex-direction: column; width: min(440px, 100%);
  background: var(--sheet); box-shadow: -18px 0 50px -20px rgba(15, 15, 15, .35); transform: translateX(104%); transition: transform .42s var(--e-out); }
.ct.open { transform: none; }
.ct-top { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 6px 22px; }
.ct-top h2 { font: 500 26px/1.15 var(--f-display); color: var(--ink); }
.ct-n { margin-left: 4px; font: 500 15px/1 var(--f-mono); color: var(--ink-4); vertical-align: middle; }
.ct-x { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; color: var(--ink-3); transition: background-color .2s, color .2s; }
.ct-x:hover { background: var(--hover); color: var(--ink); }
.ct-x svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.ct-in { flex: 1; overflow: auto; padding: 0 18px 12px; }
/* the stack stands on a small stage of the site's halftone dots */
.ct-tower { min-height: 190px; margin: 6px 0 12px; padding: 18px 0 26px; border-radius: 16px; background: var(--paper);
  background-image: radial-gradient(var(--dots) 1px, transparent 1.3px); background-size: 14px 14px; box-shadow: inset 0 0 0 1px var(--line); }
.ct-tower:hover .iso { --gap: 7px; }
.ct-tower .iso { animation: iso-sway 7s ease-in-out infinite; }
@keyframes iso-sway { 50% { transform: rotateX(58deg) rotateZ(-34deg); } }
.ct-list { display: grid; gap: 2px; }
.ct-list li { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto 30px; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; transition: background-color .2s, opacity .3s, transform .3s var(--e-out); }
.ct-list li:hover { background: var(--hover); }
.ct-list li.going { opacity: 0; transform: translateX(24px); }
.ct-list img { width: 64px; height: 48px; border-radius: 7px; object-fit: cover; box-shadow: 0 0 0 1px var(--line); }
.ct-l-t { display: grid; gap: 4px; min-width: 0; }
.ct-l-t b { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14.5px; font-weight: 600; color: var(--ink); }
.ct-l-p { display: grid; justify-items: end; font-weight: 650; font-size: 14.5px; color: var(--ink); }
.ct-l-p s { font-weight: 400; font-size: 12px; color: var(--ink-4); }
.ct-rm { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: var(--ink-4); opacity: .6; transition: opacity .2s, background-color .2s, color .2s; }
.ct-list li:hover .ct-rm, .ct-rm:focus-visible { opacity: 1; }
.ct-rm:hover { background: var(--t-red-bg); color: var(--t-red); }
.ct-rm svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.ct-empty { padding: 26px 8px; text-align: center; color: var(--ink-3); }
.ct-empty b { color: var(--ink); }
.ct-foot { display: grid; gap: 10px; padding: 14px 22px calc(18px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--sheet); }
.ct-foot[hidden] { display: none; }
.ct-sum { display: flex; align-items: baseline; justify-content: space-between; font-size: 15px; color: var(--ink-2); }
.ct-sum b { font: 600 24px/1 var(--f-display); color: var(--ink); }
.ct-sum b s { margin-right: 6px; font: 500 15px/1 var(--f-ui); color: var(--ink-4); }
.ct-save { margin-top: -6px; font-size: 13px; font-weight: 600; color: var(--t-green); }
:root[data-theme="dark"] .ct-save { color: #7FC796; }
.ct-go { justify-content: center; height: 52px; font-size: 15.5px; }
.ct-go svg { width: 16px; height: 16px; transition: transform .35s var(--e-spring); }
.ct-go:hover svg { transform: translateX(3px); }
.ct-fine { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12.5px; color: var(--ink-4); }
.ct-fine svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.5; }

@media (max-width: 760px) {
  /* a phone: a round button above the dock, just the stack and the count (it opens out to "Checkout" after adding) */
  .ct-fab { right: 12px; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); height: 58px; min-width: 58px; padding: 0 5px; gap: 6px; border-radius: 29px; }
  .ct-fab-t, .ct-fab-go { display: none; }
  .ct-mini { width: 48px; height: 48px; border-radius: 50%; }
  .ct-fab.say { padding-right: 6px; }
  .ct-fab.say .ct-fab-say { max-width: 230px; }
  .ct-say-t { display: none; }
  .ct-say-go { padding: 12px 14px; border-radius: 22px; }
  .ct { top: auto; width: 100%; height: 86vh; border-radius: 20px 20px 0 0; transform: translateY(104%); }
  .ct.open { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .blk, .ct-fab, .ct { transition: none; }
  .blk.drop, .blk.lift, .ct-fab.bump, .ct-tower .iso { animation: none; }
}

/* --- the Templates page's buttons once a template is in the cart */
.tpl-get.in { gap: 5px; color: var(--t-green); background: var(--t-green-bg); }
.tpl-get.in:hover { box-shadow: none; }
