/* papertooth: photos, postage, labels, bullet journal, progress */

/* lift anything off the page with a soft shadow (works with masked shapes too) */
.pt-lift { filter: drop-shadow(0 1px 1px rgba(0,0,0,.14)) drop-shadow(0 8px 9px rgba(0,0,0,.13)); }

/* photo: <figure class="pt-photo" data-mount="polaroid|corners|tape"><img alt="…"><figcaption>…</figcaption></figure> */
.pt-photo {
  --pt-rot: 0deg; --pt-photo-w: 240px;
  position: relative; display: inline-flex; flex-direction: column; margin: 0;
  width: min(var(--pt-photo-w), 100%); box-sizing: border-box;
  transform: rotate(calc(var(--pt-rot) * var(--pt-tilt)));
}
.pt-photo > :is(img, svg, .pt-photo__img) { display: block; width: 100%; height: auto; aspect-ratio: var(--pt-photo-ratio, 4 / 3); object-fit: cover; }
.pt-photo figcaption { font-family: var(--pt-font-hand); font-size: 22px; line-height: 24px; color: var(--pt-pen); }
/* instant print: thick white border, wider at the bottom for writing */
.pt-photo[data-mount="polaroid"] {
  padding: 12px 12px 10px; background: #fbfbf8;
  box-shadow: 0 1px 2px rgba(0,0,0,.14), 0 10px 18px -10px rgba(0,0,0,.35);
}
.pt-photo[data-mount="polaroid"] > :is(img, svg, .pt-photo__img) { aspect-ratio: var(--pt-photo-ratio, 1); box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.pt-photo[data-mount="polaroid"] figcaption { padding-top: 12px; min-height: 36px; text-align: center; }
/* black paper mounting corners */
.pt-photo[data-mount="corners"] { box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.pt-photo[data-mount="corners"] figcaption { padding-top: 10px; }
.pt-photo[data-mount="corners"]::after {
  --c: 22px;
  content: ""; position: absolute; left: -5px; right: -5px; top: -5px; height: calc(100% - var(--pt-cap, 0px) + 10px); pointer-events: none;
  background:
    linear-gradient(135deg, #26272b 0 50%, transparent 50%) 0 0 / var(--c) var(--c),
    linear-gradient(225deg, #26272b 0 50%, transparent 50%) 100% 0 / var(--c) var(--c),
    linear-gradient(315deg, #26272b 0 50%, transparent 50%) 100% 100% / var(--c) var(--c),
    linear-gradient(45deg,  #26272b 0 50%, transparent 50%) 0 100% / var(--c) var(--c);
  background-repeat: no-repeat;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.3));
}
.pt-photo[data-mount="corners"]:has(figcaption) { --pt-cap: 34px; }
.pt-photo .pt-tape { position: absolute; top: -14px; left: 50%; width: 96px; height: 26px; margin-left: -48px; }

/* postage stamp frame with perforated edges: wrap it in .pt-lift for a shadow */
.pt-postage {
  --pt-rot: 0deg; --pt-perf: 12px;
  position: relative; display: inline-block; padding: 10px; background: #fbfaf5; box-sizing: border-box;
  transform: rotate(calc(var(--pt-rot) * var(--pt-tilt)));
  -webkit-mask: radial-gradient(circle at center, #0000 3.6px, #000 4px) calc(var(--pt-perf) / -2) calc(var(--pt-perf) / -2) / var(--pt-perf) var(--pt-perf) round, linear-gradient(#000 0 0) content-box;
  mask: radial-gradient(circle at center, #0000 3.6px, #000 4px) calc(var(--pt-perf) / -2) calc(var(--pt-perf) / -2) / var(--pt-perf) var(--pt-perf) round, linear-gradient(#000 0 0) content-box;
}
.pt-postage > * { display: block; max-width: 100%; }
.pt-postage__value { position: absolute; right: 14px; bottom: 12px; font-family: var(--pt-font-type-head); font-size: 18px; line-height: 1; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.4); }

/* label tape: printed (a Japanese label printer: laminated tape, long margins, square cut)
   or embossed (Dymo-style: glossy vinyl, each letter punched and stress-whitened) */
.pt-label {
  --pt-rot: 0deg; --pt-label-bg: #fbfbf7; --pt-label-ink: #17181b;
  display: inline-block; padding: 1px 20px 0; border-radius: .5px;
  font-family: "Archivo Narrow", "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  font-stretch: condensed; font-weight: 500; font-size: 14px; line-height: 19px; letter-spacing: .01em;
  color: var(--pt-label-ink);
  background:
    /* the laminate: a hard bright edge and a faint sheen across the top third */
    linear-gradient(to bottom, rgba(255,255,255,.7) 0 .5px, rgba(255,255,255,.18) .5px 30%, rgba(255,255,255,0) 50%, rgba(0,0,0,.025) calc(100% - .5px), rgba(0,0,0,.09) calc(100% - .5px)),
    var(--pt-label-bg);
  /* it lies flat: only the thickness of the tape */
  box-shadow: 0 0 0 .5px rgba(0,0,0,.14), 0 .5px 0 rgba(0,0,0,.08);
  transform: rotate(calc(var(--pt-rot) * var(--pt-tilt)));
}
.pt-label[data-color="yellow"] { --pt-label-bg: #f9dc4a; }
.pt-label[data-color="clear"]  { --pt-label-bg: rgba(255,255,255,.28); box-shadow: 0 0 0 .5px rgba(0,0,0,.12); }
.pt-label[data-color="black"]  { --pt-label-bg: #1c1d20; --pt-label-ink: #f4f2ea; }
.pt-label[data-color="blue"]   { --pt-label-bg: #a9cdf0; }
.pt-label[data-color="green"]  { --pt-label-bg: #b9e3c4; }

.pt-label--emboss {
  --pt-label-bg: #c22d2a; --pt-wobble: 1;
  padding: 2px 9px 1px; border-radius: 1px;
  font-family: "Archivo", "Arial Narrow", Arial, sans-serif; font-stretch: normal; font-weight: 700; font-size: 13px; line-height: 19px;
  letter-spacing: .2em; text-transform: uppercase;
  /* punched letters go milky white, never pure white, and stand up from the tape */
  color: rgba(255, 255, 255, .84);
  text-shadow: 0 1px 0 rgba(0,0,0,.28), 0 -.5px 0 rgba(255,255,255,.18), 0 0 1px rgba(255,255,255,.35);
  background:
    linear-gradient(to bottom, rgba(255,255,255,.38) 0 1px, rgba(255,255,255,.16) 1px 22%, rgba(255,255,255,0) 40%, rgba(0,0,0,.08) 80%, rgba(0,0,0,.2) calc(100% - 1px), rgba(0,0,0,.3) calc(100% - 1px)),
    repeating-linear-gradient(to bottom, rgba(255,255,255,.02) 0 1px, transparent 1px 4px),
    var(--pt-label-bg);
  box-shadow: 0 1px 1px rgba(0,0,0,.22), 0 0 0 .5px rgba(0,0,0,.2);
  /* the cutter leaves slightly clipped corners */
  clip-path: polygon(1.5px 0, calc(100% - 1.5px) 0, 100% 1.5px, 100% calc(100% - 1.5px), calc(100% - 1.5px) 100%, 1.5px 100%, 0 calc(100% - 1.5px), 0 1.5px);
}
.pt-label--emboss .pt-c { display: inline-block; }
.pt-label--emboss[data-color="blue"]  { --pt-label-bg: #24489a; }
.pt-label--emboss[data-color="black"] { --pt-label-bg: #222327; }
.pt-label--emboss[data-color="green"] { --pt-label-bg: #2b6f45; }
.pt-label--emboss:is([data-color="yellow"], [data-color="clear"], [data-color="mint"], [data-color="orange"]) { --pt-label-bg: #c22d2a; }

/* tape you can write on */
.pt-tape--text { display: inline-flex; align-items: center; justify-content: center; width: auto; min-width: 96px; height: 28px; padding: 0 18px; box-sizing: border-box; font-family: var(--pt-font-hand); font-size: 20px; line-height: 1; color: var(--pt-ribbon); }

/* bullet journal: <ul class="pt-bujo"><li data-sign="task|done|migrated|scheduled|event|note|priority"> */
.pt-bujo { list-style: none; padding: 0; display: flex; flex-direction: column; }
.pt-bujo li { position: relative; padding-left: calc(var(--pt-grid) * 1.25); max-width: none; }
.pt-bujo li[data-sign]::before {
  content: ""; position: absolute; left: 0; top: calc(var(--pt-grid) / 2 - 9px); width: 18px; height: 18px;
  background: currentColor;
  -webkit-mask: var(--pt-sign) center / contain no-repeat; mask: var(--pt-sign) center / contain no-repeat;
  color: currentColor;
}
.pt-bujo li[data-sign="task"]      { --pt-sign: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M9.4 7.2 C 11 7.4, 11.3 9.9, 9.6 10.8 C 8 11.4, 6.9 9.9, 7.4 8.6 C 7.7 7.7, 8.4 7.3, 9.4 7.2 Z'/%3E%3C/svg%3E"); }
.pt-bujo li[data-sign="done"]      { --pt-sign: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round'%3E%3Cpath d='M5 5.4 C 8 8.2, 10.5 10.8, 13.2 13.4 M12.8 4.8 C 10.4 7.6, 7.6 10.6, 5.2 13'/%3E%3C/svg%3E"); }
.pt-bujo li[data-sign="migrated"]  { --pt-sign: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 4.6 C 8.4 6.4, 10.6 8, 12.6 9.1 C 10.4 10.4, 8.4 11.8, 6.2 13.6'/%3E%3C/svg%3E"); }
.pt-bujo li[data-sign="scheduled"] { --pt-sign: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12.2 4.6 C 9.8 6.3, 7.6 7.9, 5.6 9.1 C 7.8 10.5, 9.8 11.9, 12 13.6'/%3E%3C/svg%3E"); }
.pt-bujo li[data-sign="event"]     { --pt-sign: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M9 4.6 C 12.2 4.5, 13.6 7.4, 13.3 9.6 C 12.9 12.4, 10.2 13.6, 8.2 13.3 C 5.6 12.8, 4.4 10.4, 4.8 8.4 C 5.2 6.2, 7.2 4.7, 9.6 4.9'/%3E%3C/svg%3E"); }
.pt-bujo li[data-sign="note"]      { --pt-sign: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round'%3E%3Cpath d='M4.6 9.4 C 7.4 9, 10.4 9.1, 13.4 8.8'/%3E%3C/svg%3E"); }
.pt-bujo li[data-sign="priority"]  { --pt-sign: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M9.1 4 L 8.9 14 M4.8 6.6 L 13.2 11.4 M13.4 6.4 L 4.6 11.6'/%3E%3C/svg%3E"); }
.pt-bujo li[data-sign="done"] { color: color-mix(in srgb, currentColor 60%, transparent); }
.pt-bujo li[data-sign="priority"]::before { color: var(--pt-pencil); }

/* progress: <div class="pt-progress" data-shape="bar|boxes|circles|ring|tally|sei" data-style="highlight|pencil|hatch|cross|scribble|stipple"
                role="progressbar" aria-valuenow="62" style="--pt-value: .62">
   The script draws it with any writing instrument (data-tool); without it, a highlighter bar. */
/* --pt-value has no default here, so the script can tell it apart from aria-valuenow */
.pt-progress {
  position: relative; height: var(--pt-grid); max-width: calc(var(--pt-grid) * 14);
  background: var(--pt-box) 0 2px / 100% 20px no-repeat;
}
.pt-progress::before {
  content: ""; position: absolute; left: 3px; top: 4px; bottom: 4px;
  width: calc((100% - 6px) * var(--pt-value, .5));
  background: var(--pt-hl);
  -webkit-mask: var(--pt-mask-a) 0 0 / 100% 100% no-repeat; mask: var(--pt-mask-a) 0 0 / 100% 100% no-repeat;
  mix-blend-mode: var(--pt-blend, multiply);
}
.pt-progress[data-pt-painted] { background: var(--pt-progress-img) 0 0 / 100% 100% no-repeat; }
.pt-progress[data-pt-painted]::before { display: none; }
.pt-progress:is([data-shape="boxes"], [data-shape="circles"], [data-style="segments"], [data-style="dots"]) { height: calc(var(--pt-grid) * 1.25); }
.pt-progress:is([data-shape="ring"], [data-style="ring"]) { width: calc(var(--pt-grid) * 3); height: calc(var(--pt-grid) * 3); display: grid; place-items: center; }
.pt-progress:is([data-shape="tally"], [data-shape="sei"], [data-style="tally"], [data-style="sei"]) { width: calc(var(--pt-groups, 4) * 30px); height: calc(var(--pt-grid) * 1.25); }
.pt-progress[data-label]::after { content: attr(data-label); font-family: var(--pt-font-hand); font-size: 20px; line-height: 1; color: currentColor; }
.pt-progress:not([data-style="ring"], [data-shape="ring"])[data-label] { max-width: min(calc(var(--pt-grid) * 14), calc(100% - 56px)); }
.pt-progress:not([data-style="ring"], [data-shape="ring"])[data-label]::after { position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%); white-space: nowrap; }
