/* DevAcademy shared interface - every page except index.html (which keeps its own preloader):
   the circular preloader, the index.html cursor, noise texture and magnetic buttons.
   Markup comes from pp_ui_body() in config.php, behaviour from ui.js. */

/* --- Preloader: a ring fills up, then shrinks into the cursor dot and the mask fades away --- */
.pp-loader {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: var(--bg-dark, #0a0a0a);
    z-index: 99990;
    transition: opacity 0.8s cubic-bezier(0.85, 0, 0.15, 1), visibility 0.8s;
}

html.pp-ready .pp-loader { opacity: 0; visibility: hidden; pointer-events: none; }

.pp-loader-svg {
    position: fixed;
    top: 50%; left: 50%;
    width: 160px; height: 160px;
    transform: translate(-50%, -50%) rotate(-90deg);
    z-index: 100000;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.pp-loader-svg circle {
    fill: none;
    stroke: #FF5A00;
    stroke-width: 2;
    stroke-dasharray: 440;
    stroke-dashoffset: 440;
    transition: stroke-dashoffset 0.1s linear;
}

/* optional word inside the ring, e.g. "Terminating" on logout.php */
.pp-loader-text {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100001;
    pointer-events: none;
    color: #FF5A00;
    font-family: 'Outfit', sans-serif;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 3px;
    text-transform: uppercase;
    text-align: center;
    transition: opacity 0.4s ease;
}

.pp-loader-svg.done, .pp-loader-text.done { opacity: 0; }

@keyframes ppPulseLoader {
    0% { transform: translate(-50%, -50%) scale(0.95); }
    50% { transform: translate(-50%, -50%) scale(1.05); }
    100% { transform: translate(-50%, -50%) scale(0.95); }
}

/* --- Noise Overlay --- */
.pp-noise {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    pointer-events: none;
    z-index: 9998;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* --- Custom Cursor (same as index.html) ---
   A direct child of <body> (never inside a wrapper with its own z-index), so mix-blend-mode can
   invert whatever is underneath - that is what makes the big white circle look see-through.
   It starts in the middle of the screen as the preloader ring. */
.pp-cursor {
    position: fixed;
    top: 50%; left: 50%;
    width: 20px; height: 20px;
    background: #FF5A00;
    border-radius: 50%;
    pointer-events: none;
    z-index: 100000;
    transform: translate(-50%, -50%);
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), height 0.3s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease;
    mix-blend-mode: difference;
}

.pp-cursor.hovering {
    width: 80px; height: 80px;
    background: #fff;
    mix-blend-mode: difference;
}

.pp-cursor.loading-state {
    width: 120px; height: 120px;
    background: rgba(255, 90, 0, 0.1);
    border: 1px solid #FF5A00;
    mix-blend-mode: normal;
    transition: width 0.8s cubic-bezier(0.85, 0, 0.15, 1), height 0.8s cubic-bezier(0.85, 0, 0.15, 1), background 0.8s ease;
    animation: ppPulseLoader 2s infinite ease-in-out;
}

/* The native pointer is hidden only while the dot is active (mouse/trackpad, wide screens). */
@media (min-width: 769px) {
    html.pp-has-cursor, html.pp-has-cursor * { cursor: none !important; }
}

/* Phones, tablets and narrow windows: the ring still shows while loading, then the dot goes away. */
html:not(.pp-has-cursor) .pp-cursor:not(.loading-state) { display: none; }

@media (max-width: 768px) {
    .pp-cursor:not(.loading-state) { display: none; }
}

/* --- Side menu (markup: pp_sidemenu() in sidemenu.php; behaviour: ui.js) ---
   Every rule is scoped to .pp-sm* classes and sets its own fonts/colours, so page styles for
   nav, a, button, span ... cannot leak in. */
.pp-sm-brandrow { display: inline-flex; align-items: center; gap: 16px; }
/* the button makes the top bar a little wider: when it no longer fits (phones), the right-hand
   part moves to a second line instead of squashing the logo */
nav.pp-sm-host { flex-wrap: wrap; row-gap: 16px; }
.pp-sm-toggle {
    flex: none; width: 44px; height: 44px; padding: 0; border-radius: 14px;
    display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
    background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: border-color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}
.pp-sm-toggle span { display: block; width: 18px; height: 2px; border-radius: 2px; background: #f4f4f5; transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease; }
.pp-sm-toggle span:nth-child(2) { width: 12px; align-self: center; transform: translateX(-3px); }
.pp-sm-toggle:hover, .pp-sm-toggle:focus-visible { border-color: rgba(255, 90, 0, 0.6); background: rgba(255, 90, 0, 0.08); box-shadow: 0 0 18px rgba(255, 90, 0, 0.15); outline: none; }
.pp-sm-toggle:hover span { background: #FF5A00; }
.pp-sm-toggle:hover span:nth-child(2) { width: 18px; transform: none; }
.pp-sm-toggle.is-floating { position: fixed; top: 18px; left: 18px; z-index: 8000; background: rgba(10, 10, 10, 0.7); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }

/* Two ways of showing the menu (state classes on <html>, set by ui.js):
   - wide screens (1100px and up): it sits beside the page. html.pp-sm-push gives <body> a left
     padding and ZOOMS the page out (--pp-sm-z) so it keeps its full desktop layout, only smaller,
     instead of being squeezed. The page stays usable while the menu is open.
   - narrower screens: no room to push the page, so it slides over it with a shade (tap to close).
   html.pp-sm-open = the menu is showing; html.pp-sm-push = the page is moved/zoomed beside it. */
:root { --pp-sm-w: 300px; --pp-sm-z: 1; }
.pp-sm { position: fixed; inset: 0; z-index: 9000; visibility: hidden; pointer-events: none; transition: visibility 0s linear 0.6s; font-family: 'Outfit', sans-serif; }
html.pp-sm-open .pp-sm { visibility: visible; transition: none; }
html.pp-sm-open .pp-sm-panel, html.pp-sm-open .pp-sm-scrim { pointer-events: auto; }
.pp-sm-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); opacity: 0; transition: opacity 0.45s ease; }
html.pp-sm-open .pp-sm-scrim { opacity: 1; }
.pp-sm-panel {
    position: absolute; top: 0; left: 0; bottom: 0; width: min(var(--pp-sm-w), 86vw); overflow: hidden auto;
    display: flex; flex-direction: column; padding: 24px 16px 20px;
    background: rgba(12, 12, 12, 0.9); border-right: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);
    box-shadow: 30px 0 60px rgba(0, 0, 0, 0.5), inset -1px 0 0 rgba(255, 255, 255, 0.03);
    transform: translate3d(-104%, 0, 0); transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform; color: #f4f4f5; outline: none;
    scrollbar-width: thin; scrollbar-color: rgba(255, 90, 0, 0.35) transparent;
}
html.pp-sm-open .pp-sm-panel { transform: translate3d(0, 0, 0); }
/* the menu's own scrollbar (short windows): a thin orange line instead of the system bar */
.pp-sm-panel::-webkit-scrollbar { width: 6px; }
.pp-sm-panel::-webkit-scrollbar-track { background: transparent; }
.pp-sm-panel::-webkit-scrollbar-thumb { background: rgba(255, 90, 0, 0.35); border-radius: 6px; }
.pp-sm-panel::-webkit-scrollbar-thumb:hover { background: rgba(255, 90, 0, 0.7); }
.pp-sm-glow { position: absolute; top: -120px; left: -80px; width: 320px; height: 320px; background: radial-gradient(circle, rgba(255, 90, 0, 0.22) 0%, transparent 65%); filter: blur(40px); pointer-events: none; }
.pp-sm-panel > *:not(.pp-sm-glow) { position: relative; }

.pp-sm-head { display: flex; align-items: center; min-height: 38px; padding: 0 8px 18px; }
.pp-sm-brand { font-size: 1.3rem; font-weight: 900; letter-spacing: -1px; text-transform: uppercase; text-decoration: none; color: #f4f4f5; }
.pp-sm-brand span { color: #FF5A00; }

.pp-sm-who { display: flex; align-items: center; gap: 12px; padding: 12px; margin-bottom: 18px; border-radius: 16px; background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.06); }
.pp-sm-avatar { flex: none; width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.05rem; color: #FF5A00; background: rgba(255, 90, 0, 0.1); border: 1px solid rgba(255, 90, 0, 0.3); }
.pp-sm-id { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pp-sm-id b { font-weight: 600; font-size: 1rem; color: #f4f4f5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-sm-id small { font-size: 0.72rem; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: #FF5A00; }

.pp-sm-label { padding: 0 10px 8px; font-size: 0.68rem; font-weight: 600; letter-spacing: 2.5px; text-transform: uppercase; color: #8a8a93; }
.pp-sm-nav { display: flex; flex-direction: column; gap: 3px; margin-bottom: 18px; }
.pp-sm-link {
    position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px;
    font-size: 0.98rem; font-weight: 400; color: #b9b9c0; text-decoration: none; letter-spacing: 0;
    transition: color 0.25s ease, background 0.25s ease;
}
.pp-sm-link span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-sm-ico { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: 0.8; }
.pp-sm-link:hover, .pp-sm-link:focus-visible { color: #f4f4f5; background: rgba(255, 255, 255, 0.05); outline: none; }
.pp-sm-link.is-here { color: #f4f4f5; font-weight: 600; background: linear-gradient(90deg, rgba(255, 90, 0, 0.16), rgba(255, 90, 0, 0.03)); }
.pp-sm-link.is-here::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: #FF5A00; box-shadow: 0 0 10px rgba(255, 90, 0, 0.7); }
.pp-sm-link.is-here .pp-sm-ico { color: #FF5A00; opacity: 1; }
.pp-sm-sub { display: flex; flex-direction: column; gap: 2px; margin: 0 0 4px 22px; padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, 0.08); }
.pp-sm-child { padding: 8px 12px; font-size: 0.9rem; }
.pp-sm-child.is-here::before { left: -13px; top: 8px; bottom: 8px; }
.pp-sm-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, 0.06); display: flex; flex-direction: column; gap: 3px; }
.pp-sm-out:hover, .pp-sm-out:focus-visible { color: #ff5577; background: rgba(255, 0, 51, 0.08); }

/* links glide in one after another when someone opens the menu (pp-sm-anim, set by ui.js for a moment) */
@keyframes ppSmIn { from { opacity: 0; transform: translate3d(-12px, 0, 0); } to { opacity: 1; transform: none; } }
html.pp-sm-anim .pp-sm-link, html.pp-sm-anim .pp-sm-who { animation: ppSmIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both; animation-delay: calc(0.1s + var(--i, 0) * 0.03s); }
/* the one menu button turns into an X while the menu is open */
.pp-sm-toggle span { transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1), transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease, background 0.3s ease; }
.pp-sm-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.pp-sm-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.pp-sm-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* While the page changes size it fades out and back in, so the one re-layout is never seen
   (animating the width itself re-lays out the whole page on every frame and stutters).
   .pp-sm-content = the page's own top-level parts, marked by ui.js. */
/* (only while switching, so the pages' own load-in animations are left alone) */
html.pp-sm-fade .pp-sm-content { opacity: 0 !important; transition: opacity 0.16s ease !important; }
html.pp-sm-fadein .pp-sm-content { transition: opacity 0.34s ease !important; }

@media (min-width: 1100px) {
    .pp-sm { z-index: 900; }                       /* the page's own pop-ups (1000+) still cover it */
    .pp-sm-scrim { display: none; }
    .pp-sm-panel { box-shadow: 10px 0 40px rgba(0, 0, 0, 0.35), inset -1px 0 0 rgba(255, 255, 255, 0.03); }
    html.pp-sm-push body { padding-left: var(--pp-sm-w); }
    html.pp-sm-push .pp-sm-content { zoom: var(--pp-sm-z); }  /* same layout as full width, drawn smaller */
    /* full-width bars fixed to the window edge start after the menu (access.php's save bar) */
    html.pp-sm-push .finalize-bar { left: var(--pp-sm-w); width: auto; right: 0; }
    /* the preloader covers the page only: the menu stays in view while the next page loads */
    html.pp-sm-push .pp-loader { left: var(--pp-sm-w); width: calc(100vw - var(--pp-sm-w)); }
    html.pp-sm-push .pp-loader-svg, html.pp-sm-push .pp-loader-text, html.pp-sm-push .pp-cursor.loading-state { left: calc(50% + var(--pp-sm-w) / 2); }
}
@media (max-width: 1099px) {
    html.pp-sm-open, html.pp-sm-open body { overflow: hidden; } /* the shaded page behind does not scroll */
}
/* short windows: a more compact menu, so it rarely needs to scroll */
@media (max-height: 820px) {
    .pp-sm-panel { padding-top: 18px; padding-bottom: 14px; }
    .pp-sm-head { padding-bottom: 12px; }
    .pp-sm-who { padding: 10px; margin-bottom: 12px; }
    .pp-sm-avatar { width: 34px; height: 34px; }
    .pp-sm-link { padding: 8px 12px; }
    .pp-sm-child { padding: 6px 12px; }
    .pp-sm-nav { gap: 1px; margin-bottom: 10px; }
    .pp-sm-foot { padding-top: 10px; }
}
/* re-opened on page load (it was left open): already in place, no slide or fade */
html.pp-sm-instant .pp-sm-panel, html.pp-sm-instant .pp-sm-scrim { transition: none !important; }
html.pp-sm-instant .pp-sm .pp-sm-link, html.pp-sm-instant .pp-sm .pp-sm-who { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
    .pp-sm-panel, .pp-sm-scrim { transition: none; }
    html.pp-sm-anim .pp-sm-link, html.pp-sm-anim .pp-sm-who { animation: none; }
}
@media (max-width: 768px) {
    .pp-sm-toggle { width: 40px; height: 40px; border-radius: 12px; }
    .pp-sm-brandrow { gap: 12px; }
}

/* --- Page scrollbar: thin and dark with an orange thumb, instead of the system's white bar --- */
html { scrollbar-width: thin; scrollbar-color: rgba(255, 90, 0, 0.4) #0a0a0a; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #0a0a0a; }
::-webkit-scrollbar-thumb { background: rgba(255, 90, 0, 0.35); border-radius: 10px; border: 2px solid #0a0a0a; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 90, 0, 0.7); }
::-webkit-scrollbar-corner { background: #0a0a0a; }

/* a small badge after a side-menu label (Chat: Beta) */
.pp-sm-badge { margin-left: auto; flex: none; font-style: normal; font-size: .62rem; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: #FF5A00; border: 1px solid rgba(255, 90, 0, .45); background: rgba(255, 90, 0, .1); border-radius: 999px; padding: 2px 7px; }

/* The help pill (ui.js): bottom right, above the page and below every pop-up (pop-ups are 1000+) */
.pp-help { position: fixed; right: max(18px, 2.4vw); bottom: max(18px, 2.6vh); z-index: 950; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; font-family: 'Outfit', system-ui, sans-serif; }
.pp-help-pill { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px 0 14px; border-radius: 30px; border: 1px solid rgba(255, 90, 0, .5); background: rgba(16, 16, 16, .92); color: #f4f4f5; font: inherit; font-size: .95rem; font-weight: 600; cursor: pointer; box-shadow: 0 12px 34px rgba(0, 0, 0, .5); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: border-color .2s ease, transform .2s ease; }
.pp-help-pill:hover, .pp-help.is-open .pp-help-pill { border-color: #FF5A00; transform: translateY(-1px); }
.pp-help-pill svg { width: 20px; height: 20px; fill: none; stroke: #FF5A00; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.pp-help-pop { position: relative; width: min(320px, calc(100vw - 36px)); padding: 20px 20px 18px; border-radius: 18px; background: #151515; border: 1px solid rgba(255, 255, 255, .12); color: #f4f4f5; box-shadow: 0 24px 60px rgba(0, 0, 0, .6); animation: ppHelpIn .3s cubic-bezier(0.16, 1, 0.3, 1); }
.pp-help-pop[hidden] { display: none; }
.pp-help-pop b { display: block; font-size: 1.08rem; font-weight: 700; padding-right: 26px; }
.pp-help-pop p { margin: 6px 0 16px; color: #a8a8b0; font-size: .9rem; line-height: 1.5; }
.pp-help-x { position: absolute; top: 10px; right: 12px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: none; color: #8f8f98; font-size: 1.3rem; line-height: 1; cursor: pointer; }
.pp-help-x:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.pp-help-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.pp-help-yes { flex: 1; display: inline-flex; justify-content: center; align-items: center; height: 40px; padding: 0 16px; border-radius: 12px; background: #FF5A00; color: #fff; text-decoration: none; font-weight: 600; font-size: .92rem; }
.pp-help-yes:hover { background: #ff7a33; }
.pp-help-no { height: 40px; padding: 0 14px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .16); background: none; color: #d4d4d8; font: inherit; font-size: .92rem; cursor: pointer; }
.pp-help-no:hover { border-color: rgba(255, 255, 255, .3); }
@keyframes ppHelpIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
body.st .pp-help { bottom: calc(max(20px, 3vh) + 76px); } /* above the Book store's cart button */
body:has(.timer) .pp-help, :fullscreen .pp-help { display: none; } /* not over a running quiz */
@media print { .pp-help { display: none !important; } }
