:root {
  color-scheme: dark;
  --background: #0d0d0d;
  --foreground: #fff;
  --muted-foreground: rgba(255, 255, 255, 0.62);
  background: var(--background);
  font-family: "Libre Baskerville", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--background);
  transition: background-color 700ms cubic-bezier(.22, .8, .28, 1);
}

body {
  display: grid;
  place-items: center;
  overscroll-behavior: none;
  user-select: none;
  transition: background-color 700ms cubic-bezier(.22, .8, .28, 1);
}

:root.theme-light,
body.theme-light {
  color-scheme: light;
  --background: #fafafa;
  --foreground: #000;
  --muted-foreground: rgba(0, 0, 0, 0.58);
  background: #fafafa;
}

main {
  position: relative;
  width: min(88vw, 720px);
  height: 150px;
  transform: translateY(-14px);
}

.identity,
.slogan {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
}

.identity-part {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

h1,
p { margin: 0; }

h1 {
  color: var(--foreground);
  font-size: clamp(1.62rem, 4vw, 2.58rem);
  font-weight: 400;
  -webkit-text-stroke: 0.22px currentColor;
  letter-spacing: -0.04em;
  line-height: 1;
  transition: color 700ms cubic-bezier(.22, .8, .28, 1);
}

.location {
  position: absolute;
  top: calc(50% + 30px);
  left: 50%;
  display: flex;
  margin: 0;
  color: var(--muted-foreground);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(0.66rem, 1.2vw, 0.78rem);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transform: translateX(-50%);
  opacity: 0;
  animation: reveal-location 500ms ease 5s forwards;
  transition: color 700ms cubic-bezier(.22, .8, .28, 1);
}

.location span + span { margin-left: 0.8em; }

/* Duplicate text turns crisp letters into blurred letters, left to right. */
.identity-blur {
  clip-path: inset(0 100% 0 0);
  filter: blur(13px);
  opacity: 0;
  pointer-events: none;
}

.identity-erase {
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.slogan {
  color: var(--foreground);
  font-size: clamp(1.34rem, 3.7vw, 2.35rem);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 1.05;
  clip-path: inset(0 100% 0 0);
  filter: blur(15px);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-18px);
  transition: color 700ms cubic-bezier(.22, .8, .28, 1);
}

/* 1 — the first scroll starts the left-to-right blur sweep. */
body.is-blurring .identity-clear {
  animation: hide-crisp-title 1100ms cubic-bezier(.33, .02, .16, 1) forwards;
}

body.is-blurring .identity-blur {
  animation: blur-title-left-to-right 1100ms cubic-bezier(.33, .02, .16, 1) forwards;
}

/* Keep the fully blurred title visible while the automatic pause runs. */
body.is-blurred .identity-clear {
  clip-path: inset(0 0 0 100%);
}

body.is-blurred .identity-blur {
  clip-path: inset(0 0 0 0);
  opacity: 1;
}

/* 2 — after two seconds, the blurred identity erases itself automatically. */
body.is-erasing .identity-erase {
  animation: erase-title-left-to-right 900ms cubic-bezier(.55, .04, .2, 1) forwards;
}

/* 3 — when more than half the title is gone, the slogan flows in. */
body.is-erasing .slogan {
  animation: reveal-slogan-left-to-right 1500ms cubic-bezier(.19, .75, .22, 1) 470ms forwards;
}

/* Reverse scene: the name drops into place as the slogan leaves downward. */
body.is-returning .identity-clear {
  clip-path: inset(0 0 0 0);
  animation: name-drop-into-place 1500ms cubic-bezier(.16, .82, .24, 1) forwards;
}

body.is-returning .identity-blur {
  clip-path: inset(0 100% 0 0);
  opacity: 0;
}

body.is-returning .slogan {
  clip-path: inset(0 0 0 0);
  filter: blur(0);
  opacity: 1;
  transform: translateY(0);
  animation: slogan-fall-away 650ms cubic-bezier(.45, .02, .34, 1) 250ms forwards;
}

body.has-started .location {
  animation: fade-location 500ms ease forwards;
}

@keyframes hide-crisp-title {
  to { clip-path: inset(0 0 0 100%); }
}

@keyframes blur-title-left-to-right {
  0% { clip-path: inset(0 100% 0 0); opacity: 0; }
  10% { opacity: 1; }
  100% { clip-path: inset(0 0 0 0); opacity: 1; }
}

@keyframes erase-title-left-to-right {
  from { clip-path: inset(0 0 0 0); }
  to { clip-path: inset(0 0 0 100%); }
}

@keyframes reveal-slogan-left-to-right {
  0% {
    clip-path: inset(0 100% 0 0);
    filter: blur(15px);
    opacity: 0;
    transform: translateX(-18px);
  }
  16% { opacity: 0.9; }
  100% {
    clip-path: inset(0 0 0 0);
    filter: blur(0);
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes name-drop-into-place {
  0% {
    filter: blur(5px);
    opacity: 0;
    transform: translateY(-62px);
  }
  45% { opacity: 1; }
  100% {
    filter: blur(0);
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slogan-fall-away {
  to {
    filter: blur(4px);
    opacity: 0;
    transform: translateY(20px);
  }
}

@keyframes reveal-location {
  to { opacity: 1; }
}

@keyframes fade-location {
  from { opacity: 1; }
  to { opacity: 0; }
}

