/* IBM Plex, only the faces the page uses (fonts/LICENSE.txt), subset with pyftsubset to the
   characters of unicode-range; others come from a system font. Text shows while they load. */
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url("fonts/IBMPlexSans-Regular.4fd671a08fce.woff2") format("woff2"); unicode-range: U+0000-017F, U+0192, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url("fonts/IBMPlexSans-Medium.bfd19ef24594.woff2") format("woff2"); unicode-range: U+0000-017F, U+0192, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Condensed"; font-weight: 200; font-display: swap; src: url("fonts/IBMPlexSansCondensed-ExtraLight.7eb8558df78f.woff2") format("woff2"); unicode-range: U+0000-017F, U+0192, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Condensed"; font-weight: 300; font-display: swap; src: url("fonts/IBMPlexSansCondensed-Light.9cca59abc69e.woff2") format("woff2"); unicode-range: U+0000-017F, U+0192, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Condensed"; font-weight: 400; font-display: swap; src: url("fonts/IBMPlexSansCondensed-Regular.1b6ae330938b.woff2") format("woff2"); unicode-range: U+0000-017F, U+0192, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: rgb(238, 238, 238);
  --fg: #333;

  /* One hue, the logo's blue. It is too light for text; links use a darker shade (5.1:1 on --bg).
     Headings are in ink. */
  --primary: #5099ca;
  --primary-dimmed: oklch(from var(--primary) 0.50 0.045 h);
  /* Table rules: translucent, so they take the tint of what is behind them. */
  --rule: rgba(from var(--secondary) r g b / .16);
  --rule-strong: rgba(from var(--secondary) r g b / .35);
  --secondary: oklch(from var(--primary) 0.50 c h);
  --secondary-hover: oklch(from var(--primary) 0.40 c h);

  --border: var(--primary-dimmed);

  --body-width: min(max(50vw, 1400px), 100%);

  --padding: 1.2em;
  @media (width <= 800px) {
    --padding: 0.8em;
  }
  --padding-md: calc(var(--padding) * 0.4);
  --padding-sm: calc(var(--padding) * 0.2);

  font-family: IBM Plex Sans, sans-serif;
  /* Unitless, so every element's leading follows its own size. */
  line-height: 1.65;
  font-weight: 400;
  /* Grows with the width: 16px on a phone held upright (400px), 20px from 1400px; all em follow. */
  font-size: clamp(16px, 14.4px + 0.4vw, 20px);
  color: #333;

  background-attachment: fixed;
  background: var(--bg);

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0;

  color: var(--fg);

  /* Each page fades in briefly, as a soft transition between pages. */
  @media (prefers-reduced-motion: no-preference) {
    animation: page-in 250ms ease-out;
  }
}

@keyframes page-in {
  from { opacity: 0; }
}

header, section, div.gallery, footer {
    flex: 1;
    width: 100%;
    max-width: var(--body-width);
    align-self: center;
    text-align: left;
    padding: var(--padding) calc(2 * var(--padding));
}

header, footer {
    position: relative;
    flex-wrap: wrap;
    gap: 2em;
    justify-content: center;
}

header > .bg, footer > .bg {
    z-index: -1;
    position: absolute;
    top: 0;
    left: 50%;
    margin-left: -50vw;
    width: 100vw;
    height: 100%;
}

footer > .bg {
    box-shadow: inset 0 0 20px #aaa;
    border-top: 1px solid rgba(from var(--border) r g b / 0.4);
}

header > .bg {
    box-shadow: inset 0 0 30px #aaa;
}

header {
    min-height: 300px;
    max-width: 100vw;
    padding: var(--padding);

    display: flex;
    flex-direction: row;

    /* The logo is a link to the front page; the link is what the header lays out. */
    & > a:has(#logo) {
        align-self: center;
        display: block;
        line-height: 0;
    }

    #logo {
        max-height: 250px;
        mix-blend-mode: darken;
    }

    #description {
        align-self: center;
        min-width: min(400px, 100%);
        font-size: 1.1em;
        mix-blend-mode: darken;

        width: 50vw;
    }

    /* On narrow screens the logo sits alone above the text: smaller, and centred (above). */
    @media (width <= 800px) {
        flex-direction: column;

        #logo {
            max-height: 120px;
        }

        #description {
            width: auto;
        }
    }
}

/* An arrow to the content while the first screen holds no text yet (scroll.js); at the bottom
   of the screen, as a round button of frosted glass like the login link, so it shows on the
   photo and on the page alike. */
.scroll-down {
    position: fixed;
    z-index: 2;
    left: 50%;
    bottom: 1em;
    translate: -50% 0;
    padding: .5em;
    line-height: 0;
    border-radius: 50%;
    color: black;

    background:
        radial-gradient(70% 90% at center, oklch(from var(--primary) calc(l + 0.5) c h / 0.3), transparent),
        rgba(from white r g b / 0.30);
    backdrop-filter: blur(10px);
    border: 1px solid oklch(from white l c h / 0.5);
    border-bottom: 2px solid white;
    box-shadow: 0 0 20px rgba(from black r g b / 0.2);

    /* Faded out unless scroll.js shows it; invisible, it cannot be clicked or focused. */
    opacity: 0;
    visibility: hidden;
    transition: opacity 250ms ease-out, visibility 0s 250ms;

    &.shown {
        opacity: 1;
        visibility: visible;
        transition: opacity 250ms ease-out;
    }

    @media (prefers-reduced-motion: reduce) {
        transition: none;
    }

    svg {
        width: 1.6em;
        height: 1.6em;
    }
}

html {
    @media (prefers-reduced-motion: no-preference) {
        scroll-behavior: smooth;
    }
}

/* The photos cannot be dragged out of the page (see also photos.js). */
.gallery img, #banner img, #outro img {
    -webkit-user-drag: none;
    user-select: none;
}

header > nav {
    position: absolute;
    right: 1em;
    top: calc(100% + 1em);
    padding: 0em 1em;
    border-radius: 100em;

    font-size: 1.2em;
    z-index: 1000;
    background:
        radial-gradient(70% 90% at center, oklch(from var(--primary) calc(l + 0.5) c h / 0.3), transparent),
        rgba(from white r g b / 0.30);
    backdrop-filter: blur(10px);

    display: flex;
    flex-direction: row;
    justify-content: center;
    border-style: solid;
    border-color: white;
    border-width: 1px 0px 2px 0px;
    border-top-width: 1px;
    border-top-color: oklch(from white l c h / 0.5);

    text-align: left;
    box-shadow: 0 0 20px rgba(from black r g b / 0.2);

    a {
        padding: var(--padding-sm);
        color: black;
        text-decoration: none;
    }
}

footer {
    padding-top: 2em;

    font-size: 0.8em;
    line-height: 1.4;

    display: flex;
    flex-direction: row;

    gap: 2em;

    @media (width <= 800px) {
        gap: 1em;
        flex-direction: column;
        justify-content: flex-start;
    }

    & > div.item {
        flex: 1;
        flex-basis: 0;
        flex-grow: 1;
    }

    /* A quiet colophon: slate text, and labels as on the contact tiles. */
    color: var(--primary-dimmed);

    h1 {
        display: block;
        margin-bottom: .8em;
        font-family: inherit;
        font-size: .75em;
        font-weight: 400;
        letter-spacing: .1em;
        text-transform: uppercase;
        color: var(--secondary);
    }

    h2 {
        margin-top: 0;
        font-family: inherit;
        font-size: 1em;
        font-weight: 500;
        color: inherit;
    }

    /* Links in the text's colour; the dotted underline marks them, the hover colours them. */
    a {
        color: inherit;

        &:hover {
            color: var(--secondary);
        }
    }

    /* The ANBI logo beside the text about it. */
    .anbi {
        display: flex;
        align-items: flex-start;
        gap: 1em;

        /* Its light and dark, in the colour of the glow behind it. */
        img {
            flex: none;
            width: 62px;
            mix-blend-mode: luminosity;
            opacity: .8;
        }
    }
}

.addresslist {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1em;

    .addressitem {
        flex: 1;
    }
}

/* Emphasis as a light highlight in the logo's blue, not in bold; it continues across line breaks. */
strong, b {
    font-weight: inherit;
    background: rgba(from var(--primary) r g b / .18);
    border-radius: 2px;
    box-decoration-break: clone;
    padding-inline: .2em;
}

/* Running text: no lone word on a last line. */
p, li {
    text-wrap: pretty;
}

h1, h2, h3 {
    text-wrap: balance;
}

/* Subpages: long running text at about 70 characters to a line; tables take the full width. */
section.page {
    p, ul:not(.tiles), ol {
        max-width: 68ch;
    }

    h2 {
        margin-top: 1.5em;
    }
}

ul:not(.tiles) {
    list-style: none;
    padding-left: 1.4em;

    & > li {
        position: relative;
    }

    /* A small dot in the accent colour, centred on the first line. */
    & > li::before {
        content: "";
        position: absolute;
        left: -1em;
        top: calc((1lh - 0.4em) / 2);
        width: 0.4em;
        height: 0.4em;
        border-radius: 50%;
        background: var(--primary);
    }
}

ol {
    padding-left: 1.4em;

    & > li::marker {
        color: var(--secondary);
        font-weight: 500;
    }
}

p.version {
    font-size: .85em;
    color: var(--primary-dimmed);
}

/* The roster: the theme takes the remaining width and may wrap. */
table.roster td:last-child {
    width: 100%;
    white-space: normal;
}

/* On narrow screens each service is a block: date and time on one line, then title,
   minister and theme. Days are set apart as in the table: dashed within a day, solid between. */
@media (width <= 800px) {
    table.roster {
        thead {
            display: none;
        }

        tbody tr {
            display: grid;
            grid-template-columns: auto 1fr;
            column-gap: .6em;
            padding-block: .5em;
            border-bottom: 1px solid var(--rule);
        }

        tbody tr.table-odd:has(+ tr.table-odd),
        tbody tr.table-even:has(+ tr.table-even) {
            border-bottom-style: dashed;
        }

        td {
            display: block;
            padding: 0;
            border: none;
            white-space: normal;
        }

        /* A later service of the same day has no date. */
        td:first-child:empty {
            display: none;
        }

        td:first-child {
            font-weight: 500;
        }

        td:nth-child(n + 3) {
            grid-column: 1 / -1;
            width: auto;
        }

        td:nth-child(4)::before { content: "Voorganger: "; color: var(--primary-dimmed); }
        td:nth-child(5):not(:empty)::before { content: "Thema: "; color: var(--primary-dimmed); }
    }
}

/* The verwerkingsregister: situation, data and grounds side by side. */
table.register {
    th, td {
        white-space: normal;
        vertical-align: top;
    }

    th:nth-child(1) { width: 42%; }
    th:nth-child(2) { width: 28%; }

    ul {
        margin: .2em 0 .4em;
    }

    /* On narrow screens, each cell under the name of its column. */
    @media (width <= 800px) {
        thead {
            display: none;
        }

        tr, td {
            display: block;
        }

        td {
            border: none;
            padding-block: .2em;
        }

        tbody tr {
            border-bottom: 1px solid var(--rule);
            padding-bottom: .6em;
        }

        td::before {
            display: block;
            font-size: .75em;
            letter-spacing: .1em;
            text-transform: uppercase;
            color: var(--secondary);
        }

        td:nth-child(1)::before { content: "Situatie"; }
        td:nth-child(2)::before { content: "Gegevens"; }
        td:nth-child(3)::before { content: "Grondslag"; }
    }
}

/* A table of facts: a header column instead of a header row. */
table.facts {
    /* No header row, so the divider a header would have bounds the table instead. */
    border-top: 2px solid var(--rule-strong);

    th, td {
        vertical-align: top;
    }

    td {
        white-space: normal;
        overflow-wrap: break-word;
    }

    /* As narrow as its longest label; the values take the rest. */
    th {
        width: 1%;
        font-weight: 500;
    }

    /* On narrow screens, each label above its value; the rules separate rows, not cells. */
    @media (width <= 600px) {
        tr, th, td {
            display: block;
        }

        th {
            width: auto;
            padding-bottom: 0;
        }

        th, td {
            border: none;
        }

        tbody tr {
            border-bottom: 1px solid var(--rule);
        }
    }
}

/* Contact tiles: an icon, a small label and a value; the whole tile is the link. */
ul.tiles {
    list-style: none;
    padding: 0;
    margin: 1.2em 0 1em;
    display: flex;
    flex-wrap: wrap;
    gap: .8em;
}

.tile {
    display: flex;
    align-items: center;
    gap: .7em;
    padding: .5em 1.1em .5em .8em;

    border: 1px solid rgba(from var(--border) r g b / 0.3);
    border-radius: 2px;
    color: var(--fg);
    text-decoration: none;
    font-weight: 400;
    line-height: 1.5;

    transition: border-color 150ms linear;

    &:is(a):hover {
        color: var(--fg);
        border-color: var(--primary);
    }

    .icon {
        display: flex;
        color: var(--primary);

        svg {
            width: 1.6em;
            height: 1.6em;
        }
    }

    .label {
        display: block;
        font-size: .65em;
        line-height: 1.4;
        letter-spacing: .1em;
        text-transform: uppercase;
        color: var(--secondary);
    }

    .value {
        display: block;
        font-size: .9em;
        line-height: 1.35;
        overflow-wrap: break-word;
    }
}

div.gallery {
    position: relative;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1mm;
    overflow: none;
    /* A little more room above and below than a section has. */
    padding-block: calc(1.3 * var(--padding));

    img {
        box-shadow: 0 0 5px rgba(from var(--fg) r g b / 0.15);
        border: 1px solid rgb(255 255 255 / .5);

        flex: 1;
        min-width: 200px;
        flex-shrink: 1;

        object-fit: cover;
    }

    /* On narrow screens, one photo under the other, each its own height. */
    @media (width <= 800px) {
        flex-direction: column;

        img {
            flex: none;
            width: 100%;
            min-width: 0;
        }
    }
}

* {
    box-sizing: border-box;
}

h1, h2, h3, h4 {
    font-family: IBM Plex Sans Condensed;
    margin: 0;
    margin-top: 1em;
    margin-bottom: .2em;
    font-weight: 300;

    &:first-child {
      margin-top: 0;
    }
}

h1 {
    font-weight: 300;
    display: inline-block;
    max-width: 100%;
    overflow-wrap: break-word;

    /* 1.8em at 400px wide, 2.2em at 1400px. */
    font-size: clamp(1.8em, 1.5em + 1vw, 2.3em);
    line-height: 1.2;
}

h2 {
    font-weight: 400;
    line-height: 1.2;
}

p {
    padding: 0;
    margin: 0;
    margin-bottom: 1em;
}

/* Sections are spaced by their padding alone, as after a gallery, not by their last margin too. */
section > :last-child {
    margin-bottom: 0;
}

/* Sub-subheadings: as firm as the text they introduce. */
h3 {
    font-size: 1.15em;
    font-weight: 400;
}

#banner img {
    display: block;
    /* At most 1.2× the width: on a phone held upright the text is not a long scroll away. */
    height: min(max(50vh, 800px), 120vw);
    width: 100%;
    object-fit: cover;
    object-position: top;
}

#banner {
    /* An eased fade, gone well before the edge, so no edge of the photo shows. */
    mask-image: linear-gradient(to bottom,
        rgb(0 0 0 / 1) 40%,
        rgb(0 0 0 / .7) 58%,
        rgb(0 0 0 / .35) 72%,
        rgb(0 0 0 / .1) 84%,
        transparent 93%);

    border-top: 1px solid var(--border);

    /* overlay the body onto the fade; less on narrow screens, where the photo is lower */
    margin-bottom: max(-150px, -30vw);
}

/* The title on the fade stands out at a larger size. */
#banner + section > h1:first-child {
    /* ExtraLight: at this size it holds, and it lies lightly on the photo. */
    font-weight: 200;
    /* 2.2em at 400px wide, 3.4em at 1400px. */
    font-size: clamp(2.2em, 1.6em + 2.5vw, 3.4em);
}

/* The masks make the photos layers of their own, painted over plain text;
   the sections overlapping their fades stay on top. */
#banner + section, section:has(+ #outro) {
    position: relative;
    z-index: 1;
}

/* A closing photo above the footer: the banner's fade, mirrored. The last section's
   text runs slightly onto the fade. */
#outro {
    margin-top: -4em;
    mask-image: linear-gradient(to top,
        rgb(0 0 0 / 1) 40%,
        rgb(0 0 0 / .7) 58%,
        rgb(0 0 0 / .35) 72%,
        rgb(0 0 0 / .1) 84%,
        transparent 93%);

    img {
        display: block;
        width: 100%;
        /* A page may take more off, for its photo. */
        height: calc(max(40vh, 600px) - 5cm - var(--outro-shorter, 0cm));
        object-fit: cover;
        /* Which part of the photo shows; a page may set it for its photo. By default the crop
           comes off the bottom: the top stays where a centred 600px crop puts it. */
        object-position: var(--outro-position, 50% 26%);
    }
}

a {
  font-weight: 500;
  text-decoration: underline;

  color: var(--secondary);
  text-decoration-line: underline;
  text-decoration-style: dotted;
  /* Below the descenders rather than through them. */
  text-underline-offset: .2em;

  &:hover {
    color: var(--secondary-hover);
  }

  transition: color 100ms linear;
}

button {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.6em var(--padding);
  font-size: 1em;
  font-weight: 500;
  font-family: inherit;
  background-color: #1a1a1a;
  cursor: pointer;
  transition: border-color 0.25s;
}

button:hover {
  border-color: var(--primary);
}

button:focus,
button:focus-visible {
  outline: 4px auto -webkit-focus-ring-color;
}

/* Tables as on the members' site: no stripes, translucent accent rules, a divider under
   the header. Rows of one day (`table-odd`/`table-even`) are separated by a dashed line,
   days by a solid one. */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    /* Figures of equal width, so times and dates line up. */
    font-variant-numeric: tabular-nums;
    line-height: 1.5;
    margin-bottom: 1.5em;

    th, td {
      white-space: nowrap;
      text-align: left;
      padding: .5em .5em;
      border-bottom: 1px solid var(--rule);
    }

    thead th {
      line-height: 1.3;
      vertical-align: bottom;
      font-weight: 500;
      border-bottom: 2px solid var(--rule-strong);
    }

    /* :where, so a table that lays out its cells otherwise (the roster on narrow screens) overrides this. */
    tbody tr:where(.table-odd:has(+ tr.table-odd), .table-even:has(+ tr.table-even)) > * {
      border-bottom-style: dashed;
    }
}
