/* Binary portal between the website and the Code Lab (js/portal.js) — 2 s out, a short decode in */
.cdp{position:fixed;inset:0;z-index:9000;display:grid;place-items:center;pointer-events:all;--p-bg:#FFF6EA;--p-ink:#16133F;--p-bit:#221E5B;--p-hot:#FF7A1A;--p-alt:#14BFC8}
:root[data-theme="dark"] .cdp{--p-bg:#0B0A22;--p-ink:#FFF6EA;--p-bit:#14BFC8;--p-hot:#FF7A1A;--p-alt:#9D97FF}
.cdp-bg{position:absolute;inset:0;background:var(--p-bg)}
.cdp canvas{position:absolute;inset:0;width:100%;height:100%}
.cdp-core{position:relative;display:flex;flex-direction:column;align-items:center;gap:18px;padding:20px}
.cdp-face{width:150px;aspect-ratio:1;border-radius:50%;background:#FFD7B5;display:grid;place-items:center;overflow:hidden;box-shadow:0 0 0 6px color-mix(in srgb,var(--p-hot) 30%,transparent),0 30px 60px -20px rgba(0,0,0,.5)}
.cdp-face svg{width:96%;height:auto}
.cdp-say{max-width:min(440px,86vw);background:var(--p-ink);color:var(--p-bg);border-radius:20px;padding:12px 18px;font:700 17px/1.55 'Tajawal','Rubik',sans-serif;text-align:center;min-height:1.6em}
html[lang="en"] .cdp-say{font-family:'Rubik','Tajawal',sans-serif}
.cdp-bits{font:700 15px/1 'JetBrains Mono',monospace;letter-spacing:.2em;color:var(--p-hot);direction:ltr}

/* leaving (2 s): rain fades in, Miss Enas pops in and talks, then she is "compiled" into bits */
.cdp.out .cdp-bg{animation:cdpBgIn .35s ease-out both}
.cdp.out .cdp-face{animation:cdpPop .55s .15s cubic-bezier(.3,1.6,.5,1) both,cdpGlitch .45s 1.35s steps(2,end) both}
.cdp.out .cdp-say{animation:cdpRise .5s .35s cubic-bezier(.22,1,.36,1) both,cdpFade .3s 1.6s ease-in forwards}
.cdp.out .cdp-bits{animation:cdpRise .4s .6s cubic-bezier(.22,1,.36,1) both,cdpFade .3s 1.6s ease-in forwards}
.cdp.out .cdp-face .eyes{animation:cdpLook 1s .45s ease-in-out both}
.cdp.out .cdp-face .m-o{animation:cdpTalk .16s .5s 6 alternate both}
@keyframes cdpBgIn{from{opacity:0}}
@keyframes cdpPop{from{transform:scale(.3) rotate(-12deg);opacity:0}}
@keyframes cdpRise{from{transform:translateY(14px);opacity:0}}
@keyframes cdpFade{to{opacity:0;transform:translateY(-8px)}}
@keyframes cdpLook{0%,100%{transform:translate(0,0)}35%{transform:translate(-6px,2px)}70%{transform:translate(6px,2px)}}
@keyframes cdpTalk{from{transform:scaleY(.3)}to{transform:scaleY(1)}}
@keyframes cdpGlitch{
  0%{clip-path:inset(0 0 0 0 round 50%);transform:none;opacity:1;filter:none}
  25%{clip-path:inset(20% 0 55% 0 round 12px);transform:translateX(-10px);filter:hue-rotate(60deg)}
  50%{clip-path:inset(60% 0 10% 0 round 12px);transform:translateX(12px) scale(1.05);filter:hue-rotate(-60deg)}
  75%{clip-path:inset(35% 0 35% 0 round 12px);transform:translateX(-4px) scale(.9);opacity:.6}
  100%{clip-path:inset(50% 0 50% 0 round 12px);transform:scale(.4);opacity:0}}
.cdp-face .eyes,.cdp-face .m-o{transform-box:fill-box;transform-origin:center}

/* going to the lab: the same choreography stretched to 3 s */
.cdp.out.long .cdp-face{animation:cdpPop .6s .15s cubic-bezier(.3,1.6,.5,1) both,cdpGlitch .55s 2.25s steps(2,end) both}
.cdp.out.long .cdp-say{animation:cdpRise .5s .35s cubic-bezier(.22,1,.36,1) both,cdpFade .35s 2.5s ease-in forwards}
.cdp.out.long .cdp-bits{animation:cdpRise .4s .6s cubic-bezier(.22,1,.36,1) both,cdpFade .35s 2.5s ease-in forwards}
.cdp.out.long .cdp-face .eyes{animation:cdpLook 1.6s .5s ease-in-out both}
.cdp.out.long .cdp-face .m-o{animation:cdpTalk .16s .5s 10 alternate both}

/* arriving (short decode): the rain thins out and lifts away */
.cdp.in{pointer-events:none}
.cdp.in .cdp-core{display:none}
.cdp.in{animation:cdpLift .85s .1s cubic-bezier(.65,0,.35,1) forwards}
@keyframes cdpLift{to{opacity:0;clip-path:inset(0 0 100% 0)}}

/* cover the first paint while a page is arriving through the portal */
html.cdp-arrive body::after{content:"";position:fixed;inset:0;z-index:8999;background:#FFF6EA}
html.cdp-arrive[data-theme="dark"] body::after{background:#0B0A22}
@media (prefers-reduced-motion:reduce){.cdp *,.cdp{animation:none !important}}
