/* The design system: one ink on one background, emphasis as alpha steps of the ink.
 * Re-theme anything by setting --ink and --bg (RGB channels) on :root or a [data-look] element. */

:root, [data-look] {
  --ink-1: rgb(var(--ink) / 1);
  --ink-2: rgb(var(--ink) / .62);
  --ink-3: rgb(var(--ink) / .45);
  --ink-4: rgb(var(--ink) / .32);
  --ink-5: rgb(var(--ink) / .22);
  --ink-6: rgb(var(--ink) / .12);
  --paper: rgb(var(--bg));
}

:root {
  --ink: 255 255 255;
  --bg: 0 0 0;

  --mono: Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
  --heavy: "Arial Black", "Arial Bold", Gadget, "Helvetica Neue", Arial, sans-serif;

  --fs-xs: 11px;
  --fs-s: 12px;
  --fs-m: 14px;
  --fs-l: 18px;
  --fs-xl: 24px;
  --track: .06em;
  --track-w: .08em;

  --sp-1: 2px;
  --sp-2: 6px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 48px;
  --sp-7: 96px;

  --blink: 1.1s;
  --measure: 72ch;
  --frame: 132ch;
  --rail: 12ch;
  --gutter: 2ch;
  --pad-x: var(--sp-2);   /* a [ link ]'s side padding */

  color-scheme: dark;
}

/* ---------- base ---------- */

.n-page {
  margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink-2);
  font: var(--fs-m)/1.7 var(--mono);
  -webkit-text-size-adjust: 100%;
}
.n-page ::selection { background: var(--ink-1); color: var(--paper); }
.n-page a { color: var(--ink-1); text-decoration: underline; text-decoration-color: var(--ink-4); text-underline-offset: 3px; }
.n-page a:hover { text-decoration-color: var(--ink-1); }
.n-page :focus-visible { outline: 1px solid var(--ink-2); outline-offset: 3px; }

.n-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- top bar ---------- */

.n-bar {
  /* spans the content frame (so its ch is the page text's), the first and last bracket on the text's edges */
  display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3);
  max-width: calc(var(--frame) + 2 * var(--pad-x)); margin-inline: auto;
  padding: var(--sp-3) calc(var(--sp-4) - var(--pad-x)); font: var(--fs-m)/1 var(--mono);
}
.n-brand { flex: none; font: var(--fs-s)/1 var(--mono); letter-spacing: var(--track); }

/* ---------- [ bracketed ] links ---------- */

.n-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-1); font: var(--fs-s)/1 var(--mono); letter-spacing: var(--track); }
:is(.n-brand, .n-links a, .n-link) { color: var(--ink-2); text-decoration: none; padding: var(--sp-2) var(--pad-x); white-space: nowrap; }
:is(.n-brand, .n-links a, .n-link)::before { content: '[ '; opacity: .4; }
:is(.n-brand, .n-links a, .n-link)::after { content: ' ]'; opacity: .4; }
:is(.n-brand, .n-links a, .n-link):is(:hover, :focus-visible) { color: var(--paper); background: var(--ink-1); outline: none; }
:is(.n-brand, .n-links a, .n-link):is(:hover, :focus-visible)::before,
:is(.n-brand, .n-links a, .n-link):is(:hover, :focus-visible)::after,
.n-links a[aria-current="page"]::before, .n-links a[aria-current="page"]::after { opacity: 1; }
.n-links a[aria-current="page"]:not(:hover, :focus-visible) { color: var(--ink-1); }
.n-link { display: inline-block; font: var(--fs-s)/1 var(--mono); letter-spacing: var(--track); }
button.n-link { background: none; border: 0; border-radius: 0; margin: 0; cursor: pointer; }
@media (pointer: coarse) { :root { --pad-x: 7px; } :is(.n-brand, .n-links a, .n-link) { padding-block: 11px; } }
/* narrow: compact brackets keep it one row down to ~350px; below that the links wrap under the name */
@media (max-width: 520px) {
  .n-bar { --pad-x: 4px; flex-wrap: wrap; row-gap: 0; }
  .n-links { justify-content: flex-start; }
  .n-bar :is(.n-brand, .n-links) { font-size: var(--fs-xs); letter-spacing: 0; }
  .n-bar :is(.n-brand, .n-links a)::before { content: '['; }
  .n-bar :is(.n-brand, .n-links a)::after { content: ']'; }
}

/* ---------- small type ---------- */

.n-caption { font: var(--fs-xs)/1.4 var(--mono); letter-spacing: var(--track-w); color: var(--ink-4); }

.n-caret { opacity: .7; animation: n-blink var(--blink) steps(1) infinite; }
@keyframes n-blink { 50% { opacity: 0; } }

.n-tag { font: var(--fs-xs)/1 var(--mono); letter-spacing: var(--track-w); color: var(--ink-3); white-space: nowrap; }
.n-tag::before { content: '['; opacity: .6; }
.n-tag::after { content: ']'; opacity: .6; }

.n-tags { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-2); }

.n-rule { border: 0; height: 1em; margin: var(--sp-6) 0; overflow: hidden; color: var(--ink-5); font: var(--fs-s)/1 var(--mono); }
.n-rule::before { content: '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'; white-space: pre; }

/* ---------- frame: the cursor's corner brackets ---------- */

.n-frame {
  --l: 10px; --c: var(--ink-4);
  position: relative; padding: var(--sp-4);
  background:
    linear-gradient(var(--c) 0 0) top left / var(--l) 1px,
    linear-gradient(var(--c) 0 0) top left / 1px var(--l),
    linear-gradient(var(--c) 0 0) top right / var(--l) 1px,
    linear-gradient(var(--c) 0 0) top right / 1px var(--l),
    linear-gradient(var(--c) 0 0) bottom left / var(--l) 1px,
    linear-gradient(var(--c) 0 0) bottom left / 1px var(--l),
    linear-gradient(var(--c) 0 0) bottom right / var(--l) 1px,
    linear-gradient(var(--c) 0 0) bottom right / 1px var(--l);
  background-repeat: no-repeat;
  transition: background-size .18s cubic-bezier(.2, .7, .2, 1);
}
.n-frame:is(:hover, :focus-within) { --c: var(--ink-1); --l: 18px; }

/* ---------- titles ---------- */

.n-title { color: var(--ink-1); font-size: var(--fs-xl); font-weight: normal; line-height: 1.25; margin: 0; }
.n-lede { color: var(--ink-3); margin: var(--sp-3) 0 0; }

/* ---------- prose ---------- */

.n-prose { max-width: var(--measure); color: var(--ink-2); }
.n-prose > :first-child { margin-top: 0; }
.n-prose p, .n-prose ul, .n-prose ol, .n-prose blockquote, .n-prose pre, .n-prose figure { margin: 0 0 1.25em; }
.n-prose h2, .n-prose h3, .n-prose h4 { color: var(--ink-1); font-weight: normal; line-height: 1.3; margin: 2.4em 0 .8em; scroll-margin-top: var(--sp-5); }
.n-prose h2 { font-size: var(--fs-l); }
.n-prose h3, .n-prose h4 { font-size: var(--fs-m); }
.n-prose strong { color: var(--ink-1); font-weight: normal; }
.n-prose em { font-style: normal; color: var(--ink-1); }
.n-prose ul, .n-prose ol { padding-left: 3ch; }
.n-prose ul { list-style: none; }
.n-prose ul > li::before { content: var(--mark, '-'); color: var(--ink-4); display: inline-block; width: 3ch; margin-left: -3ch; }
.n-prose li::marker { color: var(--ink-4); }
.n-prose blockquote { border-left: 1px solid var(--ink-5); padding-left: 2ch; color: var(--ink-3); }
.n-prose code { color: var(--ink-1); }
.n-prose :not(pre) > code { background: var(--ink-6); padding: .1em .5ch; }
.n-prose pre { font-size: var(--fs-s); line-height: 1.55; overflow-x: auto; }
.n-prose pre.n-frame { padding: var(--sp-4) 2ch; }
.n-prose img { max-width: 100%; height: auto; display: block; }
.n-zoom { display: block; max-width: 100%; padding: 0; margin: 0; border: 0; background: none; cursor: zoom-in; }
.n-zoom:focus-visible { outline: 1px solid var(--ink-2); outline-offset: 3px; }
.n-prose figcaption { margin-top: var(--sp-2); }
.n-prose hr { border: 0; }
.n-prose table { border-collapse: collapse; margin: 0 0 1.25em; font-size: var(--fs-s); }
.n-prose :is(th, td) { padding: var(--sp-1) 2ch var(--sp-1) 0; text-align: left; border-bottom: 1px dashed var(--ink-6); }
.n-prose th { color: var(--ink-1); font-weight: normal; }

.n-linkrow { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.n-linkrow .n-link:first-child { margin-left: calc(-1 * var(--pad-x)); }

/* ---------- relief, portrait ---------- */

n-relief, n-portrait { display: block; position: relative; overflow: hidden; background: var(--paper); }
n-relief canvas, n-portrait canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
n-portrait {
  aspect-ratio: 1; touch-action: pan-y;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}

/* ---------- page patterns ---------- */

.n-hero { width: 100%; height: clamp(140px, min(34vh, 44vw), 340px); }
.n-main { max-width: var(--frame); margin: 0 auto; padding: var(--sp-4) var(--sp-4) var(--sp-7); }
.n-head { margin-bottom: var(--sp-5); } 
.n-head > p { margin: 0; }

.n-log { list-style: none; margin: 0; padding: 0; border-bottom: 1px dashed var(--ink-6); }
.n-log li { color: var(--ink-2); }
.n-log a {
  display: grid; grid-template-columns: var(--rail) 1fr; column-gap: var(--gutter); row-gap: var(--sp-1);
  padding: var(--sp-3) 0; color: inherit; text-decoration: none; border-top: 1px dashed var(--ink-6);
}
.n-log time { grid-row: span 3; padding-top: .3em; }
.n-log-title { color: var(--ink-1); justify-self: start; }
.n-log-title::before { content: var(--mark, '>') ' '; color: var(--ink-4); }
.n-log-sum { color: var(--ink-3); font-size: var(--fs-s); line-height: 1.6; }
.n-log a:hover .n-log-title, .n-log a:focus-visible .n-log-title { background: var(--ink-1); color: var(--paper); }
.n-log a:hover .n-log-title::before, .n-log a:focus-visible .n-log-title::before { color: var(--paper); }
.n-log a:focus-visible { outline: none; }
@media (max-width: 560px) { .n-log a { grid-template-columns: 1fr; } .n-log time { grid-row: auto; } }

.n-logbox { position: relative; }
.n-log-thumb { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; opacity: .85; }
.n-log a:is(:hover, :focus-visible) .n-log-thumb { opacity: 1; }
.n-log-pic {
  --c: var(--ink-1); --l: 18px;
  position: absolute; right: 0; margin: 0; padding: var(--sp-2); pointer-events: none; background-color: var(--paper);
  width: min(520px, calc(100% - var(--rail) - var(--gutter) - 60ch - var(--sp-6)));
  transition: top .2s cubic-bezier(.2, .7, .2, 1);
}
.n-log-pic.n-still { transition: none; }
.n-log-pic img { display: block; width: 100%; height: auto; }
.n-log-pic.n-wipe img { animation: n-wipe .22s steps(8, end); }
@keyframes n-wipe { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0); } }
@media (hover: hover) and (min-width: 1001px) {
  .n-log-pics a { grid-template-columns: var(--rail) minmax(0, 60ch); }
  .n-log-thumb { display: none; }
}
@media not ((hover: hover) and (min-width: 1001px)) {
  .n-log-pic { display: none; }
  .n-log-pics a { grid-template-columns: var(--rail) minmax(0, 1fr) min(30%, 220px); grid-template-rows: auto auto auto 1fr; }
  .n-log-pics a > * { grid-column: 2; }
  .n-log-pics time { grid-column: 1; grid-row: 1 / span 3; }
  .n-log-pics .n-log-thumb { grid-column: 3; grid-row: 1 / span 4; align-self: start; }
}
@media (max-width: 560px) {
  .n-log-pics a { display: flow-root; }
  .n-log-pics a > :is(time, .n-log-sum) { display: block; margin-bottom: var(--sp-1); }
  .n-log-pics .n-log-title { display: table; margin-bottom: var(--sp-1); }
  .n-log-pics .n-log-thumb { float: right; width: 38%; margin: .3em 0 var(--sp-2) var(--sp-3); }
  .n-log-pics .n-tags { margin-top: var(--sp-1); }
}

.n-entry {
  display: grid; column-gap: var(--sp-6); align-items: start;
  grid-template-columns: minmax(0, 1fr) minmax(0, var(--measure)) minmax(0, 1fr);
  grid-template-areas: "back head share" "meta body toc" "meta foot toc";
}
.n-back { grid-area: back; justify-self: end; align-self: baseline; margin: 0; }
.n-back .n-link { margin-right: calc(-1 * var(--pad-x)); }
.n-entry-share { grid-area: share; justify-self: start; align-self: baseline; margin: 0; }
.n-entry-share .n-link { margin-left: calc(-1 * var(--pad-x)); }
.n-entry-head { grid-area: head; align-self: baseline; margin-bottom: var(--sp-6); }
.n-entry .n-prose { grid-area: body; }
.n-entry-foot { grid-area: foot; }
.n-meta {
  grid-area: meta; justify-self: end; position: sticky; top: var(--sp-5);
  display: flex; flex-direction: column; align-items: flex-end; gap: var(--sp-2); text-align: end;
}
.n-meta p { margin: 0; }
.n-meta > :empty { display: none; }
.n-meta .n-tags { justify-content: flex-end; }
.n-meta-links { display: flex; flex-direction: column; align-items: flex-end; margin-right: calc(-1 * var(--pad-x)) !important; }
.n-toc { grid-area: toc; position: sticky; top: var(--sp-5); }
.n-toc:empty { display: none; }
.n-toc ol { list-style: none; margin: var(--sp-2) 0 0; padding: 0; font-size: var(--fs-s); line-height: 1.4; }
.n-toc li { position: relative; margin-bottom: var(--sp-2); }
.n-page .n-toc a { color: var(--ink-4); text-decoration: none; }
.n-page .n-toc a:is(:hover, [aria-current]) { color: var(--ink-1); }
.n-toc a[aria-current]::before { content: var(--mark, '>'); position: absolute; right: 100%; padding-right: 1ch; color: var(--ink-4); }
@media (max-width: 1040px) {
  .n-entry { grid-template-columns: 16ch minmax(0, var(--measure)); justify-content: center; column-gap: var(--sp-5); grid-template-areas: "back share" "head head" "meta body" "meta foot"; }
  .n-entry-share { justify-self: start; }
  .n-toc { display: none; }
}
@media (max-width: 560px) {
  .n-entry { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--sp-3); grid-template-areas: "back share" "head head" "meta meta" "body body" "foot foot"; }
  .n-back { justify-self: start; margin-bottom: var(--sp-5); }
  .n-back .n-link { margin: 0 0 0 calc(-1 * var(--pad-x)); }
  .n-entry-share { justify-self: end; align-self: baseline; }
  .n-entry-share .n-link { margin-right: calc(-1 * var(--pad-x)); }
  .n-entry-head { margin-bottom: var(--sp-3); }
  .n-meta { position: static; justify-self: stretch; flex-flow: row wrap; align-items: baseline; gap: var(--sp-1) var(--sp-3); text-align: start; margin-bottom: var(--sp-5); }
  .n-meta .n-tags { justify-content: flex-start; }
  .n-meta-links { flex: 1 0 100%; flex-direction: row; margin: 0 0 0 calc(-1 * var(--pad-x)) !important; }
}

.n-empty { padding: var(--sp-5) 0; }

.n-pager { display: flex; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.n-pager .n-link { white-space: normal; }
.n-pager .n-link:first-child { margin-left: calc(-1 * var(--pad-x)); }
.n-pager .n-link:last-child:not(:first-child) { margin-right: calc(-1 * var(--pad-x)); }

.n-about { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; row-gap: var(--sp-5); }
.n-sitter { width: min(100%, 62vh, 520px); margin: 0; }
.n-sitter figcaption { text-align: center; margin-top: var(--sp-3); }
.n-about-text { width: 100%; max-width: var(--measure); }
.n-about .n-title { margin-bottom: var(--sp-5); }
@media (min-width: 1000px) {
  .n-about {
    grid-template-columns: min(46%, 70vh, 600px) minmax(0, var(--measure)); justify-content: center; align-items: center;
    column-gap: var(--sp-7); min-height: calc(100vh - 7rem); padding-top: 0; padding-bottom: var(--sp-6);
  }
  .n-sitter { width: 100%; }
}

html.n-viewing { overflow: hidden; }
.n-viewer {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: var(--paper); color: var(--ink-2); font: var(--fs-m)/1.7 var(--mono);
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.n-viewer[open] { display: grid; }
.n-viewer::backdrop { background: transparent; }
.n-viewer ::selection { background: var(--ink-1); color: var(--paper); }
.n-viewer-bar { display: flex; align-items: center; gap: var(--sp-1); padding: var(--sp-3); }
.n-viewer-gap { flex: 1; }
.n-viewer-count { font: var(--fs-xs)/1 var(--mono); letter-spacing: var(--track-w); color: var(--ink-4); padding-left: var(--sp-2); }
.n-viewer-stage { position: relative; display: flex; overflow: hidden; padding: 0 var(--sp-5); }
.n-viewer-pic { display: block; margin: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.n-viewer-pic.n-big { cursor: zoom-in; }
.n-viewer-stage.n-zoomed { overflow: auto; padding: 0; }
.n-zoomed .n-viewer-pic { max-width: none; max-height: none; cursor: zoom-out; }
.n-viewer-cap { margin: 0; padding: var(--sp-3) var(--sp-4) var(--sp-4); text-align: center; }
@media (max-width: 560px) { .n-viewer-stage { padding: 0; } }

@media (prefers-reduced-motion: reduce) {
  .n-caret { animation: none; }
  .n-frame { transition: none; }
  .n-log-pic.n-wipe img { animation: none; }
  .n-log-pic { transition: none; }
}

/* ---------- home ---------- */

html.n-home, .n-home body { margin: 0; height: 100%; background: var(--paper); overflow: hidden; }
.n-home body { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.n-home canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.n-home .n-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 1; pointer-events: none; }
.n-home .n-bar a { pointer-events: auto; }
.n-home .n-links { min-width: 0; }

.hud { position: fixed; bottom: 16px; left: 18px; pointer-events: none; }
#face {
  all: unset; pointer-events: auto; cursor: text; font: var(--fs-s)/1 var(--mono); letter-spacing: var(--track);
  color: var(--ink-4); white-space: pre; padding: var(--sp-2); margin: calc(-1 * var(--pad-x));
}
#face:hover { color: var(--ink-2); }
#face b { font-weight: normal; color: var(--ink-2); }
#face.custom b { color: var(--ink-1); }
#face.egg b { text-decoration: underline; text-underline-offset: 3px; }
#face #set:not(:empty) ~ .ph, #face #set:empty ~ .n-caret { display: none; }
#face:focus-visible { outline: 1px solid rgb(var(--ink) / .5); outline-offset: 4px; }
.hud-r { left: auto; right: 18px; display: flex; flex-direction: column; align-items: flex-end; gap: var(--sp-3); }
.hud-r[hidden], .hud-r [hidden] { display: none; }
.tilt-note {
  max-width: min(34ch, calc(100vw - 36px)); margin: 0 0 36px; padding: var(--sp-3) var(--sp-4);
  background-color: rgb(var(--bg) / .82); text-align: right;
}
.hud-r button { pointer-events: auto; }
#tiltBtn { margin: calc(-1 * var(--pad-x)); }
#ti { position: fixed; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; font-size: 16px; }
@media (pointer: coarse) { #face, #tiltBtn { padding: 11px 7px; margin: -11px -7px; } }
