/* Engine styles (U15): the buying controls, page states, cart, size guide, return view and
   email forms. Layout and state styling only. Colour, type and shape come from the skin's
   custom properties (--skin-bg, --skin-surface, --skin-fg, --skin-muted, --skin-border,
   --skin-accent, --skin-accent-fg, --skin-danger, --skin-font-display, --skin-font-body,
   --skin-radius), each with a fallback, so any skin restyles it and the plain test skin
   looks acceptable. Every control is at least 44 px. The last section ("Motion kit", U16) holds
   every animation and transition: hidden or moving states exist only behind html.kp-motion,
   which site/engine/motion.js sets, and reduced motion removes all of it. */

.kp-sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* skip link: off-screen until focused */
.kp-skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  background: var(--skin-bg, #ffffff);
  color: var(--skin-fg, #1a1a1a);
  border: 2px solid var(--skin-accent, #3d5a80);
}
.kp-skip:focus { left: 8px; top: 8px; }

/* top bar: a fixed height, so the strip and the cart button never move the page */
.kp-top { min-height: 60px; }
.kp-strip { flex: 1 1 auto; min-width: 0; min-height: 3em; }
.kp-cart-button { flex: none; white-space: nowrap; }
.kp-strip-batch { font-weight: 700; }

/* hide what only a live drop has, in the Sold out and Locked views */
main[data-state="soldout"] [data-live-only],
main[data-state="locked"] [data-live-only] { display: none !important; }

/* the buy pad */
.kp-choice { margin: 0 0 12px; padding: 0; border: 0; display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.kp-choice-item { position: relative; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 8px 14px; border: 2px solid var(--skin-border, #c8c8c8); border-radius: var(--skin-radius, 4px); background: var(--skin-bg, #ffffff); cursor: pointer; }
.kp-choice-item input { position: absolute; top: -2px; left: -2px; width: calc(100% + 4px); height: calc(100% + 4px); margin: 0; opacity: 0; cursor: pointer; }
.kp-choice-item:has(input:checked) { background: var(--skin-accent, #3d5a80); color: var(--skin-accent-fg, #ffffff); border-color: var(--skin-accent, #3d5a80); font-weight: 700; }
.kp-choice-item:has(input:focus-visible) { outline: 3px solid var(--skin-accent, #3d5a80); outline-offset: 2px; }

.kp-size[aria-pressed="true"] { background: var(--skin-accent, #3d5a80); color: var(--skin-accent-fg, #ffffff); border-color: var(--skin-accent, #3d5a80); font-weight: 700; }
.kp-size[data-soldout="true"] { text-decoration: line-through; color: var(--skin-muted, #5f5f5f); border-style: dashed; cursor: not-allowed; }
.kp-size-group[data-needs-size="true"] { outline: 3px solid var(--skin-danger, #a4161a); outline-offset: 4px; }
.kp-size-group[data-needs-size="true"] h3 { color: var(--skin-danger, #a4161a); }

.kp-qty { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0 0 12px; }
.kp-qty-label { font-weight: 600; }
.kp-stepper { display: inline-flex; align-items: center; gap: 4px; }
.kp-step { min-width: 44px; min-height: 44px; padding: 0; font: inherit; font-size: 1.25rem; line-height: 1; color: var(--skin-fg, #1a1a1a); background: var(--skin-surface, #f2f2f2); border: 2px solid var(--skin-border, #c8c8c8); border-radius: var(--skin-radius, 4px); cursor: pointer; }
.kp-step[aria-disabled="true"] { opacity: 0.45; cursor: default; }
.kp-qty-value { display: inline-block; min-width: 2ch; text-align: center; font-weight: 700; }

.kp-counter { min-height: 1.5em; margin: 0 0 12px; font-weight: 700; }
.kp-country { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0 0 12px; }
.kp-country label { font-weight: 600; }
.kp-select, .kp-input { min-height: 44px; max-width: 100%; padding: 8px 12px; font: inherit; color: var(--skin-fg, #1a1a1a); background: var(--skin-bg, #ffffff); border: 2px solid var(--skin-border, #c8c8c8); border-radius: var(--skin-radius, 4px); }
.kp-input { width: 100%; }

.kp-summary { margin: 0 0 8px; padding: 0; }
.kp-summary-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; padding-block: 4px; }
.kp-summary-row dt { font-weight: 600; }
.kp-summary-row dd { margin: 0; }
.kp-summary-row[data-row="total"] { border-top: 2px solid var(--skin-border, #c8c8c8); font-weight: 700; }
.kp-duty { margin: 0 0 8px; min-height: 3em; }
.kp-dispatch { min-height: 1.5em; margin: 0 0 8px; font-weight: 600; }
.kp-allfinal { margin: 0 0 12px; color: var(--skin-muted, #5f5f5f); }
.kp-add, .kp-checkout, .kp-retry { width: 100%; font-weight: 700; white-space: nowrap; }
.kp-trust { margin: 10px 0 0; font-weight: 600; }
.kp-trust + .kp-beside { margin-top: 4px; }
.kp-retry { margin-top: 8px; }

.kp-message { min-height: 1.5em; margin: 8px 0 0; font-weight: 600; }
.kp-message[data-tone="error"] { color: var(--skin-danger, #a4161a); }
.kp-message[data-tone="info"] { color: var(--skin-fg, #1a1a1a); }

/* the stamp (Sold out, NOTED): a plain bordered block here; a skin gives it character and motion.js lands it (see the Motion kit section) */
.kp-stamp { display: inline-block; margin: 0 0 12px; padding: 4px 16px; font-family: var(--skin-font-display, inherit); font-size: 1.75rem; font-weight: 700; letter-spacing: 0.08em; border: 4px solid var(--skin-danger, #a4161a); color: var(--skin-danger, #a4161a); border-radius: var(--skin-radius, 4px); transform: rotate(var(--skin-stamp-rotate, -3deg)); }
.kp-stamp[data-stamp="noted"] { border-color: var(--skin-accent, #3d5a80); color: var(--skin-accent, #3d5a80); }

/* Sold out and Locked views */
.kp-state-view { margin: 0 0 16px; }
.kp-state-line { font-weight: 600; }
.kp-state-link a, .kp-live-link { display: inline-flex; align-items: center; min-height: 44px; }

/* email forms */
.kp-signup { display: grid; gap: 8px; margin: 8px 0 0; max-width: 28rem; }
.kp-label { font-weight: 600; }
.kp-signup-consent { margin: 0; color: var(--skin-muted, #5f5f5f); font-size: 0.875rem; }
.kp-signup[data-invalid="true"] .kp-input { border-color: var(--skin-danger, #a4161a); }
.kp-signup .kp-message { margin: 0; }
.kp-trap { position: absolute; left: -9999px; top: 0; width: 44px; height: 44px; opacity: 0; overflow: hidden; }
.kp-trap input { width: 44px; height: 44px; }
.kp-locked-card [data-signup-open][aria-expanded="true"] { border-style: dashed; }
.kp-locked-card .kp-stamp { font-size: 1.25rem; margin: 8px 0 0; }

/* the return view */
.kp-return { margin: 0 0 16px; padding: 16px; background: var(--skin-surface, #f2f2f2); border: 2px solid var(--skin-border, #c8c8c8); border-radius: var(--skin-radius, 4px); }
.kp-return[data-kind="notcompleted"], .kp-return[data-kind="refunded"], .kp-return[data-kind="notfound"] { border-color: var(--skin-danger, #a4161a); }
.kp-return[data-kind="confirmed"] { border-color: var(--skin-accent, #3d5a80); }
.kp-return-main { font-size: 1.25rem; font-weight: 700; }
.kp-video-options { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 8px; }
.kp-video-title { font-weight: 700; margin-bottom: 4px; }

/* the sticky bar */
.kp-sticky-bar { display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px; background: var(--skin-bg, #ffffff); border-top: 2px solid var(--skin-border, #c8c8c8); }
.kp-sticky-bar[hidden] { display: none !important; }
.kp-sticky-buy { flex: 1 1 0; min-width: 0; font-weight: 700; white-space: nowrap; }
html.kp-has-bar { scroll-padding-bottom: 80px; }
html.kp-has-bar body { padding-bottom: 72px; }
.kp-top-link { margin: 0; padding: 0 16px 16px; max-width: 40rem; margin-inline: auto; }

/* overlays: the scrim, the cart and the size guide */
.kp-scrim { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.5); }
.kp-cart, .kp-modal { position: fixed; z-index: 30; overflow-y: auto; max-height: 100vh; max-height: 100dvh; background: var(--skin-bg, #ffffff); color: var(--skin-fg, #1a1a1a); border: 2px solid var(--skin-border, #c8c8c8); padding: 16px; overflow-wrap: anywhere; }
.kp-cart { top: 0; right: 0; bottom: 0; width: min(92%, 26rem); }
.kp-modal { top: 0; left: 0; right: 0; bottom: 0; margin: auto; width: min(100%, 30rem); height: fit-content; }
.kp-cart:focus, .kp-modal:focus { outline: none; }
.kp-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.kp-panel-head h2 { margin: 0; }

.kp-cart-lines { list-style: none; margin: 0 0 12px; padding: 0; }
.kp-cart-line { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding-block: 12px; border-bottom: 1px solid var(--skin-border, #c8c8c8); }
/* a skin's small picture of the shirt (cfg.productArt) sits first in the line */
.kp-cart-line[data-has-art] { grid-template-columns: 56px 1fr auto; align-items: center; }
.kp-line-art { width: 56px; height: 56px; object-fit: contain; }
.kp-cart-note { margin: 0 0 12px; font-weight: 600; }
.kp-line-main { display: grid; gap: 2px; min-width: 0; }
.kp-line-meta { color: var(--skin-muted, #5f5f5f); }
.kp-line-note { color: var(--skin-danger, #a4161a); font-weight: 600; }
.kp-line-price { font-weight: 700; text-align: right; }
.kp-line-controls { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.kp-cart-line[data-flag] .kp-line-name, .kp-cart-line[data-flag] .kp-line-price { text-decoration: line-through; }
.kp-cart-line[data-flag] { color: var(--skin-muted, #5f5f5f); }
.kp-cart-empty { font-weight: 600; }

.kp-table-wrap { overflow-x: auto; margin: 0 0 16px; }
.kp-table { width: 100%; border-collapse: collapse; }
.kp-table caption { text-align: left; font-weight: 700; padding-bottom: 4px; }
.kp-table th, .kp-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--skin-border, #c8c8c8); }

/* keep every overlay and form inside a 320 px screen */
.kp-pad, .kp-buy-controls, .kp-cart, .kp-modal, .kp-signup, .kp-return { max-width: 100%; }
@media (max-width: 360px) {
  .kp-cart, .kp-modal { padding: 12px; }
  .kp-choice-item { padding-inline: 10px; }
}

/* =====================================================================================
   Motion kit (U16). Contract: drops/skins/README.md, "Motion kit".
   Rules: animate transform and opacity only; nothing is hidden unless html.kp-motion is set
   by site/engine/motion.js (so a blocked or failed script hides nothing); the hero and the
   buy section never wait; reduced motion removes every animation (last block).
   Custom properties a skin may set (all optional, each with a fallback here):
   --skin-ink, --skin-shadow-offset, --skin-slap-duration, --skin-slap-ease, --skin-slap-scale,
   --skin-slap-rotate, --skin-stagger, --skin-stamp-rotate (and, read by motion.js,
   --skin-confetti-colors, --skin-confetti-shapes, --skin-marquee-speed).
   ===================================================================================== */

/* ---- hard-shadow press: a resting control has a solid ink shadow; a pressed one moves by the
   shadow's offset and loses it, like a physical key. A chosen chip rests pressed in. ---- */
.kp-button, .kp-cart-button, .kp-size, .kp-step, .kp-choice-item, .kp-good, .kp-locked-card, [data-press] {
  box-shadow: var(--skin-shadow-offset, 3px) var(--skin-shadow-offset, 3px) 0 0 var(--skin-ink, #1a1a1a);
}
:is(.kp-button, .kp-cart-button, .kp-size, .kp-step, .kp-choice-item, [data-press]):is(:disabled, [aria-disabled="true"]) { box-shadow: none; }
:is(.kp-button, .kp-cart-button, .kp-size, .kp-step, .kp-choice-item, [data-press]):active:not(:disabled):not([aria-disabled="true"]),
.kp-size[aria-pressed="true"],
.kp-choice-item:has(input:checked),
:is(.kp-good, .kp-locked-card):active:not(:has(:is(button, a, summary, input, select):active)) {
  transform: translate(var(--skin-shadow-offset, 3px), var(--skin-shadow-offset, 3px));
  box-shadow: none;
}
[data-press="off"] { box-shadow: none; transform: none; }
html.kp-motion :is(.kp-button, .kp-cart-button, .kp-size, .kp-step, .kp-choice-item, .kp-good, .kp-locked-card, [data-press]) { transition: transform 60ms linear; }

/* ---- sticker-slap reveal: below-the-fold units wait hidden, then slap in (oversized, rotated,
   settling with a back-out ease) staggered by --kp-i. States: pending, shown, done. ---- */
html.kp-motion main { overflow-x: clip; }
html.kp-motion [data-reveal] { --kp-rot: var(--skin-slap-rotate, -4deg); }
html.kp-motion [data-reveal]:nth-child(even) { --kp-rot: calc(var(--skin-slap-rotate, -4deg) * -0.75); }
html.kp-motion [data-reveal="pending"] {
  opacity: 0;
  transform: translateY(10px) scale(var(--skin-slap-scale, 1.3)) rotate(var(--kp-rot));
}
html.kp-motion [data-reveal="shown"] {
  animation: kp-slap var(--skin-slap-duration, 0.45s) var(--skin-slap-ease, cubic-bezier(0.34, 1.56, 0.64, 1)) calc(var(--kp-i, 0) * var(--skin-stagger, 45ms)) both;
}
@keyframes kp-slap {
  from { opacity: 0; transform: translateY(10px) scale(var(--skin-slap-scale, 1.3)) rotate(var(--kp-rot, -4deg)); }
  to { opacity: 1; transform: none; }
}
/* the same slap for a view the engine un-hides (Sold out view, return view, sign-up field): transform only, so its text is never hidden */
html.kp-motion [data-slapping="solid"] { --kp-rot: var(--skin-slap-rotate, -4deg); animation: kp-slap-solid 0.4s var(--skin-slap-ease, cubic-bezier(0.34, 1.56, 0.64, 1)) both; }
@keyframes kp-slap-solid {
  from { transform: scale(1.12) rotate(var(--kp-rot, -4deg)); }
  to { transform: none; }
}

/* a letter-split heading that is a reveal unit slaps in letter by letter instead of as one block: the heading itself never fades,
   each letter waits hidden and lands oversized in its turn (--kp-i), on the same back-out ease */
html.kp-motion [data-split-done][data-reveal="pending"] { opacity: 1; transform: none; }
html.kp-motion [data-split-done][data-reveal="shown"] { animation: none; }
html.kp-motion [data-split-done][data-reveal="pending"] .kp-letter { opacity: 0; }
html.kp-motion [data-split-done][data-reveal="shown"] .kp-letter {
  animation: kp-letter-slap var(--skin-slap-duration, 0.45s) var(--skin-slap-ease, cubic-bezier(0.34, 1.56, 0.64, 1)) calc(var(--kp-i, 0) * var(--skin-stagger, 45ms)) both;
}
@keyframes kp-letter-slap {
  from { opacity: 0; transform: translateY(-0.35em) scale(1.7) rotate(-12deg); }
  to { opacity: 1; transform: none; }
}

/* ---- letter-split headings: each letter is its own element (--kp-i index, --kp-r a steady
   random from -1 to 1, --kp-w word index) so a skin can colour, rotate and shadow it ---- */
.kp-split { display: inline; }
.kp-word { display: inline-block; white-space: nowrap; }
.kp-letter { display: inline-block; }

/* ---- marquee strips: a repeating line scrolling sideways, alternating direction, running only
   while in view. The template's line is aria-hidden, so none of this is announced. ---- */
html.kp-motion .kp-marquee-track { display: flex; width: max-content; animation: kp-marquee var(--kp-marquee-dur, 24s) linear infinite; }
html.kp-motion [data-marquee-dir="right"] .kp-marquee-track { animation-direction: reverse; }
html.kp-motion [data-marquee]:not([data-inview="true"]) .kp-marquee-track { animation-play-state: paused; }
.kp-marquee-group { display: inline-block; flex: none; white-space: nowrap; }
@keyframes kp-marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* ---- the stamp lands from about three times size, then the pad gives a short thud ---- */
html.kp-motion [data-stamp][data-landing="true"] { animation: kp-stamp-land 0.34s var(--skin-slap-ease, cubic-bezier(0.34, 1.56, 0.64, 1)) both; }
@keyframes kp-stamp-land {
  from { opacity: 0; transform: scale(3) rotate(calc(var(--skin-stamp-rotate, -3deg) * 4)); }
  to { opacity: 1; transform: scale(1) rotate(var(--skin-stamp-rotate, -3deg)); }
}
html.kp-motion [data-thud="true"] { animation: kp-thud 0.3s linear both; }
@keyframes kp-thud {
  0% { transform: translate(0, 0); }
  15% { transform: translate(0, 5px); }
  35% { transform: translate(-4px, -2px); }
  55% { transform: translate(3px, 1px); }
  75% { transform: translate(-2px, 0); }
  100% { transform: none; }
}

/* ---- field feedback: an invalid sign-up field shakes, an empty size group nudges (its
   highlight is the [data-needs-size] rule above and needs no motion) ---- */
html.kp-motion [data-shake="true"] { animation: kp-shake 0.36s linear both; }
@keyframes kp-shake {
  0%, 100% { transform: none; }
  15% { transform: translateX(-6px); }
  30% { transform: translateX(6px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}
html.kp-motion [data-shake="nudge"] { animation: kp-nudge 0.4s linear both; }
@keyframes kp-nudge {
  0%, 100% { transform: none; }
  30% { transform: translateX(-4px) rotate(-0.6deg); }
  60% { transform: translateX(4px) rotate(0.6deg); }
}

/* ---- the confetti canvas: one, fixed, above everything, never takes a tap ---- */
canvas[data-kp-confetti] { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

/* ---- the reel slot (site/engine/reel.js, drops/skins/README.md "The reel slot"): a reserved 9 by 16 box that holds the video (its
   poster shows until play starts), a play and pause control and, only for a reel with sound, a sound control. The box keeps its size
   whatever loads, so nothing below it moves. The controls are at least 56 px. A skin sets the colours, border and tilt. ---- */
.kp-reel { position: relative; overflow: hidden; }
.kp-reel-video { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; background: var(--skin-ink, #1a1a1a); }
.kp-reel-toggle, .kp-reel-sound { position: absolute; bottom: 12px; z-index: 2; display: grid; place-items: center; min-width: 56px; min-height: 56px; margin: 0; padding: 0; background: var(--skin-surface, #f2f2f2); color: var(--skin-fg, #1a1a1a); border: 3px solid var(--skin-ink, #1a1a1a); border-radius: var(--skin-radius, 0); cursor: pointer; }
.kp-reel-toggle { left: 12px; }
.kp-reel-sound { right: 12px; }
.kp-reel-toggle[hidden], .kp-reel-sound[hidden] { display: none; }
.kp-reel-icon { display: block; box-sizing: border-box; width: 0; height: 0; border-style: solid; border-width: 12px 0 12px 20px; border-color: transparent transparent transparent currentColor; margin-left: 4px; }
.kp-reel[data-state="playing"] .kp-reel-toggle .kp-reel-icon { width: 20px; height: 24px; margin: 0; border-width: 0 7px; border-color: currentColor; }
.kp-reel-sound .kp-reel-icon { position: relative; width: 12px; height: 14px; margin: 0 10px 0 0; border: 0; background: currentColor; }
.kp-reel-sound .kp-reel-icon::before { content: ""; position: absolute; left: 12px; top: -7px; border-style: solid; border-width: 14px 14px 14px 0; border-color: transparent currentColor transparent transparent; }
.kp-reel-sound[aria-pressed="false"] .kp-reel-icon::after { content: ""; position: absolute; left: -6px; top: 5px; width: 34px; height: 4px; background: var(--skin-danger, #a80c3f); border: 1px solid var(--skin-surface, #f2f2f2); transform: rotate(-45deg); }

/* ---- reduced motion: every animation and transition is removed, everything is visible at
   once, and states still show through text and colour (the stamp is a plain stamp) ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  html.kp-motion [data-reveal="pending"] { opacity: 1; transform: none; }
  .kp-marquee { white-space: normal; }
}
