/*
 * davidsteinmetz.io
 *
 * Posts are books on a shelf (shelf.js). The active book is pulled out and
 * turned so its cover faces you; opening it grows a sheet of paper out of the
 * cover and the cover bleeds in beside the text like spreading ink.
 *
 * Type: D-DIN (an open revival of DIN 1451, the German road-sign face) for
 * spines, labels and cover titles; Newsreader for reading.
 */

@font-face { font-family: "D-DIN"; font-weight: 700; font-display: swap; src: url("/assets/fonts/D-DIN-Bold.woff2") format("woff2"); }
@font-face { font-family: "D-DIN Condensed"; font-weight: 700; font-display: swap; src: url("/assets/fonts/D-DINCondensed-Bold.woff2") format("woff2"); }

:root {
  --paper: #e3e6e9;
  --sheet: #eef0f2;
  --ink: #12163a;
  --muted: #5b6176;
  --accent: #c8553d;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --H: min(48vh, 30vw);
  --sans: "D-DIN", "DIN Alternate", system-ui, sans-serif;
  --cond: "D-DIN Condensed", "D-DIN", system-ui, sans-serif;
  --serif: "Newsreader", Georgia, serif;
}
@media (max-width: 767px) { :root { --H: min(62vw, 42svh); } }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
}
.js body:not(.plain) { height: 100%; overflow: hidden; user-select: none; }
@media (pointer: fine) { .js body:not(.plain), .js body:not(.plain) button, .js body:not(.plain) a { cursor: none; } }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.lbl { font-family: var(--sans); font-weight: 700; font-size: 13px; letter-spacing: .03em; }

/* ---------- Top bar ---------- */
.top {
  position: fixed; top: 0; left: 0; right: 0; height: 84px; padding: 0 32px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; z-index: 30;
}
.top a { text-decoration: none; }
.top a.lbl:hover { text-decoration: underline; text-underline-offset: 3px; }
.logo { font-family: var(--sans); font-weight: 700; font-size: 24px; letter-spacing: .01em; }
.top .since { color: var(--muted); }
.top .about { justify-self: end; }

/* ---------- The shelf ---------- */
.shelf {
  position: fixed; left: 0; right: 0;
  top: calc(46% - var(--H) / 2 - 60px); height: calc(var(--H) + 120px);
  perspective: 2200px; perspective-origin: 50% 50%; touch-action: pan-y; z-index: 10;
}
.stage { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-style: preserve-3d; }
.plank {
  position: fixed; left: 0; right: 0; top: calc(46% + var(--H) / 2 + 1px);
  height: 1px; background: rgba(18, 22, 58, .55); z-index: 5;
}
.book { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-style: preserve-3d; will-change: transform; }
.face {
  position: absolute; height: var(--H); top: calc(var(--H) / -2);
  backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 2px; overflow: hidden;
}
.face::after { content: ""; position: absolute; inset: 0; background: #000; opacity: var(--shade, 0); pointer-events: none; }
.sp {
  background: var(--c); color: var(--fg);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 14px 0 12px;
  box-shadow: inset 2px 0 0 rgba(255, 255, 255, .12), inset -3px 0 0 rgba(0, 0, 0, .14);
}
.sp .t {
  writing-mode: vertical-rl; font-family: var(--cond); font-weight: 700;
  font-size: calc(var(--H) * .066); letter-spacing: .02em; white-space: nowrap;
  flex: 1; display: flex; align-items: center;
}
.sp .mark { font-family: var(--serif); font-style: italic; font-size: calc(var(--H) * .045); }
.sp .band { width: 100%; height: 3px; background: var(--fg); opacity: .5; }
.cv { box-shadow: 0 30px 60px -28px rgba(10, 14, 40, .55); }
/* The back cover: plain cloth, a touch darker, as if turned from the light. */
.bk {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .12), transparent 12%),
    var(--c);
  --shade: .22;
}
.bk::before {
  content: ""; position: absolute; left: 12%; right: 12%; bottom: 8%; height: 2px;
  background: var(--fg); opacity: .35;
}
.locked .bk {
  background:
    linear-gradient(90deg, transparent 45%, #6b4a2a 45%, #6b4a2a 51%, transparent 51%),
    linear-gradient(0deg, transparent 47.5%, #6b4a2a 47.5%, #6b4a2a 51.5%, transparent 51.5%),
    #b8925f;
}
.locked .bk::before { display: none; }
.cv svg { display: block; width: 100%; height: 100%; }

/* Locked: wrapped in kraft paper and string. */
.locked .sp {
  background:
    linear-gradient(90deg, transparent 46%, #6b4a2a 46%, #6b4a2a 54%, transparent 54%),
    repeating-linear-gradient(170deg, rgba(0, 0, 0, .04) 0 3px, transparent 3px 7px),
    #b8925f;
}
.locked .sp .t { background: #b8925f; padding: 8px 0; }

/* ---------- Caption and arrows ---------- */
.caption {
  position: fixed; left: 0; right: 0; top: calc(46% + var(--H) / 2 + 34px);
  display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none; z-index: 20;
}
.mask { position: relative; overflow: hidden; width: min(92vw, 760px); text-align: center; }
.mask > span { display: block; }
.mask > span + span { position: absolute; left: 0; right: 0; top: 0; }
.cap-title { font-size: 34px; line-height: 1.12; letter-spacing: -.01em; }
.cap-meta { color: var(--muted); }

.arrow {
  position: fixed; top: calc(46% + var(--H) / 2 + 36px); width: 44px; height: 44px;
  display: grid; place-items: center; z-index: 25;
}
.arrow.prev { left: 20px; }
.arrow.next { right: 20px; }
.arrow svg { width: 22px; height: 12px; }

/* ---------- Without JavaScript: a plain list ---------- */
.index { padding: 120px 7vw 40px; }
.index ul { list-style: none; padding: 0; margin: 16px 0 0; }
.index li { font-size: 28px; margin: 0 0 12px; }
.index li .lbl { color: var(--muted); margin-left: 8px; }
.shelf, .plank, .caption, .arrow, .cursor { display: none; }
.js .shelf, .js .plank, .js .caption, .js .arrow { display: block; }
.js .arrow { display: grid; }
.js .caption { display: flex; }
/* With JavaScript the list stays for screen readers only. */
.js .index {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Paper grain ---------- */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 40; mix-blend-mode: multiply; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .36 0 0 0 0 .40 0 0 0 0 .46 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Cursor ---------- */
.cursor {
  position: fixed; left: 0; top: 0; width: 62px; height: 62px; margin: -31px 0 0 -31px;
  pointer-events: none; z-index: 100;
}
@media (pointer: fine) { .js .cursor { display: block; } }
.cursor .ring {
  position: absolute; inset: 0; border: 1.5px solid var(--ink); border-radius: 50%;
  transition: transform .5s var(--ease), background-color .4s var(--ease), border-color .4s var(--ease);
}
.cursor .dot {
  position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%;
  background: var(--ink); transition: transform .4s var(--ease);
}
.cursor .say {
  position: absolute; inset: 0; display: grid; place-items: center; color: #fff;
  font-family: var(--sans); font-weight: 700; font-size: 13px;
  transform: scale(0); transition: transform .45s var(--ease);
}
.cursor.spine .ring { transform: scale(.72); }
.cursor.btn .ring { transform: scale(.55); }
.cursor.btn .dot { transform: scale(0); }
.cursor.read .ring, .cursor.lock .ring { transform: scale(1.6); background: var(--ink); border-color: var(--ink); }
.cursor.lock .ring { background: var(--accent); border-color: var(--accent); }
.cursor.read .dot, .cursor.lock .dot { transform: scale(0); }
.cursor.read .say, .cursor.lock .say { transform: scale(1); }
/* Over the reading sheet the cursor is just a dot-and-ring; text is selectable. */
.cursor.reading .ring { transform: scale(.4); }

/* ---------- Reading sheet ---------- */
.detail {
  position: fixed; inset: 0; z-index: 60; background: var(--sheet); visibility: hidden;
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 5vw;
  padding: 96px 6vw 48px 7vw;
}
.detail.is-open { visibility: visible; }
/* Top right: where people expect to close things, and in reach of a right thumb. */
.close {
  position: fixed; top: 22px; right: 22px; z-index: 2; padding: 14px 12px;
  text-decoration: none; background: var(--sheet); border-radius: 2px;
}
.close:hover { text-decoration: underline; text-underline-offset: 3px; }
.text { overflow-y: auto; padding-right: 12px; user-select: text; max-height: 100%; }
.text .m { overflow: hidden; }
.text .m > * { display: block; }
/* Spacing sits outside the masks, so a line waiting to rise stays hidden. */
.text .m:nth-child(1) { margin-bottom: 18px; }
.text .m:nth-child(2) { margin-bottom: 32px; }
.d-meta { color: var(--muted); margin: 0; }
.d-title { font-weight: 400; font-size: clamp(44px, 5.4vw, 84px); line-height: 1; letter-spacing: -.025em; margin: 0; padding-bottom: .08em; }
.plain-main .d-title { margin-bottom: 32px; }
.d-body p, .d-body li { font-size: 19px; line-height: 1.6; max-width: 36em; }
.d-body p { margin: 0 0 1em; }
.d-body h2, .d-body h3, .d-body h4 { font-style: italic; font-weight: 400; font-size: 22px; margin: 0 0 1em; }
.d-body blockquote { margin: 0 0 1em; padding-left: 1em; border-left: 2px solid var(--accent); }
.poster { align-self: center; justify-self: center; height: min(100%, 78vh); aspect-ratio: 2 / 3; }
.poster svg { width: 100%; height: 100%; display: block; }

/* The cover on its way back to the shelf when a book closes. */
.fly {
  position: fixed; z-index: 70; pointer-events: none; transform-origin: 50% 50%;
  border-radius: 2px; overflow: hidden; will-change: transform;
  box-shadow: 0 30px 60px -28px rgba(10, 14, 40, .55);
}
.fly svg { display: block; width: 100%; height: 100%; }

/* ---------- Plain pages (about, 404) ---------- */
.plain .top { position: static; }
.plain-main { padding: 40px 7vw 80px; max-width: calc(14vw + 760px); }

@media (max-width: 767px) {
  .top { height: 64px; padding: 0 16px; }
  .top .since { visibility: hidden; }
  .logo { font-size: 20px; }
  .cap-title { font-size: 26px; }
  .arrow.prev { left: 6px; }
  .arrow.next { right: 6px; }
  .detail { grid-template-columns: 1fr; overflow-y: auto; padding: 72px 22px 40px; gap: 24px; }
  .poster { order: -1; height: 46svh; }
  .text { overflow: visible; max-height: none; }
  .close { top: 10px; right: 8px; }
  .index li { font-size: 22px; }
}
