/* Both transparent layers share the same rail at the upper edge of the section. */
main > .section,
.footer {
  --frieze-height: min(5.5vw, clamp(40px, 4.7vw, 66px));
  --frieze-center-rail: 64;
  position: relative;
}

.footer {
  padding-top: calc(var(--frieze-height) + clamp(20px, 2vw, 30px));
}

main > .section {
  --heading-top-gap: 16px;
  /* Visible distance from the rail to the lowest gold pixel, in source-image rows. */
  --frieze-depth: 162;
  --frieze-visible-depth: calc(var(--frieze-height) * var(--frieze-depth) / 228 - var(--frieze-tip-trim, 0px));
  --heading-box-top: calc(var(--frieze-visible-depth) + var(--heading-top-gap) - var(--heading-ink-top, 5px));
  /* Mirror the distance from the section's color boundary to the first line of text. */
  --heading-gap: calc(var(--heading-box-top) + var(--heading-text-top, 5px));
  padding-top: var(--heading-box-top);
}

main > .section::before,
main > .section::after,
.footer::before,
.footer::after,
.frieze-sheen::before,
.frieze-sheen::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  pointer-events: none;
  border: 0 solid transparent;
}

/* Stretch only the straight span. The two outer ornaments keep their proportions. */
main > .section::before,
.footer::before,
.frieze-sheen::before {
  --rail-slice: var(--frieze-center-rail);
  --rail-canvas-height: 228;
  --end-above-rail: calc(var(--frieze-height) * var(--rail-slice) / 228);
  width: 50%;
  height: calc(var(--frieze-height) * (var(--rail-canvas-height) - var(--rail-slice)) / 228);
  border-image-source: var(--frieze-ends);
  border-image-slice: var(--rail-slice) 232 0 fill;
  border-image-outset: var(--end-above-rail) 0 0;
  border-image-width: var(--end-above-rail) calc(var(--frieze-height) * 232 / 228) 0;
}

main > .section::after,
.footer::after,
.frieze-sheen::after {
  --center-above-rail: calc(var(--frieze-height) * var(--frieze-center-rail) / 228);
  width: calc(var(--frieze-height) * 806 / 228);
  height: calc(var(--frieze-height) - var(--center-above-rail));
  border-image-source: var(--frieze-center);
  border-image-slice: var(--frieze-center-rail) 0 0 fill;
  border-image-outset: var(--center-above-rail) 0 0;
  border-image-width: var(--center-above-rail) 0 0;
}

/* Both nine-slice layers pass under a single stripe, including their overhang above the seam. */
.frieze-sheen {
  position: absolute;
  z-index: 1;
  top: calc(0px - var(--frieze-height));
  left: 25%;
  width: 50%;
  height: calc(2 * var(--frieze-height));
  pointer-events: none;
}
.frieze-sheen::before, .frieze-sheen::after { top: var(--frieze-height); }
.frieze-sheen::before { width: 100%; }

/* The Hero divider uses the original, shorter rail image. */
#benefits::before, #benefits > .frieze-sheen::before {
  --rail-slice: 53;
  --rail-canvas-height: 102;
}

#benefits {
  --frieze-depth: 160;
  --frieze-ends: url("../images/dividers/frieze-leaf-ends.png");
  --frieze-center: url("../images/dividers/section-frieze.png");
}

#salary {
  --frieze-depth: 123;
  --frieze-ends: url("../images/dividers/salary-ends.png");
  --frieze-center: url("../images/dividers/salary-center.png");
}

#timeline {
  --frieze-depth: 116;
  --frieze-ends: url("../images/dividers/timeline-ends.png");
  --frieze-center: url("../images/dividers/timeline-center.png");
}

/* Set the artwork row that meets the section boundary on the center layer alone. */
#timeline::after, #timeline > .frieze-sheen::after {
  --frieze-center-rail: 110;
}

#requirements {
  --frieze-ends: url("../images/dividers/requirements-ends.png");
  --frieze-center: url("../images/dividers/requirements-center.png");
}

#documents {
  --frieze-ends: url("../images/dividers/documents-ends.png");
  --frieze-center: url("../images/dividers/documents-center.png");
}

#vacancies {
  --frieze-depth: 118;
  /* The hairline at the compass tip fades when the source image is scaled down. */
  --frieze-tip-trim: 1px;
  /* The compass attaches at its equator, with room above the rail for the north point. */
  --frieze-center-rail: 108;
  --frieze-ends: url("../images/dividers/vacancies-ends.png");
  --frieze-center: url("../images/dividers/vacancies-center.png");
}

#social {
  --frieze-ends: url("../images/dividers/social-ends.png");
  --frieze-center: url("../images/dividers/social-center.png");
}

#support {
  --frieze-depth: 89;
  --frieze-ends: url("../images/dividers/support-ends.png");
  --frieze-center: url("../images/dividers/support-center.png");
}

#support::after, #support > .frieze-sheen::after {
  --frieze-center-rail: 137;
}

#how-to-apply {
  --frieze-depth: 163;
  --frieze-ends: url("../images/dividers/how-to-apply-ends.png");
  --frieze-center: url("../images/dividers/how-to-apply-center.png");
}

#faq {
  --frieze-depth: 98;
  --frieze-ends: url("../images/dividers/faq-ends.png");
  --frieze-center: url("../images/dividers/faq-center.png");
}

#contact {
  --frieze-depth: 111;
  --frieze-ends: url("../images/dividers/contact-ends.png");
  --frieze-center: url("../images/dividers/contact-center.png");
}

#footer {
  --frieze-ends: url("../images/dividers/footer-ends.png");
  --frieze-center: url("../images/dividers/footer-center.png");
}

/* Between ivory and yellow, the thin rail can land on either background after zoom. */
main > .section:not(#benefits)::before {
  filter: drop-shadow(0 1px 0 rgba(135, 69, 1, .65));
}
