/* ==========================================================
   Page transition: a purple portal opens from the clicked link,
   then closes over the new page (driven by js/transition.js)
   ========================================================== */

:root { --pt-logo: min(300px, 68vw, 60vh); }   /* size of the logo in the middle */

/* leaving: the circle grows from the click point */
.pt {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 50% 50%, #3b0a6b 0, #1a0533 38%, #07030f 75%);
    animation: ptOpen .55s cubic-bezier(.7, 0, .2, 1) forwards;
}
.pt__ring {                      /* golden edge racing ahead of the circle */
    position: fixed;
    z-index: 1001;
    width: 40px; height: 40px;
    margin: -20px 0 0 -20px;
    border: 2px solid #f5c35a;
    border-radius: 50%;
    box-shadow: 0 0 24px #f5c35a, inset 0 0 18px rgba(192, 132, 252, .9);
    pointer-events: none;
    animation: ptRing .65s cubic-bezier(.3, .6, .3, 1) forwards;
}
.pt__logo,
html.pt-enter::after {
    width: var(--pt-logo);
    height: var(--pt-logo);
    border-radius: 50%;
    background: url("../img/brand/logo-512.webp") center / cover;
    box-shadow: 0 0 70px rgba(245, 195, 90, .55);
}
.pt__logo { animation: ptLogo .55s .05s cubic-bezier(.2, .8, .2, 1) both; }

@keyframes ptOpen {
    from { clip-path: circle(0 at var(--x) var(--y)); }
    to   { clip-path: circle(150% at var(--x) var(--y)); }
}
@keyframes ptRing { to { transform: scale(45); opacity: 0; } }
@keyframes ptLogo { from { opacity: 0; transform: scale(.4) rotate(-120deg); } }

/* arriving: the new page starts covered (class set in <head>, before the first paint) */
html.pt-enter::before,
html.pt-enter::after {
    content: '';
    position: fixed;
    z-index: 1000;
    pointer-events: none;
}
html.pt-enter::before {
    inset: 0;
    background: radial-gradient(circle at 50% 50%, #3b0a6b 0, #1a0533 38%, #07030f 75%);
    animation: ptClose .75s .15s cubic-bezier(.7, 0, .2, 1) both;
}
html.pt-enter::after {
    left: 50%; top: 50%;
    margin: calc(var(--pt-logo) / -2) 0 0 calc(var(--pt-logo) / -2);
    animation: ptLogoOut .55s .15s ease-in both;
}
@keyframes ptClose {
    from { clip-path: circle(150% at 50% 50%); visibility: visible; }
    to   { clip-path: circle(0 at 50% 50%); visibility: hidden; }
}
@keyframes ptLogoOut {
    from { opacity: 1; transform: none; visibility: visible; }
    to   { opacity: 0; transform: scale(1.7) rotate(120deg); visibility: hidden; }
}

/* first visit, slow and soft: the logo drifts in, breathes, then dissolves as the page opens (about 4s) */
html.pt-intro::before { animation: ptClose 1.6s 2.5s cubic-bezier(.65, 0, .35, 1) both; }
html.pt-intro::after { animation: ptIntroLogo 3.6s both; }
@keyframes ptIntroLogo {          /* the easing applies to each step, so every change starts and ends gently */
    0%   { opacity: 0; transform: scale(.72) rotate(-45deg); visibility: visible; animation-timing-function: cubic-bezier(.22, .61, .36, 1); }
    40%  { opacity: 1; transform: scale(1) rotate(0deg); animation-timing-function: ease-in-out; }
    58%  { opacity: 1; transform: scale(1.04) rotate(0deg); animation-timing-function: ease-in-out; }
    72%  { opacity: 1; transform: scale(1) rotate(0deg); animation-timing-function: cubic-bezier(.45, 0, .55, 1); }
    100% { opacity: 0; transform: scale(1.35) rotate(30deg); visibility: hidden; }
}
