/* The resources pages: the shelf of folders, a folder's cards, and the
   doodle sheet. Shared cursors and tools are in site.css. */

:root {
  --ink: #000000;
  --paper: #ffffff;
  --wash: rgba(0, 0, 0, 0.04);
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); }
body { font: 15px/1.5 var(--sans); overflow-x: hidden; }
/* the page's frame always reaches the bottom of the window, even when the
   content is short (a % height can't, since html has no fixed height) */
body { min-height: 100vh; min-height: 100dvh; }

a { color: inherit; }
:focus-visible { outline: 1px dotted var(--ink); outline-offset: 4px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* top: back home, the page's name */
.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 0 8px;
  font: 12px/1 var(--mono);
}
.top a { text-decoration: none; }
.top a:hover { text-decoration: underline; text-underline-offset: 3px; }
.chip {
  display: inline-block;
  padding: 3px 5px 2px;
  font: 11px/1 var(--mono);
  color: var(--paper);
  background: var(--ink);
  white-space: nowrap;
}

.head { padding: clamp(40px, 9vh, 88px) 0 clamp(28px, 5vh, 48px); }
.head h1, .head h2 {
  margin: 0;
  font: 600 clamp(32px, 6vw, 56px)/1 var(--sans);
  letter-spacing: -0.03em;
}
.head p { margin: 12px 0 0; max-width: 44ch; color: rgba(0, 0, 0, 0.6); }
.back {
  display: inline-block;
  margin: 0 0 20px;
  font: 12px/1 var(--mono);
  text-decoration: none;
}
.back:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- the shelf of folders ---------- */
.shelf {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(40px, 6vw, 56px) clamp(20px, 3vw, 36px);
  padding: 24px 0 64px;
}
/* four folders to a row on a wide screen, two on a tablet, one on a phone */
@media (min-width: 520px) { .shelf { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .shelf { grid-template-columns: repeat(4, 1fr); } }
.folder {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  color: var(--ink);
  text-decoration: none;
  perspective: 700px;
  -webkit-tap-highlight-color: transparent;
}
.folder svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.folder path {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
/* the links inside, peeking out over the front */
.sheets { position: absolute; inset: 14% 8% 10%; }
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid var(--ink);
  background: repeating-linear-gradient(0deg, transparent 0 9px, rgba(0, 0, 0, 0.12) 9px 10px) var(--paper);
  transform: translate(var(--x, 0), 0) rotate(var(--r, 0deg));
  transition: transform 0.45s var(--ease);
}
.sheet:nth-child(1) { --r: -4deg; --x: -3%; }
.sheet:nth-child(2) { --r: 3deg; --x: 4%; }
.sheet:nth-child(3) { --r: -1deg; --x: 0%; }
.front-wrap {
  position: absolute;
  inset: 30% 0 0;
  transform-origin: 50% 100%;
  transition: transform 0.45s var(--ease);
}
.label {
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 12%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.label b { font: 600 clamp(17px, 2.2vw, 20px)/1.1 var(--sans); letter-spacing: -0.01em; }
.label span { font: 11px/1 var(--mono); color: rgba(0, 0, 0, 0.55); white-space: nowrap; }
.folder:hover .sheet, .folder:focus-visible .sheet { transform: translate(var(--x, 0), -16%) rotate(calc(var(--r, 0deg) * 1.6)); }
.folder:hover .front-wrap, .folder:focus-visible .front-wrap { transform: rotateX(-24deg); }
.folder:focus-visible { outline-offset: 10px; }

/* ---------- an open folder: its links as cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 40px 28px;
  padding: 8px 0 64px;
}
.card {
  position: relative;
  animation: rise 0.5s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 50ms);
}
/* the title's link covers the whole card, so the card is one link */
.card h2 a { text-decoration: none; }
.card h2 a::after { content: ""; position: absolute; inset: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.shot {
  position: relative;
  aspect-ratio: 1200 / 630;   /* the usual Open Graph size */
  border: 1px solid var(--ink);
  background: var(--wash);
  overflow: hidden;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.shot img, .sheet img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.shot .none {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 600 clamp(20px, 3vw, 26px)/1 var(--sans);
  letter-spacing: -0.02em;
  background: repeating-linear-gradient(0deg, transparent 0 13px, rgba(0, 0, 0, 0.08) 13px 14px) var(--paper);
}
.card:hover .shot, .card:focus-within .shot { transform: translate(-3px, -3px); box-shadow: 3px 3px 0 var(--ink); }
.card h2 a:focus-visible { outline: none; }
.meta { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 12px; }
.meta h2 { margin: 0; font-size: 15px; font-weight: 600; }
.meta .chip { flex: none; }
.card p { margin: 4px 0 0; color: rgba(0, 0, 0, 0.6); font-size: 14px; }

.view { animation: fade 0.3s ease both; }
/* one view shows at a time: the shelf here, a folder on its own page */
.js .view:not(.on) { display: none; }
.js .folder-view .cards { padding-top: 8px; }
@keyframes fade { from { opacity: 0; } }

/* the note at the bottom: tell me how a link worked out, on X */
.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 32px;
  margin: 0 0 72px;
  padding: 12px 12px 12px 18px;
  border: 1px solid var(--ink);
}
.banner b { display: block; font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.banner p { margin: 1px 0 0; color: rgba(0, 0, 0, 0.6); font-size: 13px; line-height: 1.4; }
.say {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 9px;
  font: 12px/1 var(--mono);
  color: var(--paper);
  background: var(--ink);
  text-decoration: none;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.say:hover, .say:focus-visible { transform: translate(-3px, -3px); box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.35); }

/* ---------- Paint, as on the home page: pencil, eraser, the eye ---------- */
body { position: relative; }
/* text can be selected and copied, except while a tool is down */
.drawing body, .blank body { -webkit-user-select: none; user-select: none; }
/* the sheet lies in a box the size of the page, which cuts off whatever
   is drawn past the page's end, so the sheet never makes the page longer */
.doodle-box { position: absolute; inset: 0; z-index: 5; overflow: hidden; pointer-events: none; }
.doodle { left: 0; top: 0; }
.tools {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 10;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
}
html:not(.js) .tools { display: none; }
/* while you read down the page the toolbox steps out of the way: its tools
   tip over and drop out one after another, and when you scroll up they
   spring back in turn, the box first */
.tools { transition: translate 0.55s cubic-bezier(.34, 1.45, .64, 1); }
.tools .tool {
  transition: translate 0.55s cubic-bezier(.34, 1.6, .64, 1), rotate 0.55s cubic-bezier(.34, 1.6, .64, 1);
  transition-delay: calc(var(--n) * 70ms + 60ms);
}
.tools .tool:nth-child(1) { --n: 0; --tilt: -16deg; }
.tools .tool:nth-child(2) { --n: 1; --tilt: 12deg; }
.tools .tool:nth-child(3) { --n: 2; --tilt: -9deg; }
.tools-away .tools {
  translate: 0 calc(100% + 48px);
  pointer-events: none;
  transition: translate 0.32s cubic-bezier(.55, 0, .8, .2) 0.16s;
}
.tools-away .tools .tool {
  translate: 0 70%;
  rotate: var(--tilt);
  transition-duration: 0.28s;
  transition-timing-function: cubic-bezier(.55, 0, .8, .2);
  transition-delay: calc(var(--n) * 45ms);
}
.tool .ink { display: block; width: 100%; height: 100%; overflow: visible; }
.tool .ink path { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.pixel .tool .ink { visibility: hidden; }
.tool:focus-visible { outline: 1px dotted var(--ink); outline-offset: 0; }
/* the eye pressed: the page steps aside for drawing, and a finger draws too */
.blank .wrap { visibility: hidden; }
.blank, .blank body { touch-action: none; }
/* drawing on a touch screen: one finger draws, two fingers scroll and zoom */
.drawing, .drawing body { touch-action: pinch-zoom; }
.wrap { padding-bottom: 64px; }
/* the toolbox as the machine sees it, as on the home page: every box
   outlined, its tag on a chip */
.box { position: relative; outline: 1px solid var(--ink); background-color: rgba(0, 0, 0, 0.025); }
/* the page's own box: its frame on the window's edge, its tag in the corner */
.page.box { outline-offset: -1px; }
.page.box::before { left: 0; top: 0; bottom: auto; }
.tools.box { position: fixed; background: linear-gradient(rgba(0, 0, 0, 0.025), rgba(0, 0, 0, 0.025)) var(--paper); }
.box::before {
  content: attr(data-tag);
  position: absolute;
  left: -1px;
  bottom: 100%;
  z-index: 2;
  padding: 2px 4px 1px;
  font: 10px/1 var(--mono);
  color: var(--paper);
  background: var(--ink);
  white-space: nowrap;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
