/* ===========================================================================
   Whānau Tahi — Navigator documentation
   Brand theme layer for the docfx "modern" template (Bootstrap 5.3).

   Embodies manaakitanga (care, generosity, respect): a warm, calm, welcoming
   and accessible reading experience built on the Whānau Tahi palette.

   Palette (brand guidelines):
     Whānau Blue   #012639   Brand Blue   #024852
     Pathway #1    #2D8892   Pathway #2   #7DC7BF   Pathway #3 #03A3BA
   Typography: Segoe UI. Radius: 4px. Motion: gentle. Contrast: WCAG 2.2 AA.
   =========================================================================== */

/* ---- Brand palette constants ------------------------------------------- */
:root {
  --wt-whanau-blue: #012639;
  --wt-brand-blue:  #024852;
  --wt-path-1:      #2d8892;
  --wt-path-2:      #7dc7bf;
  --wt-path-3:      #03a3ba;

  /* Brand scale, left → right (used for the header signature strip). */
  --wt-scale: linear-gradient(90deg, #012639, #024852, #2d8892, #7dc7bf, #03a3ba);

  --wt-radius: 4px;
  --wt-ease: cubic-bezier(0.2, 0, 0.2, 1);
}

/* ---- Light theme (default) --------------------------------------------- */
:root,
[data-bs-theme="light"] {
  /* Semantic surface + ink tokens (warm-neutral white, brand ink). */
  --wt-bg:            #fafaf8;   /* faintly warm page background  */
  --wt-surface:       #ffffff;   /* cards / raised surfaces       */
  --wt-surface-tint:  #f1f7f7;   /* sidebars, code, table heads   */
  --wt-ink:           #11252f;   /* body text  (~15:1 on bg)      */
  --wt-heading:       var(--wt-whanau-blue);
  --wt-ink-soft:      #4c6571;   /* muted text (~5.4:1 on bg)     */
  --wt-link:          #024852;   /* Brand Blue (~9.6:1 on white)  */
  --wt-link-hover:    #012639;   /* Whānau Blue (darken on hover) */
  --wt-accent:        #03a3ba;   /* Pathway #3 — non-text accents */
  --wt-border:        rgba(1, 38, 57, 0.12);
  --wt-border-strong: rgba(2, 72, 82, 0.22);
  --wt-shadow: 0 1px 2px rgba(1, 38, 57, 0.04), 0 6px 18px rgba(1, 38, 57, 0.07);
  --wt-focus: 0 0 0 0.18rem rgba(3, 163, 186, 0.45);
  --wt-code-ink: #0a5462;

  /* Map Bootstrap 5 variables to the brand. */
  --bs-body-bg: var(--wt-bg);
  --bs-body-color: var(--wt-ink);
  --bs-emphasis-color: var(--wt-heading);
  --bs-heading-color: var(--wt-heading);
  --bs-secondary-color: var(--wt-ink-soft);
  --bs-secondary-bg: var(--wt-surface-tint);
  --bs-tertiary-bg: var(--wt-surface-tint);
  --bs-border-color: var(--wt-border);
  --bs-link-color: var(--wt-link);
  --bs-link-color-rgb: 2, 72, 82;
  --bs-link-hover-color: var(--wt-link-hover);
  --bs-link-hover-color-rgb: 1, 38, 57;
  --bs-primary: var(--wt-brand-blue);
  --bs-primary-rgb: 2, 72, 82;
  --bs-code-color: var(--wt-code-ink);
  --bs-highlight-bg: rgba(125, 199, 191, 0.32);
}

/* ---- Dark theme (gradient inversion permitted by brand) ---------------- */
[data-bs-theme="dark"] {
  --wt-bg:            #02202c;   /* deep Whānau-Blue ground       */
  --wt-surface:       #06303d;   /* cards rise above the ground   */
  --wt-surface-tint:  #073545;
  --wt-ink:           #e8eff0;   /* warm off-white (~13:1)        */
  --wt-heading:       #f2f7f7;
  --wt-ink-soft:      #a9c3c9;   /* muted (~6:1 on bg)            */
  --wt-link:          #7dc7bf;   /* Pathway #2 (~8:1 on bg)       */
  --wt-link-hover:    #a6dbd4;
  --wt-accent:        #2bbcd2;
  --wt-border:        rgba(125, 199, 191, 0.18);
  --wt-border-strong: rgba(125, 199, 191, 0.34);
  --wt-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 22px rgba(0, 0, 0, 0.36);
  --wt-focus: 0 0 0 0.18rem rgba(125, 199, 191, 0.5);
  --wt-code-ink: #9fd8d0;

  --bs-body-bg: var(--wt-bg);
  --bs-body-color: var(--wt-ink);
  --bs-emphasis-color: var(--wt-heading);
  --bs-heading-color: var(--wt-heading);
  --bs-secondary-color: var(--wt-ink-soft);
  --bs-secondary-bg: var(--wt-surface-tint);
  --bs-tertiary-bg: var(--wt-surface-tint);
  --bs-border-color: var(--wt-border);
  --bs-link-color: var(--wt-link);
  --bs-link-color-rgb: 125, 199, 191;
  --bs-link-hover-color: var(--wt-link-hover);
  --bs-link-hover-color-rgb: 166, 219, 212;
  --bs-primary: var(--wt-path-2);
  --bs-primary-rgb: 125, 199, 191;
  --bs-code-color: var(--wt-code-ink);
  --bs-highlight-bg: rgba(3, 163, 186, 0.28);
}

/* ---- Base typography ---------------------------------------------------- */
:root {
  --bs-font-sans-serif: "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-font-family: var(--bs-font-sans-serif);
  --bs-body-line-height: 1.65;
  --bs-border-radius: var(--wt-radius);
  --bs-border-radius-sm: var(--wt-radius);
  --bs-border-radius-lg: 8px;
}

body {
  font-family: var(--bs-font-sans-serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

article h1,
article h2,
article h3,
article h4,
article h5,
article h6 {
  color: var(--wt-heading);
  font-weight: 600;
  letter-spacing: -0.005em;
}

article h1 {
  font-size: 2rem;
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

article h2 {
  font-size: 1.45rem;
  margin-top: 2.25rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--wt-border);
}

article h3 {
  font-size: 1.18rem;
  margin-top: 1.6rem;
}

/* Comfortable reading measure for prose. */
article .content > p,
article .content > ul,
article .content > ol,
article .content > blockquote {
  max-width: 72ch;
}

article a {
  text-underline-offset: 0.16em;
  text-decoration-thickness: 0.07em;
  transition: color 140ms var(--wt-ease);
}

/* ---- Accessibility: focus + reduced motion ------------------------------ */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
.inventory-card:focus-visible {
  outline: 2px solid transparent;
  box-shadow: var(--wt-focus);
  border-radius: var(--wt-radius);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Header / navbar ---------------------------------------------------- */
header {
  position: relative;
}

/* Brand signature: the full palette scale as a thin top strip. */
header::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--wt-scale);
  z-index: 1;
}

.navbar {
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
  background-color: var(--wt-surface) !important;
}

.navbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  color: var(--wt-heading);
  letter-spacing: 0.01em;
}

.navbar-brand img#logo,
.navbar-brand .svg {
  height: 34px;
  width: auto;
  border-radius: 6px;
}

/* ---- Left table of contents -------------------------------------------- */
/* The modern template marks the whole active PATH with `li.active` (ancestors
   carry `expander expanded active`). We emphasise only the deepest active li —
   the current page — and place its indicator in the li's existing .85rem left
   gutter so it never overlaps the link text. */
.toc li > a {
  color: var(--wt-ink-soft);
  transition: color 140ms var(--wt-ease);
}

.toc li > a:hover,
.toc li > a:focus {
  color: var(--wt-link);
}

.toc li.active:not(:has(li.active)) > a {
  color: var(--wt-link);
  font-weight: 600;
}

.toc li.active:not(:has(li.active))::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.2em;
  bottom: 0.2em;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--wt-accent);
}

/* ---- Right rail "In this article" (scrollspy adds .active on scroll) ----- */
.affix li.active > a,
.affix a.active {
  color: var(--wt-link);
  font-weight: 600;
}

/* ---- Search ------------------------------------------------------------- */
.search input,
#search input {
  border-radius: var(--wt-radius);
}

/* ---- Content polish: code, tables, alerts ------------------------------- */
article :not(pre) > code {
  background: var(--wt-surface-tint);
  border: 1px solid var(--wt-border);
  border-radius: var(--wt-radius);
  padding: 0.08rem 0.32rem;
}

article pre {
  background: var(--wt-surface-tint);
  border: 1px solid var(--wt-border);
  border-left: 3px solid var(--wt-path-1);
  border-radius: var(--wt-radius);
}

article table:not(.inventory-bare) {
  border: 1px solid var(--wt-border);
  border-radius: var(--wt-radius);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

article table:not(.inventory-bare) thead th {
  background: var(--wt-surface-tint);
  color: var(--wt-heading);
  border-bottom: 1px solid var(--wt-border-strong);
}

article table:not(.inventory-bare) td,
article table:not(.inventory-bare) th {
  border-top: 1px solid var(--wt-border);
}

/* Admonitions / blockquotes get a calm Pathway wash. */
.alert,
blockquote {
  border-radius: var(--wt-radius);
}

blockquote {
  border-left: 3px solid var(--wt-path-2);
  background: var(--wt-surface-tint);
  padding: 0.75rem 1rem;
  color: var(--wt-ink);
}

/* ---- Footer with proverb ----------------------------------------------- */
.wt-footer {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.wt-footer__proverb {
  color: var(--wt-path-1);
  font-style: italic;
}

[data-bs-theme="dark"] .wt-footer__proverb {
  color: var(--wt-path-2);
}

.wt-footer__legal {
  color: var(--wt-ink-soft);
  font-size: 0.92em;
}

/* ===========================================================================
   Settings-inventory catalogue (index page) + sanitised reference pages.
   Token-based so light/dark are inherited automatically.
   =========================================================================== */
.inventory-catalogue {
  margin-top: 1.75rem;
}

.inventory-catalogue__toolbar {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 2.4fr) minmax(16.5rem, 1fr);
  margin-bottom: 1rem;
}

.inventory-catalogue__field {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
  min-width: 0;
}

.inventory-catalogue__field span {
  color: var(--wt-ink-soft);
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

.inventory-catalogue__control {
  align-items: center;
  background: var(--wt-surface);
  border: 1px solid var(--wt-border);
  border-radius: var(--wt-radius);
  display: flex;
  min-width: 0;
  transition: border-color 140ms var(--wt-ease), box-shadow 140ms var(--wt-ease);
}

.inventory-catalogue__control:hover {
  border-color: var(--wt-border-strong);
}

.inventory-catalogue__control:focus-within {
  border-color: var(--wt-accent);
  box-shadow: var(--wt-focus);
}

.inventory-catalogue__search,
.inventory-catalogue__filter {
  background: transparent;
  border: 0;
  color: var(--wt-ink);
  font: inherit;
  min-width: 0;
  outline: 0;
  padding: 0.72rem 0.9rem;
  width: 100%;
}

.inventory-catalogue__search::placeholder {
  color: var(--wt-ink-soft);
}

.inventory-catalogue__filter {
  appearance: none;
  padding-right: 2rem;
  cursor: pointer;
  text-overflow: ellipsis;
}

.inventory-catalogue__chevron {
  color: var(--wt-brand-blue);
  font-size: 0.95rem;
  line-height: 1;
  padding: 0 0.75rem 0 0;
  pointer-events: none;
}

[data-bs-theme="dark"] .inventory-catalogue__chevron {
  color: var(--wt-path-2);
}

.inventory-catalogue__count {
  background: rgba(125, 199, 191, 0.18);
  border: 1px solid rgba(45, 136, 146, 0.24);
  border-radius: 999px;
  color: var(--wt-brand-blue);
  display: inline-flex;
  font-size: 0.84rem;
  font-weight: 600;
  margin: 0 0 1rem;
  padding: 0.3rem 0.74rem;
}

[data-bs-theme="dark"] .inventory-catalogue__count {
  color: var(--wt-path-2);
}

.inventory-catalogue__results {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
}

.inventory-card {
  background: var(--wt-surface);
  border: 1px solid var(--wt-border);
  border-radius: var(--wt-radius);
  box-shadow: var(--wt-shadow);
  color: var(--wt-ink);
  display: grid;
  gap: 0.5rem;
  min-height: 100%;
  min-width: 0;
  padding: 1.1rem 1.15rem;
  position: relative;
  text-decoration: none;
  transition: transform 140ms var(--wt-ease), box-shadow 140ms var(--wt-ease), border-color 140ms var(--wt-ease);
}

/* A quiet Pathway accent rail that warms on hover. */
.inventory-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  border-radius: var(--wt-radius) 0 0 var(--wt-radius);
  background: var(--wt-path-2);
  opacity: 0;
  transition: opacity 140ms var(--wt-ease);
}

.inventory-card:hover,
.inventory-card:focus-visible {
  border-color: var(--wt-border-strong);
  box-shadow: 0 2px 4px rgba(1, 38, 57, 0.06), 0 14px 30px rgba(1, 38, 57, 0.12);
  text-decoration: none;
  transform: translateY(-2px);
}

.inventory-card:hover::before,
.inventory-card:focus-visible::before {
  opacity: 1;
}

.inventory-card__kind {
  color: var(--wt-path-1);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

[data-bs-theme="dark"] .inventory-card__kind {
  color: var(--wt-path-2);
}

.inventory-card__title {
  color: var(--wt-heading);
  font-size: 1.05rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.inventory-card__subtitle {
  color: var(--wt-ink-soft);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.inventory-card__description {
  color: var(--wt-ink);
  font-size: 0.95rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.inventory-catalogue__empty {
  background: var(--wt-surface-tint);
  border: 1px dashed var(--wt-border-strong);
  border-radius: var(--wt-radius);
  color: var(--wt-ink-soft);
  margin: 0;
  padding: 1.5rem;
  text-align: center;
}

@media (max-width: 768px) {
  .inventory-catalogue__toolbar,
  .inventory-catalogue__results {
    grid-template-columns: 1fr;
  }
}
