/* The penalties page's late-payment meter (data-explainer="pen-meter"): a tally counter of days late,
   a ruler marked at the penalty days with a break after the first 60, and a till receipt. */

.pm-panel { position: relative; background: var(--card); border: 1px solid var(--rule); box-shadow: 0 1px 0 var(--rule), 0 24px 44px -30px rgba(23, 32, 51, .5); padding: 16px 18px 18px; }

/* The bill */
.pm-inputs { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 10px 12px; }
.pm-inputs > p { grid-column: 1 / -1; margin: 0; font-size: 15px; color: var(--ink-2); }
.pm-inputs > p b { color: var(--ink); }
.pm-field { display: grid; gap: 4px; min-width: 0; }
.pm-field > span:first-child { font: 12px/1.3 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.pm-money { display: flex; align-items: stretch; border: 1px solid var(--rule); border-bottom: 2px solid var(--ink); background: var(--paper); }
.pm-money i { display: flex; align-items: center; padding: 0 2px 0 10px; font: 600 17px var(--mono); font-style: normal; color: var(--ink-3); }
.pm-money input { width: 100%; min-width: 0; height: 44px; padding: 0 10px 0 4px; border: 0; background: transparent; font: 600 19px/1 var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); }
.pm-money input:focus-visible { outline: none; }
.pm-money:focus-within { outline: 2px solid var(--link); outline-offset: 2px; }
.pm-money:has(input[aria-invalid="true"]) { border-color: var(--red); background: var(--red-wash); }
.pm-field select, .pm-field input[type="date"] { width: 100%; min-width: 0; height: 46px; padding: 0 30px 0 10px; border: 1px solid var(--rule); border-bottom: 2px solid var(--ink); border-radius: 0; background-color: var(--paper); font: 14px var(--sans); color: var(--ink); }
.pm-field select { -webkit-appearance: none; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%); background-position: right 16px top 50%, right 11px top 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.pm-field input[type="date"] { padding-right: 8px; font: 600 14px var(--mono); }
.pm-err { grid-column: 1 / -1; margin: 0; font-size: 14px; color: var(--red); }
.pm-err[hidden] { display: none; }

/* The counter: three drums of figures in a window, as on a hand tally. */
.pm-dial { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin: 18px 0 0; }
.pm-counter { display: inline-flex; flex-direction: column; gap: 5px; padding: 8px 10px 10px; background: var(--ink); color: var(--paper); }
.pm-label { font: 12px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: #C9CFDB; }
.pm-count { display: flex; gap: 3px; }
.pm-drum { display: block; width: 30px; height: 40px; overflow: hidden; background: #0F1626; box-shadow: inset 0 7px 6px -6px rgba(0, 0, 0, .9), inset 0 -7px 6px -6px rgba(0, 0, 0, .9); text-align: center; }
.pm-num { display: none; }
.pm-reel::before { content: "0 1 2 3 4 5 6 7 8 9"; }
.pm-reel { display: block; padding-top: 3px; font: 600 34px/1 var(--mono); font-variant-numeric: tabular-nums; color: #F4F1E8; transform: translateY(calc(var(--d) * -34px)); transition: transform 320ms var(--ease); word-spacing: 30px; white-space: normal; width: 30px; }
.pm-read { flex: 1 1 150px; min-width: 0; margin: 0; font-size: 15px; line-height: 1.45; color: var(--ink-2); }
.pm-read b { color: var(--ink); font-weight: 600; white-space: nowrap; }
.pm-dial .pm-paid { flex: 1 1 100%; grid-template-columns: auto minmax(0, 190px); align-items: center; gap: 10px; }
.pm-dial .pm-paid > span:first-child { white-space: nowrap; }

/* The ruler */
.pm-ruler { position: relative; margin: 20px 0 0; padding: 26px 8px 0 4px; outline: none; cursor: ew-resize; touch-action: pan-y; -webkit-user-select: none; user-select: none; }
.pm-ruler:focus-visible { outline: 2px solid var(--link); outline-offset: 4px; }
.pm-scale { position: relative; height: 30px; }
.pm-near, .pm-far { position: absolute; bottom: 0; height: 100%; border-bottom: 2px solid var(--ink); }
.pm-near { left: 0; width: 58%;
	background: repeating-linear-gradient(90deg, var(--ink) 0 1px, transparent 1px calc(100% / 12)) left bottom / 100% 15px no-repeat,
	            repeating-linear-gradient(90deg, var(--mute-line) 0 1px, transparent 1px calc(100% / 60)) left bottom / 100% 7px no-repeat; }
.pm-near::after { content: ""; position: absolute; right: 0; bottom: 0; width: 1px; height: 15px; background: var(--ink); }
/* The break in the ruler, drawn as a draughtsman would: two short slanted strokes. */
.pm-near::before { content: ""; position: absolute; left: 100%; bottom: -6px; width: 9%; height: 14px; background: linear-gradient(110deg, transparent 0 34%, var(--ink) 34% 40%, transparent 40% 58%, var(--ink) 58% 64%, transparent 64%); }
.pm-far { left: 63%; width: 37%; background: repeating-linear-gradient(90deg, var(--mute-line) 0 1px, transparent 1px calc(100% / 37)) left bottom / 100% 7px no-repeat; }
.pm-tick { position: absolute; left: var(--x); bottom: 0; width: 1px; height: 15px; background: var(--ink); }
.pm-zone { position: absolute; left: var(--x); width: var(--w); bottom: 2px; height: 5px; background: repeating-linear-gradient(135deg, rgba(179, 38, 30, .55) 0 1.5px, transparent 1.5px 5px); }
.pm-zone i { position: absolute; left: 0; top: 54px; font: 11px/1.2 var(--mono); font-style: normal; color: var(--red); white-space: nowrap; display: none; }
.pm-mark { position: absolute; left: var(--x); bottom: 0; width: 2px; height: calc(100% + 12px); margin-left: -1px; background: var(--red); }
.pm-mark b { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding: 1px 4px; background: var(--red); color: var(--card); font: 600 12px/1.3 var(--mono); white-space: nowrap; }
.pm-mark.pm-eased { background: repeating-linear-gradient(0deg, var(--mute-line) 0 3px, transparent 3px 6px); }
.pm-mark.pm-eased b { background: var(--card); color: var(--ink-3); border: 1px dashed var(--mute-line); text-decoration: line-through; }
.pm-mark.pm-cap { width: 1px; height: calc(100% + 4px); }
.pm-mark.pm-cap b { background: none; color: var(--red); padding: 0; transform: translateX(-100%); left: 2px; }
/* Time to pay: from the day you asked, the penalties are paused (interest is not). */
.pm-pause { position: absolute; left: var(--x); right: 0; top: -2px; bottom: 2px; border-left: 2px solid var(--ink); background: repeating-linear-gradient(45deg, rgba(23, 32, 51, .13) 0 1.5px, transparent 1.5px 6px); }
.pm-cursor { position: absolute; z-index: 2; left: var(--x); top: -26px; bottom: -22px; width: 2px; margin-left: -1px; background: var(--ink); pointer-events: none; }
.pm-cursor::before { content: ""; position: absolute; left: 50%; top: 0; width: 0; height: 0; transform: translateX(-50%); border: 6px solid transparent; border-top: 8px solid var(--ink); }
.pm-cursor::after { content: ""; position: absolute; left: 50%; bottom: -14px; width: 16px; height: 18px; transform: translateX(-50%); background: var(--card) repeating-linear-gradient(90deg, transparent 0 4px, var(--ink-3) 4px 5px, transparent 5px 7px) center / 9px 9px no-repeat; border: 2px solid var(--ink); }
.pm-ruler.pm-drag .pm-cursor::after, .pm-ruler:focus-visible .pm-cursor::after { background-color: var(--wash); }
.pm-labs { position: relative; height: 20px; margin-top: 5px; }
.pm-lab { position: absolute; left: var(--x); transform: translateX(-50%); font: 12px/1.4 var(--mono); color: var(--ink-3); }
.pm-lab:first-child { transform: none; }

.pm-lab.red { color: var(--red); font-weight: 600; }
.pm-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 18px 0 0; font: 13px/1.4 var(--mono); color: var(--ink-3); }
.pm-legend span::before { content: ""; display: inline-block; width: 18px; height: 6px; margin-right: 6px; vertical-align: 1px; }
.pm-legend .lz::before { background: repeating-linear-gradient(135deg, rgba(179, 38, 30, .55) 0 1.5px, transparent 1.5px 5px); }
.pm-legend .lm::before { width: 2px; height: 11px; background: var(--red); vertical-align: -1px; }
.pm-legend .lp::before { background: repeating-linear-gradient(45deg, rgba(23, 32, 51, .35) 0 1.5px, transparent 1.5px 5px); border-left: 2px solid var(--ink); height: 9px; vertical-align: -1px; }
.pm-legend [hidden] { display: none; }

/* Asking for time to pay */
.pm-plan { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 16px 0 0; font-size: 15px; color: var(--ink-2); }
.pm-plan:empty { display: none; }
.pm-check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.pm-check input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); }
.pm-on { display: inline-flex; align-items: center; gap: 8px; }
.pm-planday { width: 74px; height: 44px; padding: 0 8px; border: 1px solid var(--rule); border-bottom: 2px solid var(--ink); border-radius: 0; background: var(--paper); font: 600 15px var(--mono); color: var(--ink); }
.pm-planday:disabled { opacity: .5; }

/* The slip: a counterfoil. The stub on the left keeps the bill's dates; a perforated line, notched
   at both ends, divides it from the charges. Each charge is entered as the days pass its mark. */
.pm-print { --notch: var(--card); margin: 18px 0 8px; container: pmslip / inline-size; }
.pm-slip { position: relative; display: grid; grid-template-columns: 108px minmax(0, 1fr); background: var(--paper); border: 1px solid var(--rule); }
.pm-stub { position: relative; display: grid; align-content: start; gap: 12px; padding: 14px 12px; background: var(--wash-2); border-right: 2px dashed #C8C0AE; }
.pm-stub::before, .pm-stub::after { content: ""; position: absolute; right: -9px; width: 16px; height: 16px; border-radius: 50%; background: var(--notch); border: 1px solid var(--rule); }
.pm-stub::before { top: -9px; }
.pm-stub::after { bottom: -9px; }
.pm-stub p { margin: 0; display: grid; gap: 1px; }
.pm-stub span { font: 12px/1.3 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.pm-stub b { font: 600 14px/1.25 var(--mono); color: var(--ink); }
.pm-stub i { font: normal 600 13px/1.3 var(--mono); color: var(--red); }
.pm-receipt { width: 100%; border-collapse: collapse; font: 15px/1.35 var(--sans); }
.pm-receipt th, .pm-receipt td { padding: 9px 14px 8px 0; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
.pm-receipt th { padding-left: 16px; text-align: left; font-weight: 600; color: var(--ink); }
.pm-receipt th small { display: block; margin-top: 1px; font-weight: 400; font-size: 13px; line-height: 1.35; color: var(--ink-3); }
.pm-receipt td { text-align: right; font: 600 15px/1.35 var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pm-receipt tr.due th, .pm-receipt tr.due td { border-bottom: 2px solid var(--ink); }
.pm-receipt tr.wait th, .pm-receipt tr.wait td { color: var(--ink-4); font-weight: 400; }
.pm-receipt tr.wait th small { color: var(--ink-4); }
.pm-receipt tr.off td { color: var(--ink-3); font-weight: 400; }
.pm-receipt tr.on td { color: var(--red); }
.pm-receipt tr.on th::before { content: ""; float: left; width: 6px; height: 6px; margin: 8px 8px 0 -12px; background: var(--red); border-radius: 50%; }
.pm-receipt tr.total th, .pm-receipt tr.total td { padding-top: 11px; padding-bottom: 12px; border-top: 3px double var(--ink); border-bottom: 0; color: var(--ink); }
.pm-receipt tr.total td { font: 700 24px/1 var(--cond); letter-spacing: -.01em; }
.pm-ann { margin: 10px 0 8px; font-size: 14px; line-height: 1.45; color: var(--ink-2); font-family: var(--sans); }
.pm-ann b { font: 600 12px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--red); margin-right: 4px; }
/* Narrow: the stub becomes a band across the top, perforated along its foot. */
@container pmslip (max-width: 430px) {
	.pm-slip { grid-template-columns: minmax(0, 1fr); }
	.pm-stub { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 10px 12px 12px; border-right: 0; border-bottom: 2px dashed #C8C0AE; }
	.pm-stub::before, .pm-stub::after { top: auto; bottom: -9px; right: auto; }
	.pm-stub::before { left: -9px; }
	.pm-stub::after { right: -9px; }
	.pm-stub b { font-size: 13px; }
	.pm-receipt th { padding-left: 14px; }
	.pm-receipt th, .pm-receipt td { padding-right: 10px; }
}
@keyframes pm-print { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }
.pm-printed > * { animation: pm-print 420ms var(--ease) both; }

/* The worked examples' receipts, in the prose */
figure.pen-eg-receipt figcaption { margin: 0 0 8px; font: 12px/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
figure.pen-eg-receipt .pm-print { --notch: var(--paper); margin: 0 0 14px; max-width: 34em; }

@media (max-width: 560px) {
	.pm-panel { padding: 14px 12px 16px; }
	.pm-inputs { grid-template-columns: minmax(0, 1fr); }
	.pm-drum { width: 26px; height: 36px; }
	.pm-reel { font-size: 30px; transform: translateY(calc(var(--d) * -30px)); width: 26px; word-spacing: 26px; }
	.pm-dial .pm-paid { grid-template-columns: auto minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
	.pm-reel { transition: none; }
}
