/* Rounded grain: hue-preserving seams and a separate, shallow relief layer. */
@property --pp-material-tone {
    syntax: "<color>";
    inherits: true;
    initial-value: #b1dfdd;
}

@media (min-width: 992px) {
    .pp-home {
        /* Match the warm paper used by the about-us opening section. */
        --pp-home-paper-surface: #e6e0d5;
        --pp-grain: url("/images/studio/cellular-grain-mask.svg");
        --pp-grain-relief: url("/images/studio/cellular-grain-relief.svg");
        --pp-grain-size: 360px 360px;
        --pp-grain-light-opacity: .95;
        --pp-grain-color-opacity: .85;
        --pp-grain-dark-opacity: .65;
        --pp-grain-lightness-cap: .95;
        --pp-grain-surface: #062527;
        --pp-material-tone: #b1dfdd;
        /* Both neighboring sections inherit the same animated benefit color. */
        transition: --pp-material-tone 1.1s ease;
    }

    .pp-home :is(.pp-discover:not(.pp-services-active), .pp-why-choose-us, .pp-process, .pp-work, .pp-footer) {
        position: relative;
        isolation: isolate;
    }

    .pp-home :where(.pp-discover:not(.pp-services-active), .pp-why-choose-us, .pp-process, .pp-work, .pp-footer)::before,
    .pp-home .pp-services-stage::before {
        content: "";
        position: absolute;
        inset: 0;
        z-index: -1;
        background-color: color-mix(in srgb, var(--pp-grain-surface) 70%, #b1dfdd);
        background-color: oklch(from var(--pp-grain-surface) min(var(--pp-grain-lightness-cap), calc(l + .16)) c h);
        mask-image: var(--pp-grain);
        mask-size: var(--pp-grain-size);
        mask-repeat: repeat;
        mask-mode: alpha;
        mix-blend-mode: normal;
        opacity: var(--pp-grain-dark-opacity);
        pointer-events: none;
    }

    .pp-home :where(.pp-discover:not(.pp-services-active), .pp-why-choose-us, .pp-process, .pp-work, .pp-footer)::after,
    .pp-home .pp-services-stage::after {
        content: "";
        position: absolute;
        inset: 0;
        z-index: -1;
        background: var(--pp-grain-relief) repeat 0 0 / var(--pp-grain-size);
        pointer-events: none;
    }

    /* One stationary grain spans both sides of the existing diagonal color wipe. */
    .pp-home .pp-services-stage {
        --pp-service-grain-dark: color-mix(in srgb,
            color-mix(in srgb, #062527, #183f50 calc(var(--pp-service-progress, 0) * 100%)),
            var(--pp-material-tone) calc(var(--pp-service-exit-progress, 0) * 100%));
        /* Project the wipe's center onto its normal; the mask itself never moves. */
        --pp-service-grain-boundary: calc(50% + (var(--pp-service-wipe-y, 110vh) - 50dvh) * cos(var(--pp-service-wipe-angle, -10deg)));
        --pp-service-grain-opacity: calc(var(--pp-grain-dark-opacity)
            + (var(--pp-grain-color-opacity) - var(--pp-grain-dark-opacity)) * var(--pp-service-exit-progress, 0));
        background-color: var(--pp-home-paper-surface);
        background-image: linear-gradient(
            color-mix(in srgb, var(--pp-home-paper-surface) 82%, transparent),
            color-mix(in srgb, var(--pp-home-paper-surface) 82%, transparent));
        background-size: auto;
    }

    .pp-home .pp-services-stage::after { z-index: 0; }

    .pp-home .pp-services-stage::before {
        z-index: 0;
        background-color: transparent;
        /* Each side retains its own hue and contrast throughout the diagonal wipe. */
        background-image: linear-gradient(calc(180deg + var(--pp-service-wipe-angle, -10deg)),
            oklch(from var(--pp-home-paper-surface) .99 c h / var(--pp-grain-light-opacity)) var(--pp-service-grain-boundary),
            oklch(from var(--pp-service-grain-dark) min(.95, calc(l + .16)) c h / var(--pp-service-grain-opacity)) var(--pp-service-grain-boundary));
        opacity: 1;
    }

    .pp-home .pp-services-wipe {
        background: color-mix(in srgb,
            color-mix(in srgb, #062527, #183f50 calc(var(--pp-service-progress, 0) * 100%)),
            var(--pp-material-tone) calc(var(--pp-service-exit-progress, 0) * 100%));
    }

    .pp-home :is(.pp-discover:not(.pp-services-active), .pp-work) {
        --pp-grain-surface: var(--pp-home-paper-surface);
        --pp-grain-lightness-cap: .99;
        background-color: var(--pp-home-paper-surface);
    }

    .pp-home :is(.pp-discover:not(.pp-services-active), .pp-work)::before {
        opacity: var(--pp-grain-light-opacity);
    }

    .pp-home .pp-why-choose-us::before { opacity: var(--pp-grain-color-opacity); }

    /* The material keeps its shape as the benefits change its tint. */
    .pp-home .pp-why-choose-us {
        --pp-grain-surface: var(--pp-material-tone);
        background-color: var(--pp-material-tone);
    }

    .pp-home:has(.pp-why-choose-us [data-why-select="1"][aria-pressed="true"]) { --pp-material-tone: #c4dce8; }
    .pp-home:has(.pp-why-choose-us [data-why-select="2"][aria-pressed="true"]) { --pp-material-tone: #e7dac2; }
    .pp-home:has(.pp-why-choose-us [data-why-select="3"][aria-pressed="true"]) { --pp-material-tone: #b8d8cb; }
    .pp-home:has(.pp-why-choose-us [data-why-select="4"][aria-pressed="true"]) { --pp-material-tone: #d9cde3; }
    .pp-home:has(.pp-why-choose-us [data-why-select="5"][aria-pressed="true"]) { --pp-material-tone: #d4e2ce; }
    .pp-home:has(.pp-why-choose-us [data-why-select="6"][aria-pressed="true"]) { --pp-material-tone: #c3dcde; }
    .pp-home:has(.pp-why-choose-us [data-why-select="7"][aria-pressed="true"]) { --pp-material-tone: #e4cfc7; }
    .pp-home:has(.pp-why-choose-us [data-why-select="8"][aria-pressed="true"]) { --pp-material-tone: #c5dfd4; }

    .pp-home .pp-process {
        background-color: #062527;
        background-image: radial-gradient(ellipse at 80% 25%, #164951, transparent 70%);
    }

    .pp-home .pp-process::before {
        background-image: radial-gradient(ellipse at 80% 25%, oklch(from #164951 calc(l + .16) c h), transparent 70%);
    }

    .pp-home .pp-footer {
        background-image: radial-gradient(ellipse at 20% 100%, #164951, transparent 75%);
    }

    .pp-home .pp-footer::before {
        background-image: radial-gradient(ellipse at 20% 100%, oklch(from #164951 calc(l + .16) c h), transparent 75%);
    }
}

@media (min-width: 992px) and (prefers-reduced-motion: reduce) {
    .pp-home { transition: none; }
}
