/**
 * Utilities: single-purpose helper classes used on any block through the
 * editor's "Additional CSS class" or GB global classes.
 *
 * Groups: spacing, width, typography helpers, image effects, visibility.
 * Block-specific rules do not belong here; put them in css/blocks/.
 */

/* ---------- Spacing ---------- */

.gb-container.no-padding {
    padding: 0;
}

.bottom-padding {
    padding: var(--section-padding);
    padding-top: 0;
}

.gb-container.no-padding-bottom {
    padding-bottom: 0;
}

.gb-container.no-padding-top {
    padding-top: 0;
}

.gb-container.default-margin-top {
    margin-top: var(--default-margin-top);
}

.gb-container.default-margin-bottom {
    margin-bottom: var(--default-margin-bottom);
}

/* ---------- Typography helpers ---------- */

.larger-text {
    font-size: 1.25rem;
}

.smaller-text {
    font-size: 0.8em;
}

.very-large-text {
    font-size: 24px;
}

.small-heading {
    font-size: 20px;
}

.huge-heading {
    font-size: 60px;
    line-height: 0.8em;
}

h2.larger-h2 {
    font-size: var(--h1-size);
}

.light-text {
    font-weight: 300;
}

.semi-bold {
    font-weight: 600;
}

.bold {
    font-weight: 700;
}

.text-shadow {
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

/* ---------- Image effects ---------- */

/* Image fills its figure (use on the img). */
figure:has(> img.object-fit-img) {
    position: relative;
    height: 100%;
    width: 100%;
}

.object-fit-img {
    object-fit: cover;
    object-position: center;
    height: 100%;
    width: 100%;
}

/* Tinted overlay in the section's accent color (use on the img).
   Override the color per block with --tint-layer-clr. */
figure:has(> img.tint-layer) {
    position: relative;
}

figure:has(> img.tint-layer)::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(149deg, transparent 0%, var(--tint-layer-clr, var(--accent-clr)) 100%);
    mix-blend-mode: multiply;
    transition: all 1s ease-in-out;
}

img.moody-image {
    filter: grayscale(100%) contrast(1.08) brightness(0.95);
}

.black-and-white {
    filter: grayscale(100%);
}

.black-and-white-invert {
    filter: grayscale(100%) invert(1);
}

.square-img,
.square-img img {
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

/* Slow pan of an image inside its figure, starts when .is-visible is added
   (element-visibility-observer). Direction modifiers on the same img. */
figure:has(> img.pan-image) {
    position: relative;
    overflow: hidden;
    height: 100%;
    width: 100%;
}

img.pan-image {
    --pan-scale: 1.25;
    --pan-duration: 30s;
    --pan-from-x: 8%;
    --pan-from-y: -8%;
    --pan-to-x: -8%;
    --pan-to-y: 8%;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(var(--pan-scale)) translate(var(--pan-from-x), var(--pan-from-y));
    transition: transform var(--pan-duration) linear;
    will-change: transform;
}

img.pan-image.is-visible {
    transform: scale(var(--pan-scale)) translate(var(--pan-to-x), var(--pan-to-y));
}

img.pan-image.pan-bl-tr { --pan-from-x: 8%;  --pan-from-y: -8%; --pan-to-x: -8%; --pan-to-y: 8%;  }
img.pan-image.pan-tr-bl { --pan-from-x: -8%; --pan-from-y: 8%;  --pan-to-x: 8%;  --pan-to-y: -8%; }
img.pan-image.pan-tl-br { --pan-from-x: 8%;  --pan-from-y: 8%;  --pan-to-x: -8%; --pan-to-y: -8%; }
img.pan-image.pan-br-tl { --pan-from-x: -8%; --pan-from-y: -8%; --pan-to-x: 8%;  --pan-to-y: 8%;  }
img.pan-image.pan-l-r   { --pan-from-x: 8%;  --pan-from-y: 0;   --pan-to-x: -8%; --pan-to-y: 0;   }
img.pan-image.pan-r-l   { --pan-from-x: -8%; --pan-from-y: 0;   --pan-to-x: 8%;  --pan-to-y: 0;   }
img.pan-image.pan-t-b   { --pan-from-x: 0;   --pan-from-y: 8%;  --pan-to-x: 0;   --pan-to-y: -8%; }
img.pan-image.pan-b-t   { --pan-from-x: 0;   --pan-from-y: -8%; --pan-to-x: 0;   --pan-to-y: 8%;  }

@media (prefers-reduced-motion: reduce) {
    img.pan-image {
        transition: none;
    }
}

/* ---------- Visibility ---------- */

/* The one max-width query in the theme: hiding below a breakpoint cannot be
   expressed mobile first without knowing the element's display value. */
@media only screen and (max-width: 767px) {
    .hide-in-mobile {
        display: none;
    }
}

/* ---------- Width ---------- */

@media only screen and (min-width: 768px) {
    .max-width-600-article {
        max-width: 600px;
        margin: 0 auto;
    }

    .small-heading {
        font-size: 25px;
    }

    .huge-heading {
        font-size: 80px;
    }

    .very-large-text {
        font-size: 40px;
    }
}

@media only screen and (min-width: 990px) {
    .max-width-600,
    .gb-container.max-width-600 {
        max-width: 600px;
        margin: 0 auto 40px;
    }

    .max-width-768,
    .gb-container.max-width-768 {
        max-width: 768px;
        margin: 0 auto;
    }
}

@media only screen and (min-width: 1280px) {
    .huge-heading {
        font-size: 100px;
    }
}
