/**
 * Hero Block - Frontend Styles
 */

.hero-block {
    position: relative;
    min-height: 600px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: stretch;
    overflow: hidden;
    width: 100%;
    background-color: var(--scheme-2-bg);
}

/* Custom padding applied only on desktop (mobile uses theme defaults below). */
.hero-block.hero-block--desktop-padding-only {
    padding-top: var(--hero-pad-top);
    padding-bottom: var(--hero-pad-bot);
}

/* YouTube (or embed) background — below overlay, cover behavior */
.hero-block .hero-background-video,
.hero-block-editor .hero-background-video {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.hero-block .hero-background-video__iframe,
.hero-block-editor .hero-background-video__iframe {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100vw;
    height: 56.25vw;
    min-width: 177.77vh;
    min-height: 100%;
    transform: translate(-50%, -50%);
    border: 0;
    pointer-events: none;
}

/* Self-hosted MP4 (or other video) — cover fill */
.hero-block .hero-background-video__media,
.hero-block-editor .hero-background-video__media {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    background-color: var(--scheme-bg, #000000);
}

/* Gradient overlay: scheme tint fades to transparent (uses --hero-overlay-angle / --hero-overlay-mix-pct on .hero-block) */
.hero-block[data-color-scheme] .hero-overlay.hero-overlay--gradient,
.hero-block-editor[data-color-scheme] .hero-overlay.hero-overlay--gradient {
    opacity: 1;
    background: linear-gradient(
        var(--hero-overlay-angle, 180deg),
        color-mix(in srgb, var(--scheme-bg) var(--hero-overlay-mix-pct, 50%), transparent) 0%,
        transparent 100%
    );
}

/* Container inside hero — same max-width as header / other sections. */
.hero-block > .container {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    min-height: inherit;
    width: 100%;
    max-width: var(--mestari-container-width, 1200px);
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
    box-sizing: border-box;
}

.hero-content {
    color: var(--scheme-1-bg);
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* Content Positions - Bottom Left */
.hero-content-bottom-left {
    align-items: flex-start;
    text-align: left;
}

.hero-block > .container:has(.hero-content-bottom-left) {
    justify-content: flex-end;
    align-items: flex-start;
}

/* Content Positions - Left (vertically centered) */
.hero-content-left {
    align-items: flex-start;
    text-align: left;
}

.hero-block > .container:has(.hero-content-left) {
    justify-content: center;
    align-items: flex-start;
}

/* Content Positions - Center */
.hero-content-center {
    /* Horizontal alignment of inner blocks is intentionally not forced here.
       Each block controls its own alignment via WP's native text-align / block alignment tools. */
}

.hero-block > .container:has(.hero-content-center) {
    justify-content: center;
    align-items: center;
}

/* Content Positions - Bottom Center */
.hero-content-bottom-center {
    align-items: center;
    text-align: center;
}

.hero-block > .container:has(.hero-content-bottom-center) {
    justify-content: flex-end;
    align-items: center;
}

/* Typography */
.hero-main-heading {
    font-size: var(--fontsize-h1, 42px);
    margin: 0 0 36px;
    font-weight: var(--fontweight-h1, 700);
    line-height: var(--lineheight-h1, 1.2);
    max-width: 900px;
    color: var(--scheme-1-bg);
}

.hero-block .hero-content h1,
.hero-block .hero-content .wp-block-heading:where(h1) {
    font-size: var(--fontsize-h1, 42px) !important;
    font-weight: var(--fontweight-h1, 700);
    line-height: var(--lineheight-h1, 1.2);
    letter-spacing: var(--letterspacing-h1, 0);
}

.hero-block .hero-content h2,
.hero-block .hero-content .wp-block-heading:where(h2) {
    font-size: var(--fontsize-h2, 32px) !important;
    font-weight: var(--fontweight-h2, 700);
    line-height: var(--lineheight-h2, 1.3);
    letter-spacing: var(--letterspacing-h2, 0);
}

.hero-block .hero-content h3,
.hero-block .hero-content .wp-block-heading:where(h3) {
    font-size: var(--fontsize-h3, 26px) !important;
    font-weight: var(--fontweight-h3, 600);
    line-height: var(--lineheight-h3, 1.3);
    letter-spacing: var(--letterspacing-h3, 0);
}

.hero-block .hero-content h4,
.hero-block .hero-content .wp-block-heading:where(h4) {
    font-size: var(--fontsize-h4, 22px) !important;
    font-weight: var(--fontweight-h4, 600);
    line-height: var(--lineheight-h4, 1.4);
    letter-spacing: var(--letterspacing-h4, 0);
}

.hero-block .hero-content h5,
.hero-block .hero-content .wp-block-heading:where(h5) {
    font-size: var(--fontsize-h5, 18px) !important;
    font-weight: var(--fontweight-h5, 600);
    line-height: var(--lineheight-h5, 1.4);
    letter-spacing: var(--letterspacing-h5, 0);
}

.hero-block .hero-content h6,
.hero-block .hero-content .wp-block-heading:where(h6) {
    font-size: var(--fontsize-h6, 16px) !important;
    font-weight: var(--fontweight-h6, 600);
    line-height: var(--lineheight-h6, 1.4);
    letter-spacing: var(--letterspacing-h6, 0);
}

.hero-smaller-heading {
    font-size: var(--fontsize-p, 16px);
    margin: 0 0 10px;
    font-weight: 400;
    opacity: 0.85;
    max-width: 800px;
    line-height: var(--lineheight-p, 1.6);
}

/* Optional rich inner content in Hero (paragraph/list/quote/quick-links). */
.hero-content-body {
    max-width: 800px;
    width: 100%;
    margin: 0 0 30px;
}

.hero-content-body p,
.hero-content-body ul,
.hero-content-body ol,
.hero-content-body blockquote {
    margin-top: 0;
    margin-bottom: 1em;
}

.hero-content-body > :last-child {
    margin-bottom: 0;
}

/* Buttons Container */
.hero-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: inherit;
}

/*
 * Button group alignment by Hero style (tyyli):
 * left for all styles except Text + Image (centered).
 */
.hero-block:not(.hero-block--text-image) .wp-block-buttons,
.hero-block:not(.hero-block--text-image) .wp-block-buttons.is-layout-flex,
.hero-block-editor:not(.hero-block--text-image) .wp-block-buttons,
.hero-block-editor:not(.hero-block--text-image) .wp-block-buttons.is-layout-flex {
    justify-content: flex-start !important;
}

.hero-block--text-image .wp-block-buttons,
.hero-block--text-image .wp-block-buttons.is-layout-flex,
.hero-block-editor.hero-block--text-image .wp-block-buttons,
.hero-block-editor.hero-block--text-image .wp-block-buttons.is-layout-flex {
    justify-content: center !important;
}


/* Dynamic color scheme — overrides hardcoded defaults */
.hero-block[data-color-scheme] {
    background-color: var(--scheme-bg) !important;
}

.hero-block[data-color-scheme] .hero-overlay {
    background-color: var(--scheme-bg);
}

.hero-block[data-color-scheme] .hero-content {
    color: var(--scheme-text);
}

.hero-block[data-color-scheme] .hero-main-heading,
.hero-block[data-color-scheme] .hero-content .wp-block-heading:not(.has-text-color) {
    color: var(--scheme-heading);
}

.hero-block[data-color-scheme] .hero-smaller-heading:not(.has-text-color),
.hero-block[data-color-scheme] .hero-content .section-subtitle-block:not(.has-text-color),
.hero-block[data-color-scheme] .hero-content p:not(.has-text-color) {
    color: var(--scheme-text) !important;
}

/* Custom color scheme (no data-color-scheme): text + buttons from CSS variables on .hero-block */
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .hero-content,
.hero-block-editor.hero-block--custom-colors:not([data-color-scheme]) .hero-content,
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .hero-content .wp-block-heading:not(.has-text-color),
.hero-block-editor.hero-block--custom-colors:not([data-color-scheme]) .hero-content .wp-block-heading:not(.has-text-color),
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .hero-content h1:not(.has-text-color),
.hero-block-editor.hero-block--custom-colors:not([data-color-scheme]) .hero-content h1:not(.has-text-color),
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .hero-content h2:not(.has-text-color),
.hero-block-editor.hero-block--custom-colors:not([data-color-scheme]) .hero-content h2:not(.has-text-color),
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .hero-content h3:not(.has-text-color),
.hero-block-editor.hero-block--custom-colors:not([data-color-scheme]) .hero-content h3:not(.has-text-color),
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .hero-content h4:not(.has-text-color),
.hero-block-editor.hero-block--custom-colors:not([data-color-scheme]) .hero-content h4:not(.has-text-color),
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .hero-content p:not(.has-text-color),
.hero-block-editor.hero-block--custom-colors:not([data-color-scheme]) .hero-content p:not(.has-text-color),
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .hero-content li,
.hero-block-editor.hero-block--custom-colors:not([data-color-scheme]) .hero-content li,
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .hero-content blockquote,
.hero-block-editor.hero-block--custom-colors:not([data-color-scheme]) .hero-content blockquote,
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .hero-content figcaption,
.hero-block-editor.hero-block--custom-colors:not([data-color-scheme]) .hero-content figcaption {
    color: var(--hero-custom-text) !important;
}

.hero-block.hero-block--custom-colors:not([data-color-scheme]) .hero-content a,
.hero-block-editor.hero-block--custom-colors:not([data-color-scheme]) .hero-content a {
    color: var(--hero-custom-text) !important;
}

.hero-block.hero-block--custom-colors:not([data-color-scheme]) .hero-content .wp-block-button:not(.is-style-outline) .wp-block-button__link,
.hero-block-editor.hero-block--custom-colors:not([data-color-scheme]) .hero-content .wp-block-button:not(.is-style-outline) .wp-block-button__link {
    background-color: var(--hero-custom-btn-bg) !important;
    color: var(--hero-custom-btn-text) !important;
    border-color: var(--hero-custom-btn-bg) !important;
}

.hero-block.hero-block--custom-colors:not([data-color-scheme]) .hero-content .wp-block-button.is-style-outline .wp-block-button__link,
.hero-block-editor.hero-block--custom-colors:not([data-color-scheme]) .hero-content .wp-block-button.is-style-outline .wp-block-button__link {
    background-color: transparent !important;
    color: var(--hero-custom-text) !important;
    border-color: var(--hero-custom-text) !important;
}

.hero-block.hero-block--custom-colors:not([data-color-scheme]) .hero-content .wp-block-button:not(.is-style-outline) .wp-block-button__link:hover,
.hero-block-editor.hero-block--custom-colors:not([data-color-scheme]) .hero-content .wp-block-button:not(.is-style-outline) .wp-block-button__link:hover {
    opacity: 0.9;
}

/* Gravity Forms in custom-color hero */
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .gform_wrapper .gfield_label,
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .gform_wrapper .gfield .gfield_label,
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .gform_wrapper .gfield > legend,
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .gform_wrapper .gform-field-label--type-sub,
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .gform_wrapper .gfield_required,
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .gform_wrapper .gfield_description,
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .gform_wrapper .gform_heading .gform_title,
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .gform_wrapper .gform_heading .gform_description,
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .gform_wrapper .gfield_checkbox label,
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .gform_wrapper .gfield_radio label,
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .gform_wrapper .charleft,
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .gform_wrapper .ginput_counter,
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .gform_confirmation_message {
    color: var(--hero-custom-text) !important;
}

.hero-block.hero-block--custom-colors:not([data-color-scheme]) .gform_wrapper .gform_footer input[type="submit"],
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .gform_wrapper .gform_footer button,
.hero-block.hero-block--custom-colors:not([data-color-scheme]) .gform_wrapper .gform_button {
    background: var(--hero-custom-btn-bg) !important;
    color: var(--hero-custom-btn-text) !important;
    border-color: var(--hero-custom-btn-bg) !important;
}

/* InnerBlocks spacing inside hero */
.hero-block h1,
.hero-block .wp-block-heading:where(h1) {
    margin-top: 25px;
    margin-bottom: 36px;
}

.hero-block .wp-block-buttons.is-layout-flex {
    margin-top: 25px;
    margin-bottom: 25px;
}

/* Slightly more space after body copy than after the heading (paragraph → buttons) */
.hero-block .wp-block-paragraph + .wp-block-buttons,
.hero-block-editor .wp-block-paragraph + .wp-block-buttons {
    margin-top: 34px;
}

/* Full width narrow: content uses 8/12 columns inside the normal container. */
.hero-content-narrow {
    max-width: 66.666667%;
}

.hero-content-narrow.hero-content-narrow--justify-center {
    margin-left: auto;
    margin-right: auto;
}

.hero-content-narrow.hero-content-narrow--justify-right {
    margin-left: auto;
}

/*
 * Full-width narrow: same title/text/button spacing as 2 Columns.
 * WP flow layout adds margin-block-start between siblings (block gap) on top of
 * our hero margins — that double-spacing is why this style looked looser.
 * Kill the flow gap; keep shared .hero-block h1 / buttons / p+buttons margins.
 */
.hero-block.hero-block--full-width-narrow .hero-content-narrow.is-layout-flow > * + *,
.hero-block.hero-block--full-width-narrow .hero-content-narrow > * + *,
.hero-block.hero-block--full-width-narrow .hero-content.is-layout-flow > * + * {
    margin-block-start: 0 !important;
}

.hero-block.hero-block--full-width-narrow .hero-content-narrow,
.hero-block.hero-block--full-width-narrow .hero-content-narrow.is-layout-flow {
    gap: 0 !important;
    row-gap: 0 !important;
}

@media screen and (min-width: 769px) {
    .hero-block.hero-block--full-width-narrow .wp-block-buttons,
    .hero-block.hero-block--full-width-narrow .wp-block-buttons.is-layout-flex {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: flex-start !important;
        width: auto !important;
    }

    .hero-block.hero-block--full-width-narrow .wp-block-button,
    .hero-block.hero-block--full-width-narrow .wp-block-button .wp-block-button__link {
        width: auto !important;
    }
}

/*
 * Editor: force a definite narrow width + stretch so content doesn't shrink-wrap
 * and look centered (align-items:center on the hero container).
 */
.hero-block-editor.hero-block--full-width-narrow .hero-content-narrow {
    box-sizing: border-box;
    width: min(100%, calc(var(--mestari-container-width, 1200px) * 2 / 3)) !important;
    max-width: min(100%, calc(var(--mestari-container-width, 1200px) * 2 / 3)) !important;
    min-width: 0;
    align-items: stretch !important;
    text-align: left;
}

.hero-block-editor.hero-block--full-width-narrow .hero-content-narrow > .block-editor-inner-blocks,
.hero-block-editor.hero-block--full-width-narrow .hero-content-narrow .block-editor-block-list__layout {
    display: flex !important;
    flex-direction: column;
    align-items: stretch !important;
    justify-content: flex-start !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    /* No custom gap — use shared hero margin rhythm (same as 2 Columns). */
    gap: 0 !important;
    row-gap: 0 !important;
}

.hero-block-editor.hero-block--full-width-narrow .hero-content-narrow .block-editor-block-list__layout > * + *,
.hero-block-editor.hero-block--full-width-narrow .hero-content-narrow .block-editor-block-list__layout > .wp-block + .wp-block {
    margin-block-start: 0 !important;
}

.hero-block-editor.hero-block--full-width-narrow .hero-content-narrow .block-editor-block-list__layout > .wp-block {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    align-self: stretch !important;
    box-sizing: border-box;
}

/* Buttons keep content-sized width — don't stretch like text blocks. */
.hero-block-editor.hero-block--full-width-narrow .hero-content-narrow .block-editor-block-list__layout > .wp-block:has(.wp-block-buttons),
.hero-block-editor.hero-block--full-width-narrow .hero-content-narrow .block-editor-block-list__layout > .wp-block.wp-block-buttons {
    width: auto !important;
    max-width: 100% !important;
    align-self: flex-start !important;
}

.hero-block-editor.hero-block--full-width-narrow .wp-block-buttons,
.hero-block-editor.hero-block--full-width-narrow .wp-block-buttons.is-layout-flex {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
    align-items: center !important;
    width: auto !important;
    gap: 0.5rem;
}

.hero-block-editor.hero-block--full-width-narrow .wp-block-button {
    width: auto !important;
    max-width: none !important;
}

/* Beat theme mobile `width:100%` on button links when the editor canvas is narrow. */
.hero-block-editor.hero-block--full-width-narrow .wp-block-button .wp-block-button__link,
.hero-block-editor.hero-block--full-width-narrow .wp-block-button .wp-element-button {
    width: auto !important;
    display: inline-block !important;
}

@media screen and (max-width: 1024px) {
    .hero-content-narrow {
        max-width: 100%;
    }

    /* Remove horizontal block padding from headings and paragraphs inside hero at tablet */
    .hero-block .wp-block-heading,
    .hero-block .wp-block-paragraph {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

/* 2 Columns Layout */
.hero-content-2col {
    text-align: left;
    width: 100%;
}

.hero-block > .container:has(.hero-content-2col) {
    justify-content: center;
    align-items: center;
}

.hero-block--2-columns .wp-block-columns {
    gap: var(--hero-columns-gap, 120px) !important;
    align-items: center;
    margin-bottom: 0;
}

.hero-block--2-columns .wp-block-column > *:last-child {
    margin-bottom: 0;
}

/* Framed-image CSS is often delayed; keep the LCP image shrinkable so
   50% + 50% + gap cannot overflow and get clipped by overflow:hidden. */
.hero-block .jk-framed-image,
.hero-block .mestari-framed-image,
.hero-block .wp-block-jerryketola-kuva-kehyksilla,
.hero-block .wp-block-mestariteema-framed-image {
    max-width: 100%;
    min-width: 0;
}

.hero-block .jk-framed-image__img,
.hero-block .mestari-framed-image__img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
}

/*
 * Keep 2-column hero side-by-side until 768px — same breakpoint as
 * Content Block image+text. Overrides WP core column stacking at 781px.
 * Use flex-basis:0 + min-width:0 so column-gap doesn't force a wrap
 * (50% + 50% + gap > 100% wraps and turns the large gap vertical).
 */
@media screen and (min-width: 769px) {
    .hero-block.hero-block--2-columns {
        min-height: 0 !important;
        overflow-x: hidden;
        overflow-y: visible;
    }

    .hero-block.hero-block--2-columns > .container,
    .hero-block.hero-block--2-columns > .container:has(.hero-content-2col) {
        min-height: 0 !important;
        justify-content: flex-start !important;
        align-items: stretch !important;
        max-width: var(--mestari-container-width, 1200px);
        margin-left: auto;
        margin-right: auto;
    }

    .hero-block--2-columns .wp-block-columns,
    .hero-block--2-columns .wp-block-columns.is-not-stacked-on-mobile {
        flex-wrap: nowrap !important;
        flex-direction: row !important;
        align-items: center;
        width: 100%;
        max-width: 100%;
        gap: clamp(24px, 3vw, 48px) !important;
        column-gap: clamp(24px, 3vw, 48px) !important;
    }

    .hero-block--2-columns .wp-block-columns > .wp-block-column,
    .hero-block--2-columns .wp-block-columns.is-not-stacked-on-mobile > .wp-block-column,
    .hero-block--2-columns .wp-block-columns.is-not-stacked-on-mobile > .wp-block-column[style*="flex-basis"] {
        flex: 1 1 0 !important;
        flex-grow: 1 !important;
        flex-shrink: 1 !important;
        flex-basis: 0 !important;
        min-width: 0 !important;
        max-width: calc(50% - 24px) !important;
        width: auto !important;
    }
}

/*
 * Tablet (769–1024): beat inline min-height/padding (e.g. 60vh + padding-top:0).
 * Keep 2-column heroes side-by-side; child themes may stack only below 768px.
 */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .hero-block,
    .hero-block.hero-block--2-columns {
        min-height: 0 !important;
    }

    .hero-block.padding-default,
    .hero-block.hero-block--desktop-padding-only {
        padding-top: var(--padding-default-top, 60px);
        padding-bottom: var(--padding-default-bottom, 60px);
    }

    .hero-block > .container,
    .hero-block > .container:has(.hero-content-2col),
    .hero-block > .container:has(.hero-content-center),
    .hero-block > .container:has(.hero-content-left) {
        justify-content: flex-start !important;
        align-items: stretch !important;
        min-height: 0 !important;
    }

    .hero-block--2-columns .wp-block-columns {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 32px !important;
        row-gap: 32px !important;
        column-gap: 32px !important;
    }

    .hero-block--2-columns .wp-block-columns > .wp-block-column {
        flex: 1 1 0 !important;
        flex-basis: 0 !important;
        min-width: 0 !important;
        max-width: none !important;
        width: auto !important;
    }

    /* Honor column vertical alignment from block settings. */
    .hero-block--2-columns .wp-block-columns > .wp-block-column.is-vertically-aligned-center {
        justify-content: center !important;
        align-self: center !important;
    }

    .hero-block--2-columns .wp-block-columns > .wp-block-column.is-vertically-aligned-top {
        justify-content: flex-start !important;
        align-self: flex-start !important;
    }

    .hero-block--2-columns .wp-block-columns > .wp-block-column.is-vertically-aligned-bottom {
        justify-content: flex-end !important;
        align-self: flex-end !important;
    }

    /* Tighter copy rhythm for all hero styles (matches 2 Columns). */
    .hero-block .hero-main-heading,
    .hero-block .hero-content h1,
    .hero-block .wp-block-heading:where(h1) {
        margin-top: 0 !important;
        margin-bottom: 0.5em !important;
    }

    .hero-block .wp-block-paragraph {
        margin-top: 0 !important;
        margin-bottom: 0.75em !important;
    }

    .hero-block .wp-block-paragraph:last-of-type {
        margin-bottom: 0 !important;
    }

    /* Bottom margin keeps a gap before whatever follows the buttons (e.g. a rating bar), as on mobile */
    .hero-block .wp-block-buttons.is-layout-flex,
    .hero-block .wp-block-paragraph + .wp-block-buttons {
        margin-top: 1em !important;
        margin-bottom: 1em !important;
    }

    .hero-block .wp-block-buttons.is-layout-flex:last-child {
        margin-bottom: 0 !important;
    }

    body.header-overlay-active .hero-block {
        padding-top: calc(var(--mestari-header-height, 64px) + var(--padding-default-top, 60px)) !important;
    }
}

/* Right column image — contain before delayed CSS / WP Rocket. */
.hero-block .wp-block-image,
.hero-block--2-columns .wp-block-column .wp-block-image {
    margin-bottom: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.hero-block .wp-block-image img,
.hero-block--2-columns .wp-block-column .wp-block-image img {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    contain-intrinsic-size: none;
}

/* Text + Image (stacked) Layout */
.hero-content-text-image {
    text-align: center;
    width: 100%;
}

.hero-block > .container:has(.hero-content-text-image) {
    justify-content: center;
    align-items: center;
}

.hero-block--text-image .hero-content-text-image > .wp-block-group:first-child {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.hero-block--text-image .hero-content-text-image > .wp-block-image,
.hero-block--text-image .hero-content-text-image > .wp-block-group:last-child .wp-block-image {
    margin-top: 40px;
}

.hero-block--text-image .hero-content-text-image > .wp-block-image img,
.hero-block--text-image .hero-content-text-image .wp-block-image img {
    max-width: 100%;
    height: auto;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

@media screen and (max-width: 768px) {
    .hero-block--text-image .hero-content-text-image > .wp-block-image,
    .hero-block--text-image .hero-content-text-image > .wp-block-group:last-child .wp-block-image {
        margin-top: 24px;
    }
}

/* ===== Gravity Forms inside Hero ===== */

.hero-block .gform_wrapper {
    width: 100%;
}

/* Reset GF theme spacing — tighten everything inside the hero */
.hero-block .gform_wrapper .gform-body,
.hero-block .gform_wrapper .gform_body {
    margin: 0;
    padding: 0;
}

.hero-block .gform_wrapper .gform_fields {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 0;
    margin: 0;
}

/* Individual field (fieldset / div) — kill GF default margins */
.hero-block .gform_wrapper .gfield {
    margin: 0 !important;
    padding: 0 !important;
}

/* Legend / label — the bold field name ("Nimi", "Sähköposti", etc.) */
.hero-block .gform_wrapper .gfield_label,
.hero-block .gform_wrapper .gfield .gfield_label,
.hero-block .gform_wrapper .gfield > legend {
    color: var(--scheme-1-bg);
    font-weight: 600;
    font-size: 0.9em;
    margin: 0 0 4px;
    padding: 0;
}

/* Sub-labels ("Etunimi", "Sukunimi", "Syötä sähköpostiosoite") */
.hero-block .gform_wrapper .gform-field-label--type-sub {
    color: var(--scheme-1-bg);
    opacity: 0.75;
    font-size: 0.8em;
    font-weight: 400;
    margin: 0 0 2px;
}

/* Grid row (name halves, email halves) */
.hero-block .gform_wrapper .gform-grid-row {
    display: flex;
    gap: 12px;
    margin: 0;
}

.hero-block .gform_wrapper .gform-grid-col {
    flex: 1;
    min-width: 0;
}

/* Required indicator — same color as label so it's readable on dark bg */
.hero-block .gform_wrapper .gfield_required {
    color: var(--scheme-1-bg);
    opacity: 0.75;
}

/* Description above/below field */
.hero-block .gform_wrapper .gfield_description {
    color: var(--scheme-1-bg);
    opacity: 0.7;
    font-size: 0.85em;
    margin: 0;
    padding: 0;
}

/* Kill extra gap between label and input when description is above */
.hero-block .gform_wrapper .gfield--has-description.field_description_above .ginput_container {
    margin-top: 0;
}

/* Text inputs, textareas, selects */
/* Override GF theme CSS variables for inputs inside hero */
.hero-block .gform_wrapper {
    --gf-ctrl-radius: 10px !important;
    --gf-ctrl-textarea-radius: 10px !important;
    --gf-ctrl-border-width: 0px !important;
    --gf-ctrl-border-color: transparent !important;
    --gf-ctrl-bg-color: #ffffff !important;
    --gf-ctrl-color: #011D28 !important;
    --gf-ctrl-padding-x: 15px !important;
    --gf-ctrl-padding-y: 15px !important;
}

.hero-block .gform_wrapper input[type="text"],
.hero-block .gform_wrapper input[type="email"],
.hero-block .gform_wrapper input[type="tel"],
.hero-block .gform_wrapper input[type="url"],
.hero-block .gform_wrapper input[type="number"],
.hero-block .gform_wrapper input[type="password"],
.hero-block .gform_wrapper textarea,
.hero-block .gform_wrapper select {
    background: #ffffff !important;
    color: #011D28 !important;
    border: none !important;
    border-radius: 10px !important;
    padding: 15px !important;
    font-size: 0.95em;
    width: 100%;
    box-sizing: border-box;
}

.hero-block .gform_wrapper input[type="text"]:focus,
.hero-block .gform_wrapper input[type="email"]:focus,
.hero-block .gform_wrapper input[type="tel"]:focus,
.hero-block .gform_wrapper input[type="url"]:focus,
.hero-block .gform_wrapper input[type="number"]:focus,
.hero-block .gform_wrapper input[type="password"]:focus,
.hero-block .gform_wrapper textarea:focus,
.hero-block .gform_wrapper select:focus {
    outline: none !important;
    border: none !important;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25) !important;
}

/* Placeholder text */
.hero-block .gform_wrapper input::placeholder,
.hero-block .gform_wrapper textarea::placeholder {
    color: #999;
    opacity: 0.7;
}

/* Textarea */
.hero-block .gform_wrapper textarea {
    min-height: 120px;
    resize: vertical;
}

/* ginput_container — remove extra margin around input wrappers */
.hero-block .gform_wrapper .ginput_container {
    margin: 0;
}

/* Checkboxes and radio labels */
.hero-block .gform_wrapper .gfield_checkbox label,
.hero-block .gform_wrapper .gfield_radio label {
    color: var(--scheme-1-bg);
}

/* Character counter / ginput_counter */
.hero-block .gform_wrapper .charleft,
.hero-block .gform_wrapper .ginput_counter {
    color: var(--scheme-1-bg);
    opacity: 0.6;
    font-size: 0.8em;
    margin-top: 4px;
}

/* Form title & description (if form has a title) */
.hero-block .gform_wrapper .gform_heading {
    margin: 0 0 16px;
    padding: 0;
}

.hero-block .gform_wrapper .gform_heading .gform_title {
    color: var(--scheme-1-bg);
    font-size: var(--fontsize-h3, 24px);
    font-weight: var(--fontweight-h3, 700);
    line-height: var(--lineheight-h3, 1.3);
    margin: 0 0 6px;
}

.hero-block .gform_wrapper .gform_heading .gform_description {
    color: var(--scheme-1-bg);
    opacity: 0.85;
    margin: 0;
}

/* Footer / submit */
.hero-block .gform_wrapper .gform-footer,
.hero-block .gform_wrapper .gform_footer {
    margin: 20px 0 0;
    padding: 0;
}

.hero-block .gform_wrapper .gform_footer input[type="submit"],
.hero-block .gform_wrapper .gform_footer button,
.hero-block .gform_wrapper .gform_page_footer input[type="submit"],
.hero-block .gform_wrapper .gform_button {
    background: var(--btn-primary-bg, var(--scheme-1-accent));
    color: var(--btn-primary-text, var(--scheme-1-bg));
    border: 2px solid var(--btn-primary-border, var(--scheme-1-accent));
    padding: 12px 30px;
    font-weight: 600;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    border-radius: 0;
    transition: opacity 0.2s ease;
}

.hero-block .gform_wrapper .gform_footer input[type="submit"]:hover,
.hero-block .gform_wrapper .gform_footer button:hover,
.hero-block .gform_wrapper .gform_button:hover {
    opacity: 0.9;
}

/* Validation messages */
.hero-block .gform_wrapper .gfield_error .gfield_label {
    color: #ff6b6b;
}

.hero-block .gform_wrapper .validation_message,
.hero-block .gform_wrapper .gfield_error .validation_message {
    color: #ff6b6b;
    font-size: 0.85em;
}

.hero-block .gform_wrapper .gform_validation_errors,
.hero-block .gform_wrapper .validation_error {
    border-color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
    color: var(--scheme-1-bg);
}

/* Confirmation message */
.hero-block .gform_confirmation_message {
    color: var(--scheme-1-bg);
    font-size: 1.1em;
}

/* Color scheme overrides */
.hero-block[data-color-scheme] .gform_wrapper .gform_heading .gform_title {
    color: var(--scheme-heading) !important;
}

.hero-block[data-color-scheme] .gform_wrapper .gform_heading .gform_description,
.hero-block[data-color-scheme] .gform_wrapper .gfield_label,
.hero-block[data-color-scheme] .gform_wrapper .gfield .gfield_label,
.hero-block[data-color-scheme] .gform_wrapper .gfield > legend,
.hero-block[data-color-scheme] .gform_wrapper .gfield_checkbox label,
.hero-block[data-color-scheme] .gform_wrapper .gfield_radio label {
    color: var(--scheme-text) !important;
}

.hero-block[data-color-scheme] .gform_wrapper .gfield_required {
    color: var(--scheme-text) !important;
    opacity: 0.75;
}

.hero-block[data-color-scheme] .gform_wrapper .gform-field-label--type-sub {
    color: var(--scheme-text) !important;
    opacity: 0.75;
}

.hero-block[data-color-scheme] .gform_wrapper .gfield_description {
    color: var(--scheme-text) !important;
    opacity: 0.7;
}

.hero-block[data-color-scheme] .gform_wrapper .charleft,
.hero-block[data-color-scheme] .gform_wrapper .ginput_counter {
    color: var(--scheme-text) !important;
    opacity: 0.6;
}

.hero-block[data-color-scheme] .gform_confirmation_message {
    color: var(--scheme-text) !important;
}

/* Responsive */
@media screen and (max-width: 768px) {
    /*
     * Mobile: keep hero content near the top.
     * Desktop min-height + justify-content:center otherwise creates a large
     * empty band under the header.
     */
    .hero-block {
        min-height: 0 !important;
    }

    .hero-block.padding-default,
    .hero-block.hero-block--desktop-padding-only {
        padding-top: var(--padding-default-top, 20px);
        padding-bottom: var(--padding-default-bottom, 20px);
    }

    .hero-block > .container {
        min-height: 0;
        justify-content: flex-start !important;
        align-items: stretch !important;
        padding-top: 0;
        padding-bottom: 0;
    }

    /* Overlay header: only clear the sticky header, no extra theme padding. */
    body.header-overlay-active .hero-block {
        padding-top: calc(var(--mestari-header-height, 64px) + 12px) !important;
    }

    body.header-overlay-active .hero-block > .container {
        padding-top: 0;
    }

    .hero-smaller-heading {
        margin-top: 0;
        margin-bottom: 8px;
    }

    .hero-main-heading,
    .hero-block h1,
    .hero-block .hero-content h1,
    .hero-block .wp-block-heading:where(h1) {
        margin-top: 0 !important;
        margin-bottom: 12px !important;
    }

    /* Match button spacing to paragraph rhythm (desktop uses larger gaps). */
    .hero-block .wp-block-buttons.is-layout-flex,
    .hero-block .wp-block-paragraph + .wp-block-buttons,
    .hero-block-editor .wp-block-paragraph + .wp-block-buttons {
        margin-top: 1em !important;
        margin-bottom: 1em !important;
    }

    .hero-block .wp-block-paragraph:last-of-type {
        margin-bottom: 0;
    }

    .hero-cta-button {
        padding: var(--btn-padding-mobile, 12px 20px);
        font-size: var(--btn-font-size, 15px);
        white-space: normal;
        word-wrap: break-word;
        min-width: 0;
        width: 100%;
        text-align: center;
        display: block;
    }

    .hero-buttons {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        max-width: 100%;
        gap: 12px;
        padding: 0;
    }
    
    .hero-content {
        padding: 0;
        width: 100%;
        box-sizing: border-box;
    }

    /* Mobile content positioning */
    .hero-content-bottom-left,
    .hero-content-left {
        align-items: flex-start;
        text-align: left;
    }

    .hero-content-bottom-center {
        align-items: center;
        text-align: center;
    }

    .hero-content-bottom-center .hero-buttons {
        align-items: center;
    }

    .hero-content-left .hero-buttons,
    .hero-content-bottom-left .hero-buttons {
        align-items: flex-start;
    }

    /* Remove paragraph padding on mobile */
    .hero-block .wp-block-paragraph {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Stack 2-columns hero on mobile.
       IMPORTANT: use nowrap — column + wrap + flex-basis:100% wraps the
       second column beside the first (off-screen), and overflow:hidden clips it. */
    .hero-block--2-columns .wp-block-columns {
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        gap: 30px !important;
    }

    .hero-block--2-columns .wp-block-columns > .wp-block-column {
        flex: 0 0 auto !important;
        flex-basis: auto !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}

@media screen and (max-width: 480px) {
    .hero-cta-button {
        padding: var(--btn-padding-mobile, 12px 20px);
        width: 100%;
        text-align: center;
        font-size: var(--btn-font-size, 15px);
    }
    
    .hero-content {
        padding: 0;
    }
    
    .hero-buttons {
        padding: 0;
    }
}
