/*
Theme Name: Indie Films 2027
Theme URI: 
Author: Indie Films
Description: Simple theme for IF.
Version: 4
Text Domain: indiefilms
*/

body {
    min-height: 100vh;
    overflow-wrap: break-word;
    word-wrap: break-word;
    -webkit-hyphens: auto;
    hyphens: auto;
    background: var(--body-bg) url('img/ssscribble.svg') fixed repeat center;
    background-size: contain;
    color-scheme: light;

    [data-theme="dark"] & {
        color-scheme: dark;
    }

    [data-theme="light"] & {
        color-scheme: light;
    }
}

a {
    --gradient-1: var(--body-color);
    --gradient-2: var(--primary-color);
    display: inline-block;
    margin-inline: -.25rem;
    padding-inline: .25rem;
    background-image: linear-gradient(to right, var(--gradient-1), var(--gradient-1) 50%, var(--gradient-2) 50%);
    background-size: 300%;
    background-position: 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;

    @media (prefers-reduced-motion: no-preference) {
        transition: all var(--transition-speed) var(--transition-style);
    }

    &:where(:active, :focus, :focus-within, :focus-visible) {
        background-position: 0;
    }

    @media (hover: hover) {
        &:hover {
            background-position: 0;
        }
    }
}

header.masthead,
main,
footer {
    max-width: 72rem;
    padding-inline: max(1rem, 5vw);
    margin-inline: auto;

    @media (width > 75rem) {
        padding-inline: 0;
    }
}

header.masthead {
    position: relative;
    margin-block: 0;
    margin-inline: auto;
    padding-block: 2.5dvh 0;
    color: var(--body-color);

    display: flex;
    flex-direction: column;

    @media (width > 75rem) {
        padding-inline: 3rem;
    }

    .home & {
        padding-block: 7.5dvh 0;
    }

    & .hero {
        order: 2;
    }

    & h1,
    & .h1 {
        display: inline-block;
        margin-block: 0;
        margin-inline-start: -2px;
        font-size: clamp(2.25rem, 2rem + 5vw, 10rem);
        font-weight: 900;
        line-height: 1;
        letter-spacing: -.1rem;
        transform: translate(-.05ch, 0);
    }

    & .h1 {
        --gradient-1: var(--primary-color);
        --gradient-2: var(--body-color);
        margin-inline-start: -0.015rem;
        padding-block-start: .25rem;
        padding-inline: 0 .25rem;
        color: var(--body-color);
        font-size: var(--font-size-h1);
        transition: all var(--transition-speed) var(--transition-style);
    }

    & p {
        position: relative;
        max-width: 64ch;
        font-size: var(--body-font-size);
        hyphens: none;
        text-wrap: balance;
    }
}

.navmenu {
    order: 1;
    z-index: 10;

    & ul {
        display: flex;
        justify-content: start;
        gap: .5ch;
        row-gap: 0;
        list-style: none;
        margin: 0;
        padding: 0;
    }

    & .nav-link {
        --gradient-1: var(--primary-color);
        --gradient-2: var(--body-color);
        display: block;
        padding: .25rem .5ch;
        font-family: var(--heading-font-family);
        font-size: clamp(.75rem, .75rem + .5vw, .875rem);
        line-height: 1;
        font-weight: 600;
        text-transform: uppercase;
        color: var(--primary-color);
        hyphens: none;
        white-space: nowrap;
        transition-duration: calc(var(--transition-speed) / 2);

        @media (width < 25rem) {
            max-width: 10ch;
            overflow: hidden;
            text-overflow: ellipsis;
            font-weight: 300;
        }

        @media (width > 46rem) {
            font-size: 1rem;
        }

        &:not(span, button) {
            background-image: linear-gradient(to right, var(--gradient-1), var(--gradient-1) 50%, var(--gradient-2) 50%, var(--gradient-2) 100%);
            background-position: 0;

            &:where(:hover, :active, :focus, :focus-within) {
                color: var(--body-color);
                background-position: -50%;
            }
        }
    }

    & span.nav-link {
        padding-inline-start: 0;
        color: currentColor;

        @media (width < 25rem) {
            max-width: 9ch;
        }
    }

    & .lang {
        margin-inline-start: auto;
    }

    & button.theme-toggle {
        border: none;
        background: none;
        transform: translate(0, -.1rem);

        & svg {
            fill: var(--link-color);

            &.sun {
                width: 1.2rem;
                height: 1.2rem;
            }
        }

        &:where(:hover, :active, :focus-within) svg {
            fill: var(--body-color);
        }
    }
}

.sun,
[data-theme="light"] .sun,
[data-theme="dark"] .moon {
    display: none;
}

[data-theme="dark"] .sun {
    display: inline-block;
}

#sisalto,
main [id] {
    scroll-margin-top: 2rem;
}

main {
    position: relative;
    padding-inline: 0;

    & ul {
        list-style: square outside url('img/gray.svg');
        padding-inline-start: 1.2rem;

        & ul {
            list-style: square outside;
        }

        & ol {
            margin-top: .5rem;
        }
    }

    & ol {
        padding-left: 0;
        counter-reset: item;
    }

    & li {
        line-height: 1.1;
        margin-block-end: 1ch;
        padding-inline-start: .15rem;
        text-wrap: balance;
    }

    & ol ul {
        padding-left: 2.5rem;
    }

    & ol>li {
        display: block;

        &::before {
            content: counters(item, ".") ". ";
            counter-increment: item;
        }
    }

    .alignnone {
        width: fit-content;
    }

    & figcaption,
    & .wp-caption-text {
        font-size: 90%;
        line-height: 1.2;
        text-align: center;

        &:not(.h6) {
            font-style: italic;
        }
    }
}

.section-title {
    margin-bottom: 1.5rem;
    font-weight: 800;

    & a {
        --gradient-1: var(--body-color);
        --gradient-2: var(--primary-color);
    }
}

.section,
section {
    box-sizing: border-box;

    &.latest article,
    .page & article {

        @media (width > 46rem) {
            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: space-between;
            gap: 3vw;
            row-gap: 1rem;

        }

        @media(width > 46rem) {

            & .article-content,
            & figure.article-img,
            & .article-header {
                width: 50%;
            }
        }

        & .article-title {
            padding-block-start: 0;

            & a {
                font-weight: 800;
            }
        }

        & figure.article-img {
            & a {
                width: 100%;
            }
        }

        & img.article-img {
            width: 100%;
            height: auto;
            aspect-ratio: 16 / 9;
            object-fit: cover;
            object-position: 50% 0;
        }
    }

    &.films {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
        grid-template-rows: auto;
        gap: 1.5rem;

        @media (width > 32rem) {
            grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
        }

        & article {
            display: block;

            & a {
                display: block;
                padding: 0;
            }

            & figure {
                margin-block-end: 0;
                padding: 0;
            }

            & img {
                width: 100%;
                height: auto;
                aspect-ratio: 16/9;
                object-fit: cover;
                object-position: 50% 0;
            }

            & .article-title {
                padding-block-start: 1rem;
                padding-inline: .5ch;
                font-size: 75%;
                font-weight: 500;
            }
        }
    }

    .page & h1.article-title {
        font-size: calc(var(--font-size-h1) * 1.5);
        font-weight: 800;
        line-height: 1;
        letter-spacing: -.1rem;
    }
}

article.news,
.blog article,
.error404 article {
    display: grid;
    grid-template-rows: auto;
    gap: 3vw;
    row-gap: 1rem;
    align-items: center;

    .wp-singular:not(.home) & {
        align-items: start;
    }

    @media (width > 42rem) {
        grid-template-columns: 37.5% auto;
        grid-template-rows: 1fr;

        .page &.category-elokuvat,
        .page &.category-films,
        .home &,
        .error404 & {
            grid-template-columns: 1fr 1fr;
        }
    }

    & .article-header {
        order: 1;

        & .article-title {
            margin-block-end: 0;
            font-weight: 800;

            & a {
                font-weight: 800;
            }
        }
    }

    & .article-content {
        order: 2;
    }

    & .news-headline {
        padding-top: 0;

        & a {
            font-weight: 800;
        }
    }

    & .news-img {
        & a {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 100%;
            height: 100%;
            aspect-ratio: 16 / 9;
        }

        & img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            object-position: 50% 0;
        }
    }

    & .has-default-img {
        & .default-img {
            position: relative;
            width: 50%;
            height: 50%;
            object-fit: contain;
            object-position: 50% 50%;
        }
    }
}

.navigation {
    margin-block: max(1.5rem, 5dvh);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1ch;

    .page-numbers:not(.prev, .next) {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 1.6rem;
        height: 100%;
        aspect-ratio: 1 / 1;
        background-color: var(--primary-color);
        color: var(--body-color);
        font-size: 90%;
        border-radius: 100%;

        --gradient-1: var(--body-color);

        &:where(:hover, :active, :focus, :focus-within) {
            border: 1px solid var(--link-color);
        }

        &.current {
            aspect-ratio: 1;
            color: var(--body-bg);
            background-color: transparent;
            border: 1px solid var(--body-bg-50);
            border-radius: 100%;
            filter: invert(1);
        }
    }
}

footer {
    display: flex;
    justify-content: center;
    align-items: start;
    gap: min(2rem, 5vw);

    & .section-headline {
        margin-bottom: 0;
        font-weight: 800;
    }

    & img {
        width: clamp(5rem, 30%, 9rem);
    }

    & ul {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    & li {
        margin: 0;
        line-height: 1.4;
        white-space: nowrap;
    }
}

.search-form {
    position: relative;
    display: flex;
    align-items: center;
    width: fit-content;
    min-width: 50%;
    margin-top: 5dvh;
    background-color: var(--body-bg);
    color: var(--body-color);
    border-radius: .15rem;

    & input {
        width: 100%;
        padding: 1ch;
        background-color: transparent;
        color: var(--body-color);
        border: none;
        outline-color: transparent;

        &.search-submit {
            width: fit-content;
            padding-inline: 1ch;
            background-color: var(--link-color);
            color: var(--body-bg);
            border-radius: 0 .25rem .25rem 0;
        }
    }

    & label {
        display: none;
    }

    & .search-field:where(:focus, :focus-within, :focus-visible) {
        color: var(--body-color);
        border-radius: .25rem 0 0 .25rem;
        outline-offset: 0;
    }
}

/* Utilities */
:focus {
    outline-color: var(--link-color);
}

.sticky {
    @media (width > 46rem) and (height > 43rem) {
        align-self: flex-start;
        position: sticky;
        top: 3rem;
    }
}

.translucent-bg {
    background-color: light-dark(rgb(0 0 0 / 0.035), rgb(255 255 255 / 0.05));

    @media (width > 72rem) {
        border-radius: 1rem;
        border-shape: squircle;
    }
}

.m-5 {
    margin: .25rem auto;

    @media (width > 75rem) {
        margin-block: max(1.5rem, 5dvh);
    }
}

.p-5 {
    padding: max(3rem, 5dvh) max(1rem, 5vw);

    @media (width > 75rem) {
        padding-inline: 3rem;
    }
}

.px-5 {
    padding: max(1rem, 2.5dvh) max(1rem, 5vw);

    @media (width > 75rem) {
        padding-inline: 3rem;
    }
}

.excerpt-read-more,
time,
.edit-link {
    font-size: 87.5%;
}

/* WP */
.wp-block-media-text {
    margin-block: 1rem;
}

.wp-embed-aspect-16-9 iframe {
    height: auto;
    width: 100%;
    aspect-ratio: 16 / 9;
    padding: 0;
    object-fit: cover;
}

/* Plugins */
.lang {

    & .current,
    span.no-lang {
        display: none;
    }
}

#ez-toc-container {
    margin-block: 1rem;
    padding: 0;
    border: none;

    & ul {
        list-style: none;
        padding: 0;

        & li {
            margin-block-end: 0;
            padding: 0;
            line-height: 1.2;

            & a {
                font-size: 100% !important;
                font-weight: 500 !important;
                text-transform: uppercase;
                text-decoration: none !important;
            }
        }
    }
}

[data-title] {
    display: inline;
    position: relative;
}

[data-title]:hover {
    transform: translateZ(0);
    /* safari does not behave */

    &::after {
        position: absolute;
        z-index: 98;
        content: attr(data-title);
        inset: auto auto -2.5rem 0;
        width: fit-content;
        padding: .5rem 1ch !important;
        color: var(--body-bg);
        background: var(--body-color);
        border-radius: .25rem;
        font-size: 75%;
        font-weight: 400;
        line-height: 1;
        text-transform: none;
        box-shadow: var(--box-shadow-lg);
        display: grid;
        place-content: center;
        white-space: nowrap;
        hyphens: none;

    }

    &::before {
        content: '';
        position: absolute;
        inset-block-end: -.75rem;
        inset-inline-start: 33%;
        z-index: 99;
        border-width: 0 .5rem .5rem .5rem;
        border-style: solid;
        border-color: var(--body-color) transparent;
    }
}

/* SEASONAL EXTRA */
[data-theme="dark"] {

    & .masthead h1,
    & .masthead .h1 {
        background-image: linear-gradient(to right, rgb(120, 79, 23) 5%, rgb(181, 63, 27), var(--primary-color), var(--primary-color-hover), rgb(249, 150, 33), rgb(245, 193, 30), rgb(241, 235, 27) 48%, rgb(241, 235, 27), rgb(241, 235, 27) 52%, rgb(99, 199, 32), rgb(12, 155, 73), rgb(33, 135, 141), rgb(57, 84, 165), rgb(97, 55, 155), rgb(147, 40, 142) 100%) !important;
        background-position: 20%;
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;

        &:where(:hover, :active, :focus) {
            background-position: 40%;
        }
    }
}