/* Kiplines: ink on cream paper. One colour family, a lot of room. */
:root {
  --paper: #f5f0e6;
  --paper-evening: #c9c4b8;
  --ink: #1d1a16;
  --soft: #6f675c;
  --line: #d9d1c3;
  --frame: #efe8dc;
  --sans: "Inter Variable", Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  --gutter: 40px;
  --top-h: 80px; /* the header's height: the little world fills the rest of the first screen */
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--ink); }
img { display: block; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: 4px; z-index: 50; }
.skip:focus { left: 12px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 22px var(--gutter); background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(6px); }
.brand img { height: 36px; width: auto; }
.top nav { display: flex; align-items: center; gap: 26px; font-size: 15px; }
.top nav a { white-space: nowrap; }
.top nav a { text-decoration: none; padding-bottom: 2px; border-bottom: 1.5px solid transparent; }
.top nav a[aria-current="true"] { border-bottom-color: var(--ink); }
/* the X account: the site's own button, an ink outline on paper, the same everywhere it appears */
.xlink { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1.5px solid var(--ink); border-radius: 22px; background: var(--paper); color: var(--ink); font-weight: 600; font-size: 14px; line-height: 1; text-decoration: none; white-space: nowrap; transition: background 0.15s, color 0.15s; }
.xlink:hover, .xlink:focus-visible { background: var(--ink); color: var(--paper); }
.stage.evening .xlink { background: var(--paper-evening); }
.stage.evening .xlink:hover { background: var(--ink); }
.xlink .x-mark { width: 15px; height: 15px; fill: currentColor; flex: none; }
.top nav .xlink { padding: 8px 14px; border-bottom: 1.5px solid var(--ink); margin-left: 6px; }
.top nav .xlink[aria-current] { border-bottom-color: var(--ink); }
.intro-x { margin-top: 18px; }

/* ---- the little world: one screen, dragged across ---- */
.world { position: relative; height: calc(100vh - var(--top-h)); height: calc(100svh - var(--top-h)); }
.stage { position: relative; height: 100%; overflow: hidden; background: var(--paper); transition: background 0.6s linear; cursor: grab; touch-action: pan-y pinch-zoom; user-select: none; -webkit-user-select: none; }
.stage.dragging, .stage.dragging .scene .tap { cursor: grabbing; }
.scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.intro { position: absolute; left: var(--gutter); top: 96px; max-width: 420px; transition: opacity 0.4s; }
.intro.away { opacity: 0; pointer-events: none; }
.intro-line { margin: 0 0 12px; font-size: 19px; color: var(--ink); }
.intro-link { display: inline-block; font-size: 15px; text-decoration: none; border-bottom: 1.5px solid var(--ink); padding-bottom: 2px; }
.intro .intro-x { display: inline-flex; }
.intro-link + .intro-x { margin-left: 0; }
.intro .xlink { display: flex; width: max-content; }
.caption { position: absolute; left: 50%; top: 92px; transform: translateX(-50%); width: min(560px, calc(100% - 2 * var(--gutter))); text-align: center; font-weight: 600; font-size: 15px; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0; transition: opacity 0.35s; }
.caption.on { opacity: 1; }
.caption small { display: block; margin-top: 6px; font-weight: 400; font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--soft); }
.sound { position: absolute; left: var(--gutter); bottom: 19px; padding: 6px 0; border: 0; background: none; color: var(--ink); font: 12px/1.5 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer; border-bottom: 1.5px solid transparent; }
.sound[aria-pressed="true"] { border-bottom-color: var(--ink); }
.sound[hidden] { display: none; }
.hint { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); margin: 0; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink); white-space: nowrap; transition: opacity 0.4s; }
.hint .arrow { display: inline-block; animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(6px); } }
.hint.away { opacity: 0; }
.dots { position: absolute; right: var(--gutter); bottom: 30px; margin: 0; padding: 0; list-style: none; display: flex; gap: 10px; }
.dots li { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--ink); }
.dots li.on { background: var(--ink); }
.stage.evening { background: var(--paper-evening); }
.stage.evening .caption small, .stage.evening .hint { color: #4a463f; }

/* the ink */
.world { --p: var(--paper); }
.evening { --p: var(--paper-evening); }
.scene .ink { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.scene .thin { stroke-width: 2.2; }
.scene .hair { stroke-width: 1.4; }
.scene .thick { stroke-width: 5; }
.scene .fill { fill: var(--p); transition: fill 0.6s linear; }
.scene .dot { fill: var(--ink); stroke: none; }
.scene .hit { fill: transparent; stroke: none; }
.scene .tap { cursor: pointer; }
/* a limb is a tube: ink underneath, paper on top */
.scene .tube-o { fill: none; stroke: var(--ink); stroke-width: 10; stroke-linecap: round; stroke-linejoin: round; }
.scene .tube-i { fill: none; stroke: var(--p); stroke-width: 4.6; stroke-linecap: round; stroke-linejoin: round; transition: stroke 0.6s linear; }
.scene .tube-o.neck { stroke-width: 17; }
.scene .tube-i.neck { stroke-width: 11.4; }
.scene .beak { fill: #d9623b; }
.scene .shellfill { fill: #e6b1ab; }
.scene .boltfill { fill: #f2d36b; }
.scene .glow { fill: #f1e2a6; opacity: 0; transition: opacity 0.8s; }
.scene .glow.on { opacity: 0.55; }
.scene .star { opacity: 0; transition: opacity 0.8s; }
.evening .star { opacity: 1; animation: twinkle 3.4s ease-in-out infinite; }
.evening .star.s1 { animation-delay: -1.1s; }
.evening .star.s2 { animation-delay: -2.3s; }
@keyframes twinkle { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .evening .star, .hint .arrow { animation: none; } }

/* reduced motion: the scenes as still pictures, one under the other */
.stills { padding: 0 var(--gutter) 20px; display: grid; gap: 28px; }
.stills figure { margin: 0; }
.stills svg { width: 100%; height: auto; max-height: 420px; display: block; background: var(--paper); border: 1px solid var(--line); border-radius: 3px; }
.stills svg.evening { background: var(--paper-evening); }
.stills figcaption { margin-top: 8px; font-weight: 600; font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; }
.stills figcaption small { display: block; margin-top: 3px; font-weight: 400; font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--soft); }

/* ---- the drawings ---- */
section.drawings, section.about, section.coin { padding: 64px var(--gutter) 24px; scroll-margin-top: 72px; }
section.coin[hidden], .top nav a[hidden] { display: none; }
.coin-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; max-width: 640px; }
.coin-row code { flex: 1 1 260px; min-width: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 3px; background: var(--frame); font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.coin-row button { height: 44px; padding: 0 18px; border: 1.5px solid var(--ink); border-radius: 22px; background: var(--paper); color: var(--ink); font: 600 14px var(--sans); cursor: pointer; }
.coin-row button:disabled { opacity: 0.4; cursor: default; }
.coin-links { margin: 16px 0 0; display: flex; flex-wrap: wrap; gap: 8px 22px; }
.coin-links a { text-decoration: none; border-bottom: 1.5px solid var(--ink); padding-bottom: 2px; }
.coin-small { max-width: 520px; margin: 22px 0 0; font-size: 13px; color: var(--soft); }
h2 { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.sub { margin: 0 0 28px; color: var(--soft); }
.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px 20px; }
.grid button { width: 100%; margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.paper { aspect-ratio: 4 / 3; background: var(--frame); border: 1px solid var(--line); border-radius: 3px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.paper img { max-width: 90%; max-height: 90%; width: auto; height: auto; object-fit: contain; }
.grid figcaption { margin-top: 9px; font-size: 13px; line-height: 1.4; }
.grid figcaption:empty::before { content: "untitled"; color: var(--soft); }
.about .bio { max-width: 520px; margin: 0; font-size: 17px; line-height: 1.6; }
.about .links { margin: 22px 0 0; }

/* ---- the large view ---- */
.viewer { position: fixed; inset: 0; z-index: 40; background: color-mix(in srgb, var(--paper) 94%, #000 6%); display: grid; grid-template-columns: 64px minmax(0, 1fr) 64px; align-items: center; padding: 56px 16px 24px; }
.viewer[hidden] { display: none; }
.viewer-figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; min-height: 0; height: 100%; justify-content: center; }
.viewer-figure img { max-width: 100%; max-height: calc(100vh - 160px); width: auto; height: auto; object-fit: contain; border: 1px solid var(--line); border-radius: 3px; background: var(--frame); }
.viewer-figure figcaption { font-size: 14px; text-align: center; }
.viewer button { height: 44px; min-width: 44px; border: 1px solid var(--line); border-radius: 22px; background: var(--paper); color: var(--ink); font: 600 18px var(--sans); cursor: pointer; }
.viewer-close { position: absolute; top: 14px; right: 16px; }
.viewer-prev { justify-self: start; }
.viewer-next { justify-self: end; }

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 16px; }
  .grid figcaption { font-size: 12px; }
}
@media (max-width: 600px) {
  :root { --gutter: 18px; --top-h: 58px; }
  .top { padding: 14px var(--gutter); }
  .brand img { height: 30px; }
  .top nav { gap: 12px; font-size: 14px; min-width: 0; }
  .top nav .xlink { padding: 8px 10px; margin-left: 0; }
  .top nav .xlink span { display: none; }
  .top nav .xlink .x-mark { width: 14px; height: 14px; }
  .intro { top: 76px; }
  .intro-line { font-size: 17px; }
  .caption { top: 70px; font-size: 13px; }
  .caption small { font-size: 12px; }
  .hint { bottom: 62px; }
  section.drawings, section.about, section.coin { padding-top: 44px; }
  .viewer { grid-template-columns: 1fr; padding: 56px 12px 90px; }
  .viewer-prev, .viewer-next { position: absolute; bottom: 24px; }
  .viewer-prev { left: 16px; }
  .viewer-next { right: 16px; }
  .viewer-figure img { max-height: calc(100vh - 200px); }
}
@media (max-width: 420px) {
  .brand img { height: 26px; }
  .top nav { gap: 10px; font-size: 13px; }
  .top nav .xlink { padding: 7px 9px; }
  .top nav .xlink .x-mark { width: 13px; height: 13px; }
}
