/**
 * Brand override — Interstellar Cyberdefence (blog_id 3) only.
 *
 * The palette (theme.json / tailwind.config.js) is one shared file on disk
 * for every site in the multisite network, so it can't be edited directly
 * without repainting the other two sites too. This file re-points just the
 * colours (and the one logo size) this site wants different; functions.php
 * only enqueues it when the current blog is Cyberdefence.
 *
 *   #AA4FEF (primary-50, the theme's purple)         → #5080E9 (already this
 *                                                        theme's secondary-50)
 *   #221D28 (primary-300, the page's base dark
 *            surface — footer, header pills, panel
 *            backgrounds, etc.)                       → #0E1425 (already
 *                                                        secondary-400)
 *   #210039 (raw hex on the keynote/approach-cards
 *            card backgrounds, not a palette slug)    → #0E1425
 *
 * Everything below sits inside Tailwind's own "utilities" layer, not
 * unlayered. Tailwind v4 wraps its whole build in
 * `@layer theme, base, components, utilities;`, and per the cascade-layers
 * spec, !important priority between layers is the REVERSE of normal
 * priority: a named layer's !important rule beats an unlayered !important
 * rule no matter its specificity or how much later it's loaded. Every
 * "!-important" utility this theme uses (.\!text-primary-50, .\!bg-[#…])
 * compiles into that utilities layer, so an unlayered override here would
 * always lose to it. Declaring the same layer name here appends these rules
 * to the end of that same layer instead, where they win on ordinary
 * specificity/source-order like any other same-layer rule.
 */
@layer utilities {
    /* Covers every var(--color-primary-50, ...) / var(--color-primary-300, ...)
       usage across the theme in one shot — text/bg/border-primary-50, the
       hero gradient, category pills, the footer, header glass pills, panel
       backgrounds, etc. — since they all resolve back to these. */
    :root {
        --wp--preset--color--primary-50: #5080E9 !important;
        --wp--preset--color--primary-300: #0E1425 !important;
    }

    /**
     * ======================================================================
     * Header — 32px pills, and the room they need
     * ======================================================================
     *
     * The shared header renders the logo at "h-auto w-[160px] lg:w-[200px]"
     * (header.php). .site-logo img (0,1,1) outranks both of those utilities
     * (0,1,0) — the lg: one too, since a media query adds no specificity —
     * so none of this needs !important.
     *
     * The bar stays inside `.container` (max-width 1280, custom.css), so its
     * width budget is fixed: the same 1280 ceiling at 1440px, 1920px or
     * 2560px. A wider logo doesn't get more room, it just eats the gap — and
     * when the contents overran that ceiling, flexbox shrank the nav to its
     * minimum and wrapped the two longest labels ("SOC Diensten", "Kennis &
     * Actueel") onto a second line, which is what silently doubled the nav
     * pill's height and pushed Contact off the right edge.
     *
     * That is why rule 1 exists. The nav's items carried px-5 (20px) either
     * side, far more than they need to read as separate; at px-3 they free
     * 80px across the five top-level items, and the bar now has real slack:
     *
     *     logo pill (319 + px-4)   351
     *     nav with px-3 items      709
     *     gap + Contact button     142
     *                            -----
     *     needed                  1202   ≤   1280  available  (78px gap)
     *
     * So the four rules below are one fix: free the width (1), stop the
     * labels wrapping if it ever runs short again (2), put all three pills
     * on the same 32px height (3), and size the logo to match (4).
     */

    /* 1. Where the 80px comes from. Only the top-level items
          (nav > div > a, mb_render_desktop_menu_item) — the dropdown panels'
          own links sit deeper and keep their own spacing. */
    nav[aria-label="Hoofdmenu"] > div > a {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* 2. Top-level nav labels stay on one line. Only the top-level items
          (nav > div > a, mb_render_desktop_menu_item) — the dropdown panels'
          own links sit deeper and are meant to wrap. This makes the pill
          height stable regardless of how tight the bar gets: a future menu
          item can now overflow, but it can no longer silently double the
          height of the whole bar. */
    nav[aria-label="Hoofdmenu"] > div > a {
        white-space: nowrap;
    }

    /**
     * 2b. The 1024–1106px band keeps the hamburger instead of the desktop bar.
     *
     * Rule 1's arithmetic assumes the bar gets the full 1280, and it doesn't
     * at the low end: `.container` is capped at 1280 but is otherwise the
     * viewport, and picks up px-4 at 1086px and below (custom.css). With the
     * logo on its 200px step there (rule 4) the contents still need 1083 —
     * a 232px logo pill plus the 851px nav/Contact block — so anything
     * narrower overruns. At 1024 the bar overran the container by 91px and
     * pushed the Contact button 75px off-screen, which is the nav looking
     * cut off at the right.
     *
     * Nothing sensible can be trimmed to recover 91px: the nav block alone is
     * 851 of the 992 available at 1024 (86% of the bar) with six items, a
     * search icon and the Contact pill, so even if it fitted it would be
     * wall-to-wall. This band gets the theme's own answer for a bar with no
     * room — the mobile panel, which carries exactly the same menu plus the
     * Contact link.
     *
     * The desktop bar returns at 1107px, the first width where 1083 of
     * contents leaves at least 24px between the logo pill and the nav. The
     * arithmetic — not a round number — sets that edge; 1087 would
     * technically fit and look like a mistake, with the two pills 4px apart.
     *
     * The theme switches at the lg breakpoint (1024px) via `hidden lg:flex`
     * on the nav and Contact and `lg:hidden` on the toggle. Each override
     * below is one class more specific than the utility it beats, so no
     * !important is needed.
     *
     * The Contact selector walks the child path (bar > right-hand block > a)
     * rather than matching on classes alone: the mobile panel's own Contact
     * link carries the same rounded-full/bg-primary-50/font-black classes,
     * and hiding that one in this band would empty the very panel this rule
     * is switching to. The nav needs no such care — the panel's <nav> is
     * labelled "Hoofdmenu (mobiel)", which an exact [aria-label] match
     * doesn't touch.
     */
    @media (min-width: 1024px) and (max-width: 1106px) {
        header[data-site-header] nav[aria-label="Hoofdmenu"],
        header[data-site-header] > .container > div > a[class*="rounded-full"][class*="bg-primary-50"][class*="font-black"] {
            display: none;
        }

        header[data-site-header] button[data-menu-toggle] {
            display: flex;
        }

        /* The panel it opens is lg:hidden too, so without this the toggle
           would be a button that does nothing. `grid` specifically, not
           block: the open/close transition animates grid-template-rows
           from 0fr to 1fr (header.php), which only works on a grid. */
        header[data-site-header] div[data-menu-panel] {
            display: grid;
        }
    }

    /* 3. All three pills 32px tall — the logo's glass pill, the nav bar and
          the Contact button, sharing the vertical centre the bar's
          items-center already gives them.
     *
     *    32 is the theme's own height for the nav items and the Contact
     *    button (min-h-8), so neither needs a rule here; only the logo pill
     *    does. A fixed height rather than trimmed padding, because the logo
     *    inside it is 41px tall and stays that way (rule 4) — the pill is
     *    sized independently of its content and the artwork simply overhangs
     *    it, 4.5px top and bottom.
     *
     *    That overhang is invisible: the logo file's own viewBox carries
     *    whitespace above and below the wordmark, so the drawn ink is about
     *    22px of those 41 and sits well inside the 32px pill. Nothing clips
     *    it either way — .site-logo has no overflow-hidden (header.php), and
     *    backdrop-filter creates a stacking context without clipping
     *    children. */
    .site-logo {
        height: 32px;
        padding-top: 0;
        padding-bottom: 0;
    }

    /* 4. The logo itself, untouched by rule 3's 32px pill: the requested
          319 × 41 wherever the bar is wide enough to hold it, and the theme's
          own 200px width below that — so narrow desktops and phones behave
          exactly as they did before this file touched the logo, rather than
          trading a too-small logo for a nav that runs off the screen.
          200 × 26 keeps the same proportions.
     *
     *    319 × 41 is the artwork's own shape, not an arbitrary pair: the
     *    selected file ("…CD logo – Large – WIT – Horizontaal") has viewBox
     *    0 0 1131.25 143.45, a ratio of 7.886, and 319 / 7.886 is 40.5. So
     *    these numbers scale it without distortion.
     *
     *    The switch is at 1280px, the width at which the bar reaches its full
     *    1280 (`.container` is capped there, so below it the bar is the
     *    viewport). 1202 of that is spoken for by rule 1's arithmetic, which
     *    leaves the 78px gap; under 1280 the bar shrinks with the window and
     *    the smaller logo keeps that gap open.
     *
     *    max-width is the backstop: if the pill is ever squeezed narrower
     *    than the declared width, an SVG's default preserveAspectRatio scales
     *    the artwork down inside the box rather than distorting it. */
    .site-logo img {
        max-width: 100%;
    }

    @media (min-width: 1280px) {
        .site-logo img {
            width: 319px;
            height: 41px;
        }
    }

    @media (max-width: 1279px) {
        .site-logo img {
            width: 200px;
            height: 26px;
        }
    }

    /* The two spots that hardcode the old purple/dark-purple as a raw
       Tailwind arbitrary value instead of the CSS variable, so the rule
       above can't reach them. */
    [class*="bg-[#AA4FEF]"] {
        background-color: #5080E9 !important;
    }

    [class*="bg-[#210039]"] {
        background-color: #0E1425 !important;
    }

    /**
     * Yellow, opted in per element — text colour. Two shapes of link use it:
     *
     *  - Arrow-links with an uppercase label (.arrow-link, e.g. form_block.php
     *    / showcase.php's "MEER INFORMATIE"): the label is .text-label-uppercase,
     *    which sets its own color directly on that span (custom.css) — plain
     *    inheritance from an ancestor's .yellow would never reach it. .arrow-link
     *    neutralises that (color: inherit, custom.css) so the label and the
     *    arrow both just follow whatever's put on the wrapping <a> — put
     *    "yellow" there and both go yellow together.
     *  - Plain links with no such label, e.g. cta_card.php's "Talk to our
     *    team" (a bare <span>, no .text-label-uppercase to fight): ordinary
     *    inheritance already reaches both the label and the arrow, so
     *    "yellow" straight on the <a> is enough on its own.
     *
     * Every arrow-link already resolves to this site's blue automatically
     * (text-primary-50 → the --wp--preset override above), same as
     * everything else that uses that colour — no rule is needed for the
     * plain default here, only for opting a specific one into yellow.
     *
     *   #F3DE70 (requested)                → base
     *   #E0CF41 (~12% darker, same family) → hover
     */
    .yellow {
        color: #F3DE70 !important;
    }

    .yellow:hover {
        color: #E0CF41 !important;
    }

    /**
     * CTA card (cta_card.php), opted into yellow — card_color: "primary"
     * renders class="... bg-primary-50 ..."; add "yellow" alongside it
     * (".bg-primary-50.yellow", both classes on that same element) for the
     * bright-yellow variant. Covers the card's own panel AND the download
     * button's round puck icon, which reuses bg-primary-50 too and can
     * carry "yellow" the same way — sitting on the button's dark
     * bg-primary-200 fill, a yellow puck reads fine there.
     *
     * The heading text needs its own fix, not just the background: it's
     * white via .scheme-on-dark's --tx-heading variable (cta_card.php's own
     * comment — "Heading white, body in the card's deep shade"), which reads
     * fine on this site's blue but goes near-invisible on bright yellow.
     * Overriding --tx-heading here (rather than fighting the heading
     * selector's specificity directly) rides the same var(--tx-heading)
     * mechanism the card's own CSS already uses, so it flows through
     * automatically. The body copy (explicit text-primary-200, dark) and the
     * download button's own fill (dark bg-primary-200 pill) already read
     * fine on yellow as they are — untouched. The button's OUTLINE
     * (border-primary-50) is separate — `color` doesn't touch `border-color`
     * — see the next rule below.
     */
    .bg-primary-50.yellow {
        background-color: #F3DE70 !important;
        --tx-heading: #0E1425;
    }

    /* The download button's own outline (border-primary-50), same opt-in —
       add "yellow" to that button's own class list, alongside border-primary-50. */
    .border-primary-50.yellow {
        border-color: #F3DE70 !important;
    }

    /**
     * Header — the primary nav bar's top-level items.
     *
     *   inactive (not the current page, not hovered) → #FFFFFF — this is
     *     already what the theme's own text-neutral-50 resolves to, so it
     *     needs no override here; noted for completeness.
     *   active (the current page, and hover as its preview)  → #F3DE70
     *
     * Scoped to nav[aria-label="Hoofdmenu"] (the desktop bar specifically —
     * the mobile panel carries a different aria-label, "Hoofdmenu (mobiel)")
     * and to font-black + uppercase, the classes unique to a top-level item
     * (mb_render_desktop_menu_item()) — a dropdown panel's own sub-links
     * (mb_render_dropdown_simple() etc.) use a plainer
     * text-neutral-200/hover:text-primary-50 style without those classes,
     * so they're untouched and stay blue.
     *
     * [class~="…"] (exact whitespace-separated token), not [class*="…"]
     * (substring) — an inactive item's class list is "… text-neutral-50
     * hover:text-primary-50", and "hover:text-primary-50" itself CONTAINS
     * "text-primary-50" as a substring. A *= match on "text-primary-50"
     * therefore fired on every item, active or not (the bug this replaced:
     * inactive items showing yellow-tinted white instead of plain white).
     * ~= only matches a token that's exactly "text-primary-50" on its own,
     * which just the current item's class list has.
     */
    nav[aria-label="Hoofdmenu"] a[class*="font-black"][class*="uppercase"][class~="text-primary-50"] {
        color: #F3DE70 !important;
    }

    nav[aria-label="Hoofdmenu"] a[class*="font-black"][class*="uppercase"][class~="hover:text-primary-50"]:hover {
        color: #F3DE70 !important;
    }

    /* The Contact button, desktop pill and its mobile-panel twin — both are
       class="... rounded-full bg-primary-50 ... font-black uppercase
       text-neutral-50 ... hover:bg-primary-100 ...", scoped to the header so
       this doesn't touch any other solid bg-primary-50 button on the site. */
    header[data-site-header] a[class*="rounded-full"][class*="bg-primary-50"][class*="font-black"] {
        background-color: #F3DE70 !important;
        color: #0E1425 !important;
    }

    header[data-site-header] a[class*="rounded-full"][class*="bg-primary-50"][class*="font-black"]:hover {
        background-color: #E0CF41 !important;
    }
}
