/* Legal document styles (/privacy-policy/, /terms-of-service/) — layered on top
   of ../style.css, sharing its CSS custom properties. Scoped so the landing page
   and portal are unaffected: layout overrides hang off body.legal-body, the same
   idiom admin.css uses.

   No web fonts and no external assets of any kind. A privacy policy that states
   "no third-party trackers" must not itself make a third-party request. */

/* --- Page frame ----------------------------------------------------------- */

body.legal-body {
  /* style.css centers the landing card both ways; a document flows from the top
     and its bands (header, footer) span the full viewport width. */
  justify-content: flex-start;
  align-items: stretch;
  background:
    radial-gradient(58rem 28rem at 50% -14rem, rgba(99, 102, 241, 0.18), transparent 70%),
    var(--color-bg);
}

/* Smooth anchor jumps, but only where the reader hasn't asked for less motion.
   Scoped via :has() so the rest of the site keeps the default behavior. */
@media (prefers-reduced-motion: no-preference) {
  :root:has(body.legal-body) {
    scroll-behavior: smooth;
  }
}

.legal-body a:focus-visible,
.legal-body summary:focus-visible {
  outline: 2px solid var(--color-accent-hover);
  outline-offset: 3px;
  border-radius: 4px;
}

/* --- Sticky masthead ------------------------------------------------------ */

.legal-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--color-border);
  background: rgba(15, 17, 23, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.legal-header-inner {
  max-width: 74rem;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.legal-header-brand {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.legal-header-brand:hover {
  color: var(--color-accent-hover);
}

.legal-chip {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  padding: 0.2rem 0.6rem;
}

.legal-header-spacer {
  flex: 1;
}

.legal-header-link {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.legal-header-link:hover {
  color: var(--color-accent-hover);
}

/* --- Title block ---------------------------------------------------------- */

.legal-page {
  width: 100%;
  max-width: 74rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.legal-hero {
  padding: 4rem 0 2.75rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 3rem;
}

.legal-eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--color-accent-hover);
  margin-bottom: 0.85rem;
}

.legal-hero h1 {
  font-size: clamp(2.1rem, 6vw, 3.1rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.08;
  margin-bottom: 1.1rem;
}

.legal-lede {
  font-size: 1.08rem;
  line-height: 1.65;
  color: var(--color-text-muted);
  max-width: 44rem;
  margin-bottom: 1.5rem;
}

.legal-meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* --- Two-column layout: contents rail + document -------------------------- */

.legal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.5rem;
  padding-bottom: 5rem;
}

@media (min-width: 62rem) {
  .legal-layout {
    grid-template-columns: 16rem minmax(0, 1fr);
    gap: 4rem;
    align-items: start;
  }

  .legal-aside {
    position: sticky;
    top: 5.25rem;
    max-height: calc(100vh - 7.5rem);
    overflow-y: auto;
  }
}

/* --- Table of contents ---------------------------------------------------- */

.legal-toc {
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-surface);
}

.legal-toc > summary {
  cursor: pointer;
  padding: 0.9rem 1rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.legal-toc > summary::-webkit-details-marker {
  display: none;
}

.legal-toc > summary::after {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translate(-0.1rem, -0.1rem);
  transition: transform 0.15s ease;
}

.legal-toc[open] > summary::after {
  transform: rotate(-135deg) translate(-0.15rem, -0.15rem);
}

.legal-toc ol {
  list-style: none;
  margin: 0;
  padding: 0 0.5rem 0.6rem;
  counter-reset: toc;
}

.legal-toc li {
  counter-increment: toc;
  margin: 0;
}

.legal-toc a {
  display: flex;
  gap: 0.55rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--color-text-muted);
}

.legal-toc a::before {
  content: counter(toc);
  min-width: 1.15rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.55;
}

.legal-toc a:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--color-text);
}

.legal-toc a.is-active {
  background: rgba(99, 102, 241, 0.16);
  color: var(--color-accent-hover);
  font-weight: 600;
}

.legal-toc a.is-active::before {
  opacity: 1;
}

/* --- Document prose ------------------------------------------------------- */

.legal-doc {
  max-width: 44rem;
  text-align: left;
}

.legal-doc section {
  scroll-margin-top: 5.5rem;
}

.legal-doc section + section {
  margin-top: 3rem;
  padding-top: 3rem;
  border-top: 1px solid var(--color-border);
}

.legal-doc h2 {
  font-size: 1.45rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 1.25rem;
}

.legal-num {
  color: var(--color-accent-hover);
  font-variant-numeric: tabular-nums;
  margin-right: 0.55rem;
  font-weight: 700;
}

.legal-anchor {
  margin-left: 0.5rem;
  font-size: 0.75em;
  font-weight: 400;
  color: var(--color-text-muted);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.legal-doc h2:hover .legal-anchor,
.legal-anchor:focus-visible {
  opacity: 1;
}

.legal-doc h3 {
  font-size: 1.02rem;
  font-weight: 650;
  margin-top: 2rem;
  margin-bottom: 0.65rem;
}

.legal-doc p,
.legal-doc li {
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.legal-doc p {
  margin-bottom: 1.15rem;
}

.legal-doc ul,
.legal-doc ol {
  padding-left: 1.4rem;
  margin-bottom: 1.35rem;
}

.legal-doc li {
  margin-bottom: 0.65rem;
}

.legal-doc li::marker {
  color: var(--color-accent);
}

.legal-doc strong {
  color: #fff;
  font-weight: 650;
}

.legal-doc a {
  text-decoration: underline;
  text-underline-offset: 0.2em;
  text-decoration-color: rgba(99, 102, 241, 0.45);
}

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

/* --- Callout — used for the "not end-to-end encrypted" disclosure ---------- */

.legal-note {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-left: 3px solid var(--color-accent);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin: 1.75rem 0;
}

.legal-note-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-accent-hover);
  margin-bottom: 0.6rem;
}

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

/* --- Unfilled placeholders ------------------------------------------------ */

/* Deliberately loud: an entity name or governing-state left unfilled must be
   impossible to miss on the rendered page, not just greppable in the source. */
.legal-todo {
  display: inline-block;
  padding: 0.05em 0.5em;
  border: 1px dashed rgba(99, 102, 241, 0.65);
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.12);
  color: var(--color-accent-hover);
  font-size: 0.92em;
  font-weight: 600;
}

/* --- Tables --------------------------------------------------------------- */

.legal-table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--color-border);
  border-radius: 12px;
}

.legal-doc table {
  width: 100%;
  min-width: 33rem;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.legal-doc th,
.legal-doc td {
  padding: 0.85rem 1rem;
  text-align: left;
  vertical-align: top;
  line-height: 1.55;
  border-bottom: 1px solid var(--color-border);
}

.legal-doc th {
  background: var(--color-surface);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.legal-doc tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.018);
}

.legal-doc tbody tr:last-child td {
  border-bottom: none;
}

/* --- Footer --------------------------------------------------------------- */

.legal-footer {
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  background: rgba(26, 29, 39, 0.45);
}

.legal-footer-inner {
  max-width: 74rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 2.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.legal-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

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

@media print {
  body.legal-body {
    display: block;
    background: #fff;
    color: #000;
  }

  .legal-header,
  .legal-aside,
  .legal-anchor,
  .legal-footer-links {
    display: none;
  }

  .legal-page,
  .legal-doc {
    max-width: none;
    padding: 0;
  }

  .legal-hero {
    padding-top: 0;
  }

  .legal-doc a {
    color: #000;
    text-decoration: underline;
  }

  .legal-doc strong {
    color: #000;
  }

  .legal-eyebrow,
  .legal-num,
  .legal-note-label,
  .legal-todo {
    color: #000;
  }

  .legal-note,
  .legal-todo {
    background: none;
    border-color: #000;
  }

  .legal-doc section + section {
    border-color: #ccc;
    page-break-before: auto;
  }

  .legal-doc h2,
  .legal-doc h3 {
    page-break-after: avoid;
  }
}
