/* ==========================================================================
   BLUEFRONT AI  /  /services/firm-knowledge
   Concept: "The library and the keys"  a handbook style documentation page.
   Everything scoped under .pg-firm-knowledge. Colour via CSS vars only.
   ========================================================================== */

/* ---- brand fallbacks (site provides the real values) ---- */
:root {
  --bg: #fff;
  --surface: #f3f7ff;
  --card: #fff;
  --ink: #0b1b3f;
  --muted: #4a5a7d;
  --border: #e1e9f7;
  --accent: #1d5bff;
  --accent-fill: #1d5bff;
  --accent-soft: #e8efff;
  --navy: #0a1c4a;
  --ink-rgb: 11, 27, 63;
  --accent-rgb: 29, 91, 255;
}
html[data-theme="dark"] {
  --bg: #071022;
  --surface: #0a1530;
  --card: #0e1c3f;
  --ink: #f1f5ff;
  --muted: #aab8d8;
  --border: #1f2f5a;
  --accent: #4a86ff;
  --accent-fill: #2d62e8;
  --accent-soft: #14275a;
  --navy: #081735;
  --ink-rgb: 255, 255, 255;
  --accent-rgb: 74, 134, 255;
}

/* ========================================================================== */

.pg-firm-knowledge {
  --fk-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --fk-sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fk-amber-soft: rgba(196, 132, 0, 0.14);
  --fk-amber-ink: #8a5300;
  --fk-top: 100px;

  position: relative;
  padding-top: var(--fk-top);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--fk-sans);
  font-size: 16px;
  line-height: 1.66;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}
html[data-theme="dark"] .pg-firm-knowledge {
  --fk-amber-soft: rgba(242, 197, 107, 0.16);
  --fk-amber-ink: #f2c56b;
}

:where(.pg-firm-knowledge) *,
:where(.pg-firm-knowledge) *::before,
:where(.pg-firm-knowledge) *::after { box-sizing: border-box; }

:where(.pg-firm-knowledge) h1,
:where(.pg-firm-knowledge) h2,
:where(.pg-firm-knowledge) h3 { margin: 0; font-family: var(--fk-sans); color: var(--ink); }
:where(.pg-firm-knowledge) p { margin: 0; }
:where(.pg-firm-knowledge) a { color: inherit; }
:where(.pg-firm-knowledge) ul { margin: 0; padding: 0; list-style: none; }
:where(.pg-firm-knowledge) img,
:where(.pg-firm-knowledge) svg { display: block; }

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

.pg-firm-knowledge :focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---- layout ------------------------------------------------------------ */
.fk-layout {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 120px;
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}

/* ---- chapter navigation ------------------------------------------------ */
.fk-toc {
  position: sticky;
  top: calc(var(--fk-top) + 28px);
  align-self: start;
}
.fk-toc__inner { border-left: 1px solid var(--border); padding-left: 20px; }
.fk-toc__title {
  font: 600 11px/1.4 var(--fk-mono);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}
.fk-toc__list { display: flex; flex-direction: column; gap: 2px; }
.fk-toc__link {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-height: 44px;
  padding: 11px 0;
  text-decoration: none;
  font-size: 13.5px;
  color: var(--muted);
  border-radius: 4px;
  transition: color 0.18s ease, padding-left 0.18s ease;
}
.fk-toc__link:hover { color: var(--ink); padding-left: 4px; }
.fk-toc__link.is-active { color: var(--accent); }
.fk-toc__num {
  font: 600 11px/1.4 var(--fk-mono);
  letter-spacing: 0.08em;
  color: inherit;
  opacity: 0.7;
}

/* ---- document column --------------------------------------------------- */
.fk-doc { max-width: 720px; min-width: 0; }

.fk-doc__head {
  padding-bottom: 44px;
  border-bottom: 1px solid var(--border);
}
.fk-kicker {
  font: 600 11px/1.4 var(--fk-mono);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}
.fk-h1 {
  margin-top: 16px;
  font-size: clamp(2.5rem, 5.2vw, 4rem);
  font-weight: 300;
  line-height: 1.03;
  letter-spacing: -0.022em;
}
.fk-lede {
  margin-top: 24px;
  max-width: 56ch;
  font-size: 1.14rem;
  line-height: 1.6;
  color: var(--muted);
}

/* ---- chapters ---------------------------------------------------------- */
.fk-sec {
  padding: 64px 0;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 132px;
}
.fk-sec__head { margin-bottom: 30px; }
.fk-h2 {
  font-size: clamp(1.5rem, 2.6vw, 2.05rem);
  font-weight: 500;
  line-height: 1.16;
  letter-spacing: -0.012em;
}
.fk-h2__num {
  display: block;
  margin-bottom: 8px;
  font: 600 12px/1.2 var(--fk-mono);
  letter-spacing: 0.14em;
  color: var(--accent);
}
.fk-p {
  max-width: 60ch;
  color: var(--muted);
  font-size: 1rem;
}
.fk-p + .fk-p { margin-top: 14px; }

.fk-example {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 10px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font: 600 10px/1 var(--fk-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--card);
  vertical-align: middle;
}

/* ---- 1.0 library shelf ------------------------------------------------- */
.fk-shelf { display: flex; flex-direction: column; gap: 26px; }
.fk-band {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 18px;
  align-items: end;
}
.fk-band__label {
  padding-bottom: 10px;
  font: 600 10.5px/1.45 var(--fk-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.fk-shelf__row {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  min-height: 122px;
  padding-bottom: 9px;
  border-bottom: 2px solid var(--border);
  box-shadow: 0 10px 18px -16px rgba(var(--ink-rgb), 0.5);
}
.fk-spine {
  --h: 96px;
  height: var(--h);
  width: 27px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0;
  border-radius: 4px 4px 2px 2px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font: 600 11px/1 var(--fk-mono);
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.fk-spine--soft { background: var(--accent-soft); color: var(--ink); border: 1px solid var(--border); }
.fk-spine--mid { background: var(--accent); color: #fff; }
.fk-spine--deep { background: var(--navy); color: #fff; }
.fk-spine--amber { background: var(--fk-amber-soft); color: var(--fk-amber-ink); border: 1px solid rgba(196, 132, 0, 0.34); }
.fk-spine:hover { transform: translateY(-5px); box-shadow: 0 14px 20px -14px rgba(var(--ink-rgb), 0.55); }

/* signature motion: the shelf fills, spines rise into place */
.fk-js .fk-shelf .fk-spine { opacity: 0; transform: translateY(16px); }
.fk-js .fk-shelf.is-in .fk-spine {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s ease, transform 0.62s cubic-bezier(0.2, 0.7, 0.2, 1);
  transition-delay: calc(var(--i, 0) * 55ms);
}
.fk-js .fk-shelf.is-in .fk-spine:hover { transform: translateY(-5px); }

/* ---- 2.0 question and answer ------------------------------------------ */
.fk-qa {
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  overflow: hidden;
}
.fk-qa__q {
  display: flex;
  gap: 14px;
  padding: 20px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.fk-qa__mark {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font: 700 12px/1 var(--fk-mono);
}
.fk-qa__qtext { font-size: 1.02rem; font-weight: 600; align-self: center; }
.fk-qa__a { padding: 22px; }
.fk-qa__atext { max-width: 58ch; color: var(--muted); }
.fk-cite {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 6px;
  font: 700 11px/1 var(--fk-mono);
  color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
  vertical-align: middle;
  transition: background 0.16s ease, color 0.16s ease;
}
.fk-cite:hover,
.fk-cite:focus-visible { background: var(--accent-fill); color: #fff; }

.fk-notes {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.fk-note {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 8px 10px;
  border-radius: 8px;
  scroll-margin-top: 140px;
  transition: background 0.2s ease;
}
.fk-note:target { background: var(--accent-soft); }
.fk-note__num {
  width: 26px; height: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font: 700 11px/1 var(--fk-mono);
}
.fk-note__text { font-size: 0.92rem; color: var(--muted); padding-top: 3px; }
.fk-note__text strong { color: var(--ink); font-weight: 600; }

/* ---- 3.0 access matrix ------------------------------------------------- */
.fk-matrix-wrap {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  padding: 8px 14px 4px;
}
.fk-matrix { width: 100%; border-collapse: collapse; }
.fk-matrix th,
.fk-matrix td {
  padding: 15px 8px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  font-size: 0.86rem;
}
.fk-matrix tr:last-child th,
.fk-matrix tr:last-child td { border-bottom: 0; }
.fk-matrix thead th {
  font: 600 10.5px/1.4 var(--fk-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 12px;
}
.fk-matrix thead th:first-child { text-align: left; }
.fk-matrix th[scope="row"] {
  text-align: left;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}
.fk-matrix tbody tr { transition: background 0.2s ease; }
.fk-matrix tbody tr:hover,
.fk-matrix tbody tr:focus-within { background: var(--surface); }
.fk-mark {
  width: 30px; height: 30px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  background: rgba(var(--ink-rgb), 0.05);
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.fk-mark--on { background: var(--accent-soft); color: var(--accent); }
.fk-matrix tbody tr:hover .fk-mark,
.fk-matrix tbody tr:focus-within .fk-mark { transform: translateY(-2px) scale(1.06); }
.fk-matrix tbody tr:hover .fk-mark--on,
.fk-matrix tbody tr:focus-within .fk-mark--on { background: var(--accent-fill); color: #fff; }
.fk-matrix tbody tr:hover .fk-mark--lock,
.fk-matrix tbody tr:focus-within .fk-mark--lock { color: var(--ink); }
.fk-matrix__note {
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---- 4.0 changelog rollout -------------------------------------------- */
.fk-log { margin-top: 6px; position: relative; }
.fk-log::before {
  content: "";
  position: absolute;
  left: 5px; top: 26px; bottom: 26px;
  width: 1px;
  background: var(--border);
}
.fk-log__item {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 22px;
  padding: 24px 0;
  border-top: 1px solid var(--border);
}
.fk-log__item:first-child { border-top: 0; }
.fk-log__tag {
  position: relative;
  padding-left: 22px;
  font: 600 12px/1.5 var(--fk-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.fk-log__tag::before {
  content: "";
  position: absolute;
  left: 0; top: 7px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.fk-log__title { font-size: 1.02rem; font-weight: 600; margin-bottom: 6px; }
.fk-log__text { font-size: 0.94rem; color: var(--muted); max-width: 52ch; }

/* ---- 5.0 FAQ ----------------------------------------------------------- */
.fk-faq { display: flex; flex-direction: column; gap: 10px; }
.fk-faq details {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  overflow: hidden;
}
.fk-faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 56px;
  padding: 16px 20px;
  cursor: pointer;
  list-style: none;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}
.fk-faq summary::-webkit-details-marker { display: none; }
.fk-faq summary:hover { background: var(--surface); }
.fk-faq__chev {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  transition: transform 0.22s ease;
}
.fk-faq details[open] .fk-faq__chev { transform: rotate(180deg); }
.fk-faq__body {
  padding: 0 20px 20px;
  max-width: 58ch;
  font-size: 0.95rem;
  color: var(--muted);
}

/* ---- related + closing margin note ------------------------------------ */
.fk-related {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 18px;
  padding: 30px 0;
  border-bottom: 1px solid var(--border);
}
.fk-related__label {
  font: 600 11px/1.4 var(--fk-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.fk-related a {
  font-size: 0.98rem;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  padding-bottom: 2px;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.fk-related a:hover { color: var(--accent); border-color: var(--accent); }

.fk-close {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 44px;
  align-items: end;
  padding: 64px 0 0;
}
.fk-close__text { max-width: 46ch; font-size: 1.14rem; line-height: 1.6; color: var(--ink); }
.fk-margin-note {
  position: relative;
  padding: 20px 20px 22px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}
.fk-margin-note::before {
  content: "";
  position: absolute;
  left: -22px; top: 26px;
  width: 16px; height: 1px;
  background: var(--border);
}
.fk-margin-note__kicker {
  font: 600 10.5px/1.4 var(--fk-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.fk-margin-note__text { font-size: 0.9rem; color: var(--muted); margin-bottom: 16px; }
.fk-margin-note__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 3px;
  transition: color 0.18s ease, border-color 0.18s ease, gap 0.18s ease;
}
.fk-margin-note__link:hover { gap: 12px; }
.fk-margin-note__link svg { width: 16px; height: 16px; }

/* ---- reveal ------------------------------------------------------------ */
.fk-js .fk-reveal { opacity: 0; transform: translateY(12px); }
.fk-js .fk-reveal.is-in {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ==========================================================================
   breakpoints
   ========================================================================== */
@media (max-width: 1000px) {
  .fk-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 30px;
  }
  .fk-toc {
    position: static;
    top: auto;
  }
  .fk-toc__inner {
    border-left: 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 14px 0;
  }
  .fk-toc__title { margin-bottom: 10px; }
  .fk-toc__list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }
  .fk-toc__link {
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 13px;
  }
  .fk-toc__link:hover { padding-left: 14px; background: var(--surface); }
  .fk-toc__link.is-active { border-color: var(--accent); background: var(--accent-soft); }
  .fk-doc { max-width: 100%; }
}

@media (max-width: 820px) {
  .fk-band {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .fk-band__label { padding-bottom: 2px; }
  .fk-close {
    grid-template-columns: minmax(0, 1fr);
    gap: 26px;
    align-items: start;
  }
  .fk-margin-note::before { display: none; }
}

@media (max-width: 620px) {
  .pg-firm-knowledge { font-size: 15.5px; }
  .fk-layout { padding: 0 18px 84px; }
  .fk-h1 { font-size: clamp(2.1rem, 9vw, 2.6rem); }
  .fk-lede { font-size: 1.05rem; }

  /* shelf becomes upright cards so vertical text never crowds */
  .fk-shelf { gap: 20px; }
  .fk-shelf__row {
    flex-wrap: wrap;
    align-items: stretch;
    min-height: 0;
    gap: 8px;
    padding-bottom: 12px;
  }
  .fk-spine {
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    width: auto;
    height: auto;
    min-height: 44px;
    flex: 1 1 128px;
    border-radius: 8px;
    padding: 12px 12px;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    text-align: center;
  }
  .fk-spine:hover { transform: translateY(-2px); }

  .fk-log__item {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .fk-log::before { display: none; }

  .fk-matrix-wrap { padding: 6px 8px 2px; }
  .fk-matrix th,
  .fk-matrix td { padding: 11px 4px; font-size: 0.74rem; }
  .fk-matrix th[scope="row"] {
    white-space: normal;
    font-size: 0.78rem;
    padding-right: 6px;
  }
  .fk-mark { width: 26px; height: 26px; }
}

/* ==========================================================================
   reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  :where(.pg-firm-knowledge) *,
  :where(.pg-firm-knowledge) *::before,
  :where(.pg-firm-knowledge) *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
  .fk-js .fk-reveal,
  .fk-js .fk-shelf .fk-spine {
    opacity: 1 !important;
    transform: none !important;
  }
  .fk-spine:hover,
  .fk-matrix tbody tr:hover .fk-mark { transform: none !important; }
}
