/* keeps the calendar in the page until the paper has gone back */
@property --hold {
  syntax: "<number>";
  inherits: false;
  initial-value: 0;
}

.lr {
  --ink: #2c3039;
  --thin: rgb(44 48 57 / 0.36);
  --teeth: 8px;
  /* the slip's emblem, above the line the frame crops at once the calendar is out */
  --crest: 138px;
  /* the rest of the slip, from that line to its lower edge */
  --body: 246px;
  /* how far the slip rides up as the calendar feeds: from the middle of the desk to that line */
  --ride: calc((540px - var(--crest) - var(--body)) / 2 + var(--crest));
  position: absolute;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  background-color: #170f0a;
  background-size: 540px 540px;
}
.lr *,
.lr-feed * {
  box-sizing: border-box;
}
.lr p,
.lr-feed p {
  margin: 0;
}
.lr-defs {
  position: absolute;
  width: 0;
  height: 0;
}

/* The paper rides up and the calendar feeds out, on transforms and a clip the
   compositor can animate on their own. These used to be driven by one number
   inherited down the whole slip, so every frame restyled — and repainted, and
   re-filtered — the calendar and its forty-two days along with it. */

/* receipt paper, 42 characters wide: a cool white with a faint sheen */
.lr-paper {
  position: relative;
  width: 355px;
  padding: 0 20px;
  color: var(--ink);
  font-family: "Inconsolata Variable", monospace;
  font-size: 15px;
  font-weight: 500;
  line-height: 19px;
  font-variant-numeric: tabular-nums lining-nums;
  text-transform: uppercase;
  -webkit-font-smoothing: antialiased;
}
/* the cutter's serrated edge */
.lr-paper::after,
.lr-cut {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: var(--teeth);
  margin-top: -0.5px;
  background:
    linear-gradient(135deg, var(--end) 50%, #0000 50%) 0 0 / 7.1px 100% repeat-x,
    linear-gradient(225deg, var(--end) 50%, #0000 50%) 0 0 / 7.1px 100% repeat-x;
}
.lr-cut {
  top: auto;
  bottom: 100%;
  margin: 0 0 -0.5px;
  background:
    linear-gradient(45deg, #fbfdff 50%, #0000 50%) 0 0 / 7.1px 100% repeat-x,
    linear-gradient(315deg, #fbfdff 50%, #0000 50%) 0 0 / 7.1px 100% repeat-x;
}
/* the print: a grey-black that never reaches full density, soft at the edges, thinner in faint bands
   where the paper slipped and towards the right margin */
.lr-print {
  filter: url(#lr-inkfade);
  mask-image:
    linear-gradient(to right, #000 56%, rgb(0 0 0 / 0.74) 100%),
    repeating-linear-gradient(
      to bottom,
      #000 0 29px,
      rgb(0 0 0 / 0.74) 29px 31px,
      #000 31px 52px,
      rgb(0 0 0 / 0.84) 52px 53px,
      #000 53px 87px,
      rgb(0 0 0 / 0.7) 87px 88.5px,
      #000 88.5px 113px
    );
  mask-composite: intersect;
}

/* the slip as printed. It lies in the middle of the desk; the lamp is up and to the left. */
.lr-slip {
  --end: #eef2f7;
  position: absolute;
  left: 92px;
  top: calc(-1 * var(--crest));
  padding-top: 14px;
  padding-bottom: 13px;
  background:
    linear-gradient(104deg, #fff0 34%, rgb(255 255 255 / 0.7) 47%, #fff0 61%),
    linear-gradient(to bottom, #0000 30%, rgb(52 66 92 / 0.05) 46%, #0000 60%, rgb(255 255 255 / 0.4) 76%, #0000 92%),
    linear-gradient(to bottom, #fbfdff, var(--end));
  /* the paper is a rectangle, so its shadow is a box shadow: two drop-shadow
     filters meant two full blur passes over the paper on every frame of the
     ride and the feed. The radii double the filters' deviations. */
  box-shadow:
    1px 2px 3px rgb(0 0 0 / 0.5),
    7px 12px 28px rgb(0 0 0 / 0.55);
  transform: translateY(var(--ride));
  transition: transform 0.52s cubic-bezier(0.33, 0, 0.3, 1);
  will-change: transform;
}
.lr-roll[data-open] .lr-slip {
  transform: translateY(0);
}
/* the last of the paper lifts off the desk a little */
.lr-curl {
  position: absolute;
  inset: auto 0 0;
  height: 34px;
  background: linear-gradient(to top, rgb(52 66 92 / 0.12), rgb(255 255 255 / 0.5) 34%, rgb(255 255 255 / 0) 100%);
  opacity: 1;
  transition: opacity 0.52s cubic-bezier(0.33, 0, 0.3, 1);
  pointer-events: none;
}
.lr-roll[data-open] .lr-curl {
  opacity: 0;
}
.lr-roll[data-closed] .lr-curl {
  transition-duration: 0.38s;
}

.lr-emblem {
  display: block;
  margin: 0 auto 20px;
}
.lr-name {
  height: 26px;
  font-size: 19px;
  font-weight: 800;
  font-stretch: 150%;
  line-height: 24px;
  text-align: center;
}
.lr-row {
  display: flex;
  justify-content: space-between;
  white-space: nowrap;
}
.lr-row b {
  font-weight: 800;
}
.lr-author {
  text-transform: none;
}
.lr-rule {
  height: 0;
  margin: 6px 0;
  border: 0;
  border-top: 1.5px dashed var(--ink);
}
.lr-loan + .lr-loan {
  margin-top: 7px;
}
/* a renewed loan keeps its old due date, struck out */
.lr-due[data-renewed] {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

/* the field: a printed form line, its value in a ruled box at the end of a dotted leader */
.lr-field {
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 1ch;
  width: 100%;
  height: 28px;
  margin-top: 7px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}
.lr-leader {
  flex: 1;
  height: 2px;
  margin-top: 8px;
  background: repeating-linear-gradient(to left, var(--ink) 0 2px, #0000 2px 7.5px);
}
.lr-value {
  display: flex;
  align-items: center;
  gap: 1ch;
  height: 28px;
  padding: 0 1ch;
  box-shadow: inset 0 0 0 1.5px var(--ink);
  transition: box-shadow 0.1s linear;
}
.lr-caret {
  width: 0;
  height: 0;
  border: 5px solid #0000;
  border-top: 7px solid currentColor;
  border-bottom: 0;
  transition: rotate 0.2s linear;
}
.lr-field[data-open] .lr-caret {
  rotate: 180deg;
}
.lr-field:hover .lr-value {
  box-shadow: inset 0 0 0 2.5px var(--ink);
}
.lr-field:focus-visible .lr-value {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.lr-edge {
  position: absolute;
  left: 92px;
  top: var(--body);
  width: 355px;
  height: 0;
}

/* more paper: the calendar feeds out from under the slip's lower edge while the slip rides up the
   desk. The popup is the window the new paper is seen through. */
.lr-feed {
  width: var(--anchor-width);
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  overflow: visible;
  background: none;
  clip-path: inset(var(--ride) -60px -90px -60px);
  /* --hold keeps the calendar in the page until the paper has gone back */
  transition:
    clip-path 0.52s cubic-bezier(0.33, 0, 0.3, 1),
    --hold 0.52s linear;
}
/* The popup mounts already open, so its paper arrives on a keyframe animation:
   a transition would have nothing to start from. Same values and easing as the
   slip's ride. */
@keyframes lr-feed-in {
  from { clip-path: inset(var(--ride) -60px -90px -60px); }
  to { clip-path: inset(0 -60px -90px -60px); }
}
@keyframes lr-feed-out {
  from { clip-path: inset(0 -60px -90px -60px); }
  to { clip-path: inset(var(--ride) -60px -90px -60px); }
}
@keyframes lr-cal-in {
  from { transform: translateY(calc(var(--ride) - 100%)); }
  to { transform: translateY(0); }
}
@keyframes lr-cal-out {
  from { transform: translateY(0); }
  to { transform: translateY(calc(var(--ride) - 100%)); }
}
.lr-roll[data-open] .lr-cal {
  transform: translateY(0);
  animation: lr-cal-in 0.52s cubic-bezier(0.33, 0, 0.3, 1) both;
}
.lr-roll[data-open] .lr-feed {
  clip-path: inset(0 -60px -90px -60px);
  animation: lr-feed-in 0.52s cubic-bezier(0.33, 0, 0.3, 1) both;
}
.lr-roll[data-closed] .lr-slip {
  transition-duration: 0.38s;
}
.lr-feed[data-ending-style] {
  --hold: 1;
  animation: lr-feed-out 0.4s cubic-bezier(0.33, 0, 0.3, 1) both;
}
.lr-feed[data-ending-style] .lr-cal {
  animation: lr-cal-out 0.4s cubic-bezier(0.33, 0, 0.3, 1) both;
}
.lr-cal {
  --end: #e5eaf1;
  padding-top: 1px;
  padding-bottom: 10px;
  background:
    linear-gradient(104deg, #fff0 30%, rgb(255 255 255 / 0.6) 45%, #fff0 60%),
    linear-gradient(to top, rgb(52 66 92 / 0.12), rgb(255 255 255 / 0.45) 26px, rgb(255 255 255 / 0) 64px),
    linear-gradient(to bottom, #eef2f7, var(--end));
  box-shadow:
    1px 2px 3px rgb(0 0 0 / 0.5),
    7px 13px 30px rgb(0 0 0 / 0.58);
  transform: translateY(calc(var(--ride) - 100%));
  transition: transform 0.52s cubic-bezier(0.33, 0, 0.3, 1);
  will-change: transform;
}
/* the dotted line the kiosk prints to tear along */
.lr-tear {
  height: 0;
  margin: 0 -20px 5px;
  border: 0;
  border-top: 2px dotted rgb(44 48 57 / 0.7);
}

.lr-head {
  display: flex;
  align-items: center;
  height: 28px;
}
.lr-month {
  flex: 1;
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  font-stretch: 150%;
  line-height: 28px;
}
.lr-nav {
  all: unset;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  width: 30px;
  height: 24px;
  margin-left: 6px;
  cursor: pointer;
}
.lr-arrow {
  width: 0;
  height: 0;
  border: 6px solid #0000;
}
.lr-arrow[data-to="previous"] {
  border-right: 9px solid currentColor;
  border-left: 0;
}
.lr-arrow[data-to="next"] {
  border-left: 9px solid currentColor;
  border-right: 0;
}
.lr-nav:hover {
  box-shadow: inset 0 0 0 1.5px var(--ink);
}
.lr-nav:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}
.lr-nav[data-disabled] {
  color: var(--thin);
  box-shadow: none;
  cursor: default;
}

/* seven columns of six characters */
.lr-grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.lr-grid th,
.lr-grid td {
  padding: 0;
}
.lr-weekday {
  height: 20px;
  font-size: 15px;
  font-weight: 500;
  line-height: 19px;
  text-align: center;
  vertical-align: top;
  border-bottom: 1.5px solid var(--ink);
}
.lr-grid tbody tr:first-child .lr-day {
  padding-top: 2px;
  height: 27px;
}
.lr-day {
  height: 25px;
  text-align: center;
  outline: none;
  cursor: pointer;
}
.lr-date {
  position: relative;
  display: inline-block;
  width: 5ch;
  height: 22px;
  font-size: 17px;
  font-weight: 700;
  line-height: 19px;
  vertical-align: middle;
}
/* today stands in printed brackets */
.lr-day[data-today] .lr-date::before,
.lr-day[data-today] .lr-date::after {
  position: absolute;
  top: -1px;
  font-weight: 500;
}
.lr-day[data-today] .lr-date::before {
  content: "[";
  left: 0.3ch;
}
.lr-day[data-today] .lr-date::after {
  content: "]";
  right: 0.3ch;
}
/* days that can't be chosen print thin: before today and past the renewal limit */
.lr-day[data-disabled] {
  cursor: default;
}
.lr-day[data-disabled] .lr-date {
  color: var(--thin);
  font-weight: 500;
}
/* days the library is closed are struck out */
.lr-day[data-unavailable] .lr-date {
  background: linear-gradient(var(--ink), var(--ink)) 50% 9px / 3.4ch 1.5px no-repeat;
  color: rgb(44 48 57 / 0.56);
}
.lr-day:not([data-disabled]):hover .lr-date {
  box-shadow: inset 0 0 0 1.5px var(--ink);
}
/* the chosen date is printed in reverse */
.lr-day[data-selected] .lr-date {
  background: var(--ink);
  color: #f4f7fb;
}
.lr-day:focus-visible .lr-date {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.lr-note {
  margin-top: 7px;
  padding-top: 5px;
  border-top: 1.5px dashed var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  /* the paper jumps straight to its end state: no ride, no feed, no fade.
     The selectors match the state-specific transitions and animations above,
     which would otherwise outrank a bare .lr-slip / .lr-cal rule. */
  .lr-roll,
  .lr-roll[data-closed],
  .lr-slip,
  .lr-curl,
  .lr-cal,
  .lr-feed,
  .lr-feed[data-ending-style],
  .lr-caret {
    transition: none;
  }
  .lr-roll[data-open] .lr-slip,
  .lr-roll[data-open] .lr-curl,
  .lr-roll[data-open] .lr-cal,
  .lr-roll[data-open] .lr-feed,
  .lr-feed[data-ending-style],
  .lr-feed[data-ending-style] .lr-cal {
    animation: none;
  }
}
