/* ============================================
   ULSE PAPYRUS5 — Auto Height, Realistic Mode
============================================ */

.ulse-papyrus5 {
    position: relative;
    margin: 40px auto;
    --papyrus-base: 610px;
    --papyrus-scale: 1;
    --papyrus-width: calc(var(--papyrus-base) * var(--papyrus-scale));
    max-width: var(--papyrus-width);
    width: min(100%, var(--papyrus-width));
    overflow: visible; /* ensure background pseudo-element not clipped */
    z-index: 0; /* create stacking context so ::before sits behind content */

    /* Transparent base; single papyrus image handled via ::before */
    background: transparent;

    /* Text zone padding INSIDE the papyrus */
    padding:
        calc(170px * var(--papyrus-scale))
        calc(70px * var(--papyrus-scale))
        calc(150px * var(--papyrus-scale));
    color: #f5d7a0;
    font-family: Georgia, serif;
    line-height: 1.85;

    /* Edge slice heights (match papyrus-top/bottom images) */
    --papyrus-top: calc(280px * var(--papyrus-scale));
    --papyrus-bottom: calc(280px * var(--papyrus-scale));

    /* Center inner flow */
    display: grid;
    place-items: center;
    text-align: center;
}

/* Papyrus background layers (top + seamless middle + bottom) */
.ulse-papyrus5::before {
    content: "";
    position: absolute;
    top: var(--papyrus-top);
    bottom: var(--papyrus-bottom);
    left: 0;
    right: 0;
    background-image: url('../img/papyrus-mid5.webp');
    background-size: 100% auto;
    background-repeat: repeat-y;
    background-position: top center;
    opacity: 1;
    pointer-events: none;
    z-index: -2; /* middle layer behind edges */
}

.ulse-papyrus5::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url('../img/papyrus-top5.webp'), url('../img/papyrus-bottom5.webp');
    background-size: 100% var(--papyrus-top), 100% var(--papyrus-bottom);
    background-repeat: no-repeat, no-repeat;
    background-position: top center, bottom center;
    opacity: 1;
    pointer-events: none;
    z-index: -1; /* edge layers above middle, behind text */
}

/* Headings */
.ulse-papyrus5 h1,
.ulse-papyrus5 h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #f8e0b0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Paragraphs */
.ulse-papyrus5 p {
    margin-bottom: 18px;
    font-size: 20px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.35);
    text-align: center !important;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ulse-papyrus5 a {
    overflow-wrap: anywhere;
    word-break: break-word;
    display: inline-block;
}

/* Constrain text width inside the papyrus without shrinking the image */
.ulse-papyrus5 article {
    max-width: 90%;
    width: 100%;
    margin: 0 auto;
}

.ulse-papyrus5 article * {
    max-width: 100%;
}

@media (max-width: 700px) {
    .ulse-papyrus5 {
        padding: calc(130px * var(--papyrus-scale)) calc(40px * var(--papyrus-scale)) calc(120px * var(--papyrus-scale));
    }
    .ulse-papyrus5 article {
        max-width: 95%;
    }
}
