:root {
    --max-width-narrow: 600px;
    --max-width: 900px;
}

body {
    font-family: "Open Sans", "Helvetica Neue", sans-serif;
    letter-spacing: 1%;
    line-height: 1.3;
    font-size: 14px;
}

h1,
h2,
h3,
h4,
h5 {
    /*font-family: "Times New Roman", Times, serif;*/
    font-family: Georgia, "Times New Roman", Times, serif;
}

hr {
    height: 1px;
    background-color: #ddd;
    border: none;
}

header {
    width: 100%;
    max-width: var(--max-width-narrow);
    margin-inline: auto;
    padding-inline: 16px;
    margin-block: 64px;
}

a {
    color: inherit;
    text-underline-offset: 3px;
    display: inline-block;

    transition: all 0.2s ease;
    &:hover {
        scale: 1.01;
        text-underline-offset: 4px;
    }
    &:active {
        text-underline-offset: 2px;
    }
}

nav {
    width: 100%;
    max-width: var(--max-width-narrow);
    margin-inline: auto;
    padding-inline: 16px;
    padding-block: 16px;
    position: sticky;
    top: 0;

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

    & > div {
        display: flex;
        align-items: center;
        gap: 8px;
        /*font-size: 1.1rem;*/
    }

    .active {
        text-underline-offset: 6px;
        text-decoration-thickness: 5px;
        text-decoration-skip-ink: none;
        text-decoration-color: #ccc;
    }
}

main {
    padding: 32px;
    width: 100%;
    max-width: var(--max-width);
    margin-inline: auto;
}

article {
    padding-block: 20px;
    border-bottom: 1px solid #eee;

    display: grid;
    grid-template-columns: 1fr 140px;
    gap: 12px;

    blockquote {
        border-left: 3px solid lightgray;
        padding-left: 12px;
        margin-left: 12px;
    }

    .content {
        .timestamp {
            display: block;
            margin-bottom: 0.5rem;
        }
    }

    .source {
        display: flex;
        flex-direction: column;
        height: 100%;
        width: 100%;
        overflow: hidden;
        font-size: 0.7rem;
        opacity: 0.9;
        align-items: start;
        padding: 4px;

        img {
            max-width: 90px;
            width: 100%;
            max-height: 90px;
            object-fit: cover;
            flex-shrink: 1;
            border-radius: 12px;
            aspect-ratio: 1;
        }
    }

    .tags {
        display: flex;
        gap: 4px;
        align-items: center;

        .tag {
            font-size: 0.8rem;
            padding: 2px 4px;
            border-radius: 6px;
            background: #eee;

            &[data-published-by] {
                background: #333;
                color: white;
            }
        }
    }
}

.expandable-wrapper {
    position: relative;

    .expand-toggle {
        display: none;
    }

    .expandable-content {
        height: 150px;
        overflow: hidden;
        transition: height 0.3s ease-in-out;
        position: relative;
    }

    &.no-expand .expandable-content::after {
        display: none;
    }

    /* fade-out gradient at the bottom when collapsed */
    .expandable-content::after {
        content: "";
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 80px;
        background: linear-gradient(to bottom, transparent, #fffa 50%, #fff);
        pointer-events: none;
        transition: opacity 0.3s;
    }

    .expand-toggle:checked ~ .expandable-content {
        height: calc-size(auto, size);
    }
    .expand-toggle:checked ~ .expandable-content::after {
        opacity: 0;
    }

    .show-more-btn {
        display: inline-block;
        margin-top: 10px;
        padding: 8px 16px;
        border: 1px solid #eee;
        border-radius: 4px;
        cursor: pointer;
        user-select: none;
        font-size: 0;
    }

    &.no-expand .show-more-btn {
        display: none;
    }

    .expand-toggle:checked ~ .show-more-btn::before {
        content: "Visa mindre";
    }

    .expand-toggle:not(:checked) ~ .show-more-btn::before {
        content: "Visa mer";
    }

    .show-more-btn::before {
        font-size: 14px;
    }
}

.loader {
    display: block;
    margin-inline: auto;
    height: 35px;
    aspect-ratio: 1;
    background: #7779;
    opacity: 0;
    animation:
        loader 0.8s infinite alternate,
        appear 0.5s linear 0.25s forwards;
}

@keyframes appear {
    to {
        opacity: 1;
    }
}

@keyframes loader {
    0% {
        clip-path: polygon(
            50% 0%,
            48% 52%,
            100% 50%,
            74% 76%,
            50% 100%,
            48% 52%,
            0% 50%,
            26% 24%
        );
    }
    100% {
        clip-path: polygon(
            50% 0%,
            76% 26%,
            100% 50%,
            49% 53%,
            50% 100%,
            21% 71%,
            0% 50%,
            49% 52%
        );
    }
}
