:root {
  --sand: #e8c87c;
  --rust: #702215;
  --bone: #ead9be;
  --ink: #13141c;
  --gutter: clamp(20px, 5vw, 48px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--sand);
}

body {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--sand);
  color: var(--rust);
  font-family: "Source Code Pro", ui-monospace, Menlo, Consolas, monospace;
  font-size: clamp(15px, 1rem + 0.15vw, 18px);
  line-height: 1.6;
  overflow-x: hidden;
}

::selection {
  background: var(--rust);
  color: var(--sand);
}

/* Fixed backdrop: replaces background-attachment: fixed, which iOS ignores */
.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #c4581e url("assets/bg.jpg") center / cover no-repeat;
}

/* Hero: the robot figure stands in the junkyard and its robe melts into the sand */
.hero {
  position: relative;
  z-index: 1;
  width: 100%;
  aspect-ratio: 1920 / 1047;
  min-height: min(78svh, 640px);
  max-height: 100svh;
  overflow: hidden;
}

.figure {
  position: absolute;
  inset: 0;
}

.figure img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 69% 100%;
  user-select: none;
  -webkit-user-drag: none;
}

.logo {
  position: absolute;
  z-index: 2;
  top: max(clamp(14px, 3vw, 40px), env(safe-area-inset-top));
  left: max(clamp(14px, 3vw, 40px), env(safe-area-inset-left));
  width: clamp(60px, 9vw, 120px);
  aspect-ratio: 1;
  display: block;
  border-radius: 9%;
  box-shadow: 0 6px 24px rgb(60 15 5 / 0.35);
  transition: filter 0.2s;
}

.logo img {
  width: 100%;
  height: 100%;
  display: block;
}

.logo:hover,
.logo:focus-visible {
  filter: brightness(0.85);
}

/* Letter */
.content {
  position: relative;
  z-index: 1;
  flex: 1;
  background: var(--sand);
  padding: clamp(40px, 8vw, 100px) var(--gutter) clamp(56px, 10vw, 120px);
}

.content > * {
  max-width: 38rem;
  margin-left: clamp(0px, 14vw - 60px, 18vw);
}

.content h1 {
  font-weight: 400;
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.4rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 1.4em;
}

.content h2,
.content h3 {
  font-weight: 600;
  margin: 2em 0 0.8em;
}

.content p,
.content ul,
.content ol,
.content blockquote {
  margin-bottom: 1.6em;
}

.content ul,
.content ol {
  padding-left: 1.4em;
}

.content p:last-child {
  margin-bottom: 0;
}

.content a {
  color: inherit;
  text-decoration: underline dashed;
  text-underline-offset: 0.2em;
}

.content a:hover {
  background: var(--rust);
  color: var(--sand);
  text-decoration: none;
}

.content img {
  max-width: 100%;
  height: auto;
}

.content hr {
  border: 0;
  border-top: 1px dashed currentColor;
}

/* Dashed rule closing the letter, as on the original */
.content::after {
  content: "";
  display: block;
  max-width: 38rem;
  margin-top: clamp(40px, 6vw, 72px);
  margin-left: clamp(0px, 14vw - 60px, 18vw);
  border-bottom: 1px dashed var(--rust);
}

.footer {
  position: relative;
  z-index: 1;
  background: var(--rust);
  height: clamp(80px, 14vw, 180px);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- Decay ---------- */

.decay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  pointer-events: none;
}

/* Displaced strips of an image, cloned by decay.js */
.shard {
  position: absolute;
  inset: 0;
  pointer-events: none;
  will-change: transform, clip-path;
}

.sky.shard {
  position: fixed;
}

/* Once everything is lost: nothing left but white */
body.void {
  background: #fff;
  cursor: none;
}

html:has(body.void) {
  background: #fff;
  overflow: hidden;
}

body.void > :not(.decay) {
  visibility: hidden;
}
