/*
 * Ticket: a solid strip across the top names the kind, the title stands
 * centred beneath it like the event on an admission ticket, the text fills
 * the ticket, and the figures ride on a tinted stub torn off along a
 * perforation that is punched at either end. On a wide card the stub is the
 * ticket's right end and the perforation runs down.
 */

.ticket-card {
    --ticket-stub-height: 17cqh;
    --ticket-hole: 2.6mm;
    --ticket-tear-colour: color-mix(in srgb, var(--card-accent-second) 70%, transparent);
}

/* The sheet holds the ticket and its stub; it is what turns on a wide card,
   since a card cannot query its own size. */
.ticket-sheet {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.ticket-leaf {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.ticket-strip {
    flex: none;
    display: flex;
    justify-content: center;
    padding: 0.3em 1em 0.35em;
    color: var(--card-surface);
    background: var(--card-accent-second);
}

.ticket-strip .print-card-type {
    margin-bottom: 0;
    color: inherit;
}

.ticket-card .print-card-header {
    margin-top: 1.4mm;
    text-align: center;
}

.ticket-card .print-card-subline {
    justify-content: center;
}

.ticket-card .print-card-body {
    margin-top: 1.6mm;
}

/* The stub is a fixed share of the card so the tear falls at the same place
   on every card of a sheet; its inner padding keeps the figures clear of the
   punched holes. */
.ticket-card .print-card-figures {
    height: var(--ticket-stub-height);
    margin-top: 1.6mm;
    padding: 1.4mm 3.6mm 0.4mm;
}

.ticket-card .ticket-tear {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--card-padding-bottom) + var(--ticket-stub-height));
    background: color-mix(in srgb, var(--card-accent-second) 9%, transparent);
    border-top: 0.35mm dashed var(--ticket-tear-colour);
}

.ticket-tear::before,
.ticket-tear::after {
    content: "";
    position: absolute;
    top: calc(-0.5 * var(--ticket-hole) - 0.175mm);
    width: var(--ticket-hole);
    height: var(--ticket-hole);
    border-radius: 50%;
    background: var(--sheet-paper, #ffffff);
    box-shadow: inset 0 0 0 0.2mm var(--ticket-tear-colour);
}

.ticket-tear::before {
    left: 0.8mm;
}

.ticket-tear::after {
    right: 0.8mm;
}

/* The fields share one label column, so the values stand in a column of
   their own. */
.ticket-fields {
    display: grid;
    grid-template-columns: fit-content(42%) minmax(0, 1fr);
    gap: 0.28em 0.6em;
    width: 100%;
    margin: 0;
}

.ticket-field {
    display: contents;
}

.ticket-field-label {
    align-self: baseline;
    padding: 0.05em 0.55em 0.1em;
    font-family: var(--card-label-font);
    font-size: 0.6em;
    line-height: 1.25;
    letter-spacing: var(--card-label-spacing);
    text-transform: var(--card-label-transform);
    overflow-wrap: break-word;
    hyphens: auto;
    color: var(--card-surface);
    background: var(--card-accent-second);
    border-radius: 0.3mm;
}

.ticket-field-value {
    align-self: baseline;
    min-width: 0;
    margin: 0;
    font-size: 0.82em;
    line-height: 1.22;
    overflow-wrap: break-word;
    hyphens: auto;
    color: var(--card-ink);
}

@container card (orientation: landscape) {
    .ticket-sheet {
        flex-direction: row;
    }

    .ticket-leaf {
        min-width: 0;
        padding-right: 2mm;
    }

    .ticket-card .print-card-figures {
        flex: 0 0 var(--figures-column-width);
        height: auto;
        margin-top: 0;
        padding: 0.4mm 0.4mm 0.4mm 3mm;
        justify-content: flex-start;
    }

    .ticket-card .ticket-tear {
        left: auto;
        top: 0;
        width: calc(var(--card-padding-side) + var(--figures-column-width));
        height: auto;
        border-top: none;
        border-left: 0.35mm dashed var(--ticket-tear-colour);
    }

    .ticket-tear::before,
    .ticket-tear::after {
        top: auto;
        right: auto;
        left: calc(-0.5 * var(--ticket-hole) - 0.175mm);
    }

    .ticket-tear::before {
        top: 0.8mm;
    }

    .ticket-tear::after {
        bottom: 0.8mm;
    }

    .ticket-fields {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.15em;
    }

    .ticket-field-label {
        justify-self: start;
    }

    .ticket-field-value {
        margin-bottom: 0.35em;
    }
}
