/* ================================================================
   terms&policy.css — legal page
   ================================================================
   This page intentionally uses NO card backgrounds, NO borders,
   NO shadows. Per prompt.md: "some sections do not need backgrounds
   mostly the privacy & terms page."

   Plain text on the page background. Structure comes from generous
   spacing and a subtle inset line at the top of each section.
   Colored text limited to warning callouts and the accent on h3.
   ================================================================ */

.legal-doc {
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
}

/* ----------------------------------------------------------------
   Page headline
   ---------------------------------------------------------------- */

.legal-doc .page-headline {
  margin: 0;
}

.legal-doc .page-headline h1 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: var(--leading-tight);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}

.legal-doc .page-headline h1 svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .legal-doc .page-headline h1 {
    font-size: var(--text-2xl);
  }
}

/* ----------------------------------------------------------------
   Last-updated banner — text only, no chrome
   ---------------------------------------------------------------- */

.legal-banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0;
  background: transparent;
  border: none;
}

.legal-banner > svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
  flex-shrink: 0;
}

.legal-banner-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.legal-banner-title {
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.legal-banner-meta {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.legal-banner-meta span {
  color: var(--text-primary);
  font-weight: var(--weight-medium);
}

/* ----------------------------------------------------------------
   TOC — plain text between two inset lines
   ---------------------------------------------------------------- */

.legal-toc {
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
  box-shadow:
    inset 0 1px 0 var(--divider),
    inset 0 -1px 0 var(--divider);
}

.legal-toc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.legal-toc-title {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.legal-toc-title svg {
  width: 12px;
  height: 12px;
  color: var(--accent);
}

.legal-toc-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-1) var(--space-2);
  min-height: 26px;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition:
    color var(--duration-fast) var(--ease),
    background-color var(--duration-fast) var(--ease);
}

.legal-toc-toggle:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.legal-toc-toggle svg {
  width: 10px;
  height: 10px;
  transition: transform var(--duration-base) var(--ease);
}

.legal-toc-toggle[aria-expanded="false"] svg {
  transform: rotate(180deg);
}

.legal-toc-body {
  padding-top: var(--space-2);
  max-height: 480px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--divider-strong) transparent;
}

.legal-toc-body[hidden] {
  display: none;
}

.legal-toc-list,
.legal-toc-sublist {
  margin: 0;
  padding: 0;
  list-style: none;
}

.legal-toc-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

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

.legal-toc-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 2px 4px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  text-decoration: none;
  transition:
    color var(--duration-fast) var(--ease),
    background-color var(--duration-fast) var(--ease);
}

.legal-toc-link:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.legal-toc-link.is-active {
  color: var(--accent);
  font-weight: var(--weight-medium);
}

.legal-toc-list > li > .legal-toc-link {
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.legal-toc-list > li > .legal-toc-link.is-active {
  color: var(--accent);
}

.legal-toc-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  flex-shrink: 0;
}

.legal-toc-list > li > .legal-toc-link .legal-toc-num {
  color: var(--accent);
}

.legal-toc-sublist {
  padding-left: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 0;
}

.legal-toc-sublist .legal-toc-link {
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: 1px 4px;
}

.legal-toc-sublist .legal-toc-link:hover {
  color: var(--text-primary);
}

.legal-toc-sublist .legal-toc-link.is-active {
  color: var(--accent);
}

/* ----------------------------------------------------------------
   Card — structural wrapper only, no surface, no border
   ---------------------------------------------------------------- */

.legal-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding-top: var(--space-4);
  margin-top: var(--space-2);
  scroll-margin-top: 90px;
  box-shadow: inset 0 1px 0 var(--divider);
}

.legal-card:first-of-type {
  box-shadow: none;
  padding-top: 0;
  margin-top: 0;
}

.legal-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.legal-card-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: var(--leading-snug);
  margin: 0;
}

@media (min-width: 768px) {
  .legal-card-title {
    font-size: var(--text-xl);
  }
}

.legal-card h3 {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin: var(--space-3) 0 var(--space-1);
  line-height: var(--leading-snug);
  scroll-margin-top: 90px;
}

.legal-card h3:first-of-type {
  margin-top: 0;
}

/* Body text */
.legal-card p {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
  max-width: 72ch;
}

.legal-card p:last-child {
  margin-bottom: 0;
}

.legal-card strong {
  color: var(--text-primary);
  font-weight: var(--weight-semibold);
}

.legal-card ul,
.legal-card ol {
  margin: 0 0 var(--space-2);
  padding-left: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 72ch;
  list-style: disc;
}

.legal-card ol {
  list-style: decimal;
}

.legal-card li {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

.legal-card li strong {
  color: var(--text-primary);
}

.legal-card code {
  font-family: var(--font-sans);
  font-size: 0.85em;
  padding: 1px 5px;
  background: var(--bg-elevated);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1, 'zero' 1;
}

.legal-card a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--accent-subtle);
  transition: text-decoration-color var(--duration-fast) var(--ease);
}

.legal-card a:hover {
  text-decoration-color: var(--accent);
}

/* ----------------------------------------------------------------
   Definitions — indented, accent rail, no background
   ---------------------------------------------------------------- */

.legal-definitions {
  margin: 0 0 var(--space-2);
  padding: 0 0 0 var(--space-3);
  box-shadow: inset 3px 0 0 0 var(--accent-subtle);
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 72ch;
}

.legal-definitions dt {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin: 0;
}

.legal-definitions dd {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

.legal-definitions dd:last-child {
  margin-bottom: 0;
}

/* ----------------------------------------------------------------
   Warning callouts — colored inline text
   ---------------------------------------------------------------- */

.legal-warning {
  display: inline-block;
  font-size: 0.85em;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--warning);
  margin-right: 6px;
}

/* ----------------------------------------------------------------
   Back to top
   ---------------------------------------------------------------- */

.legal-back-to-top {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  flex-shrink: 0;
  transition:
    background-color var(--duration-fast) var(--ease),
    color var(--duration-fast) var(--ease);
}

.legal-back-to-top:hover {
  background: var(--bg-elevated);
  color: var(--accent);
}

.legal-back-to-top svg {
  width: 12px;
  height: 12px;
}

/* ----------------------------------------------------------------
   Acknowledgment banner — accent rail, no background
   ---------------------------------------------------------------- */

.legal-ack {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) 0 var(--space-2) var(--space-3);
  margin-top: var(--space-4);
  box-shadow: inset 3px 0 0 0 var(--warning);
}

.legal-ack-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--warning);
  flex-shrink: 0;
}

.legal-ack-icon svg {
  width: 16px;
  height: 16px;
}

.legal-ack-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.legal-ack-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--warning);
}

.legal-ack-text {
  margin: 0;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

/* ----------------------------------------------------------------
   Top anchor
   ---------------------------------------------------------------- */

.legal-doc #top {
  scroll-margin-top: 90px;
}

/* ----------------------------------------------------------------
   Responsive
   ---------------------------------------------------------------- */

@media (max-width: 640px) {
  .legal-card-title {
    font-size: var(--text-md);
  }

  .legal-card h3 {
    font-size: var(--text-2xs);
    margin-top: var(--space-2);
  }

  .legal-card p,
  .legal-card li,
  .legal-definitions dt,
  .legal-definitions dd,
  .legal-ack-text {
    font-size: var(--text-xs);
  }

  .legal-toc-body {
    max-height: 360px;
  }
}

/* ----------------------------------------------------------------
   Print
   ---------------------------------------------------------------- */

@media print {
  .sidebar,
  .app-header,
  .legal-toc,
  .legal-banner,
  .legal-back-to-top,
  .legal-ack-icon,
  .legal-public-bar,
  .page-headline {
    display: none !important;
  }

  .legal-doc {
    max-width: 100% !important;
  }

  .legal-card {
    box-shadow: inset 0 1px 0 #000 !important;
    page-break-inside: avoid;
  }

  .legal-card:first-of-type {
    box-shadow: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .legal-card p,
  .legal-card li,
  .legal-card strong,
  .legal-card h3,
  .legal-card-title,
  .legal-card a,
  .legal-definitions dt,
  .legal-definitions dd,
  .legal-warning,
  .legal-ack-title,
  .legal-ack-text {
    color: #000000 !important;
  }

  .legal-definitions {
    box-shadow: none !important;
    border-left: 2px solid #000 !important;
  }

  .legal-ack {
    box-shadow: none !important;
    border-left: 2px solid #000 !important;
  }
}

/* ----------------------------------------------------------------
   Reduced motion
   ---------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .legal-toc-toggle,
  .legal-toc-toggle svg,
  .legal-toc-link,
  .legal-card a,
  .legal-back-to-top {
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto !important;
  }
}