/* Actum Forge — visual effects, all in one place (with forge-fx.js and forge-cracks.js next
   to this file): stone surfaces, cracks that are faint everywhere and burn near the cursor,
   sparks. The crack texture is forged anew for every visit by forge-cracks.js, which sets
   --fx-cracks / --fx-cracks-pale; the drawn images below are only the fallback.

   How it stays cheap:
   - the faint cracks of a card are one more background layer of the card itself, not extra
     elements; the texture is baked at 10% alpha (cracks-pale.png), which blended with
     "screen" gives exactly what the old 10%-opacity layer gave;
   - the burning cracks are a small spot (2 × the glow radius) moved under the cursor, only
     in surfaces near it; its mask never changes, so only that small square is repainted;
   - nothing is attached to the viewport (background-attachment: fixed made every scroll
     repaint every card): the cracks belong to the page and scroll with it, a card's cracks
     continue the cracks of the ground under it (--fx-cx / --fx-cy, set by forge-fx.js). */

:root {
    --fx-cracks: url("../images/forge/cracks.54eb79bac049.png");
    --fx-cracks-pale: url("../images/forge/cracks-pale.37f2de35408d.png");
    --fx-stone: url("../images/forge/stone.e7f5ba7f1eae.jpg");
    --fx-glow-radius: 190px;
    --fx-glow-mask: radial-gradient(circle var(--fx-glow-radius) at 50% 50%, #000 0%, rgba(0, 0, 0, 0.6) 40%, rgba(0, 0, 0, 0.15) 75%, rgba(0, 0, 0, 0) 100%);
}

fx-layer {
    display: block;
    pointer-events: none;
}

/* ---------- the ground: faint cracks over the obsidian, the whole page long ---------- */

.fx-ground {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    z-index: 0;
    background-image: var(--fx-cracks);
    background-size: 1024px 1024px;
    opacity: 0.1;
    mix-blend-mode: screen;
}

/* a denser band of cracks along the sidebar edge (it stays with the sidebar) */
.fx-edge,
.fx-edge-zone {
    position: fixed;
    inset: 0 auto 0 170px;
    width: 300px;
    z-index: 0;
    -webkit-mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, #000 30%, #000 55%, rgba(0, 0, 0, 0) 100%);
    mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, #000 30%, #000 55%, rgba(0, 0, 0, 0) 100%);
}

.fx-edge {
    background-image: var(--fx-cracks);
    background-size: 900px 900px;
    background-position: -380px -240px;
    opacity: 0.13;
    mix-blend-mode: screen;
}

.sidebar-is-collapsed :is(.fx-edge, .fx-edge-zone) { left: -90px; }

/* phones: the sidebar is the bottom bar - no edge to follow, and the rail patch (372 px
   down) would make the bar taller than itself, so it could be scrolled */
@media (max-width: 760px) {
    .fx-edge,
    .fx-edge-zone,
    .fx-rail,
    .fx-rail-zone {
        display: none;
    }
}

/* the extra patch in the rail, around Дневник / Обучение / Битва */
.fx-rail,
.fx-rail-zone {
    position: absolute;
    inset: 372px 0 auto 0;
    height: 220px;
    z-index: -1;
    -webkit-mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 35%, rgba(0, 0, 0, 0) 100%);
    mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 35%, rgba(0, 0, 0, 0) 100%);
}

.fx-rail {
    background-image: var(--fx-cracks);
    background-size: 760px 760px;
    background-position: -150px -60px;
    opacity: 0.1;
    mix-blend-mode: screen;
}

/* ---------- the glow: a spot of burning cracks under the cursor ---------- */

/* inside a surface: under its content, over its stone, clipped to its corners */
.fx-glow {
    position: absolute;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    border-radius: inherit;
}

.fx-spot {
    position: absolute;
    left: 0;
    top: 0;
    width: calc(var(--fx-glow-radius) * 2);
    height: calc(var(--fx-glow-radius) * 2);
    background-image: var(--fx-cracks);
    background-size: 1024px 1024px;
    mix-blend-mode: screen;
    -webkit-mask-image: var(--fx-glow-mask);
    mask-image: var(--fx-glow-mask);
    /* its own GPU layer: moving it repaints nothing around it, only its own small square */
    will-change: transform;
}

/* the ground's own spot lives right in the page, under the content */
.fx-spot.is-ground {
    z-index: 0;
}

[hidden].fx-glow,
[hidden].fx-spot {
    display: none;
}

/* ---------- sparks ---------- */

.fx-sparks {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2147483000;
    pointer-events: none;
}

.fx-sparks[hidden] {
    display: none;
}

@media (hover: none), (prefers-reduced-motion: reduce) {
    .fx-glow,
    .fx-spot,
    .fx-sparks {
        display: none !important;
    }
}

/* ---------- switched off in settings («Эффекты»): fx-no-<effect> on <html> ---------- */

.fx-no-cracks {
    --fx-cracks: none !important;
    --fx-cracks-pale: none !important;
}

.fx-no-cracks :is(.fx-ground, .fx-edge, .fx-rail, .fx-glow, .fx-spot),
.fx-no-sparks .fx-sparks {
    display: none !important;
}

/* ---------- stone surfaces: every card / panel of every page ---------- */

.forge-surface,
.forge-pane {
    isolation: isolate;
}

.forge-surface,
.tasks-list .card.forge-surface,
.contact-form section.forge-surface,
.contact-sections section.forge-surface,
.social-layout > .forge-surface,
.spending-summary article.forge-surface,
.passport-grid section.forge-surface {
    border-color: #23272D;
    border-radius: 8px;
    background-color: #0D0F12;
    background-image:
        var(--fx-cracks-pale),
        linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 38%),
        linear-gradient(180deg, rgba(14, 16, 19, 0.19), rgba(9, 10, 12, 0.54)),
        var(--fx-stone);
    background-size: 1024px 1024px, auto, auto, 1024px 1024px;
    background-position: var(--fx-cx, 0) var(--fx-cy, 0), 0 0, 0 0, 0 0;
    background-repeat: repeat, no-repeat, no-repeat, repeat;
    background-blend-mode: screen, normal, normal, normal;
}

.forge-surface {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        inset 0 -24px 40px rgba(0, 0, 0, 0.32),
        0 14px 34px rgba(0, 0, 0, 0.42);
}

/* full-height panes: stone and cracks, their own square edges */
.forge-pane {
    background-color: #0B0D10;
    background-image:
        var(--fx-cracks-pale),
        linear-gradient(180deg, rgba(10, 11, 14, 0.3), rgba(8, 9, 11, 0.6)),
        var(--fx-stone);
    background-size: 1024px 1024px, auto, 1024px 1024px;
    background-position: var(--fx-cx, 0) var(--fx-cy, 0), 0 0, 0 0;
    background-repeat: repeat, no-repeat, repeat;
    background-blend-mode: screen, normal, normal;
}

/* the sidebar: stone with faint cracks; on phones it is the bottom bar */
.sidebar {
    isolation: isolate;
}

@media (min-width: 761px) {
    .sidebar {
        background-color: #08090B;
        background-image:
            var(--fx-cracks-pale),
            linear-gradient(180deg, rgba(8, 9, 11, 0.19), rgba(8, 9, 11, 0.49)),
            var(--fx-stone);
        background-size: 1024px 1024px, auto, 1024px 1024px;
        background-blend-mode: screen, normal, normal;
    }
}

@media (max-width: 760px) {
    .sidebar {
        background-color: rgba(7, 8, 10, 0.96);
        background-image:
            var(--fx-cracks-pale),
            linear-gradient(180deg, rgba(8, 9, 11, 0.35), rgba(8, 9, 11, 0.7)),
            var(--fx-stone);
        background-size: 1024px 1024px, auto, 1024px 1024px;
        background-blend-mode: screen, normal, normal;
    }
}
