/* CODR landing — page transitions between pages (index ⇄ login). Works with js/page-transition.js. Only under html.motion
   (OS does not ask for reduced motion). "Grid Wave": the page is covered by a wave of Petrol squares on the same 32px grid as the
   grid-paper backdrop. The wave starts at the exact point the visitor clicked (or the centre of the focused link); every square grows
   from nothing with a delay that depends on its distance from that point, and the leading squares glow Orange. When the page is
   covered the four logo tiles (C · O · D · R) assemble in the middle while the next page loads. On the next page the tiles fall apart
   and the squares shrink away from the SAME point (glowing Orange as they go), revealing the page, which then rises in.
   The squares are painted on a <canvas> by the script (per-cell timing is not expressible in CSS); this file holds the cover, the logo
   mark, the depth effect on the old page and the page-block entrance. Explicit longhands, one easing, no shorthand.
   Timing (constants live in js/page-transition.js): wave 420ms spread + 300ms per square = 720ms; logo mark 260ms (+60ms steps);
   after release the mark leaves in 220ms, the reveal wave starts 160ms later, page blocks rise at 420ms / 540ms. */

:root {
  --pt-ease: cubic-bezier(0.65, 0, 0.35, 1);   /* in-out cubic: gentle start, long soft landing */
  --pt-recede: 28px;                            /* how far the outgoing page drifts upward while the wave covers it */
  --pt-x: 50%;                                  /* click point as % of the viewport; set by the script / the head script */
  --pt-y: 50%;
}

.pt-curtain {
  position: fixed;
  inset: 0;
  z-index: 1000;                                   /* above the sticky header (50) */
  pointer-events: none;                            /* never blocks a click, even while covering */
}
.pt-curtain canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---- Logo mark: the four tiles of the brand, shown only while the page is fully covered ---- */
.pt-mark { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 6px; }
.pt-mark i {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  font-size: 2rem;
  font-style: normal;
  font-weight: 700;
  line-height: 1;
  color: var(--petrol);
  background: var(--concrete);
  opacity: 0;
  transform: scale(0.6);
}
.pt-mark i:nth-child(2) { color: var(--ink); background: var(--orange); }

/* ---- Leave: the wave covers the page, then the mark assembles; the old page recedes underneath (depth) ---- */
.motion.is-leaving main,
.motion.is-leaving .site-footer {
  opacity: 0.6;
  transform: translateY(calc(var(--pt-recede) * -1));
  transition-property: transform, opacity;
  transition-duration: 720ms;
  transition-timing-function: var(--pt-ease);
}
.motion.is-covered .pt-mark i {
  animation-name: pt-mark-in;
  animation-duration: 260ms;
  animation-timing-function: var(--ease-out);
  animation-fill-mode: both;
}
.motion.is-covered .pt-mark i:nth-child(2) { animation-delay: 60ms; }
.motion.is-covered .pt-mark i:nth-child(3) { animation-delay: 120ms; }
.motion.is-covered .pt-mark i:nth-child(4) { animation-delay: 180ms; }

/* ---- Arrive: covered from the very first paint (head script adds pt-hold only when the hand-over flag exists) ---- */
.pt-hold .pt-curtain {
  background: var(--petrol);
  animation-name: pt-curtain-failsafe;              /* failsafe: if the script never releases, the curtain goes away after 2.5s */
  animation-duration: 0s;
  animation-delay: 2.5s;
  animation-fill-mode: forwards;
}
.pt-hold .pt-mark i { opacity: 1; transform: none; }

/* ---- Released: the mark falls apart, then (script) the squares shrink away; page blocks rise ---- */
.pt-in .pt-mark i {
  opacity: 1;
  animation-name: pt-mark-out;
  animation-duration: 220ms;
  animation-timing-function: var(--pt-ease);
  animation-fill-mode: both;
}
.pt-in .pt-mark i:nth-child(2) { animation-delay: 40ms; }
.pt-in .pt-mark i:nth-child(3) { animation-delay: 80ms; }
.pt-in .pt-mark i:nth-child(4) { animation-delay: 120ms; }

.pt-in main[data-pt-enter] [data-pt-item] {
  animation-name: pt-enter;
  animation-duration: 560ms;
  animation-timing-function: var(--ease-out);
  animation-fill-mode: both;
  animation-delay: 420ms;
}
.pt-in main[data-pt-enter] [data-pt-item]:nth-child(2) { animation-delay: 540ms; }

@keyframes pt-mark-in {
  from { opacity: 0; transform: translateY(10px) scale(0.6); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pt-mark-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-8px) scale(0.85); }
}
@keyframes pt-enter {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pt-curtain-failsafe { from { opacity: 1; } to { opacity: 0; } }

@media print {
  .pt-curtain { display: none; }
  .motion.is-leaving main, .motion.is-leaving .site-footer { opacity: 1; transform: none; }
}
