/*
 * dashboard.forladfolkekirken.dk
 *
 * Colour is two separate things here, and keeping them apart is what stops the
 * charts from turning into a brand swatch:
 *
 *  - Brand colours dress the interface: the navy and blues of forladfolkekirken.dk
 *    (hue 205), its kirkerum illustration and Raleway. The header is navy in both
 *    themes, as the site is.
 *  - Chart colours are a validated set. Magnitude is the brand's own #0077b3. Women
 *    and men are blue and orange, which pass every check of the palette validator
 *    on all pairs: worst ΔE 20.1 under simulated colour blindness on white, 21.7 on
 *    the dark surface, and at least 3:1 contrast against both. The dark steps are
 *    re-stepped for the navy surface, not an automatic inversion.
 */

@font-face {
    font-family: "Raleway";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/raleway/raleway-v28-latin-ext_latin-regular.woff2") format("woff2");
}

@font-face {
    font-family: "Raleway";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/raleway/raleway-v28-latin-ext_latin-500.woff2") format("woff2");
}

@font-face {
    font-family: "Raleway";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/raleway/raleway-v28-latin-ext_latin-600.woff2") format("woff2");
}

@font-face {
    font-family: "Raleway";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/raleway/raleway-v28-latin-ext_latin-700.woff2") format("woff2");
}

@font-face {
    font-family: "Raleway";
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url("../fonts/raleway/raleway-v28-latin-ext_latin-800.woff2") format("woff2");
}

:root {
    color-scheme: light;

    /* Brand, from forladfolkekirken.dk css/base.css. Interface only. */
    --navy-blue: #001d33;
    --dark-blue: #002e51;
    --base-blue: #003e6f;
    --mid-blue: #005185;
    --light-blue: #00649c;
    --lightest-blue: #0077b3;
    --trans-blue: #5da8dc;

    /* Surfaces and ink. */
    --surface-page: #f2f6f9;
    --surface-1: #ffffff;
    --surface-2: #e9f0f5;
    --border: #d6e1ea;
    --border-strong: #b6c7d5;
    --text-primary: #001d33;
    --text-secondary: #33485b;
    --text-muted: #566b7d;
    --link: #00649c;
    --focus: #0077b3;

    /* Chart marks (validated, see the header comment). */
    --series-magnitude: #0077b3;
    --series-magnitude-soft: rgba(0, 119, 179, 0.1);
    --series-men: #0077b3;
    --series-women: #e0662f;
    --grid: #e3eaf0;
    --axis: #b6c7d5;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgb(0 29 51 / 6%), 0 1px 3px rgb(0 29 51 / 5%);
    --gutter: 16px;
    --max-width: 1240px;
    --font: "Raleway", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root:where(:not([data-theme="light"])) {
        color-scheme: dark;
        --surface-page: #001d33;
        --surface-1: #002744;
        --surface-2: #00304f;
        --border: #0c3b5d;
        --border-strong: #1d5279;
        --text-primary: #ffffff;
        --text-secondary: #c4d6e5;
        --text-muted: #94adc2;
        --link: #8cc6ef;
        --focus: #5da8dc;
        --series-magnitude: #4a9bd4;
        --series-magnitude-soft: rgba(74, 155, 212, 0.16);
        --series-men: #4a9bd4;
        --series-women: #e06d36;
        --grid: #0b3756;
        --axis: #1d5279;
        --shadow: 0 1px 2px rgb(0 0 0 / 35%);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --surface-page: #001d33;
    --surface-1: #002744;
    --surface-2: #00304f;
    --border: #0c3b5d;
    --border-strong: #1d5279;
    --text-primary: #ffffff;
    --text-secondary: #c4d6e5;
    --text-muted: #94adc2;
    --link: #8cc6ef;
    --focus: #5da8dc;
    --series-magnitude: #4a9bd4;
    --series-magnitude-soft: rgba(74, 155, 212, 0.16);
    --series-men: #4a9bd4;
    --series-women: #e06d36;
    --grid: #0b3756;
    --axis: #1d5279;
    --shadow: 0 1px 2px rgb(0 0 0 / 35%);
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--surface-page);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 16px;
    font-weight: 500;
    line-height: 1.55;
    font-variant-numeric: lining-nums;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.2;
    font-weight: 800;
}

a {
    color: var(--link);
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

[hidden] {
    display: none !important;
}

.shell {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

/* ------------------------------------------------------------------- hero --- */

/* Navy in both themes, like forladfolkekirken.dk itself. */
.hero {
    position: relative;
    overflow: hidden;
    color: #ffffff;
    background: linear-gradient(165deg, var(--dark-blue) 0%, var(--navy-blue) 70%);
    border-bottom: 4px solid #ffffff;
}

/* The church interior with the open door, from the front page. Decorative, faded
   towards the text so it never competes with the numbers. */
.hero__art {
    position: absolute;
    right: -6%;
    top: -18%;
    width: min(760px, 75%);
    height: auto;
    opacity: 0.55;
    pointer-events: none;
    -webkit-mask-image: linear-gradient(to left, #000 35%, transparent 95%);
    mask-image: linear-gradient(to left, #000 35%, transparent 95%);
}

.hero .shell {
    position: relative;
}

.hero__bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 0 8px;
}

.hero__brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #ffffff;
    text-decoration: none;
    font-weight: 800;
    font-size: 1.1875rem;
    letter-spacing: 0.01em;
}

.hero__mark {
    width: 30px;
    height: 30px;
}

.hero__brand:hover .hero__mark {
    color: var(--trans-blue);
}

.hero__tag {
    padding-left: 14px;
    border-left: 1px solid rgb(255 255 255 / 30%);
    font-weight: 500;
    color: rgb(255 255 255 / 80%);
}

.theme-toggle {
    margin-left: auto;
    padding: 7px 12px;
    font: inherit;
    font-size: 0.875rem;
    color: #ffffff;
    background: rgb(255 255 255 / 8%);
    border: 1px solid rgb(255 255 255 / 25%);
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
}

.theme-toggle:hover {
    background: rgb(255 255 255 / 16%);
}

.hero__body {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px 40px;
    padding: 28px 0 36px;
}

.hero__label {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: rgb(255 255 255 / 80%);
}

/* The one hero figure on the page. */
.hero__value {
    margin: 2px 0 6px;
    font-size: clamp(3rem, 1.8rem + 6vw, 5.75rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.02em;
}

.hero__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 0.9375rem;
    color: rgb(255 255 255 / 85%);
}

#live-today {
    font-weight: 800;
    color: #ffffff;
}

.hero__pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--trans-blue);
    box-shadow: 0 0 0 0 rgb(93 168 220 / 60%);
    animation: pulse 2.4s ease-out infinite;
}

@keyframes pulse {
    to {
        box-shadow: 0 0 0 10px rgb(93 168 220 / 0%);
    }
}

.hero__milestone {
    max-width: 34ch;
    margin: 0;
    padding: 12px 14px;
    font-size: 0.9375rem;
    color: rgb(255 255 255 / 88%);
    background: rgb(0 29 51 / 55%);
    border: 1px solid rgb(255 255 255 / 18%);
    border-radius: var(--radius);
    backdrop-filter: blur(4px);
}

.hero__milestone strong {
    color: #ffffff;
    font-weight: 800;
}

/* ------------------------------------------------------------------ intro --- */

.intro {
    padding: 28px 0 4px;
}

.intro h1 {
    font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem);
}

.intro p {
    margin: 8px 0 0;
    max-width: 68ch;
    color: var(--text-secondary);
}

.freshness {
    font-size: 0.8125rem;
    color: var(--text-muted) !important;
}

/* ----------------------------------------------------------------- filters -- */

/* One row above the charts, sticky, so a filter change is always visible as the
   cause of the numbers moving underneath it. */
.filters {
    position: sticky;
    top: 0;
    z-index: 20;
    margin: 20px calc(var(--gutter) * -1) 24px;
    padding: 12px var(--gutter);
    background: color-mix(in srgb, var(--surface-page) 92%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.filters__bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filters__row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.filters__toggle {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    min-height: 40px;
    font: inherit;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--surface-1);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

/* Says how many filters are set, so a collapsed panel never hides that the numbers
   below describe a subset. */
.filters__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 0.75rem;
    font-weight: 800;
    color: #ffffff;
    background: var(--lightest-blue);
    border-radius: 999px;
}

.filters__count {
    flex-basis: 100%;
    margin: 0 0 8px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.filters__count strong {
    color: var(--text-primary);
    font-weight: 800;
}

.filters__hint {
    margin: 10px 0 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.field > label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.field select,
.field input {
    font: inherit;
    font-size: 0.9375rem;
    padding: 8px 10px;
    min-height: 40px;
    color: var(--text-primary);
    background: var(--surface-1);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    max-width: 100%;
}

.field select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.field--grow {
    flex: 1 1 240px;
}

.field--grow input {
    width: 100%;
}

.filters__reset {
    font: inherit;
    font-size: 0.875rem;
    padding: 9px 14px;
    min-height: 40px;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.filters__reset:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

/* --------------------------------------------------------------- stat tiles -- */

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
    gap: 12px;
    margin-bottom: 36px;
}

.tile {
    padding: 16px 18px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.tile__label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.tile__value {
    margin-top: 4px;
    font-size: 1.875rem;
    font-weight: 800;
    line-height: 1.15;
}

.tile__note {
    margin-top: 2px;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* --------------------------------------------------------------- sections --- */

.section {
    margin-bottom: 44px;
    scroll-margin-top: 120px;
}

.section__head {
    margin-bottom: 14px;
}

.section__head h2 {
    font-size: 1.375rem;
}

.section__head p {
    margin: 5px 0 0;
    max-width: 72ch;
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
}

.grid + .grid {
    margin-top: 16px;
}

.grid--wide {
    /* minmax(0, …) rather than 1fr: a bare 1fr track never shrinks below its
       content, and the 24 column heatmap would push the page wider than a phone. */
    grid-template-columns: minmax(0, 1fr);
}

/* Rankings need the width for sogn names, so they never go three across. */
.grid--two {
    grid-template-columns: repeat(auto-fit, minmax(min(480px, 100%), 1fr));
}

/* ------------------------------------------------------------------ cards --- */

.card {
    display: flex;
    flex-direction: column;
    padding: 16px 18px 18px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 0;
}

.card__title {
    font-size: 1rem;
    font-weight: 800;
}

.card__sub {
    margin: 3px 0 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.card__canvas {
    position: relative;
    margin-top: 14px;
    height: 280px;
}

.card__canvas--tall {
    height: 380px;
}

.card canvas {
    max-width: 100%;
}

/* Shown instead of a chart when a filter leaves too little data to be honest. */
.card__empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    margin: 0;
    padding: 20px;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
    background: var(--surface-2);
    border-radius: var(--radius-sm);
}

.card__toggle {
    align-self: flex-start;
    margin-top: 12px;
    padding: 5px 10px;
    font: inherit;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.card__toggle:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
}

/* ------------------------------------------------------------------ table --- */

.data-table {
    margin-top: 12px;
    max-height: 320px;
    overflow: auto;
}

.data-table--open {
    max-height: none;
}

.data-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.data-table th,
.data-table td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    position: sticky;
    top: 0;
    background: var(--surface-1);
    font-weight: 700;
    color: var(--text-secondary);
    white-space: nowrap;
}

.data-table td.num,
.data-table th.num {
    text-align: right;
    font-variant-numeric: lining-nums tabular-nums;
    white-space: nowrap;
}

/* ----------------------------------------------------------------- events --- */

.events {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.events li::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    vertical-align: 1px;
}

.events__date {
    font-weight: 700;
    color: var(--text-primary);
}

/* ---------------------------------------------------------------- heatmap --- */

/* A plain grid: rows are display: contents so the cells line up across rows.
   One hue, from the surface to the brand blue, with a 2px surface gap. */
.heatmap {
    display: grid;
    grid-template-columns: 2.6rem repeat(24, minmax(11px, 1fr));
    gap: 2px;
    margin-top: 14px;
    overflow-x: auto;
    font-size: 0.75rem;
}

.heatmap__row {
    display: contents;
}

.heatmap__cell {
    height: 26px;
    border-radius: 3px;
    background: color-mix(in oklab, var(--series-magnitude) calc(var(--v, 0) * 100%), var(--surface-2));
}

.heatmap__day {
    align-self: center;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.heatmap__hour {
    color: var(--text-muted);
    font-variant-numeric: lining-nums tabular-nums;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.heatmap-legend__ramp {
    width: 120px;
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(to right, var(--surface-2), var(--series-magnitude));
}

/* ------------------------------------------------------------------ notes --- */

.note {
    margin: 12px 0 0;
    padding: 10px 12px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: var(--surface-2);
    border-left: 3px solid var(--lightest-blue);
    border-radius: var(--radius-sm);
}

.facts {
    margin: 10px 0 0;
    padding-left: 18px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.facts li + li {
    margin-top: 8px;
}

/* ----------------------------------------------------------------- footer --- */

.site-footer {
    margin-top: 12px;
    padding: 32px 0 44px;
    color: #ffffff;
    background: var(--navy-blue);
    border-top: 4px solid #ffffff;
    font-size: 0.875rem;
}

.site-footer__inner {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.site-footer p {
    margin: 0 0 8px;
    max-width: 72ch;
    color: rgb(255 255 255 / 85%);
}

.site-footer a {
    color: #ffffff;
}

.site-footer__mark {
    flex-shrink: 0;
    color: #ffffff;
}

.site-footer__mark:hover {
    color: var(--trans-blue);
}

.site-footer__logo {
    width: 64px;
    height: 64px;
}

/* ---------------------------------------------------------------- loading --- */

.state {
    padding: 48px 0;
    text-align: center;
    color: var(--text-secondary);
}

.state--error {
    color: #c2410c;
}

/* ------------------------------------------------------------- responsive --- */

@media (max-width: 760px) {
    .filters__toggle {
        display: inline-flex;
    }

    .filters__count {
        flex-basis: auto;
        margin: 0;
    }

    .filters__panel {
        display: none;
        padding-top: 12px;
    }

    .filters__panel.is-open {
        display: block;
        max-height: 65vh;
        overflow-y: auto;
    }

    .filters__row .field {
        flex: 1 1 100%;
    }

    .filters__reset {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .hero__tag {
        display: none;
    }

    .hero__art {
        width: 120%;
        right: -40%;
        opacity: 0.35;
    }

    .theme-toggle {
        font-size: 0.8125rem;
        padding: 6px 10px;
    }

    .card__canvas {
        height: 240px;
    }

    .card__canvas--tall {
        height: 320px;
    }

    .site-footer__inner {
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
