.motif-section {
  position: relative;
  isolation: isolate;
  --ink-color: #80512e;
  --ink-strength: .36;
  --art-size: clamp(270px, 44vw, 660px);
  --art-edge: -5vw;
  --art-mask: linear-gradient(to left, #000 0 38%, transparent 98%);
}

.motif-section.hero,
.motif-section.contact {
  --ink-color: #e3ae76;
  --ink-strength: .62;
}

.motif-section.hero {
  --art-size: clamp(430px, 61vw, 930px);
  --art-edge: -3vw;
  --art-mask: linear-gradient(to left, #000 0 31%, transparent 96%);
}

.motif-section.contact { --ink-strength: .4; }
.motif-section.manifesto { --ink-strength: .27; }

.motif-left {
  --art-mask: linear-gradient(to right, #000 0 23%, transparent 91%);
}

.motif-backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
  -webkit-mask-image: var(--art-mask);
  mask-image: var(--art-mask);
}

.hero .motif-backdrop { z-index: 0; }

.motif-layer {
  position: absolute;
  width: var(--art-size);
  aspect-ratio: 1;
  top: 50%;
  right: var(--art-edge);
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 1.13s ease;
}

.motif-left .motif-layer { right: auto; left: var(--art-edge); }
.motif-layer.is-active { opacity: var(--ink-strength); }

.motif-layer::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--ink-color);
  -webkit-mask: var(--plate) center / contain no-repeat;
  mask: var(--plate) center / contain no-repeat;
  animation: stahlstich-drift 10s ease-in-out infinite alternate;
  animation-play-state: paused;
  transform: translateX(-2%);
}

.motif-moving .motif-layer.is-active::before { animation-play-state: running; }
.motif-layer.is-turning::before { animation-name: stahlstich-turn; }

@keyframes stahlstich-drift {
  from { transform: translate(-5%, 2%); }
  to { transform: translate(4%, -2%); }
}

@keyframes stahlstich-turn {
  from { transform: translateX(-2%) rotate(-5deg); }
  to { transform: translateX(3%) rotate(7deg); }
}

.motif-toggle {
  align-self: flex-start;
  padding: 4px 11px;
  border: 1px solid #ddba8c61;
  border-radius: 20px;
  color: #eee2d1;
  background: #16130fea;
  font: inherit;
  font-size: .8rem;
  cursor: pointer;
}

.motif-toggle:hover { border-color: #ddba8c; }

.field--books { --field-plate: url("12.webp"); }
.field--language { --field-plate: url("10.webp"); }
.field--technology { --field-plate: url("04.webp"); }

.field::before {
  content: "";
  position: absolute;
  inset: 0 0 0 23%;
  z-index: -1;
  background: var(--field-plate) right bottom / auto 125% no-repeat;
  opacity: .58;
  mask-image: linear-gradient(to right, transparent, rgba(0,0,0,.24) 46%, #000 85%);
  pointer-events: none;
}

@media (max-width: 820px) {
  .field::before {
    inset-inline-start: 31%;
    background-size: auto 118%;
  }
}

.work-item[href]:hover strong, .work-item[href]:focus-visible strong { text-decoration: underline; }
.work-item[href] strong { text-decoration: underline; text-underline-offset: .19em; }

@media (max-width: 820px) {
  .motif-section { --art-size: min(73vw, 430px); --art-edge: -21vw; --ink-strength: .24; }
  .motif-section.hero {
    --art-size: min(98vw, 630px);
    --art-edge: -21vw;
    --ink-strength: .4;
  }
  .motif-section.contact { --ink-strength: .28; }
  .motif-section.manifesto { --ink-strength: .21; }
  .motif-toggle { margin: 9px 0 3px; }
}

@media (prefers-reduced-motion: reduce) {
  .motif-layer { transition: none; }
  .motif-layer::before { animation: none; }
}

.matrix-rain {
  --matrix-tone: #643c21;
  --matrix-accent: #643c21;
  --matrix-wash: #6a3f24a0;
  position: absolute;
  inset: 0 0 0 auto;
  width: min(54%, 730px);
  overflow: hidden;
  pointer-events: none;
}

.hero .matrix-rain, .contact .matrix-rain {
  --matrix-tone: #efbb83;
  --matrix-accent: #ffd4a6;
  --matrix-wash: #f6be7fbd;
}

.motif-left .matrix-rain { inset: 0 auto 0 0; }

.field .matrix-rain {
  width: 64%;
  z-index: -1;
}

.field .matrix-language {
  --matrix-accent: #77431f;
  --matrix-wash: #86552d9c;
}

.hero .matrix-language, .contact .matrix-language {
  --matrix-accent: #ffe0b4;
  --matrix-wash: #d5965ebd;
}

.matrix-rain::before {
  content: "";
  position: absolute;
  width: var(--art-size, 100%);
  aspect-ratio: 1;
  top: 50%;
  right: var(--art-edge, 0);
  transform: translateY(-50%);
  background: linear-gradient(to bottom, transparent 27%, var(--matrix-wash) 48%, transparent 69%);
  background-size: 100% 55%;
  background-repeat: no-repeat;
  -webkit-mask: var(--matrix-plate, var(--field-plate)) center / contain no-repeat;
  mask: var(--matrix-plate, var(--field-plate)) center / contain no-repeat;
  animation: matrix-contours 870ms ease-out both;
}

.motif-left .matrix-rain::before { right: auto; left: var(--art-edge); }

.matrix-column {
  position: absolute;
  left: var(--x);
  top: var(--y);
  display: grid;
  justify-items: center;
  color: var(--matrix-tone);
  font: 600 clamp(10px, .94vw, 15px) / 1.15 ui-monospace, Consolas, monospace;
  animation: matrix-fall 740ms var(--delay) ease-out both;
}

.matrix-column i { font-style: normal; opacity: .44; }
.matrix-column i:nth-child(n+4) { opacity: .8; }
.matrix-column i:last-child { opacity: 1; }
.matrix-column.matrix-accent { color: var(--matrix-accent); }

.hero .matrix-column.matrix-accent, .contact .matrix-column.matrix-accent {
  text-shadow: 0 0 7px #efbb8380;
}

@keyframes matrix-fall {
  0% { opacity: 0; transform: translateY(-52px); }
  24% { opacity: .86; }
  64% { opacity: .65; }
  100% { opacity: 0; transform: translateY(112px); }
}

@keyframes matrix-contours {
  0% { opacity: 0; background-position: center -120%; }
  37% { opacity: .75; }
  100% { opacity: 0; background-position: center 235%; }
}

@media (max-width: 820px) {
  .matrix-rain { width: 63%; }
}

@media (prefers-reduced-motion: reduce) {
  .matrix-rain { display: none; }
}

.contact-matrix { position: relative; }
.contact-matrix.is-dissolving > span:first-child { opacity: 0; }

.contact-matrix-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.contact-matrix-word { display: inline-block; white-space: nowrap; }

.contact-matrix-letter {
  display: inline-block;
  position: relative;
  animation: contact-letter 1.15s var(--letter-delay) both;
}

.contact-matrix-letter::after {
  content: attr(data-glyph);
  position: absolute;
  inset: 0;
  color: #70ff94;
  text-shadow: 0 0 .5em #27d45e;
  font: 600 .9em/1.65 ui-monospace, monospace;
  text-align: center;
  animation: contact-glyph 1.15s var(--letter-delay) both;
}

@keyframes contact-letter {
  0%, 100% { color: inherit; }
  25%, 69% { color: transparent; }
}

@keyframes contact-glyph {
  0% { opacity: 0; transform: translateY(0); }
  24% { opacity: 1; }
  69%, 100% { opacity: 0; transform: translateY(1.9em); }
}
