﻿/* =============================================
   PAGE TRANSITIONS – Langhard & Co

   Dual-section wipe using CSS mask-image.
   Both the departing and arriving sections are
   visible simultaneously. The incoming section
   renders in a fixed overlay whose mask sweeps
   across, revealing new content while old content
   remains visible behind it. Feathered edge via
   gradient mask gives a smooth, cinematic feel.
   ============================================= */

/* ── Incoming section overlay ────────────────── *
   top: 64px keeps the overlay below the sticky
   header so hero height matches normal flow –
   no size-jump when the wipe finishes.            */

.section-incoming {
    position: fixed;
    inset: var(--header-h, 64px) 0 0;
    z-index: 500;
    overflow: hidden;
    background: #fff;
}

/* ── Tech – left-to-right mask wipe ──────────── */

.section-incoming.wipe-ltr {
    -webkit-mask-image: linear-gradient(to right, #000 44%, transparent 56%);
    mask-image: linear-gradient(to right, #000 44%, transparent 56%);
    -webkit-mask-size: 300% 100%;
    mask-size: 300% 100%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: 100% 0;
    mask-position: 100% 0;
    animation: mask-ltr 1s ease-in-out forwards;
}

@keyframes mask-ltr {
    from {
        -webkit-mask-position: 100% 0;
        mask-position: 100% 0;
    }
    to {
        -webkit-mask-position: 0% 0;
        mask-position: 0% 0;
    }
}

/* ── Nature – right-to-left mask wipe ────────── */

.section-incoming.wipe-rtl {
    -webkit-mask-image: linear-gradient(to left, #000 44%, transparent 56%);
    mask-image: linear-gradient(to left, #000 44%, transparent 56%);
    -webkit-mask-size: 300% 100%;
    mask-size: 300% 100%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: 0% 0;
    mask-position: 0% 0;
    animation: mask-rtl 1s ease-in-out forwards;
}

@keyframes mask-rtl {
    from {
        -webkit-mask-position: 0% 0;
        mask-position: 0% 0;
    }
    to {
        -webkit-mask-position: 100% 0;
        mask-position: 100% 0;
    }
}

/* ── Iris – Star Wars circle wipe (Om oss) ───── */

.section-incoming.wipe-iris {
    -webkit-mask-image: radial-gradient(circle, #000 38%, transparent 58%);
    mask-image: radial-gradient(circle, #000 38%, transparent 58%);
    -webkit-mask-size: 0% 0%;
    mask-size: 0% 0%;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    animation: mask-iris 0.9s ease-in-out forwards;
}

@keyframes mask-iris {
    from {
        -webkit-mask-size: 0% 0%;
        mask-size: 0% 0%;
    }
    to {
        -webkit-mask-size: 300% 300%;
        mask-size: 300% 300%;
    }
}

/* ── Down – vertical downward sweep (Kontakt) ── */

.section-incoming.wipe-down {
    -webkit-mask-image: linear-gradient(to bottom, #000 44%, transparent 56%);
    mask-image: linear-gradient(to bottom, #000 44%, transparent 56%);
    -webkit-mask-size: 100% 300%;
    mask-size: 100% 300%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: 0 100%;
    mask-position: 0 100%;
    animation: mask-down 1s ease-in-out forwards;
}

@keyframes mask-down {
    from {
        -webkit-mask-position: 0 100%;
        mask-position: 0 100%;
    }
    to {
        -webkit-mask-position: 0 0%;
        mask-position: 0 0%;
    }
}

/* ── Fade – fallback ─────────────────────────── */

.section-incoming.wipe-fade {
    opacity: 0;
    animation: section-fade 0.6s ease-out forwards;
}

@keyframes section-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Leaves & wind (nature wipe decoration) ──── *
   Inline SVG leaves (oak, birch, maple) with
   veins and stems. Rendered outside .section-
   incoming so they are NOT clipped by the mask.
   Wind streaks add atmospheric depth.             */

.wipe-leaves {
    position: fixed;
    inset: 0;
    z-index: 600;
    pointer-events: none;
    overflow: hidden;
}

.wipe-leaves .leaf-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.wipe-leaves .leaf {
    position: absolute;
    pointer-events: none;
    opacity: 0;
    height: auto;
    filter: drop-shadow(1px 2px 3px rgba(0,0,0,0.18));
}

/* — Leaf instances ————————————————————————————
   Layout only — animation is applied dynamically
   via inline style so each transition gets a
   unique randomised speed & flutter pattern.      */

.wipe-leaves .leaf-1  { top: 1%;  right: -15px; width: 72px; }
.wipe-leaves .leaf-2  { top: 5%;  right: 5%;    width: 56px; }
.wipe-leaves .leaf-3  { top: 10%; right: -8px;  width: 66px; }
.wipe-leaves .leaf-4  { top: 15%; right: 4%;    width: 78px; }
.wipe-leaves .leaf-5  { top: 20%; right: -12px; width: 54px; }
.wipe-leaves .leaf-6  { top: 26%; right: 7%;    width: 64px; }
.wipe-leaves .leaf-7  { top: 32%; right: -5px;  width: 82px; }
.wipe-leaves .leaf-8  { top: 37%; right: 3%;    width: 58px; }
.wipe-leaves .leaf-9  { top: 43%; right: -18px; width: 70px; }
.wipe-leaves .leaf-10 { top: 48%; right: 6%;    width: 74px; }
.wipe-leaves .leaf-11 { top: 53%; right: -10px; width: 60px; }
.wipe-leaves .leaf-12 { top: 59%; right: 4%;    width: 55px; }
.wipe-leaves .leaf-13 { top: 64%; right: -8px;  width: 80px; }
.wipe-leaves .leaf-14 { top: 69%; right: 5%;    width: 62px; }
.wipe-leaves .leaf-15 { top: 75%; right: -14px; width: 70px; }
.wipe-leaves .leaf-16 { top: 80%; right: 3%;    width: 56px; }
.wipe-leaves .leaf-17 { top: 85%; right: -6px;  width: 68px; }
.wipe-leaves .leaf-18 { top: 89%; right: 6%;    width: 52px; }
.wipe-leaves .leaf-19 { top: 93%; right: -10px; width: 84px; }
.wipe-leaves .leaf-20 { top: 97%; right: 2%;    width: 58px; }

/* — Flutter keyframes ————————————————————————
   Natural tumbling: oscillating rotation (not
   monotonic spin), vertical bobbing, scaleX
   flip for 3D tumble feel. Opacity stays solid
   until past viewport edge.                       */

@keyframes flutter-a {
    0%   { opacity: 0;    transform: translate(0, 0)          rotate(0deg)   scaleX(1); }
    6%   { opacity: 0.95; }
    15%  { opacity: 0.95; transform: translate(-16vw, 22px)   rotate(35deg)  scaleX(0.35); }
    28%  { opacity: 0.95; transform: translate(-30vw, -14px)  rotate(-20deg) scaleX(1); }
    40%  { opacity: 0.93; transform: translate(-44vw, 30px)   rotate(50deg)  scaleX(0.3); }
    52%  { opacity: 0.93; transform: translate(-56vw, -10px)  rotate(-15deg) scaleX(0.9); }
    64%  { opacity: 0.9;  transform: translate(-68vw, 24px)   rotate(40deg)  scaleX(0.35); }
    76%  { opacity: 0.9;  transform: translate(-80vw, -18px)  rotate(-25deg) scaleX(1); }
    88%  { opacity: 0.88; transform: translate(-96vw, 14px)   rotate(30deg)  scaleX(0.5); }
    100% { opacity: 0.85; transform: translate(-115vw, -5px)  rotate(-10deg) scaleX(0.8); }
}

@keyframes flutter-b {
    0%   { opacity: 0;    transform: translate(0, 0)          rotate(0deg)    scaleX(1); }
    8%   { opacity: 0.92; }
    18%  { opacity: 0.92; transform: translate(-18vw, -18px)  rotate(-40deg)  scaleX(0.4); }
    30%  { opacity: 0.92; transform: translate(-32vw, 24px)   rotate(25deg)   scaleX(1); }
    42%  { opacity: 0.9;  transform: translate(-46vw, -20px)  rotate(-55deg)  scaleX(0.3); }
    54%  { opacity: 0.9;  transform: translate(-58vw, 16px)   rotate(15deg)   scaleX(0.85); }
    66%  { opacity: 0.88; transform: translate(-70vw, -12px)  rotate(-35deg)  scaleX(0.4); }
    78%  { opacity: 0.88; transform: translate(-84vw, 20px)   rotate(20deg)   scaleX(1); }
    90%  { opacity: 0.86; transform: translate(-100vw, -8px)  rotate(-30deg)  scaleX(0.55); }
    100% { opacity: 0.84; transform: translate(-115vw, 8px)   rotate(10deg)   scaleX(0.75); }
}

@keyframes flutter-c {
    0%   { opacity: 0;    transform: translate(0, 0)          rotate(0deg)    scaleX(1); }
    5%   { opacity: 0.94; }
    16%  { opacity: 0.94; transform: translate(-14vw, 28px)   rotate(45deg)   scaleX(0.3); }
    30%  { opacity: 0.93; transform: translate(-32vw, -22px)  rotate(-30deg)  scaleX(1); }
    42%  { opacity: 0.92; transform: translate(-46vw, 18px)   rotate(60deg)   scaleX(0.35); }
    54%  { opacity: 0.9;  transform: translate(-58vw, -16px)  rotate(-20deg)  scaleX(0.9); }
    66%  { opacity: 0.9;  transform: translate(-72vw, 26px)   rotate(45deg)   scaleX(0.3); }
    78%  { opacity: 0.88; transform: translate(-86vw, -14px)  rotate(-35deg)  scaleX(1); }
    90%  { opacity: 0.86; transform: translate(-100vw, 10px)  rotate(25deg)   scaleX(0.5); }
    100% { opacity: 0.84; transform: translate(-116vw, -8px)  rotate(-15deg)  scaleX(0.85); }
}

@keyframes flutter-d {
    0%   { opacity: 0;    transform: translate(0, 0)          rotate(0deg)    scaleX(1); }
    7%   { opacity: 0.93; }
    14%  { opacity: 0.93; transform: translate(-12vw, -24px)  rotate(-50deg)  scaleX(0.35); }
    26%  { opacity: 0.92; transform: translate(-28vw, 20px)   rotate(30deg)   scaleX(1); }
    38%  { opacity: 0.92; transform: translate(-40vw, -18px)  rotate(-45deg)  scaleX(0.3); }
    50%  { opacity: 0.9;  transform: translate(-54vw, 28px)   rotate(20deg)   scaleX(0.85); }
    62%  { opacity: 0.9;  transform: translate(-66vw, -10px)  rotate(-40deg)  scaleX(0.4); }
    74%  { opacity: 0.88; transform: translate(-78vw, 22px)   rotate(35deg)   scaleX(1); }
    86%  { opacity: 0.86; transform: translate(-92vw, -6px)   rotate(-25deg)  scaleX(0.45); }
    100% { opacity: 0.84; transform: translate(-114vw, 10px)  rotate(15deg)   scaleX(0.8); }
}
