/**
 * madcap-guide.css  v3.1.0
 * Styles for the madcap_guide CPT template.
 *
 * Uses BEM notation: .madcap-guide__* for layout, .madcap-toc__* for TOC,
 * .madcap-section__* for content sections.
 *
 * Designed to work inside any classic WordPress theme.
 * Variables at the top — override in your child theme if needed.
 */

/* -------------------------------------------------------------------------
   Custom properties (override in :root or .madcap-guide in child theme)
   ---------------------------------------------------------------------- */
:root {
  --mg-sidebar-width: 280px;
  --mg-header-bg: #472645;
  --mg-header-color: #ffffff;
  --mg-sidebar-bg: #f5f6f8;
  --mg-sidebar-border: #dde0e6;
  --mg-toc-active-color: #472645;
  --mg-toc-active-bg: #e4ecf7;
  --mg-content-bg: #ffffff;
  --mg-font-size-base: 1rem;
  --mg-line-height: 1.7;
  --mg-top-offset: 60px; /* Match your theme's sticky header height */
  --mg-toc-link-color: #1a2b4a;
}

/* -------------------------------------------------------------------------
   Outer wrapper
   ---------------------------------------------------------------------- */
.madcap-guide {
  display: flex;
  flex-direction: column;

  font-size: var(--mg-font-size-base);
  line-height: var(--mg-line-height);

  min-height: 100vh;
}

/* -------------------------------------------------------------------------
   Header strip
   ---------------------------------------------------------------------- */
.madcap-guide__header {
  background: var(--mg-header-bg);
  color: var(--mg-header-color);
  padding: 1rem 1.5rem;
}

.madcap-guide__header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  max-width: 1600px;
  margin: 0 auto;
}

.madcap-guide__title-block {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.madcap-guide__product-name {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.75;
}

.madcap-guide__product-model {
  font-size: 0.8125rem;
  opacity: 0.6;
}

.madcap-guide__guide-title {
  margin: 0 !important;
  font-size: 1.85rem;
}

/* Language switcher */
.madcap-guide__lang-switcher {
  flex-shrink: 0;
}

.madcap-guide__lang-select {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  color: var(--mg-header-color);
  font-size: 0.875rem;
  padding: 0.375rem 0.625rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.madcap-guide__lang-select:hover,
.madcap-guide__lang-select:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.madcap-guide__lang-select option {
  background: #1a2b4a;
  color: #fff;
}

/* -------------------------------------------------------------------------
   Body: sidebar + content
   ---------------------------------------------------------------------- */
.madcap-guide__body {
  display: flex;
  flex: 1;
  align-items: flex-start;
  justify-content: center;
}

/* -------------------------------------------------------------------------
   Sidebar
   ---------------------------------------------------------------------- */
.madcap-guide__sidebar {
  width: var(--mg-sidebar-width);
  min-width: var(--mg-sidebar-width);
  max-width: var(--mg-sidebar-width);
  /* background: var(--mg-sidebar-bg); */
  border-right: 1px solid var(--mg-sidebar-border);
  position: sticky;
  top: var(--mg-top-offset);
  max-height: calc(100vh - var(--mg-top-offset));
  overflow: hidden;

  /* Flex column so footer pins to bottom, TOC scrolls */
  display: flex;
  flex-direction: column;
}

/* -------------------------------------------------------------------------
   TOC nav
   ---------------------------------------------------------------------- */
.madcap-guide__toc {
  padding: 1rem 0;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;

  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--mg-sidebar-border) transparent;
}

.madcap-guide__toc::-webkit-scrollbar {
  width: 4px;
}
.madcap-guide__toc::-webkit-scrollbar-track {
  background: transparent;
}
.madcap-guide__toc::-webkit-scrollbar-thumb {
  background: var(--mg-sidebar-border);
  border-radius: 4px;
}

.madcap-guide__toc-heading {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8a93a6;
  margin: 0 0 0.5rem;
  padding: 0 1rem;
}

.madcap-guide__toc-empty {
  padding: 0 1rem;
  color: #999;
  font-size: 0.875rem;
}

.madcap-toc__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Depth 1 — first level of children.
   A subtle left border acts as a visual connecting line to the parent. */
.madcap-toc__list--depth-1 {
  margin-left: 1.125rem;
  border-left: 2px solid var(--mg-sidebar-border);
}

/* Depth 2 — second level, indented further with a lighter line */
.madcap-toc__list--depth-2 {
  margin-left: 1rem;
  border-left: 2px solid color-mix(in srgb, var(--mg-sidebar-border) 50%, transparent);
}

/* Depth 3+ — clamp at a sensible indent */
.madcap-toc__list--depth-3,
.madcap-toc__list--depth-4 {
  margin-left: 0.875rem;
  border-left: 1px dashed var(--mg-sidebar-border);
}

.madcap-toc__item {
  margin: 0;
  padding: 0;
}

/* ---- Base link ---- */
.madcap-toc__link {
  display: block;
  padding: 0.3125rem 0.875rem;
  font-size: 0.875rem;
  color: var(--mg-toc-link-color);
  text-decoration: none;
  border-left: 3px solid transparent;
  margin-left: -2px; /* overlap the parent border-left */
  transition:
    background 0.1s ease,
    color 0.1s ease,
    border-color 0.1s ease;
  word-break: break-word;
  hyphens: auto;
}

/* ---- Depth-0 top-level items — full weight ---- */
.madcap-toc__list--depth-0 > .madcap-toc__item > .madcap-toc__link {
  padding-left: 1rem;
  margin-left: 0;
  font-weight: 500;
}

/* ---- Depth-1 children — slightly smaller, muted ---- */
.madcap-toc__list--depth-1 > .madcap-toc__item > .madcap-toc__link {
  font-size: 0.8125rem;
  color: color-mix(in srgb, var(--mg-toc-link-color) 80%, transparent);
}

/* ---- Depth-2+ — smaller still ---- */
.madcap-toc__list--depth-2 > .madcap-toc__item > .madcap-toc__link,
.madcap-toc__list--depth-3 > .madcap-toc__item > .madcap-toc__link {
  font-size: 0.75rem;
  color: color-mix(in srgb, var(--mg-toc-link-color) 65%, transparent);
}

.madcap-toc__link:hover {
  background: rgba(0, 85, 164, 0.06);
  color: var(--mg-toc-active-color);
}

.madcap-toc__item--active > .madcap-toc__link {
  background: var(--mg-toc-active-bg);
  color: var(--mg-toc-active-color);
  border-left-color: var(--mg-toc-active-color);
  font-weight: 600;
}

/* -------------------------------------------------------------------------
   Content area
   ---------------------------------------------------------------------- */
.madcap-guide__content {
  flex: 1;
  min-width: 0; /* prevent flex blowout */
  background: var(--mg-content-bg);
  padding: 2rem 2.5rem;
  max-width: 900px;
}

.madcap-guide__no-content {
  color: #999;
  font-style: italic;
}

/* -------------------------------------------------------------------------
   Welcome hero — auto-generated from depth-0 sections
   Rendered by renderWelcome() in madcap-guide.js before section content.
   Grid layout is handled by Bootstrap 5 row/col utilities in the markup;
   these rules handle colour, hover behaviour, and typography only.
   ---------------------------------------------------------------------- */
.madcap-welcome {
  margin-bottom: 3rem;
  padding-bottom: 2.5rem;
  border-bottom: 2px solid #edf0f4;
}

.madcap-welcome__title {
  font-size: 1.75rem;
  font-weight: 700;

  margin: 0 0 1.75rem;
}

/* Card — layers on top of Bootstrap's .card */
.madcap-welcome__card.card {
  background: #f5f7fb;
  border: 1px solid #dde4ef;
  color: inherit;
  transition:
    box-shadow 0.18s ease,
    transform 0.18s ease,
    border-color 0.18s ease;
}

.madcap-welcome__card.card:hover {
  box-shadow: 0 4px 16px rgba(0, 85, 164, 0.12);
  transform: translateY(-2px);
  border-color: #b3c8e8;
  color: inherit;
  text-decoration: none;
}

.madcap-welcome__card-title {
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  margin-bottom: 0 !important;
}

.madcap-welcome__card-desc {
  font-size: 0.875rem;
  color: #555;
  line-height: 1.55;
}

@media (max-width: 480px) {
  .madcap-welcome__title {
    font-size: 1.375rem;
  }
}

/* -------------------------------------------------------------------------
   Sections — depth-aware styling
   data-depth="0"  top-level chapter
   data-depth="1"  section within a chapter
   data-depth="2"  sub-section
   ---------------------------------------------------------------------- */

/* --- Shared base --- */
.madcap-section {
  scroll-margin-top: calc(var(--mg-top-offset) + 1rem);
}

/* --- Depth 0 — top-level chapter --- */
.madcap-section[data-depth="0"] {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid #edf0f4;
}

.madcap-section[data-depth="0"]:last-child {
  border-bottom: none;
}

.madcap-section[data-depth="0"] > .madcap-section__title {
  font-size: 1.375rem;
  font-weight: 700;
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
}

/* --- Depth 1 — section inside a chapter --- */
.madcap-section[data-depth="1"] {
  margin: 1.75rem 0 1.75rem 1.25rem;
  padding: 0 0 1.5rem 1.25rem;
  border-left: 3px solid #e4ecf7;
  border-bottom: 1px solid #f2f4f8;
}

.madcap-section[data-depth="1"]:last-child {
  border-bottom: none;
}

.madcap-section[data-depth="1"] > .madcap-section__title {
  font-size: 1.125rem;
  font-weight: 600;

  margin: 0 0 0.75rem;

  padding-bottom: 0.375rem;
}

/* --- Depth 2 — sub-section --- */
.madcap-section[data-depth="2"] {
  margin: 1.25rem 0 1.25rem 1rem;
  padding: 0 0 1rem 1rem;
  border-left: 2px solid #edf0f4;
}

.madcap-section[data-depth="2"]:last-child {
  border-bottom: none;
}

.madcap-section[data-depth="2"] > .madcap-section__title {
  font-size: 1rem;
  font-weight: 600;

  margin: 0 0 0.625rem;
}

/* --- Depth 3+ — deep nesting, minimal chrome --- */
.madcap-section[data-depth="3"],
.madcap-section[data-depth="4"] {
  margin: 1rem 0 1rem 0.75rem;
  padding-left: 0.875rem;
  border-left: 1px dashed #dde0e6;
}

.madcap-section[data-depth="3"] > .madcap-section__title,
.madcap-section[data-depth="4"] > .madcap-section__title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #3d5070;
  margin: 0 0 0.5rem;
}

/* Fallback — any section that has no depth attribute yet (legacy) */
.madcap-section:not([data-depth]) {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid #edf0f4;
}

.madcap-section:not([data-depth]) > .madcap-section__title {
  font-size: 1.375rem;
  font-weight: 700;

  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e4ecf7;
}

.madcap-section__body {
  color: #333;
}

/* -------------------------------------------------------------------------
   Section body content — typical guide elements
   ---------------------------------------------------------------------- */
.madcap-section__body p {
  margin: 0 0 1em;
}

.madcap-section__body h1,
.madcap-section__body h2,
.madcap-section__body h3,
.madcap-section__body h4,
.madcap-section__body h5,
.madcap-section__body h6 {
  margin: 1.5em 0 0.5em;
  line-height: 1.3;
}

.madcap-section__body h1 {
  font-size: 1.5rem;
}
.madcap-section__body h2 {
  font-size: 1.25rem;
}
.madcap-section__body h3 {
  font-size: 1.125rem;
}
.madcap-section__body h4 {
  font-size: 1rem;
}

.madcap-section__body ul,
.madcap-section__body ol {
  margin: 0 0 1em 1.5em;
  padding-left: 0.5em;
}

.madcap-section__body li {
  margin-bottom: 0.4em;
}

.madcap-section__body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25em 0;
  font-size: 0.9375rem;
}

.madcap-section__body th,
.madcap-section__body td {
  border: 1px solid #dde0e6;
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

.madcap-section__body th {
  background: #f0f4fa;
  font-weight: 600;
}

.madcap-section__body tr:nth-child(even) td {
  background: #f9fafc;
}

.madcap-section__body img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 0.75em 0;
}

.madcap-section__body a {
  color: var(--mg-toc-active-color);
  text-decoration: underline;
}

.madcap-section__body a:hover {
  text-decoration: none;
}

.madcap-section__body code {
  background: #f0f4fa;
  border: 1px solid #dde0e6;
  border-radius: 3px;
  font-size: 0.875em;
  padding: 0.1em 0.35em;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.madcap-section__body pre {
  background: #1a2b4a;
  color: #e4ecf7;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
  margin: 1em 0;
}

.madcap-section__body pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}

.madcap-section__body blockquote {
  border-left: 4px solid var(--mg-toc-active-color);
  margin: 1.25em 0;
  padding: 0.5em 1em;
  background: #f0f4fa;
  color: #444;
  font-style: italic;
}

/* Warning / note callout boxes MadCap often uses */
.madcap-section__body .Note,
.madcap-section__body .Tip,
.madcap-section__body .Warning,
.madcap-section__body .Caution {
  border-left: 4px solid #f0b429;
  background: #fffbec;
  padding: 0.75rem 1rem;
  margin: 1.25em 0;
  border-radius: 0 4px 4px 0;
  font-size: 0.9375rem;
}

.madcap-section__body .Warning,
.madcap-section__body .Caution {
  border-left-color: #e0351b;
  background: #fff5f5;
}

/* -------------------------------------------------------------------------
   Mobile — sticky header + right-side TOC drawer
   ---------------------------------------------------------------------- */
@media (max-width: 767px) {
  .madcap-guide__header {
    position: sticky;
    top: 0;
    z-index: 200;
  }

  .madcap-guide__body {
    display: block; /* sidebar is out-of-flow (fixed) on mobile */
  }

  .madcap-guide__sidebar {
    /* Drawer: fixed panel slides in from the right */
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 85vw);
    min-width: 0;
    max-width: none;
    max-height: none;
    z-index: 300;
    transform: translateX(110%);
    transition: transform 0.28s ease;
    background: var(--mg-sidebar-bg, #f5f6f8);
    border-right: none;
    border-left: 1px solid var(--mg-sidebar-border);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    overflow: hidden;
  }

  .madcap-guide__sidebar--open {
    transform: translateX(0);
  }

  .madcap-guide__content {
    padding: 1.25rem 1rem;
  }
}

@media (max-width: 480px) {
  .madcap-guide__header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .madcap-guide__guide-title {
    font-size: 1.125rem;
  }
}

/* -------------------------------------------------------------------------
   Opacity transition helper (used by JS during lang switch)
   ---------------------------------------------------------------------- */
#madcap-toc,
#madcap-content {
  transition: opacity 0.2s ease;
}

/* -------------------------------------------------------------------------
   Skip link — WCAG 2.4.1: bypass repeated navigation
   ---------------------------------------------------------------------- */
.madcap-guide__skip-link {
  position: absolute;
  left: 50%;
  top: 0.5rem;
  transform: translateX(-50%) translateY(-120%);
  background: #1a2b4a;
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.875rem;
  z-index: 9999;
  text-decoration: none;
  transition: transform 0.15s ease;
}

.madcap-guide__skip-link:focus {
  transform: translateX(-50%) translateY(0);
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* -------------------------------------------------------------------------
   Hamburger toggle — hidden on desktop, shown on mobile
   ---------------------------------------------------------------------- */
.madcap-guide__toc-toggle {
  display: none; /* shown only in mobile media query below */
  background: none;
  border: none;
  color: var(--mg-header-color);
  cursor: pointer;
  padding: 0.375rem;
  border-radius: 4px;
  line-height: 0;
  flex-shrink: 0;
}

.madcap-guide__toc-toggle:hover,
.madcap-guide__toc-toggle:focus-visible {
  background: rgba(255, 255, 255, 0.15);
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

@media (max-width: 767px) {
  .madcap-guide__toc-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* -------------------------------------------------------------------------
   Sidebar close button — visible inside drawer on mobile
   ---------------------------------------------------------------------- */
.madcap-guide__sidebar-close {
  display: none;
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  padding: 0.75rem 1rem;
  align-self: flex-end;
  line-height: 0;
  border-radius: 4px;
  flex-shrink: 0;
}

.madcap-guide__sidebar-close:hover,
.madcap-guide__sidebar-close:focus-visible {
  background: rgba(0, 0, 0, 0.06);
  outline: 2px solid var(--mg-toc-active-color);
  outline-offset: 2px;
}

@media (max-width: 767px) {
  .madcap-guide__sidebar-close {
    display: flex;
  }
}

/* -------------------------------------------------------------------------
   Overlay — tinted backdrop behind the mobile TOC drawer
   ---------------------------------------------------------------------- */
.madcap-guide__overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 250;
  opacity: 0;
  pointer-events: none; /* invisible overlay must never block clicks */
  transition: opacity 0.28s ease;
}

.madcap-guide__overlay--visible {
  opacity: 1;
  pointer-events: auto; /* only capture clicks once the drawer is open */
}

@media (max-width: 767px) {
  .madcap-guide__overlay {
    display: block;
  }
}

/* -------------------------------------------------------------------------
   Sidebar footer + Save as PDF button
   ---------------------------------------------------------------------- */
.madcap-guide__sidebar-footer {
  flex-shrink: 0;
  padding: 0.875rem 1rem;
  border-top: 1px solid var(--mg-sidebar-border);
}

.madcap-guide__print-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  background: none;
  border: 1px solid var(--mg-sidebar-border);
  border-radius: 6px;
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #444;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
  text-align: left;
}

.madcap-guide__print-btn:hover {
  background: var(--mg-toc-active-bg);
  border-color: var(--mg-toc-active-color);
  color: var(--mg-toc-active-color);
}

.madcap-guide__print-btn:focus-visible {
  outline: 2px solid var(--mg-toc-active-color);
  outline-offset: 2px;
}

/* -------------------------------------------------------------------------
   Focus-visible improvements — WCAG 2.4.7
   ---------------------------------------------------------------------- */
.madcap-toc__link:focus-visible {
  outline: 2px solid var(--mg-toc-active-color);
  outline-offset: 2px;
  border-radius: 2px;
}

.madcap-guide__lang-select:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.7);
  outline-offset: 2px;
}

/* -------------------------------------------------------------------------
   Print / Save as PDF
   ---------------------------------------------------------------------- */
@media print {
  .madcap-guide__header,
  .madcap-guide__sidebar,
  .madcap-guide__overlay,
  .madcap-guide__skip-link {
    display: none !important;
  }

  .madcap-guide__body {
    display: block;
  }

  .madcap-guide__content {
    max-width: none;
    padding: 0;
  }

  .madcap-section {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .madcap-section[data-depth="0"] {
    page-break-before: auto;
  }

  /* Show external link URLs inline */
  .madcap-section__body a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.75em;
    color: #666;
  }

  /* Reset colours for clean print output */
  :root {
    --mg-toc-active-color: #000;
    --mg-content-bg: #fff;
  }
}
