/* The trigger keeps the original portrait's size and spacing. */
.avatar-button {
  position: relative;
  display: block;
  inline-size: fit-content;
  margin: 0 auto 1rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.avatar-button .profile-avatar { margin: 0; }
.avatar-button:focus-visible { outline: 3px solid currentColor; outline-offset: 7px; }
.crayon-portrait { display: none; }
.crayon-world { display: none; }

.tap-spark {
  position: absolute;
  inset: 30% 0 auto;
  pointer-events: none;
  color: var(--spark-color);
  font: 1.75rem/1 Schoolbell, cursive;
  animation: tap-spark 650ms ease-out both;
}

@keyframes tap-spark {
  to { transform: translate(var(--spark-x), -65px) rotate(45deg); opacity: 0; }
}

/* A sheet of paper, waxy marks, and no perfectly straight lines. */
body.crayon-mode {
  position: relative;
  color-scheme: light;
  --canvas: #fffefa;
  --ink: #302c42;
  --muted-ink: #514b60;
  --link-hover: #fff1b9;
  --link-pressed: #fbe8a4;
  background: var(--canvas);
  font-family: Schoolbell, "Comic Sans MS", cursive;
}

.crayon-mode::before {
  content: "";
  position: fixed;
  z-index: 8;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='paper'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath fill='%236f6048' filter='url(%23paper)' opacity='.18' d='M0 0h180v180H0z'/%3E%3C/svg%3E");
  opacity: 0.15;
  pointer-events: none;
}

.crayon-mode .profile {
  z-index: 2;
  background: transparent;
  border-radius: 0;
  gap: 1.6rem;
  padding-block-end: 4rem;
}

.crayon-mode .profile-header { position: relative; }
.crayon-mode .profile-avatar { display: none; }
.crayon-mode .avatar-button {
  inline-size: 6rem;
  block-size: 6rem;
  margin-block-end: 1.1rem;
  transform: rotate(-7deg);
}
.crayon-mode .crayon-portrait { display: block; inline-size: 100%; block-size: 100%; overflow: visible; }
.crayon-mode h1 {
  font-family: Schoolbell, "Comic Sans MS", cursive;
  font-weight: 400;
  font-size: clamp(2.9rem, 1.75rem + 5vw, 3.65rem);
  line-height: 1.1;
  letter-spacing: 0.015em;
  transform: rotate(-3deg);
  filter: url(#wax-letter);
}
.crayon-mode h1 > span:last-child { transform: rotate(2deg); }
.crayon-mode h1 .crayon-letter {
  display: inline-block;
  color: var(--letter-color);
  transform: translateY(var(--letter-y)) rotate(var(--letter-tilt));
}

.crayon-mode .profile-badges { margin-block: 1rem 0.75rem; gap: 0.7rem; }
.crayon-mode .verified-badge, .crayon-mode .follower-count {
  position: relative;
  background: transparent;
  border-radius: 35% 13% 27% 15% / 17% 43% 23% 39%;
  color: #51426b;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 400;
  padding: 0.35rem 0.6rem;
}
.crayon-mode .verified-badge { border: 2px dashed #81579c; transform: rotate(-4deg); }
.crayon-mode .verified-badge svg { color: #79509c; }
.crayon-mode .verified-badge svg path:last-child { stroke: #fffefa; }
.crayon-mode .follower-count { transform: rotate(3deg); color: #566439; }
.crayon-mode .follower-count::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  block-size: 6px;
  background: #e7d86c;
  clip-path: polygon(0 15%, 50% 35%, 96% 0, 100% 60%, 55% 90%, 2% 85%);
  opacity: 0.7;
}

.crayon-mode .social-links { gap: 0.9rem; }
.crayon-mode .social-link {
  color: #365aa1;
  border: 2px solid currentColor;
  border-radius: 43% 57% 58% 42% / 48% 36% 64% 52%;
  transform: rotate(-8deg);
  filter: url(#wax-outline);
}
.crayon-mode .social-links li:nth-child(2) .social-link { color: #bd4168; transform: rotate(9deg); }
.crayon-mode .social-links li:nth-child(3) .social-link { color: #4c793d; transform: rotate(-4deg); }
.crayon-mode .social-link svg { inline-size: 1.4rem; block-size: 1.4rem; }
.crayon-mode .profile-share { color: #6e5090; background: transparent; border: 2px dashed currentColor; transform: rotate(8deg); }
.crayon-mode .storefront-links { gap: 1.25rem; }
.crayon-mode .storefront-link {
  --link-tilt: -2deg;
  position: relative;
  isolation: isolate;
  min-block-size: 4.1rem;
  border-radius: 4px 18px 7px 14px / 12px 5px 14px 5px;
  background: transparent;
  color: #3b5494;
  font-size: 1.3rem;
  font-weight: 400;
  transform: rotate(var(--link-tilt));
}
.crayon-mode .storefront-link::before, .crayon-mode .storefront-link::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  border: 3px solid currentColor;
  border-radius: inherit;
  filter: url(#wax-outline);
  pointer-events: none;
}
.crayon-mode .storefront-link::before {
  background: repeating-linear-gradient(174deg, #f8d95c33 0 2px, #fffefa00 2px 5px);
  box-shadow: inset 0 0 0 5px #f7d95622;
}
.crayon-mode .storefront-link::after { inset: 4px -2px -3px 3px; border-width: 1.5px; opacity: 0.65; transform: rotate(1deg); }
.crayon-mode .storefront-links li:nth-child(2) .storefront-link {
  --link-tilt: 2deg;
  color: #a23d69;
}
.crayon-mode .storefront-links li:nth-child(2) .storefront-link::before {
  background: repeating-linear-gradient(168deg, #eaa1bd25 0 2px, transparent 2px 5px);
  box-shadow: inset 0 0 0 5px #eaa1bd18;
}
.crayon-mode .storefront-icon { filter: brightness(0) saturate(100%); opacity: 0.65; }
.crayon-mode .outbound-icon { color: currentColor; stroke-width: 2.5; transform: rotate(8deg); }
.crayon-mode .social-link:focus-visible, .crayon-mode .storefront-link:focus-visible,
.crayon-mode .profile-share:focus-visible { outline: 3px dashed currentColor; outline-offset: 7px; }

/* Scenery is clipped in its own layer so visitors can still scroll and tap links. */
.crayon-mode .crayon-world { display: block; }
.crayon-world { position: absolute; z-index: 1; inset: 0; overflow: hidden; pointer-events: none; }
.crayon-doodle { position: absolute; overflow: visible; }
.crayon-sun { inline-size: clamp(90px, 15vw, 170px); inset: 6% auto auto 7%; transform: rotate(-12deg); }
.crayon-flower { inline-size: 65px; inset: 31% 16% auto auto; transform: rotate(12deg); }
.crayon-star { inline-size: 52px; inset: 43% auto auto 15%; transform: rotate(12deg); }
.crayon-ufo {
  will-change: transform;
  --ufo-lift: -75px;
  position: absolute;
  inset: 6% 0 auto auto;
  inline-size: clamp(95px, 14vw, 145px);
  animation: ufo-flight 29s 5s linear infinite both;
}
.crayon-ufo > svg { display: block; overflow: visible; inline-size: 100%; animation: ufo-bob 2.1s ease-in-out infinite alternate; }
.ufo-beam { animation: beam-glow 3s ease-in-out infinite alternate; }
.crayon-dinosaur {
  will-change: transform;
  position: absolute;
  inline-size: clamp(155px, 18vw, 180px);
  inset: auto auto max(1rem, env(safe-area-inset-bottom)) 0;
  animation: dino-walk 25s linear infinite both;
}
.crayon-dinosaur > svg { display: block; inline-size: 100%; overflow: visible; animation: dino-bob 560ms ease-in-out infinite alternate; }
.dino-leg { transform-box: fill-box; transform-origin: 50% 0; animation: dino-step 560ms ease-in-out infinite alternate; }
.dino-leg-back { animation-delay: -560ms; }
.dino-arm { transform-box: fill-box; transform-origin: 0 0; animation: dino-wave 1.1s ease-in-out infinite alternate; }
.crayon-takeover {
  position: fixed;
  z-index: 20;
  inset: -4px;
  pointer-events: none;
  contain: strict;
}
.crayon-swipe {
  position: absolute;
  inset-inline: -12px;
  inset-block-start: calc(var(--stroke-row) * 16.6667% - 9px);
  block-size: calc(16.6667% + 18px);
  background-color: var(--stroke-color);
  background-image: repeating-linear-gradient(178deg, transparent 0 3px, #ffffff1a 3px 4px, transparent 4px 9px);
  clip-path: polygon(0 4%, 13% 1%, 28% 4%, 47% 0, 64% 3%, 83% 0, 100% 4%, 100% 96%, 86% 99%, 67% 96%, 46% 100%, 23% 97%, 0 100%);
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
}
.crayon-swipe:nth-child(even) { transform-origin: right center; }
.crayon-sleeping .crayon-world * { animation-play-state: paused !important; }
@keyframes dino-walk {
  from { transform: translateX(calc(-100% - 24px)); }
  to { transform: translateX(calc(100vw + 30px)); }
}
@keyframes dino-bob { to { transform: translateY(-5px) rotate(1deg); } }
@keyframes dino-step { from { transform: rotate(-17deg); } to { transform: rotate(19deg); } }
@keyframes dino-wave { to { transform: rotate(-18deg); } }
@keyframes ufo-flight {
  0% { transform: translate(calc(100% + 24px), 10px) rotate(9deg); }
  50% { transform: translate(-44vw, var(--ufo-lift)) rotate(-6deg); }
  100% { transform: translate(calc(-100vw - 40px), 20px) rotate(8deg); }
}
@keyframes ufo-bob { to { transform: translateY(15px) rotate(5deg); } }
@keyframes beam-glow { to { opacity: 0.3; } }

@media (min-width: 36rem) {
  body.crayon-mode { display: flex; flex-direction: column; justify-content: center; padding-block: 1.5rem 9rem; }
  .crayon-mode .profile { inline-size: min(100%, 29rem); min-block-size: auto; gap: 1.25rem; padding: 1rem 2.5rem 2rem; }
  .crayon-mode .avatar-button { inline-size: 5rem; block-size: 5rem; margin-block-end: 0.75rem; }
  .crayon-mode h1 { font-size: 3.3rem; }
  .crayon-mode .profile-badges { margin-block: 0.75rem 0.5rem; }
  .crayon-mode .profile-share { inset-block-start: 0.5rem; }
}
@media (max-width: 35.999rem) {
  .crayon-mode .profile {
    min-block-size: auto;
    padding-block-start: max(4.75rem, calc(3rem + env(safe-area-inset-top)));
    padding-block-end: max(10rem, calc(9rem + env(safe-area-inset-bottom)));
  }
  .crayon-sun { inline-size: 86px; inset: 1.5rem auto auto -0.6rem; }
  .crayon-star { inline-size: 31px; inset: 34% auto auto 1rem; }
  .crayon-ufo { --ufo-lift: -18px; inline-size: 80px; inset-block-start: 0; }
  .crayon-flower { inline-size: 35px; inset: 30% 0.5rem auto auto; }
  .crayon-dinosaur { inline-size: 145px; }
}
@media (hover: hover) {
  .crayon-mode .storefront-link:hover { background: #f9df6929; }
  .crayon-mode .social-link:hover { background: #f9df6929; }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .crayon-mode .storefront-link:hover:not(:active) { transform: rotate(var(--link-tilt)) translateY(-2px); }
}
@media (prefers-reduced-motion: no-preference) {
  .crayon-mode .storefront-link:active { transform: rotate(var(--link-tilt)) translateY(1px); }
}
@media (prefers-reduced-motion: reduce) {
  .tap-spark { display: none; }
  .crayon-world * { animation: none !important; }
  .crayon-dinosaur { transform: translateX(calc(70vw - 80px)); }
  .crayon-ufo { transform: translateX(-10vw) rotate(-8deg); }
}
