/* Tijdbalk — base styles */

/* --tijdbalk-accent is set per-site via an inline <style> in wp_head
   (see includes/layout.php), based on the TIJDBALK_ACCENT_COLOR config
   constant. Fallback here covers the rare case that ran before wp_head.
   Selector is scoped to .site-branding so its specificity (0,0,2,1) beats
   the GeneratePress theme's own ".main-title a" rule (0,0,1,1) regardless
   of stylesheet load order — this stayed unnoticed pre-refactor because
   nobody had checked the rendered color recently. */
.site-branding .main-title a {
    color: var(--tijdbalk-accent, #3a4a5a);
}

/* GeneratePress renders an uploaded custom_logo at its native pixel size
   unless a Logo Width is set in the Customizer — we set the logo via
   WP-CLI on deploy, bypassing the Customizer, so without this the source
   image (sized for crisp favicon export) renders edge-to-edge. */
.site-logo img {
    max-height: 60px;
    width: auto;
}

.tijdbalk-tabel {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1em;
}

/* Ruimte tussen het door DataTables ingevoegde zoekveld en de tabel eronder. */
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 1em;
}

.tijdbalk-bron-events-kop {
    margin-top: 2em;
}

.tijdbalk-tabel th,
.tijdbalk-tabel td {
    padding: 6px 10px;
    border: 1px solid #ddd;
    vertical-align: top;
}

.tijdbalk-tabel th {
    background: #f0f0f0;
    font-weight: bold;
}

.tijdbalk-th-datum,
.tijdbalk-td-datum {
    white-space: nowrap;
}

.tijdbalk-toc {
    background: #f5f5f5;
    border-left: 4px solid var(--tijdbalk-accent, #3a4a5a);
    border-radius: 3px;
    padding: 0.8em 1.2em;
    margin: 0 0 1.5em;
}

.tijdbalk-toc-title {
    font-weight: bold;
    margin: 0 0 0.4em;
}

.tijdbalk-toc ul {
    margin: 0;
    padding-left: 1.2em;
}

.tijdbalk-toc li {
    margin: 0.15em 0;
}

.tijdbalk-toc a {
    text-decoration: none;
}

.tijdbalk-toc a:hover {
    text-decoration: underline;
}

/* Links in running text: accent-derived color (--tijdbalk-link, set in layout.php,
   darkened where needed for 4.5:1 contrast on white), underlined, darker on hover.
   Classed components (buttons, tags, nav, lightbox: any tijdbalk-* class), the
   kenmerk bar (white on orange) and the TOC keep their own look. Overview
   tables and lists (almost everything a link) are calmer: see below. */
.entry-content a:not([class*="tijdbalk-"]):not(.wp-block-button__link):not(.tijdbalk-kenmerk a):not(.tijdbalk-toc a):not(:is(.tijdbalk-tabel-wrap, .tijdbalk-tabel, .dataTables_wrapper, .tijdbalk-periodes, .tijdbalk-onderwerpen-lijst) a) {
    color: var(--tijdbalk-link, #1e73be);
    text-decoration: underline;
}

.entry-content a:not([class*="tijdbalk-"]):not(.wp-block-button__link):not(.tijdbalk-kenmerk a):not(.tijdbalk-toc a):not(:is(.tijdbalk-tabel-wrap, .tijdbalk-tabel, .dataTables_wrapper, .tijdbalk-periodes, .tijdbalk-onderwerpen-lijst) a):hover,
.entry-content a:not([class*="tijdbalk-"]):not(.wp-block-button__link):not(.tijdbalk-kenmerk a):not(.tijdbalk-toc a):not(:is(.tijdbalk-tabel-wrap, .tijdbalk-tabel, .dataTables_wrapper, .tijdbalk-periodes, .tijdbalk-onderwerpen-lijst) a):focus {
    color: var(--tijdbalk-link-hover, #0f4a80);
}

/* Overview tables and navigation lists: text color, no underline; the accent
   only shows on hover/focus, so red keeps meaning "link in running text". */
.entry-content :is(.tijdbalk-tabel-wrap, .tijdbalk-tabel, .dataTables_wrapper, .tijdbalk-periodes, .tijdbalk-onderwerpen-lijst) a:not([class*="tijdbalk-"]) {
    color: inherit;
    text-decoration: none;
}

.entry-content :is(.tijdbalk-tabel-wrap, .tijdbalk-tabel, .dataTables_wrapper, .tijdbalk-periodes, .tijdbalk-onderwerpen-lijst) a:not([class*="tijdbalk-"]):is(:hover, :focus) {
    color: var(--tijdbalk-link, #1e73be);
    text-decoration: underline;
}

.tijdbalk-kenmerk {
    background-color: #D56F3F;
    color: #fff;
    padding: 8px 12px;
    margin: 1em 0;
    border-radius: 3px;
}

.tijdbalk-kenmerk a {
    color: #fff;
}

.tijdbalk-nav {
    margin: 0.5em 0 1em;
}

.tijdbalk-infobox {
    border-collapse: collapse;
    margin-bottom: 1em;
    width: auto;
    border: none;
    outline: none;
    box-shadow: none;
}

.tijdbalk-infobox th,
.tijdbalk-infobox td {
    padding: 4px 16px 4px 0;
    border: none;
    outline: none;
    box-shadow: none;
    text-align: left;
}

.tijdbalk-infobox th {
    background: none;
    font-weight: bold;
    white-space: nowrap;
}

/* Subject grid */
.tijdbalk-onderwerpen-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 1.5em;
}

.tijdbalk-onderwerp-item {
    width: 160px;
    text-align: center;
}

.tijdbalk-onderwerp-item a {
    display: block;
    text-decoration: none;
    color: inherit;
}

.tijdbalk-onderwerp-item img {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border: 1px solid #ddd;
}

.tijdbalk-onderwerp-item span {
    display: block;
    margin-top: 4px;
    font-size: 0.9em;
}

.tijdbalk-tags {
    margin: 1em 0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
}

.tijdbalk-tag {
    display: inline-block;
    padding: 2px 10px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 999px;
    text-decoration: none;
    color: inherit;
}

.tijdbalk-tag:hover {
    background: #fbe4e2;
    border-color: var(--tijdbalk-accent);
    color: var(--tijdbalk-accent);
}

.tijdbalk-eeuwnav {
    margin: 0.5em 0 1em;
    line-height: 1.8;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tijdbalk-eeuwnav-btn {
    display: inline-block;
    padding: 2px 9px;
    font-size: 0.75em;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 999px;
    text-decoration: none;
    color: inherit;
}

.tijdbalk-eeuwnav-btn:hover {
    background: #fbe4e2;
    border-color: var(--tijdbalk-accent);
    color: var(--tijdbalk-accent);
}

.tijdbalk-eeuwnav-btn-current {
    background: var(--tijdbalk-accent);
    border-color: var(--tijdbalk-accent);
    color: #fff;
}

/* Vorige/volgende-navigatie op de gebeurtenis-pagina (tijdbalk-nav.js) en
   de highlight van de context (onderwerp/eeuw/bron) waarop die knoppen
   navigeren — dezelfde accentkleur, zodat het verband zichtbaar is. */
.tijdbalk-prevnext {
    margin: 0.5em 0 1em;
    display: flex;
    gap: 8px;
}

.tijdbalk-prevnext-btn {
    display: inline-block;
    padding: 1px 7px;
    font-size: 0.7em;
    border: 1px solid #ddd;
    border-radius: 999px;
    text-decoration: none;
    color: inherit;
    background: #f0f0f0;
}

.tijdbalk-tag.tijdbalk-context-actief,
.tijdbalk-eeuwnav-btn.tijdbalk-context-actief,
.tijdbalk-prevnext-btn.tijdbalk-context-actief {
    background: var(--tijdbalk-accent);
    border-color: var(--tijdbalk-accent);
    color: #fff;
}

.tijdbalk-bronnen-list li.tijdbalk-context-actief {
    border-left: 3px solid var(--tijdbalk-accent);
    padding-left: 8px;
    background: rgba(0, 0, 0, 0.04);
}

.tijdbalk-periodes {
    columns: 3;
    list-style: none;
    padding: 0;
}

.tijdbalk-onderwerpen-lijst {
    line-height: 2;
}

.tijdbalk-geen-wijzigingslog {
    color: #767676;
    font-style: italic;
}

/* Click-to-enlarge lightbox for content images (see tijdbalk-lightbox.js) */
a.tijdbalk-lightbox {
    display: inline-block;
}

.entry-content img {
    cursor: zoom-in;
}

.tijdbalk-lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    cursor: zoom-out;
    padding: 2rem;
    box-sizing: border-box;
}

.tijdbalk-lightbox-overlay img {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
}

.tijdbalk-lightbox-close {
    position: fixed;
    top: 1rem;
    right: 1.5rem;
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    background: none;
    border: none;
    cursor: pointer;
}

/* "Links" / "Link(s)" / "Link(s):" headings from the wiki (== Link(s) ==): same look as the "Onderwerp:" / "Bronnen:" labels
   (bold, body text size). Scoped to heading anchor ids starting with "Link" so other headings are untouched. */
h2.wp-block-heading[id^="Link"] {
    font-size: inherit;
    font-weight: bold;
    line-height: inherit;
    margin: 1em 0 0.5em;
}

/* Wiki images keep their (small) wiki size; consecutive images sit next to each other. */
.entry-content .wp-block-image img {
    max-width: 100%;
    height: auto;
}

.entry-content .tijdbalk-afbeeldingen {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px 12px;
    margin: 1em 0;
}

.entry-content .tijdbalk-afbeeldingen .wp-block-image {
    margin: 0;
}

/* Phone (A9, plugin 1.0.40): everything below only applies on <= 782px, desktop is untouched.
   "body" prefixes beat equal-specificity rules from the theme/WP block styles regardless of load order. */
@media (max-width: 782px) {
    /* Header: logo + title wrap instead of making the page wider than the screen. */
    body .site-branding-container {
        flex-wrap: wrap;
        max-width: 100%;
    }

    body .site-branding {
        max-width: 100%;
    }

    body .site-branding .main-title {
        font-size: 20px;
        line-height: 1.25;
    }

    body .entry-title,
    body .entry-content h1 {
        font-size: 30px;
        line-height: 1.2;
    }

    /* Overview tables: dates may wrap, otherwise the event column gets ~50px. */
    body .tijdbalk-th-datum,
    body .tijdbalk-td-datum {
        white-space: normal !important;
    }

    body .entry-content .tijdbalk-tabel th,
    body .entry-content .tijdbalk-tabel td {
        padding: 10px 6px;
    }

    body .entry-content .tijdbalk-tabel th {
        padding-right: 20px;
    }

    /* Tap targets >= 44px. */
    body .entry-content .tijdbalk-tabel td a,
    body .entry-content .tijdbalk-bronnen-list a,
    body .entry-content .tijdbalk-periodes a,
    body .entry-content .tijdbalk-nav a,
    body .entry-content .tijdbalk-special-link a {
        display: inline-block;
        padding: 10px 0;
    }

    body .main-navigation .main-nav ul li a {
        line-height: 48px;
    }

    body .tijdbalk-eeuwnav {
        gap: 8px;
    }

    body .tijdbalk-eeuwnav-btn,
    body .tijdbalk-prevnext-btn,
    body .tijdbalk-tag {
        font-size: 15px;
        padding: 10px 14px;
        line-height: 1.2;
    }

    body .tijdbalk-prevnext {
        gap: 10px;
    }

    body .wp-element-caption {
        font-size: 15px;
    }

    /* Source list on an event: no author on a phone (keeps it on one line). */
    body .tijdbalk-bron-auteur {
        display: none;
    }

    /* Subject page: tiles are enough, the long text list is hidden; tiles halved. */
    body .tijdbalk-onderwerpen-lijst {
        display: none;
    }

    body .tijdbalk-onderwerpen-grid {
        gap: 10px 8px;
    }

    body .tijdbalk-onderwerp-item {
        width: 90px;
    }

    body .tijdbalk-onderwerp-item img {
        width: 75px;
        height: 75px;
    }

    body .tijdbalk-onderwerp-item span {
        font-size: 14px;
        overflow-wrap: anywhere;
    }

    /* Lists closer to the edge. */
    body .entry-content ul,
    body .entry-content ol {
        margin-left: 1.2em;
    }

    /* Homepage tiles (column blocks): two next to each other instead of stacked. */
    body .entry-content .wp-block-columns {
        flex-wrap: wrap !important;
        gap: 12px !important;
    }

    body .entry-content .wp-block-columns:not(.is-not-stacked-on-mobile) > .wp-block-column {
        flex-basis: calc(50% - 6px) !important;
        flex-grow: 0 !important;
    }

    /* Sources and authors overview: only the first column is shown on a phone (far fewer
       screens of scrolling). The hidden columns stay in the table, so the DataTables
       search still matches on them. */
    body #tijdbalk-bronnen th:nth-child(n+2),
    body #tijdbalk-bronnen td:nth-child(n+2),
    body #tijdbalk-auteurs th:nth-child(n+2),
    body #tijdbalk-auteurs td:nth-child(n+2) {
        display: none !important;
    }
}

/* Table blocks with class tijdbalk-tabel (e.g. on /links/): left-aligned headers, like the generated overviews. */
.wp-block-table.tijdbalk-tabel th { text-align: left; }
