/*
 * Huli FHIR IG — main override stylesheet (#1364 §Visual identity)
 *
 * Stripe/Anthropic/Vercel-grade restyle of the HL7 IG Publisher output.
 * Loaded by `.github/workflows/fhir-ig-build.yml` AFTER all of the base
 * template's CSS (bootstrap-fhir.css, project.css, hl7.css, prism.css)
 * so these rules win without `!important` battles.
 *
 * Sections:
 *   1. Resets / base / typography
 *   2. Three-column app shell (sticky topbar + sidebar + content + TOC)
 *   3. Topbar
 *   4. Left sidebar (repositioned navbar nav)
 *   5. Right TOC ("On this page")
 *   6. Breadcrumbs
 *   7. Content + reading column
 *   8. Headings + anchor links
 *   9. Prose (paragraphs, lists, blockquotes)
 *  10. Links
 *  11. Inline code + code blocks
 *  12. Callouts / admonitions (#publish-box, alerts)
 *  13. Tables (FHIR structure-definition + generic)
 *  14. FHIR convention glyphs (S / ?! / Σ / I)
 *  15. Panels + bootstrap cards
 *  16. Buttons + form widgets
 *  17. FHIR resource tabs
 *  18. Page-meta + footer (INCLUDES BOTTOM-CUTOFF FIX)
 *  19. Prev / Next pagination
 *  20. Reduced motion
 */

/* Inter web font + JetBrains Mono via Google Fonts CDN — same family the
 * docs site uses (#1363). Single @import block, no FOUC because the IG
 * Publisher loads all stylesheets in <head> before body renders. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* =========================================================================
 * 1. Resets / base / typography
 * ======================================================================= */

html {
  color-scheme: dark;
  background-color: var(--canvas);
}

body {
  background-color: var(--canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  margin: 0;
  padding-bottom: 0;
}

::selection {
  background: var(--accent-muted);
  color: var(--text-primary);
}

/* Kill any bootstrap container white backgrounds inherited from
 * bootstrap-fhir.css. */
.segment > .container,
#segment-header .container,
#segment-navbar .container,
#segment-breadcrumb .container,
#segment-content .container,
#segment-footer .container,
#segment-post-footer .container,
body > .container,
body > div > .container {
  background-color: transparent;
}

/* =========================================================================
 * 2. Three-column app shell
 *
 * `huli-enhance.js` adds the `.has-shell` class to <body> once it has
 * wrapped the IG Publisher's existing segments into a Grid layout:
 *
 *   <body class="has-shell">
 *     <header class="topbar"> …compact brand strip… </header>
 *     <div class="layout">
 *       <aside class="sidebar"> #segment-navbar nav </aside>
 *       <main  class="content"> #segment-breadcrumb + #segment-content </main>
 *       <aside class="toc">     auto-generated from h2/h3 </aside>
 *     </div>
 *     <footer class="footer-strip"> #segment-footer </footer>
 *   </body>
 *
 * Pre-JS state still renders cleanly via section 7's content cap; the
 * shell rules below only fire when `.has-shell` is present.
 * ======================================================================= */

body.has-shell {
  padding-bottom: 0;
}

body.has-shell .layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  max-width: var(--container-max);
  margin: 0 auto;
  gap: var(--space-12);
  padding: 0 var(--content-pad-x);
  min-height: calc(100vh - var(--topbar-h));
}

@media (max-width: 1439px) {
  body.has-shell .layout {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    gap: var(--space-8);
  }
  body.has-shell .toc {
    display: none;
  }
}

@media (max-width: 1023px) {
  body.has-shell .layout {
    grid-template-columns: minmax(0, 1fr);
    padding: 0 var(--space-4);
  }
  body.has-shell .sidebar {
    display: none;
  }
  body.has-shell .sidebar.is-open {
    display: block;
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: min(320px, 85vw);
    background: var(--surface);
    border-right: 1px solid var(--border-subtle);
    padding: var(--space-4);
    z-index: 60;
    overflow-y: auto;
  }
}

/* Hide segments that the shell has wrapped out — they get rendered
 * in their new positions. Pre-JS, none of these get hidden. */
body.has-shell #segment-header {
  display: none;
}
body.has-shell #segment-navbar {
  display: none;
}
body.has-shell #segment-post-footer {
  display: none;
}

/* =========================================================================
 * 3. Topbar
 * ======================================================================= */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--canvas) 85%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 var(--content-pad-x);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  max-width: var(--container-max);
  margin: 0 auto;
  width: 100%;
}

.topbar__brand {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
  color: var(--text-primary);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-md);
  letter-spacing: var(--tracking-tight);
  text-decoration: none;
}
.topbar__brand:hover {
  color: var(--text-primary);
  border-bottom: none;
}

.topbar__brand-mark {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-interactive);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0;
}

.topbar__version {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  margin-left: var(--space-2);
}

.topbar__actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

.topbar__action {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 10px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius-interactive);
  background: transparent;
  cursor: pointer;
  transition:
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}
.topbar__action:hover {
  color: var(--text-primary);
  border-color: var(--border-default);
  background: var(--surface);
}

.topbar__menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-interactive);
  color: var(--text-secondary);
  padding: 4px 8px;
  cursor: pointer;
  font-size: var(--fs-sm);
}
@media (max-width: 1023px) {
  .topbar__menu-toggle {
    display: inline-flex;
    align-items: center;
  }
}

/* Compact topbar on small screens */
@media (max-width: 1023px) {
  .topbar {
    padding: 0 var(--space-4);
  }
  .topbar__brand > span:not(.topbar__brand-mark) {
    display: none;
  }
  .topbar__version {
    display: none;
  }
}

/* =========================================================================
 * 4. Left sidebar (repositioned navbar nav)
 * ======================================================================= */

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: var(--space-6) 0 var(--space-12);
  font-size: var(--fs-sm);
  scrollbar-width: thin;
  scrollbar-color: var(--border-default) transparent;
}
.sidebar::-webkit-scrollbar {
  width: 6px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 3px;
}

.sidebar__heading {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-tertiary);
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-5);
}
.sidebar__heading:first-child {
  margin-top: 0;
}

.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}
.sidebar ul ul {
  margin-left: var(--space-3);
  border-left: 1px solid var(--border-subtle);
  padding-left: var(--space-3);
  margin-top: var(--space-1);
  margin-bottom: var(--space-2);
}

.sidebar li {
  margin: 0;
}

.sidebar a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-3);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-interactive);
  border-bottom: none;
  transition:
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.sidebar a:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  border-bottom: none;
}
.sidebar a[aria-current='page'],
.sidebar li.is-active > a,
.sidebar a.is-active {
  background: var(--accent-muted);
  color: var(--accent);
  font-weight: var(--fw-medium);
}

/* Group header rows (the .dropdown items from menu.xml become collapsible
 * group headers in the sidebar) */
.sidebar__group {
  position: relative;
}
.sidebar__group > a {
  font-weight: var(--fw-medium);
  color: var(--text-primary);
}
.sidebar__group > a::after {
  content: '▸';
  margin-left: auto;
  font-size: 10px;
  color: var(--text-tertiary);
  transition: transform var(--dur-fast) var(--ease-out);
}
.sidebar__group.is-open > a::after {
  transform: rotate(90deg);
}
.sidebar__group:not(.is-open) > ul {
  display: none;
}

/* Hide bootstrap dropdown carets that no longer apply in sidebar mode */
.sidebar .caret {
  display: none;
}

/* =========================================================================
 * 5. Right TOC ("On this page")
 * ======================================================================= */

.toc {
  position: sticky;
  top: calc(var(--topbar-h) + var(--space-6));
  align-self: start;
  height: fit-content;
  max-height: calc(100vh - var(--topbar-h) - var(--space-12));
  overflow-y: auto;
  padding: var(--space-6) 0;
  font-size: var(--fs-sm);
}
.toc__heading {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-tertiary);
  margin: 0 0 var(--space-3);
  font-weight: var(--fw-semibold);
}
.toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.toc li {
  margin: 0;
}
.toc a {
  display: block;
  padding: 4px 0 4px var(--space-3);
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition:
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
  line-height: 1.4;
}
.toc a:hover {
  color: var(--text-primary);
  border-bottom: none;
}
.toc a.is-active {
  color: var(--accent);
  border-left-color: var(--accent);
}
.toc a.toc--h3 {
  padding-left: var(--space-6);
  font-size: 12.5px;
}
.toc.is-empty {
  display: none;
}

/* =========================================================================
 * 6. Breadcrumbs
 * ======================================================================= */

.breadcrumbs {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  margin: 0 0 var(--space-4);
  padding: 0;
}
.breadcrumbs ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.breadcrumbs li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.breadcrumbs li + li::before {
  content: '›';
  color: var(--text-tertiary);
}
.breadcrumbs a {
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: none;
}
.breadcrumbs a:hover {
  color: var(--accent);
  border-bottom: none;
}
.breadcrumbs [aria-current='page'] {
  color: var(--text-primary);
}

#segment-breadcrumb {
  background-color: transparent;
  border-bottom: none;
}
#segment-breadcrumb .breadcrumb {
  background-color: transparent;
  color: var(--text-tertiary);
  font-size: var(--fs-sm);
  padding: 0;
  margin: 0 0 var(--space-4);
  list-style: none;
}
#segment-breadcrumb .breadcrumb a {
  color: var(--text-secondary);
  border-bottom: none;
}
#segment-breadcrumb .breadcrumb a:hover {
  color: var(--accent);
}
#segment-breadcrumb .breadcrumb b {
  color: var(--text-primary);
}

/* Hide pre-JS breadcrumb when shell takes over (shell injects its own) */
body.has-shell #segment-breadcrumb {
  display: none;
}

/* =========================================================================
 * 7. Content + reading column
 * ======================================================================= */

#segment-content {
  background-color: var(--canvas);
}

#segment-content .container {
  max-width: 1100px;
  padding: 0;
}

#segment-content .inner-wrapper {
  max-width: var(--content-max);
  margin-left: auto;
  margin-right: auto;
  padding: var(--space-8) var(--space-4) var(--space-12);
}
body.has-shell #segment-content .inner-wrapper {
  padding: var(--space-8) 0 var(--space-12);
  max-width: none;
}
body.has-shell .content {
  max-width: var(--content-max);
  padding: var(--space-6) 0 var(--space-12);
  margin: 0 auto;
}

/* Tables (resource matrix, profile differential, etc.) need the full
 * container width — opt them back out of the reading-column cap. */
#segment-content .inner-wrapper > .col-12 > table,
#segment-content .inner-wrapper > .col-12 > div > table {
  max-width: none;
}

/* =========================================================================
 * 8. Headings + anchor links
 * ======================================================================= */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-sans);
  color: var(--text-primary);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-tight);
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}

h1 {
  font-size: var(--fs-2xl);
  letter-spacing: var(--tracking-display);
  line-height: var(--lh-tight);
  margin: 0 0 var(--space-4);
  font-weight: var(--fw-bold);
}

h2 {
  font-size: var(--fs-xl);
  line-height: var(--lh-snug);
  margin: var(--space-12) 0 var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

h3 {
  font-size: var(--fs-lg);
  line-height: var(--lh-snug);
  margin: var(--space-8) 0 var(--space-3);
}

h4 {
  font-size: var(--fs-md);
  margin: var(--space-6) 0 var(--space-2);
  font-weight: var(--fw-medium);
}
h5 {
  font-size: var(--fs-base);
  margin: var(--space-5) 0 var(--space-2);
}
h6 {
  font-size: var(--fs-sm);
  margin: var(--space-4) 0 var(--space-2);
  color: var(--text-secondary);
}

/* The HL7 Jekyll counter prefixes (`10.7.1.1`) — hide entirely. Both
 * `project.css` and a `<style>` block emitted inline by the publisher
 * set `h{1..6}::before { content: var(--heading-prefix) … counter(…) }`.
 * We can't strip those rules without forking the template, so override
 * them by setting `content: none` and forcing the pseudo to collapse
 * (`display: none` belt-and-suspenders). User-facing rationale (#1364):
 * the duplicate "8" prefix on page-title h1/h2 reads as visual noise,
 * not navigational signal — the sidebar + breadcrumb already disambiguate. */
h1::before,
h2::before,
h3::before,
h4::before,
h5::before,
h6::before {
  content: none !important;
  display: none !important;
}

/* Heading anchor link, revealed on hover (added by huli-enhance.js) */
.heading-anchor {
  margin-left: var(--space-2);
  opacity: 0;
  color: var(--text-tertiary);
  text-decoration: none;
  font-weight: var(--fw-regular);
  font-size: 0.85em;
  border-bottom: none;
  transition:
    opacity var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out);
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
.heading-anchor:focus-visible {
  opacity: 1;
}
.heading-anchor:hover {
  color: var(--accent);
  border-bottom: none;
}

/* =========================================================================
 * 9. Prose
 * ======================================================================= */

p {
  margin: 0 0 var(--space-4);
  color: var(--text-primary);
  max-width: 70ch;
}

ul,
ol {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-6);
}
li {
  margin: var(--space-1) 0;
  max-width: 70ch;
}
li > p {
  margin-bottom: var(--space-2);
}
li::marker {
  color: var(--text-tertiary);
}

strong {
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
}
em {
  font-style: italic;
  color: var(--text-primary);
}

hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-12) 0;
}

/* =========================================================================
 * 10. Links
 * ======================================================================= */

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(77, 141, 255, 0.4);
  border-bottom: none;
  transition:
    color var(--dur-base) var(--ease-out),
    text-decoration-color var(--dur-base) var(--ease-out);
}
a:hover,
a:focus {
  color: var(--accent-hover);
  text-decoration-color: var(--accent-hover);
  border-bottom: none;
}
a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 2px;
}
/* Strip nav/sidebar/toc links of underlines (those have their own treatment) */
.sidebar a,
.toc a,
.topbar a,
.breadcrumbs a,
.tab-content a.btn,
a.btn {
  text-decoration: none;
}

/* =========================================================================
 * 11. Inline code + code blocks
 * ======================================================================= */

code,
pre,
kbd,
samp {
  font-family: var(--font-mono);
}

:not(pre) > code,
code.language-plaintext {
  font-size: 0.875em;
  background-color: var(--code-inline-bg);
  color: var(--code-inline-text);
  padding: 1px 6px;
  border: none;
  border-radius: var(--radius-interactive);
  font-feature-settings: 'calt' 0;
  white-space: normal;
}

pre {
  background-color: var(--code-bg) !important;
  color: var(--code-text);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-surface);
  padding: var(--space-4);
  margin: var(--space-5) 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.65;
  position: relative;
  font-feature-settings:
    'calt' 1,
    'liga' 1;
}
pre code {
  background-color: transparent;
  color: inherit;
  border: none;
  padding: 0;
  font-size: inherit;
}

/* Filename header bar (set via <pre data-filename="…">) */
pre[data-filename]::before {
  content: attr(data-filename);
  display: block;
  margin: calc(var(--space-4) * -1) calc(var(--space-4) * -1) var(--space-3);
  padding: 8px var(--space-4);
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--border-subtle);
  border-radius: var(--radius-surface) var(--radius-surface) 0 0;
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  font-weight: var(--fw-medium);
}

/* Copy button (injected by huli-enhance.js) */
pre .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  font-size: var(--fs-xs);
  font-family: var(--font-sans);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-interactive);
  cursor: pointer;
  opacity: 0;
  transition:
    opacity var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
}
pre:hover .copy-btn,
pre .copy-btn:focus-visible {
  opacity: 1;
}
pre .copy-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}
pre .copy-btn[data-state='copied'] {
  color: var(--success);
  border-color: var(--success);
  opacity: 1;
}

/* Prism syntax tokens */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: var(--syn-comment);
  font-style: italic;
}
.token.punctuation {
  color: var(--syn-punctuation);
}
.token.property,
.token.boolean,
.token.number,
.token.constant,
.token.symbol {
  color: var(--syn-number);
}
.token.tag {
  color: var(--syn-tag);
}
.token.string,
.token.char,
.token.attr-value {
  color: var(--syn-string);
}
.token.keyword,
.token.atrule {
  color: var(--syn-keyword);
}
.token.attr-name {
  color: var(--syn-attr);
}
.token.function,
.token.class-name {
  color: var(--syn-function);
}
.token.selector,
.token.important {
  color: var(--syn-tag);
}

/* FHIRPath: NOT italicized (#1364 §3) */
.fhirpath,
span.inv,
td.fhirpath {
  font-family: var(--font-mono);
  font-style: normal;
  color: var(--text-primary);
}

/* =========================================================================
 * 12. Callouts / admonitions
 *
 * Left-border-accent only — no big colored fills. Per #1364 anti-patterns.
 * ======================================================================= */

#publish-box {
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-interactive);
  padding: var(--space-3) var(--space-4);
  margin: 0 0 var(--space-6);
  font-size: var(--fs-sm);
  line-height: 1.5;
}
#publish-box a {
  color: var(--warn);
  text-decoration-color: rgba(245, 181, 71, 0.4);
}
#publish-box a:hover {
  color: var(--warn);
  text-decoration-color: var(--warn);
}

blockquote {
  margin: var(--space-5) 0;
  padding: var(--space-3) var(--space-4);
  background-color: transparent;
  border: none;
  border-left: 3px solid var(--accent);
  color: var(--text-primary);
}
blockquote > :first-child {
  margin-top: 0;
}
blockquote > :last-child {
  margin-bottom: 0;
}
blockquote p {
  max-width: none;
  color: var(--text-secondary);
}

blockquote.stu-note,
blockquote.draft-note {
  border-left-color: var(--warn);
}
blockquote.stu-note p,
blockquote.draft-note p {
  color: var(--text-primary);
}

/* Bootstrap-flavored alerts */
.alert,
.alert-info,
.alert-warning,
.alert-danger,
.alert-success {
  background-color: transparent !important;
  color: var(--text-primary) !important;
  border: none;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-interactive);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-5) 0;
}
.alert-warning {
  border-left-color: var(--warn) !important;
}
.alert-danger {
  border-left-color: var(--danger) !important;
}
.alert-success {
  border-left-color: var(--success) !important;
}

.bg-info {
  background-color: var(--accent-muted) !important;
  color: var(--accent) !important;
  border-radius: var(--radius-interactive);
  padding: 2px 8px;
}
.bg-warning {
  background-color: var(--warn-muted) !important;
  color: var(--warn) !important;
  border-radius: var(--radius-interactive);
  padding: 2px 8px;
}
.bg-success {
  background-color: var(--success-muted) !important;
  color: var(--success) !important;
  border-radius: var(--radius-interactive);
  padding: 2px 8px;
}
.bg-danger {
  background-color: var(--danger-muted) !important;
  color: var(--danger) !important;
  border-radius: var(--radius-interactive);
  padding: 2px 8px;
}

/* Yellow Bootstrap warning leak — kill it dead */
.alert.alert-warning,
.bg-warning.callout-warning,
[class*='bg-warning'] {
  background-color: transparent !important;
  color: var(--text-primary) !important;
}

/* The Markdown TOC widget (`.markdown-toc`) renders as a Bootstrap `.well`
 * styled yellow by default. Restyle as a quiet info box.  */
.well,
.markdown-toc,
div.markdown-toc,
ul.markdown-toc {
  background-color: transparent;
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-interactive);
  padding: var(--space-3) var(--space-4);
  margin: 0 0 var(--space-6);
  box-shadow: none;
}
.markdown-toc > *:first-child {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-secondary);
  margin-top: 0;
}
.markdown-toc ul {
  padding-left: var(--space-4);
  margin-bottom: 0;
}

/* =========================================================================
 * 13. Tables
 *
 * Horizontal-only borders, tabular figures for cardinality cells, no
 * heavy header fill. FHIR structure-definition tables keep their tree
 * indentation; we only retint.
 * ======================================================================= */

table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--fs-sm);
  background-color: transparent;
  color: var(--text-primary);
  margin: var(--space-5) 0;
  border-top: 1px solid var(--border-default);
  border-bottom: 1px solid var(--border-default);
}

thead th,
table th {
  background-color: transparent;
  text-align: left;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-secondary);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-default);
  vertical-align: bottom;
}

tbody td,
table td {
  background-color: transparent;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  border-right: none;
  border-left: none;
  vertical-align: top;
  color: var(--text-primary);
}
tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background var(--dur-fast) var(--ease-out);
}
tbody tr:hover td,
tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.025);
}

/* Generic FHIR tables — bootstrap-fhir.css pins these to white/yellow.
 * Override with transparent so the canvas shows through. */
table.colsd,
table.colsi,
table.colse,
table.colsa,
table.colsm,
table.lines,
table.list,
table.dict,
table.grid,
table.codes,
table.diff,
table.none,
table.table-condensed,
table.table-hover {
  background-color: transparent;
}
table.colsd td,
table.colsd tr td,
table.colsi td,
table.colsi tr td,
table.colse td,
table.colse tr td,
table.colsa td,
table.colsa tr td,
table.colsm td,
table.colsm tr td,
table.list td,
table.dict td,
table.grid td,
table.lines td,
table.codes td,
table.diff td,
table.table-condensed td,
table.table-hover td {
  background-color: transparent !important;
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
table.colsd tr:nth-child(even) td,
table.colsi tr:nth-child(even) td,
table.list tr:nth-child(even) td {
  background-color: rgba(255, 255, 255, 0.02) !important;
}
table.colsd i,
table.colsi i {
  color: var(--text-tertiary);
}
table.colsd a,
table.colsi a {
  text-decoration: none;
}

/* Some FHIR pages emit raw <tr style="background-color:..."> and
 * <td class="hierarchy" style="background-color: white"> inline styles.
 * Override with !important so the dark canvas wins. The hierarchy
 * cells use `background-image: url(tbl_bck*.png)` for tree-line glyphs
 * — those are FHIR-canonical and we keep them. */
table tr[style*='background'] td,
table td[style*='background-color: white'],
table th[style*='background-color: white'],
table td.hierarchy[style*='background'],
td.hierarchy {
  background-color: transparent !important;
}

/* The FHIR-generated `<tr fhir="generated-heirarchy">` rows hold the
 * structure-definition tree. Force tabular-numeric-friendly type. */
tr[fhir='generated-heirarchy'] {
  font-family: var(--font-mono) !important;
  font-size: var(--fs-sm) !important;
  border-color: var(--border-subtle) !important;
}
tr[fhir='generated-heirarchy'] td,
tr[fhir='generated-heirarchy'] th {
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
}
tr[fhir='generated-heirarchy'] a {
  color: var(--accent) !important;
  text-decoration: none !important;
}
tr[fhir='generated-heirarchy'] a:hover {
  text-decoration: underline !important;
}
tr[fhir='generated-heirarchy'] th {
  background-color: transparent !important;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  font-weight: var(--fw-semibold) !important;
  border-bottom: 1px solid var(--border-default) !important;
}

/* The "Description & Constraints" wide column text */
tr[fhir='generated-heirarchy'] td span {
  color: var(--text-secondary) !important;
}
tr[fhir='generated-heirarchy'] td span span,
tr[fhir='generated-heirarchy'] td span b,
tr[fhir='generated-heirarchy'] td b {
  color: var(--text-primary) !important;
}

/* The faint hash "filter" input area */
input[type='text'][style*='background'] {
  background-color: var(--surface) !important;
  color: var(--text-primary) !important;
}

/* Type / Cardinality columns — monospace */
table td code,
table td span[style*='monospace'] {
  font-family: var(--font-mono);
  font-size: 0.88em;
}
table td[class*='cardinality'],
table.list td:nth-child(3) {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

/* The bootstrap-fhir flag cell that holds Must Support letters */
table td.flags {
  white-space: nowrap;
}

/* =========================================================================
 * 14. FHIR convention glyphs — preserve letters, recolor only (#1364 §3)
 * ======================================================================= */

td span[title*='Must Support'],
td a[title*='Must Support'],
.must-support,
span.must-support,
a.must-support {
  color: var(--accent) !important;
  font-weight: var(--fw-bold);
  font-family: var(--font-mono);
  background: var(--accent-muted) !important;
  padding: 0 4px;
  border-radius: var(--radius-interactive);
}

td span[title*='Modifier'],
td a[title*='Modifier'],
.modifier {
  color: var(--warn) !important;
  font-weight: var(--fw-bold);
  font-family: var(--font-mono);
  background: var(--warn-muted) !important;
  padding: 0 4px;
  border-radius: var(--radius-interactive);
}

td span[title*='Summary'],
td a[title*='Summary'] {
  color: var(--text-secondary);
  font-weight: var(--fw-semibold);
  font-family: var(--font-mono);
}

td span[title*='Invariant'],
td a[title*='Invariant'] {
  color: var(--text-secondary);
  font-style: normal;
  font-family: var(--font-mono);
}

/* =========================================================================
 * 15. Panels + bootstrap cards
 * ======================================================================= */

.panel,
.panel-default,
.panel.panel-default,
.well {
  background-color: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-surface);
  box-shadow: none;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}
.panel-heading {
  background-color: transparent;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: var(--space-3) var(--space-4);
  font-weight: var(--fw-semibold);
  border-top-left-radius: var(--radius-surface);
  border-top-right-radius: var(--radius-surface);
}
.panel-body {
  background-color: transparent;
  color: var(--text-primary);
  padding: var(--space-4);
}
.panel-footer {
  background-color: transparent;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: var(--space-3) var(--space-4);
}

/* =========================================================================
 * 16. Buttons + form widgets
 * ======================================================================= */

.btn,
button.btn-copy,
.btn-default {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background-color: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-interactive);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  padding: 6px var(--space-3);
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
}
.btn:hover,
button.btn-copy:hover {
  background-color: var(--surface-raised);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.copy-text {
  font-family: var(--font-mono);
  font-size: 0.88em;
}

input[type='text'],
input[type='search'],
select,
textarea {
  background-color: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-interactive);
  padding: 6px var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

/* =========================================================================
 * 17. FHIR resource tabs — flat underline-on-active
 * ======================================================================= */

.nav-tabs,
ul.nav.nav-tabs {
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0;
  margin: 0 0 var(--space-5);
  background: transparent;
}
.nav-tabs > li,
ul.nav.nav-tabs > li {
  margin-bottom: -1px;
}
.nav-tabs > li > a,
ul.nav.nav-tabs > li > a {
  background-color: transparent !important;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  border-radius: 0 !important;
  color: var(--text-secondary) !important;
  padding: var(--space-2) var(--space-3) !important;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  text-decoration: none;
  margin-right: var(--space-2);
}
.nav-tabs > li > a:hover,
ul.nav.nav-tabs > li > a:hover {
  color: var(--text-primary) !important;
  border-bottom-color: var(--border-default) !important;
}
.nav-tabs > li.active > a,
ul.nav.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
ul.nav.nav-tabs > li.active > a:hover,
.nav-tabs > li.active > a:focus,
ul.nav.nav-tabs > li.active > a:focus {
  color: var(--accent) !important;
  border-bottom-color: var(--accent) !important;
  background-color: transparent !important;
}

/* jQuery UI tabs — used for "Key Elements Table | Differential …" widget */
.ui-tabs.ui-widget {
  background-color: transparent !important;
  border: none !important;
}
.ui-tabs-nav.ui-widget-header {
  background: transparent !important;
  border: none !important;
  border-bottom: 1px solid var(--border-subtle) !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin: 0 0 var(--space-5) !important;
}
.ui-tabs-nav .ui-state-default,
.ui-tabs-nav .ui-corner-top {
  background: transparent !important;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  border-radius: 0 !important;
  margin: 0 var(--space-2) 0 0 !important;
  padding: 0 !important;
}
.ui-tabs-nav .ui-state-default > a,
.ui-tabs-nav .ui-tabs-anchor {
  color: var(--text-secondary) !important;
  background: transparent !important;
  border: none !important;
  font-size: var(--fs-sm) !important;
  font-weight: var(--fw-medium) !important;
  padding: var(--space-2) var(--space-3) !important;
  text-decoration: none !important;
}
.ui-tabs-nav .ui-state-default:hover > a {
  color: var(--text-primary) !important;
}
.ui-tabs-nav .ui-state-active,
.ui-tabs-nav .ui-tabs-active {
  background: transparent !important;
  border-bottom-color: var(--accent) !important;
}
.ui-tabs-nav .ui-state-active > a,
.ui-tabs-nav .ui-tabs-active .ui-tabs-anchor {
  color: var(--accent) !important;
}
.ui-tabs-panel.ui-widget-content {
  background: transparent !important;
  border: none !important;
  padding: var(--space-4) 0 0 !important;
  color: var(--text-primary) !important;
}

/* =========================================================================
 * 18. Page-meta + footer
 *
 * `huli-enhance.js` removes the HL7-emitted `#segment-footer` entirely
 * (it would have rendered a centered "Huli ↗ FHIR 4.0.1 ↗" row plus a
 * "Links: Table of Contents | QA Report" sub-row pointing at the IG
 * Publisher's internal qa.html — useless for partners). The footer is
 * therefore a single left-aligned brand line that absorbs the FHIR
 * version inline.
 *
 * Defensive: leave a `#segment-post-footer` reset in case the publisher
 * template later un-hides it.
 * ======================================================================= */

#segment-post-footer {
  background-color: var(--canvas);
  min-height: 0;
}

.footer-strip {
  border-top: 1px solid var(--border-subtle);
  background: var(--surface);
  padding: var(--space-6) var(--content-pad-x) var(--space-6);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  margin-top: var(--space-12);
}
.footer-strip__inner {
  max-width: var(--container-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  text-align: center;
}
.footer-strip__brand {
  color: var(--text-tertiary);
  text-align: center;
}

/* Page-meta (Last updated) — appears at end of content. Left-aligned;
 * the "Edit on GitHub" link was removed because the monorepo is private
 * and the link would dead-end for partners. */
.page-meta {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-10);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
}

/* =========================================================================
 * 19. Prev / Next pagination
 * ======================================================================= */

.pagination {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-top: var(--space-12);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border-subtle);
  list-style: none;
}
.pagination a {
  display: block;
  padding: var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-surface);
  text-decoration: none;
  color: var(--text-primary);
  background: transparent;
  transition:
    border-color var(--dur-base) var(--ease-out),
    background var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
}
.pagination a:hover {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text-primary);
  transform: translateY(-1px);
  text-decoration: none;
}
.pagination__label {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  display: block;
  margin-bottom: 4px;
}
.pagination__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
}
.pagination__item--next {
  text-align: right;
}
.pagination__item--prev {
  text-align: left;
}
.pagination__item--placeholder {
  visibility: hidden;
}

/* =========================================================================
 * 20. Reduced motion
 * ======================================================================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
