/*
Theme Name: FHNW Custom Theme
Theme URI: https://www.fhnw.ch/
Author: FHNW
Description: Custom WordPress theme based on the FHNW Design System Version 1.71.0.
Version: 1.0.0
Text Domain: fhnw-theme
Requires at least: 6.3
Requires PHP: 8.0
License: GPL v2 or later
*/

/*
 * Base typography, colours, buttons and components come from fhnw.css (loaded before this file).
 * Only add rules here for markup the design system does not cover, or to work around it.
 * Note: fhnw.css sets  a { color: inherit !important }  and  span { color: #141414 }  globally.
 */

/* ===================== LAYOUT ===================== */
main {
    min-height: 60vh;
}

/* ===================== BREADCRUMB ===================== */
.fhnw-breadcrumb {
    margin-bottom: 0.75rem;
}

/* ===================== BLOG LIST (templates/home.html) ===================== */
.fhnw-post-list .card-title {
    margin-top: 0;
}

.fhnw-post-list .fhnw-post-date {
    margin-bottom: 0.75rem;
    color: #535353;
    font-size: 1rem;
}

.fhnw-post-list .wp-block-query-pagination {
    margin-top: 3rem;
}

/* ===================== FOOTER ===================== */
/* Markup follows the design system's webdienst footer; background and text come from fhnw.css "footer". */

/* fhnw.css styles every <footer> as the black page footer; undo that for footers inside content (e.g. comment meta). */
main footer {
    background-color: transparent;
    color: inherit;
    padding-bottom: 0;
}

footer .tools__footer span {
    color: inherit;
}

footer .webdienst__footer ul.webdienst__footer-list a:hover,
footer .webdienst__footer p a:hover {
    color: #fde52e !important;
}

/* ===================== MAIN NAVIGATION: MEGAMENU (desktop) ===================== */
/* Markup: .nav-item.dropdown.has-megamenu > .dropdown-menu.megamenu (Bootstrap toggles .show on click). */
@media (min-width: 992px) {

    .navbar:has(.has-megamenu > .dropdown-menu.show) {
        background-color: #141414;
    }

    .navbar:has(.has-megamenu > .dropdown-menu.show) .navbar-brand,
    .navbar:has(.has-megamenu > .dropdown-menu.show) .navbar-title,
    .navbar:has(.has-megamenu > .dropdown-menu.show) .navbar-nav .nav-link {
        color: #fff !important;
    }

    .navbar:has(.has-megamenu > .dropdown-menu.show) .navbar-brand img {
        filter: brightness(0) invert(1);
    }

    .navbar:has(.has-megamenu > .dropdown-menu.show) .navbar-nav .nav-link::after {
        border-bottom-color: #fff;
    }

    /* fhnw.css keys the open underline on .nav-item.show, but Bootstrap 5 puts .show on the toggle. */
    .navbar-nav .nav-item .nav-link.show::after {
        width: calc(100% - 2rem);
    }

    .navbar-nav .nav-item:first-child .nav-link.show::after {
        width: calc(100% - 1rem);
    }

    .navbar .dropdown-menu.fhnw-megamenu {
        background-color: #141414;
        color: #fff;
        border: 0;
        border-radius: 0;
        padding: 4rem 0 5rem;
        max-height: 85vh;
        overflow-y: auto;
    }

    .fhnw-megamenu__inner {
        display: flex;
        align-items: flex-start;
        gap: 5rem;
        padding: 0 1.25rem;
    }

    .fhnw-megamenu__close {
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 72px;
        height: 72px;
        border: 0;
        border-radius: 50%;
        background-color: #fde52e;
        color: #000;
        cursor: pointer;
    }

    .fhnw-megamenu__close .icn {
        font-size: 1.75rem;
    }

    .fhnw-megamenu__close:hover {
        background-color: #e9d32a;
    }

    .fhnw-megamenu__close:focus-visible {
        outline: 2px solid #fff;
        outline-offset: 2px;
    }

    .fhnw-megamenu__sections,
    .fhnw-megamenu__links {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .fhnw-megamenu__sections {
        flex: 1 1 auto;
        max-width: 61rem;
    }

    .fhnw-megamenu__sections li {
        margin: 0;
    }

    .fhnw-megamenu__section + .fhnw-megamenu__section {
        margin-top: 4rem;
    }

    .navbar .fhnw-megamenu a {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        margin: 0;
        color: #fff;
        text-decoration: none;
    }

    .navbar .fhnw-megamenu .fhnw-megamenu__heading {
        font-size: clamp(2rem, 3.5vw, 3.5rem);
        font-weight: 700;
        line-height: 1.15;
        padding: 0 0 1.5rem;
    }

    .navbar .fhnw-megamenu .fhnw-megamenu__link {
        font-size: 1.3rem;
        font-weight: 400;
        line-height: 1.5;
        padding: 0.9rem 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    }

    .navbar .fhnw-megamenu a .icn {
        flex-shrink: 0;
        font-size: 1rem;
        color: #fde52e;
    }

    .navbar .fhnw-megamenu a:hover,
    .navbar .fhnw-megamenu a:focus-visible {
        color: #fde52e !important;
    }

    .navbar .fhnw-megamenu a:focus-visible {
        outline: 2px solid #fde52e;
        outline-offset: 2px;
    }
}

/* ===================== MAIN NAVIGATION: OFFCANVAS (mobile) ===================== */
/* Base styling comes from fhnw.css (.offcanvas-mainnav, __entry, __sub); only nested headings are added. */
.offcanvas.offcanvas-mainnav .offcanvas-mainnav__sub a:hover,
.offcanvas.offcanvas-mainnav .offcanvas-mainnav__sub a:focus-visible {
    color: #fde52e !important;
}

.offcanvas.offcanvas-mainnav .offcanvas-mainnav__sub .fhnw-oc-heading {
    margin: 1rem 0 0;
}

.offcanvas.offcanvas-mainnav .offcanvas-mainnav__sub .fhnw-oc-heading a {
    font-size: 1.35rem;
    font-weight: 700;
    border-bottom: 0;
}

.offcanvas.offcanvas-mainnav .offcanvas-mainnav__sub.fhnw-oc-nested {
    padding: 0 0 0.5rem;
}

/* ===================== CONSENT: COOKIE BANNER & VIDEO PLACEHOLDER ===================== */
/* fhnw.css hides the banner only visually; also remove it from the tab order and accessibility tree. */
.cookiealert:not(.show) {
    visibility: hidden;
}

.fhnw-video {
    position: relative;
    min-height: 16rem;
    background-color: #141414;
    color: #fff;
}

/* Inside WordPress's aspect-ratio wrapper, fill the space it reserves. */
.wp-has-aspect-ratio .fhnw-video {
    position: absolute;
    inset: 0;
    min-height: 0;
}

.fhnw-video iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.fhnw-video__consent {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 1rem;
    padding: 2rem;
    overflow: auto;
}

.fhnw-video__consent p {
    margin: 0;
    color: #fff;
    font-size: 1rem;
}

.fhnw-video__consent .fhnw-video__title {
    font-size: 1.2rem;
    font-weight: 700;
}

/* ===================== KEYBOARD FOCUS ===================== */
/* fhnw.css focus styles are too faint (nav links: 25% yellow glow) or removed (.btn: outline 0). */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.wp-element-button:focus-visible,
.navbar-nav .nav-link:focus-visible {
    outline: 2px solid #141414 !important;
    outline-offset: 2px;
    box-shadow: none !important;
}

/* White on dark backgrounds. */
footer :focus-visible,
.cookiealert :focus-visible,
.fhnw-video :focus-visible,
.fhnw-megamenu__close:focus-visible,
.navbar:has(.has-megamenu > .dropdown-menu.show) .navbar-nav .nav-link:focus-visible {
    outline-color: #fff !important;
}

/* Yellow inside the dark menus, as fhnw.css does there. */
.fhnw-megamenu a:focus-visible,
.offcanvas-mainnav :focus-visible {
    outline-color: #fde52e !important;
}

/* The dropdown toggle is a <button>: give it the link colour (links inherit via fhnw.css, buttons don't). */
.navbar-nav .nav-item button.nav-link {
    color: inherit;
}

/* ===================== COOKIE BANNER ON SMALL SCREENS ===================== */
@media (max-width: 575.98px) {

    .cookiealert p.p-4 {
        padding: 0.75rem 0 !important;
        font-size: 1rem;
    }
}

/* ===================== PRINT ===================== */
@media print {

    header.wp-block-template-part,
    footer.wp-block-template-part,
    .navbar-dock,
    .offcanvas {
        display: none !important;
    }
}
