/* Small things on every page (static/js/whimsy.js): the ink for the theme toggle, the tossed coin, a quiet
   underline on links in running text, a highlighter for selections, and the drawn reading-progress lines. */

/* the new theme comes as a roll of its paper, rolled down from the toggle (whimsy.js); nothing of the browser's own
   cross-fade, for the two pages or for the roll's own layer */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-group(switch-over), ::view-transition-new(switch-over), ::view-transition-old(switch-over) { animation: none; }
::view-transition-group(switch-grain), ::view-transition-new(switch-grain), ::view-transition-old(switch-grain) { animation: none; }
/* the one set of values the switch animates (on ::view-transition, whose pseudo-elements inherit them): --sw-y the roll's
   axis, --sw-k its thickness, and --sw-gt/--sw-gb the rolling paper-grain slice window. All start at nothing, and the new
   page is hidden until the switch starts, or it flashes for a frame and then drops back to the old one (the theme toggle's
   is the site's only view transition; no class marks it, since a class on <html> wakes every theme watcher) */
@property --sw-y { syntax: "<length>"; inherits: true; initial-value: 0px; }
@property --sw-k { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --sw-gt { syntax: "<length>"; inherits: true; initial-value: 0px; }
@property --sw-gb { syntax: "<length>"; inherits: true; initial-value: 0px; }
::view-transition-new(root) { clip-path: polygon(0 0, 0 0, 0 0); }

/* selection: a highlighter */
::selection { background: rgba(255, 214, 90, 0.55); color: inherit; }
.dark ::selection { background: rgba(143, 176, 255, 0.35); }

/* links in running text take a thin straight underline when pointed at (not the contents, menus or rails) */
p a:hover, article li a:hover, .lede a:hover, figcaption a:hover {
  text-decoration-line: underline; text-decoration-style: solid; text-decoration-thickness: 1px; text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, currentColor 55%, transparent);
}
nav li a:hover, .rail li a:hover, .toc li a:hover { text-decoration-line: none; }

/* the reading-progress line, drawn for the page (static/js/whimsy.js): the pages set its width, which uncovers the drawing;
   a line marked data-auto has its width set by whimsy.js from the scroll */
.progress[data-auto] { position: fixed; top: 0; left: 0; width: 0; z-index: 60; }
.progress.bar-walk, .progress.bar-mesh { height: 10px !important; background: none !important; overflow: hidden; pointer-events: none; }
.progress .bar-art { position: absolute; left: 0; top: 0; display: block; overflow: visible; }
.progress .bar-ink { fill: none; stroke: #1f3fd0; stroke-width: 1.3; stroke-linejoin: round; }
.progress .bar-dot { fill: #1f3fd0; }
.progress .bar-tri { fill: #1f3fd0; fill-opacity: 0; stroke: rgba(20, 22, 40, 0.28); stroke-width: 0.7; stroke-linejoin: round; transition: fill-opacity 0.4s; }
.progress .bar-tri.on { fill-opacity: 0.1; }
.progress .bar-tri.fresh { fill-opacity: 0.45; }
.dark .progress .bar-ink { stroke: #8fb0ff; }
.dark .progress .bar-dot { fill: #8fb0ff; }
.dark .progress .bar-tri { fill: #8fb0ff; stroke: rgba(255, 255, 255, 0.28); }

/* the coin */
.whimsy-coin { position: fixed; right: 22px; bottom: 22px; z-index: 90; display: flex; align-items: center; gap: 10px; perspective: 400px;
  font: 0.82rem Newsreader, Georgia, serif; color: var(--ink, #222); transition: opacity 0.5s, transform 0.5s; }
.whimsy-coin.gone { opacity: 0; transform: translateY(8px); pointer-events: none; }
/* the floating notes are patches of the site's paper (partials/header.html), not flat cream or grey */
/* (shapes, 11-09) no pill: the result sits on a patch of the paper whose edges fade out, as the way past a story does (below) */
.whimsy-coin p { margin: 0; padding: 0.45rem 0.95rem; background: var(--ground, #fff) var(--paper-img) 0 var(--paper-y, 0px) / 768px 768px fixed; background-blend-mode: var(--patch-blend);
  -webkit-mask: linear-gradient(to right, transparent, #000 0.8rem, #000 calc(100% - 0.8rem), transparent), linear-gradient(transparent, #000 0.4rem, #000 calc(100% - 0.4rem), transparent); -webkit-mask-composite: source-in;
  mask: linear-gradient(to right, transparent, #000 0.8rem, #000 calc(100% - 0.8rem), transparent), linear-gradient(transparent, #000 0.4rem, #000 calc(100% - 0.4rem), transparent); mask-composite: intersect; }
.whimsy-coin .face { position: relative; width: 38px; height: 38px; transform-style: preserve-3d; animation: coin-toss 1s cubic-bezier(.2, .7, .3, 1) both; }
.whimsy-coin .face span { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 50%; backface-visibility: hidden;
  font: 700 0.95rem Newsreader, Georgia, serif;
  /* (interior audit 11-06) a pencil ring on a patch of the paper, not a glossy gold disc */
  background: var(--ground, #e9d7b1) var(--paper-img) 0 0 / 768px 768px; background-blend-mode: var(--patch-blend);
  border: 1.5px solid color-mix(in srgb, currentColor 55%, transparent); }
.whimsy-coin .face .t { transform: rotateY(180deg); }
@keyframes coin-toss {
  0% { transform: translateY(0) rotateY(0); }
  45% { transform: translateY(-46px) rotateY(900deg); }
  100% { transform: translateY(0) rotateY(calc(1800deg + var(--end, 0deg))); }
}
.dark .whimsy-coin { color: #e8e8e8; }

/* the little coin on "Flip again" buttons */
.mini-coin { display: inline-block; width: 0.8em; height: 0.8em; margin-right: 0.45em; vertical-align: -0.08em; border-radius: 50%; box-sizing: border-box;
  border: 1.25px solid color-mix(in srgb, currentColor 70%, transparent); }   /* (interior audit 11-06) a pencil ring, not a glossy gold disc */
.mini-coin.spin { animation: mini-toss 0.7s cubic-bezier(.2, .7, .3, 1); }
@keyframes mini-toss { 0% { transform: translateY(0) rotateY(0); } 45% { transform: translateY(-9px) rotateY(540deg); } 100% { transform: translateY(0) rotateY(1080deg); } }

/* idle doodles (whimsy.js draws each stroke in pencil order, so nothing here animates). Grey only; a game's end is the
   one place colour comes in, set on the stroke itself by doodle-games.js */
.whimsy-doodle { position: absolute; width: 90px; height: 90px; pointer-events: none; z-index: 1; color: var(--ink-3, #999); opacity: 0.55; overflow: visible; }
.whimsy-doodle path { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
/* (11-12) dots in the doodle's grey, set down after the line that places them (whimsy.js fades each in on its turn) */
.whimsy-doodle .fill { fill: currentColor; stroke: none; }
/* a half-played game takes clicks; the passive doodles never do */
.whimsy-doodle.whimsy-game { pointer-events: auto; }
/* a game's rules, in the margin by it: the site's serif in a quiet grey, no box */
.whimsy-rules { position: absolute; left: 0; top: 0; z-index: 1; margin: 0; pointer-events: none; opacity: 0; box-sizing: border-box; padding: 11px 14px 12px;
  font: 0.8rem/1.45 Newsreader, "Iowan Old Style", Georgia, serif; color: #62626c; text-align: left; hyphens: manual; }
/* (11-14) a slip of the page's paper, edged in pencil (sheets.js, PencilFrame) the way the phone menu's slip is */
.whimsy-rules::before { content: ""; position: absolute; inset: -4px; z-index: -1;
  background: var(--ground) var(--paper-img) 0 0 / 768px 768px; background-blend-mode: var(--patch-blend); clip-path: var(--frame-clip, inset(4px)); }
.pencil-frame { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; color: rgba(64, 57, 48, 1); }
.dark .pencil-frame { color: rgba(214, 210, 200, 1); }
.pencil-frame .pl { fill: none; stroke-linecap: round; }
.pencil-frame stop { stop-color: currentColor; }
.whimsy-rules.on { opacity: 1; transition: opacity 0.35s ease-out; }
.dark .whimsy-rules { color: #8e8f98; }
@media (max-width: 1099.98px) { html:not(.whimsy-small) .whimsy-doodle, html:not(.whimsy-small) .whimsy-rules { display: none; } }
.whimsy-small .whimsy-doodle.whimsy-game { touch-action: manipulation; }   /* the colophon on a phone: a double tap restarts the game, never zooms */

/* on paper */
@media print {
  .whimsy-coin, .whimsy-doodle, .whimsy-rules, .progress { display: none !important; }
  .site-foot::after { content: "Printed from sbabichenko.com, where the drawings move."; display: block; width: 100%; margin-top: 0.4rem; font-style: italic; }
}

/* keyboard focus, everywhere, only for keyboard users. (11-12) No rounded box: a link (the site's links are words)
   gets a thick accent underline, the way the site already marks links; anything else (buttons, sliders, figures,
   links that hold only a picture) keeps a square-cornered accent outline, which it needs to be seen */
:focus-visible { outline: 2px solid var(--accent, #1f3fd0); outline-offset: 2px; border-radius: 0; }
a:focus-visible:not(:has(img, svg, canvas, picture, video)) { outline: none; text-decoration: underline; text-decoration-color: var(--accent, #1f3fd0); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.step :focus-visible, .cards a:focus-visible, .demo:focus-visible { outline-offset: 4px; }


/* the way past a scroll-told section (static/js/skip.js) */
.skip-pill { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 80; transform: translate(-50%, 12px);
  opacity: 0; pointer-events: none; transition: opacity 0.3s, transform 0.3s;
  font: 600 0.82rem Newsreader, Georgia, serif; padding: 0.6rem 1.6rem; text-decoration: none;
  color: var(--ink, #222); white-space: nowrap; }
/* (shapes, 11-09) no pill: the words sit on a patch of the paper whose edges fade out, so the text passing under them
   is rubbed out softly and there is no outline at all. The patch is a pseudo-element so the focus ring is not faded
   with it (--paper-y is inherited from the link, which partials/header.html keeps moving with the scroll) */
.skip-pill::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: var(--ground, #fff) var(--paper-img) 0 var(--paper-y, 0px) / 768px 768px fixed; background-blend-mode: var(--patch-blend);
  -webkit-mask: linear-gradient(to right, transparent, #000 1.1rem, #000 calc(100% - 1.1rem), transparent), linear-gradient(transparent, #000 0.45rem, #000 calc(100% - 0.45rem), transparent);
  -webkit-mask-composite: source-in;
  mask: linear-gradient(to right, transparent, #000 1.1rem, #000 calc(100% - 1.1rem), transparent), linear-gradient(transparent, #000 0.45rem, #000 calc(100% - 0.45rem), transparent);
  mask-composite: intersect; }
.skip-pill::after { content: " ↓"; }
.skip-pill.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.skip-pill:hover { color: var(--accent, #1f3fd0); }
.dark .skip-pill { color: #e8e8e8; }
.dark .skip-pill:hover { color: var(--accent, #8fb0ff); }
@media print { .skip-pill { display: none !important; } }
