/**
 * The following styles get applied both on the front of your site
 * and in the editor.
 *
 * Replace them with your own styles or remove the file completely.
 */

:root {
    --bc-block-article-gap: 20px;
    --sponsored-border-color: black;
    --sponsored-padding: 10px;
    --live-background-color: #d93025;
}

/**
* SECTIONS
*/

.dh-main {
    box-sizing: border-box;
    *,
    *:before,
    *:after {
        box-sizing: inherit;
    }
    a {
        display: block;
    }
}

/* ========== post */

section.dh-articles {
    margin-bottom: 24px;
    @media (min-width: 600px) {
        display: flex;
        gap: var(--bc-block-article-gap);
        & > .bc-article {
            flex: 1 0;
        }
    }
}

section.dh-articles.dh-articles--6 {
    @media (min-width: 600px) {
        flex-wrap: wrap;
        & > .bc-article {
            flex: 1 0 calc(33% - var(--bc-block-article-gap));
        }
    }
}

.dh-cols {
    section.dh-articles.dh-articles--6 {
        & > .bc-article {
            flex: 1 0 calc(50% - var(--bc-block-article-gap));
        }
    }
}

section.dh-articles.dh-articles--4 {
    @media (min-width: 600px) {
        flex-wrap: wrap;
        & > .bc-article {
            flex: 1 0 calc(50% - var(--bc-block-article-gap));
        }
    }
}

/* ========== podcast */

section.dh-podcast {
    @media (min-width: 600px) {
        display: flex;
        gap: var(--bc-block-article-gap);
        & > .bc-article {
            flex: 1 0;
        }
    }
}

/* ========== video */

section.dh-video {
    @media (min-width: 600px) {
        display: flex;
        gap: var(--bc-block-article-gap);
        & > .bc-article {
            flex: 1 0;
        }
    }
}

section.dh-video.dh-video--4 {
    @media (min-width: 600px) {
        flex-wrap: wrap;
        & > .bc-article {
            flex: 1 0 calc(50% - var(--bc-block-article-gap));
        }
    }
    @media (min-width: 700px) {
        flex-wrap: wrap;
        & > .bc-article {
            flex: 1 0 calc(25% - var(--bc-block-article-gap));
        }
    }
}

/* ========== photogallery */

section.dh-photogallery {
    @media (min-width: 600px) {
        display: flex;
        gap: var(--bc-block-article-gap);
        & > .bc-article {
            flex: 1 0;
        }
    }
}

section.dh-photogallery.dh-photogallery--4 {
    @media (min-width: 600px) {
        flex-wrap: wrap;
        & > .bc-article {
            flex: 1 0 calc(50% - var(--bc-block-article-gap));
        }
    }
    @media (min-width: 700px) {
        flex-wrap: wrap;
        & > .bc-article {
            flex: 1 0 calc(25% - var(--bc-block-article-gap));
        }
    }
}

/* ========== columns */

.dh-cols {
    display: flex;
    gap: var(--bc-block-article-gap);
    & > .bc-article {
        flex: 1 0;
    }
}

.dh-cols.dh-cols--50-50 {
    flex-wrap: wrap;
    @media (min-width: 600px) {
        flex-wrap: nowrap;
    }
    & > div {
        width: 100%;
        @media (min-width: 600px) {
            width: 50%;
        }
    }
}

.dh-cols.dh-cols--66-33 {
    flex-wrap: wrap;
    @media (min-width: 600px) {
        flex-wrap: nowrap;
    }
    & > div:first-child {
        width: 100%;
        @media (min-width: 600px) {
            width: 66%;
        }
    }
    & > div:last-child {
        width: 100%;
        @media (min-width: 600px) {
            width: 33%;
        }
    }
}

.dh-cols.dh-cols--33-66 {
    flex-wrap: wrap;
    @media (min-width: 600px) {
        flex-wrap: nowrap;
    }
    & > div:first-child {
        width: 100%;
        @media (min-width: 600px) {
            width: 33%;
        }
    }
    & > div:last-child {
        width: 100%;
        @media (min-width: 600px) {
            width: 66%;
        }
    }
}

.bc-single-sponsor {
    display: flex;
    gap: calc(var(--bc-block-article-gap) / 2);
    align-items: center;
    p {
        margin-top: 0 !important;
        font-size: var(--wp--preset--font-size--x-small);
        text-decoration: underline;
    }
    span {
        height: 30px;
    }
}

/**
* ARTICLE CARD
* rules copied from blockcraft/src/blocks/blockcraft-article/style-index.css
*/

/* main article rules */
.bc-article {
    margin-bottom: var(--wp--preset--spacing--40);
    & > .block-group {
        gap: var(--wp--preset--spacing--40);
    }
    &.bc-featured {
        img {
            aspect-ratio: 16 / 9 !important;
        }
    }
    h2,
    p {
        margin: 0;
    }
    .bc-single-category {
        color: var(--wp--preset--color--secondary);
        a {
            color: var(--wp--preset--color--secondary);
            &:hover {
                border-color: var(--wp--preset--color--white);
            }
        }
    }
    ul {
        margin: 0;
        padding: 0;
        list-style-type: none;
        display: flex;
        gap: var(--wp--preset--spacing--20);
        /*
        li::after {
            content: ", ";
        }
        li:last-child::after {
            content: "";
        }
        */
    }
    img {
        display: block;
        width: 100%;
        object-fit: cover;
    }
}

.bc-article--warning {
    color: red;
    background: #ebeef0;
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    padding: 20px 0;
    text-align: center;
}

/* card-inline-small */
.bc-card.bc-card--inline.bc-card--small {
    .block-group {
        display: flex;
        flex-wrap: nowrap;
        justify-content: flex-start;
        align-items: center;
        & > .block-group {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: var(--wp--preset--spacing--40);
            width: 66.33%;
        }
        & > a {
            width: 33.34%;
        }
    }
    h2 {
        font-size: var(--wp--preset--font-size--large);
    }
    img {
        aspect-ratio: 1 / 1;
        width: 100%;
        height: auto;
        object-fit: cover;
    }
    .bc-single-category {
        font-size: var(--wp--preset--font-size--x-small);
    }
    .bc-single-date {
        font-size: var(--wp--preset--font-size--x-small);
    }
}

/* card-inline-medium */
.bc-card.bc-card--inline.bc-card--medium {
    .block-group {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
        @media (min-width: 600px) {
            flex-wrap: nowrap;
        }
        & > .block-group {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: var(--wp--preset--spacing--40);
            width: 100%;
            @media (min-width: 600px) {
                width: 50%;
            }
        }
        & > a {
            width: 100%;
            @media (min-width: 600px) {
                width: 50%;
            }
        }
    }
    h2 {
        font-size: var(--wp--preset--font-size--large);
    }
    img {
        aspect-ratio: 1 / 1;
        width: 100%;
        height: auto;
        object-fit: cover;
    }
    .bc-single-category {
        font-size: var(--wp--preset--font-size--x-small);
    }
    .bc-single-date {
        font-size: var(--wp--preset--font-size--x-small);
    }
}

/* card-inline-small-flipped */
.bc-card.bc-card--inline.bc-card--small.bc-card-flipped {
    .block-group {
        justify-content: space-between;
        & > .block-group {
            width: 66.33%;
        }
        & > a {
            width: 33.34%;
        }
    }
    .bc-single-date {
        font-size: var(--wp--preset--font-size--x-small);
    }
    img {
        aspect-ratio: 1 / 1;
        width: 100%;
        height: auto;
        object-fit: cover;
    }
}

/* card-overlay-medium */
.bc-card.bc-card--overlay.bc-card--medium {
    height: 100%;
    .block-group {
        display: flex;
        flex-direction: column;
        color: var(--wp--preset--color--white);
    }
    .wp-block-cover {
        height: 100%;
        position: relative;
        &::before {
            content: "";
            position: absolute;
            inset: 0;
            background: #000;
            opacity: 0.2;
        }
        .wp-block-cover__inner-container {
            position: absolute;
            inset: 0;
            display: flex;
            flex-direction: column;
            justify-content: center;
            margin-left: var(--wp--preset--spacing--40);
            width: calc(100% - (var(--wp--preset--spacing--40) * 2));
        }
        img {
            display: block;
            width: 100%;
        }
    }
    a {
        color: var(--wp--preset--color--white);
        &:hover {
            border-color: var(--wp--preset--color--white);
        }
    }
    h2 {
        font-size: var(--wp--preset--font-size--4-x-large);
    }
    .bc-single-category {
        font-size: var(--wp--preset--font-size--small);
    }
    .bc-single-author {
        font-size: var(--wp--preset--font-size--x-small);
        display: flex;
        align-items: center;
        a {
            display: block;
            &:nth-child(1) {
                order: 2;
            }
            &:nth-child(2) {
                order: 1;
            }
        }
    }
}

/* card-stack-medium */
.bc-card.bc-card--stack.bc-card--medium {
    .block-group {
        display: flex;
        flex-direction: column;
    }
    h2 {
        font-size: var(--wp--preset--font-size--4-x-large);
    }
    p {
        font-size: var(--wp--preset--font-size--large);
    }
    img {
        aspect-ratio: 16 / 9;
        width: 100%;
        height: auto;
        object-fit: cover;
    }
    .bc-single-category {
        font-size: var(--wp--preset--font-size--small);
    }
    .bc-single-author {
        font-size: var(--wp--preset--font-size--x-small);
        display: flex;
        align-items: center;
        a {
            display: block;
            &:nth-child(1) {
                order: 2;
            }
            &:nth-child(2) {
                order: 1;
            }
        }
    }
    .bc-single-date {
        font-size: var(--wp--preset--font-size--x-small);
    }
}

/* card-text-extrasmall */
.bc-card.bc-card--text.bc-card--extrasmall {
    display: flex;
    flex-direction: column;
    h2 {
        font-size: var(--wp--preset--font-size--medium);
    }
    .bc-single-category {
        font-size: var(--wp--preset--font-size--x-small);
    }
    .bc-single-author {
        font-size: var(--wp--preset--font-size--x-small);
        display: flex;
        align-items: center;
        a {
            display: block;
            &:nth-child(1) {
                order: 2;
            }
            &:nth-child(2) {
                order: 1;
            }
        }
    }
    .bc-single-date {
        font-size: var(--wp--preset--font-size--x-small);
    }
}

/**
* CUSTOM RULES
*
*/

/* ========== live event post */

.bc-article.live {
    .bc-single-category {
        position: relative;
        & > ul {
            display: inline-block;
        }
        &::before {
            content: "IN DIRETTA";
            display: inline-block;
            font-size: var(--wp--preset--font-size--x-small);
            background: var(--live-background-color);
            color: white;
            font-weight: 700;
            padding: 5px 8px;
            margin-right: 6px;
            border-radius: 2px;
            padding-left: 20px;
        }
        &::after {
            content: "";
            position: absolute;
            top: 50%;
            left: 8px;
            transform: translateY(-50%) !important;
            width: 4px;
            height: 4px;
            background: #fff;
            border-radius: 50%;
            animation: pulse 1.5s infinite;
        }
    }
}

@keyframes pulse {
    0% {
        transform: translateY(-50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateY(-50%) scale(1.6);
        opacity: 0.3;
    }
    100% {
        transform: translateY(-50%) scale(1);
        opacity: 1;
    }
}

/* ========== sponsored post */

.bc-article.sponsored {
    overflow: hidden;
    .bc-single-sponsor {
        img {
            width: 100% !important;
            height: 100% !important;
            object-fit: cover !important;
            aspect-ratio: auto !important;
        }
    }
}

.bc-article.bc-card--stack.sponsored {
    outline: 1px solid var(--sponsored-border-color);
    & > * {
        padding-left: var(--sponsored-padding);
        padding-right: var(--sponsored-padding);
    }
    & > *:first-child {
        padding-top: var(--sponsored-padding);
    }
    & > *:last-child {
        padding-bottom: var(--sponsored-padding);
    }
}
.bc-article.bc-card--inline.sponsored {
    outline: 1px solid var(--sponsored-border-color);
    & > * {
        padding-left: var(--sponsored-padding);
        padding-right: var(--sponsored-padding);
    }
    & > *:first-child {
        padding-top: var(--sponsored-padding);
    }
    & > *:last-child {
        padding-bottom: var(--sponsored-padding);
    }
}

/* ========== force inline template on mobile */

.force-inline-on-mobile {
    @media (max-width: 599px) {
        .bc-article {
            display: flex;
            gap: 1rem;
            align-items: center;
            margin: 1rem 0;
            & h2 {
                line-height: normal;
            }
            & h2 > a {
                font-size: var(--wp--preset--font-size--medium) !important;
            }
            & > a {
                width: 145px;
                min-width: 145px;
                aspect-ratio: 16 / 9;
            }
            & > .block-group {
                width: calc(66.66% - (var(--bc-article-margin) / 2));
                display: flex;
                flex-direction: column;
                align-items: flex-start;
                justify-content: center;
                gap: calc(var(--bc-article-margin) / 4) !important;
            }
            .bc-single-category {
                margin: 0;
                font-size: var(--wp--preset--font-size--x-small);
                @media (min-width: 600px) {
                    font-size: var(--wp--preset--font-size--small);
                }
            }
            .bc-single-author a {
                display: flex;
                p {
                    font-size: var(--wp--preset--font-size--x-small);
                    @media (min-width: 600px) {
                        font-size: var(--wp--preset--font-size--small);
                    }
                }
            }
        }
    }
}

.force-inline-on-mobile {
    @media (max-width: 599px) {
        .bc-article.sponsored {
            & > * {
                padding-left: 0;
                padding-right: 0;
            }
            & > *:first-child {
                padding-top: var(--sponsored-padding);
                padding-bottom: var(--sponsored-padding);
                padding-left: var(--sponsored-padding);
            }
            & > *:last-child {
                margin-top: 0;
                padding-top: var(--sponsored-padding);
                padding-bottom: var(--sponsored-padding);
                padding-right: var(--sponsored-padding);
            }
        }
    }
}

/* ========== force horizontal overflow on mobile */

.force-overflow-on-mobile {
    @media (max-width: 599px) {
        overflow-x: auto;
        display: flex;
        flex-wrap: nowrap;
        gap: var(--bc-article-margin);
        & > * {
            flex: 0 0 auto;
            width: 330px;
        }
    }
}

/* ========== section title */

.bc-section-title {
    margin-bottom: 24px;
    .wp-block-button {
        @media (max-width: 599px) {
            height: 50px !important;
        }
    }

    .wp-block-heading {
        font-size: 24px;
        text-transform: capitalize;
    }
}

/**
* SWIPER
*
*/

.dh-swiper-container {
    position: relative;
    @media (min-width: 600px) {
        padding: 0 40px;
    }
    .swiper-button-next,
    .swiper-button-prev {
        color: var(--wp--preset--color--custom-1);
        &::after {
            font-size: 26px;
        }
    }
    .swiper-button-next {
        right: -16px;
        display: none;
        @media (min-width: 600px) {
            display: block;
        }
    }
    .swiper-button-prev {
        left: 0;
        display: none;
        @media (min-width: 600px) {
            display: block;
        }
    }
}

.dh-swiper {
    width: 100%;
    overflow: hidden;
    position: relative;
}

.dh-swiper.dh-swiper--elite-authors {
    .swiper-slide {
        width: 80%;
        @media (min-width: 768px) {
            width: 28%;
        }
    }
}
