/* scratchme.com, coming soon: one page, no scripts.
   After 197historiasilustradas.com: a line types itself, the title holds the middle,
   and a field of square pictures opens out from the center in a diamond. Here the
   pictures are moments from @scratchme.co, the title is the logo, and the field
   drifts on its own (the site runs no scripts).
   Brand: black, white, Archivo, and one accent, the pink the image analysis draws in. */

@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo-var-latin.woff2") format("woff2");
  font-weight: 400 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}

:root {
  --black: #000;
  --white: #fff;
  --ink-d2: #9b9b9b;        /* secondary text on black */
  --pink: #ff1fa9;          /* the measurement color */
  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --pad: 24px;
  --t: clamp(88px, 8.5vmax, 168px); /* a tile */
  --px: calc(var(--t) * 1.72);       /* column pitch */
  --py: calc(var(--t) * 1.72);       /* row pitch */
  --lift: calc(var(--t) * .3);       /* every other column sits a little lower */
  --soon: 5.31s;                  /* when the tiles start to open out; everything is timed from it */
}

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

html {
  background: var(--black);
  color: var(--white);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font: 400 1rem/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
::selection { background: var(--pink); color: var(--white); }
p { margin: 0; }
a { color: inherit; text-decoration: none; }

.vh {                                /* for screen readers only */
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.lab {                               /* small labels: Archivo's condensed cut, bold capitals */
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 700;
  font-stretch: 75%;
  line-height: 1.3;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

@keyframes in   { to { opacity: 1; } }
@keyframes in2  { to { opacity: 1; } }
@keyframes out  { to { opacity: 0; visibility: hidden; } }
@keyframes out2 { to { opacity: 0; visibility: hidden; } }

/* ---- 1. the line that types itself ---- */

.intro {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  padding: var(--pad);
  pointer-events: none;
  animation: out .45s ease-in calc(var(--soon) - 1.15s) forwards;
}
.typed {                             /* the scratchme.ai headline face: Archivo at 62% width, weight 800, capitals */
  font-size: clamp(2.6rem, 6.4vw, 7rem);
  font-weight: 800;
  font-stretch: 62%;
  line-height: 0.86;
  letter-spacing: -0.005em;
  text-transform: uppercase;
}
.typed .s { display: block; text-wrap: balance; }
.typed .s > span { opacity: 0; animation: key 1ms linear forwards; }
@keyframes key { to { opacity: 1; } }
.s1 > span:nth-of-type(1) { animation-delay: 0.400s; }
.s1 > span:nth-of-type(2) { animation-delay: 0.428s; }
.s1 > span:nth-of-type(3) { animation-delay: 0.456s; }
.s1 > span:nth-of-type(4) { animation-delay: 0.484s; }
.s1 > span:nth-of-type(5) { animation-delay: 0.512s; }
.s1 > span:nth-of-type(6) { animation-delay: 0.540s; }
.s1 > span:nth-of-type(7) { animation-delay: 0.568s; }
.s1 > span:nth-of-type(8) { animation-delay: 0.596s; }
.s1 > span:nth-of-type(9) { animation-delay: 0.624s; }
.s1 > span:nth-of-type(10) { animation-delay: 0.652s; }
.s1 > span:nth-of-type(11) { animation-delay: 0.680s; }
.s1 > span:nth-of-type(12) { animation-delay: 0.708s; }
.s1 > span:nth-of-type(13) { animation-delay: 0.736s; }
.s1 > span:nth-of-type(14) { animation-delay: 0.764s; }
.s1 > span:nth-of-type(15) { animation-delay: 0.792s; }
.s1 > span:nth-of-type(16) { animation-delay: 0.820s; }
.s1 > span:nth-of-type(17) { animation-delay: 0.848s; }
.s1 > span:nth-of-type(18) { animation-delay: 0.876s; }
.s1 > span:nth-of-type(19) { animation-delay: 0.904s; }
.s1 > span:nth-of-type(20) { animation-delay: 0.932s; }
.s1 > span:nth-of-type(21) { animation-delay: 0.960s; }
.s1 > span:nth-of-type(22) { animation-delay: 0.988s; }
.s1 > span:nth-of-type(23) { animation-delay: 1.016s; }
.s1 > span:nth-of-type(24) { animation-delay: 1.044s; }
.s1 > span:nth-of-type(25) { animation-delay: 1.072s; }
.s1 > span:nth-of-type(26) { animation-delay: 1.100s; }
.s1 > span:nth-of-type(27) { animation-delay: 1.128s; }
.s1 > span:nth-of-type(28) { animation-delay: 1.156s; }
.s1 > span:nth-of-type(29) { animation-delay: 1.184s; }
.s1 > span:nth-of-type(30) { animation-delay: 1.212s; }
.s1 > span:nth-of-type(31) { animation-delay: 1.240s; }
.s1 > span:nth-of-type(32) { animation-delay: 1.268s; }
.s1 > span:nth-of-type(33) { animation-delay: 1.296s; }
.s1 > span:nth-of-type(34) { animation-delay: 1.324s; }
.s1 > span:nth-of-type(35) { animation-delay: 1.352s; }
.s1 > span:nth-of-type(36) { animation-delay: 1.380s; }
.s1 > span:nth-of-type(37) { animation-delay: 1.408s; }
.s1 > span:nth-of-type(38) { animation-delay: 1.436s; }
.s1 > span:nth-of-type(39) { animation-delay: 1.464s; }
.s1 > span:nth-of-type(40) { animation-delay: 1.492s; }
.s1 > span:nth-of-type(41) { animation-delay: 1.520s; }
.s1 > span:nth-of-type(42) { animation-delay: 1.548s; }
.s1 > span:nth-of-type(43) { animation-delay: 1.576s; }
.s1 > span:nth-of-type(44) { animation-delay: 1.604s; }
.s1 > span:nth-of-type(45) { animation-delay: 1.632s; }
.s1 > span:nth-of-type(46) { animation-delay: 1.660s; }
.s1 > span:nth-of-type(47) { animation-delay: 1.688s; }
.s1 > span:nth-of-type(48) { animation-delay: 1.716s; }
.s1 > span:nth-of-type(49) { animation-delay: 1.744s; }
.s1 > span:nth-of-type(50) { animation-delay: 1.772s; }
.s1 > span:nth-of-type(51) { animation-delay: 1.800s; }
.s1 > span:nth-of-type(52) { animation-delay: 1.828s; }
.s1 > span:nth-of-type(53) { animation-delay: 1.856s; }
.s1 > span:nth-of-type(54) { animation-delay: 1.884s; }
.s1 > span:nth-of-type(55) { animation-delay: 1.912s; }
.s1 > span:nth-of-type(56) { animation-delay: 1.940s; }
.s1 > span:nth-of-type(57) { animation-delay: 1.968s; }
.s1 > span:nth-of-type(58) { animation-delay: 1.996s; }
.s1 > span:nth-of-type(59) { animation-delay: 2.024s; }
.s1 > span:nth-of-type(60) { animation-delay: 2.052s; }
.s1 > span:nth-of-type(61) { animation-delay: 2.080s; }
.s1 > span:nth-of-type(62) { animation-delay: 2.108s; }
.s1 > span:nth-of-type(63) { animation-delay: 2.136s; }
.s1 > span:nth-of-type(64) { animation-delay: 2.164s; }
.s1 > span:nth-of-type(65) { animation-delay: 2.192s; }
.s1 > span:nth-of-type(66) { animation-delay: 2.220s; }
.s2 > span:nth-of-type(1) { animation-delay: 2.568s; }
.s2 > span:nth-of-type(2) { animation-delay: 2.596s; }
.s2 > span:nth-of-type(3) { animation-delay: 2.624s; }
.s2 > span:nth-of-type(4) { animation-delay: 2.652s; }
.s2 > span:nth-of-type(5) { animation-delay: 2.680s; }
.s2 > span:nth-of-type(6) { animation-delay: 2.708s; }
.s2 > span:nth-of-type(7) { animation-delay: 2.736s; }
.s2 > span:nth-of-type(8) { animation-delay: 2.764s; }
.s2 > span:nth-of-type(9) { animation-delay: 2.792s; }
.s2 > span:nth-of-type(10) { animation-delay: 2.820s; }
.s2 > span:nth-of-type(11) { animation-delay: 2.848s; }
.s2 > span:nth-of-type(12) { animation-delay: 2.876s; }
.s2 > span:nth-of-type(13) { animation-delay: 2.904s; }
.s2 > span:nth-of-type(14) { animation-delay: 2.932s; }
.s2 > span:nth-of-type(15) { animation-delay: 2.960s; }
.s2 > span:nth-of-type(16) { animation-delay: 2.988s; }
.s2 > span:nth-of-type(17) { animation-delay: 3.016s; }
.s2 > span:nth-of-type(18) { animation-delay: 3.044s; }
.s2 > span:nth-of-type(19) { animation-delay: 3.072s; }
.s2 > span:nth-of-type(20) { animation-delay: 3.100s; }
.s2 > span:nth-of-type(21) { animation-delay: 3.128s; }
.s2 > span:nth-of-type(22) { animation-delay: 3.156s; }
.s2 > span:nth-of-type(23) { animation-delay: 3.184s; }
.s2 > span:nth-of-type(24) { animation-delay: 3.212s; }
.s2 > span:nth-of-type(25) { animation-delay: 3.240s; }
.s2 > span:nth-of-type(26) { animation-delay: 3.268s; }
.s2 > span:nth-of-type(27) { animation-delay: 3.296s; }
.s2 > span:nth-of-type(28) { animation-delay: 3.324s; }
.s2 > span:nth-of-type(29) { animation-delay: 3.352s; }
.s2 > span:nth-of-type(30) { animation-delay: 3.380s; }
.s2 > span:nth-of-type(31) { animation-delay: 3.408s; }

/* [ Skip ]: a checkbox, so it works without scripts */
.skip-box {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  animation: out 1ms linear calc(var(--soon) - 1.15s) forwards;
}
.skip {
  position: fixed;
  z-index: 6;
  left: 50%;
  bottom: 40px;
  padding: 8px 10px;
  transform: translateX(-50%);
  color: var(--ink-d2);
  white-space: nowrap;
  cursor: pointer;
  animation: out .3s ease-in calc(var(--soon) - 1.15s) forwards;
}
.skip:hover { color: var(--white); }
.skip-box:focus-visible + .skip { color: var(--white); outline: 2px solid var(--pink); outline-offset: 2px; }

/* ---- 2. the logo holds the middle, then moves up into the bar ---- */

.mark {
  position: fixed;
  z-index: 4;
  left: 50%;
  top: 50%;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%);
  transform-origin: 50% 0;
  animation:
    in .6s ease-out calc(var(--soon) - .8s) forwards,
    dock .9s cubic-bezier(.7, 0, .2, 1) calc(var(--soon) + .4s) forwards;
}
.mark img { display: block; width: 160px; height: auto; margin: 0 auto; }
.mark-soon { margin-top: 1.1rem; animation: out .3s ease-in calc(var(--soon) + .4s) forwards; }
@keyframes dock {
  to {
    transform: translate(-50%, calc(20px - 50vh)) scale(.6);
    transform: translate(-50%, calc(20px - 50dvh)) scale(.6);
  }
}
@keyframes dock2 {
  to {
    transform: translate(-50%, calc(20px - 50vh)) scale(.6);
    transform: translate(-50%, calc(20px - 50dvh)) scale(.6);
  }
}

/* ---- 3. the field: an 8 x 4 block of tiles, repeated 4 x 4 times, drifting one block
   up and to the left per loop so the loop never shows ---- */

.field { position: fixed; inset: 0; overflow: hidden; }
.grid {
  position: absolute;
  left: calc(50vw - 8 * var(--px) - var(--t) / 2);    /* a room full of collectors sits mid-screen, under the logo */
  top: calc(50vh - 4 * var(--py) - var(--t) / 2);
  top: calc(50dvh - 4 * var(--py) - var(--t) / 2);
  display: grid;
  grid-template-columns: repeat(32, var(--px));
  grid-auto-rows: var(--py);
  animation: drift 160s linear calc(var(--soon) + 1.5s) infinite;
}
@keyframes drift  { to { transform: translate(calc(-8 * var(--px)), calc(-4 * var(--py))); } }
@keyframes drift2 { to { transform: translate(calc(-8 * var(--px)), calc(-4 * var(--py))); } }
.grid:has(.tile:hover),
.grid:has(.tile:focus-visible) { animation-play-state: paused; }

.tile { position: relative; display: block; width: var(--t); height: var(--t); }
.tile:nth-child(2n) { margin-top: var(--lift); }
.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.06);
  outline: 1.5px solid transparent;
  outline-offset: 5px;
  transition: filter .3s, outline-color .3s;
}
.tile.card img { width: auto; margin: 0 auto; }    /* whole cards, not cropped */
.tile:hover,
.tile:focus-visible { z-index: 2; outline: none; }
.tile:hover img,
.tile:focus-visible img { filter: none; outline-color: var(--pink); }

.cap {                                             /* number and caption, shown on hover */
  position: absolute;
  left: 0;
  top: calc(100% + 14px);
  width: calc(var(--px) - 16px);
  color: var(--ink-d2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.cap b { margin-right: .3em; color: var(--white); font-weight: 700; }
.tile.card .cap { left: calc(var(--t) * .146); }
.tile:hover .cap,
.tile:focus-visible .cap { opacity: 1; }

/* opening out from the middle, one ring every 80 ms; rings past 12 start off-screen */
.tile:not(.rx) { animation: bloom .55s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes bloom  { from { opacity: 0; transform: scale(.6); } }
@keyframes bloom2 { from { opacity: 0; transform: scale(.6); } }
.tile.r0 { animation-delay: calc(var(--soon) + 1.00s); }
.tile.r1 { animation-delay: calc(var(--soon) + 0.08s); }
.tile.r2 { animation-delay: calc(var(--soon) + 0.16s); }
.tile.r3 { animation-delay: calc(var(--soon) + 0.24s); }
.tile.r4 { animation-delay: calc(var(--soon) + 0.32s); }
.tile.r5 { animation-delay: calc(var(--soon) + 0.40s); }
.tile.r6 { animation-delay: calc(var(--soon) + 0.48s); }
.tile.r7 { animation-delay: calc(var(--soon) + 0.56s); }
.tile.r8 { animation-delay: calc(var(--soon) + 0.64s); }
.tile.r9 { animation-delay: calc(var(--soon) + 0.72s); }
.tile.r10 { animation-delay: calc(var(--soon) + 0.80s); }
.tile.r11 { animation-delay: calc(var(--soon) + 0.88s); }
.tile.r12 { animation-delay: calc(var(--soon) + 0.96s); }

/* ---- 4. the bar and the footer ---- */

.chrome {
  position: fixed;
  z-index: 3;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0 var(--pad);
  pointer-events: none;
  opacity: 0;
  animation: in .6s ease-out calc(var(--soon) + 1.1s) forwards;
}
.chrome a { pointer-events: auto; }
.top {
  top: 0;
  height: 120px;
  align-items: flex-start;
  padding-top: 36px;
  background: linear-gradient(var(--black) 62%, rgb(0 0 0 / 0));
}
.bottom {
  bottom: 0;
  height: 96px;
  align-items: flex-end;
  padding-bottom: 22px;
  color: var(--ink-d2);
  background: linear-gradient(rgb(0 0 0 / 0), var(--black) 72%);
}
.social { display: flex; gap: 1.1rem; }
.social a { color: var(--white); }
.social a::after {                   /* links: a small arrow after the words, as on the site */
  content: "\2191";
  display: inline-block;
  margin-left: 0.15em;
  transform: rotate(45deg);
  color: var(--pink);
}
.social a:hover { color: var(--pink); }
.social a:focus-visible { outline: 2px solid var(--pink); outline-offset: 3px; }
.social-bottom { display: none; }    /* on phones the links move down to the footer */

/* ---- [ Skip ]: the same sequence, fast ---- */

body:has(#skip:checked) { --soon: .15s; }
body:has(#skip:checked) .intro,
body:has(#skip:checked) .skip,
body:has(#skip:checked) .skip-box { display: none; }
body:has(#skip:checked) .mark { animation-name: in2, dock2; }
body:has(#skip:checked) .mark-soon { animation-name: out2; }
body:has(#skip:checked) .tile:not(.rx) { animation-name: bloom2; }
body:has(#skip:checked) .chrome { animation-name: in2; }
body:has(#skip:checked) .grid { animation-name: drift2; }

/* ---- phones ---- */

@media (max-width: 40rem) {
  :root { --pad: 16px; }
  .lab { font-size: 0.6875rem; }
  .bottom {
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 0.2rem;
    height: 150px;
    background: linear-gradient(rgb(0 0 0 / 0), var(--black) 42%);   /* solid behind all three lines */
  }
  .social-top { display: none; }
  .social-bottom { display: flex; gap: 1rem; margin-bottom: 0.45rem; }
  .skip { bottom: 28px; }
}

/* ---- reduced motion: no typing, no opening out, no drift ---- */

@media (prefers-reduced-motion: reduce) {
  .intro, .skip, .skip-box, .mark-soon { display: none; }
  .mark {
    animation: none;
    opacity: 1;
    transform: translate(-50%, calc(20px - 50vh)) scale(.6);
    transform: translate(-50%, calc(20px - 50dvh)) scale(.6);
  }
  .tile:not(.rx), .grid, .chrome { animation: none; }
  .chrome { opacity: 1; }
}
