/*
 * Return of Midgard — dedicated logo/title effects V139
 * Loaded AFTER bakbakan.css so older V128-V138 overrides cannot win.
 * Approved V5 direction: subtle pulse + 4 small Lv99-blue fairies + softer Ivory Halo
 * plus pure glossy shine across the two blue diamonds (no star/cross flare).
 */

@keyframes rm139-brand-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.013); }
}

@keyframes rm139-halo-breathe {
    0%, 100% { opacity: .54; transform: translate(-50%, -50%) scale(.98); }
    50%      { opacity: .72; transform: translate(-50%, -50%) scale(1.04); }
}

@keyframes rm139-fairy-twinkle {
    from { opacity: .48; filter: brightness(.94); }
    to   { opacity: 1;   filter: brightness(1.18); }
}

/* Slow, irregular-looking paths; intentionally not perfect circles. */
@keyframes rm139-fairy-1 {
    0%   { left: 26%; top: 58%; }
    17%  { left: 17%; top: 33%; }
    34%  { left: 31%; top: 17%; }
    51%  { left: 58%; top: 20%; }
    69%  { left: 80%; top: 33%; }
    86%  { left: 70%; top: 63%; }
    100% { left: 26%; top: 58%; }
}
@keyframes rm139-fairy-2 {
    0%   { left: 75%; top: 60%; }
    19%  { left: 62%; top: 78%; }
    38%  { left: 37%; top: 80%; }
    55%  { left: 19%; top: 57%; }
    72%  { left: 24%; top: 24%; }
    88%  { left: 53%; top: 14%; }
    100% { left: 75%; top: 60%; }
}
@keyframes rm139-fairy-3 {
    0%   { left: 50%; top: 84%; }
    14%  { left: 76%; top: 69%; }
    29%  { left: 84%; top: 38%; }
    47%  { left: 61%; top: 18%; }
    64%  { left: 35%; top: 22%; }
    82%  { left: 17%; top: 46%; }
    100% { left: 50%; top: 84%; }
}
@keyframes rm139-fairy-4 {
    0%   { left: 44%; top: 12%; }
    18%  { left: 20%; top: 28%; }
    37%  { left: 19%; top: 66%; }
    56%  { left: 43%; top: 83%; }
    74%  { left: 77%; top: 76%; }
    91%  { left: 83%; top: 34%; }
    100% { left: 44%; top: 12%; }
}

/* Pure surface shine — no star/cross. */
@keyframes rm139-gem-top-sweep {
    0%, 7%, 100% { left: -95%; opacity: 0; }
    10%           { opacity: .35; }
    14%           { opacity: 1; }
    21%           { left: 145%; opacity: .90; }
    27%           { left: 145%; opacity: 0; }
}
@keyframes rm139-gem-bottom-sweep {
    0%, 49%, 100% { left: -95%; opacity: 0; }
    52%            { opacity: .35; }
    56%            { opacity: 1; }
    63%            { left: 145%; opacity: .90; }
    69%            { left: 145%; opacity: 0; }
}
@keyframes rm139-gem-top-bloom {
    0%, 8%, 100% { opacity: 0; }
    14%           { opacity: .82; }
    21%           { opacity: .36; }
    27%           { opacity: 0; }
}
@keyframes rm139-gem-bottom-bloom {
    0%, 50%, 100% { opacity: 0; }
    56%            { opacity: .82; }
    63%            { opacity: .36; }
    69%            { opacity: 0; }
}

@media (min-width: 801px) {
    /* Restore the title block to the pre-effect stable location.
       Screenshot comparison: current block was ~63px too low. */
    .portal-hero-copy {
        transform: translateY(-53px) !important;
        padding-top: 10px !important;
        position: relative !important;
        z-index: 20 !important;
    }

    /* Logo root: final authority after all older accumulated rules. */
    .portal-brand.portal-brand-image {
        position: relative !important;
        overflow: visible !important;
        isolation: isolate !important;
        transform-origin: center center !important;
        animation: rm139-brand-pulse 6.8s ease-in-out infinite !important;
        will-change: transform !important;
    }

    /* Kill all legacy pseudo halos; V139 uses the explicit DOM halo only. */
    .portal-brand.portal-brand-image::before,
    .portal-brand.portal-brand-image::after {
        content: none !important;
        display: none !important;
        animation: none !important;
    }

    /* Ivory Halo — real DOM element, deliberately visible against the bright sky. */
    .portal-brand.portal-brand-image .romidgard-ivory-halo-live {
        display: block !important;
        position: absolute !important;
        left: 50% !important;
        top: 49% !important;
        width: 112% !important;
        height: 96% !important;
        z-index: 1 !important;
        pointer-events: none !important;
        border-radius: 50% !important;
        background: radial-gradient(ellipse at center,
            rgba(255,255,247,.76) 0%,
            rgba(255,249,230,.42) 33%,
            rgba(255,246,216,.16) 53%,
            rgba(255,255,255,0) 73%) !important;
        filter: blur(16px) !important;
        animation: rm139-halo-breathe 6.8s ease-in-out infinite !important;
        transform-origin: center center !important;
        will-change: opacity, transform !important;
    }

    .portal-brand.portal-brand-image .romidgard-logo-art {
        position: relative !important;
        display: block !important;
        width: 410px !important;
        max-width: 100% !important;
        line-height: 0 !important;
        z-index: 4 !important;
        overflow: visible !important;
    }

    .portal-brand.portal-brand-image .romidgard-logo-art img {
        display: block !important;
        position: relative !important;
        z-index: 4 !important;
        width: 100% !important;
        max-width: 410px !important;
        max-height: 230px !important;
        height: auto !important;
        object-fit: contain !important;
        animation: none !important;
        transform: none !important;
        filter:
            drop-shadow(0 12px 22px rgba(5,20,35,.45))
            drop-shadow(0 0 7px rgba(255,255,244,.62))
            drop-shadow(0 0 18px rgba(255,245,215,.38)) !important;
    }

    /* Approved small Lv99-blue fairy lights. */
    .portal-brand.portal-brand-image .romidgard-fairy {
        display: block !important;
        position: absolute !important;
        z-index: 8 !important;
        width: 6px !important;
        height: 6px !important;
        margin: -3px 0 0 -3px !important;
        border-radius: 50% !important;
        pointer-events: none !important;
        background: #fffef8 !important;
        box-shadow:
            0 0 4px 1px rgba(230,249,255,.96),
            0 0 8px 3px rgba(122,220,255,.68),
            0 0 14px 5px rgba(110,207,255,.22) !important;
    }
    .portal-brand.portal-brand-image .romidgard-fairy::before,
    .portal-brand.portal-brand-image .romidgard-fairy::after {
        content: "" !important;
        position: absolute !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
        border-radius: 999px !important;
        background: rgba(177,235,255,.96) !important;
    }
    .portal-brand.portal-brand-image .romidgard-fairy::before {
        width: 1px !important;
        height: 15px !important;
    }
    .portal-brand.portal-brand-image .romidgard-fairy::after {
        width: 15px !important;
        height: 1px !important;
    }
    .portal-brand.portal-brand-image .romidgard-fairy-1 {
        animation: rm139-fairy-1 16.5s ease-in-out infinite, rm139-fairy-twinkle 2.4s ease-in-out infinite alternate !important;
    }
    .portal-brand.portal-brand-image .romidgard-fairy-2 {
        animation: rm139-fairy-2 19.5s ease-in-out infinite, rm139-fairy-twinkle 2.9s ease-in-out infinite alternate !important;
    }
    .portal-brand.portal-brand-image .romidgard-fairy-3 {
        animation: rm139-fairy-3 22s ease-in-out infinite, rm139-fairy-twinkle 2.6s ease-in-out infinite alternate !important;
    }
    .portal-brand.portal-brand-image .romidgard-fairy-4 {
        animation: rm139-fairy-4 18.2s ease-in-out infinite, rm139-fairy-twinkle 3.2s ease-in-out infinite alternate !important;
    }

    /* Exact measured gem overlays, inside the image wrapper. */
    .portal-brand.portal-brand-image .romidgard-gem-shine {
        display: block !important;
        position: absolute !important;
        z-index: 12 !important;
        transform: translate(-50%, -50%) !important;
        pointer-events: none !important;
        overflow: hidden !important;
        clip-path: polygon(50% 0%,100% 50%,50% 100%,0 50%) !important;
        mix-blend-mode: screen !important;
    }
    .portal-brand.portal-brand-image .romidgard-gem-shine-top {
        left: 50.06% !important;
        top: 26.35% !important;
        width: 18px !important;
        height: 22px !important;
    }
    .portal-brand.portal-brand-image .romidgard-gem-shine-bottom {
        left: 50.09% !important;
        top: 73.38% !important;
        width: 15px !important;
        height: 18px !important;
    }
    .portal-brand.portal-brand-image .romidgard-gem-shine::before {
        content: "" !important;
        position: absolute !important;
        top: -24% !important;
        left: -95%;
        width: 72% !important;
        height: 148% !important;
        opacity: 0;
        background: linear-gradient(90deg,
            rgba(255,255,255,0) 0%,
            rgba(255,255,255,.22) 18%,
            rgba(255,255,255,1) 46%,
            rgba(225,246,255,.86) 59%,
            rgba(255,255,255,.16) 72%,
            rgba(255,255,255,0) 100%) !important;
        filter: blur(.20px) !important;
        transform: skewX(-18deg) !important;
        mix-blend-mode: screen !important;
    }
    .portal-brand.portal-brand-image .romidgard-gem-shine::after {
        content: "" !important;
        position: absolute !important;
        inset: 6% !important;
        opacity: 0;
        background: radial-gradient(circle at 36% 28%,
            rgba(255,255,255,.80) 0%,
            rgba(226,244,255,.38) 28%,
            rgba(226,244,255,0) 68%) !important;
        filter: blur(.30px) !important;
    }
    .portal-brand.portal-brand-image .romidgard-gem-shine-top::before {
        animation: rm139-gem-top-sweep 7.2s ease-in-out infinite !important;
    }
    .portal-brand.portal-brand-image .romidgard-gem-shine-top::after {
        animation: rm139-gem-top-bloom 7.2s ease-in-out infinite !important;
    }
    .portal-brand.portal-brand-image .romidgard-gem-shine-bottom::before {
        animation: rm139-gem-bottom-sweep 7.2s ease-in-out infinite !important;
    }
    .portal-brand.portal-brand-image .romidgard-gem-shine-bottom::after {
        animation: rm139-gem-bottom-bloom 7.2s ease-in-out infinite !important;
    }
}

@media (max-width: 800px) {
    .portal-brand.portal-brand-image .romidgard-ivory-halo-live,
    .portal-brand.portal-brand-image .romidgard-fairy,
    .portal-brand.portal-brand-image .romidgard-gem-shine {
        display: none !important;
    }
}

/* V143: layout remains the approved V139 baseline. Fairy and diamond effects are
   rendered in a separate fixed canvas overlay created by external JS, so they
   cannot affect header flow, logo size/position, or title placement. */
