:root {
    color-scheme: light dark;

    @media screen {
        &[data-settings-theme="light"] {
            color-scheme: only light;
        }

        &[data-settings-theme="dark"] {
            color-scheme: only dark;
        }
    }

    --accent: light-dark(#B94E36, #EF911F);
    --background-light: #F3F6F9;
    --background-dark: #0F191F;

    --background: light-dark(var(--background-light), var(--background-dark));
    --background-80: color-mix(in srgb, var(--background) 80%, transparent);
    --background-80: color-mix(in srgb, var(--background) 80%, transparent);
    --background-60: color-mix(in srgb, var(--background) 60%, transparent);
    --background-40: color-mix(in srgb, var(--background) 40%, transparent);
    --background-20: color-mix(in srgb, var(--background) 20%, transparent);
    --background-05: color-mix(in srgb, var(--background)  5%, transparent);
    --background-secondary: light-dark(
        color-mix(in srgb, var(--background) 95%, #000),
        color-mix(in srgb, var(--background) 95%, #FFF)
    );

    --foreground-light: #0F191F;
    --foreground-dark: #F3F6F9;

    --foreground: light-dark(var(--foreground-light), var(--foreground-dark));
    --foreground-80: color-mix(in srgb, var(--foreground) 80%, transparent);
    --foreground-60: color-mix(in srgb, var(--foreground) 60%, transparent);
    --foreground-40: color-mix(in srgb, var(--foreground) 40%, transparent);
    --foreground-20: color-mix(in srgb, var(--foreground) 20%, transparent);
    --foreground-10: color-mix(in srgb, var(--foreground) 10%, transparent);
    --foreground-05: color-mix(in srgb, var(--foreground)  5%, transparent);

    --gradient-color: light-dark(#DCEBF2, #142C2C);
    --gradient-start: color-mix(in srgb, var(--gradient-color) 60%, #FFF);
    --gradient-end: color-mix(in srgb, var(--gradient-color) 95%, #000);
    --gradient: linear-gradient(to bottom, var(--gradient-start), var(--gradient-end));
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100vw;
    min-height: 100vh;
    
    background-color: var(--background);
    color: var(--foreground);
    
    font-family: 'Open Sans', sans-serif;
    font-size: 16px;
}

body {
    display: flex;
    flex-direction: column;
}

.constrained {
    margin: 0 auto;
    padding: 0 1.5rem;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    container-type: inline-size;
}

.narrow {
    max-width: 42rem;
}

.wide {
    max-width: 64rem;
}

@property --angle {
  syntax: "<angle> | <zero>";
  inherits: true;
  initial-value: 0;
}

.gutters {
    max-width: 64rem;
    display: grid;
    grid-template-columns:
        [full-start pull-left-start left-start]
        1fr
        [left-end pull-right-start center-start]
        min(42rem, 100%)
        [center-end pull-left-end right-start]
        1fr
        [right-end pull-right-end full-end];

    > *,
    .centered {
        grid-column: center;
    }

    @media (min-width: 42rem) {
        .pull-left {
            grid-column: pull-left;

            &[data-angle] {
                --angle: attr(data-angle deg);
            }

            .photo {
                width: 16.5rem;
                float: left;
                margin-left: 0;
                margin-right: 2rem;
                transform: rotate(var(--angle, -1deg));

                ~ * {
                    margin-left: 18.75rem;
                }
            }
        }
        
        .pull-right {
            grid-column: pull-right;

            &[data-angle] {
                --angle: attr(data-angle deg);
            }

            .photo {
                width: 16.5rem;
                float: right;
                margin-left: 2rem;
                margin-right: 0;
                transform: rotate(var(--angle, 1deg));

                ~ * {
                    margin-right: 18.75rem;
                }
            }
        }
    }

    .full {
        display: grid;
        grid-template-columns: subgrid;
        grid-column: full;
    }
}

.photo {
    max-width: 25rem;
    width: 100%;
    margin: 0 auto 1.5rem;
    padding: 0.75rem;
    box-sizing: border-box;
    border: solid 0.1rem #0002;
    aspect-ratio: 10/11;
    background-color: #FFF;
    border-radius: 0.25rem;
    display: grid;
    grid-template-columns: auto;
    grid-template-rows: min-content auto;
    align-content: space-between;
    box-shadow: 0 0.25rem 0.2rem #0001, inset 0 0 2rem #28221d33;

    img,
    &::after {
        display: block;
        width: 100%;
        grid-row: 1;
        grid-column: 1;
        border-radius: 0.125rem;
    }

    img {
        object-fit: cover;
        aspect-ratio: 1/1;
    }

    figcaption {
        color: var(--foreground-light);
        font-family: Caveat, sans-serif;
        text-align: center;
        margin-top: 0.5rem;
        font-size: 1.2rem;
    }

    &::after {
        content: "";
        display: block;
        box-shadow: inset 0 0 3rem #0009;
    }
}

h1, h2, h3, h4, h5, h6 {
    font-family: Montserrat, sans-serif;
}

p {
    margin: 0 0 1rem;
    line-height: 1.75rem;
}

a[href] {
    color: inherit;
    text-underline-offset: 0.25rem;

    &:hover,
    &:focus-visible {
        color: var(--accent);
    }

    &.action {
        display: flex;
        border: solid 0.1rem currentColor;
        border-radius: 0.5rem;
        margin: 0 -0.5rem 1rem;
        padding: 0.5rem;
        gap: 0.5rem;
        align-items: center;
        background: var(--foreground-05);
        font-weight: bold;
        text-decoration: none;

        svg {
            stroke: currentColor;
            fill: currentColor;
        }

        .icon {
            max-width: 2rem;
            order: -1;
        }
    }
}

a[href]:focus-visible,
button:focus-visible {
    outline: dashed 0.2rem var(--accent);
    outline-offset: 0.25rem;
}

ul.info {
    margin: 0;
    line-height: 1.75rem;

    li {
        margin-bottom: 1.5rem;
        break-inside: avoid-column;
        list-style-type: "ℹ️  ";

        ul {
            margin-top: 0;
            padding-left: 1.25rem;
        }

        li {
            margin-bottom: 0;
            position: relative;
        }

        &.government {
            list-style-type: "🏛️  ";
        }

        &.group {
            list-style-type: "👥  ";
        }

        &.person,
        &.group li {
            list-style-type: "👤  ";
        }
        
        &.orgs {
            list-style-type: "📂  ";
        }

        &.library {
            list-style-type: "📚  ";
        }

        &.outdoor {
            list-style-type: "🌿  ";
        }
    }
}

.skip-link {
    display: block;
    position: absolute;
    top: -100rem;
    left: -100rem;
    z-index: 999;
    background-color: var(--background);

    &[href]:focus {
        position: fixed;
        top: 4.125rem;
        left: 50%;
        translate: -50% -50%;
        padding: 1rem 2rem;
        outline-offset: -0.5rem;
        border-radius: 0.5rem;
        text-decoration: none;
        border: solid 1px var(--foreground);
        box-shadow: var(--shadow);
        box-sizing: border-box;
    }
}

:target {
    scroll-margin-block: 7.5rem;
    position: relative;

    &::before {
        content: "↦";
        position: absolute;
        right: calc(100% + 0.5rem);
        top: 0;
        padding-top: inherit;
        line-height: inherit;
        color: var(--accent);
    }

    &:focus {
        outline: none;

        &::after {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            pointer-events: none;
            outline: double 0.25rem var(--accent);
            outline-offset: -0.5rem;
        }
    }
}

body:has(.skip-link[href]:focus)::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--background-dark);
    opacity: 0.33;
    z-index: 999;
    pointer-events: none;
}

.columns {
    margin: 0 0 2rem;
    padding: 0;
    list-style: none;
    display: grid;
    grid-auto-columns: 1fr;
    grid-template-rows: repeat(auto-fit, minmax(8rem, 1fr));
    gap: 3rem;
    overflow: hidden;

    &.count-2 {
        grid-template-columns: repeat(auto-fill, minmax(min(100cqw, max(15rem, calc(50cqw - 1rem))), 1fr));
    }

    &.count-3 {
        grid-template-columns: repeat(auto-fill, minmax(min(100cqw, max(15rem, calc(33cqw - 2rem))), 1fr));
    }

    &.count-4 {
        grid-template-columns: repeat(auto-fill, minmax(min(100cqw, max(15rem, calc(25cqw - 3rem))), 1fr));
    }

    @container (width < 32rem) {
        .column {
            grid-column: auto !important;
        }
    }
}

.column {
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 0.5rem;
    gap: 4rem;

    &.span-2 {
        grid-column: span 2;
    }

    &.span-3 {
        grid-column: span 3;
    }

    &.rows-2 {
        grid-row: span 2;
    }

    &::before {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        left: -1.5rem;
        border-left: double 0.3rem var(--foreground-05);
    }

    &::after {
        content: "";
        position: absolute;
        bottom: -1.5rem;
        left: 0;
        right: 0;
        border-bottom: double 0.3rem var(--foreground-05);
    }
}

.module {
    .title {
        font-size: 1.2em;
        font-weight: 600;
        margin: 0 0 1.25em;

        a[href] {
            text-decoration: none;
        }
    }
    
    .subtitle {
        font-size: 1em;
        font-weight: bolder;
        margin: 0 0 1em;

        a[href] {
            text-decoration: none;
        }
    }
}

.grid {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
    grid-auto-rows: minmax(10rem, 1fr);
    gap: 1rem;
    container-type: inline-size;

    &::before,
    &::after {
        content: "";
        display: block;
        border: solid 0.1rem var(--foreground-05);
        border-radius: 0.5rem;
        background: linear-gradient(
            to bottom right,
            color-mix(in srgb, var(--foreground-05) 65%, transparent),
            color-mix(in srgb, var(--foreground-05) 15%, transparent)
        );
        order: 999;

        @container (width < 17rem) {
            display: none;
        }
    }

    &::after {
        @container (width < 26rem) {
            display: none;
        }
    }

    &.large {
        grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
        grid-auto-rows: minmax(16rem, 1fr);

        &::before {
            @container (width < 31rem) {
                display: none;
            }
        }

        &::after {
            @container (width < 47rem) {
                display: none;
            }
        }
    }

    &:has(:nth-child(3n - 1 of .grid-item):nth-last-child(1 of .grid-item)) {
        &::before {
            @container (width > 17rem) {
                display: none;
            }
        }
        &.large::before {
            @container (width > 31rem) {
                display: none;
            }
        }
    }

    &:has(:nth-child(2n of .grid-item):nth-last-child(1 of .grid-item)) {
        &::before {
            @container (width < 26rem) {
                display: none;
            }
        }
        &.large::before {
            @container (width < 47rem) {
                display: none;
            }
        }
    }

    &:has(:nth-child(3n of .grid-item):nth-last-child(1 of .grid-item)) {
        &::before {
            @container (width > 26rem) {
                display: none;
            }
        }
        &.large::before {
            @container (width > 47rem) {
                display: none;
            }
        }

        &::after {
            @container (width > 17rem) {
                display: none;
            }
        }
        &.large::after {
            @container (width > 31rem) {
                display: none;
            }
        }
    }
}

.grid-item {
    display: flex;
}

.card {
    flex-grow: 1;
    border: solid 0.1rem var(--foreground-05);
    padding: 0.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 0.1rem 0.2rem var(--foreground-05);
    display: flex;
    flex-direction: column;
    position: relative;

    &::before {
        content: "";
        display: block;
        aspect-ratio: 16 / 9;
        margin: -0.5rem -0.5rem 0.5rem;
        border-radius: 0.5rem 0.5rem 0 0;
        background: var(--gradient-color);
    }

    a.main {
        text-decoration: none;

        &::before {
            content: "";
            display: block;
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }

        &:focus-visible {
            outline: none;

            &::before {
                outline: dashed 0.2rem var(--accent);
                outline-offset: 0.25rem;
            }
        }
    }

    .title {
        flex-grow: 1;
        font-size: 1rem;
        font-weight: 500;
        margin: 0 0 0.25rem;
    }

    time {
        display: block;
        text-transform: uppercase;
        font-size: 0.75em;
        font-weight: normal;
        text-align: right;
    }
}

.panel {
    flex-grow: 1;
    border: solid 0.1rem var(--foreground-05);
    border-radius: 0.5rem;
    box-shadow: 0 0.1rem 0.2rem var(--foreground-05);
    padding: 1rem;
    background: var(--gradient-color);
}

.news-item {
    padding: 0 0 1rem;
    margin: 0 0 1rem;
    border-bottom: solid 0.1rem var(--foreground-05);

    &:last-of-type {
        border-bottom: none;
        padding-bottom: 0;
        margin-bottom: 0;
    }

    .title {
        display: block;
        text-transform: uppercase;
        font-size: 0.75em;
        font-weight: bold;
        margin: 0;
    }

    > * {
        margin: 0.5rem 0 0;
    }
}

.multicol {
    column-width: 20rem;
    column-gap: 3rem;

    p {
        margin-top: 0;
    }
}

.schedule {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    row-gap: 1rem;

    .day,
    .static {
        padding: 0 0 1rem;
        margin: 0;
        border-bottom: solid 0.1rem var(--foreground-05);

        &:last-of-type {
            border-bottom: none;
            padding-bottom: 0;
        }

        .label {
            display: block;
            text-transform: uppercase;
            font-size: 0.75em;
            font-weight: bold;
            margin: 0 0 0.5em;
        }

        .events {
            margin: 0 0 0 1.5em;
            padding: 0;
            line-height: 1.75rem;
            
            .event {
                list-style-type: "- ";

                &[data-calendar="waste"] {
                    list-style-type: "♻️ ";
                }

                &[data-calendar="events"] {
                    list-style-type: "📆 ";
                }

                &[data-calendar="elections"] {
                    list-style-type: "🗳️ ";
                }
            }

            span {
                display: block;
                font-size: 0.75em;
            }
        }
        
        .content {
            display: list-item;
            list-style-type: attr(data-icon);
            margin: 0 0 0 1.5rem;
        }
    }
}

#main-header {
    color: var(--foreground);
    line-height: 1.5rem;
    padding: 1.25rem 0;
    border-bottom: solid 0.1rem var(--foreground-20);
    margin-bottom: 5rem;

    .wrapper {
        display: flex;
        column-gap: 2.5rem;
        row-gap: 0.5rem;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    p {
        margin: 0;
    }

    nav {
        flex-grow: 1;
        display: flex;
        justify-content: flex-end;
        container-type: inline-size;
    }

    ul {
        margin: 0;
        padding: 0;
        list-style: none;
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        column-gap: 0.5rem;
        row-gap: 0.5rem;

        li {
            margin: 0;
        }
    }

    .height-wrapper {
        container-type: size;
    }

    .height-validator {
        display: none;

        @container (height > 2.5rem) {
            display: block;
        }
    }

    a {
        text-decoration: none;
        display: block;
        padding: 0.25rem 1rem;
        white-space: nowrap;

        &[aria-current="page"] {
            font-weight: bold;
            border-bottom: solid 0.1rem;
        }

        &:focus-visible {
            outline-offset: 0.1rem;
        }
    }
}

#main-content {
    flex-grow: 1;

    .hero {
        position: relative;
        overflow: hidden;
        min-height: 15rem;
        max-height: 20rem;
        display: flex;
        margin: -5rem 0 5rem;
        padding: 3rem 0;
        border-bottom: solid 0.1rem var(--foreground-20);

        &::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 1;
            background: var(--background-60);
        }

        img {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
            z-index: 0;
        }

        .content {
            flex-grow: 1;
            position: relative;
            z-index: 1;
            display: flex;
            gap: 2rem;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            text-align: center;
        }

        .title {
            font-weight: bold;
            font-size: 3em;
            font-family: Montserrat;
            text-shadow: 0 0 1rem var(--background);
            margin: 0;
        }

        p {
            background: var(--background-80);
            padding: 0.5rem 1rem;
            border-radius: 2em;
            margin: 0;
            border: solid 0.1rem var(--foreground-20);
            box-shadow: 0 0.1rem 0.5rem var(--foreground-20);
        }

        span {
            display: inline-block;
        }
    }
}

#main-footer {
    position: relative;
    margin-top: 5rem;
    padding: 7rem 0;
    background: url(/assets/images/pg-map.png) 50% 50%;
    background-size: cover;
    border-top: solid 0.1rem #0009;

    &::before {
        content: "";
        position: absolute;
        top: -0.1rem;
        left: 0;
        width: 100%;
        height: calc(100% + 0.1rem);
        z-index: 1;
        background: var(--background-60);
    }

    &::after {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 0.75rem;
        background: linear-gradient(to bottom, #0006, #0000);
    }

    .content {
        z-index: 1;
        display: flex;
        gap: 2rem;
        flex-direction: row;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    ul {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        list-style: none;
        margin: 0;
        padding: 0;
        column-gap: 2rem;
        row-gap: 1rem;
    }

    small {
        display: block;
        text-align: right;
        font-size: 1rem;
    }
}