/*
 * Loading overlay — replaces the SweetAlert "Loading..." box (markup layouts/loader.php, script js/loader.js;
 * site.js msg_waiting() shows it, msg_close() or any SweetAlert dialog hides it). Shared by the classic layout
 * (layouts/template.php) and the new look (layouts/c/head.php; markup at the top of the body in every layout).
 * The page dimmed under translucent dark grey, a white emblem with a rainbow ring turning around an open book
 * whose pages flip, and "Loading" with three dots. Theme colour from the new look's --p / --p-rgb / --p-soft
 * when they exist; the classic look gets the fallback blue.
 * Sizes: emblem 92px, 68px on phones (up to 576px wide).
 * z-index above everything on the classic pages (fixed menus up to 9999); it never shows together with a
 * SweetAlert dialog (js/loader.js hides one when the other opens).
 */
.c-loader { position: fixed; inset: 0; z-index: 100000; display: flex; align-items: center; justify-content: center; padding: 24px;
    font-family: "IBM Plex Sans Thai", "Prompt", -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased;
    background: radial-gradient(120% 90% at 50% 45%, rgba(38, 43, 54, .58) 0%, rgba(24, 28, 37, .72) 55%, rgba(15, 18, 25, .82) 100%);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .25s ease, visibility 0s linear .25s; }
.c-loader.is-on { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity .25s ease; }
.c-loader *, .c-loader *::before, .c-loader *::after { box-sizing: border-box; }
.c-loader-box { display: flex; flex-direction: column; align-items: center; gap: 20px; transform: translateY(8px) scale(.97); transition: transform .35s cubic-bezier(.2, .8, .2, 1); }
.c-loader.is-on .c-loader-box { transform: none; }
.c-loader-emblem { position: relative; width: 92px; height: 92px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 0 6px rgba(255, 255, 255, .1), 0 0 46px rgba(var(--p-rgb, 79, 123, 255), .35), 0 24px 50px rgba(0, 0, 0, .35),
        inset 0 0 0 1px rgba(var(--p-rgb, 79, 123, 255), .08); }   /* faint track under the ring, theme glow */
.c-loader-emblem::before { content: ""; position: absolute; inset: -6px; border-radius: 50%;   /* the turning ring: rainbow */
    background: conic-gradient(from 0deg, #ff5f6d, #ffa53b, #ffe14d, #4cd97b, #33c7e8, #4f7bff, #a35cff, #ff5fc1, #ff5f6d);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3.5px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3.5px));
    animation: c-loader-spin 1.15s linear infinite; }
.c-loader-emblem::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: radial-gradient(circle at 50% 35%, var(--p-soft, #EEF2FF), #fff 70%); }
/* open book: two pages (::before / ::after) with text lines, a theme-colour cover edge, three pages turning over */
.c-loader-book { position: relative; z-index: 1; width: 56px; height: 38px; perspective: 260px; transform-style: preserve-3d; margin-top: 2px; transform: scale(.86); }   /* drawn for a 108px emblem */
.c-loader-book::before, .c-loader-book::after, .c-loader-page { position: absolute; top: 0; bottom: 0; width: 50%;
    background: repeating-linear-gradient(to bottom, transparent 0 6px, rgba(var(--p-rgb, 79, 123, 255), .2) 6px 7px) 5px 7px / calc(100% - 10px) calc(100% - 12px) no-repeat, #fff; }
.c-loader-book::before, .c-loader-book::after { content: ""; border: 2px solid var(--p, #4F7BFF); box-shadow: 0 6px 12px rgba(var(--p-rgb, 79, 123, 255), .18); }
.c-loader-book::before { left: 0; border-right-width: 1px; border-radius: 6px 2px 2px 6px; }
.c-loader-book::after { right: 0; border-left-width: 1px; border-radius: 2px 6px 6px 2px; }
.c-loader-page { left: 50%; top: 2px; bottom: 2px; width: calc(50% - 2px); border-radius: 0 4px 4px 0; transform-origin: left center;
    background-color: #fff; box-shadow: inset 6px 0 6px -6px rgba(17, 24, 39, .25);
    animation: c-loader-flip 2.1s cubic-bezier(.45, .05, .35, 1) infinite; }
.c-loader-page:nth-child(2) { animation-delay: .22s; }
.c-loader-page:nth-child(3) { animation-delay: .44s; }
.c-loader-text { font-size: 15px; font-weight: 500; line-height: 1.4; letter-spacing: .03em; color: #fff; text-shadow: 0 1px 8px rgba(0, 0, 0, .35); display: inline-flex; align-items: baseline; }
.c-loader-dots { display: inline-flex; gap: 4px; margin-left: 6px; }
.c-loader-dots i { width: 5px; height: 5px; border-radius: 50%; background: #fff; animation: c-loader-dot 1.2s ease-in-out infinite; }
.c-loader-dots i:nth-child(2) { animation-delay: .15s; }
.c-loader-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes c-loader-spin { to { transform: rotate(360deg); } }
@keyframes c-loader-flip { 0%, 12% { transform: translateZ(1px) rotateY(0); } 58%, 100% { transform: translateZ(1px) rotateY(-180deg); } }
@keyframes c-loader-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
/* phones: a smaller emblem, thinner ring, smaller text */
@media (max-width: 576px) {
    .c-loader-box { gap: 14px; }
    .c-loader-emblem { width: 68px; height: 68px;
        box-shadow: 0 0 0 4px rgba(255, 255, 255, .1), 0 0 30px rgba(var(--p-rgb, 79, 123, 255), .35), 0 14px 32px rgba(0, 0, 0, .35),
            inset 0 0 0 1px rgba(var(--p-rgb, 79, 123, 255), .08); }
    .c-loader-emblem::before { inset: -4px;
        -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
        mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px)); }
    .c-loader-emblem::after { inset: 7px; }
    .c-loader-book { transform: scale(.64); margin-top: 1px; }
    .c-loader-text { font-size: 13px; }
    .c-loader-dots { gap: 3px; margin-left: 5px; }
    .c-loader-dots i { width: 4px; height: 4px; }
}
@media (prefers-reduced-motion: reduce) {
    .c-loader-emblem::before { animation-duration: 3s; }
    .c-loader-page, .c-loader-dots i { animation: none; }
    .c-loader-dots i { opacity: .6; }
}
