/************************************************************/
/*
/*      Block CSS
/*
/************************************************************/
.wp-block-post-content {
	/* Gutenberg style override */
	:root &:where(.is-layout-constrained) > * {
		margin-block-start: 0;
	}
	
	/* Full-width background support */
	& > .has-background:not(.alignfull, .no-full-size-bg) {
		position: relative;
		
		&::before {
			content: '';
			position: absolute;
			top: 0;
			left: calc((var(--wp--custom--viewport-width) - 100%) / 2 * -1);
			width: var(--wp--custom--viewport-width);
			height: 100%;
			background: inherit;
			z-index: -1;
		}
	}
	
	/* First block top margin adjustments (frontend only) */
	/* Remove if theme does not have blocks that go behind the header */
    body:not(.wp-admin, .block-editor-iframe__body) & {
        & > :first-child {
            /* Move some blocks behind the header */
            &:is(.wp-block-cover) {
                margin-block-start: calc(var(--wp--custom--header-height) * -1) !important;
            }
            
            &:not(.wp-block-cover) {
                margin-block-start: max(var(--wp--preset--spacing--12-5), calc((var(--wp--custom--header-height) - var(--wp--custom--stickied-header-height)) + var(--wp--preset--spacing--12-5))) !important;
            }
        }
    }
}

/************************************************************/
/* Core blocks
/************************************************************/
/******************************/
/* Columns
/******************************/
.wp-block-columns {
    /* Responsive ****************************************************/
	@media (width <= 1200px) {
        &.responsive-adjust-l {
            flex-wrap: wrap !important;

            & > .wp-block-column {
                flex-basis: 100% !important;
            }
        }
    }
    
    @media (width <= 1000px) {
        &.responsive-adjust {
            flex-wrap: wrap !important;

            & > .wp-block-column {
                flex-basis: 100% !important;
            }
        }
    }

	@media (width <= 781px) {
        &.responsive-reverse-order {
            flex-direction: column-reverse;
        }
    }
}

/******************************/
/* Cover
/******************************/
.wp-block-cover {
    &.alignfull {
        margin-inline: calc(var(--wp--custom--full-pad) * -1) !important;
    }

    & > .wp-block-cover__inner-container {
        max-width: calc(100% / 3);
        padding-block: var(--wp--custom--header-height) var(--wp--preset--spacing--2);
    }

    /**** Small style variation ****/
    &.is-style-small {
        height: min(550px, 100svh);

        & > .wp-block-cover__inner-container {
            max-width: 55%;
        }
    }

    /* Responsive ****************************************************/
	@media (width <= 1720px) {
        & > .wp-block-cover__inner-container {
            max-width: 40%;
        }

        &.is-style-small {
            & > .wp-block-cover__inner-container {
                max-width: calc(100% * (2/3));
            }
        }
    }
    
    @media (width <= 1300px) {
        & > .wp-block-cover__inner-container {
            max-width: 50%;
        }

        &.is-style-small {
            & > .wp-block-cover__inner-container {
                max-width: 75%;
            }
        }
    }
    
    @media (width <= 1000px) {
        & > .wp-block-cover__inner-container {
            max-width: calc(100% * (2/3));
        }

        &.is-style-small {
            & > .wp-block-cover__inner-container {
                max-width: 90%;
            }
        }
    }
    
    @media (width <= 800px) {
        & > .wp-block-cover__inner-container {
            max-width: 75%;
        }
    }
    
    @media (width <= 500px) {
        & > .wp-block-cover__inner-container {
            max-width: 90%;
        }

        &.is-style-small {
            & > .wp-block-cover__inner-container {
                max-width: 95%;
            }
        }
    }
}

/******************************/
/* Group
/******************************/
.wp-block-group {
    /* Group link hover color inheritance */
    &.is-linked[class*="focus-"] > :is(p, .wp-block-heading) {
        color: inherit !important;
        transition: color .3s !important;
    }
}

/******************************/
/* Image
/******************************/
.wp-block-image {
	position: relative;
    border-radius: var(--wp--custom--border-radius--medium);
    overflow: clip;
    
    /* :is added to increase specificity */
    &:is(.wp-block-image) {
        margin-block: unset;
    }

    &.aligncenter {
        justify-self: center;
    }
    
    &.alignright {
        justify-self: end;
    }

    /* Image caption */
    &:has(figcaption)::before {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 20%;
        background:
            linear-gradient(
                0deg,
                rgba(0, 0, 0, .3) 0%,
                transparent 100%
            );
        z-index: 1;
    }

    & > figcaption {
        position: absolute;
        bottom: var(--wp--preset--spacing--2);
        left: var(--wp--preset--spacing--1-5);
        max-width: calc(100% - (var(--wp--preset--spacing--1-5) * 2));
        font-size: var(--wp--preset--font-size--medium-large);
        color: var(--wp--custom--color--default--bg--1);
        margin-block: unset;
        z-index: 2;
    }
    
	
	/**** Fill style variations ****/
	:has(> &[class*="is-style-fill"]) {
		&.wp-block-column {
			align-self: stretch;
		}
		
		& > [class*="is-style-fill"] {
			&:not(.cover, .contain) :not(figcaption) {
				object-fit: cover;
			}
			
			/* Fill width */
			&.is-style-fill-width,
			&.is-style-fill-width :not(figcaption) {
				width: 100% !important;
                height: auto;
			}
			
			/* Fill height */
			&.is-style-fill-height,
			&.is-style-fill-height :not(figcaption) {
                height: 100% !important;
                width: auto;
			}
			
			/* Fill both */	
			&.is-style-fill-both,
			&.is-style-fill-both :not(figcaption) {
				width: 100% !important;
				height: 100% !important;

                &:not(figure, figcaption) {
                    /* position: absolute; */
                    position: relative;
                    inset: 0;

                    /* Support for Cake Tools focal points */
                    [style*="--focal-x"][style*="--focal-y"] > & {
                        left: 50%;
                        height: auto !important;
                        translate: calc(var(--focal-x, 50%) * -1) calc(50% - var(--focal-y, 50%)) !important;
                    }
                }
                
                /* If in a block with a defined minimum height, inherit it */
                [style*="min-height:"] > & {
                    min-height: inherit;
                }
			}
		}
	}
	
	/* Backend style ****************************************************/
    body:is(.wp-admin, .block-editor-iframe__body) & {
        &[class*="is-style-fill"]:not(.is-resized) .components-resizable-box__container {
            display: contents !important;
        }

        style + &.is-style-fill-both {
            /* Support for Cake Tools focal points */
            &.is-style-fill-both img {
                left: 50% !important;
                height: auto !important;
                translate: calc(var(--focal-x, 50%) * -1) calc(50% - var(--focal-y, 50%)) !important;
            }
        }
    }
	
	/* Responsive ****************************************************/
	@media (width <= 800px) {
		&:not(:has(> img[src$=".svg"])) {
            max-height: 50svh;
        }
	}
}

/******************************/
/* List
/******************************/
ul.wp-block-list {
	&:is(ul) {
		padding-inline-start: unset !important;
		
		& > li {
			display: flex;
			align-items: baseline;
			column-gap: var(--wp--preset--spacing--0-50);
			list-style: unset;
			
			&::before {
				content: '-';
			}
			
			& + li {
				margin-block-start: var(--wp--preset--spacing--0-75);
			}
			
			&:is(.block-editor-block-list__block:not(.is-selected), :not(.block-editor-block-list__block)) :is(div, b, strong, em, a):not([role="textbox"]) {
				display: contents;
			}
		}
	}
	
	&:is(ol) {
		padding-inline-start: 24px !important;
	}
}

/******************************/
/* Media-text
/******************************/
.wp-block-media-text {
	grid-template-columns: 40% 50% !important;
	justify-content: space-between;
	
	&.has-media-on-the-right {
		grid-template-columns: 50% 40% !important;
	}
	
	.wp-block-media-text__media {
		border-radius: var(--wp--custom--border-radius--medium);
		overflow: clip;

        &, img {
            width: 100%;
            height: auto;
            aspect-ratio: 4/3;
            object-fit: cover;
        }
	}
	
	.wp-block-media-text__content {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		padding-inline: unset;
		
		& > * {
			margin-block: unset;
			
			& + * {
				margin-block-start: 2em;
			}
		}
	}
	
	/* Responsive ****************************************************/
	@media (width <= 1200px) {
		grid-template-columns: 45% 50%!important;
		
		&.has-media-on-the-right {
			grid-template-columns: 50% 45% !important;
		}
	}
	
	@media (width <= 900px) {
		grid-template-columns: 65% 20% 1fr !important;
		row-gap: var(--wp--preset--spacing--3);
		
		&.has-media-on-the-right {
			grid-template-columns: 1fr 20% 65% !important;
		}
		
		.wp-block-media-text__media {
			grid-row: 1 !important;
			grid-column: 1;
			max-height: 60svh;
			
			.has-media-on-the-right > & {
				grid-column: 3;
			}
		}
		
		.wp-block-media-text__content {
			grid-row: 2 !important;
			grid-column: 1 / span 2;
			
			.has-media-on-the-right > & {
				grid-column: 2 / span 2;
				text-align: right;
				
				& > :is(.wp-block-group, .wp-block-buttons) {
					place-content: end;
				}
			}
		}
	}
	
	@media (width <= 700px) {
		grid-template-columns: 75% 20% 1fr !important;
		
		&.has-media-on-the-right {
			grid-template-columns: 1fr 20% 75% !important;
		}
	}
    
    @media (width <= 600px) {
        &,
        &.has-media-on-the-right {
            grid-template-columns: 100% !important;

            & > .wp-block-media-text__media,
            & > .wp-block-media-text__content {
                grid-column: 1 !important;
            }
        }
	}
}

/******************************/
/* Video
/******************************/
.wp-block-video {
	position: relative;
    border-radius: var(--wp--custom--border-radius--medium);
    overflow: clip;
	
	&::after {
        content: '';
		position: absolute;
        top: 50%;
		left: 50%;
		width: 12.5%;
		height: auto;
		max-height: 50%;
		aspect-ratio: 1;
		background-image: url(../images/play.svg);
		background-size: contain;
		background-repeat: no-repeat;
        opacity: 1;
		pointer-events: none;
		translate: -50% -50%;
		transition: opacity var(--wp--custom--duration--medium);
		z-index: 2;
	}
    
    &.played::after {
		opacity: 0;
	}

    video {
        cursor: pointer;
    }

    /* Backend style */
    body:is(.wp-admin, .block-editor-iframe__body) & {
        &:has(.components-placeholder) {
            &::before,
            &::after {
                display: none;
            }
        }
    }
}

/************************************************************/
/* Custom blocks
/************************************************************/
/******************************/
/* Anchor
/******************************/
.wp-block-cke-anchor {
    & + :not(.wp-block-cke-anchor) {
        margin-block-start: unset !important;
    }
}

/******************************/
/* Mosaic Element
/******************************/
.wp-block-cke-mosaic-element {
    & > .acf-innerblocks-container {
        & > .wp-block-image {
            min-height: var(--row-height-responsive, var(--row-height, 30svh));
            max-height: var(--row-height-responsive, var(--row-height, 30svh));
        }
    }
}

/******************************/
/* Scrollspy Nav
/******************************/
.wp-block-cke-scrollspy-nav {
    &.is-style-vertical {
        flex-direction: column;
        flex-wrap: nowrap;
        gap: unset;
        max-height: 95svh;
        background-color: var(--wp--custom--color--default--accent--light);
        padding: var(--wp--preset--spacing--3-5) var(--wp--preset--spacing--2);
        box-sizing: border-box;
        overflow-x: clip;
        overflow-y: auto;
        margin-block-start: unset !important;
        border-radius: var(--wp--custom--border-radius--x-small);

        & > .anchor-link-container {
            font-size: var(--wp--preset--font-size--medium-large);
            line-height: var(--wp--custom--line-height--equal);
            color: var(--wp--custom--color--default--accent--dark);
    
            & + * {
                padding-block-start: var(--wp--preset--spacing--1);
                margin-block-start: var(--wp--preset--spacing--1);
                border-block-start: 1px solid var(--wp--custom--color--default--accent--dark);
            }
    
            & > .anchor-link {
                display: inline-block;
                font-size: inherit;
                line-height: inherit;
                color: inherit !important;
                padding: unset !important;
                
                &:is(:hover, :focus) {
                    color: var(--wp--custom--color--default--text--alt) !important;
                }
                
                &.active {
                    font-weight: 700;
                }
            }
        }

        & > .extra-content {
            & > * {
                overflow-wrap: anywhere;
            }
        }
    }

    /* Responsive ****************************************************/
	@media (width <= 1500px) {
        .wp-block-columns:has(> .wp-block-column:first-child > &) {
            & > .wp-block-column:first-child {
                flex-basis: 30% !important;
            }
            
            & > .wp-block-column:last-child {
                flex-basis: 65% !important;
            }
        }
    }

    @media (850px < width <= 1100px) {
        &.is-style-vertical {
            padding: var(--wp--preset--spacing--2);

            /* Override breakpoint set in block style in plugin */
            &.ready {
                position: sticky !important;
                top: var(--wp--preset--spacing--2) !important;
            }
            
            & > .anchor-link-container {
                font-size: var(--wp--preset--font-size--medium);
            }
        }
    }
    
    @media (width <= 850px) {
        .wp-block-columns:has(> .wp-block-column:first-child > &) {
            flex-wrap: wrap !important;
            row-gap: var(--wp--preset--spacing--4-5);

            & > .wp-block-column:first-child,
            & > .wp-block-column:last-child {
                flex-basis: 100% !important;

                & > .wp-block-cke-scrollspy-nav {
                    margin-block-start: unset !important;

                    &.ready {
                        position: relative !important;
                    }

                    &.is-style-vertical {
                        width: max-content !important;
                        max-width: 100%;

                        & > .anchor-link-container {
                            & + * {
                                padding-block-start: var(--wp--preset--spacing--0-75);
                                margin-block-start: var(--wp--preset--spacing--0-75);
                                border-block-start: 1px solid var(--wp--custom--color--default--accent--dark);
                            }
                        }
                    }
                }
            }
        }
    }

    /* Height queries */
    @media (height <= 825px) {
        .wp-block-columns:has(> .wp-block-column:first-child > &) {
            .wp-block-cke-scrollspy-nav {
                &.is-style-vertical {
                    padding: var(--wp--preset--spacing--1-5);
                    
                    & > .anchor-link-container {
                        font-size: var(--wp--preset--font-size--small);
                    }
                }
            }
        }
    }
}

/************************************************************/
/* Other blocks/elements
/************************************************************/
/******************************/
/* Limited width
/* (For elements with no
/* max-width control in editor)
/******************************/
h1, h2, h3, h4, h5, h6, p {
	&.limited-width-l {
		&,
		.edit-post-visual-editor .is-root-container & {
			max-width: min(40rem, 100%);
		}
	}
	
	&.limited-width {
		&,
		.edit-post-visual-editor .is-root-container & {
			max-width: min(37.5rem, 100%);
		}
	}
	
	&.limited-width-s {
		&,
		.edit-post-visual-editor .is-root-container & {
			max-width: min(28.125rem, 100%);
		}
	}
	
	&.limited-width-xs {
		&,
		.edit-post-visual-editor .is-root-container & {
			max-width: min(20rem, 100%);
		}
	}
}

/******************************/
/* Groups/Columns with
/* "constrained" layout
/******************************/
:is(.wp-block-group, .wp-block-column).is-layout-constrained {
    /**** Responsive ****/
    @media (width <= 1240px) {
        & > :not(.wp-block-image) {
            min-width: 50%;
        }
    }
    
    @media (width <= 1000px) {
        & > :not(.wp-block-image) {
            min-width: calc(100% * (2/3));
        }
    }

    @media (width <= 800px) {
        & > :not(.wp-block-image) {
            min-width: 75%;
        }
    }

    @media (width <= 600px) {
        & > :not(.wp-block-image) {
            min-width: 95%;
        }
    }

    @media (width <= 400px) {
        & > :not(.wp-block-image) {
            min-width: 100%;
        }
    }
}

/******************************/
/* Buttons
/******************************/
.wp-block-button,
.menu-item.btn,
body:not(.wp-admin, .login) .gfield--type-fileupload .ginput_container_fileupload,
body:not(.wp-admin, .login) .gform_footer {
	position: relative;
    
    &, 
	& > :is(.wp-block-button__link, [type="submit"], a) {
        min-width: min(250px, 100%);
        max-width: 100%;
    }
	
	& > :is(.wp-block-button__link, [type="submit"], a) {
		display: inline-block;
		width: max-content;
		height: 100%;
        color: var(--wp--custom--color--default--accent--dark);
        background-color: var(--wp--custom--color--default--accent--light);
        padding: var(--wp--preset--spacing--1) var(--wp--preset--spacing--2);
        border-radius: var(--wp--custom--border-radius--x-small);
		transition: color var(--wp--custom--duration--short), background-color var(--wp--custom--duration--short), scale var(--wp--custom--duration--medium);
		scale: 1;
        user-select: none;

        /* !important needed to override Gravity Forms submit button */
        &:is([type="submit"]) {
            display: inline-block !important;
            color: var(--wp--custom--color--default--accent--dark) !important;
            background-color: var(--wp--custom--color--default--accent--light) !important;
            padding: var(--wp--preset--spacing--1) var(--wp--preset--spacing--2) !important;
            border-radius: var(--wp--custom--border-radius--x-small) !important;
            transition: color var(--wp--custom--duration--short), background-color var(--wp--custom--duration--short), scale var(--wp--custom--duration--medium) !important;
            font-family: var(--wp--preset--font-family--inter) !important;
            font-size: var(--wp--preset--font-size--medium-large) !important;
            line-height: var(--wp--custom--line-height--equal) !important;
			font-weight: 400 !important;
        }
		
		&:is(:hover, :focus, :active) {
			color: var(--wp--custom--color--default--accent--light) !important;
            background-color: var(--wp--custom--color--default--accent--dark) !important;
		}
		
		&:active {
			scale: 0.975;
		}
	}
}

/******************************/
/* Forms/inputs
/******************************/
body:not(.wp-admin, .login) .gform_wrapper {
	container-type: inline-size;
	container-name: form-wrapper;
	
	.gform_fields {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		column-gap: var(--wp--preset--spacing--2);
		row-gap: var(--wp--preset--spacing--1-5);
		
		/* Typo */
		:is(input, select, textarea):not([type="submit"], [type="button"], [class*="adminbar"]),
		.gfield_label {
            font-family: var(--wp--preset--font-family--inter);
            font-size: var(--wp--preset--font-size--medium);
            line-height: var(--wp--custom--line-height--equal);
            font-weight: 400;
		}
		
		/* Fields */
		.gfield {
			grid-column: span 2;
			
			&.gfield--width-half {
				grid-column: span 1;
			}
			
			:is(input, select, textarea):not([type="submit"], [type="button"], [type="file"], [class*="adminbar"], [class*="ui-datepicker"]) {
				width: 100% !important;
				height: auto !important;
				color: var(--wp--custom--color--default--accent--dark);
				background-color: #EDEFF6;
				padding: var(--wp--preset--spacing--1) var(--wp--preset--spacing--1-5);
				border: unset;
				border-radius: var(--wp--custom--border-radius--small);
				box-sizing: border-box;
				box-shadow: unset !important;
				outline: unset !important;
				resize: none;

                &::placeholder {
                    font-family: inherit;
                    font-size: inherit;
                    line-height: inherit;
                    font-weight: inherit;
                    color: var(--wp--custom--color--default--text--alt);
                }
			}
		}
	}
	
	/* Form footer */
	.gform_footer {
        justify-self: center;
		position: relative;
		width: max-content;
		margin-block-start: var(--wp--preset--spacing--3-5) !important;
		margin-inline: unset !important;
		overflow: clip;
		
		[type="submit"] {
			font-family: inherit !important;
			font-size: inherit !important;
			line-height: inherit !important;
			font-weight: inherit !important;
			color: inherit !important;
			border: unset !important;
			border-radius: unset !important;
			outline: unset !important;
		}
	}
	
	/* Form error/confirmation messages & Loading icon */
	.gform_validation_errors {
		display: none;
	}
    
    &.gform_confirmation_message {
        &, & > * {
            font-size: var(--wp--preset--font-size--large);
            color: var(--wp--custom--color--default--text--alt);
            margin-block: unset;
        }
    }
	
	.gform-loader {
		display: none;
	}
	
	form:has(.gform-loader) {
		position: relative;
		
		:is(.gfield, .gform_footer) {
			opacity: .5 !important;
			pointer-events: none !important;
		}
		
		&::after {
			content: '';
			position: absolute;
			top: 50%;
			left: 50%;
			width: 100px;
			height: auto;
			aspect-ratio: 1;
			background: url(../images/loading.svg) no-repeat center;
			background-size: contain;
			translate: -50% -50%;
            filter: var(--wp--custom--color--danube-blue--filter);
		}
	}
	
	/* Responsive */
	@container form-wrapper (width <= 800px) {
		.gfield {
			grid-column: span 2 !important;
		}
	}
	
	@media (width <= 1200px) {
		.gform_fields {
			column-gap: var(--wp--preset--spacing--1);
			row-gap: var(--wp--preset--spacing--1);
		}
	}
}