/*
 * Cohabit legal page styles
 *
 * Usage:
 *   1. Load this stylesheet in the target app.
 *   2. Wrap the legal document in `.legal-page`.
 *   3. Render rich text inside `.legal-page__rich-text` using semantic HTML.
 */

@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800;900&display=swap");

.legal-page {
  --legal-blue: #0065ff;
  --legal-ink: #101010;
  --legal-copy: #171717;
  --legal-muted: #303030;
  --legal-line: #e6e6e6;
  --legal-font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;

  box-sizing: border-box;
  width: min(920px, calc(100% - 48px));
  margin: 0 auto;
  padding: 58px 0 86px;
  color: var(--legal-ink);
  font-family: var(--legal-font);
  font-feature-settings: "kern" 1;
  text-rendering: geometricPrecision;
}

.legal-page *,
.legal-page *::before,
.legal-page *::after {
  box-sizing: border-box;
}

.legal-page__hero {
  max-width: 720px;
  margin: 0 auto 54px;
  text-align: center;
}

.legal-page__eyebrow {
  margin: 0 0 12px;
  color: #6a6a6a;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
}

.legal-page__hero h1 {
  margin: 0;
  color: var(--legal-blue);
  font-size: clamp(36px, 4.2vw, 54px);
  font-weight: 500;
  line-height: 1.04;
}

.legal-page__updated {
  display: block;
  margin-top: 16px;
  color: var(--legal-muted);
  font-size: 14px;
  font-weight: 600;
}

.legal-page__description {
  max-width: 640px;
  margin: 22px auto 0;
  color: var(--legal-muted);
  font-size: 15px;
  line-height: 1.5;
}

.legal-page__content {
  display: grid;
  max-width: 760px;
  margin: 0 auto;
  gap: 58px;
  counter-reset: legal-section;
}

.legal-page__intro {
  margin: 0 0 6px;
  color: var(--legal-copy);
  font-size: 18px;
  line-height: 1.65;
}

.legal-page__intro p {
  margin: 0 0 22px;
}

.legal-page__section--numbered {
  counter-increment: legal-section;
}

.legal-page__section h2 {
  margin: 0 0 20px;
  color: var(--legal-blue);
  font-size: clamp(30px, 3vw, 40px);
  font-weight: 500;
  line-height: 1.12;
}

.legal-page__section--numbered > h2::before {
  content: counter(legal-section) ". ";
}

.legal-page__subsection {
  margin: 26px 0;
}

.legal-page__subsection h3 {
  margin: 0 0 12px;
  color: #111;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
}

.legal-page__section p,
.legal-page__section li,
.legal-page__rich-text p,
.legal-page__rich-text li {
  color: var(--legal-copy);
  font-size: 18px;
  line-height: 1.65;
}

.legal-page__section p,
.legal-page__rich-text p {
  margin: 0 0 22px;
  white-space: pre-line;
}

.legal-page__section ul,
.legal-page__section ol,
.legal-page__rich-text ul,
.legal-page__rich-text ol {
  display: grid;
  margin: 16px 0 26px;
  padding-left: 30px;
  gap: 10px;
}

/* Generate stable legal references such as 1., 1.1 and 1.1.1. */
.legal-page__rich-text ol {
  counter-reset: legal-clause;
  list-style: none;
}

.legal-page__rich-text ol > li {
  position: relative;
  counter-increment: legal-clause;
  white-space: pre-line;
}

.legal-page__rich-text ol > li::before {
  position: absolute;
  right: calc(100% + 8px);
  content: counters(legal-clause, ".");
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.legal-page__rich-text > ol > li::before {
  content: counter(legal-clause) ".";
}

.legal-page__rich-text h2 {
  margin: 58px 0 20px;
  color: var(--legal-blue);
  font-size: clamp(30px, 3vw, 40px);
  font-weight: 500;
  line-height: 1.12;
}

.legal-page__rich-text h2:first-child {
  margin-top: 0;
}

.legal-page__rich-text h3 {
  margin: 30px 0 14px;
  color: #111;
  font-size: 22px;
  line-height: 1.3;
}

.legal-page__rich-text h4 {
  margin: 24px 0 12px;
  color: #111;
  font-size: 19px;
  line-height: 1.35;
}

.legal-page__rich-text li > ul,
.legal-page__rich-text li > ol {
  margin: 10px 0 4px;
}

.legal-page__rich-text blockquote {
  margin: 28px 0;
  padding-left: 22px;
  border-left: 3px solid var(--legal-blue);
  color: var(--legal-muted);
  font-size: 18px;
  line-height: 1.65;
}

.legal-page__rich-text a {
  color: var(--legal-blue);
  text-underline-offset: 0.15em;
}

.legal-page__rich-text strong {
  font-weight: 700;
}

.legal-page .rich-text__image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 16px 0;
  object-fit: contain;
}

.legal-page .rich-text-table {
  width: 100%;
  max-width: 100%;
  margin: 16px 0;
  overflow-x: auto;
  border: 1px solid var(--legal-line);
  border-radius: 6px;
  -webkit-overflow-scrolling: touch;
}

.legal-page .rich-text-table table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  color: var(--legal-muted);
  font-size: 15px;
  line-height: 1.4;
}

.legal-page .rich-text-table caption {
  padding: 12px 14px;
  color: #111;
  font-weight: 700;
  text-align: left;
}

.legal-page .rich-text-table th,
.legal-page .rich-text-table td {
  padding: 12px 14px;
  border-top: 1px solid var(--legal-line);
  border-right: 1px solid var(--legal-line);
  text-align: left;
  vertical-align: top;
}

.legal-page .rich-text-table th {
  background: #f7f8fa;
  color: #111;
  font-weight: 700;
}

.legal-page .rich-text-table th:last-child,
.legal-page .rich-text-table td:last-child {
  border-right: 0;
}

@media (max-width: 768px) {
  .legal-page {
    width: min(calc(100% - 40px), 920px);
    padding: 48px 0 64px;
  }

  .legal-page__hero {
    margin-bottom: 46px;
  }

  .legal-page__content {
    gap: 42px;
  }

  .legal-page__section h2,
  .legal-page__rich-text h2 {
    font-size: 30px;
  }

  .legal-page__section p,
  .legal-page__intro,
  .legal-page__section li,
  .legal-page__rich-text p,
  .legal-page__rich-text li,
  .legal-page__rich-text blockquote {
    font-size: 16px;
  }

  .legal-page__subsection h3,
  .legal-page__rich-text h3 {
    font-size: 18px;
  }
}
