/* ═══════════════════════════════════════════════════════════════
   Trellar — Living Gradient Mesh (shared background)

   Pure-CSS animated background: five large blurred blobs drift, scale
   and re-shade on independent, non-aligned clocks so the mix never
   quite repeats. Fixed full-viewport layer behind the whole page.

   Markup:  {% include "components/living_mesh.html" %}
   Style:   <link rel="stylesheet" href="{% static 'css/base/living_mesh.css' %}">
   ═══════════════════════════════════════════════════════════════ */

.living-mesh {
    /* Base */
    --mesh-base: #f9f8fc;
    --mesh-cloud: #ffffff;

    /* Violet — lead brand hue */
    --mesh-violet-1: #e6dcfb;
    --mesh-violet-2: #bba4f3;
    --mesh-violet-3: #8f66e8;

    /* Indigo — echoes the brand navy (#1e1b4b) at a pale value */
    --mesh-indigo-1: #dfe2f8;
    --mesh-indigo-2: #a9b1e8;
    --mesh-indigo-3: #6f76c8;

    /* Amber — brand orange accent */
    --mesh-amber-1: #fcead8;
    --mesh-amber-2: #f6d2b0;
    --mesh-amber-3: #eab583;

    /* Teal — brand secondary accent */
    --mesh-teal-1: #d5eeeb;
    --mesh-teal-2: #91ccc5;
    --mesh-teal-3: #429b93;

    /* Orchid — soft bridge between violet and amber */
    --mesh-orchid-1: #ecdff6;
    --mesh-orchid-2: #d0b8ea;
    --mesh-orchid-3: #a982d2;

    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    background: var(--mesh-base);
}

.living-mesh__mesh {
    position: absolute;
    inset: 0;
    animation: living-mesh-breathe 60s ease-in-out infinite;
}

/* ─── Blobs ─── */
.living-mesh__blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    will-change: transform, background-color;
    transform: translate3d(0, 0, 0);
}

.living-mesh__blob--violet {
    width: 58vw; height: 58vw; top: -16%; left: 2%;
    background-color: var(--mesh-violet-1);
    opacity: 0.8;
    animation: living-mesh-violet 27s ease-in-out infinite;
}
.living-mesh__blob--indigo {
    width: 54vw; height: 54vw; top: -12%; right: -10%;
    background-color: var(--mesh-indigo-1);
    opacity: 0.75;
    animation: living-mesh-indigo 33s ease-in-out infinite;
    animation-delay: -9s;
}
.living-mesh__blob--amber {
    width: 60vw; height: 60vw; bottom: -20%; left: -12%;
    background-color: var(--mesh-amber-1);
    opacity: 0.65;
    animation: living-mesh-amber 30s ease-in-out infinite;
    animation-delay: -21s;
}
.living-mesh__blob--teal {
    width: 50vw; height: 50vw; bottom: -16%; right: 4%;
    background-color: var(--mesh-teal-1);
    opacity: 0.68;
    animation: living-mesh-teal 36s ease-in-out infinite;
    animation-delay: -14s;
}
.living-mesh__blob--orchid {
    width: 40vw; height: 40vw; top: 32%; left: 32%;
    background-color: var(--mesh-orchid-1);
    opacity: 0.6;
    animation: living-mesh-orchid 41s ease-in-out infinite;
    animation-delay: -27s;
}

/* ─── Light "cloud" that lifts the bottom of the mesh ─── */
.living-mesh__cloud {
    position: absolute;
    left: -15%; bottom: -22%;
    width: 130vw; height: 46vh;
    background: radial-gradient(ellipse at center, var(--mesh-cloud) 0%, rgba(255, 255, 255, 0) 68%);
    filter: blur(40px);
    opacity: 0.8;
    animation: living-mesh-cloud 56s ease-in-out infinite;
}

/* ─── Keyframes ─── */
@keyframes living-mesh-violet {
    0%   { transform: translate3d(0, 0, 0) scale(1);          background-color: var(--mesh-violet-1); }
    25%  { transform: translate3d(7vw, 6vh, 0) scale(1.14);   background-color: var(--mesh-violet-2); }
    50%  { transform: translate3d(-4vw, 11vh, 0) scale(0.93); background-color: var(--mesh-violet-3); }
    75%  { transform: translate3d(-8vw, 3vh, 0) scale(1.1);   background-color: var(--mesh-violet-2); }
    100% { transform: translate3d(0, 0, 0) scale(1);          background-color: var(--mesh-violet-1); }
}
@keyframes living-mesh-indigo {
    0%   { transform: translate3d(0, 0, 0) scale(1);          background-color: var(--mesh-indigo-1); }
    30%  { transform: translate3d(-8vw, 7vh, 0) scale(1.16);  background-color: var(--mesh-indigo-2); }
    60%  { transform: translate3d(-3vw, -8vh, 0) scale(0.92); background-color: var(--mesh-indigo-3); }
    85%  { transform: translate3d(6vw, 3vh, 0) scale(1.07);   background-color: var(--mesh-indigo-2); }
    100% { transform: translate3d(0, 0, 0) scale(1);          background-color: var(--mesh-indigo-1); }
}
@keyframes living-mesh-amber {
    0%   { transform: translate3d(0, 0, 0) scale(1);          background-color: var(--mesh-amber-1); }
    28%  { transform: translate3d(8vw, -5vh, 0) scale(1.14);  background-color: var(--mesh-amber-2); }
    55%  { transform: translate3d(3vw, -12vh, 0) scale(0.9);  background-color: var(--mesh-amber-3); }
    80%  { transform: translate3d(-7vw, -4vh, 0) scale(1.09); background-color: var(--mesh-amber-2); }
    100% { transform: translate3d(0, 0, 0) scale(1);          background-color: var(--mesh-amber-1); }
}
@keyframes living-mesh-teal {
    0%   { transform: translate3d(0, 0, 0) scale(1);          background-color: var(--mesh-teal-1); }
    33%  { transform: translate3d(-7vw, -7vh, 0) scale(1.14); background-color: var(--mesh-teal-2); }
    66%  { transform: translate3d(4vw, -3vh, 0) scale(0.91);  background-color: var(--mesh-teal-3); }
    100% { transform: translate3d(0, 0, 0) scale(1);          background-color: var(--mesh-teal-1); }
}
@keyframes living-mesh-orchid {
    0%   { transform: translate3d(0, 0, 0) scale(1);          background-color: var(--mesh-orchid-1); }
    40%  { transform: translate3d(6vw, -6vh, 0) scale(1.2);   background-color: var(--mesh-orchid-2); }
    70%  { transform: translate3d(-6vw, 5vh, 0) scale(0.88);  background-color: var(--mesh-orchid-3); }
    100% { transform: translate3d(0, 0, 0) scale(1);          background-color: var(--mesh-orchid-1); }
}
@keyframes living-mesh-cloud {
    0%, 100% { transform: translate3d(0, 0, 0); }
    50%      { transform: translate3d(9vw, -2vh, 0); }
}
@keyframes living-mesh-breathe {
    0%, 100% { filter: hue-rotate(0deg); }
    33%      { filter: hue-rotate(11deg) saturate(1.06); }
    66%      { filter: hue-rotate(-7deg) saturate(1.03); }
}

/* ─── Small screens: cheaper blur, one blob fewer ─── */
@media (max-width: 720px) {
    .living-mesh__blob { filter: blur(50px); }
    .living-mesh__blob--orchid { display: none; }
    .living-mesh__blob--violet { width: 90vw; height: 90vw; }
    .living-mesh__blob--indigo { width: 80vw; height: 80vw; }
    .living-mesh__blob--amber  { width: 90vw; height: 90vw; }
    .living-mesh__blob--teal   { width: 80vw; height: 80vw; }
}

/* ─── Reduced motion: freeze on the mid shade of each blob ─── */
@media (prefers-reduced-motion: reduce) {
    .living-mesh__mesh,
    .living-mesh__blob,
    .living-mesh__cloud { animation: none !important; }
    .living-mesh__blob--violet { background-color: var(--mesh-violet-2); }
    .living-mesh__blob--indigo { background-color: var(--mesh-indigo-2); }
    .living-mesh__blob--amber  { background-color: var(--mesh-amber-2); }
    .living-mesh__blob--teal   { background-color: var(--mesh-teal-2); }
    .living-mesh__blob--orchid { background-color: var(--mesh-orchid-2); }
}
