/* Studio Textra: home. Alleen geladen op index.html, na textra.css.
   Beweging is CSS; alles staat stil bij prefers-reduced-motion. */

/* ---------- Alle tekst in Textra Hand ---------- */

:root {
  --font-serif: "Textra Hand", "Comic Sans MS", cursive;
  --font-sans: "Textra Hand", "Comic Sans MS", cursive;
}
body { font-family: var(--font-hand); }

/* ---------- Proef: hagelwit papier (alleen home) ---------- */

:root { --color-paper: #ffffff; }

/* ---------- Hero ---------- */

.rise { display: block; overflow: hidden; padding-bottom: .12em; margin-bottom: -.12em; }
.rise > span { display: block; animation: rise .9s cubic-bezier(.2, .8, .2, 1) both; animation-delay: var(--d, 0s); }
@keyframes rise { from { transform: translateY(110%) rotate(3deg); } to { transform: none; } }

.marker-sweep {
  background: linear-gradient(var(--color-highlight), var(--color-highlight)) no-repeat 0 88% / 0% 48%;
  -webkit-box-decoration-break: clone; box-decoration-break: clone; padding: 0 .08em;
  animation: sweep .9s 1.1s cubic-bezier(.6, 0, .2, 1) forwards;
}
@keyframes sweep { to { background-size: 100% 48%; } }

.bob { display: inline-block; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(.35em); } }

/* ---------- Tekstband ---------- */

.band { overflow: hidden; border-block: var(--line-thick) solid var(--color-ink); }
.band-track { display: flex; width: max-content; animation: band 45s linear infinite; }
.band-reverse .band-track { animation-direction: reverse; animation-duration: 38s; }
.band:hover .band-track { animation-play-state: paused; }
.band-item { display: flex; align-items: center; gap: 2.5rem; padding-right: 2.5rem; white-space: nowrap; }
@keyframes band { to { transform: translateX(-50%); } }

/* ---------- Cijfers en rijen ---------- */

.num-outline { color: transparent; -webkit-text-stroke: 2px var(--color-primary); transition: color .25s ease; }
.case-card:hover .num-outline, .case-card:focus-within .num-outline { color: var(--color-primary); }

.sweep-row {
  background: linear-gradient(var(--color-highlight), var(--color-highlight)) no-repeat 0 100% / 0% 100%;
  transition: background-size .4s cubic-bezier(.6, 0, .2, 1);
}
.sweep-row:hover, .sweep-row:focus-within { background-size: 100% 100%; }
.sweep-row .row-arrow { transition: transform .3s ease; }
.sweep-row:hover .row-arrow, .sweep-row:focus-within .row-arrow { transform: translateX(.3em) rotate(-8deg); }

.row-link { text-decoration: none; color: inherit; }
.row-link::after { content: ""; position: absolute; inset: 0; }
.row-link:focus-visible { outline: none; }
.sweep-row:has(.row-link:focus-visible) { outline: 3px solid var(--color-ink); outline-offset: 3px; }

/* ---------- Tekst die zich inkt bij het scrollen ---------- */

@supports (animation-timeline: view()) {
  [data-ink] .w { opacity: .16; animation: ink linear both; animation-timeline: view(); animation-range: entry 15% cover 40%; }
}
@keyframes ink { to { opacity: 1; } }

/* ---------- Echt schrijven: letter voor letter, met pen (JS zet .js-writing en maakt .wr en .pen) ---------- */

.js-writing .wr-word { display: inline-block; white-space: nowrap; }
.js-writing .wr { display: inline-block; clip-path: inset(-30% 100% -30% 0); }
.js-writing .wr.done { clip-path: none; }
.pen {
  position: absolute; width: .14em; border-radius: 2px; background: var(--color-primary);
  transform: translateX(.05em) rotate(20deg); transform-origin: bottom center;
  opacity: 0; pointer-events: none; transition: left .05s linear, top .05s linear;
}
.pen.on { opacity: 1; }

/* ---------- Zetwerk: nette regelval ---------- */

main :is(h1, h2, h3) { text-wrap: balance; }
main p { text-wrap: pretty; }

/* ---------- De lezer schrapt mee (CSS Custom Highlight API; JS zet .schrap-aan) ---------- */

::highlight(schrap) { color: var(--color-pencil); text-decoration: line-through; text-decoration-color: var(--color-primary); text-decoration-thickness: .12em; }
.schrap-aan main ::selection { background: transparent; color: var(--color-pencil); text-decoration: line-through; text-decoration-color: var(--color-primary); text-decoration-thickness: .12em; }

/* ---------- Voor en na: schrappen bij het scrollen ---------- */

.scrap {
  background: linear-gradient(var(--color-primary), var(--color-primary)) no-repeat 0 56% / 100% .12em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
@keyframes scrap { to { background-size: 100% .12em; color: var(--color-pencil); } }
@keyframes rewrite { from { clip-path: inset(-20% 100% -20% 0); } to { clip-path: inset(-20% -5% -20% 0); } }
@keyframes ink-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.ink-progress { display: none; }

@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .scrap-wrap { view-timeline-name: --scrap; }
    .scrap { background-size: 0% .12em; animation: scrap linear both; animation-timeline: --scrap; animation-range: entry 55% cover 50%; }
    .rewrite { animation: rewrite linear both; animation-timeline: view(); animation-range: entry 25% cover 45%; }
    .ink-progress {
      display: block; position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 60;
      background: var(--color-primary); transform-origin: left center;
      animation: ink-progress linear both; animation-timeline: scroll(root);
    }
  }
}

/* ---------- Rijen: titel schuift mee ---------- */

.sweep-row h3 { transform-origin: left center; transition: transform .3s cubic-bezier(.2, 1.4, .3, 1); }
.sweep-row:hover h3, .sweep-row:focus-within h3 { transform: translateX(.12em) rotate(-1.5deg); }

/* ---------- Stilstand als het moet ---------- */

@media (prefers-reduced-motion: reduce) {
  .rise > span, .band-track, .bob { animation: none !important; transform: none !important; }
  .marker-sweep { animation: none !important; background-size: 100% 48%; }
  [data-ink] .w { animation: none !important; opacity: 1; }
  .sweep-row { transition: none; }
}
