/* ==========================================================================
   RedAid Nigeria — "Field Index" Mobile Navigation
   A full-screen, numbered ledger that replaces the drill-down mobile drawer.
   Loaded after styles.css and scoped to .fidx so the legacy drawer CSS and
   the desktop panel are untouched. Tokens only — dark theme is automatic.
   ========================================================================== */

/* ------------------------------------------------------------ shell --- */

.veritas-drawer-panel.fidx {
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  height: 100dvh !important;
  min-height: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
  gap: 0 !important;
  overflow: hidden !important;
  background-color: var(--surface) !important;
  color: var(--text) !important;
}

.fidx *,
.fidx *::before,
.fidx *::after {
  box-sizing: border-box;
}

/* -------------------------------------------------------------- bar --- */

.fidx-bar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  height: 58px;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  background-color: var(--surface);
}

.fidx-bar-left,
.fidx-bar-right {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.fidx-bar-right {
  justify-content: flex-end;
}

.fidx-bar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 8px;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 160ms ease, color 160ms ease;
}

.fidx-bar-btn:hover {
  background-color: var(--bg);
}

/* the legacy .drawer-lang-btn rules outrank a single class, so re-assert here */
.fidx .drawer-lang-btn {
  background-color: transparent !important;
  background-image: none !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
  color: var(--text) !important;
}

.fidx .drawer-lang-btn:hover,
.fidx .drawer-lang-btn:focus-visible {
  background-color: var(--bg) !important;
  color: var(--text) !important;
}

.fidx-bar-btn svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.fidx-bar-label {
  line-height: 1;
}

.fidx-bar-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background-color: var(--surface);
}

.fidx-bar-seal-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

.fidx-lang-wrap {
  position: relative;
  display: inline-flex;
}

.fidx-lang-code {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text);
}

.fidx-lang-wrap .drawer-lang-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: 184px;
  display: flex;
  flex-direction: column;
  padding: 6px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: none;
}

.fidx-lang-wrap .drawer-lang-dropdown[hidden] {
  display: none;
}

.fidx-lang-wrap .drawer-lang-opt {
  display: block;
  width: 100%;
  padding: 9px 10px;
  background: none;
  border: 0;
  border-radius: 6px;
  text-align: left;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.fidx-lang-wrap .drawer-lang-opt:hover,
.fidx-lang-wrap .drawer-lang-opt.active {
  background-color: var(--bg);
}

.fidx-lang-wrap .drawer-lang-opt:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: -2px;
}

/* --------------------------------------------------------- meta row --- */

.fidx-nav {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 20px;
}

.fidx-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 8px;
}

.fidx-meta-title {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.fidx-meta-count {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

/* ---------------------------------------------------------- entries --- */

.fidx-entries {
  border-top: 1px solid var(--border);
}

.fidx-entry {
  border-bottom: 1px solid var(--border);
}

.fidx-row {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 26px;
  align-items: center;
  column-gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 14px 0;
  background: none;
  border: 0;
  text-align: left;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.fidx-row-num {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  transition: color 180ms ease;
}

.fidx-row-label {
  font-family: var(--font-display);
  font-size: clamp(21px, 6.2vw, 26px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: var(--text);
  transition: color 180ms ease;
}

.fidx-row-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  justify-self: end;
  color: var(--text-secondary);
  transition: color 180ms ease, transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.fidx-row-mark svg {
  width: 11px;
  height: 11px;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
}

.fidx-row-go {
  width: 13px;
  height: 13px;
}

.fidx-entry.is-open .fidx-row-mark {
  transform: rotate(45deg);
  color: var(--text);
}

.fidx-row:hover .fidx-row-label,
.fidx-row:focus-visible .fidx-row-label {
  color: var(--link);
}

.fidx-row:hover .fidx-row-num,
.fidx-row:focus-visible .fidx-row-num {
  color: var(--text);
}

.fidx-row:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* you-are-here */
.fidx-entry.is-current .fidx-row-label {
  color: var(--red-text);
}

.fidx-entry.is-current .fidx-row-num {
  color: var(--red-text);
}

.fidx-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------ panels --- */

.fidx-panel {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
  transition: grid-template-rows 360ms cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0s linear 360ms;
}

.fidx-entry.is-open .fidx-panel {
  grid-template-rows: 1fr;
  visibility: visible;
  transition: grid-template-rows 360ms cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0s;
}

.fidx-panel-inner {
  min-height: 0;
  overflow: hidden;
}

.fidx-panel-lede {
  margin: 0 0 6px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 46ch;
}

.fidx-links {
  list-style: none;
  margin: 0;
  padding: 0 0 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 520px) {
  .fidx-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 22px;
  }
}

.fidx-links li {
  min-width: 0;
}

.fidx-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 6px 0;
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px solid var(--border-subtle);
  transition: color 160ms ease;
}

.fidx-links a span {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0;
  transform: translateX(-3px);
  transition: opacity 160ms ease, transform 160ms ease;
}

/* touch devices get no hover, so the affordance is always legible */
@media (hover: none) {
  .fidx-links a span {
    opacity: 0.55;
    transform: none;
  }
}

.fidx-links a:hover,
.fidx-links a:focus-visible {
  color: var(--text);
  text-decoration: none;
}

.fidx-links a:hover span,
.fidx-links a:focus-visible span {
  opacity: 1;
  transform: translateX(0);
}

.fidx-links a:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* ------------------------------------------------------------ office --- */

.fidx-office {
  margin-top: auto;
  padding: 18px 0 20px;
  border-top: 1px solid var(--border);
}

.fidx-office-label {
  margin: 0 0 8px;
  font-family: var(--font-body);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.fidx-office-addr {
  margin: 0 0 6px;
  font-family: var(--font-body);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  max-width: 34ch;
}

.fidx-office-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fidx-office-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 160ms ease, color 160ms ease;
}

.fidx-office-links a:hover,
.fidx-office-links a:focus-visible {
  color: var(--red-text);
  border-bottom-color: currentColor;
}

.fidx-office-links a:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* ------------------------------------------------------------- foot --- */

.fidx-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background-color: var(--surface);
}

.fidx-donate {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 20px;
  background-color: var(--red-600);
  border: 1px solid var(--red-600);
  border-radius: 999px;
  color: #FFFFFF;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.fidx-donate svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

.fidx-donate:hover,
.fidx-donate:focus-visible {
  background-color: var(--red-700);
  border-color: var(--red-700);
  color: #FFFFFF;
  text-decoration: none;
}

.fidx-donate:hover svg {
  transform: translateX(3px);
}

.fidx-donate:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

.fidx-socials {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0;
  padding: 0;
}

.fidx-social {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 160ms ease, background-color 160ms ease;
}

.fidx-social svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.fidx-social:hover,
.fidx-social:focus-visible {
  color: var(--text);
  background-color: var(--bg);
  text-decoration: none;
}

.fidx-social:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 1px;
}

@media (max-width: 380px) {
  .fidx-foot {
    padding-left: 14px;
    padding-right: 14px;
  }
  .fidx-donate {
    padding: 0 16px;
  }
  .fidx-social {
    width: 44px;
    height: 44px;
  }
  .fidx-nav {
    padding: 0 14px;
  }
}

/* ------------------------------------------------------------ motion --- */

@media (prefers-reduced-motion: reduce) {
  .fidx-panel,
  .fidx-entry.is-open .fidx-panel,
  .fidx-row-mark,
  .fidx-donate svg,
  .fidx-links a span {
    transition: none !important;
  }
}

/* --------------------------------------------------- tablet landscape --- */

@media (min-width: 700px) and (max-width: 991px) {
  .fidx-nav {
    padding: 0 clamp(24px, 6vw, 64px);
  }
  .fidx-bar,
  .fidx-foot {
    padding-left: clamp(16px, 4vw, 40px);
    padding-right: clamp(16px, 4vw, 40px);
  }
  .fidx-row-label {
    font-size: 26px;
  }
  .fidx-meta {
    padding-top: 20px;
  }
}
