/* Pottle, drawn by hand: every rule, ring, underline and slider is a pencil or marker stroke instead of a ruled line.
   On by default; add ?ui=clean to the address to see the ruled version. */
html[data-ui="hand"] {
  --pen: var(--ink);
  --wob-ease: cubic-bezier(.34, 1.56, .64, 1);
}

/* ---- rules: pencil lines instead of hairlines */
html[data-ui="hand"] .pane h2 { border-bottom: 0; background: url(hand/hair0.svg) left bottom / 100% 7px no-repeat; padding-bottom: calc(9 * var(--u)); }
html[data-ui="hand"] .pane h2:nth-of-type(2n) { background-image: url(hand/hair1.svg); }
html[data-ui="hand"] .pane h2:nth-of-type(3n) { background-image: url(hand/hair2.svg); }
html[data-ui="hand"] .spec { border-top: 0; background: url(hand/hair2.svg) left top / 100% 7px no-repeat; }
html[data-ui="hand"] .spec dt, html[data-ui="hand"] .spec dd { border-bottom: 0; background: url(hand/hair0.svg) left bottom / 100% 7px no-repeat; }
html[data-ui="hand"] .spec dt:nth-of-type(2n), html[data-ui="hand"] .spec dd:nth-of-type(2n) { background-image: url(hand/hair1.svg); }
html[data-ui="hand"] .spec dd { background-position: right bottom; }

/* ---- underlines: a quick marker swoosh that draws itself in */
html[data-ui="hand"] .tab-line { height: 7px; bottom: -1px; background: var(--pen); -webkit-mask: url(hand/under.svg) center / 100% 100% no-repeat; mask: url(hand/under.svg) center / 100% 100% no-repeat; }
html[data-ui="hand"] .seg button::after { height: 7px; bottom: -4px; background: var(--pen); -webkit-mask: url(hand/under.svg) center / 100% 100% no-repeat; mask: url(hand/under.svg) center / 100% 100% no-repeat; transform: none; clip-path: inset(0 100% 0 0); transition: clip-path .45s var(--ease); }
html[data-ui="hand"] .seg button[aria-checked="true"]::after { clip-path: inset(0 0 0 0); }
html[data-ui="hand"] .reset, html[data-ui="hand"] .tlink { position: relative; text-decoration: none; }
html[data-ui="hand"] .tlink::after, html[data-ui="hand"] .reset::after { content: ""; position: absolute; left: -2px; right: -2px; bottom: -3px; height: 6px; background: currentColor; -webkit-mask: url(hand/under.svg) center / 100% 100% no-repeat; mask: url(hand/under.svg) center / 100% 100% no-repeat; clip-path: inset(0 100% 0 0); transition: clip-path .35s var(--ease); }
html[data-ui="hand"] .tlink:hover:not(:disabled)::after, html[data-ui="hand"] .tlink[aria-pressed="true"]::after, html[data-ui="hand"] .reset:hover::after { clip-path: inset(0 0 0 0); }
html[data-ui="hand"] .tlink { color: var(--ink); }
html[data-ui="hand"] .tlink:disabled { opacity: .3; }

/* ---- sliders: a faint pencil line, a marker stroke for the filled part, an inky blob to hold */
html[data-ui="hand"] input[type=range]:not(.pk-r)::-webkit-slider-runnable-track { height: 10px; background: url(hand/marker.svg) left center / var(--p, 50%) 10px no-repeat, url(hand/track.svg) left center / 100% 10px no-repeat; }
html[data-ui="hand"] input[type=range]:not(.pk-r)::-webkit-slider-thumb { width: 17px; height: 15px; margin-top: -2.5px; border-radius: 47% 53% 40% 60% / 58% 42% 58% 42%; background: var(--pen); rotate: -8deg; }
html[data-ui="hand"] input[type=range]:not(.pk-r)::-moz-range-track { height: 10px; background: url(hand/track.svg) left center / 100% 10px no-repeat; }
html[data-ui="hand"] input[type=range]:not(.pk-r)::-moz-range-progress { height: 10px; background: url(hand/marker.svg) left center / 100% 10px no-repeat; }
html[data-ui="hand"] input[type=range]:not(.pk-r)::-moz-range-thumb { width: 17px; height: 15px; border-radius: 47% 53% 40% 60% / 58% 42% 58% 42%; background: var(--pen); }

/* ---- chosen things get circled, like marking a catalogue with a pen */
html[data-ui="hand"] .tp, html[data-ui="hand"] .pal, html[data-ui="hand"] .paper, html[data-ui="hand"] .pk-swatches button { position: relative; }
html[data-ui="hand"] .tp[aria-pressed="true"] canvas,
html[data-ui="hand"] .chip4[aria-pressed="true"],
html[data-ui="hand"] .mat[aria-pressed="true"] i,
html[data-ui="hand"] .stage-tools .paper[aria-pressed="true"],
html[data-ui="hand"] .paper[aria-pressed="true"],
html[data-ui="hand"] .pk-swatches button[aria-pressed="true"] { box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); outline: 0; }
html[data-ui="hand"] .tp[aria-pressed="true"]::after,
html[data-ui="hand"] .paper[aria-pressed="true"]::after,
html[data-ui="hand"] .pk-swatches button[aria-pressed="true"]::after,
html[data-ui="hand"] .mat[aria-pressed="true"] i::after {
  content: ""; position: absolute; inset: -7px; background: var(--pen); pointer-events: none;
  -webkit-mask: url(hand/loop.svg) center / 100% 100% no-repeat; mask: url(hand/loop.svg) center / 100% 100% no-repeat;
  animation: penIn .45s var(--wob-ease) both;
}
html[data-ui="hand"] .mat i { position: relative; }
html[data-ui="hand"] .paper[aria-pressed="true"]::after, html[data-ui="hand"] .pk-swatches button[aria-pressed="true"]::after { inset: -6px; }
html[data-ui="hand"] .chip4 { overflow: visible; }
html[data-ui="hand"] .chip4 i:first-child { border-radius: 6px 0 0 6px; }
html[data-ui="hand"] .chip4 i:last-child { border-radius: 0 6px 6px 0; }
html[data-ui="hand"] .chip4[aria-pressed="true"]::after {
  content: ""; position: absolute; inset: -9px -8px; background: var(--pen); pointer-events: none;
  -webkit-mask: url(hand/loop-wide.svg) center / 100% 100% no-repeat; mask: url(hand/loop-wide.svg) center / 100% 100% no-repeat;
  animation: penIn .45s var(--wob-ease) both;
}
@keyframes penIn { from { opacity: 0; transform: scale(.82) rotate(-6deg); } }

/* ---- buttons: drawn outlines and an inked pill */
html[data-ui="hand"] .btn-line { position: relative; box-shadow: none !important; background: none; }
html[data-ui="hand"] .btn-line::before { content: ""; position: absolute; inset: -1px; background: var(--pen); opacity: .55; -webkit-mask: url(hand/pill.svg) center / 100% 100% no-repeat; mask: url(hand/pill.svg) center / 100% 100% no-repeat; transition: opacity .2s; pointer-events: none; }
html[data-ui="hand"] .btn-line:hover::before { opacity: 1; }
html[data-ui="hand"] .btn-ink, html[data-ui="hand"] .nav .btn-ink { border-radius: 0; background: var(--pen); -webkit-mask: url(hand/pill-fill.svg) center / 100% 100% no-repeat; mask: url(hand/pill-fill.svg) center / 100% 100% no-repeat; }
html[data-ui="hand"] .shelf-link b { border-radius: 46% 54% 50% 50% / 55% 48% 52% 45%; }

/* ---- shapes and the outline editor: the outline is inked, the handles are little blobs */
html[data-ui="hand"] #profile .body { stroke-width: 1.6; stroke-linecap: round; }
html[data-ui="hand"] #profile .knob .dot { stroke-width: 1.6; }

/* ---- phone bar: a pencil line on top instead of a rule */
@media (max-width: 860px) {
  html[data-ui="hand"] .step-tabs { border-top: 0; background: url(hand/hair1.svg) left top / 100% 7px no-repeat, color-mix(in srgb, var(--ground) 96%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  html[data-ui="hand"] *::after { animation: none !important; }
}

/* one continuous pencil line per fact row: both halves of a row share one drawing sized to the whole list */
html[data-ui="hand"] .spec { container-type: inline-size; }
html[data-ui="hand"] .spec dt, html[data-ui="hand"] .spec dd { background-size: 100cqw 7px; }
html[data-ui="hand"] .spec dt { background-position: left bottom; }
html[data-ui="hand"] .spec dd { background-position: right bottom; }
html[data-ui="hand"] .spec dt:nth-of-type(3n), html[data-ui="hand"] .spec dd:nth-of-type(3n) { background-image: url(hand/hair2.svg); }

/* ===== looser pen: lines, ovals and tiles drawn more freely; type stays as set ===== */
html[data-ui="hand"] .pane h2 { background-image: url(hand/loose0.svg); background-size: 100% 10px; }
html[data-ui="hand"] .pane h2:nth-of-type(2n) { background-image: url(hand/loose1.svg); }
html[data-ui="hand"] .pane h2:nth-of-type(3n) { background-image: url(hand/loose2.svg); }
html[data-ui="hand"] .spec { background-image: url(hand/loose2.svg); background-size: 100% 10px; }
html[data-ui="hand"] .spec dt, html[data-ui="hand"] .spec dd { background-image: url(hand/loose0.svg); background-size: 100cqw 10px; }
html[data-ui="hand"] .spec dt:nth-of-type(2n), html[data-ui="hand"] .spec dd:nth-of-type(2n) { background-image: url(hand/loose1.svg); }
html[data-ui="hand"] .spec dt:nth-of-type(3n), html[data-ui="hand"] .spec dd:nth-of-type(3n) { background-image: url(hand/loose2.svg); }

/* outline buttons: a loose oval drawn round the word */
html[data-ui="hand"] .btn-line::before { content: ""; position: absolute; inset: -3px -4px; background: var(--pen); opacity: 1; -webkit-mask: url(hand/oval.svg) center / 100% 100% no-repeat; mask: url(hand/oval.svg) center / 100% 100% no-repeat; pointer-events: none; transition: rotate .3s var(--wob-ease); }
html[data-ui="hand"] .btn-line::before { -webkit-mask-image: url(hand/oval2.svg); mask-image: url(hand/oval2.svg); opacity: .75; }
html[data-ui="hand"] .btn-line:hover::before { rotate: -2deg; background: var(--pen); }

/* sliders and tiles: a looser pen */
html[data-ui="hand"] input[type=range]:not(.pk-r)::-webkit-slider-runnable-track { height: 12px; background: url(hand/lmarker.svg) left center / var(--p, 50%) 12px no-repeat, url(hand/ltrack.svg) left center / 100% 12px no-repeat; }
html[data-ui="hand"] input[type=range]:not(.pk-r)::-webkit-slider-thumb { margin-top: -1.5px; }
html[data-ui="hand"] .tp canvas { border-radius: 9px 4px 10px 5px / 5px 10px 4px 9px; box-shadow: none; }
html[data-ui="hand"] .tp:nth-child(3n+1) canvas { rotate: -1.2deg; }
html[data-ui="hand"] .tp:nth-child(3n+2) canvas { rotate: .9deg; }
html[data-ui="hand"] .tp[aria-pressed="true"]::after { inset: -8px; }
html[data-ui="hand"] .mat i, html[data-ui="hand"] .cdot i { box-shadow: none; }

/* ink buttons stay a clean pill: a drawn outline only reads on small buttons */
html[data-ui="hand"] .btn-ink, html[data-ui="hand"] .nav .btn-ink { border-radius: 999px; -webkit-mask: none; mask: none; }

/* headings carry no line in either mode */
html[data-ui="hand"] .pane h2, html[data-ui="hand"] .pane h2:nth-of-type(n) { background: none; padding-bottom: 0; }
