/* Standalone legal pages (terms.php, privacy_policy.php).
 * Uses the site's --sb-* theme tokens (assets/css/sb_theme.css) so light/
 * dark mode works the same way it does everywhere else — no page-specific
 * theme logic beyond the no-FOUC cookie read in includes/legal/legal_head.php. */

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--sb-bg);
  color: var(--sb-text);
  font-family: Segoe UI Historic, Segoe UI, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

a {
  color: var(--sb-accent);
}

/* ── Top bar ─────────────────────────────────────────────────────────── */

.legal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--sb-surface);
  border-bottom: 1px solid var(--sb-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.legal-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  color: var(--sb-text);
  text-decoration: none;
}

.legal-brand img {
  height: 28px;
  width: 28px;
  border-radius: 8px;
}

.legal-topbar-links {
  display: flex;
  gap: 20px;
  font-size: 14px;
}

.legal-topbar-links a {
  color: var(--sb-text-muted);
  text-decoration: none;
}

.legal-topbar-links a:hover,
.legal-topbar-links a.is-active {
  color: var(--sb-accent);
}

/* ── Shell layout ────────────────────────────────────────────────────── */

.legal-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 40px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ── Sidebar: search + TOC ───────────────────────────────────────────── */

.legal-sidebar {
  position: sticky;
  top: 76px;
  align-self: start;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}

.legal-search {
  position: relative;
  margin-bottom: 16px;
}

.legal-search i.feather-search {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--sb-text-muted);
  font-size: 14px;
  pointer-events: none;
}

.legal-search input {
  width: 100%;
  box-sizing: border-box;
  height: 40px;
  padding: 0 36px 0 34px;
  border-radius: 8px;
  border: 1px solid var(--sb-border);
  background: var(--sb-surface);
  color: var(--sb-text);
  font-size: 13px;
}

.legal-search input::placeholder {
  color: var(--sb-text-muted);
}

.legal-search input:focus {
  outline: none;
  border-color: var(--sb-accent);
  box-shadow: 0 0 0 3px rgba(0,115,183,.15);
}

.legal-search-count {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--sb-text-muted);
  pointer-events: none;
}

.legal-toc {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legal-toc a {
  display: block;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--sb-text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  white-space: normal;
}

.legal-toc a:hover {
  color: var(--sb-text);
  background: var(--sb-bg);
}

.legal-toc a.is-active {
  color: var(--sb-accent);
  border-left-color: var(--sb-accent);
  background: var(--sb-bg);
  font-weight: 600;
}

.legal-toc a.is-hidden {
  display: none;
}

/* ── Main content ────────────────────────────────────────────────────── */

.legal-main {
  min-width: 0;
}

.legal-header {
  margin-bottom: 8px;
}

.legal-header h1 {
  margin: 0 0 6px;
  font-size: 30px;
  font-weight: 700;
  color: var(--sb-text);
}

.legal-updated {
  margin: 0 0 24px;
  font-size: 13px;
  color: var(--sb-text-muted);
}

.legal-content {
  background: var(--sb-surface);
  border: 1px solid var(--sb-border);
  border-radius: 14px;
  box-shadow: var(--sb-shadow);
  padding: 36px 40px;
}

.legal-content h2 {
  margin: 40px 0 14px;
  font-size: 20px;
  font-weight: 700;
  color: var(--sb-text);
  scroll-margin-top: 90px;
}

.legal-content section:first-of-type h2 {
  margin-top: 0;
}

.legal-content h3 {
  margin: 22px 0 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--sb-text);
  scroll-margin-top: 90px;
}

.legal-content p {
  margin: 0 0 14px;
  color: var(--sb-text);
}

.legal-content ul,
.legal-content ol {
  margin: 0 0 14px;
  padding-left: 22px;
  color: var(--sb-text);
}

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

.legal-content strong {
  color: var(--sb-text);
}

.legal-content .legal-caps {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .01em;
}

.legal-content hr {
  border: none;
  border-top: 1px solid var(--sb-border);
  margin: 28px 0;
}

.legal-content section + section {
  border-top: 1px solid var(--sb-border);
  padding-top: 8px;
}

.legal-content mark {
  background: #ffe58a;
  color: #3a2e00;
  border-radius: 3px;
  padding: 0 2px;
}

.legal-content mark.is-current {
  background: var(--sb-accent);
  color: #ffffff;
}

.legal-content section.is-search-hidden {
  display: none;
}

.legal-footer {
  margin-top: 24px;
  font-size: 13px;
  color: var(--sb-text-muted);
  text-align: center;
}

/* ── Back to top ─────────────────────────────────────────────────────── */

.legal-back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--sb-border);
  background: var(--sb-surface);
  color: var(--sb-text-muted);
  box-shadow: var(--sb-shadow);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  z-index: 20;
}

.legal-back-to-top:hover {
  color: var(--sb-accent);
  border-color: var(--sb-accent);
}

.legal-back-to-top.is-visible {
  display: flex;
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .legal-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }
  .legal-sidebar {
    position: static;
    max-height: none;
    order: -1;
  }
  .legal-toc {
    display: none;
  }
  .legal-content {
    padding: 24px;
  }
}

@media (max-width: 600px) {
  .legal-topbar-links {
    gap: 12px;
    font-size: 13px;
  }
  .legal-content {
    padding: 20px 16px;
  }
  .legal-header h1 {
    font-size: 24px;
  }
}

/* ── Print ───────────────────────────────────────────────────────────── */

@media print {
  .legal-topbar,
  .legal-sidebar,
  .legal-back-to-top {
    display: none !important;
  }
  .legal-shell {
    display: block;
    max-width: none;
    padding: 0;
  }
  .legal-content {
    box-shadow: none;
    border: none;
  }
}
