/*
 * LeedyBox shared chrome: sticky header with dropdown menus, footer,
 * cookie banner, back-to-top button, toast and tool-page link block.
 * Loaded on every page (Tailwind tool pages and site.css content pages),
 * so every rule is scoped to an lb-* class and sets its own box model.
 */

html[data-theme="dark"] {
  color-scheme: dark;
}

.lb-header,
.lb-footer,
.lb-consent,
.lb-skip,
.lb-top,
.lb-toast {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  line-height: 1.5;
  box-sizing: border-box;
}

.lb-header *,
.lb-footer *,
.lb-consent * {
  box-sizing: border-box;
}

.lb-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Skip link ---------- */
.lb-skip {
  position: fixed;
  left: 12px;
  top: -48px;
  z-index: 1000;
  padding: 8px 14px;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.15s ease;
}

.lb-skip:focus {
  top: 12px;
}

/* ---------- Header ---------- */
.lb-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.97);
  border-bottom: 1px solid #1e293b;
  color: #f8fafc;
  -webkit-backdrop-filter: saturate(160%) blur(8px);
  backdrop-filter: saturate(160%) blur(8px);
}

.lb-header__inner {
  position: relative;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.lb-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #ffffff !important;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-decoration: none !important;
  flex-shrink: 0;
}

.lb-brand__mark {
  width: 28px;
  height: 28px;
  display: block;
}

/* Desktop menu */
.lb-nav {
  flex: 1 1 auto;
  min-width: 0;
}

.lb-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 2px;
}

.lb-menu__item {
  position: relative;
}

.lb-menu__link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 18px 12px;
  color: #cbd5e1 !important;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none !important;
  transition: color 0.15s ease;
}

.lb-menu__link svg {
  width: 14px;
  height: 14px;
  transition: transform 0.15s ease;
}

.lb-menu__item:hover > .lb-menu__link,
.lb-menu__item:focus-within > .lb-menu__link,
.lb-menu__item.is-open > .lb-menu__link,
.lb-menu__link.is-active {
  color: #ffffff !important;
}

.lb-menu__link.is-active {
  box-shadow: inset 0 -2px 0 var(--lb-accent, #3b82f6);
}

.lb-menu__item:hover > .lb-menu__link svg,
.lb-menu__item.is-open > .lb-menu__link svg {
  transform: rotate(180deg);
}

/* Dropdown panels */
.lb-sub {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  padding: 10px;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.45);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
}

.lb-menu__item:hover > .lb-sub,
.lb-menu__item:focus-within > .lb-sub,
.lb-menu__item.is-open > .lb-sub {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition-delay: 0s;
}

.lb-sub__title {
  display: block;
  margin: 0 0 4px;
  padding: 6px 10px 4px;
  color: #94a3b8 !important;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none !important;
}

.lb-sub__title--gap {
  margin-top: 8px;
  border-top: 1px solid #1e293b;
  padding-top: 12px;
}

a.lb-sub__title:hover {
  color: #ffffff !important;
}

/* Section heading inside a menu panel (e.g. "ID number validators" under Developer Tools) */
.lb-sub__section {
  display: block;
  padding: 8px 10px 2px;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.lb-sub__section--gap {
  margin-top: 6px;
  border-top: 1px solid #1e293b;
  padding-top: 10px;
}

.lb-sub a.lb-sub__link {
  display: block;
  padding: 7px 10px;
  border-radius: 8px;
  color: #e2e8f0 !important;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none !important;
  white-space: nowrap;
}

.lb-sub a.lb-sub__link:hover,
.lb-sub a.lb-sub__link:focus-visible {
  background: #1e293b;
  color: #ffffff !important;
}

.lb-sub a.lb-sub__link[aria-current="page"] {
  background: #1e293b;
  color: #ffffff !important;
  box-shadow: inset 2px 0 0 var(--lb-accent, #3b82f6);
}

/* Cascading dropdowns: a first-level list whose rows open a panel to the right */
.lb-sub--cascade {
  min-width: 230px;
}

.lb-fly {
  position: relative;
}

.lb-sub a.lb-fly__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lb-fly__trigger svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transform: rotate(-90deg);
  opacity: 0.7;
}

.lb-sub .lb-fly:hover > a.lb-fly__trigger,
.lb-sub .lb-fly:focus-within > a.lb-fly__trigger,
.lb-sub .lb-fly.is-open > a.lb-fly__trigger {
  background: #1e293b;
  color: #ffffff !important;
}

.lb-sub.lb-fly__panel {
  top: -10px;
  left: 100%;
  margin-left: 8px;
  min-width: 230px;
  max-width: 360px;
  transform: translateX(-6px);
}

/* Invisible bridge so the pointer can cross the gap without closing the panel */
.lb-fly__panel::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -10px;
  width: 10px;
}

.lb-fly__panel a.lb-sub__link {
  white-space: normal;
}

.lb-fly:hover > .lb-fly__panel,
.lb-fly:focus-within > .lb-fly__panel,
.lb-fly.is-open > .lb-fly__panel {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  transition-delay: 0s;
}

/* Right-hand tools */
.lb-header__tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.lb-support {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #fda4af !important;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none !important;
}

.lb-support svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.lb-support:hover,
.lb-support[aria-current="page"] {
  background: #334155;
  color: #ffffff !important;
}

@media (max-width: 600px) {
  .lb-support {
    width: 36px;
    padding: 0;
    justify-content: center;
  }

  .lb-support span {
    display: none;
  }
}

.lb-lang {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
}

.lb-lang svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.lb-lang select {
  appearance: auto;
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  max-width: 150px;
}

.lb-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  cursor: pointer;
}

.lb-icon-btn:hover {
  background: #334155;
}

.lb-icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Theme button shows the icon of the theme you can switch to. */
.lb-theme .lb-i-sun {
  display: none;
}

html[data-theme="dark"] .lb-theme .lb-i-sun {
  display: block;
}

html[data-theme="dark"] .lb-theme .lb-i-moon {
  display: none;
}

.lb-menu-toggle {
  display: none;
}

.lb-header a:focus-visible,
.lb-header select:focus-visible,
.lb-header button:focus-visible,
.lb-footer a:focus-visible,
.lb-footer button:focus-visible,
.lb-consent a:focus-visible,
.lb-consent button:focus-visible,
.lb-top:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

/* Mobile: hamburger + full-width panel with every submenu expanded */
@media (max-width: 960px) {
  .lb-header__inner {
    padding: 0 12px;
    gap: 10px;
  }

  .lb-menu-toggle {
    display: inline-flex;
    order: 3;
  }

  .lb-header__tools {
    order: 2;
  }

  .lb-lang > svg {
    display: none;
  }

  .lb-lang select {
    max-width: 110px;
  }

  .lb-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: calc(100vh - 58px);
    overflow-y: auto;
    background: #0f172a;
    border-bottom: 1px solid #1e293b;
    box-shadow: 0 18px 40px rgba(2, 6, 23, 0.45);
    padding: 8px 12px 16px;
  }

  .lb-header.is-menu-open .lb-nav {
    display: block;
  }

  .lb-menu {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .lb-menu__item {
    border-bottom: 1px solid #1e293b;
  }

  /* Mobile: Tools, Guides and About start collapsed; a tap opens one */
  .lb-menu__link {
    display: flex;
    justify-content: space-between;
    padding: 14px 6px;
    font-size: 15px;
    color: #ffffff !important;
  }

  .lb-menu__item > .lb-sub {
    display: none;
  }

  .lb-menu__item.is-open > .lb-sub {
    display: block;
  }

  .lb-menu__item:hover > .lb-menu__link svg {
    transform: none;
  }

  .lb-menu__item.is-open > .lb-menu__link svg {
    transform: rotate(180deg);
  }

  .lb-sub {
    position: static;
    display: block;
    opacity: 1;
    visibility: visible;
    transform: none;
    min-width: 0;
    padding: 0 0 10px;
    border: 0;
    box-shadow: none;
    background: transparent;
  }

  /* Mobile: second-level rows are collapsed; a tap on a row opens its list under it */
  .lb-sub.lb-fly__panel {
    display: none;
    margin: 0 0 0 12px;
    max-width: none;
    padding: 0 0 4px;
  }

  .lb-fly.is-open > .lb-sub.lb-fly__panel {
    display: block;
  }

  .lb-fly__panel::before {
    display: none;
  }

  .lb-fly__trigger svg {
    transform: none;
    transition: transform 0.15s ease;
  }

  .lb-fly.is-open > .lb-fly__trigger svg {
    transform: rotate(180deg);
  }

  /* The panel title links to the group's overview page */
  .lb-fly__panel > .lb-sub__title {
    margin: 0;
    padding: 6px 10px;
    text-transform: none;
    letter-spacing: 0;
    font-size: 13px;
  }

  .lb-fly__panel > .lb-sub__title::after {
    content: " \2192";
  }

  .lb-sub a.lb-sub__link {
    white-space: normal;
  }
}

@media (max-width: 420px) {
  .lb-brand span {
    display: none;
  }
}

/* ---------- Footer ---------- */
.lb-footer {
  margin-top: auto;
  background: #0f172a;
  border-top: 1px solid #1e293b;
  color: #94a3b8;
  font-size: 13px;
}

main + .lb-footer {
  margin-top: 60px;
}

.lb-footer__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.lb-footer__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  margin: 0;
  padding: 0;
}

.lb-footer__links a,
.lb-footer__links button {
  color: #cbd5e1 !important;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none !important;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.lb-footer__links a:hover,
.lb-footer__links button:hover {
  color: #ffffff !important;
  text-decoration: underline !important;
}

.lb-footer__copy {
  margin: 0;
  /* #94a3b8 on #0f172a: 6.9:1 (the former #64748b was 3.8:1, below WCAG AA for 12px text) */
  color: #94a3b8;
  font-size: 12px;
}

/* ---------- Back to top ---------- */
.lb-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 55;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #f8fafc;
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.35);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s, bottom 0.2s ease;
}

.lb-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition-delay: 0s;
}

.lb-top:hover {
  background: #1e293b;
}

.lb-top svg {
  width: 20px;
  height: 20px;
}

/* ---------- Toast ---------- */
.lb-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10000;
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 12px;
  background: #0f172a;
  border: 1px solid #f59e0b;
  color: #f8fafc;
  font-size: 14px;
  box-shadow: 0 12px 32px rgba(2, 6, 23, 0.45);
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.lb-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Cookie consent banner ---------- */
.lb-consent {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: #0f172a;
  border-top: 1px solid #334155;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.25);
  color: #e2e8f0;
}

.lb-consent__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
}

.lb-consent__text {
  flex: 1 1 320px;
  margin: 0;
  font-size: 13px;
  color: #cbd5e1;
}

.lb-consent__text a {
  color: #93c5fd !important;
  text-decoration: underline !important;
}

.lb-consent__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.lb-consent__btn {
  padding: 8px 18px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid #475569;
  background: transparent;
  color: #e2e8f0;
}

.lb-consent__btn:hover {
  background: #1e293b;
}

.lb-consent__btn--primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.lb-consent__btn--primary:hover {
  background: #1d4ed8;
}

/* ---------- Tool page: "check the results" notice ----------
   Same as the inline styles of the data tool pages; the converter and PDF tool pages need it here.
   Dark colours come from tool-dark.css. */
.disclaimer-banner { width: 100%; margin-bottom: 1.5rem; padding: 0.75rem 1rem; border: 1px solid #e2e8f0; border-radius: 0.75rem; background-color: #f8fafc; color: #475569; font-size: 0.8125rem; line-height: 1.6; }
.disclaimer-title { font-weight: 700; color: #334155; }
.disclaimer-detail { color: #64748b; }
.disclaimer-link { font-weight: 600; text-decoration: underline; }

/* ---------- Tool page: guide and related-tool links ---------- */
.lb-related {
  margin-top: 8px;
  padding: 16px 18px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  font-size: 14px;
  color: #475569;
}

.lb-related p {
  margin: 0;
}

.lb-related p + p {
  margin-top: 8px;
}

.lb-related strong {
  color: #0f172a;
}

.lb-related a {
  color: #2563eb;
  font-weight: 600;
  text-decoration: none;
}

.lb-related a:hover {
  text-decoration: underline;
}

.lb-related__sep {
  color: #cbd5e1;
  margin: 0 6px;
}

html[data-theme="dark"] .lb-related {
  background: #0b0f19;
  border-color: #1f2937;
  color: #9ca3af;
}

html[data-theme="dark"] .lb-related strong {
  color: #f3f4f6;
}

html[data-theme="dark"] .lb-related a {
  color: #60a5fa;
}

html[data-theme="dark"] .lb-related__sep {
  color: #374151;
}

/* Small notes added by LeedyBox scripts inside tool pages */
.lb-note {
  margin: 6px 0 0;
  font-size: 12px;
  color: #64748b;
}

html[data-theme="dark"] .lb-note {
  color: #9ca3af;
}

/* "Source · Last checked" line under figures from a country dataset (sources/data/tools/lib/source-note.js) */
.lb-source {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: #64748b;
  overflow-wrap: break-word;
}

.lb-source a {
  color: #2563eb;
  text-decoration: underline;
  overflow-wrap: anywhere;
}

.lb-source time {
  white-space: nowrap;
}

.lb-source__notice {
  display: block;
  margin-top: 2px;
}

html[data-theme="dark"] .lb-source {
  color: #9ca3af;
}

html[data-theme="dark"] .lb-source a {
  color: #60a5fa;
}
