/* ==========================================================================
   Government header + main navigation + accessibility panel
   Loaded after colours.css / typography.css. All colours come from the DBIM
   Blue group tokens (--brand-*) and the functional palette (--color-*).
   Breakpoints: <= 1023px = mobile/tablet header (matches body.mobile in general-new.js)
   ========================================================================== */

/* The flag strip image above the header is not part of the DBIM header */
india-flag { display: none !important; }

/* ---------- 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); }
#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 */
#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 .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-gov { margin: 0 0 2px; font-size: var(--fs-body); font-weight: var(--font-regular); line-height: 1.3; color: var(--text-primary); text-shadow: none; }
#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; }
#header .logo .logo-subtext1 { font-size: inherit; }

/* 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(--brand-v3); 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(--brand-key); 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(--brand-v4); color: var(--brand-key); }
#header .tool .tool__label { display: inline-flex; align-items: center; gap: 4px; color: var(--text-primary); white-space: nowrap; }
#header .tool--icon { width: 48px; height: 48px; padding: 0; border-radius: 8px; }
/* #header .tool--access { background: var(--brand-v4); } */
#header .tool--access[aria-expanded="true"] { background: var(--brand-v4); color: var(--color-white); }
#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(--color-white); border: 1px solid var(--color-grey-01); border-bottom: 3px solid var(--brand-v1);
    border-radius: 4px; box-shadow: none;
}
#header .gov-search .search-box:focus-within { border-color: var(--brand-key); border-bottom-color: var(--brand-key); 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(--brand-v1); 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(--brand-v4); color: var(--brand-key); }

/* 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(--color-white); border: 1px solid var(--color-grey-01); border-top: 3px solid var(--brand-key); 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(--brand-v4); color: var(--brand-key); }
#header .lang__list button[aria-checked="true"] { font-weight: var(--font-semibold); box-shadow: inset 4px 0 0 var(--brand-key); }

/* 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(--color-white); color: var(--text-primary); border: 1px solid var(--color-grey-01); border-radius: 10px;
    box-shadow: 0 10px 28px rgba(21, 2, 2, .25); padding: 16px;
}
#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(--color-grey-01); border-radius: 8px; background: var(--color-white);
    color: var(--brand-key); 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(--brand-v4); border-color: var(--brand-v1); }
#header .a11y-tile[aria-pressed="true"] { background: var(--brand-key); border-color: var(--brand-key); color: var(--color-white); }
#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(--color-grey-01); }
#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(--brand-v1); text-decoration: underline; text-underline-offset: 3px; border-radius: 4px;
}
#header .a11y-link:hover { color: var(--brand-key); }

/* ---------- 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; }
#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(--color-white); border: 1px solid var(--color-grey-01); border-top: 3px solid var(--brand-v2); 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;
}
#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(--color-white); color: var(--text-primary); border: 0; border-bottom: 1px solid var(--color-linen);
    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(--brand-v4); color: var(--brand-key); text-decoration: underline; text-underline-offset: 3px;
}
#header #nav ul li a:focus-visible { outline: 3px solid var(--brand-key); 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-gov { font-size: var(--fs-small); margin: 0; }
    #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 .tool--lang .tool__label { font-size: var(--fs-body-small); }

    #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 .tool--lang .tool__label #langCurrent { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    #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-gov { display: none; }
    #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 { justify-content: flex-start; } */
#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; }
    #header .logo .logo-text-wrapper { text-align: left !important; }
}
@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(--color-linen); }
    #header .gov-search { order: 3; }
    #header .tool--lang .tool__label { flex-direction: row; }
}

/* 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; }

/* Legacy mobile CSS turns .header-container into a centred column; keep a wrapping row */
#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): keep the lockup on one comfortable block */
@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 .logo .logo-text { font-size: var(--fs-h3); }
    #header .logo .logo-gov, #header .logo .logo-subtext { font-size: var(--fs-body-small); }
    #header .gov-tools { gap: 10px; }
    #header .gov-search { width: 230px; }
    #header .tool-sep { display: none; }
    #header #nav > li > a { padding: 16px 14px; }
}
