/* ==========================================================================
   Thermal receipt
   - Paper: crumpled-paper PNG (has transparent curled corners, so the
     shadow is a drop-shadow that follows the paper's shape).
   - Ink: mix-blend-mode: multiply so print picks up the paper's creases.
   - Per-line + per-character jitter, fade and smear come from custom
     properties written by receipt.js (the CSS falls back gracefully
     without it).
   ========================================================================== */

.hybrid-body .rental-receipt {
    /* --- tweakables ------------------------------------------------------ */
    --receipt-paper: url(/assets/receipt-paper.png); /* live site: /assets/receipt-paper.png */
    --thermal-ink: #24202b;        /* fresh thermal black (slightly violet) */
    --thermal-ink-faded: #6b6573;  /* worn / under-heated print */
    --stamp-ink: #c3262e;
    /* -------------------------------------------------------------------- */

    position: relative;
    isolation: isolate;
    width: 100%;
    min-width: 0;
    max-width: 440px;
    margin: 0 auto;
    border: 0;
    box-shadow: none;
    padding: clamp(32px, 7vw, 44px) clamp(22px, 7vw, 40px) clamp(34px, 7vw, 46px);
    background: var(--receipt-paper) center / 100% 100% no-repeat;
    color: var(--thermal-ink);
    font-family: 'Courier New', Courier, monospace;
    font-size: clamp(14px, 2vw, 20px);
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: .02em;
    text-transform: uppercase;
    /* shadow follows the paper's alpha (curled corners) */
    filter: drop-shadow(0 18px 22px #0007) drop-shadow(0 2px 3px #0004);
    -webkit-font-smoothing: antialiased;
}

/* ---- printed rows ------------------------------------------------------- */

.hybrid-body .rental-receipt > :not(.receipt-stamp) {
    position: relative;
    mix-blend-mode: multiply;
    color: color-mix(in srgb, var(--thermal-ink) calc(var(--line-ink, 1) * 100%), var(--thermal-ink-faded));
    opacity: var(--line-opacity, 1);
    /* paper-feed wobble: each printed row lands slightly off */
    transform:
        translate(var(--line-dx, 0px), var(--line-dy, 0px))
        rotate(var(--line-rot, 0deg))
        skewX(var(--line-skew, 0deg));
    transform-origin: 0 50%;
    /* uneven print-head heat: faint vertical columns of weaker print */
    -webkit-mask-image:
        repeating-linear-gradient(90deg, #000 0 37px, #000b 41px, #000 46px 83px),
        repeating-linear-gradient(90deg, #000 0 121px, #0009 126px, #000 133px 211px),
        linear-gradient(90deg, #000 70%, #000c);
    -webkit-mask-composite: source-in;
    mask-image:
        repeating-linear-gradient(90deg, #000 0 37px, #000b 41px, #000 46px 83px),
        repeating-linear-gradient(90deg, #000 0 121px, #0009 126px, #000 133px 211px),
        linear-gradient(90deg, #000 70%, #000c);
    mask-composite: intersect;
}

/* fallback variation for when receipt.js isn't loaded */
.hybrid-body .rental-receipt > :nth-child(2n)   { --line-dx: .6px;  --line-rot: -.25deg; --line-ink: .85; }
.hybrid-body .rental-receipt > :nth-child(3n)   { --line-dx: -.8px; --line-rot: .3deg;   --line-ink: .7;  }
.hybrid-body .rental-receipt > :nth-child(5n+1) { --line-dy: .5px;  --line-skew: -.4deg; --line-ink: .92; }

/* smear / ink-bleed filter (injected by receipt.js) */
.hybrid-body .rental-receipt.is-thermal > :not(.receipt-stamp)                 { filter: url(#msp-thermal-print-a); }
.hybrid-body .rental-receipt.is-thermal > :not(.receipt-stamp)[data-print="b"] { filter: url(#msp-thermal-print-b); }
.hybrid-body .rental-receipt.is-thermal > :not(.receipt-stamp)[data-print="c"] { filter: url(#msp-thermal-print-c); }

.hybrid-body .rental-receipt .receipt-heading {
    text-align: center;
    font-size: 1.05em;
    line-height: 1.2;
    letter-spacing: .06em;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 2px dashed currentColor;
}

.hybrid-body .rental-receipt .receipt-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin: 0;
    padding: 3px 0;
}
.hybrid-body .rental-receipt .receipt-line > span   { font-weight: 400; }
.hybrid-body .rental-receipt .receipt-line > span:not(.thermal-sr) { flex-shrink: 0; white-space: nowrap; }
.hybrid-body .rental-receipt .receipt-line > strong { font-weight: 700; text-align: right; min-width: 0; max-width: 70%; overflow-wrap: anywhere; }

/* reverse-printed block, like a thermal "TOTAL" highlight */
.hybrid-body .rental-receipt .nomination-chip {
    background: var(--thermal-ink);
    color: #ece9e4;
    font-size: inherit;
    border: 0;
    padding: 0 6px;
    box-shadow: 0 0 .6px .3px var(--thermal-ink); /* soft edge of a heated block */
}
.hybrid-body .rental-receipt .nomination-chip .thermal-char,
.hybrid-body .rental-receipt .nomination-chip:not(:has(.thermal-char)) {
    color: #ece9e4;
}

.hybrid-body .rental-receipt .receipt-thanks {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 2px dashed currentColor;
    text-align: center;
    font-size: .8em;
    font-weight: 400;
    letter-spacing: .04em;
}

/* ---- per-character variation (spans created by receipt.js) ---------------- */

.hybrid-body .rental-receipt .thermal-word {
    display: inline-block;
    white-space: normal;
    max-width: 100%;
}

.hybrid-body .rental-receipt .thermal-char {
    display: inline-block;
    opacity: var(--o, 1);
    transform:
        translate(var(--dx, 0px), var(--dy, 0px))
        rotate(var(--r, 0deg))
        scaleX(var(--sx, 1));
    /* horizontal smear + occasional double strike from paper slip */
    text-shadow:
        var(--smear, 0px) 0 var(--smear-softness, 0px) color-mix(in srgb, currentColor 45%, transparent),
        var(--ghost, 0px) var(--ghost-y, 0px) .4px color-mix(in srgb, currentColor 30%, transparent);
    filter: blur(var(--blur, 0px));
}

.hybrid-body .rental-receipt .thermal-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    user-select: none;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ---- rubber stamp (separate ink, stamped on top of the print) ------------- */

.hybrid-body .rental-receipt .receipt-stamp {
    position: relative;
    display: table;
    inset: auto;
    margin: 16px auto 12px;
    z-index: 2;
    padding: 2px 10px;
    border: 3px solid currentColor;
    border-radius: 4px;
    color: var(--stamp-ink);
    font-size: 1.15em;
    letter-spacing: .14em;
    transform: rotate(-11deg);
    mix-blend-mode: multiply;
    opacity: .82;
    pointer-events: none;
}
.hybrid-body .rental-receipt.is-thermal .receipt-stamp { filter: url(#msp-thermal-stamp); }

@media (prefers-reduced-motion: reduce) {
    .hybrid-body .rental-receipt * { transition: none !important; animation: none !important; }
}

/* A vote receipt belongs to the verified results area, below its percentages. */
.results-receipt { margin-top: 30px; padding-top: 24px; border-top: 1px solid #ffffff25; }
.results-receipt > h4 { text-align: center; margin: 0 0 20px; }
