@property --night {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}

:root {
  --ground: #e9edf1;
  --paper: #f8f9fb;
  --edge: #d3dae2;
  --ink: #17202b;
  --muted: #5a6776;
  --steel: #2f567c;
  --steel-soft: rgb(47 86 124 / 35%);
  --rule: #cfd6de;
  --line: #9aa6b3;
  --well: #eef1f5;
  --straw: #b4863a;
  --sheet: #6d9ee0;
  --fold: #8fb5dc;
  --glow: rgb(244 190 110 / 38%);
  --sun: #f2c27a;
  --cloud: #fbfcfd;
  --night: 0;
  --serif: "Spectral", "Iowan Old Style", Georgia, serif;
  --mono: "Martian Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --measure: 50rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0a0e13;
    --paper: #10161e;
    --edge: #1d2733;
    --ink: #d9e0e8;
    --muted: #8593a3;
    --steel: #8fb5dc;
    --steel-soft: rgb(143 181 220 / 35%);
    --rule: #222d3a;
    --line: #3b4958;
    --well: #151d27;
    --straw: #d6ad62;
    --glow: rgb(109 158 224 / 12%);
    --night: 1;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ground: #0a0e13;
  --paper: #10161e;
  --edge: #1d2733;
  --ink: #d9e0e8;
  --muted: #8593a3;
  --steel: #8fb5dc;
  --steel-soft: rgb(143 181 220 / 35%);
  --rule: #222d3a;
  --line: #3b4958;
  --well: #151d27;
  --straw: #d6ad62;
  --glow: rgb(109 158 224 / 12%);
  --night: 1;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 17px/1.6 var(--serif);
  -webkit-font-smoothing: antialiased;
}

body {
  position: relative;
  padding-inline: max(16px, env(safe-area-inset-left, 0px));
  transition: background-color 0.6s, color 0.6s;
}

.top,
main,
.foot {
  position: relative;
  z-index: 1;
}

.sky {
  position: absolute;
  inset: 0 0 auto;
  height: 36rem;
  overflow: hidden;
  pointer-events: none;
  background: radial-gradient(ellipse 60% 70% at 86% 0%, var(--glow), transparent 70%);
  -webkit-mask-image: linear-gradient(to bottom, #000 45%, transparent);
  mask-image: linear-gradient(to bottom, #000 45%, transparent);
  transition: --night 0.9s ease;
}

.sky svg {
  position: absolute;
  top: 0;
  left: 50%;
  width: max(100%, 72rem);
  height: 100%;
  transform: translateX(-50%);
}

.morning {
  opacity: calc(1 - var(--night));
}

.night {
  opacity: var(--night);
}

.sun {
  fill: var(--sun);
  opacity: 0.5;
}

.sun.halo {
  opacity: 0.16;
}

.cloud {
  fill: var(--cloud);
  opacity: 0.85;
  animation: drift 90s ease-in-out infinite alternate;
}

.cloud.slow {
  animation-duration: 140s;
  animation-direction: alternate-reverse;
}

.bird {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.4;
  stroke-linecap: round;
  opacity: 0.45;
}

.star {
  fill: #d9e0e8;
}

.star.twinkle {
  animation: twinkle 4s ease-in-out infinite;
}

.star.twinkle:nth-child(3n) {
  animation-delay: -1.3s;
  animation-duration: 5.5s;
}

.star.twinkle:nth-child(3n + 1) {
  animation-delay: -2.6s;
  animation-duration: 3.2s;
}

.moon {
  fill: #d6ad62;
  opacity: 0.85;
}

@keyframes drift {
  to {
    transform: translateX(-70px);
  }
}

@keyframes twinkle {
  50% {
    opacity: 0.2;
  }
}

.version-pill {
  display: inline-flex;
  align-items: center;
  height: 1.5rem;
  padding: 0 0.55rem;
  border: 1px solid var(--edge);
  background: var(--paper);
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--steel);
  font-style: normal;
  text-decoration: none;
  white-space: nowrap;
}

.version-pill:hover {
  border-color: var(--steel);
  text-decoration: none;
}

.flick {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  flex: none;
  width: 2.4rem;
  height: 1.5rem;
  padding: 0.18rem;
  background: var(--well);
  border: 1px solid var(--edge);
  border-radius: 0;
  cursor: pointer;
}

.flick:hover {
  border-color: var(--line);
}

.lever {
  display: block;
  width: 42%;
  background: var(--muted);
  transform: translateX(calc(var(--night) * 138%));
  transition: transform 0.12s cubic-bezier(0.3, 1.6, 0.6, 1), background 0.12s ease;
}

.flick:hover .lever {
  background: var(--ink);
}

.quick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  background: var(--paper);
  border: 1px solid var(--edge);
}

.quick code {
  flex: 1 1 18rem;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.quick .prompt {
  color: var(--steel);
  user-select: none;
}

.copy {
  font: italic 0.9rem var(--serif);
  color: var(--steel);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--steel-soft);
  text-underline-offset: 0.28em;
}

.copy:hover {
  text-decoration-color: var(--steel);
}

h1,
h2,
p,
ol,
ul,
pre {
  margin: 0;
}

h1,
h2 {
  font-weight: 500;
  text-wrap: balance;
}

p,
li {
  text-wrap: pretty;
}

code {
  font-family: var(--mono);
  font-size: 0.74em;
}

a {
  color: var(--steel);
  text-decoration-color: var(--steel-soft);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.28em;
  transition: text-decoration-color 0.15s;
}

a:hover {
  text-decoration-color: var(--steel);
}

:focus-visible {
  outline: 2px solid var(--steel);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.stamp {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.hint {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem 1.6rem;
}

.act {
  color: var(--steel);
}

.act.go {
  font-weight: 600;
  text-decoration-color: var(--steel);
  text-decoration-thickness: 2px;
}

.act.quiet {
  color: var(--muted);
  text-decoration-color: var(--rule);
}

.top,
main,
.foot {
  max-width: var(--measure);
  margin-inline: auto;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: calc(1.4rem + env(safe-area-inset-top, 0px)) 1.2rem;
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--ink);
  text-decoration: none;
}

.wordmark {
  font-size: 1.9rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
}

.logo {
  width: 2.1rem;
  height: 2.1rem;
}

.logo-pillow {
  fill: var(--edge);
}

.logo-cat {
  fill: var(--ink);
  stroke: var(--ink);
}

.logo-paw {
  fill: var(--ink);
}

.logo-eyes {
  fill: none;
  stroke: var(--paper);
}

.logo-whiskers {
  fill: none;
  stroke: var(--ink);
}

.logo-sheet {
  fill: var(--sheet);
}

.logo-fold {
  fill: var(--fold);
}

.top-links {
  display: flex;
  align-items: center;
  gap: 1.3rem;
  font-style: italic;
}

.top-links a:not(.version-pill) {
  color: var(--muted);
  text-decoration-color: var(--rule);
}

.top-links a:not(.version-pill):hover {
  color: var(--ink);
  text-decoration-color: var(--ink);
}

main {
  display: flex;
  flex-direction: column;
  gap: 4.2rem;
  padding-block: 4.5rem 5rem;
}

.essay {
  font-size: 1.12rem;
  line-height: 1.7;
}

.essay section,
.opening {
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
}

.opening h1 {
  font-size: clamp(2.3rem, 5.4vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: 0.4rem;
}

.lede {
  font-size: 1.3rem;
  line-height: 1.6;
}

.opening .actions {
  margin-top: 0.4rem;
}

.essay h2 {
  font-size: 1.6rem;
  letter-spacing: -0.01em;
  padding-top: 1.6rem;
  border-top: 1px solid var(--rule);
}

figure {
  margin: 0.8rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

figcaption {
  font-size: 0.9rem;
  font-style: italic;
  color: var(--muted);
}

.chain-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.vault {
  transition: color 0.4s;
}

.vault.open {
  color: var(--steel);
}

.links {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: auto;
  background: var(--paper);
  border: 1px solid var(--edge);
}

.link {
  display: grid;
  grid-row: span 4;
  grid-template-rows: subgrid;
  row-gap: 0.7rem;
  align-items: start;
  padding: 1.3rem 1.2rem 1.4rem;
  min-width: 0;
  transition: background-color 0.5s;
}

.link + .link {
  border-left: 1px solid var(--edge);
}

.link .stamp {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  transition: color 0.3s;
}

.tick {
  color: var(--steel);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.3s, transform 0.3s;
}

.link.done .tick {
  opacity: 1;
  transform: none;
}

.scramble,
.link .q {
  position: relative;
  font-size: 1rem;
  line-height: 1.35;
}

.q-size {
  visibility: hidden;
}

.q-text {
  position: absolute;
  inset: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  transition: color 0.4s;
}

.scramble .q-text {
  transition: color 0.6s;
}

.scramble.scrambling .q-text {
  color: var(--muted);
}

.link.sealed .q-text {
  color: var(--line);
  user-select: none;
}

.link .line {
  display: block;
  align-self: end;
  height: 1.8rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  line-height: 1.8rem;
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
}

.link.now .stamp {
  color: var(--ink);
}

.link.now .line {
  border-bottom: 2px solid var(--steel);
}

.link.now .typed::after {
  content: "";
  display: inline-block;
  width: 1px;
  height: 1.1rem;
  margin-left: 1px;
  vertical-align: -0.2rem;
  background: var(--ink);
  animation: blink 1.1s steps(1) infinite;
}

.link.sealed {
  background: var(--well);
}

.link.sealed .line {
  border-bottom-style: dashed;
}

.link .state {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--muted);
}

.term {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.8;
  padding: 1.3rem 1.4rem;
  background: var(--paper);
  border: 1px solid var(--edge);
  overflow-x: auto;
}

.term .prompt {
  color: var(--steel);
  user-select: none;
}

.term .out {
  color: var(--muted);
}

.blink {
  color: var(--steel);
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.6rem 1.5rem;
  padding-block: 1.6rem calc(2.4rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.92rem;
  font-style: italic;
}

@media (max-width: 52rem) {
  .links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .link:nth-child(3) {
    border-left: 0;
  }

  .link:nth-child(n + 3) {
    border-top: 1px solid var(--edge);
  }

}

@media (max-width: 32rem) {
  main {
    gap: 3.2rem;
    padding-block: 3rem 4rem;
  }

  .essay {
    font-size: 1.05rem;
  }

  .lede {
    font-size: 1.15rem;
  }

  .links {
    grid-template-columns: 1fr;
  }

  .link + .link {
    border-left: 0;
    border-top: 1px solid var(--edge);
  }

}

@media (prefers-reduced-motion: reduce) {
  .link.now .typed::after,
  .blink,
  .cloud,
  .star.twinkle {
    animation: none;
  }
}

.lost {
  min-height: 100vh;
  justify-content: center;
  gap: 1.2rem;
  padding-block: 0;
}

.lost h1 {
  font-size: clamp(2.4rem, 7vw, 4rem);
  letter-spacing: -0.03em;
}

/* The page reads lowercase; the markup keeps proper case for search
   results, screen readers and anyone copying the text. */
body {
  text-transform: lowercase;
}

code,
pre,
kbd,
samp {
  text-transform: none;
}

/* Form controls do not inherit text-transform from the UA stylesheet.
   Inputs stay untouched so what someone types is shown as typed. */
button {
  text-transform: inherit;
}
