/*
Theme Name: SFP i Esbo
Theme URI: https://esbosfp.fi/
Author: 
Description: SFP/RKP Esbo goes WP. Based visually on SFP.fi.
Requires at least: 7.0.0
Tested up to: 7.0.0
Version: 2
Text Domain: sfp
Domain Path: assets/translation
*/

:root {
    color-scheme: light dark;
    font-size: 125%;
    --header-height: 3.265rem;
}

header,
main,
footer {
    max-width: 2000px;
    margin-inline: auto;
    padding: 0 1rem;

    @media (width > 1200px) {
        padding: 0 2rem;
    }
}

@media (width > 1200px) {
    main {
        padding: 0;
    }
}

a:where(:link, :visited) {
    background-image: linear-gradient(90deg, var(--color-primary-hover), var(--color-primary));
    background-size: 0% 2px;
    background-repeat: no-repeat;
    background-position: center bottom;
    transition: all .15s ease;
}

a:where(:hover, :active, :focus) {
    color: var(--color-primary-hover);
    background-size: 100% 2px;
}

a:has(img, svg) {
    display: block;
    background: none;

    & img,
    & svg {
        transition: scale .25s ease;
    }

    &:hover img,
    &:hover svg {
        scale: 1.025;
    }
}

.btn {
    font-family: var(--font-head);
    text-transform: uppercase;

    &::after {
        content: '\203A';
        font-size: 125%;
        padding-inline-start: 1ch;
    }
}

button,
input[type="submit"],
&.btn-primary {
    padding: .5rem 2ch .35rem;
    border: none;
    background-color: var(--color-primary);
    color: var(--main-bg-light);
    border-radius: .1rem;
    transition: all .15s ease;

    &.calendar {
        padding: 0;
        background-color: transparent;
        color: var(--color-primary);

        &:where(:hover, :active, :focus) {
            color: var(--color-primary-hover);
        }
    }

    &::after {
        content: none;
    }
}

button:not(.toggler):where(:hover, :active, :focus) {
    background-color: var(--color-primary-hover);
}

.flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

form.flex {
    justify-content: start;
    gap: 1ch;

    & svg {
        fill: var(--color-primary);
        scale: 120%;
        transform: translateY(-3px);
    }
}

.grid {
    display: grid;
    align-content: center;
    gap: 1rem;
    --min-col-size: 100%;
    grid-template-columns: repeat(auto-fit, minmax(var(--min-col-size), 1fr));

    @media (width > 920px) {
        --min-col-size: calc(100% / 2 - 2rem);
    }

    @media (width > 1200px) {
        --min-col-size: calc(100% / 3 - 3rem);
    }
}

h1,
h2,
h3,
h4 {
    text-transform: uppercase;
}

h1,
.h1 {
    font-size: var(--font-size-h1);
}

h2,
.h2 {
    font-size: var(--font-size-h2);
}

h3,
.h3 {
    font-size: var(--font-size-h3);
}

h4,
.h4 {
    font-size: var(--font-size-h4);
}

h5,
.h5 {
    font-size: var(--font-size-h5);
}

h6,
.h6 {
    font-size: var(--font-size-h6);
}

/* Header */

header {
    position: fixed;
    top: 0;
    inset-inline-end: 0;
    inset-inline-start: 0;
    width: 100%;
    height: var(--header-height);
    margin: auto;
    z-index: 9999;
    transition: all .5s ease;

    background-color: var(--body-bg);
    font-size: .875rem;
    font-weight: 700;

    anchor-name: --header;

    & a {
        color: var(--body-color);
    }

    & .flex {
        position: relative;
        align-items: center;
        gap: 2.5ch;

        @media (width > 920px) and (width < 1200px) {
            font-size: .75rem;
            gap: 1ch;
        }
    }

    & ul,
    & li {
        margin: 0;
        background-color: var(--body-bg);

        & button {
            width: 100%;
            height: 100%;
            padding: 0;
            text-align: start;
            white-space: nowrap;
            color: var(--body-color);
            font-weight: 700;
            background-color: transparent;
            background-image: linear-gradient(90deg, var(--color-primary-hover), var(--color-primary));
            background-size: 0% 2px;
            background-repeat: no-repeat;
            background-position: center bottom;
            transition: all .15s ease;

            &:is(:hover, :active, :focus) {
                color: var(--color-primary-hover);
                background-color: transparent;
                background-size: 100% 2px;
            }
        }

        & a {
            display: flex;
            align-items: center;
            background-color: var(--body-bg);
        }
    }
}

.navbar-main-menu.flex {
    flex-direction: column;
    padding: 0;
    overflow: hidden;

    @media (width > 500px) {
        flex-direction: row;
    }

    @media (width <=920px) {
        position: absolute;
        z-index: 0;
        height: 0;
        visibility: hidden;

        &[popover]:popover-open {
            position: fixed;
            --anchor: --header;
            z-index: auto;
            inset: auto;
            top: anchor(var(--anchor) bottom);
            right: -1rem;
            left: -1rem;
            height: auto;
            padding-bottom: 1rem;
            visibility: visible;
            background-color: var(--body-bg);
        }
    }

    @media (width > 920px) {
        &[popover] {
            display: flex;
            flex-direction: row;
            visibility: visible;
            opacity: 1;
            width: fit-content;
            height: var(--header-height);
            margin-inline: auto 0;
            border: 0;
            transform: none;
        }
    }

    & .main-menu {
        background-color: var(--body-bg);

        @media (width <=920px) {
            flex-direction: column;
            align-items: start;
            gap: 1ch;
            width: 100%;
            padding: 1rem;
            margin-block-end: 1rem;
        }
    }

    & .nav-link {
        padding-block: .5rem;
        line-height: 1;
        white-space: nowrap;

        &:where(:hover, :active, :focus, .active) {
            color: var(--color-primary-hover);
        }

        @media (width > 920px) {
            padding-block: calc((var(--header-height) - .875rem) / 2);

            &.dropdown-link {
                padding-block: .5rem;
            }
        }
    }

    & .dropdown {
        width: 100%;
    }
}

.navbar-brand {
    & a {
        justify-content: start;
        gap: 1ch;
        font-size: .75rem;
        text-transform: uppercase;
    }

    & .header-logo {
        width: 160px;
        padding-block: .5rem 1rem;

        @media (prefers-color-scheme: dark) {
            & .blue {
                fill: #fff;
            }
        }
    }

    & span {
        position: absolute;
        inset: auto 0 -2px;
        margin-inline-end: 3px;
        text-align: center;
    }
}

.toggler {
    height: calc(var(--header-height) - 3px);
    padding: .25rem .5ch 0;
    background-color: transparent;

    & label {
        cursor: pointer;
    }

    & svg {
        display: block;
        width: 1rem;
        height: 1rem;
        fill: var(--body-color);

        .menu-toggler & {
            stroke: var(--body-color);
        }
    }

    &:where(:hover, :active, :focus) {
        box-shadow: 0 2px 0 var(--color-primary-hover);
        border-radius: 0;

        & svg {
            fill: var(--color-primary-hover);

            .menu-toggler & {
                stroke: var(--body-color);
            }
        }
    }
}

.search-toggler {
    anchor-name: --search-btn;
}

.menu-toggler {
    order: 3;
    transition: all .15s ease;


    @media (width > 920px) {
        display: none;
    }

    & svg path {
        transition: all .15s ease;
    }

    & .x {
        visibility: hidden;
        opacity: 0;
    }

    nav:has(.navbar-main-menu[popover]:popover-open) & {
        & .ham {
            visibility: hidden;
            opacity: 0;
        }

        & .x {
            visibility: visible;
            opacity: 1;
        }
    }
}

.lang-switcher {
    display: flex;
    gap: .5ch;
    anchor-name: --lang-switcher-btn;

    & span {
        font-family: var(--font-light-condensed);
        font-size: 1rem;
        font-weight: 900;
        color: var(--body-color);

    }

    & svg.locale-svg {
        stroke: #111;

        @media (prefers-color-scheme: dark) {
            stroke: white;
        }
    }

    &:is(:hover, :active, :focus-within) * {
        color: var(--color-primary-hover);
        stroke-color: var(--color-primary-hover);
    }
}

.alde {

    @media (width > 920px) {
        & a {
            padding-top: .25rem;
        }

        & img {
            width: calc(var(--header-height) * 2.66667 - 2rem);
            aspect-ratio: 600 / 225;
        }
    }
}

.meta-navbar.flex {
    gap: 1ch;
    margin-inline-start: auto;

    & .lang-switcher.flex {
        gap: .15rem;
    }

    @media (width > 920px) {
        margin-inline-start: 0;
    }
}

.searchform {
    --anchor: --header;

    @media(width > 414px) {
        --anchor: --search-btn;

        &[popover]:popover-open {
            top: calc(anchor(var(--anchor) bottom) + 1px);
            right: anchor(var(--anchor) right);
            left: auto;
        }
    }

    & form {
        gap: 0;
        align-items: stretch;
        justify-content: center;
    }

    & label {
        display: none;
    }

    & input[type="text"] {
        padding: .45rem 1ch;
        border: none;
        border: 1px solid var(--color-gray-90);
        border-radius: .15rem;
    }

    &.section-searchform {
        padding-block-end: 2.5vw;
    }
}

.bogo-language-switcher {
    --anchor: --lang-switcher-btn;
    height: auto;


    &[popover]:popover-open {
        top: calc(anchor(var(--anchor) bottom) + 1px);
        display: grid;
    }

    & li {
        height: auto;
        order: 10;

        &.sv {
            order: 1;
            text-transform: lowercase;
        }

        &.fi {
            order: 2;
            text-transform: lowercase;
        }

        &.en {
            order: 3;
        }

        &.et {
            order: 3;
            text-transform: lowercase;
        }

        & a {
            padding-block: .25rem;
        }
    }
}

[popover]:popover-open {
    inset: auto;
    top: anchor(var(--anchor) bottom);
    right: anchor(var(--anchor) right);
    border: none;
    width: fit-content;
    max-width: 100%;
    padding: .5rem 1rem 1rem;
    box-shadow: 0 .35rem .5rem var(--body-color-10);
    border-radius: 0 0 .15rem .15rem;
    opacity: 1;
    transform: translateY(0);
    transition: all .15s ease;

    .navbar-main-menu& {
        @media (width <=920px) {
            padding: .25rem 0 1rem;
            width: auto;
        }
    }

    .rtl & {
        right: auto;
        left: calc(anchor(--header left) + 2rem);
    }

    /* &::backdrop {
        margin-top: var(--header-height);
        background-color: var(--body-color-10);
        backdrop-filter: blur(1px);
    } */
}

@media (width <=920px) {
    .submenu[popover]:popover-open {
        left: anchor(var(--anchor) left);
        width: calc(100% - 2rem);
        border: 1px solid var(--color-primary-hover);

        /* &::backdrop {
            background-color: transparent;
            backdrop-filter: none;
        } */
    }
}

[popover] {
    opacity: 0;
    transform: translateY(-5%);
}

@starting-style {
    [popover]:popover-open {
        opacity: 0;
        transform: translateY(-5%);
    }
}

.navbar-bc {
    position: fixed;
    inset: auto auto 0 1rem;

    .breadcrumb {
        justify-content: start;
        width: fit-content;
        gap: .25rem;
        padding: .5rem;
        background-color: rgb(255 255 255 / .25);
        backdrop-filter: blur(.5rem);
        border-radius: .15rem;
        z-index: 9999;
        box-shadow: .15rem .5rem 1rem rgb(0 0 0 / .25);

        @media (prefers-color-scheme: dark) {
            background-color: rgb(0 0 0 / .25);
        }

        & li,
        & a {
            font-size: .75rem;
            font-weight: 400;
            white-space: nowrap;
            background-color: transparent;
            color: #555;

            @media (prefers-color-scheme: dark) {
                color: #ccc;
            }
        }
    }
}

.hero {
    position: relative;
    display: grid;
    place-content: center;
    min-height: 25rem;
    margin-top: var(--header-height);
    background-color: var(--color-primary);
    color: var(--body-bg);
    overflow: hidden;

    & .hero-image {
        position: absolute;
        inset: 0;
        z-index: 0;

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

    & .hero-caption {
        z-index: 1;
        width: fit-content;
        margin: auto;
        padding: 10cqi 2ch 5cqi;
        text-align: center;
        text-wrap: balance;
        color: var(--body-bg);
        filter: drop-shadow(-1px -1px 0 rgb(0 0 0 / .25));

        @media (prefers-color-scheme: dark) {
            color: var(--body-color);
        }

        & h1 {
            color: var(--body-bg);

            @media (prefers-color-scheme: dark) {
                color: var(--body-color);
            }
        }

        & .lead {
            font-family: var(--font-head);
            font-size: var(--font-size-h3);
            text-transform: uppercase;
        }
    }
}

main {
    padding-block: var(--header-height) 0;
    background-color: var(--main-bg);
    text-wrap: balance;
}

section,
.section {
    text-align: center;
    padding-top: 2.5vw;

    &:has(.has-post-thumbnail) {
        padding-top: 0;
    }

    /* body.search & {
        max-width: 80ch;
        margin-inline: auto;
    } */

    & .page-title,
    & .section-title {
        margin-block: 2.5vw;
    }

    & .grid {
        gap: 1rem;

        @media (width > 920px) {
            gap: 1.5rem;
        }

        @media (width > 1200px) {
            gap: 2rem;
        }
    }
}

article,
.news-article {
    justify-content: space-between;
    flex-direction: column;
    width: 100%;
    margin: 1rem auto;
    padding: 0;
    text-align: left;
    text-wrap: wrap;
    border-radius: .15rem;

    .rtl & {
        text-align: right;
    }

    .wp-singular &,
    .news-articles.grid & {
        margin: 0 auto;
        max-width: 65ch;
    }

    &.flex {
        justify-content: start;
    }

    @media (width > 576px) {

        .news-articles.grid & {
            background-color: var(--main-bg-light);
        }
    }

    & h1 {
        margin-top: 5vw;
    }

    & .featured-img {
        width: 100%;
        height: auto;
        aspect-ratio: 1.75;
        margin: 0;
        background: var(--main-bg-light) url('img/logo.svg') no-repeat 50% 50%;
        background-size: 50%;
        border-radius: .15rem;

        &.first-img {
            background-size: cover;
        }

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

        &.default-img {
            background-size: 50%;
        }

        & img {
            border-radius: .1rem .1rem 0 0;
        }
    }

    & .news-meta {
        font-family: var(--font-light-condensed);
        font-size: 1rem;
        color: var(--color-primary);
        text-transform: uppercase;

        @media (prefers-color-scheme: dark) {
            color: var(--body-color);
        }

        & a {
            font-family: var(--font-head);
        }

        h1+&,
        h2+&,
        h3+& {
            margin-block: -.5vw .5vw;
        }
    }

    & .news-content {
        width: 100%;
        padding: 1rem 0;

        @media (width > 576px) {
            padding: 1rem;
        }

        @media (width > 1200px) {
            padding: 1rem 1.5rem;
        }

        @media (width > 1400px) {
            padding: 1.5rem 2rem;
        }
    }

    .news &:first-child {
        display: flex;
        align-items: center;
        justify-content: center;

        @media (width > 1200px) {
            grid-column: 1 / span 3;
            flex-direction: row;
            max-width: none;
        }

        &>* {
            width: 100%;
            height: auto;

            @media (width > 1200px) {
                width: 50%;
            }
        }

        & .featured-img {
            aspect-ratio: 1.75;

            @media (width <=1200px) {
                background-image: none !important;
            }

            @media (width > 1200px) {
                height: 100%;
                aspect-ratio: auto;
                border-radius: .1rem 0 0 .1rem;

                & img {
                    display: none;
                }
            }
        }

        & .news-content {
            position: relative;
            padding: 1rem 0;

            @media (width > 576px) {
                padding: 1rem;
            }

            @media (width > 1200px) {
                padding: 3rem;

                &::after {
                    display: block;
                    content: " ";
                    width: 2rem;
                    height: 2rem;
                    background: var(--main-bg-light);
                    position: absolute;
                    top: 50%;
                    margin-top: -10px;
                    inset-inline-start: -20px;
                    inset-inline-end: auto;
                    transform: rotate(45deg);
                }
            }
        }
    }

    & .content-text {
        position: relative;
        padding: 0 0 3rem;
    }

    & .some {

        @media (width > 920px) {
            position: absolute;
            top: 0;
            inset-inline-start: -3rem;
        }

        & ul {
            display: flex;
            gap: 1ch;

            @media (width > 920px) {
                flex-direction: column;
            }
        }

        & a {
            background: none;
        }

        & svg {
            width: 1rem;
            height: 1rem;
        }
    }
}

.highlight {
    margin-block: 2.5vw;
    padding-bottom: 5vw;
    border-bottom: 1px solid var(--color-gray-90);
    font-size: var(--font-size-h5);

    --min-col-size: 100%;

    @media (width > 1200px) {
        --min-col-size: calc(100% / 3 - 3rem);
    }

    & article {
        flex-direction: column;
        padding-inline: 1rem;
        background-color: transparent;
        text-align: center;

        @media (width > 1200px) {
            padding-inline: 2rem;

            &:not(:first-child) {
                border-inline-start: 1px solid var(--color-gray-90);
            }
        }

        /* & p {
            -webkit-line-clamp: 8;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            overflow: hidden;
        } */
    }

    & .highlight-img {
        width: 5rem;
        height: auto;
        aspect-ratio: 1 / 1;
        object-fit: contain;
        object-position: 50%;
        margin-block: 1vw 2rem;
    }

    & .highlight-text {

        & .btn {
            margin-top: auto;
        }
    }
}

.page-content {
    font-size: 1rem;
    text-align: left;
    text-wrap: wrap;

    .rtl & {
        text-align: right;
    }

    & article {
        margin-block: 2.5vw;
        padding-bottom: 5vw;
        text-align: left;
        background-color: transparent;

        .rtl & {
            text-align: right;
        }
    }

    & .highlight-title,
    & .wp-block-heading {
        text-align: center;
    }
}

.pagination {

    & .btn,
    & .navigation {
        display: inline-block;
        margin-block: 2.5vw;
    }

    & .nav-links {
        font-family: var(--font-head);
        display: flex;
        gap: 1ch;
    }
}

.post-navigation.grid {
    --min-col-size: 100%;
    gap: 1rem;
    max-width: calc(65ch + 3rem);
    margin: 5vw auto 0;
    font-size: .875rem;

    @media (width > 1200px) {
        --min-col-size: calc(100% / 2 - 2rem);
        gap: 3rem;
        max-width: none;
    }

    & article {
        align-items: stretch;
        gap: 1.5rem;
        max-width: none;

        @media (width > 1200px) {
            flex-direction: row;
            max-width: 120ch;
        }

        & .post-img {
            aspect-ratio: 16 / 9;
            background-color: var(--body-bg);

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

            @media (width <=1200px) {
                & .default-img {
                    display: none;
                }
            }
        }
    }

    @media (width > 1200px) {
        & .content {
            width: 66%;
            padding-bottom: 1rem;
            position: relative;

            &::after {
                display: block;
                content: " ";
                position: absolute;
                top: 1rem;
                inset-inline-end: auto;
                inset-inline-start: -2.5rem;
                width: 0;
                height: 0;
                margin-top: 0;
                border-top: 1rem solid transparent;
                border-bottom: 1rem solid transparent;
                border-right: 1rem solid var(--main-bg);
            }

            .next-post & {
                &::after {
                    inset-inline-end: -3.5rem;
                    inset-inline-start: auto;
                    border-inline-end: 1rem solid transparent;
                    border-inline-start: 1rem solid var(--main-bg);
                }
            }
        }

        & .post-img {
            width: 33%;
            aspect-ratio: auto;

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

                &.default-img {
                    object-fit: contain;
                    object-position: 50% 50%;
                    padding: 1rem;
                }
            }
        }
    }

    @media (width <=1200px) {
        & .content {
            order: 2;
            padding-bottom: 1rem;
        }
    }
}

footer.footer {
    padding-block: 3rem;
    background-color: var(--color-primary);
    color: var(--body-bg);
    text-align: left;

    & .grid {
        --min-col-size: 100%;

        @media (width > 920px) {
            --min-col-size: calc(100% / 3 - 3rem);
        }

        @media (width > 1200px) {
            --min-col-size: calc(100% / 4 - 4rem);
        }
    }

    .rtl & {
        text-align: right;
    }

    @media (prefers-color-scheme: dark) {
        background-color: var(--body-bg);
        color: var(--body-color);
    }

    & h3,
    & h4 {
        color: var(--body-bg);

        @media (prefers-color-scheme: dark) {
            color: var(--body-color);
        }
    }

    & a {
        display: inline;
        color: var(--body-bg);
        background-image: linear-gradient(90deg, var(--main-bg-light), var(--body-bg));
        background-size: 100% 2px;
        background-repeat: no-repeat;
        background-position: center bottom;
        transition: all .15s ease;

        @media (prefers-color-scheme: dark) {
            color: var(--body-color);
            background-image: linear-gradient(90deg, var(--body-color), var(--body-color));
        }

        &:where(:hover, :active, :focus) {
            color: var(--body-bg);
            background-size: 0% 2px;

            @media (prefers-color-scheme: dark) {
                color: var(--color-primary-hover);
            }
        }

        &:has(.logo) {
            background-image: none;
        }

        &.flex {
            display: inline-flex;
            justify-content: start;
            gap: .25rem;
        }
    }

    & ul {
        margin-bottom: 1vw;

        & img {
            filter: invert(1);
        }
    }
}

.event-venue {
    justify-content: start;
    gap: 1ch;

    & a {
        background: none;
    }

    & svg {
        width: 1.5rem;
        height: 1.5rem;
        aspect-ratio: 1 / 1;
    }

    & .apple svg {
        transform: scale(1.2) translateY(-4px);
    }
}

.stretch {
    position: relative;
    width: 100vw !important;
    max-width: none;
    height: auto;
    aspect-ratio: auto !important;
    inset-inline-end: 50%;
    inset-inline-start: 50%;
    margin-inline-end: -50vw !important;
    margin-inline-start: -50vw !important;
    background: none !important;

    & img {
        width: 100%;
        max-height: 66dvh;
        object-fit: cover;
        object-position: 50% 25%;
    }
}

@media (width > 1200px) {
    .stretch-xl {
        position: relative;
        width: 100vw !important;
        max-width: none;
        height: auto;
        aspect-ratio: auto !important;
        inset-inline-end: 50%;
        inset-inline-start: 50%;
        margin-inline-end: -50vw !important;
        margin-inline-start: -50vw !important;
        background: none !important;

        & img {
            width: 100%;
            max-height: 66dvh;
            object-fit: cover;
            object-position: 50% 25%;
        }
    }
}

.searchwp-live-search-results {
    background: transparent !important;
    max-height: 0 !important;
    min-height: auto !important;
    min-width: 0 !important;
    width: 0 !important;
}

.searchwp-live-search-results-showing {
    position: absolute;
    font-size: .75rem;
    width: 305px !important;
    min-width: 305px !important;
    max-height: 300px !important;
    min-height: auto !important;
    overflow: scroll;
    background-color: var(--body-bg) !important;
    color: var(--body-color) !important;
    box-shadow: 0 .5rem 1rem var(--body-color);
    border-radius: .15rem;

    @media (prefers-color-scheme: dark) {
        box-shadow: 0 .5rem 1rem black;
    }

    & .flex {
        align-items: start;
        gap: 1ch;
        line-height: 1.2;
    }

    & a {
        @media (prefers-color-scheme: dark) {
            color: var(--body-color);
        }

        &:is(:hover, :active, :focus) {
            color: var(--color-primary-hover);
        }
    }
}