/* ==========================================================================
   Doodle notes — the pen layer on posts and stories (r-notes.js draws it).
   Change the look here, once, for the whole site.

   Markup (inside an element with class="n-scope", usually .post__body):
     <span class="n-ul">phrase</span>                      underline
     <span class="n-circle">phrase</span>                  circle
     <div class="n-box">…</div>                            box round a block
     <blockquote class="a-quote n-side">…</blockquote>      a hand bracket down the left side (the quote's side line)
     data-note="text" data-side="r|l"                      a handwritten note in the margin
       · on a block (p, figure, .n-box): a side arrow points from the note to it
       · on .n-ul / .n-circle: a thin line runs from the mark to the note
     <span class="n-hand" data-to=".selector">text</span>   a handwritten note written right where it stands (inside a figure);
       the pen draws an arrow from it to the first match of the selector inside the same figure
   Phones and tablets (≤1180px, as on benji.org/stageshow): no lines or arrows,
   the note sits right under its block, a little smaller, not tilted.
   ========================================================================== */

@font-face { font-family: "Vojta Notes"; src: url("assets/fonts/vojta-notes-v1.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: block; }

:root {
  --n-ink: var(--accent, #54658C);    /* the site's highlight blue */
  --n-font: "Vojta Notes", cursive;
  --n-size: 28px;                     /* margin note text */
  --n-size-sm: 24px;                  /* the same note on phones */
  --n-stroke: 2.4px;                  /* underlines, circles, boxes, arrows */
  --n-lead: 1.6px;                    /* the thin line from a mark to its note */
  --n-gap: clamp(44px, 4.5vw, 76px);  /* text column → margin note */
}

.n-scope { position: relative; }
.n-ul, .n-circle { position: relative; }
.n-circle { white-space: nowrap; }
.n-box { position: relative; padding: 14px 18px; margin-block: 1.4em; }

/* the pen layer: one SVG over the whole scope */
.n-layer { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; z-index: 1; }
.n-layer path { fill: none; stroke: var(--n-ink); stroke-width: var(--n-stroke); stroke-linecap: round; stroke-linejoin: round; }
.n-layer path[data-lead] { stroke-width: var(--n-lead); }
.n-layer .n-pad { fill: none; stroke: none; }
.n-layer g { filter: url(#n-pencil); }
.n-layer g.n-on-dark { filter: url(#n-pencil) drop-shadow(0 0 .7px rgba(255, 255, 255, .9)) drop-shadow(0 0 1.5px rgba(255, 255, 255, .35)); }   /* ink stays ink; the halo only shows over the dark image */
/* dark theme, the mirror: the ink is light, so over a light screenshot the arrow goes back to dark ink with the same halo */
:root[data-theme="dark"] .n-layer g.n-on-dark { filter: url(#n-pencil); }
:root[data-theme="dark"] .n-layer g.n-on-light { filter: url(#n-pencil) drop-shadow(0 0 .7px rgba(255, 255, 255, .9)) drop-shadow(0 0 1.5px rgba(255, 255, 255, .35)); }
:root[data-theme="dark"] .n-layer g.n-on-light path { stroke: #54658C; }

/* The older doodles, redrawn with this pen.
   Hero arrows (Home "written by these two", About "ask the questions"): the pen's stroke and handwriting, kept in ink (white on dark).
   The pencil filter lives in the first .n-scope's SVG, so these pages need one (both have). */
.duo-fork .duo-fork__svg path { stroke-width: var(--n-stroke); stroke-dasharray: none; filter: url(#n-pencil); }
.duo-fork__text { font-family: var(--n-font); font-style: normal; }
/* a hand note standing next to someone, in the notes' blue (Home stories: "this is Andrea") */
.n-stand .note__text { font-family: var(--n-font); font-style: normal; color: var(--n-ink); }
:is(.n-stand svg, svg.n-stand) path { fill: none; stroke: var(--n-ink); stroke-width: var(--n-stroke); stroke-linecap: round; stroke-linejoin: round; filter: url(#n-pencil); }

/* margin note */
.n-note {
  position: absolute; top: 0; left: 0; margin: 0;
  font-family: var(--n-font); font-size: var(--n-size); font-weight: 400; font-style: normal; line-height: 1.15;
  color: var(--n-ink); text-wrap: balance;
  transform: rotate(var(--n-tilt, 0deg)); transform-origin: 0 50%;
  /* pencil grain: tiny gaps where the paper shows through (a tiling noise mask; letterforms stay crisp) */
  --n-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -6 0 0 0 4.35'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  -webkit-mask: var(--n-grain) 0 0 / 180px 180px; mask: var(--n-grain) 0 0 / 180px 180px;
}
.n-note[data-side="l"] { text-align: right; transform-origin: 100% 50%; }
.n-note .n-w { display: inline-block; white-space: nowrap; }
.n-note .n-ch { display: inline-block; transform: translateY(var(--y, 0)) rotate(var(--rot, 0)) scale(var(--s, 1)); }

/* a note written in place (inside a figure): the figure's own layout decides where it stands */
.n-hand {
  display: block; width: fit-content; max-width: 230px;
  font-family: var(--n-font); font-size: var(--n-size); font-weight: 400; font-style: normal; line-height: 1.1;
  color: var(--n-ink); text-wrap: balance; transform: rotate(var(--n-tilt, 0deg));
}
.n-hand .n-w { display: inline-block; white-space: nowrap; }
.n-hand .n-ch { display: inline-block; transform: translateY(var(--y, 0)) rotate(var(--rot, 0)) scale(var(--s, 1)); }

/* draw-on: each mark draws itself the first time it scrolls into view, then its note fades in */
html.n-anim .n-layer g:not(.is-in) { visibility: hidden; }   /* round caps would leave a dot before the pen starts */
html.n-anim .n-layer g path { stroke-dasharray: 1; stroke-dashoffset: 1; }
html.n-anim .n-layer g.is-in path { stroke-dashoffset: 0; transition: stroke-dashoffset .65s cubic-bezier(.4, 0, .2, 1) var(--d, 0s); }
html.n-anim .n-layer g.is-in path[data-lead] { transition-duration: .35s; }
html.n-anim :is(.n-note, .n-hand) { opacity: 0; }
html.n-anim :is(.n-note, .n-hand).is-in { opacity: 1; transition: opacity .4s ease var(--d, 0s); }

.n-note.n-note--in { position: static; display: block; margin: .5em 0 1.1em; font-size: var(--n-size-sm); transform: none; text-align: left; }
@media (max-width: 1180px) {
  .n-note { position: static; display: block; margin: .5em 0 1.1em; font-size: var(--n-size-sm); transform: none; text-align: left; }
  .n-note[data-side="l"] { text-align: left; }
  :is(ul, ol) > .n-note { margin: -10px 0 18px; padding-left: 32px; }   /* a note on a list item stays with its item */
}
@media (prefers-reduced-motion: reduce) {
  html.n-anim .n-layer g path { stroke-dashoffset: 0; transition: none; }
  html.n-anim :is(.n-note, .n-hand) { opacity: 1; transition: none; }
}

/* Long marked sentences can wrap inside a single ring. */
.n-circle--sentence { display: block; width: fit-content; max-width: 100%; padding-inline: 8px; white-space: normal; }
@media (max-width: 700px) {
  .n-circle--sentence { max-width: calc(100% - 24px); margin-inline: 12px; padding-inline: 6px; }
}
p:has(> .n-circle--sentence) + .n-note--in { margin: 14px 0 1.1em 32px; }

/* Keep the inactive notes in the mobile grid so slide changes never move the controls. */
.a-gal__notes:has(> .n-note--in) { display: grid; padding-inline: 12px 24px; }
.a-gal__notes > .n-note--in { grid-area: 1 / 1; justify-self: end; margin: 10px 0 0; font-size: 22px; }
.n-note--gallery[data-inactive] { visibility: hidden; }
.n-layer g[data-gallery-mark][data-inactive] { display: none; }
.n-layer g[data-split-ink] { --n-image-ink: #54658C; }
.n-layer g[data-split-ink] feFlood { flood-color: var(--n-image-ink); }
:root[data-theme="dark"] .n-layer g[data-split-ink] path:not([data-lead]) { stroke: var(--n-image-ink); }
:root[data-theme="dark"] .n-layer g[data-split-ink] path[data-lead] { filter: var(--n-image-filter); }
.n-note--shot.n-note--in { width: fit-content; max-width: calc(100% - 24px); margin-inline: auto 24px; }
