/* ==========================================================================
   EOI Lome - Government header + main navigation + accessibility panel
   Based on the CGI Osaka header (header.css). Scoped to #header / the mobile
   menu so no other Lome page is affected.
   Load order: ... style.css -> noto-sans.css -> lome-header.css -> theme-dark.css
   Breakpoints: <= 1023px = mobile/tablet header

   Dark mode: every light-only colour in this file is a variable. The block
   "html[data-theme=dark]" below the tokens switches them, so the header works
   in dark mode on its own. theme-dark.css styles the rest of the page.
   ========================================================================== */

/* ---------- Design tokens (variables only: they style nothing by themselves) ---------- */
:root {
    --color-linen: #EBEAEA;
    --color-white: #FFFFFF;
    --color-earthy-brown: #150202;
    --color-black: #000000;
    --brand-key: #162F6A;
    --brand-v1: #214AAB;
    --brand-v2: #3270D7;
    --brand-v3: #A3BBF3;
    --brand-v4: #D2DFFF;
    --color-grey-01: #C6C6C6;
    --color-grey-02: #8E8E8E;
    --color-grey-03: #606060;
    --text-primary: var(--color-earthy-brown);
    --text-strong: var(--color-black);
    --text-secondary: var(--color-grey-03);
    --bg-page: var(--color-white);
    --border-default: var(--color-grey-01);
    --focus-ring: var(--brand-key);

    /* Theme-aware surface tokens (light values here, dark values in the dark block below) */
    --surface: var(--color-white);
    --line: var(--color-grey-01);
    --linen-line: var(--color-linen);
    --field-border: var(--color-grey-01);
    --sep: var(--brand-v3);
    --tool-color: var(--brand-key);
    --hover-bg: var(--brand-v4);
    --hover-text: var(--brand-key);
    --link-ui: var(--brand-v1);
    --accent: var(--brand-key);
    --accent-2: var(--brand-v2);
    --tile-color: var(--brand-key);
    --pressed-bg: var(--brand-key);
    --pressed-text: var(--color-white);

    /* Typography (px, not rem: Lome's legacy CSS changes the root size below 1024px) */
    --font-primary: 'Noto Sans', 'Noto Sans Devanagari', 'Segoe UI', Arial, sans-serif;
    --font-regular: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    --fs-h2: 24px;
    --fs-h3: 20px;
    --fs-body: 16px;
    --fs-body-small: 14px;
    --fs-small: 12px;
}
@media (max-width: 767px) {
    :root { --fs-h2: 20px; --fs-h3: 16px; --fs-body: 14px; --fs-body-small: 12px; --fs-small: 10px; }
}

/* ---------- Dark theme tokens (html[data-theme="dark"] is set by header-ui.js) ---------- */
html[data-theme="dark"] {
    color-scheme: dark;
    --bg-page: #150202;
    --text-primary: #FFFFFF;
    --text-strong: #FFFFFF;
    --text-secondary: #C6C6C6;
    --border-default: #606060;
    --focus-ring: #D2DFFF;

    --surface: #150202;
    --line: #606060;
    --linen-line: #606060;
    --field-border: #8E8E8E;
    --sep: #606060;
    --tool-color: #FFFFFF;
    --hover-bg: #162F6A;
    --hover-text: #FFFFFF;
    --link-ui: #A3BBF3;
    --accent: #A3BBF3;
    --accent-2: #A3BBF3;
    --tile-color: #D2DFFF;
    --pressed-bg: #D2DFFF;
    --pressed-text: #162F6A;
}

/* Noto Sans in the header and mobile menu only */
#header, #menuPartWrapper { font-family: var(--font-primary); }
#header button, #header input, #header select { font-family: inherit; }

/* ---------- Skip link (first tab stop, visible on focus) ---------- */
#header .skip-link {
    position: absolute; left: 8px; top: -60px; z-index: 10000;
    background: var(--brand-key); color: var(--color-white) !important;
    padding: 10px 16px; border-radius: 0 0 6px 6px; font-weight: 600; text-decoration: underline;
    transition: top .15s;
}
#header .skip-link:focus { top: 0; outline: 3px solid var(--color-white); box-shadow: 0 0 0 5px var(--brand-key); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Shared icon sizing ---------- */
.ic { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.ic--sm { width: 16px; height: 16px; stroke-width: 2.25; }
.ic--lg { width: 32px; height: 32px; stroke-width: 1.5; }

/* ---------- Header row ---------- */
#header { position: relative; z-index: 50; background: var(--bg-page); color: var(--text-primary); }
#header .gov-header { background: var(--bg-page); }
#header .gov-header__row {
    display: flex; align-items: center; justify-content: space-between; gap: 24px;
    padding: 14px 0; position: relative; float: none; width: auto; height: auto; min-height: 0;
}

/* Logo lockup: emblem + title + subtitle (same as CGI Osaka) */
#header .logo { display: flex; align-items: flex-end; gap: 10px; min-width: 0; float: none; width: auto; height: auto; margin: 0; padding: 0; background: none; }
#header .logo > a { display: inline-flex; align-items: flex-end; flex: none; }
#header .logo .logo-img { height: 88px; width: auto; flex: none; object-fit: contain; }
#header .logo .logo-text-wrapper { min-width: 0; margin: 0; padding: 0; float: none; width: auto; padding-bottom: 8px; }
#header .logo .logo-text { margin: 0; font-size: var(--fs-h2); font-weight: var(--font-bold); line-height: 1.25; color: var(--text-strong); text-shadow: none; }
#header .logo .logo-subtext { margin: 2px 0 0; font-size: var(--fs-body); font-weight: var(--font-regular); line-height: 1.3; color: var(--text-secondary); text-shadow: none; }

/* Tools cluster */
#header .gov-tools { display: flex; align-items: center; gap: 18px; flex: none; position: static; }
#header .tool-sep { width: 1px; height: 38px; background: var(--sep); flex: none; }

#header .tool {
    appearance: none; -webkit-appearance: none; background: transparent; border: 0; margin: 0; padding: 4px 6px;
    display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    min-width: 44px; min-height: 44px; border-radius: 6px; cursor: pointer;
    color: var(--tool-color); font: inherit; font-size: var(--fs-body-small); font-weight: var(--font-regular); line-height: 1.2; text-decoration: none;
    transition: background-color .15s, color .15s;
}
#header .tool:hover, #header .tool:focus-visible { background: var(--hover-bg); color: var(--hover-text); }
#header .tool--icon { width: 48px; height: 48px; padding: 0; border-radius: 8px; }
#header .tool--access[aria-expanded="true"] { background: var(--hover-bg); color: var(--color-white); }
html[data-theme="dark"] #header .tool--access[aria-expanded="true"] { background: #D2DFFF; color: #162F6A; }
#header .tool--search-toggle, #header .tool--menu { display: none; }

/* Theme toggle: show the icon of the mode you would switch to */
#header .tool--icon .ic--sun { display: none; }
html[data-theme="dark"] #header .tool--icon .ic--sun { display: block; }
html[data-theme="dark"] #header .tool--icon .ic--moon { display: none; }

/* Search */
#header .gov-search { margin: 0; padding: 0; float: none; width: 380px; max-width: 100%; position: static; background: none; border: 0; }
#header .gov-search .search-box {
    display: flex; align-items: center; width: 100%; height: 48px; padding: 0 4px 0 14px; margin: 0;
    background: var(--surface); border: 1px solid var(--field-border); border-bottom: 3px solid var(--link-ui);
    border-radius: 4px; box-shadow: none; box-sizing: border-box;
}
#header .gov-search .search-box:focus-within { border-color: var(--focus-ring); border-bottom-color: var(--focus-ring); box-shadow: 0 0 0 3px var(--brand-v3); }
#header .gov-search .search-box input {
    flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; box-shadow: none; outline: 0;
    color: var(--text-primary); font-size: var(--fs-body); padding: 0; margin: 0; width: auto;
}
#header .gov-search .search-box input::placeholder { color: var(--text-secondary); opacity: 1; }
#header .gov-search .search-box button {
    flex: none; width: 44px; height: 44px; border: 0; background: transparent; color: var(--link-ui); cursor: pointer; border-radius: 4px;
    display: inline-flex; align-items: center; justify-content: center; padding: 0; min-height: 0;
}
#header .gov-search .search-box button:hover, #header .gov-search .search-box button:focus-visible { background: var(--hover-bg); color: var(--hover-text); }

/* Language menu */
#header .lang { position: relative; }
#header .lang__list {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 190px; margin: 0; padding: 6px; list-style: none;
    background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 6px; box-shadow: 0 6px 18px rgba(21, 2, 2, .2);
}
#header .lang__list[hidden], #header .a11y-panel[hidden], #header .a11y-legacy[hidden] { display: none !important; }
#header .lang__list li { margin: 0; padding: 0; border: 0; }
#header .lang__list button {
    width: 100%; text-align: left; padding: 10px 12px; border: 0; border-radius: 4px; background: transparent; cursor: pointer;
    font: inherit; font-size: var(--fs-body); color: var(--text-primary); min-height: 44px;
}
#header .lang__list button:hover, #header .lang__list button:focus-visible { background: var(--hover-bg); color: var(--hover-text); }
#header .lang__list button[aria-checked="true"] { font-weight: var(--font-semibold); box-shadow: inset 4px 0 0 var(--accent); }

/* Hidden Google Translate engine (still in the DOM so the widget can run) */
#header .translator-box { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
body { top: 0 !important; }
.skiptranslate iframe.goog-te-banner-frame, .goog-te-banner-frame.skiptranslate { display: none !important; }

/* ---------- Accessibility panel ---------- */
#header .a11y-panel {
    position: absolute; right: 0; top: calc(100% - 4px); z-index: 70; width: 420px; max-width: calc(100vw - 24px);
    background: var(--surface); color: var(--text-primary); border: 1px solid var(--line); border-radius: 10px;
    box-shadow: 0 10px 28px rgba(21, 2, 2, .25); padding: 16px; box-sizing: border-box;
}
#header .a11y-panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
#header .a11y-panel__head h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: var(--fs-body); font-weight: var(--font-semibold); color: var(--text-primary); }
#header .a11y-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
#header .a11y-tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
    min-height: 92px; padding: 12px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
    color: var(--tile-color); cursor: pointer; font: inherit; font-size: var(--fs-small); font-weight: var(--font-semibold); line-height: 1.25; letter-spacing: .02em; text-transform: uppercase;
    transition: background-color .15s, border-color .15s, color .15s;
}
#header .a11y-tile:hover, #header .a11y-tile:focus-visible { background: var(--hover-bg); border-color: var(--link-ui); color: var(--hover-text); }
#header .a11y-tile[aria-pressed="true"] { background: var(--pressed-bg); border-color: var(--pressed-bg); color: var(--pressed-text); }
#header .a11y-panel__foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
#header .a11y-link {
    display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 8px; border: 0; background: transparent; cursor: pointer;
    font: inherit; font-size: var(--fs-body-small); color: var(--link-ui); text-decoration: underline; text-underline-offset: 3px; border-radius: 4px;
}
#header .a11y-link:hover { color: var(--accent); }

/* ---------- Main navigation (desktop) ---------- */
#header .mainNavigation { background: var(--brand-key); border: 0; margin: 0; float: none; width: 100%; box-shadow: none; position: relative; z-index: 40; }
html[data-theme="dark"] #header .mainNavigation { border-bottom: 1px solid #606060; }
#header .mainNavigation .menuPart { position: relative; }
#header #nav { display: flex; flex-wrap: wrap; align-items: stretch; margin: 0; padding: 0; list-style: none; width: 100%; float: none; background: transparent; }
#header #nav > li { position: relative; float: none; margin: 0; padding: 0; border: 0; background: none; width: auto; display: block; }
#header #nav > li > a {
    display: flex; align-items: center; gap: 8px; height: 100%; padding: 18px 12px; margin: 0; border: 0; border-bottom: 0;
    color: var(--color-white); background: transparent; font-size: var(--fs-body); font-weight: var(--font-regular); line-height: 1.3; text-decoration: none; white-space: nowrap;
    transition: background-color .15s;
}
#header #nav > li.has-sub > a::after {
    content: ""; width: 7px; height: 7px; margin: -3px 0 0 4px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); flex: none; transition: transform .15s;
}
#header #nav > li:hover > a, #header #nav > li.hover > a, #header #nav > li.focus > a, #header #nav > li > a:hover, #header #nav > li > a:focus-visible {
    background: var(--brand-v1); color: var(--color-white);
}
#header #nav > li.has-sub:hover > a::after, #header #nav > li.has-sub.hover > a::after { transform: rotate(-135deg); margin-top: 3px; }
#header #nav > li.is-active > a { 
    /* background: var(--brand-v1);  */
    color: var(--color-white); 
    font-weight: var(--font-semibold);
     /* box-shadow: inset 0 -3px 0 var(--color-white); */
     }
#header #nav > li > a:focus-visible { outline: 3px solid var(--color-white); outline-offset: -3px; box-shadow: none; }

/* Submenus + next-level submenus */
#header #nav ul.menuSubUl, #header #nav ul ul {
    background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--accent-2); border-radius: 0 0 6px 6px;
    box-shadow: 0 8px 20px rgba(21, 2, 2, .2); min-width: 280px; margin: 0; padding: 4px 0; list-style: none;
}
html[data-theme="dark"] #header #nav ul.menuSubUl, html[data-theme="dark"] #header #nav ul ul { box-shadow: 0 8px 20px rgba(0, 0, 0, .6); }
#header #nav > li > ul.menuSubUl { top: 100%; left: 0; z-index: 80; }
#header #nav > li:nth-last-child(-n+2) > ul.menuSubUl { left: auto; right: 0; }
#header #nav ul li { float: none; display: block; margin: 0; padding: 0; background: none; border: 0; width: auto; position: relative; }
#header #nav ul li a {
    display: block; padding: 11px 18px; background: var(--surface); color: var(--text-primary); border: 0; border-bottom: 1px solid var(--linen-line);
    font-size: var(--fs-body-small); font-weight: var(--font-regular); line-height: 1.4; white-space: normal; text-decoration: none; text-transform: none;
}
#header #nav ul li:last-child > a { border-bottom: 0; }
#header #nav ul li a:hover, #header #nav ul li a:focus-visible, #header #nav ul li.focus > a, #header #nav ul li.hover > a {
    background: var(--hover-bg); color: var(--hover-text); text-decoration: underline; text-underline-offset: 3px;
}
#header #nav ul li a:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: -3px; box-shadow: none; }
#header #nav ul ul { top: -4px; left: 100%; }

/* ---------- Mobile / tablet header (<= 1023px) ---------- */
@media (max-width: 1023px) {
    #header .gov-header__row { flex-wrap: wrap; gap: 10px 12px; padding: 10px 0; }
    #header .logo { flex: 1 1 0; gap: 10px; }
    #header .logo .logo-img { height: 56px; }
    #header .logo .logo-text { font-size: var(--fs-h3); }
    #header .logo .logo-subtext { font-size: var(--fs-body-small); }
    #header .gov-tools { gap: 4px; margin-left: 0; }
    #header .tool-sep, #header .tool--sitemap { display: none; }
    #header .tool--search-toggle { display: inline-flex; }
    #header .tool--icon { width: 44px; height: 44px; }

    #header .gov-search { display: none; order: 3; flex: 1 1 100%; width: 100%; }
    #header .gov-search.is-open { display: block; }

    #header .a11y-panel { top: 100%; right: 0; left: auto; }

    /* the legacy off-canvas menu replaces the desktop nav bar */
    #header .mainNavigation { display: none; }
    #header .gov-tools .menu-trigger {
        display: inline-flex !important; align-items: center; justify-content: center; float: none; margin: 0 0 0 4px; width: 48px; height: 48px; min-width: 48px; padding: 0;
        overflow: visible; position: relative; background: var(--brand-key); color: var(--color-white); border-radius: 8px;
    }
    #header .gov-tools .menu-trigger span { float: none; display: block; width: 22px; height: 3px; margin: 0; background: var(--color-white); position: relative; }
    #header .gov-tools .menu-trigger span:before, #header .gov-tools .menu-trigger span:after { width: 22px; background: var(--color-white); }
    #header .gov-tools .menu-trigger span:after { top: -7px; }
    #header .gov-tools .menu-trigger span:before { bottom: -7px; }
    #header .gov-tools .menu-trigger em { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); margin: 0; }
    .mp-pushed #header .gov-tools .menu-trigger span { background: transparent !important; }
}
@media (max-width: 767px) {
    #header .a11y-panel { position: fixed; left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: calc(100vh - 80px); overflow-y: auto; }
    #header .logo .logo-img { height: 48px; }
}
@media (max-width: 380px) {
    #header .logo .logo-text { font-size: var(--fs-body); }
    #header .tool--icon, #header .tool, #header .gov-tools .menu-trigger { min-width: 40px; }
    #header .tool--icon { width: 40px; height: 40px; }
    #header .gov-tools .menu-trigger { width: 42px; height: 42px; }
    #header .a11y-grid { gap: 8px; }
}

/* Accessibility feature classes (set by header-ui.js on <html>) */
html { filter: var(--a11y-filter, none); }
html.a11y-invert img, html.a11y-invert video, html.a11y-invert iframe, html.a11y-invert .logo-img { filter: invert(1) hue-rotate(180deg); }
html.a11y-links a { text-decoration: underline !important; text-underline-offset: 3px; background: var(--brand-v4) !important; color: var(--brand-key) !important; outline: 2px solid var(--brand-v2); outline-offset: 1px; }
html.a11y-noimg img:not(.logo-img) { visibility: hidden; }
html.a11y-noimg .dataSlider, html.a11y-noimg .sliderImg { background-image: none !important; }
html.a11y-cursor, html.a11y-cursor * { cursor: default !important; }

@media (prefers-reduced-motion: reduce) { #header * { transition: none !important; } }

/* ---------- Submenu visibility (hover, keyboard focus, JS .hover/.focus classes) ---------- */
#header #nav ul.menuSubUl, #header #nav ul ul { display: none !important; position: absolute; }
#header #nav li:hover > ul, #header #nav li.hover > ul, #header #nav li.focus > ul, #header #nav li:focus-within > ul { display: block !important; }
#header #nav > li { flex: 0 0 auto; width: auto !important; }
@media (max-width: 1023px) { #header #nav ul.menuSubUl { display: none !important; } }

/* Legacy mobile CSS centres and stacks the lockup: keep emblem + text side by side */
@media (max-width: 1023px) {
    #header .logo { flex-direction: row !important; text-align: left !important; justify-content: flex-start !important; width: auto; }
}
@media (max-width: 767px) {
    #header .gov-header__row { row-gap: 8px; }
    #header .logo { flex: 1 1 100%; }
    #header .gov-tools { flex: 1 1 100%; justify-content: space-between; margin-left: 0; order: 2; padding-top: 6px; border-top: 1px solid var(--linen-line); }
    #header .gov-search { order: 3; }
}

/* Legacy clearfix/pseudo elements become empty flex items inside the new flex rows */
#header .gov-header__row::before, #header .gov-header__row::after,
#header .gov-tools::before, #header .gov-tools::after, #header .logo::before, #header .logo::after { content: none !important; display: none !important; }

/* Keep a wrapping row even if legacy mobile CSS turns header rows into columns */
#header .gov-header__row { flex-direction: row !important; flex-wrap: wrap; align-items: center !important; justify-content: space-between !important; text-align: left; }
@media (min-width: 1024px) { #header .gov-header__row { flex-wrap: nowrap; } }
#header .gov-tools { flex-direction: row !important; }

/* Small desktops / landscape tablets (1024-1279) */
@media (min-width: 1024px) and (max-width: 1279px) {
    #header .gov-header__row { gap: 16px; }
    #header .logo { flex: 1 1 auto; min-width: 0; gap: 12px; }
    #header .logo .logo-img { height: 72px; }
    #header .gov-tools { gap: 10px; }
    #header .gov-search { width: 230px; }
    #header .tool-sep { display: none; }
    #header #nav > li > a { padding: 16px 14px; }
}

/* ---------- Mobile off-canvas menu colours (from Osaka colours.css, scoped) ---------- */
#menuPartWrapper, .mp-menu, .mobMenuPart { background: var(--brand-key); color: var(--color-white); }
#menuPartWrapper h2 { color: var(--color-white); }
#menuPartWrapper a { color: var(--color-white); border-bottom: 1px solid rgba(255, 255, 255, .25); font-size: var(--fs-body); font-weight: var(--font-medium); text-transform: none; }
#menuPartWrapper a:hover, #menuPartWrapper a:focus-visible { background: var(--color-white); color: var(--brand-key); }
#menuPartWrapper a:focus-visible { outline: 3px solid var(--color-white); outline-offset: -3px; }

/* ==========================================================================
   Lome-specific adaptations (Lome markup differs from Osaka in these places)
   ========================================================================== */

/* Focus ring for header controls (Osaka gets this from colours.css, which Lome does not load) */
#header a:focus-visible, #header button:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

/* Filled tool icons (sitemap / language / accessibility) - replaces the inline style="" */
#header .tool-svg { display: block; width: 24px; height: 24px; flex: none; }

/* Lome keeps Sitemap, Contact and Feedback reachable on mobile (they were in the top strip) */
@media (max-width: 1023px) { #header .tool--sitemap { display: inline-flex; } }
@media (max-width: 380px) {
    #header .gov-tools .tool, #header .gov-tools .tool--icon { min-width: 34px; width: 34px; height: 40px; padding: 0; }
    #header .gov-tools .tool-svg, #header .gov-tools .ic { width: 20px; height: 20px; }
    #header .gov-tools .menu-trigger { width: 40px; height: 40px; min-width: 40px; }
}

/* Legacy search classes kept on the controls: neutralise their sprite / float rules */
#header .gov-search .search-box .searchInput { float: none; border: 0; background: transparent; box-shadow: none; }
#header .gov-search .search-box .searchGo { background-image: none; text-indent: 0; float: none; margin: 0; box-shadow: none; }

/* Nested submenus of the last two top items open to the left so they stay in the viewport */
#header #nav > li:nth-last-child(-n+2) ul ul { left: auto; right: 100%; }
#header #nav ul.menuSubUl { max-width: calc(100vw - 24px); }

/* India / Togo clocks row (Lome only) */
#header .lome-clocks {
    display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px 20px;
    padding: 6px 0; border-top: 1px solid var(--linen-line); float: none; width: auto;
}
#header .lome-clocks .clock { display: inline-flex; align-items: center; gap: 6px; }
#header .lome-clocks iframe { display: block; border: 0; max-width: calc(100vw - 60px); }
#header .lome-clocks img { display: block; }
@media (max-width: 767px) { #header .lome-clocks { justify-content: center; } }