/*
 * Bilköparguiden – site styles
 *
 * Plain CSS, no build step: edit this file directly.
 * Article body typography (headings, paragraphs, lists, photo credits,
 * CKEditor 5 images/tables/embeds) lives in article.css, which the admin
 * editor shares so editors see what readers see.
 *
 * Rule order matters where selectors have equal specificity; media queries
 * sit directly after the section they belong to.
 *
 * Breakpoints: 600px (phone/desktop helpers), 800px (teaser grids),
 * 1140px (full layout).
 */

:root {
    --bil-green: #326750;
    --bil-blue: #189ADB;
    --bil-black: #000000;
    --white: #FFFFFF;
    --text: #333333;
    --muted: #707070;
    --page-background: #F9F9F9;
}


/* ==========================================================================
   Base
   ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Poppins", sans-serif !important;
}

body {
    background-color: var(--page-background);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-y: scroll;
}

header,
footer,
main {
    width: 100%;
    max-width: 1140px;
    margin: 0 auto;
}

main {
    padding: 0 10px;
}

@media screen and (min-width: 1140px) {
    main {
        padding: 0;
    }
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

*:focus-visible {
    outline: var(--bil-blue) auto 1px;
    outline-offset: 5px;
}


/* ==========================================================================
   Header and footer (shared)
   ========================================================================== */

header,
footer {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    background-color: var(--bil-green);
    padding: 10px 20px;
}

header ul,
footer ul {
    list-style-type: none;
    display: flex;
    flex-direction: column;
}

header li,
header li a,
header h5,
footer li,
footer li a,
footer h5 {
    color: var(--white);
    font-weight: 500;
    font-style: normal;
    font-size: 16px;
    text-decoration: none;
}

header label,
header label a,
footer label,
footer label a {
    color: var(--white);
    font-weight: 500;
    font-style: normal;
    font-size: 14px;
}

header input,
footer input {
    padding: 5px 10px;
    border-top-left-radius: 2px;
    border-bottom-left-radius: 2px;
    border: none;
}


/* ==========================================================================
   Header, navigation and mobile menu
   ========================================================================== */

header {
    align-items: center;
    padding: 20px 20px 10px 20px;
}

header nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Collapsed on mobile; opened by the #menucheck checkbox (see below). */
header nav ul {
    gap: 10px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 250ms ease-in-out;
}

header nav ul li {
    text-align: center;
}

header nav ul li:first-child a {
    display: inline-block;
}

header nav ul li a {
    font-size: 20px;
}

header nav ul li:last-child:after {
    content: "";
    height: 10px;
    display: block;
}

header nav img {
    max-width: 240px;
}

/* Hamburger menu: a hidden checkbox toggled by the #menuswitch label. */
header #menucheck {
    display: none;
}

header #menucheck:checked ~ label span {
    background-color: var(--bil-green);
}

header #menucheck:checked ~ label span:before {
    transform: rotate(45deg);
}

header #menucheck:checked ~ label span:after {
    transform: rotate(-45deg);
}

header #menucheck:checked ~ nav ul {
    max-height: 250px;
}

header #menuswitch {
    position: absolute;
    top: 20px;
    right: 20px;
    height: 32px;
    width: 40px;
    display: flex;
    justify-content: space-between;
    flex-direction: column;
    cursor: pointer;
}

header #menuswitch span {
    background-color: var(--white);
    height: 8px;
    display: inline-block;
    border-radius: 4px;
    transition: background-color 125ms ease-in-out;
}

header #menuswitch span:nth-child(2) {
    position: relative;
}

header #menuswitch span:nth-child(2):before,
header #menuswitch span:nth-child(2):after {
    content: "";
    position: absolute;
    height: 8px;
    width: 100%;
    border-radius: 4px;
    background-color: var(--white);
    transform: rotate(0deg);
    transition: transform 125ms ease-in-out;
}

@media screen and (min-width: 1140px) {
    header {
        align-items: flex-start;
        padding: 20px;
    }

    header nav {
        flex-direction: row;
        gap: 20px;
        width: 100%;
        align-items: center;
    }

    header nav ul {
        width: 100%;
        max-height: unset;
    }

    header nav ul li:last-child {
        margin-left: auto;
    }

    header nav ul li:last-child:after {
        display: none;
    }

    header nav img {
        max-width: 190px;
    }

    header #menuswitch {
        display: none;
    }

    header,
    footer {
        flex-direction: row;
        align-items: center;
        gap: 0;
    }

    header nav ul,
    footer nav ul {
        flex-direction: row;
        align-items: center;
        gap: 20px;
    }

    header nav ul li:first-child a,
    footer nav ul li:first-child a {
        display: block;
    }

    header nav ul li a,
    footer nav ul li a {
        font-size: 16px;
    }
}

header {
    margin-bottom: 10px;
}


/* ==========================================================================
   Footer
   ========================================================================== */

footer {
    padding: 20px 25px 25px 25px;
    margin-top: auto;
}

footer ul {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
}

footer input {
    border-radius: 2px;
    width: 100%;
}


/* ==========================================================================
   Forms and buttons
   ========================================================================== */

.checkbox-container {
    padding: 10px 0;
    display: grid;
    grid-template-columns: 15px 1fr;
    gap: 5px;
    align-items: baseline;
}

button,
input[type=submit] {
    color: var(--white);
    background-color: var(--bil-blue);
    border: 0;
    border-radius: 2px;
    font-size: 16px;
    font-weight: 500;
    font-style: normal;
    padding: 5px 20px;
    float: right;
}


/* ==========================================================================
   Search form (in the header)
   ========================================================================== */

#search-form {
    display: grid;
    grid-template-columns: 200px 40px;
    align-items: center;
    height: 30px;
    border-radius: 2px;
    overflow: hidden;
}

#search-form:focus-within {
    outline: 1px solid var(--bil-blue);
}

#search-form input[type=search] {
    grid-column: 1/-1;
    grid-row: 1;
    border-radius: 2px;
}

#search-form button {
    background-color: var(--bil-blue);
    height: 30px;
    display: grid;
    justify-content: center;
    align-items: center;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 2px;
    border-bottom-right-radius: 2px;
    grid-row: 1;
    grid-column: 2;
    cursor: pointer;
}


/* ==========================================================================
   Home page grids
   ========================================================================== */

/* Three top teasers: one large, two stacked on the right (desktop). */
#indexhero {
    display: grid;
    grid-column-gap: 0px;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    margin-bottom: 30px;
    gap: 10px;
}

#indexhero .puff {
    box-shadow: none;
}

@media screen and (min-width: 1140px) {
    #indexhero {
        grid-template-columns: 2fr 1fr;
        grid-template-rows: 1fr;
        margin-bottom: 10px;
        gap: 0;
    }

    #indexhero > :nth-child(1) {
        grid-column: 1;
        grid-row: 1/span 2;
    }

    #indexhero > :nth-child(2) {
        grid-column: 2;
        grid-row: 1;
    }

    #indexhero > :nth-child(3) {
        grid-column: 2;
        grid-row: 2;
    }

    #indexhero > :nth-child(2),
    #indexhero > :nth-child(3) {
        padding-left: 10px;
    }
}

#indexpuffsgrid {
    display: grid;
    gap: 30px;
    grid-template-columns: 1fr;
}

@media screen and (min-width: 1140px) {
    #indexpuffsgrid {
        gap: 10px;
        grid-template-columns: 1fr 1fr;
    }

    #indexpuffsgrid > .indexpuffs:nth-child(1) {
        grid-template-columns: 1fr 1fr;
    }
}


/* ==========================================================================
   Teaser lists (home, related articles, category, search)
   ========================================================================== */

.indexpuffs,
.articlepuffs,
.categorypuffs {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
    grid-template-rows: 40px;
    grid-auto-rows: 1fr;
    height: fit-content;
}

/* List heading bar, e.g. "Senaste nytt" */
.indexpuffs h5,
.articlepuffs h5,
.categorypuffs h5 {
    background-color: var(--bil-green);
    grid-column: 1/-1;
    padding: 0 10px;
    color: var(--white);
    font-weight: 500;
    font-style: normal;
    font-size: 18px;
    line-height: 40px;
}

@media screen and (min-width: 800px) {
    .indexpuffs.puff-type-rows .puff,
    .articlepuffs.puff-type-rows .puff,
    .categorypuffs.puff-type-rows .puff {
        grid-template-columns: 1fr 1fr;
    }
}


/* ==========================================================================
   Teaser card (.puff, template_parts/puff.html)
   ========================================================================== */

.puff {
    display: grid;
    grid-template-columns: 1fr;
    align-items: flex-start;
    grid-template-rows: min-content;
    box-shadow: inset 0px 0px 1px var(--muted);
}

.puff > div {
    position: relative;
}

.puff > div:first-child {
    aspect-ratio: 2/1;
    overflow: hidden;
}

.puff > div:last-child {
    padding: 20px;
}

.puff .sponsored,
.puff .label-over-photo {
    position: absolute;
    top: 0;
    left: 0;
    padding: 2px 10px;
    background-color: var(--bil-blue);
    color: var(--white);
}

.puff .sponsored {
    top: unset;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
}

.puff h4,
.puff h4 a {
    font-weight: 500;
    font-style: normal;
    font-size: 18px;
    line-height: 22px;
    text-decoration: none;
    color: var(--bil-black);
}

.puff p {
    margin-top: 10px;
    font-size: 14px;
}

/* Publish date, on teasers and articles */
.published {
    font-weight: 400;
    font-style: normal;
    font-size: 12px;
    line-height: 12px;
    color: var(--muted) !important;
    display: block;
    padding-top: 10px;
    text-transform: uppercase;
}

/* Large teasers (home top, first on a category page): text over the image */
#indexhero .puff,
.categorypuffs > div:nth-child(1) {
    align-items: flex-end;
}

#indexhero .puff > div,
.categorypuffs > div:nth-child(1) > div {
    grid-row: 1;
    grid-column: 1;
}

#indexhero .puff > div:first-child,
.categorypuffs > div:nth-child(1) > div:first-child {
    position: relative;
}

#indexhero .puff > div:first-child::after,
.categorypuffs > div:nth-child(1) > div:first-child::after {
    content: "";
    position: absolute;
    top: 40%;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: linear-gradient(0, rgba(0, 0, 0, 0.9), transparent);
    pointer-events: none;
}

#indexhero .puff > div:last-child,
.categorypuffs > div:nth-child(1) > div:last-child {
    pointer-events: none;
}

#indexhero .puff h4,
#indexhero .puff h4 a,
#indexhero .puff span,
.categorypuffs > div:nth-child(1) h4,
.categorypuffs > div:nth-child(1) h4 a,
.categorypuffs > div:nth-child(1) span {
    color: var(--white) !important;
}

#indexhero p,
.indexpuffs p {
    display: none;
}

.articlepuffs {
    grid-template-columns: 1fr;
}

.articlepuffs .published {
    display: none;
}

@media screen and (min-width: 800px) {
    .articlepuffs {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

.categorypuffs {
    grid-template-rows: auto;
    grid-template-columns: 1fr;
}

.categorypuffs > div:nth-child(1) {
    grid-column: 1/-1;
}

.categorypuffs > div:nth-child(1) p {
    display: none;
}

@media screen and (min-width: 1140px) {
    .categorypuffs {
        grid-template-columns: 1fr 1fr;
    }
}


/* ==========================================================================
   Page heading and article page chrome
   (article body typography: see article.css)
   ========================================================================== */

h1 {
    color: var(--text);
    font-size: 40px;
    line-height: 48px;
    font-weight: 500;
    margin-bottom: 10px;
}

article h1 {
    clear: both;
    margin-bottom: 16px;
}

article .published {
    float: right;
}

article .article-social {
    border-top: 1px solid grey;
    padding: 20px 0 30px 0;
    margin-top: 20px;
    display: grid;
    grid-template-columns: 30px 30px 30px;
    gap: 20px;
}

article .article-social img {
    height: 30px;
}

/* Readable text column */
.article-content {
    max-width: 800px;
    margin: 0 auto;
}


/* ==========================================================================
   Pagination
   ========================================================================== */

.pagination {
    padding: 30px 0;
    display: grid;
    grid-template-columns: 40px auto 40px;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 20px;
}

.pagination div span,
.pagination div span a {
    font-weight: 400;
    font-style: normal;
    font-size: 18px;
    line-height: 18px;
}

.pagination a,
.pagination span {
    background-color: var(--bil-blue);
    color: var(--white);
    text-decoration: none;
    border-radius: 20px;
    height: 40px;
    width: 40px;
    line-height: 40px;
    font-size: 30px;
    display: block;
}

.pagination a.disabled,
.pagination span.disabled {
    background-color: grey;
}


/* ==========================================================================
   Newsletter sign-up
   ========================================================================== */

#register-form input[type=email] {
    width: 400px;
    max-width: 100%;
    padding: 5px 10px;
    margin-top: 5px;
    margin-bottom: 10px;
}

#register-form input[type=submit] {
    float: unset;
    cursor: pointer;
}


/* ==========================================================================
   Banners
   ========================================================================== */

.bannercontainer {
    margin-bottom: 10px;
}

.bannercontainer img {
    width: 100%;
}


/* ==========================================================================
   Error pages (404.html; 500.html is standalone and repeats these values
   inline, so keep the two in step)
   ========================================================================== */

.error-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 30px 0 40px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
}

.error-page .error-code {
    color: var(--bil-green);
    font-size: 96px;
    line-height: 1;
    font-weight: 700;
}

.error-page h1 {
    margin-bottom: 0;
}

.error-page p {
    color: var(--text);
    font-size: 16px;
    line-height: 1.6;
}

/* Tap targets are 48px high. */
.error-search {
    width: 100%;
    max-width: 480px;
}

.error-search form {
    display: flex;
    flex-direction: column;
    gap: 5px;
    text-align: left;
}

.error-search label {
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
}

.error-search form > div {
    display: flex;
}

.error-search input[type=search] {
    flex: 1;
    min-width: 0;
    min-height: 48px;
    padding: 0 15px;
    font-size: 16px;
    color: var(--text);
    background-color: var(--white);
    border: 1px solid var(--muted);
    border-right: 0;
    border-radius: 2px 0 0 2px;
}

.error-search button {
    float: none;
    min-height: 48px;
    padding: 0 25px;
    border-radius: 0 2px 2px 0;
    cursor: pointer;
}

.error-button {
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    padding: 0 25px;
    color: var(--white);
    background-color: var(--bil-green);
    border-radius: 2px;
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;
}

.error-button:hover {
    text-decoration: underline;
}

.error-latest {
    margin-bottom: 30px;
}


/* ==========================================================================
   Utilities
   ========================================================================== */

.hidden-phone {
    display: none;
}

@media screen and (min-width: 600px) {
    .hidden-desktop {
        display: none;
    }

    .hidden-phone {
        display: block;
    }
}

/* Hidden visually, still read by screen readers and search engines. */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}
