/*
 * FAQ Help Centre — 3-Column Layout
 * Requires: theme-variables.css
 *
 * Structure expected in HTML:
 *
 *   <div class="faq-topbar">...</div>
 *   <div class="faq-shell">
 *     <aside class="faq-sidebar">...</aside>
 *     <main class="faq-content">...</main>
 *     <aside class="faq-toc">...</aside>
 *   </div>
 *
 * Breakpoints:
 *   Desktop  > 1200px : full 3-column
 *   Tablet   768-1200 : hide right TOC, 2-column
 *   Mobile   < 768px  : single column, sidebar as overlay
 */

/* ─── Reset & base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

/* Override Hello Elementor / browser default pink focus colour on all FAQ buttons.
   color: inherit !important — prevents Hello theme making text white on focus
   (caused accordion trigger text to vanish after tapping on mobile).
   background-color is intentionally NOT overridden globally — each component
   manages its own background; we only want to kill the pink outline/glow. */
.faq-page button:focus,
.faq-page button:focus-visible,
.faq-page button:active,
.faq-page a:focus,
.faq-page a:focus-visible {
  outline-color: var(--faq-accent) !important;
  color: inherit !important;
}

/* For icon-only / transparent buttons (hamburger, theme toggle, close, expand)
   suppress the pink background fill specifically */
.faq-topbar__hamburger:focus,
.faq-topbar__hamburger:focus-visible,
.faq-topbar__hamburger:active,
.faq-topbar__search-trigger:focus,
.faq-topbar__search-trigger:focus-visible,
.faq-topbar__search-trigger:active,
.faq-theme-toggle button:focus,
.faq-theme-toggle button:focus-visible,
.faq-theme-toggle button:active,
.faq-nav__expand-btn:focus,
.faq-nav__expand-btn:focus-visible,
.faq-nav__expand-btn:active,
.faq-nav__close-btn:focus,
.faq-nav__close-btn:focus-visible,
.faq-nav__close-btn:active {
  background-color: transparent !important;
}

/* accent-color applies to checkboxes/range inputs — keep it orange */
.faq-page {
  accent-color: var(--faq-accent);
}

html {
  scroll-behavior: smooth;
  min-height: 100%;
  background-color: var(--faq-bg-primary);
}

body.faq-page {
  margin: 0;
  padding: 0;
  font-family: 'Cabin', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  background: transparent;
  color: var(--faq-text-secondary);
  -webkit-font-smoothing: antialiased;
  transition: var(--faq-transition);
}

/* Gradient via fixed pseudo-element — avoids background-attachment:fixed
   Safari repaint bug; all columns remain transparent over it */
body.faq-page::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--faq-bg-page);
  pointer-events: none;
}

/* ─── Top bar ────────────────────────────────────────────────────────────── */
.faq-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 max(24px, calc((100vw - 1440px) / 2));
  gap: 16px;
  background: var(--faq-bg-page);
  background-size: 100vw 100vh;
  border-bottom: 1px solid var(--faq-border-topbar);
  transition: var(--faq-transition);
}

/* Left slot — fixed 280px, aligns logo over left sidebar column */
.faq-topbar__left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  width: 280px;
  padding-left: 0;
}

/* Right slot — fixed 220px, aligns language switcher over TOC column */
.faq-topbar__right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  width: 220px;
}

.faq-topbar__logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  text-decoration: none;
}

.faq-topbar__logo img {
  height: 32px;
  width: auto;
}

.faq-topbar__search-trigger {
  flex: 1;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--faq-border);
  background-color: var(--faq-bg-sidebar);
  color: var(--faq-text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.faq-topbar__search-trigger:hover,
.faq-topbar__search-trigger:focus,
.faq-topbar__search-trigger:focus-visible,
.faq-topbar__search-trigger:active {
  border-color: var(--faq-accent) !important;
  background-color: var(--faq-bg-sidebar) !important;
  color: var(--faq-text-muted) !important;
  outline: 2px solid var(--faq-accent) !important;
  outline-offset: 0 !important;
}

.faq-topbar__search-trigger svg {
  flex-shrink: 0;
  opacity: 0.5;
}

.faq-topbar__search-shortcut {
  margin-left: auto;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: var(--faq-border);
  color: var(--faq-text-muted);
}

.faq-topbar__hamburger {
  display: none;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--faq-text-primary);
}

.faq-topbar__hamburger:hover {
  background-color: var(--faq-accent) !important;
  color: #fff !important;
  border-radius: 4px;
}

/* ─── Shell (3-column grid) ──────────────────────────────────────────────── */
.faq-shell {
  display: grid;
  grid-template-columns: 280px 1fr 220px;
  grid-template-areas: "sidebar content toc";
  min-height: calc(100vh - 60px);
  margin-top: 60px;
  max-width: 1440px;
  margin-left: auto;
  margin-right: auto;
}

/* Homepage: 2-column layout (no right TOC).
   Must be defined before media queries so they can override it on mobile. */
.faq-shell--home {
  grid-template-columns: 280px 1fr;
  grid-template-areas: "sidebar content";
}

/* ─── Left sidebar ───────────────────────────────────────────────────────── */
.faq-sidebar {
  grid-area: sidebar;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 24px 0 40px;
  border-right: 1px solid var(--faq-border-sidebar);
  transition: var(--faq-transition);
  scrollbar-width: thin;
  scrollbar-color: var(--faq-border) transparent;
}

.faq-sidebar::-webkit-scrollbar { width: 4px; }
.faq-sidebar::-webkit-scrollbar-track { background: transparent; }
.faq-sidebar::-webkit-scrollbar-thumb { background-color: var(--faq-border); border-radius: 2px; }

/* ─── Main content ───────────────────────────────────────────────────────── */
.faq-content {
  grid-area: content;
  padding: 40px 48px calc(75vh - 275px);
  min-width: 0; /* prevent overflow in grid */
  max-width: 720px;
  width: 100%;
}

/* ─── Right TOC sidebar ──────────────────────────────────────────────────── */
/* Desktop: position:fixed pins the TOC to the viewport top-right regardless
   of grid row height. The 220px grid column is still reserved so the content
   column width is unchanged. right offset accounts for max-width centering
   of faq-shell (max-width:1440px, margin:0 auto). */
.faq-toc {
  grid-area: toc;
  position: fixed;
  top: 60px;
  right: max(0px, calc((100vw - 1440px) / 2));
  width: 220px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 32px 16px 40px 8px;
  z-index: 50;
  transition: var(--faq-transition);
  scrollbar-width: thin;
  scrollbar-color: var(--faq-border) transparent;
  /* border-left removed per user request */
}

.faq-toc::-webkit-scrollbar { width: 4px; }
.faq-toc::-webkit-scrollbar-thumb { background-color: var(--faq-border); border-radius: 2px; }

/* ─── Article typography ─────────────────────────────────────────────────── */
.faq-content h1 {
  font-family: 'Prata', Georgia, serif;
  font-size: 32px;
  font-weight: 400;
  line-height: 1.25;
  margin: 0 0 24px;
  color: var(--faq-text-primary);
}

.faq-content h2 {
  font-family: 'Prata', Georgia, serif;
  font-size: 24px;
  font-weight: 400;
  line-height: 1.3;
  margin: 40px 0 16px;
  padding-top: 8px;
  color: var(--faq-text-primary);
}

.faq-content h3 {
  font-family: 'Cabin', sans-serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  margin: 28px 0 12px;
  color: var(--faq-text-primary);
}

.faq-content p {
  margin: 0 0 16px;
  color: var(--faq-text-secondary);
}

.faq-content a {
  color: var(--faq-accent);
  text-decoration: none;
}

.faq-content a:hover {
  text-decoration: underline;
}

.faq-content ul,
.faq-content ol {
  margin: 0 0 16px;
  padding-left: 24px;
}

.faq-content li {
  margin-bottom: 6px;
}

.faq-content code {
  font-family: 'Fira Mono', 'Consolas', monospace;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: var(--faq-bg-code);
  color: var(--faq-accent);
}

.faq-content pre {
  background-color: var(--faq-bg-code);
  border-radius: 8px;
  padding: 20px;
  overflow-x: auto;
  margin: 0 0 20px;
}

.faq-content pre code {
  background: none;
  padding: 0;
  color: var(--faq-text-primary);
}

.faq-content hr {
  border: none;
  border-top: 1px solid var(--faq-border);
  margin: 32px 0;
}

/* ─── Last updated ───────────────────────────────────────────────────────── */
.faq-last-updated {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--faq-border);
  font-size: 13px;
  color: var(--faq-text-muted);
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.faq-footer {
  width: 100%;
  padding: 20px 24px;
  border-top: 1px solid var(--faq-border);
  box-sizing: border-box;
}

.faq-footer__inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 24px;
}

.faq-footer__copy {
  font-size: 13px;
  color: var(--faq-text-muted);
}

.faq-footer__nav .faq-footer__links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.faq-footer__links li::before { content: none; }

.faq-footer__links a {
  font-size: 13px;
  color: var(--faq-text-muted);
  text-decoration: none;
}

.faq-footer__links a:hover {
  color: var(--faq-accent);
}

/* ─── Theme toggle (fixed bottom-right) ─────────────────────────────────── */
.faq-theme-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 8px;
  background-color: var(--faq-bg-sidebar);
  border: 1px solid var(--faq-border);
  box-shadow: var(--faq-shadow-card);
}

.faq-theme-toggle button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 5px;
  color: var(--faq-text-muted);
  transition: background-color 0.15s ease, color 0.15s ease;
  display: flex;
  align-items: center;
}

.faq-theme-toggle button:hover {
  color: var(--faq-text-primary);
  background-color: var(--faq-border);
}

.faq-theme-toggle button.active {
  color: var(--faq-accent);
  background-color: rgba(232, 108, 58, 0.1);
}

/* ─── Tablet (hide right TOC) ────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .faq-shell {
    grid-template-columns: 280px 1fr;
    grid-template-areas: "sidebar content";
  }

  /* .faq-shell--home already has this 2-col layout — no change needed */

  .faq-toc {
    display: none;
  }

  .faq-content {
    padding: 32px 36px;
    max-width: 800px;
  }
}

/* ─── Mobile (single column + hamburger) ─────────────────────────────────── */
@media (max-width: 768px) {

  /* Both shell variants collapse to single content column */
  .faq-shell,
  .faq-shell--home {
    grid-template-columns: 1fr;
    grid-template-areas: "content";
  }

  .faq-topbar__hamburger {
    display: flex;
  }

  /* Compact search button — icon only, no text */
  .faq-topbar__search-trigger {
    flex: 0 0 auto;
    padding: 0 10px;
    max-width: none;
  }

  .faq-topbar__search-trigger span {
    display: none;
  }

  .faq-topbar__search-trigger svg {
    opacity: 0.8;
  }

  .faq-topbar__logo {
    flex: 1; /* logo fills the gap left by compressed search button */
  }

  .faq-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: 320px;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    padding-top: 72px;
    padding-bottom: 40px;
    background-color: var(--faq-bg-sidebar);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .faq-sidebar.is-open {
    transform: translateX(0);
  }

  /* Overlay behind open sidebar */
  .faq-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 299;
    background: rgba(0, 0, 0, 0.5);
  }

  .faq-sidebar-overlay.is-visible {
    display: block;
  }

  /* Content fills full column width */
  .faq-content {
    padding: 24px 20px;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }

  /* Elementor containers — ensure they don't impose their own fixed widths */
  .faq-content .elementor-section,
  .faq-content .elementor-container,
  .faq-content .e-con,
  .faq-content .e-con-inner {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Scale down large headings on small screens */
  .faq-content h1 { font-size: 26px; }
  .faq-content h2 { font-size: 20px; }
  .faq-content h3 { font-size: 17px; }

  /* Theme toggle: smaller and slightly higher so it doesn't overlap content */
  .faq-theme-toggle {
    bottom: 16px;
    right: 16px;
    padding: 4px 6px;
  }
}
