@font-face {
  font-family: "Fira Code";
  src: url("../assets/fonts/Fira_Code_v6.2/woff2/FiraCode-Regular.woff2") format("woff2");
  font-weight: 400 500;
  font-display: swap;
}

/* The homepage is one desk filling the first screen, with the map it rests on
   coming into focus below. 1em = --unit, tied to the viewport, so sheets and
   objects scale together; offsets are percentages so they spread to the edges
   of any landscape screen. */
* { box-sizing: border-box; }
/* The colour sits on the root only: a body background would cover the map,
   which is stacked below the page's other layers. */
html { overflow-x: clip; background: #92a9af; }
body { position: relative; margin: 0; }
figure { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; border-radius: 0; }

/* The wash under the desk. Blurring the image itself is cheaper than a
   backdrop-filter over it; the negative inset hides the transparent fringe the
   blur leaves at the edges. It runs half a screen past the desk, thinning to
   bare paper before its mask breaks it up like a watercolour bleed and the
   sharp map shows through. */
.backdrop {
  position: absolute;
  inset: -2vw -2vw auto;
  height: 150vh;
  background: linear-gradient(rgba(236, 232, 214, 0.3) 62%, rgba(236, 232, 214, 0.85) 82%), url("../assets/desk/open-world.jpg") center / cover;
  filter: blur(0.6vw) saturate(0.85);
  mask: url("../assets/desk/wash-edge.svg") center / 100% 100% no-repeat;
}
/* The map starts behind the last fifth of the desk, hidden by the wash, and
   fades in so its top edge never shows through a gap in the bleed. A mask
   makes a stacking layer, which would paint over the wash without z-index. */
.map {
  position: relative;
  z-index: -1;
  display: block;
  width: 100%;
  margin-top: -20vh;
  mask-image: linear-gradient(transparent, #000 15vh);
}

.table {
  --unit: min(1vw, 1.7778vh);
  --ink: #2c2418;
  position: relative;
  height: 100vh;
  /* Sheets that hang off the bottom of the desk continue down the page. */
  overflow-x: clip;
  font: 400 var(--unit) / 1.7 "Fira Code", monospace;
  color: var(--ink);
}
/* The vignette belongs to the window, not the desk, so it stays while scrolling. */
.table::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 10em 1em rgba(10, 20, 30, 0.35);
}

/* The light comes from the upper right, so every shadow falls lower left.
   Hover lifts a sheet clearly and stirs a print; loose objects stay put. */
.paper, .print, .object {
  position: absolute;
  rotate: var(--tilt, 0deg);
  filter: drop-shadow(-0.5em 0.7em 0.7em rgba(0, 0, 0, 0.5));
  transition: translate 0.25s ease, scale 0.25s ease, rotate 0.25s ease, filter 0.25s ease;
}
/* Some objects belong to a sheet: the quill to Writing, the compass and the
   spyglass to Places traversed. Hovering any member lifts the whole group. */
.paper:hover, .paper:focus-visible,
.table:has(:is(.writing, .quill):is(:hover, :focus-visible)) :is(.writing, .quill),
.table:has(:is(.places, .compass, .spyglass):is(:hover, :focus-visible)) :is(.places, .compass, .spyglass) {
  translate: 0 -0.4em;
  scale: 1.015;
  rotate: calc(var(--tilt, 0deg) * 0.75);
  filter: drop-shadow(-0.7em 1em 0.9em rgba(0, 0, 0, 0.45));
}
.print:hover { translate: 0 -0.12em; rotate: calc(var(--tilt, 0deg) + 0.6deg); }
.paper:focus-visible { outline: 0.15em solid #14606f; outline-offset: 0.3em; }
.object { height: auto; }

.print { z-index: 1; padding: 0.6em 0.6em 1.6em; background: #f1ead6; }
.print img { display: block; width: 100%; }
.streets { --tilt: -8deg; left: -1%; top: -6%; width: 15em; }
.balloons { --tilt: 4deg; right: -1%; top: -5%; width: 30em; }
.bedroom { --tilt: -6deg; right: -1%; top: 75%; width: 21em; }
/* These lie on the lower half of the map, which starts 80vh down and is sized
   by width, so their offsets follow it rather than the desk's height. */
.train { --tilt: -5deg; left: 21.5%; top: calc(80vh + 45vw); width: 15em; }
.friendship { --tilt: 3deg; left: 37%; top: calc(80vh + 48vw); width: 22em; }
.desk { --tilt: 6deg; right: 6%; top: calc(80vh + 52vw); width: 22em; }
.meme { --tilt: 5deg; left: 59%; top: calc(80vh + 21vw); width: 13em; }
/* The borsch is painted on newspaper, so it lies as a bare sheet with no mount. */
.borsch { --tilt: -4deg; left: 57%; top: calc(80vh + 22vw); width: 17em; padding: 0; }

.paper {
  padding: 2em 2.2em;
  overflow: auto;
  cursor: pointer;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.25 0 0 0 0 0.1 0 0 0 0.22 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 85% 10%, rgba(255, 244, 214, 0.9), transparent 60%),
    radial-gradient(ellipse at 10% 95%, rgba(150, 110, 60, 0.35), transparent 55%),
    #e6d9b8;
}
/* A sheet on the desk shows only its first page; the rest fades out and is
   read by opening the sheet. */
.desk-ready .paper { overflow: hidden; }
.desk-ready .paper::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 4.5em;
  background: linear-gradient(transparent, #dccda8);
}
/* The intro is a calling card, not a note: it is as tall as its few lines and
   nothing fades out. Opening it reads the whole About page instead. */
.intro { --tilt: -2deg; left: 28.3%; top: 5%; width: 36em; padding-bottom: 3em; z-index: 3; }
.desk-ready .intro::after { display: none; }
.intro .prose > :last-child { margin-bottom: 0; }
.writing { --tilt: -6deg; left: 13%; top: 33%; width: 19em; height: 24em; z-index: 2; }
.research { --tilt: 4deg; left: 63%; top: 27%; width: 22em; height: 23em; z-index: 2; }
.places { --tilt: -4deg; left: 61%; top: 70%; width: 22em; height: 15em; z-index: 4; }
.shelves { --tilt: 3deg; left: 50%; top: 99%; width: 21em; height: 16em; z-index: 5; }
.friends { --tilt: 6deg; left: 25%; top: 95%; width: 25em; height: 16em; z-index: 4; padding: 1.4em 1.6em; }
/* Quotes lie on the map among the lower prints. There is a place for three. */
.quote-1 { --tilt: -3deg; left: 34%; top: calc(80vh + 23vw); width: 21em; height: 17em; z-index: 2; }
.quote-2 { --tilt: 4deg; left: 70%; top: calc(80vh + 41vw); width: 18em; height: 14em; z-index: 3; }
.quote-3 { --tilt: -5deg; right: 3%; top: calc(80vh + 26vw); width: 22em; height: 18em; z-index: 2; }

/* Engravings have white fills; multiply prints them into the paper. */
.engraving { mix-blend-mode: multiply; opacity: 0.7; }
/* They float beside the text below the heading; the shape keeps the top
   margin from narrowing the heading's line. */
.engraving { float: right; margin: 3.2em 0 0 0.6em; shape-outside: inset(3.2em 0 0 0); }
/* The galvanometer sits beside the title so the pictures start right under it. */
.research .engraving { position: absolute; float: none; left: 13.5em; top: 0.5em; width: 5em; margin: 0; }
.shelves .engraving { width: 5.5em; }
/* Places is too narrow to wrap text around a figure; it sits by the heading. */
.places .engraving { position: absolute; float: none; right: 1.6em; top: 1.6em; width: 6em; margin: 0; opacity: 0.55; }

.globe { left: 1%; top: 27%; width: 11em; z-index: 6; }
.armillary { left: 67%; top: calc(80vh + 57vw); width: 8em; z-index: 6; }
.butterfly-case { --tilt: -5deg; left: 15%; top: 1%; width: 11em; z-index: 6; }
.bottle { --tilt: 3deg; left: 26%; top: 60%; width: 4.4em; z-index: 6; }
.nadia { --tilt: 4deg; right: 4%; top: 46%; width: 11em; z-index: 6; }
.quill { left: 0; top: 62%; width: 27em; z-index: 7; }
.compass { --tilt: 12deg; left: 79%; top: 64%; width: 8em; z-index: 7; }
.spyglass { --tilt: -14deg; left: 61%; top: 90%; width: 24em; z-index: 8; }
/* The crow perches on the top right corner of the borsch. */
.crow { left: 71.5%; top: calc(80vh + 17vw); width: 6em; z-index: 6; }
/* Its motto, on a strip of paper tucked beside it. */
.crow-label { --tilt: 5deg; left: 76%; top: calc(80vh + 16.2vw); z-index: 6; margin: 0; padding: 0.25em 0.7em; background: #f1ead6; font-size: 0.85em; font-style: italic; white-space: nowrap; filter: drop-shadow(-0.2em 0.3em 0.3em rgba(0, 0, 0, 0.4)); }
.feather-light { --tilt: -18deg; --phase: 0.33; left: 23.5%; top: 52%; width: 9em; z-index: 6; }
.feather-dark { --tilt: 26deg; --phase: 0.67; left: 60%; top: 33%; width: 4.2em; z-index: 6; }
/* The red feather has blown down onto the map, by the windmill. */
.feather-red { --tilt: 24deg; --phase: 0; left: 72%; top: calc(80vh + 30vw); width: 7em; z-index: 6; }
/* Fallen leaves: the yellow one on the train print, the rainbow one between it
   and the friendship print. They bob with the feathers. */
.ginkgo-yellow { --tilt: -19deg; --phase: 0.5; left: 18%; top: calc(80vh + 42vw); width: 10em; z-index: 6; }
.ginkgo-rainbow { --tilt: 18deg; --phase: 0.15; left: 32.5%; top: calc(80vh + 58vw); width: 7.5em; z-index: 6; }

/* Feathers bob on a slow cycle. Easing each half-cycle with a sine curve makes
   the whole motion sinusoidal. --phase is each feather's offset into the cycle
   as a fraction of it, so no two rise together; drift.js sets it at random. */
.drifter img {
  --period: 4s;
  animation: bob var(--period) cubic-bezier(0.37, 0, 0.63, 1) infinite;
  animation-delay: calc(var(--phase, 0) * var(--period) * -1);
}
@keyframes bob {
  0%, 100% { translate: 0 -0.25em; }
  50% { translate: 0 0.25em; }
}
/* The bob is off for the desk's own feathers and leaves for now; only the
   gusts keep it. A resting one floats up while hovered and settles back. To
   bring the bob back, add this list to the `.drifter img` rule above. */
:is(.feather-red, .feather-light, .feather-dark, .ginkgo-yellow, .ginkgo-rainbow) {
  transition: translate 0.7s cubic-bezier(0.37, 0, 0.63, 1), rotate 0.7s cubic-bezier(0.37, 0, 0.63, 1);
}
:is(.feather-red, .feather-light, .feather-dark, .ginkgo-yellow, .ginkgo-rainbow):hover {
  translate: 0 -1.6em;
  rotate: calc(var(--tilt) + 6deg);
}
/* Two kites fly at the left of the map below the desk, the phoenix above the
   girl's head. They rise and fall further and more slowly than a feather,
   leaning as they go, and fly above the leaves that drift across. */
.kite-phoenix { --tilt: -10deg; --phase: 0; left: 21%; top: calc(80vh + 18vw); width: 12.5em; z-index: 10; }
.kite-swallow { --tilt: -8deg; --phase: 0.4; left: 5%; top: calc(80vh + 15vw); width: 16em; z-index: 10; }
/* Each string is its own small drawing, starting under the kite's body, which
   hides that end as the kite moves. Both sag down to one unseen hand on
   the left edge. A string ends at its box's bottom, top + height: the phoenix's
   at 16vw + 22em below the map's start, the swallow's 0.5em lower than that. */
.kite-strings { position: absolute; z-index: 5; pointer-events: none; }
.kite-strings path {
  fill: none;
  stroke: rgba(255, 255, 255, 0.65);
  stroke-width: 1.5px;
  stroke-dasharray: 7 6;
  vector-effect: non-scaling-stroke;
}
.phoenix-string { left: 0; top: calc(80vh + 15.5vw + 7em); width: calc(21% + 6.25em); height: calc(0.5vw + 15em); }
.swallow-string { inset: calc(80vh + 10vw + 9em) auto auto 0; width: 11%; height: calc(6vw + 17em); }
.kite-phoenix, .kite-swallow {
  --period: 7s;
  animation: soar var(--period) cubic-bezier(0.37, 0, 0.63, 1) infinite;
  animation-delay: calc(var(--phase) * var(--period) * -1);
}
/* They climb toward the top right corner they fly in, and sink away from it. */
@keyframes soar {
  0%, 100% { translate: 0.3em -0.9em; rotate: calc(var(--tilt) + 3deg); }
  50% { translate: -0.3em 0.9em; rotate: calc(var(--tilt) - 3deg); }
}
/* drift.js places a drifting feather off the top left corner and carries it across. */
.drifter {
  position: absolute;
  z-index: 9;
  pointer-events: none;
}
/* A drifting leaf turns, and a drop-shadow on it would turn too, away from the
   light. Its shadow is instead a blackened copy of the image that turns with
   the leaf from a fixed offset to the lower left, like every other shadow. */
.drifter img { display: block; width: 100%; }
.drifter .shade {
  position: absolute;
  left: -0.8em;
  top: 1.2em;
  filter: brightness(0) blur(0.4em);
  opacity: 0.3;
}

/* Typography shared by the sheets on the desk and the opened reading sheet. */
.prose { font-size: 0.86em; overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose h1 { margin: 0 0 0.5em; font-size: 1.9em; line-height: 1.3; font-weight: 500; }
.prose h2 { margin: 0 0 0.7em; font-size: 1.35em; font-weight: 500; text-decoration: underline; text-underline-offset: 0.3em; }
.prose h3 { margin: 1.3em 0 0.4em; font-size: 1em; font-weight: 500; }
.prose p, .prose ul, .prose details { margin: 0 0 0.8em; }
.prose ul { padding-left: 1.4em; list-style-type: "– "; }
.prose li { margin: 0.2em 0; }
.prose a { color: inherit; text-underline-offset: 0.25em; }
.prose a:hover { color: #14606f; }
.prose small, .prose blockquote, .prose .letterhead { font-size: 0.85em; opacity: 0.7; }
.prose .letterhead { margin: 0 0 0.3em; letter-spacing: 0.08em; }
.prose blockquote { margin: 0.8em 0; padding-left: 1em; border-left: 1px solid currentColor; }
.prose blockquote p { margin: 0; }
.prose code { font: inherit; }
.prose hr { border: 0; border-top: 1px solid currentColor; opacity: 0.4; margin: 1.2em 0; }
.prose summary { cursor: pointer; }
/* A list whose items are pictures lies as a grid of small prints, each tilted
   a little and captioned by its title, as photographs pasted into a notebook. */
.prose ul:has(> li > img, > li > a > img) { clear: both; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.3em 1.1em; padding: 0.4em 0 0; list-style: none; }
.prose li:has(> img, > a > img) { margin: 0; font-size: 0.9em; line-height: 1.4; }
.prose li > img, .prose li > a > img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; margin-bottom: 0.5em; border: 0.3em solid #f4ecd6; box-shadow: -0.15em 0.3em 0.6em rgba(44, 36, 24, 0.35); rotate: -1.5deg; transition: rotate 0.2s ease, translate 0.2s ease; }
.prose li:nth-child(even) > img, .prose li:nth-child(even) > a > img { rotate: 1.2deg; }
.prose li > a:hover > img { rotate: 0deg; translate: 0 -0.2em; }
@media (max-width: 600px) { .prose ul:has(> li > img, > li > a > img) { grid-template-columns: repeat(2, 1fr); } }

/* Once the shader has redrawn a sheet, the DOM text stays in place but
   invisible. The host is oversized because the shader draws at 0.9 scale. */
.shaded { background: none; }
.shaded > :not(.sheet-shader), .desk-ready .shaded::after { opacity: 0; }
.sheet-shader { position: absolute; inset: -5.56%; }

@media (prefers-reduced-motion: reduce) {
  .paper, .print, .object { transition: none; }
  .object { animation: none; }
}
