/* ==========================================================================
   Site chrome — the shared header and footer (glass design from the app-download design)

   Loaded by common/header.tpl on every page, last in <head>, so it wins ties against
   newui.css and the inline styles in header.tpl. It is self-contained on purpose: three
   pages (payment, account, 404) don't load newui.css, and the header must work there too.

   It is a separate file rather than an edit to newui.css because the CDN bucket is shared
   by stage and prod: changing newui.css would change production's header the moment it is
   uploaded, before production has the matching markup.

   1. Sticky fix + tokens
   2. Header (bar, brand, glass nav pill, actions, hamburger, mobile menu)
   3. Footer
   ========================================================================== */

/* ---------- 1. Sticky fix + tokens ---------------------------------------- */
:root {
  --hc-font: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Devanagari', 'Nirmala UI', Arial, sans-serif;
  --hc-bar: linear-gradient(90deg, #03054F 0%, #5009A6 100%);   /* same colours as the top edge of the get-app hero */
  --hc-night: #11023C;
  --hc-amber: #FBBF24;
  --hc-ink: #1B1448;
  --hc-subtle: #94A3B8;
  --hc-nav-h: 72px;
}

/* header.tpl sets overflow-x:hidden on <html> AND <body>. That turns <body> into a scroll
   container, and a sticky child then pins itself to something that never scrolls, so the header
   scrolled away. `clip` clips horizontally exactly like `hidden` but doesn't create one. */
body { overflow-x: clip !important; }

/* #anchor links would otherwise scroll their target underneath the sticky header */
html:not(:has(#sticky-anchor)) { scroll-padding-top: calc(var(--hc-nav-h) + 12px); }

/* ---------- 2. Header ------------------------------------------------------ */
.hkd-topnav {
  position: sticky; top: 0; z-index: 1000;
  background: var(--hc-bar); border: 0;
  box-shadow: 0 12px 28px -20px rgba(2, 3, 40, .65);
  -webkit-backdrop-filter: none; backdrop-filter: none;
  font-family: var(--hc-font);
}
/* The dictionary pages pin their own search bar at top:0 (and say so in their comments), so on
   those pages the header keeps scrolling away exactly as before. */
body:has(#sticky-anchor) .hkd-topnav { position: relative; }

.hkd-topnav__inner {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  max-width: 1200px; height: var(--hc-nav-h); margin: 0 auto; padding: 0 24px;
}

/* Brand lockup: icon + name, with the existing tagline under it */
.hkd-topnav .hkd-brand {
  display: flex; align-items: center; gap: 12px; flex: 0 1 auto; min-width: 0;
  color: #fff !important; text-decoration: none !important; font-family: var(--hc-font);
}
.hkd-brand__icon { display: block; flex: none; width: 40px; height: 40px; border-radius: 10px; }
.hkd-brand__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.hkd-brand__name {
  font-size: 18px; font-weight: 800; letter-spacing: -.01em; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hkd-topnav .hkd-brand__accent { color: inherit; }
.hkd-topnav .hkd-brand__tag { margin: 3px 0 0; font-size: 10px; font-weight: 500; letter-spacing: .01em; color: rgba(255, 255, 255, .72); white-space: nowrap; }

/* Glass nav pill */
.hkd-topnav .hkd-topnav__links {
  display: flex; align-items: center; gap: 0; height: 48px; padding: 4px;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .18); border-radius: 12px;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.hkd-topnav .hkd-topnav__links a {
  display: inline-flex; align-items: center; height: 38px; padding: 0 16px; border-radius: 8px;
  font: 500 14px/1 var(--hc-font); color: #CBD5E1 !important; white-space: nowrap; text-decoration: none !important;
  transition: color .2s, background-color .2s;
}
.hkd-topnav .hkd-topnav__links a:hover { color: #fff !important; background: rgba(255, 255, 255, .09); }

/* Actions: app button, login (or avatar) */
.hkd-topnav .hkd-topnav__actions { display: flex; align-items: center; gap: 12px; flex: none; }
.hkd-topnav .hkd-get-app-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 12px; background: var(--hc-amber); color: var(--hc-ink) !important;
  font: 700 14px/1 var(--hc-font); white-space: nowrap; text-decoration: none !important; transition: background-color .2s, transform .15s;
}
.hkd-topnav .hkd-get-app-btn:hover { background: #FCD34D; }
.hkd-topnav .hkd-get-app-btn svg { flex: none; }
.hkd-topnav .hkd-get-app-btn svg path { fill: currentColor; }   /* one colour on the amber button */

.hkd-topnav .hkd-desktop-login {
  display: inline-flex !important; align-items: center; gap: 12px; height: 40px; padding: 0 0 0 8px !important;
  background: transparent !important; border: 0 !important; box-shadow: none !important; border-radius: 0 !important;
  font: 500 14px/1 var(--hc-font) !important; color: #fff !important; text-decoration: none !important;
}
.hkd-topnav .hkd-desktop-login::after {
  content: ''; width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255, 255, 255, .13) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E") center / 16px no-repeat;
  transition: background-color .2s;
}
.hkd-topnav .hkd-desktop-login:hover::after { background-color: rgba(255, 255, 255, .22); }

/* Logged in: avatar + name */
.hkd-topnav .hkd-profile-dropdown #profile { display: inline-flex; align-items: center; gap: 10px; padding: 0; background: transparent; border: 0; color: #fff; }
.hkd-topnav .hkd-avatar { width: 32px; height: 32px; background: rgba(255, 255, 255, .13); color: #fff; font-size: 13px; }
.hkd-topnav .hkd-profile-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff !important; font: 500 14px/1 var(--hc-font) !important; }
.hkd-topnav .hkd-profile-dropdown #profile:hover { background: transparent; }

/* Hamburger (shown when the nav pill is hidden) */
.hkd-topnav .hkd-hamburger {
  display: none; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; padding: 0;
  border-radius: 12px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .18); color: #fff; cursor: pointer;
  transition: background-color .2s;
}
.hkd-topnav .hkd-hamburger:hover { background: rgba(255, 255, 255, .18); }
.hkd-topnav .hkd-hamburger svg { display: block; }
.hkd-topnav .hkd-hamburger .hkd-hamburger__close { display: none; }
.hkd-topnav.is-open .hkd-hamburger .hkd-hamburger__open { display: none; }
.hkd-topnav.is-open .hkd-hamburger .hkd-hamburger__close { display: block; }

.hkd-topnav a:focus-visible, .hkd-topnav button:focus-visible { outline: 2px solid var(--hc-amber); outline-offset: 3px; }

/* Mobile menu: a glass panel under the bar */
.hkd-topnav .hkd-topnav__mobile {
  display: none; position: absolute; top: calc(100% + 8px); left: 12px; right: 12px; z-index: 1;
  flex-direction: column; gap: 2px; width: auto; padding: 8px; box-sizing: border-box;
  background: rgba(12, 6, 70, .97); border: 1px solid rgba(255, 255, 255, .14); border-radius: 16px;
  box-shadow: 0 24px 48px -16px rgba(2, 3, 40, .65);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.hkd-topnav .hkd-topnav__mobile--open { display: flex !important; flex-direction: column; }
.hkd-topnav .hkd-topnav__mobile a {
  display: flex; align-items: center; padding: 12px 14px; border-radius: 10px;
  font: 500 15px/1.3 var(--hc-font); color: #E2E8F0 !important; text-decoration: none !important;
}
.hkd-topnav .hkd-topnav__mobile a:hover { background: rgba(255, 255, 255, .08); color: #fff !important; }
.hkd-topnav .hkd-topnav__mobile .hkd-mobile-getapp-btn {
  gap: 10px; margin-top: 6px; background: var(--hc-amber); color: var(--hc-ink) !important; font-weight: 700; justify-content: center;
}
.hkd-topnav .hkd-topnav__mobile .hkd-mobile-getapp-btn:hover { background: #FCD34D; color: var(--hc-ink) !important; }
.hkd-topnav .hkd-topnav__mobile .hkd-mobile-getapp-btn svg path { fill: currentColor; }
.hkd-topnav .hkd-topnav__mobile .hkd-mobile-login-btn {
  display: flex; justify-content: center; margin-top: 6px; background: #fff; color: var(--hc-ink) !important; font-weight: 700; border: 0; box-shadow: none;
}
.hkd-topnav .hkd-topnav__mobile .hkd-mobile-login-btn:hover { background: #F1F5F9; color: var(--hc-ink) !important; }

/* narrower laptops: tighter pill, and a signed-in user is shown as the avatar alone */
@media (max-width: 1199px) {
  .hkd-topnav .hkd-profile-name { display: none; }
}
@media (max-width: 1099px) {
  .hkd-topnav .hkd-topnav__links a { padding: 0 12px; }
}
/* below 1024px the nav pill no longer fits next to the actions: it moves into the menu */
@media (max-width: 1023px) {
  .hkd-topnav .hkd-topnav__links { display: none; }
  .hkd-topnav .hkd-hamburger { display: inline-flex; }
  .hkd-topnav__actions { margin-left: auto; }
}
@media (max-width: 767px) {
  :root { --hc-nav-h: 60px; }
  .hkd-topnav__inner { gap: 10px; padding: 0 16px; }
  .hkd-topnav .hkd-desktop-login { display: none !important; }   /* Login lives in the menu on phones, as it always did */
  .hkd-topnav .hkd-profile-name { display: none; }
  .hkd-brand__icon { width: 34px; height: 34px; border-radius: 9px; }
  .hkd-brand__name { font-size: 16px; }
  .hkd-brand__tag { font-size: 9px; }
  .hkd-topnav .hkd-get-app-btn { height: 36px; padding: 0 12px; font-size: 13px; }
}
@media (max-width: 479px) {
  .hkd-topnav .hkd-get-app-btn { width: 36px; padding: 0; }
  .hkd-get-app-btn__text { display: none; }
}
@media (max-width: 359px) {
  .hkd-topnav__inner { padding: 0 12px; }
  .hkd-topnav .hkd-get-app-btn { display: none; }   /* still in the menu */
  .hkd-brand__tag { display: none; }
}

/* ---------- 3. Footer ------------------------------------------------------ */
.hkd-footer { background: var(--hc-night); border-top: 2px solid #1E293B; padding: 64px 0 40px; color: var(--hc-subtle); font-family: var(--hc-font); }
.hkd-footer .container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.hkd-footer__grid {
  display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, .8fr) minmax(0, 1.6fr) minmax(0, 1fr); gap: 24px; margin: 0;
}

.hkd-footer__brand { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; }
.hkd-footer__icon { display: block; flex: none; width: 40px; height: 40px; border-radius: 10px; }
.hkd-footer__brandtext { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.hkd-footer__name { font-size: 18px; font-weight: 800; letter-spacing: -.01em; color: #fff; }
.hkd-footer .hkd-footer__tag { display: block; margin: 3px 0 0; font-size: 10px; font-weight: 500; color: rgba(255, 255, 255, .72); }
.hkd-footer p, .hkd-footer .hkd-footer__desc { max-width: 380px; margin: 0 0 20px; font-size: 14px; line-height: 20px; color: var(--hc-subtle); }
.hkd-footer__apps { margin-top: 4px; }

.hkd-footer h4 { margin: 4px 0 20px; font-family: var(--hc-font); font-size: 14px; line-height: 20px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #fff; }
.hkd-footer .hkd-footer__ul { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.hkd-footer .hkd-footer__ul a { font-size: 14px; line-height: 20px; color: var(--hc-subtle); text-decoration: none; transition: color .2s; }
.hkd-footer .hkd-footer__ul a:hover { color: #fff; text-decoration: none; }
.hkd-footer .hkd-footer__ul--dict { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 20px; }

.hkd-footer .hkd-footer__social { display: flex; gap: 8px; }
.hkd-footer .hkd-footer__social a {
  display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%;
  background: #1F0F4C; border: 1px solid #1E293B; color: var(--hc-subtle); text-decoration: none; transition: background-color .2s, border-color .2s, color .2s;
}
.hkd-footer .hkd-footer__social a:hover { background: #2563EB; border-color: #2563EB; color: #fff; text-decoration: none; }

.hkd-footer .hkd-footer__bottom { margin-top: 56px; padding-top: 24px; border-top: 1px solid #18183B; text-align: left; font-size: 12px; line-height: 16px; color: #8A97AB; }
.hkd-footer a:focus-visible { outline: 2px solid var(--hc-amber); outline-offset: 3px; border-radius: 4px; }

@media (max-width: 1199px) {
  .hkd-footer__grid { grid-template-columns: minmax(0, 1.5fr) minmax(0, .8fr) minmax(0, 1.6fr) minmax(0, 1fr); }
}
@media (max-width: 991px) {
  /* brand on its own row, then Learn | Company, then Dictionary across the full width */
  .hkd-footer__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 36px; }
  .hkd-footer__grid > div:nth-child(1) { grid-column: 1 / -1; }
  .hkd-footer__grid > div:nth-child(3) { grid-column: 1 / -1; order: 1; }
  .hkd-footer .hkd-footer__ul--dict { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 599px) {
  .hkd-footer { padding: 44px 0 28px; }
  .hkd-footer .container { padding: 0 20px; }
  .hkd-footer__grid { column-gap: 20px; row-gap: 32px; }
  .hkd-footer .hkd-footer__ul--dict { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hkd-footer .hkd-footer__bottom { margin-top: 36px; }
}
@media (max-width: 359px) {
  .hkd-footer__grid { grid-template-columns: minmax(0, 1fr); }
  .hkd-footer__grid > div:nth-child(3) { order: 0; }
}
