/* ============================================
   Legal pages: privacy, terms, cookies,
   community guidelines. Loaded after styles.css.
   Phone first; the contents become a sticky
   rail at 1100px.
   ============================================ */

.legal {
  padding: 16px 0 72px;
}

.legal-grid {
  max-width: 760px;
}

/* ---------- Sibling documents ---------- */

.legal-docs {
  margin: 0 calc(var(--gutter) * -1);
  overflow-x: auto;
  scrollbar-width: none;
}

.legal-docs::-webkit-scrollbar {
  display: none;
}

.legal-docs ul {
  display: flex;
  gap: 8px;
  width: max-content;
  padding: 4px var(--gutter);
}

.legal-docs a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 16px;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.legal-docs a:hover {
  color: var(--ink);
  border-color: var(--ink-soft);
}

.legal-docs a[aria-current="page"] {
  color: var(--badge-ink);
  background-color: var(--badge);
  border-color: var(--badge);
}

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

.legal-head {
  padding: 40px 0 32px;
}

.legal-title {
  font-family: var(--font-display);
  font-size: clamp(2.75rem, 12vw, 4.25rem);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.legal-lead {
  margin-top: 20px;
  max-width: 52ch;
  font-size: 1.125rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  margin-top: 24px;
  font-size: 0.875rem;
  color: var(--ink-soft);
}

.legal-meta strong {
  font-weight: 600;
  color: var(--ink);
}

.legal-meta a {
  color: var(--accent);
}

/* ---------- The short version ---------- */

.legal-summary {
  padding: 24px;
  background-color: var(--surface);
  border-radius: var(--radius-panel);
}

.legal-summary-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.legal-summary ul {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.legal-summary li {
  position: relative;
  padding-left: 22px;
  line-height: 1.55;
}

.legal-summary li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.62em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
}

.legal-summary-note {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

/* ---------- Contents ---------- */

.legal-toc {
  margin-top: 40px;
}

.legal-toc-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.legal-toc ol {
  list-style: none;
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

.legal-toc a {
  display: grid;
  grid-template-columns: 2.25em 1fr;
  gap: 4px;
  padding: 11px 0;
  font-size: 0.9375rem;
  line-height: 1.4;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.legal-toc-num {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ---------- Document body ---------- */

.legal-body {
  margin-top: 16px;
  font-size: 1.0625rem;
  line-height: 1.7;
}

.legal-intro {
  padding-top: 40px;
}

.legal-section {
  padding-top: 56px;
  scroll-margin-top: 72px;
}

.legal-body h2 {
  display: flex;
  align-items: baseline;
  gap: 0.4em;
  margin-bottom: 20px;
  font-family: var(--font-display);
  font-size: 1.875rem;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.legal-num {
  flex: 0 0 auto;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.legal-anchor {
  margin-left: 0.15em;
  font-family: var(--font);
  font-size: 0.6em;
  color: var(--ink-soft);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

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

.legal-body h3 {
  margin: 32px 0 10px;
  font-size: 1.1875rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.legal-body h4 {
  margin: 24px 0 8px;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

.legal-body p,
.legal-body ul,
.legal-body ol {
  max-width: 66ch;
  margin-bottom: 16px;
}

.legal-body ul,
.legal-body ol {
  padding-left: 1.25em;
}

.legal-body ul {
  list-style: disc;
}

.legal-body li {
  margin-bottom: 8px;
  padding-left: 0.25em;
}

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

.legal-body strong {
  font-weight: 600;
}

.legal-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.legal-callout {
  max-width: 66ch;
  margin: 20px 0 24px;
  padding: 20px 24px;
  background-color: var(--surface);
  border-radius: var(--radius-panel);
}

.legal-callout > :last-child {
  margin-bottom: 0;
}

.legal-closing {
  margin-top: 56px;
  padding: 28px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
}

.legal-closing p {
  margin-bottom: 12px;
}

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

.legal-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  font-size: 0.875rem;
  color: var(--ink-soft);
}

.legal-top {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 20px;
  font-weight: 600;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
}

/* ---------- Phone: section bar ----------
   Fixed to the top once the contents list has
   scrolled away. Layer 40, under the getbar's 50. */

.legal-bar {
  position: fixed;
  z-index: 40;
  top: 0;
  left: 0;
  right: 0;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  transform: translateY(-110%);
  visibility: hidden;
  transition: transform 0.35s var(--ease), visibility 0s 0.35s;
}

.legal-bar--shown {
  transform: none;
  visibility: visible;
  transition: transform 0.35s var(--ease);
}

.legal-bar-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 6px 16px;
  font: inherit;
  text-align: left;
  color: var(--ink);
  background-color: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  box-shadow: 0 10px 28px rgba(var(--shadow), 0.14);
  cursor: pointer;
}

.legal-bar-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.legal-bar-label {
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.legal-bar-current {
  overflow: hidden;
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.legal-bar-chevron {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  margin-top: -4px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.25s var(--ease);
}

.legal-bar-btn[aria-expanded="true"] .legal-bar-chevron {
  margin-top: 4px;
  transform: rotate(225deg);
}

.legal-bar-panel {
  max-height: min(64vh, 520px);
  margin-top: 8px;
  padding: 4px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background-color: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow: 0 16px 40px rgba(var(--shadow), 0.18);
}

.legal-bar-panel ol {
  list-style: none;
}

.legal-bar-panel li + li a {
  border-top: 1px solid var(--line);
}

.legal-bar-panel a {
  display: grid;
  grid-template-columns: 2.25em 1fr;
  gap: 4px;
  padding: 11px 0;
  font-size: 0.9375rem;
  line-height: 1.4;
}

.legal-bar-panel a[aria-current="true"] {
  font-weight: 600;
}

/* ---------- Wider screens ---------- */

@media (min-width: 768px) {
  .legal {
    padding-top: 24px;
  }

  .legal-docs {
    margin: 0;
    overflow: visible;
  }

  .legal-docs ul {
    flex-wrap: wrap;
    width: auto;
    padding: 0;
  }

  .legal-head {
    padding: 56px 0 40px;
  }

  .legal-summary {
    padding: 32px 36px;
  }

  .legal-body h2 {
    font-size: 2.25rem;
  }

  .legal-closing {
    padding: 32px 36px;
  }
}

/* The contents leave the column and become a
   sticky rail; the phone bar is retired. */
@media (min-width: 1100px) {
  .legal-grid {
    display: grid;
    grid-template-columns: 220px minmax(0, 700px);
    column-gap: 80px;
    justify-content: center;
    max-width: 1120px;
  }

  .legal-grid > * {
    grid-column: 2;
  }

  .legal-grid > .legal-toc {
    grid-column: 1;
    grid-row: 3 / span 2;
    align-self: start;
    position: sticky;
    top: 32px;
    max-height: calc(100vh - 64px);
    margin-top: 0;
    overflow-y: auto;
    scrollbar-width: none;
  }

  .legal-toc ol {
    border-top: 0;
  }

  .legal-toc a {
    padding: 7px 0 7px 14px;
    font-size: 0.875rem;
    color: var(--ink-soft);
    border-bottom: 0;
    border-left: 2px solid var(--line);
    transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
  }

  .legal-toc a:hover {
    color: var(--ink);
  }

  .legal-toc a[aria-current="true"] {
    color: var(--ink);
    font-weight: 600;
    border-left-color: var(--accent);
  }

  .legal-bar {
    display: none;
  }
}
