@font-face {
    font-family: 'paragraph';
    src: url('fonts/montserrat-latin-500-normal.woff2') format('woff');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'bold';
    src: url('fonts/montserrat-latin-700-normal.woff2') format('woff');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'heading';
    src: url('fonts/CormorantGaramond-Medium.woff2') format('woff2');
    font-weight: 500; /* Medium is typically 500 */
    font-style: normal;
    font-display: swap;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: paragraph;
    font-size: 1.0rem;
}

h1 {
    position: absolute;
    overflow: hidden;
    width: 0;
    height: 0;
}

h2 {
    font-family: heading;
    font-size: 2.0rem;
    margin-top: 12px;
    margin-bottom: 12px;
    display: inline-block;
}

h3 {
    font-family: heading;
    font-size: 1.5rem;
    margin-top: 32px;
}

h4 {
    font-family: heading;
    font-size: 1.15rem;
    margin-top: 16px;
}

p {
    font-family: paragraph;
}

ul {
    padding-left: 24px;
}

#pageWrapper {
    display: flex;
    flex-direction: column;
    margin: auto;
    width: min(960px, 100%);
}

#pageHeader {
    position: relative; /* Added for mobile menu fallback positioning */
    height: auto;
    display: flex;
    flex-direction: row;
    gap: 8px;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
}

#headerLogo {
    height: 80px;
}

/* MOBILE MENU */
#hamburgerButton {
    width: 180px;
    height: 48px;
    margin-right: 16px;
    border: none;
    background-color: #ffffff00;
    border-bottom: 2px solid #cfcfcf;
    border-top: 2px solid #cfcfcf;

    anchor-name: --hamburger;
}

#mobileMenu {
    width: 180px;
    
    /* Standard Absolute Positioning Fallback for older browsers */
    position: absolute;
    top: 90px;
    right: 16px;
    z-index: 1000;

    border-radius: 3px;
    background-color: #efefefaa;
    backdrop-filter: blur(16px);
    border: 0;
    height: max-content;
    max-height: none;
    overflow: hidden;
    
    font-family: bold;
}

/* Fallback visibility classes applied by our script if Popover isn't supported */
.no-popover #mobileMenu {
    display: none;
}
.no-popover #mobileMenu.fallback-open {
    display: block;
}

/* Only apply cutting-edge anchor positioning if the browser supports it */
@supports (position-anchor: --hamburger) {
    #mobileMenu {
        position-anchor: --hamburger;
        top: anchor(bottom);
        left: anchor(left);
        margin-top: 8px;
        right: auto; /* Resets the fallback right align */
    }
}

#mobileMenu ul {
    padding: 0;
    list-style-type: none;
}

#mobileMenu a {
    padding: 8px 12px;
    text-decoration: none;
}

#mobileMenu a:hover {
    color: #393939;
}

#mobileMenu:popover-open {
    opacity: 1;
    transform: translateY(0);
}

@starting-style {
    #mobileMenu:popover-open {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* DESKTOP MENU */
#desktopMenu {
    display: none;
    flex-direction: row;
    gap: 8px;
}

#desktopMenu ul {
    display: flex;
    flex-direction: row;
    list-style-type: none;
}

#desktopMenu a {
    padding: 8px 12px;
}

a, a:link, a:active, a:visited {
    color: #363636;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
    display: inline-block;
    font-weight: bold;
}

a:hover {
    color: #131313;
}

/* SECTION HEADERS */
.section-header {
    position: relative;
    height: 320px;
}

.section-header img {
    position: absolute;
    border-radius: 0px;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bg-right {
    object-position: right center;
}

.caption {
    display: inline-block;
    position: absolute;

    margin-top: 16px;
    margin-left: 16px;
    color: #333333;
    font-family: heading;
    font-weight: bold;
    font-style: italic;
    text-shadow: 1px 1px 3px #ffffff;
    font-size: min(1.3rem, 2.0rem);
}

.width-narrow {
    width: min(280px, 40%);
}

.width-wide {
    width: min(480px, 50%);
}

.bottom {
    bottom: 16px;
}

.right {
    right: 16px;
}

/* SECTION ARTICLES */
article {
    margin: 16px;
    margin-top: 32px;
}

article img {
    border-radius: 8px;
    margin-left: 16px;
    float: right;
    width: min(100%, 180px);
}

article p {
    margin-top: 8px;
}


/* Details */
details {
    padding-left: 12px;
    margin-top: 8px;
    padding-top: 4px;
    padding-bottom: 4px;
}

details summary {
    font-size: 1.15rem;
    cursor: pointer;
}


/* Soita ja kysy lisää */
#soita {
    font-family: heading;
    font-size: 1.5rem;
    height: 64px;

    display: flex;
    justify-content: center;
    align-items: center;
}


iframe {
    width: 320px;
    margin-top: 32px;
    border-radius: 8px;
    border: 1px solid #afafaf;
    overflow: hidden;
}

small {
    margin-bottom: 32px;
}


/* GENERIC FLEX CONTAINER */
.flex {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    height: auto;
    
    align-items: center;
}

.flex-column {
    width: 320px;
    flex-grow: 0;
}


#yhteystiedot article {
    text-align: center;
}



/* FOOTER */
footer {
    display: flex;
    flex-direction: column;
    margin-top: 16px;
    justify-content: center;
    align-items: center;

    background: #4fcdff;

    padding: 16px;
}

footer p {
    margin-top: 0;
}

/* --- RESPONSIVE FIXES --- */

/* Fix for H3 tags not dropping below floated images on narrow screens */
@media (max-width: 768px) {
    article h2, article h3 {
        display: block;
        clear: both;
        width: 100%;
        margin-top: 16px;
    }

    article img {
        float: left;
        margin-left: 0;
        margin-bottom: 8px;
    }
}

@media (min-width: 1200px) {
    #hamburgerButton, #mobileMenu {
        display: none;
    }

    #desktopMenu {
        display: block;
    }

    #sectionHeader img, footer {
        border-radius: 8px;
    }

    .flex {
        flex-direction: row;
        justify-content: center;
    }

    footer {
        flex-direction: row;
        gap: 16px;
    }

}