:root {
  --bg: #0a0a0b;
  --bg-2: #121214;
  --ink: #ece8df;
  --muted: #8b877e;
  --dim: #56534d;
  --line: #24231f;
  --red: #ff3b2f;
  --amber: #ffb43c;
  --serif: "Instrument Serif", "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --gutter: clamp(16px, 4vw, 48px);
  --ease: cubic-bezier(.2, .7, .1, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; max-width: 100%; }
::selection { background: var(--red); color: var(--bg); }
:focus-visible { outline: 1px solid var(--amber); outline-offset: 3px; }

.serif { font-family: var(--serif); font-weight: 400; }
.mono {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--ink); color: var(--bg); padding: 8px 12px; }
.skip:focus { left: 8px; }

/* Top bar */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 18px var(--gutter);
  padding-top: max(18px, env(safe-area-inset-top));
  color: var(--ink);
  transition: background .4s var(--ease), border-color .4s var(--ease);
  border-bottom: 1px solid transparent;
}
.bar.is-solid { background: rgba(10, 10, 11, .82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-color: var(--line); }
.bar__left { display: flex; gap: 14px; color: var(--muted); }
.bar__clock { color: var(--ink); font-variant-numeric: tabular-nums; }
.bar__nav { display: flex; gap: 26px; }
.bar__nav a { position: relative; color: var(--muted); transition: color .2s; }
.bar__nav a:hover, .bar__nav a[aria-current] { color: var(--ink); }
.bar__home { color: var(--ink); }
.bar__home:hover { color: var(--red); }
.bar__nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 1px;
  background: var(--red); transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease);
}
.bar__nav a:hover::after, .bar__nav a[aria-current]::after { transform: scaleX(1); }
.bar__menu { display: none; }

.sheet {
  position: fixed; inset: 0; z-index: 15; background: var(--bg);
  display: flex; align-items: flex-end; padding: var(--gutter); padding-bottom: max(var(--gutter), env(safe-area-inset-bottom));
}
.sheet__nav { display: flex; flex-direction: column; font-size: 56px; line-height: 1.05; }
.sheet__nav a:active, .sheet__nav a[aria-current] { color: var(--red); }

/* Hero */
.hero {
  position: relative; height: 100vh; height: 100svh; min-height: 520px;
  overflow: hidden; isolation: isolate;
}
.trails { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; display: block; }

/* Page header band (inner pages) */
.phero {
  position: relative; isolation: isolate; overflow: hidden;
  height: clamp(420px, 66vh, 680px);
  display: flex; align-items: flex-end;
  padding: 0 var(--gutter) clamp(28px, 5vw, 56px);
}
.phero::after { content: ""; position: absolute; inset: auto 0 0 0; height: 40%; background: linear-gradient(transparent, var(--bg)); z-index: -1; pointer-events: none; }
.phero__inner { position: relative; max-width: 900px; }
.phero__label { color: var(--muted); margin: 0 0 10px; display: flex; align-items: center; gap: 10px; }
.phero__label::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px var(--red); }
.phero__title {
  margin: 0; font-size: clamp(72px, 13vw, 210px); line-height: .85; letter-spacing: -.035em;
  opacity: 0; transform: translateY(18px); animation: rise 1.2s var(--ease) forwards;
}
.phero__sub { color: var(--muted); font-size: clamp(19px, 2vw, 24px); max-width: 36ch; margin: 18px 0 22px; }
.phero .pill { margin-top: 18px; }
.phero__sub + .pill { margin-top: 0; }
.page { padding: clamp(24px, 4vw, 48px) var(--gutter) 0; }
.hero__name {
  position: absolute; left: var(--gutter); bottom: clamp(64px, 11vh, 120px); margin: 0;
  font-size: clamp(76px, 15.5vw, 260px); line-height: .82; letter-spacing: -.035em;
  display: flex; flex-direction: column;
}
.hero__name em { font-style: italic; padding-left: .32em; }
.hero__name span, .hero__name em { display: block; opacity: 0; transform: translateY(18px); animation: rise 1.4s var(--ease) forwards; }
.hero__name em { animation-delay: .15s; }
@keyframes rise { to { opacity: 1; transform: none; } }

.hero__foot {
  position: absolute; left: var(--gutter); right: var(--gutter); bottom: 22px;
  bottom: max(22px, env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; align-items: center; color: var(--muted);
}
.hero__exp { display: inline-flex; align-items: center; gap: 8px; }
.hero__exp b { font-weight: 400; color: var(--ink); font-variant-numeric: tabular-nums; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px var(--red); animation: blink 2s steps(1) infinite; }
@keyframes blink { 50% { opacity: .25; } }
.hero__down { font-size: 18px; color: var(--ink); width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; transition: border-color .2s, transform .3s var(--ease); }
.hero__down:hover { border-color: var(--red); transform: translateY(3px); }

/* Sections */
.sec { padding: clamp(80px, 14vw, 160px) var(--gutter) 0; scroll-margin-top: 40px; }
.sec__head { display: flex; align-items: center; gap: 14px; color: var(--muted); margin-bottom: clamp(32px, 6vw, 64px); }
.sec__head span:first-child { color: var(--red); }
.sec__head .rule { flex: 1; height: 1px; background: var(--line); }
.sec__head a { color: var(--ink); white-space: nowrap; }
.sec__head a:hover { color: var(--red); }

.reveal { opacity: 0; transform: translateY(24px); transition: opacity 1s var(--ease), transform 1s var(--ease); }
.reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

/* Writing */
.pill { display: inline-block; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; transition: border-color .2s, color .2s; }
.pill:hover { border-color: var(--red); color: var(--red); }

.posts { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.post a {
  position: relative; display: grid; grid-template-columns: 150px minmax(0, 1fr) 24px; gap: 6px 24px; align-items: baseline;
  padding: 28px 0; border-bottom: 1px solid var(--line); overflow: hidden;
}
.post__date { color: var(--muted); grid-row: span 2; font-variant-numeric: tabular-nums; }
.post__title { font-size: clamp(30px, 4vw, 56px); line-height: 1; letter-spacing: -.01em; transition: transform .45s var(--ease); }
.post__sub { grid-column: 2; color: var(--muted); font-size: 19px; line-height: 1.4; }
.post__arrow { grid-row: 1; grid-column: 3; color: var(--muted); font-family: var(--mono); transition: transform .35s var(--ease), color .2s; }
.post a::before {
  content: ""; position: absolute; left: 0; bottom: -1px; height: 1px; width: 100%;
  background: linear-gradient(90deg, transparent, var(--red) 60%, #ffd2c8);
  transform: translateX(-101%); transition: transform .7s var(--ease);
}
.post a:hover::before { transform: translateX(0); }
.post a:hover .post__title { transform: translateX(8px); }
.post a:hover .post__arrow { color: var(--red); transform: translate(3px, -3px); }

/* Photos */
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.ph { position: relative; aspect-ratio: 3 / 2; overflow: hidden; background: var(--bg-2); cursor: zoom-in; }
.ph.big { grid-column: span 2; grid-row: span 2; }
.ph img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.02); transition: transform 1.2s var(--ease), opacity .8s var(--ease), filter .6s; opacity: 0; }
.ph img.is-loaded { opacity: 1; }
.ph:hover img { transform: scale(1.06); }
.ph__meta {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 28px 12px 10px;
  display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, .65));
  opacity: 0; transform: translateY(6px); transition: opacity .35s, transform .35s var(--ease);
}
.ph:hover .ph__meta, .ph:focus-visible .ph__meta { opacity: 1; transform: none; }
.ph__n { position: absolute; top: 10px; left: 12px; font-size: 11px; color: rgba(255, 255, 255, .85); text-shadow: 0 1px 6px rgba(0,0,0,.5); }

/* Projects */
.projects { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.proj > a, .proj > div {
  position: relative; display: grid; grid-template-columns: 48px minmax(0, 6fr) minmax(0, 5fr) 190px; gap: 8px 24px; align-items: center;
  padding: clamp(22px, 3vw, 34px) 0; border-bottom: 1px solid var(--line); overflow: hidden;
}
.proj__n { color: var(--red); }
.proj__name { font-size: clamp(44px, 7vw, 104px); line-height: .9; letter-spacing: -.02em; transition: transform .5s var(--ease), color .3s; }
.proj__line { color: var(--muted); font-size: 19px; max-width: 34ch; }
.proj__tag { color: var(--muted); text-align: right; white-space: nowrap; }
.proj__trail { position: absolute; left: 0; top: 50%; height: 2px; width: 40%; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--red)); box-shadow: 0 0 12px var(--red); transform: translateX(-120%); pointer-events: none; }
.proj > a:hover .proj__trail { animation: streak 1.1s var(--ease) forwards; }
.proj > a:hover .proj__name { transform: translateX(10px); }
.proj > a:hover .proj__tag { color: var(--ink); }
@keyframes streak { to { transform: translateX(300%); } }

/* Reading: 3D book shelf */
.reading {
  list-style: none; margin: 0; padding: clamp(16px, 3vw, 40px) 0 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: clamp(48px, 6vw, 88px) clamp(20px, 3vw, 40px);
}
.shelf__item > * { display: flex; flex-direction: column; align-items: center; text-align: center; }
.b3 { --w: 176px; --h: 264px; --k: 1; --dd: calc(var(--d) * var(--k)); position: relative; display: block; width: var(--w); height: var(--h); perspective: 1400px; }
.b3__obj {
  position: absolute; inset: 0; transform-style: preserve-3d;
  transform: rotateY(48deg); transition: transform .9s var(--ease);
}
.b3__front {
  position: absolute; inset: 0; overflow: hidden; background: #1a1a1a;
  border-radius: 1px 3px 3px 1px;
  transform: translateZ(calc(var(--dd) / 2));
}
.b3__img { width: 100%; height: 100%; object-fit: cover; }
.b3__sheen {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(0,0,0,.28) 0, rgba(255,255,255,.18) 2.5%, rgba(255,255,255,0) 7%, rgba(0,0,0,.06) 8%, rgba(0,0,0,0) 14%),
    linear-gradient(180deg, rgba(255,255,255,.08), rgba(0,0,0,.12));
}
.b3__spine {
  position: absolute; top: 0; left: 0; width: var(--dd); height: 100%;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: #2a2a2a; color: #f4f1ea;
  transform-origin: left center;
  transform: translateZ(calc(var(--dd) / -2)) rotateY(-90deg);
}
.b3__spine::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.35), rgba(255,255,255,.08) 45%, rgba(0,0,0,.25)); }
.b3__spinetext {
  writing-mode: vertical-rl; font-size: 14px; line-height: 1; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-height: 86%; position: relative; z-index: 1;
}
.b3__pages {
  position: absolute; top: 3px; left: calc(var(--w) - var(--dd)); width: var(--dd); height: calc(100% - 6px);
  background: repeating-linear-gradient(90deg, #ece6d8 0 1px, #cfc8b8 1px 2px);
  transform-origin: right center;
  transform: translateZ(calc(var(--dd) / -2)) rotateY(90deg);
}
.b3__shadow {
  position: absolute; left: 8%; right: 0; bottom: -22px; height: 26px; z-index: -1;
  background: radial-gradient(closest-side, rgba(0,0,0,.75), rgba(0,0,0,0));
  transition: transform .9s var(--ease), opacity .9s var(--ease);
}
.shelf__item > *:hover .b3__obj, .shelf__item > *:focus-visible .b3__obj { transform: rotateY(0deg) translateY(-10px); }
.shelf__item > *:hover .b3__shadow { transform: scale(1.08, 1.2); opacity: .8; }

/* Designed cover for essays and articles */
.b3__design {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px;
  padding: 18px 16px 16px; background: var(--c); color: #f4efe4; text-align: left;
}
.b3__dkind { font-size: 10px; opacity: .7; }
.b3__dtitle { font-size: 30px; line-height: .98; letter-spacing: -.01em; }
.b3__drule { width: 28px; height: 2px; background: var(--red); margin-top: auto; box-shadow: 0 0 10px rgba(255, 59, 47, .6); }
.b3__dby { font-size: 10px; opacity: .85; }

.shelf__cap { display: flex; flex-direction: column; gap: 6px; margin-top: 34px; max-width: 220px; }
.shelf__title { font-size: 22px; line-height: 1.1; transition: color .2s; }
.shelf__by { color: var(--muted); font-size: 11px; }
.shelf__item a:hover .shelf__title { color: var(--amber); }

@media (hover: none) {
  .b3__obj { transform: rotateY(16deg); }
}
@media (prefers-reduced-motion: reduce) {
  .b3__obj, .b3__shadow { transition: none; }
}

/* About */
.about { display: grid; grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); gap: clamp(32px, 6vw, 96px); align-items: end; }
.about__text p { font-size: clamp(28px, 3.6vw, 52px); line-height: 1.1; margin: 0 0 .5em; letter-spacing: -.01em; }
.about__text p:not(:first-child) { color: var(--muted); }
.about__links { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.about__links a { display: flex; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--line); transition: color .2s, padding .3s var(--ease); }
.about__links a:hover { color: var(--red); padding-left: 6px; }

.foot { display: flex; justify-content: space-between; gap: 16px; padding: clamp(80px, 12vw, 140px) var(--gutter) 28px; padding-bottom: max(28px, env(safe-area-inset-bottom)); color: var(--dim); }
.foot__clock { font-variant-numeric: tabular-nums; }

/* Lightbox */
.lb {
  position: fixed; inset: 0; z-index: 50; background: rgba(6, 6, 7, .96);
  display: grid; grid-template-columns: 64px minmax(0, 1fr) 64px; align-items: center;
  padding: max(56px, env(safe-area-inset-top)) 8px max(16px, env(safe-area-inset-bottom));
  animation: fade .3s var(--ease);
}
@keyframes fade { from { opacity: 0; } }
.lb__fig { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 14px; min-width: 0; }
.lb__img { max-height: calc(100svh - 140px); width: auto; max-width: 100%; object-fit: contain; }
.lb__cap { color: var(--muted); display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.lb__close { position: absolute; top: max(18px, env(safe-area-inset-top)); right: var(--gutter); color: var(--muted); }
.lb__close:hover { color: var(--ink); }
.lb__prev, .lb__next { font-size: 22px; height: 100%; color: var(--muted); font-family: var(--mono); }
.lb__prev:hover, .lb__next:hover { color: var(--red); }

/* Tablet */
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ph.big { grid-column: auto; grid-row: auto; }
  .proj > a, .proj > div { grid-template-columns: 36px minmax(0, 1fr) auto; }
  .proj__line { grid-column: 2 / -1; grid-row: 2; }
  .proj__tag { grid-row: 1; grid-column: 3; }
  .about { grid-template-columns: 1fr; }
}

/* Phone */
@media (max-width: 640px) {
  body { font-size: 17px; }
  .bar__nav { display: none; }
  .bar__menu { display: block; z-index: 2; }
  .bar__left .bar__city { display: none; }
  .hero__name { bottom: 84px; }
  .post a { grid-template-columns: minmax(0, 1fr) 20px; padding: 18px 0; }
  .post__date { grid-row: auto; grid-column: 1 / -1; }
  .post__sub { grid-column: 1; }
  .post__arrow { grid-row: 2; grid-column: 2; }
  .grid { gap: 6px; }
  .ph__meta { display: none; }
  .proj__tag { display: none; }
  .proj > a, .proj > div { grid-template-columns: 28px minmax(0, 1fr); }
  .phero { height: clamp(380px, 60svh, 560px); }
  .reading { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 48px 12px; }
  .b3 { --w: 128px; --h: 192px; --k: .62; }
  .b3__dtitle { font-size: 22px; }
  .b3__spinetext { font-size: 12px; }
  .shelf__title { font-size: 19px; }
  .shelf__cap { margin-top: 28px; }
  .lb { grid-template-columns: 1fr; padding-left: 0; padding-right: 0; }
  .lb__prev, .lb__next { display: none; }
  .foot { flex-direction: column; }
}
