/*
 * HydroPower — blocchi core Gutenberg e blocchi dinamici ACF.
 * Caricato sia nel frontend sia nell'editor.
 */

.wordpress-blocks-content,
.entry-content,
.editor-styles-wrapper {
    color: var(--hp-navy);
    font-family: var(--hp-font-body);
    font-size: 1rem;
    line-height: 1.75;
}

.wordpress-blocks-content {
    overflow: clip;
}

.wordpress-blocks-content > *:first-child,
.entry-content > *:first-child {
    margin-top: 0;
}

.wordpress-blocks-content > *:last-child,
.entry-content > *:last-child {
    margin-bottom: 0;
}

/* Larghezze editoriali: i blocchi ACF mantengono invece la piena larghezza. */
.wordpress-blocks-content > :where(p, h1, h2, h3, h4, h5, h6, ul, ol, blockquote, figure, table, pre, .wp-block-buttons, .wp-block-columns, .wp-block-group:not(.alignfull), .wp-block-gallery, .wp-block-embed),
.entry-content > :where(p, h1, h2, h3, h4, h5, h6, ul, ol, blockquote, figure, table, pre, .wp-block-buttons, .wp-block-columns, .wp-block-group:not(.alignfull), .wp-block-gallery, .wp-block-embed) {
    width: min(100% - 1.5rem, 1140px);
    margin-left: auto;
    margin-right: auto;
}

.wordpress-blocks-content > :where(p, ul, ol, blockquote, pre),
.entry-content > :where(p, ul, ol, blockquote, pre) {
    max-width: 820px;
}

.wordpress-blocks-content > :where(h1, h2, h3, h4, h5, h6),
.entry-content > :where(h1, h2, h3, h4, h5, h6),
.editor-styles-wrapper :where(h1, h2, h3, h4, h5, h6) {
    color: var(--hp-navy);
    font-family: var(--hp-font-head);
    font-weight: 700;
    line-height: 1.2;
    margin-top: 2.25rem;
    margin-bottom: 1rem;
}

.wordpress-blocks-content h1,
.entry-content h1,
.editor-styles-wrapper h1 { font-size: clamp(2.25rem, 5vw, 4rem); }
.wordpress-blocks-content h2,
.entry-content h2,
.editor-styles-wrapper h2 { font-size: clamp(1.8rem, 3.5vw, 2.75rem); }
.wordpress-blocks-content h3,
.entry-content h3,
.editor-styles-wrapper h3 { font-size: clamp(1.4rem, 2.5vw, 2rem); }
.wordpress-blocks-content h4,
.entry-content h4,
.editor-styles-wrapper h4 { font-size: 1.35rem; }

.wordpress-blocks-content p,
.entry-content p,
.editor-styles-wrapper p {
    margin-bottom: 1.25rem;
}

.wordpress-blocks-content a:not(.btn):not([class*="hp-"]),
.entry-content a:not(.btn):not([class*="hp-"]),
.editor-styles-wrapper a:not(.btn):not([class*="hp-"]) {
    color: var(--hp-cyan);
    font-weight: 600;
    text-decoration-thickness: 1px;
    text-underline-offset: .2em;
}

.wordpress-blocks-content ul,
.wordpress-blocks-content ol,
.entry-content ul,
.entry-content ol,
.editor-styles-wrapper ul,
.editor-styles-wrapper ol {
    padding-left: 1.4rem;
    margin-bottom: 1.5rem;
}

.wordpress-blocks-content li + li,
.entry-content li + li,
.editor-styles-wrapper li + li { margin-top: .45rem; }

.is-style-checkmark {
    list-style: none;
    padding-left: 0 !important;
}

.is-style-checkmark li {
    position: relative;
    padding-left: 1.75rem;
}

.is-style-checkmark li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--hp-cyan);
    font-weight: 800;
}

.wp-block-button__link {
    background: var(--hp-cyan);
    border: 2px solid var(--hp-cyan);
    border-radius: 999px;
    color: var(--hp-white);
    font-family: var(--hp-font-body);
    font-weight: 700;
    padding: .75rem 1.4rem;
    transition: background-color 200ms var(--ease-out), border-color 200ms var(--ease-out), color 200ms var(--ease-out), transform 160ms var(--ease-out);
}

.wp-block-button__link:hover {
    background: var(--hp-deep);
    border-color: var(--hp-deep);
    color: var(--hp-white);
    transform: translateY(-1px);
}

.is-style-outline-light .wp-block-button__link {
    background: transparent;
    border-color: var(--hp-white);
    color: var(--hp-white);
}

.is-style-outline-dark .wp-block-button__link {
    background: transparent;
    border-color: var(--hp-navy);
    color: var(--hp-navy);
}

.is-style-arrow .wp-block-button__link::after {
    content: '→';
    margin-left: .65rem;
}

.wp-block-image img,
.wp-block-gallery img,
.wp-block-media-text__media img {
    border-radius: 12px;
}

.wp-block-image figcaption,
.wp-block-gallery figcaption,
.wp-block-embed figcaption {
    color: var(--hp-grey);
    font-size: .85rem;
    margin-top: .6rem;
    text-align: center;
}

.wp-block-quote {
    border-left: 4px solid var(--hp-cyan);
    margin-top: 2rem;
    margin-bottom: 2rem;
    padding: .5rem 0 .5rem 1.5rem;
}

.wp-block-quote p {
    font-family: var(--hp-font-head);
    font-size: clamp(1.35rem, 2.5vw, 2rem);
    font-style: italic;
    line-height: 1.45;
}

.wp-block-quote cite { color: var(--hp-grey); font-size: .875rem; }

.wp-block-separator {
    border-color: var(--hp-silver);
    margin-top: 3rem;
    margin-bottom: 3rem;
}

.wp-block-table table {
    border-collapse: collapse;
    width: 100%;
}

.wp-block-table th {
    background: var(--hp-navy);
    color: var(--hp-white);
    font-weight: 700;
}

.wp-block-table th,
.wp-block-table td {
    border: 1px solid var(--hp-silver);
    padding: .85rem 1rem;
    text-align: left;
}

.wp-block-table tbody tr:nth-child(even) { background: var(--hp-light); }
.wp-block-code, pre.wp-block-preformatted {
    background: var(--hp-navy);
    border-radius: 8px;
    color: var(--hp-white);
    overflow-x: auto;
    padding: 1.25rem;
}

.wp-block-columns.is-style-cards > .wp-block-column {
    border: 1px solid var(--hp-silver);
    border-radius: 12px;
    box-shadow: var(--hp-shadow);
    padding: 1.75rem;
}

.wp-block-cover { min-height: 420px; }
.wp-block-cover__inner-container { width: min(100% - 2rem, 1140px); }
.wp-block-embed iframe { max-width: 100%; }
.alignwide { width: min(100% - 1.5rem, 1320px); max-width: 1320px; }
.alignfull { width: 100%; max-width: none; }

/* Varianti condivise dei blocchi ACF. */
.hp-block-section--light,
.hp-block-cards--light,
.hp-block-media-text--light,
.hp-block-statement--light { background: var(--hp-light); }

.hp-block-section--blue,
.hp-block-cards--blue,
.hp-block-media-text--blue,
.hp-block-statement--blue { background: #f5faff; }

.hp-block-section__inner { max-width: 820px; }
.hp-block-section.text-center .hp-block-section__inner { margin-inline: auto; }
.hp-block-richtext { color: var(--hp-grey); }
.hp-block-richtext > :last-child,
.hp-cta-final__sub > :last-child,
.hp-section__sub > :last-child,
.hp-statement__sub > :last-child,
.hp-hscroll__desc > :last-child,
.hp-card__text > :last-child { margin-bottom: 0; }

.hp-block-media-text__media {
    aspect-ratio: 4 / 3;
    border-radius: 12px;
    overflow: hidden;
}

.hp-block-media-text__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hp-block-cards .hp-section__sub { max-width: 680px; }
.hp-block-contact-cta .hp-cta-final__sub { max-width: 520px; }

/* Anteprima Gutenberg: evita che la larghezza dell'iframe deformi i blocchi. */
.editor-styles-wrapper {
    padding-inline: 0 !important;
}

.editor-styles-wrapper .acf-block-preview {
    color: var(--hp-navy);
    font-family: var(--hp-font-body);
}

.editor-styles-wrapper .acf-block-preview > :first-child { margin-top: 0; }
.editor-styles-wrapper .hp-pdp-fullhero { margin-inline: 0; }
.editor-styles-wrapper .hp-header,
.editor-styles-wrapper .hp-megamenu { display: none; }

@media (max-width: 767.98px) {
    .wordpress-blocks-content > :where(p, h1, h2, h3, h4, h5, h6, ul, ol, blockquote, figure, table, pre, .wp-block-buttons, .wp-block-columns, .wp-block-group:not(.alignfull), .wp-block-gallery, .wp-block-embed),
    .entry-content > :where(p, h1, h2, h3, h4, h5, h6, ul, ol, blockquote, figure, table, pre, .wp-block-buttons, .wp-block-columns, .wp-block-group:not(.alignfull), .wp-block-gallery, .wp-block-embed) {
        width: min(100% - 2rem, 1140px);
    }

    .wp-block-table { overflow-x: auto; }
    .wp-block-media-text { grid-template-columns: 100% !important; }
    .wp-block-media-text .wp-block-media-text__content { grid-column: 1; grid-row: 2; padding: 1.5rem 0; }
    .wp-block-media-text .wp-block-media-text__media { grid-column: 1; grid-row: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .wp-block-button__link { transition: none; }
}
