/* ------------------------------------------------------------------
   REZO FUN docs — logo field

   The REZO mark repeats as a small tile across the page, held far below
   the text in contrast so it reads as paper texture, not content.

   The tricky part is that this is a documentation page: the reading
   column and the contents rail occupy the middle of the screen, and a
   flat repeating pattern behind 20 sections of body copy turns into
   noise. So the tile layer is masked horizontally — full strength in
   the empty gutters, almost nothing behind the type. The pattern is
   still unmistakably "all over the page", but it never competes with a
   paragraph.

   Blink: a repeating CSS background cannot animate individual tiles, so
   a second tile with the eyes shut is stacked in exactly the same
   geometry and its opacity is stepped. Because both tiles share size,
   position, rotation and mask, the swap is invisible apart from the
   eyes.

   Cost: two 4 KB webp tiles, one composited layer. No JS.
   ------------------------------------------------------------------ */

.logofield{
  position:fixed;
  inset:0;
  z-index:0;
  pointer-events:none;
  overflow:hidden;
  contain:strict;
  background-image:url("assets/logo-tile.webp");
  background-repeat:repeat;
  background-size:64px auto;
  background-position:18px 24px;
  opacity:.2;
  filter:grayscale(1) brightness(1.2);
  /* rotate so the grid never lines up with the text baseline */
  transform:rotate(-3deg) scale(1.14);
  transform-origin:50% 50%;
  /* Horizontal mask laid over the real layout at 1400px:
       contents rail   56–358px   (~4%–26%)
       reading column 406–1044px  (~29%–75%)
       free gutter   1050–1400px  (~75%–100%)
     The tile is at full strength only in the free right gutter and a
     thin sliver at the far-left edge; everything the reader looks at
     sits on near-flat ground. */
  -webkit-mask-image:linear-gradient(90deg,
    #000 0%,
    rgba(0,0,0,.55) 3%,
    rgba(0,0,0,.06) 7%,
    rgba(0,0,0,.05) 73%,
    rgba(0,0,0,.45) 77%,
    #000 82%,
    #000 100%);
  mask-image:linear-gradient(90deg,
    #000 0%,
    rgba(0,0,0,.55) 3%,
    rgba(0,0,0,.06) 7%,
    rgba(0,0,0,.05) 73%,
    rgba(0,0,0,.45) 77%,
    #000 82%,
    #000 100%);
}

/* The shut-eye tile sits exactly on top of the open one. `steps(1)` is
   deliberate: an interpolated fade would ghost the open eyes through the
   closed lids, and a real blink is a cut anyway. */
.logofield::before{
  content:"";
  position:absolute;
  inset:-2px;                    /* kill sub-pixel seams at the edges */
  background-image:url("assets/logo-tile-closed.webp");
  background-repeat:repeat;
  background-size:64px auto;
  background-position:20px 26px; /* same phase once the inset is counted */
  opacity:0;
  animation:logo-blink 11s steps(1,end) infinite;
}

@keyframes logo-blink{
  /* An 11s cycle: one blink early, one at the midpoint, then a natural
     double blink. Each shut frame is ~1.4% of the cycle (~150ms), which
     is about a real blink — long enough to register, short enough not to
     pull the eye off the text. */
  0%,    15.4%  { opacity:0 }
  15.9%, 17.2%  { opacity:1 }
  17.7%, 54.4%  { opacity:0 }
  54.9%, 56.2%  { opacity:1 }
  56.7%, 84.4%  { opacity:0 }
  84.9%, 86.2%  { opacity:1 }
  86.7%, 89.4%  { opacity:0 }
  89.9%, 91.2%  { opacity:1 }
  91.7%, 100%   { opacity:0 }
}

/* Vertical fade: the field settles into the page instead of stopping
   dead at the top bar and the footer. */
.logofield::after{
  content:"";
  position:absolute;
  inset:0;
  background:
    linear-gradient(180deg,rgba(11,11,13,.55) 0%,rgba(11,11,13,0) 12%),
    linear-gradient(0deg,rgba(11,11,13,.6) 0%,rgba(11,11,13,0) 16%);
}

/* Phones: the gutter disappears, so keep a whisper of the pattern. */
@media (max-width:900px){
  .logofield{
    background-size:54px auto;
    opacity:.09;
    -webkit-mask-image:none;
    mask-image:none;
  }
  .logofield::before{background-size:54px auto}
}

@media (prefers-reduced-motion:reduce){
  .logofield::before{animation:none;opacity:0}
}

@media print{
  .logofield{display:none}
}
