/*
 * Header and footer details that Blocksy has no setting for (task 02).
 * Front end only. Layout, colours, sizes and sticky behaviour are set in
 * Customizer → Header / Footer; keep them there, not here.
 */

/* Site title in the main bar (Header → HTML element): never underlined;
   hover colour comes from the element's settings, focus shows the outline. */
.storm-site-title {
    display: inline-block;
    vertical-align: top; /* no baseline gap under the sticky logo, so it stays centred in the bar */
    text-decoration: none;
}

/* The title starts at the visible left edge of the logo above it (the same
   line as the menu and the page content). */
.storm-site-title__text {
    display: inline-block;
    text-wrap: balance; /* when the title needs two lines, split it evenly */
}

/* Account dropdown (Customizer → Header → Account → Dropdown): as wide as its
   content, so a long email address stays on one line (Blocksy fixes 250 px
   and breaks words); never wider than the screen, where it may wrap. */
#header .ct-header-account-dropdown {
    width: max-content;
    min-width: 220px;
    max-width: min(24rem, calc(100vw - 2rem));
}

#header .ct-header-account-dropdown .ct-header-account-user-info span {
    word-break: normal;
    overflow-wrap: anywhere;
}

/* The logo files keep a transparent clear space of 8.3 % of their height on
   every side (storm-logo-en-colour-compact.png). Pull the images left by that
   amount so the visible logo lines up with the title, menu and page edge;
   the clear space stays (it overlaps the container padding). */
#header .site-logo-container img {
    margin-inline-start: calc(var(--logo-max-height, 0px) * -0.0833);
}

/* Compact sticky bar (Customizer → Header → Sticky: main bar only, effect
   "Default"): strip and logo band scroll away; when the main bar reaches the
   top it stays there, the title gives way to the logo and the rainbow strip
   appears above it (like the Interreg NEXT MED site). Desktop and phone alike.
   Blocksy marks the stuck state with "yes" in data-sticky.
   Logo: Customizer → Header → Logo → "Sticky State Logo" ([storm_sticky_logo]).
   Strip: the top row's background image (variables set in functions.php). */
/* 84 px: "Interreg" + EU flag the same size as in the Interreg NEXT MED site's
   sticky bar (flag ≈ 21 px high). */
:root {
    --storm-compact-bar-height: 96px;
}

#header {
    --storm-compact-logo-height: 84px;
}

/* In-page links (e.g. "Find your starting point" → #where-are-you-today) stop
   below the sticky bar instead of under it; no sticky bar on short windows. */
html {
    scroll-padding-top: calc(var(--storm-compact-bar-height) + 24px);
}

/* Signed in: WordPress's admin bar is above the header too */
html:has(> body.admin-bar) {
    scroll-padding-top: calc(var(--storm-compact-bar-height) + var(--wp-admin--admin-bar--height, 32px) + 24px);
}

@media (max-height: 500px) {
    html {
        scroll-padding-top: 0;
    }
}

.storm-sticky-logo {
    display: none;
}

#header [data-sticky*="yes"]::before {
    content: "";
    display: block;
    height: var(--storm-strip-height, 0);
    background: var(--storm-strip-image, none) center bottom / cover no-repeat;
}

#header [data-sticky*="yes"] [data-row*="bottom"] {
    --height: var(--storm-compact-bar-height);
}

#header [data-sticky*="yes"] .storm-site-title__text {
    display: none;
}

#header [data-sticky*="yes"] .storm-sticky-logo {
    display: block;
    width: auto;
    height: var(--storm-compact-logo-height);
    margin-inline-start: calc(var(--storm-compact-logo-height) * -0.0833);
}

/* Footer logo (Appearance → Widgets → Footer Widget Area 1, image block with
   class "storm-footer-logo"; size set on the block): moved left and up by its
   transparent clear space — 3.2 % of its width, 8.33 % of its height
   (storm-logo-en-colour-white-compact.png) — so it lines up with the text
   below and the column headings. */
.storm-footer-logo img {
    translate: -3.2% -8.33%;
}

/* Footer column headings (Explore, About & contact, Follow STORM): white rule
   below, as on the Interreg NEXT MED site. Font and colour: Customizer →
   Footer → main row → Widgets Title. */
#footer .widget-title {
    padding-block-end: 12px;
    margin-block-end: 20px;
    border-block-end: 4px solid var(--theme-palette-color-8);
}

/* Keyboard focus in the header: Blocksy's navy outline plus a thin white edge,
   so focus stays visible whether the bar is white or set to navy in the
   Customizer. */
#header :focus-visible {
    box-shadow: 0 0 0 2px var(--theme-palette-color-8);
}

/* Keyboard focus on the navy footer: Blocksy's focus outline is navy
   (palette 1) and would be invisible here; white instead (9.45:1). */
#footer :focus-visible {
    outline-color: var(--theme-palette-color-8);
}

/* Blocksy fixes the sticky bar's placeholder height when the page loads. If the
   text grows afterwards (browser text-only zoom), the bar would cover the page,
   so while the bar is not stuck its placeholder follows the content (WCAG 1.4.4). */
#header .ct-sticky-container:has([data-sticky]:not([data-sticky*="yes"])) {
    height: auto !important;
}

/* Short windows (landscape phones, 400 % zoom): the sticky header would cover
   too much of the page, so it scrolls away instead (WCAG 1.4.10 reflow). */
@media (max-height: 500px) {
    #header [data-sticky*="yes"] {
        position: static;
    }
}

/* Account modal (Header → Account → "Open Login Modal"): looks like the
   WordPress login screen (login.css). Colours, background and shadow stay in
   Customizer → Header → Account → Modal Options. The logo is the header logo
   (functions.php sets the variables). */
#account-modal {
    --theme-form-field-height: 48px;
    --theme-form-field-border-radius: var(--storm-ui-radius, 9px);
}

#account-modal .ct-account-forms::before {
    content: "";
    display: block;
    width: 100%;
    max-width: 200px;
    aspect-ratio: var(--storm-account-logo-ratio, 2.5);
    margin: 0 auto 24px;
    background: var(--storm-account-logo, none) center / contain no-repeat;
}

/* Field labels (not "Remember Me" or the consent checkbox) */
#account-modal form > p > label[for]:not(:has(input)) {
    font-weight: 600;
}

#account-modal .input:focus-visible {
    outline: 2px solid var(--theme-palette-color-1);
    outline-offset: 2px;
}

#account-modal :is(.storm-signup-hint, .storm-consent) {
    font-size: 15px;
}

/* Checkbox beside the consent text, text wrapping under itself */
#account-modal .storm-consent label {
    position: relative;
    display: block;
    padding-inline-start: 28px;
}

#account-modal .storm-consent .ct-checkbox {
    position: absolute;
    inset-inline-start: 0;
    top: 4px;
    margin: 0;
}

#account-modal .storm-consent a {
    text-decoration: underline;
}

/* Until the consent box is ticked: a dimmed Register button (still focusable;
   storm-core sets aria-disabled and a screen-reader hint). */
#account-modal [aria-disabled="true"] {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Narrow desktop header (Blocksy switches to the mobile header below 1000 px):
   the title wraps onto two lines, and the menu is centred between title and
   icons instead of on the page, so the title keeps enough room. */
@media (min-width: 1000px) and (max-width: 1199.98px) {
    .storm-site-title__text {
        max-width: 9em;
    }

    #header [data-device="desktop"] [data-row*="bottom"] > .ct-container {
        grid-template-columns: auto 1fr auto;
    }
}
