/* ==========================================================================
 * legal.livecircle.com — legal document styling
 *
 * Plain-CSS port of the LiveCircle app's public legal pages (app.livecircle.com/docs/*).
 * Sources it was derived from (Live-Circle-Inc/next, origin/HEAD 250837d):
 *   - src/app/layout.tsx                       body: Halyard Display via next/font, `font-sans antialiased`
 *   - src/app/docs/layout.tsx                  <main class="flex min-h-dvh flex-col bg-background-default">
 *   - src/components/docs/legal-doc-page.tsx   article / h1 / related-documents section
 *   - src/components/docs/*-document.tsx       body copy: h2 / h3 / p / ul / links / callout box
 *   - src/app/globals.css + @live-circle-inc/livecircle-design-system tokens.css (values read from
 *     the compiled production stylesheet)
 * Every Tailwind utility has been resolved to a concrete value; the original utility is noted next
 * to each declaration so the two can be kept in step. No Tailwind, no JS.
 *
 * Markup is produced by _layouts/legal-version.html, legal-history.html and home.html:
 *   <main class="legal-page">
 *     <article class="legal-doc">
 *       <h1>…</h1>
 *       <div class="legal-notice">…</div>            (optional: "not the current version")
 *       <p class="legal-doc__meta">…</p>             (effective date / version)
 *       <div class="legal-doc__body">{{ content }}</div>
 *       <section class="legal-versions">…</section>   (optional: version history)
 *       <section class="legal-related">…</section>
 *     </article>
 *   </main>
 * ========================================================================== */

/* --------------------------------------------------------------------------
 * Fonts — Halyard Display (licensed; same files the app self-hosts from
 * src/app/fonts/halyard/). Only the weights the legal pages use are declared.
 * The fallback face mirrors next/font's generated "halyardDisplay Fallback"
 * (Arial with metric overrides) so the swap causes minimal layout shift.
 * -------------------------------------------------------------------------- */
@font-face {
	font-family: "Halyard Display";
	src: url("fonts/halyard-display-regular.woff2") format("woff2");
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}
@font-face {
	font-family: "Halyard Display";
	src: url("fonts/HalyardDis-It.woff2") format("woff2");
	font-weight: 400;
	font-style: italic;
	font-display: swap;
}
@font-face {
	font-family: "Halyard Display";
	src: url("fonts/halyard-display-medium.woff2") format("woff2");
	font-weight: 500;
	font-style: normal;
	font-display: swap;
}
@font-face {
	font-family: "Halyard Display";
	src: url("fonts/halyard-display-semibold.woff2") format("woff2");
	font-weight: 600;
	font-style: normal;
	font-display: swap;
}
@font-face {
	font-family: "Halyard Display";
	src: url("fonts/halyard-display-bold.woff2") format("woff2");
	font-weight: 700;
	font-style: normal;
	font-display: swap;
}
@font-face {
	font-family: "Halyard Display Fallback";
	src: local("Arial");
	ascent-override: 118.24%;
	descent-override: 32.94%;
	line-gap-override: 0%;
	size-adjust: 91.09%;
}

/* --------------------------------------------------------------------------
 * Design tokens
 * Light is the default and the only scheme anonymous visitors see in the app
 * (deriveScheme() returns "dark" only for the signed-in contrast_dark theme,
 * and the app does not follow prefers-color-scheme). `html.dark` reproduces
 * the app's `.dark` token block for parity.
 * -------------------------------------------------------------------------- */
:root {
	/* colour roles (design-system primitives in comments) */
	--lc-color-background-default: #ffffff; /* --warm-neutral-0 */
	--lc-color-surface-elevated: #faf9f8; /* --warm-neutral-50 */
	--lc-color-border-subtle: #cdcbca; /* --warm-neutral-300 */
	--lc-color-text-primary: #120f0d; /* --warm-neutral-950 */
	--lc-color-text-tertiary: #66625f; /* --warm-neutral-650 */
	--lc-color-interactive-text: #0052cc; /* --interactive-blue-600 */

	/* typography */
	--lc-font-sans: "Halyard Display", "Halyard Display Fallback", "SF Pro Display", "SF Pro",
		system-ui, sans-serif; /* font-sans */
	--lc-weight-medium: 500; /* font-medium */
	--lc-weight-semibold: 600; /* font-semibold */
	--lc-text-xs: 0.75rem; /* 12px, line-height 1rem */
	--lc-text-sm: 0.875rem; /* 14px, line-height 1.25rem */
	--lc-text-base: 1rem; /* 16px, line-height 1.5rem */
	--lc-text-lg: 1.125rem; /* 18px, line-height 1.75rem */
	--lc-text-3xl: 1.875rem; /* 30px, line-height 2.25rem */
	--lc-leading-relaxed: 1.625; /* leading-relaxed */
	--lc-tracking-tight: -0.025em; /* tracking-tight */

	/* spacing / shape (Tailwind --spacing: 0.25rem) */
	--lc-container-2xl: 42rem; /* max-w-2xl = 672px */
	--lc-radius-md: 0.5rem; /* rounded-md = calc(--lc-radius .625rem - 2px) = 8px */
}

html.dark {
	--lc-color-background-default: #120f0d;
	--lc-color-surface-elevated: #302f2d;
	--lc-color-border-subtle: #1f1d1b;
	--lc-color-text-primary: #e8e7e6;
	--lc-color-text-tertiary: #b2b0ae;
	--lc-color-interactive-text: #3681f2;
	color-scheme: dark;
}

/* To follow the OS setting instead (the app does NOT do this), uncomment:
@media (prefers-color-scheme: dark) {
	html:not(.light) { …same values as html.dark… }
}
*/

/* --------------------------------------------------------------------------
 * Base (equivalent of Tailwind preflight for the elements we use + the app's
 * `body { bg-background-default text-text-primary }` and `font-sans antialiased`)
 * -------------------------------------------------------------------------- */
*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	line-height: 1.5; /* preflight */
	-webkit-text-size-adjust: auto; /* globals.css: honour OS font scaling */
	text-size-adjust: auto;
	tab-size: 4;
}

body {
	margin: 0;
	font-family: var(--lc-font-sans);
	background-color: var(--lc-color-background-default);
	color: var(--lc-color-text-primary);
	-webkit-font-smoothing: antialiased; /* antialiased */
	-moz-osx-font-smoothing: grayscale;
}

/* --------------------------------------------------------------------------
 * Page shell — <main class="flex min-h-dvh flex-col bg-background-default">
 * -------------------------------------------------------------------------- */
.legal-page {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	min-height: 100dvh;
	background-color: var(--lc-color-background-default);
}

/* <article class="w-full max-w-2xl mx-auto px-6 py-12 wrap-break-word"> */
.legal-doc {
	width: 100%;
	max-width: var(--lc-container-2xl); /* 672px incl. padding → 624px measure */
	margin-inline: auto;
	padding: 3rem 1.5rem; /* py-12 px-6 */
	overflow-wrap: break-word;
}

.legal-doc :where(h1, h2, h3, h4, h5, h6, p, ul, ol, blockquote, figure, table, hr) {
	margin: 0;
}

/* <h1 class="font-medium text-3xl text-text-primary tracking-tight"> */
.legal-doc h1 {
	font-size: var(--lc-text-3xl);
	line-height: 2.25rem;
	font-weight: var(--lc-weight-medium);
	letter-spacing: var(--lc-tracking-tight);
	color: var(--lc-color-text-primary);
}

/* "Last modified" line — <p class="text-text-tertiary text-xs">, the first child of the
 * document wrapper, which sits mt-8 below the title. */
.legal-doc__meta {
	margin-top: 2rem; /* mt-8 */
	font-size: var(--lc-text-xs);
	line-height: 1rem;
	color: var(--lc-color-text-tertiary);
}

/* --------------------------------------------------------------------------
 * Document body — <div class="flex flex-col gap-6 text-sm leading-relaxed text-text-tertiary">
 *
 * The app nests <section>s with flex gaps (gap-6 between top-level blocks, gap-4 inside a
 * part (h2) section, gap-2 inside a clause (h3) section). kramdown emits a flat list of
 * siblings, so the same rhythm is rebuilt with margins:
 *   intro paragraphs (before the first h2)  16px   (gap-4)
 *   intro → callout / first h2               24px   (gap-6)
 *   h2 → next block                          16px   (gap-4)
 *   between clause sections (→ h3)           16px   (gap-4)
 *   h3 → paragraphs, paragraph → paragraph    8px   (gap-2)
 * -------------------------------------------------------------------------- */
.legal-doc__body {
	margin-top: 1.5rem; /* gap-6 below the meta line */
	font-size: var(--lc-text-sm);
	line-height: var(--lc-leading-relaxed); /* 22.75px */
	color: var(--lc-color-text-tertiary);
}

/* The app's cookie-policy-document.tsx uses text-text-primary for its body; the other three
 * documents use text-text-tertiary. */
.legal-doc--cookie-policy .legal-doc__body {
	color: var(--lc-color-text-primary);
}

.legal-doc__meta + .legal-doc__body {
	margin-top: 1.5rem;
}

/* when there is no meta line, keep the title's mt-8 */
.legal-doc h1 + .legal-doc__body {
	margin-top: 2rem;
}

/* default sibling rhythm inside a clause: gap-2 */
.legal-doc__body > * + * {
	margin-top: 0.5rem;
}

/* intro block (everything before the first part heading): gap-4 */
.legal-doc__body > :not(h2 ~ *, h3 ~ *) + :not(h2, h3) {
	margin-top: 1rem;
}

/* <h2 class="font-semibold text-text-primary text-lg"> — a document part */
.legal-doc__body h2 {
	font-size: var(--lc-text-lg);
	line-height: 1.75rem;
	font-weight: var(--lc-weight-semibold);
	color: var(--lc-color-text-primary);
}

.legal-doc__body > h2 {
	margin-top: 1.5rem; /* gap-6 between parts */
}

.legal-doc__body > h2:first-child {
	margin-top: 0;
}

.legal-doc__body > h2 + * {
	margin-top: 1rem; /* gap-4 */
}

/* <h3 class="font-semibold text-text-primary"> — a numbered clause (inherits 14px / 1.625) */
.legal-doc__body h3 {
	font-size: inherit;
	line-height: inherit;
	font-weight: var(--lc-weight-semibold);
	color: var(--lc-color-text-primary);
}

.legal-doc__body > h3 {
	margin-top: 1rem; /* gap-4 between clause sections */
}

.legal-doc__body > h3:first-child {
	margin-top: 0;
}

.legal-doc__body > h3 + * {
	margin-top: 0.5rem; /* gap-2 */
}

/* h4 is not used by the app; give it the h3 treatment at a quieter weight */
.legal-doc__body h4 {
	font-size: inherit;
	line-height: inherit;
	font-weight: var(--lc-weight-medium);
	color: var(--lc-color-text-primary);
}

.legal-doc__body > h4 {
	margin-top: 1rem;
}

/* Inline emphasis. The app marks run-in labels ("Member", "Binding Arbitration.") with
 * <span class="font-medium text-text-primary">, so markdown **bold** maps to that. */
.legal-doc__body strong,
.legal-doc__body b {
	font-weight: var(--lc-weight-medium);
	color: var(--lc-color-text-primary);
}

.legal-doc__body em,
.legal-doc__body i {
	font-style: italic;
}

/* <a class="font-medium text-interactive-text underline underline-offset-2"> */
.legal-doc__body a {
	font-weight: var(--lc-weight-medium);
	color: var(--lc-color-interactive-text);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.legal-doc a:focus-visible {
	outline: 2px solid var(--lc-color-interactive-text);
	outline-offset: 2px;
	border-radius: 2px;
}

/* <ul class="flex list-disc flex-col gap-1 pl-5"> */
.legal-doc__body ul,
.legal-doc__body ol {
	padding-left: 1.25rem; /* pl-5 */
}

.legal-doc__body ul {
	list-style-type: disc;
}

/* The app writes ordered clauses as literal "a)", "b)" in a list-none <ol>; markdown ordered
 * lists get real numbering with the same indent and gap instead. */
.legal-doc__body ol {
	list-style-type: decimal;
}

.legal-doc__body li + li {
	margin-top: 0.25rem; /* gap-1 */
}

/* Lists the app spaces wider than gap-1. In markdown: `{: .legal-list-gap-2}` (or -3) on the
 * line right after the list. Only the list's own items, not nested lists. */
.legal-doc__body .legal-list-gap-2 > li + li {
	margin-top: 0.5rem; /* gap-2: terms-of-use community rules */
}

.legal-doc__body .legal-list-gap-3 > li + li {
	margin-top: 0.75rem; /* gap-3: consumer health data, section 1 */
}

/* Loose lists (blank lines between items) make kramdown wrap each item in <p>; keep them as
 * tight as the app's lists. */
.legal-doc__body li > p {
	margin-block: 0;
}

.legal-doc__body li > p + p {
	margin-top: 0.5rem;
}

/* Run-in labels at the start of a list item ("**Member** - if you have…"): the app's
 * <span class="font-medium text-text-primary">. */
.legal-doc__body li > strong:first-child,
.legal-doc__body li > p:first-child > strong:first-child {
	font-weight: var(--lc-weight-medium);
	color: var(--lc-color-text-primary);
}

/* Lists whose items carry their own literal markers ("a)", "b)", "(i)") — the app's list-none
 * <ol>. In markdown: a plain list followed by `{: .legal-lettered}`. */
.legal-doc__body .legal-lettered {
	list-style: none;
	padding-left: 0;
}

/* Small print — the app's text-xs (12px / 16px). In markdown: `{: .legal-footnote}` after a
 * paragraph. */
.legal-doc__body .legal-footnote,
.legal-footnote {
	font-size: var(--lc-text-xs);
	line-height: 1rem;
}

/* nested lists: consumer-health notice uses "mt-1 gap-1 pl-5 list-[circle]" */
.legal-doc__body li > ul,
.legal-doc__body li > ol {
	margin-top: 0.25rem;
}

.legal-doc__body li > ul {
	list-style-type: circle;
}

.legal-doc__body li > ol {
	list-style-type: lower-alpha;
}

/* Callout — HelpfulSummary / Binding Arbitration box:
 * <div class="rounded-md border border-border-subtle bg-surface-elevated p-4"><p class="text-text-primary">
 * In markdown, write it as a blockquote (> **Helpful summary:** …). */
.legal-doc__body blockquote {
	padding: 1rem; /* p-4 */
	border: 1px solid var(--lc-color-border-subtle);
	border-radius: var(--lc-radius-md);
	background-color: var(--lc-color-surface-elevated);
	color: var(--lc-color-text-primary);
}

.legal-doc__body blockquote > * + * {
	margin-top: 0.5rem;
}

/* a callout that closes the intro block sits at the top-level gap-6 */
.legal-doc__body > blockquote:not(h2 ~ *, h3 ~ *) {
	margin-top: 1.5rem;
}

/* Horizontal rule — same hairline as the related-documents divider */
.legal-doc__body hr {
	height: 0;
	border: 0;
	border-top: 1px solid var(--lc-color-border-subtle);
	margin-block: 1.5rem;
}

/* Tables (no app precedent; built from the same tokens). kramdown does not wrap tables, so the
 * table itself scrolls horizontally on narrow screens instead of overflowing the page. */
.legal-doc__body table {
	display: block;
	max-width: 100%;
	width: max-content;
	overflow-x: auto;
	border-collapse: collapse;
	border: 1px solid var(--lc-color-border-subtle);
	border-radius: var(--lc-radius-md);
}

.legal-doc__body > table {
	margin-top: 0.5rem;
}

.legal-doc__body th,
.legal-doc__body td {
	padding: 0.5rem 0.75rem;
	text-align: left;
	vertical-align: top;
	border-bottom: 1px solid var(--lc-color-border-subtle);
}

.legal-doc__body tr > * + * {
	border-left: 1px solid var(--lc-color-border-subtle);
}

.legal-doc__body tbody tr:last-child > * {
	border-bottom: 0;
}

.legal-doc__body th {
	font-weight: var(--lc-weight-medium);
	color: var(--lc-color-text-primary);
	background-color: var(--lc-color-surface-elevated);
}

.legal-doc__body code {
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 0.9em;
	color: var(--lc-color-text-primary);
}

/* --------------------------------------------------------------------------
 * "Not the current version" notice — reuses the callout box so it reads as part of the same
 * family. Placed between the title and the meta line.
 * -------------------------------------------------------------------------- */
.legal-notice {
	margin-top: 1.5rem;
	padding: 1rem;
	border: 1px solid var(--lc-color-border-subtle);
	border-radius: var(--lc-radius-md);
	background-color: var(--lc-color-surface-elevated);
	font-size: var(--lc-text-sm);
	line-height: var(--lc-leading-relaxed);
	color: var(--lc-color-text-primary);
}

.legal-notice strong {
	font-weight: var(--lc-weight-medium);
}

.legal-notice a {
	font-weight: var(--lc-weight-medium);
	color: var(--lc-color-interactive-text);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.legal-notice + .legal-doc__meta {
	margin-top: 1.5rem;
}

/* --------------------------------------------------------------------------
 * Related documents — <section class="mt-12 border-border-subtle border-t pt-8">
 * Lives outside the text-sm body, so it inherits 16px / 1.5 from the page.
 * .legal-versions (version history) shares the same frame.
 * -------------------------------------------------------------------------- */
.legal-related,
.legal-versions {
	margin-top: 3rem; /* mt-12 */
	padding-top: 2rem; /* pt-8 */
	border-top: 1px solid var(--lc-color-border-subtle);
}

/* consecutive sections share one divider rhythm */
.legal-versions + .legal-related {
	margin-top: 2rem;
}

/* <h2 class="font-medium text-text-primary text-lg"> */
.legal-related h2,
.legal-versions h2 {
	margin: 0;
	font-size: var(--lc-text-lg);
	line-height: 1.75rem;
	font-weight: var(--lc-weight-medium);
	color: var(--lc-color-text-primary);
}

/* <ul class="mt-4 flex flex-col gap-2"> */
.legal-related ul,
.legal-versions ol,
.legal-versions ul {
	margin: 1rem 0 0;
	padding: 0;
	list-style: none;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

/* <a class="text-interactive-text underline underline-offset-4"> */
.legal-related a,
.legal-versions a {
	color: var(--lc-color-interactive-text);
	text-decoration: underline;
	text-underline-offset: 4px;
}

/* Version history rows: date link · "Current" badge, then the one-line change summary */
.legal-versions li {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	column-gap: 0.5rem;
}

.legal-versions__summary {
	flex-basis: 100%;
	font-size: var(--lc-text-sm);
	line-height: 1.25rem;
	color: var(--lc-color-text-tertiary);
}

.legal-versions [aria-current="page"] {
	color: var(--lc-color-text-primary);
	font-weight: var(--lc-weight-medium);
	text-decoration: none;
}

.legal-versions__badge {
	display: inline-block;
	padding: 0 0.5rem;
	border: 1px solid var(--lc-color-border-subtle);
	border-radius: 9999px;
	background-color: var(--lc-color-surface-elevated);
	font-size: var(--lc-text-xs);
	line-height: 1.125rem;
	font-weight: var(--lc-weight-medium);
	color: var(--lc-color-text-tertiary);
}

/* Version history page: the list is the page's content, so it opens without the divider. */
.legal-versions--page {
	margin-top: 2rem;
	padding-top: 0;
	border-top: 0;
}

.legal-versions__intro {
	margin: 0.5rem 0 0;
	font-size: var(--lc-text-sm);
	line-height: 1.25rem;
	color: var(--lc-color-text-tertiary);
}

.legal-versions--page li + li {
	margin-top: 0.75rem;
}

.legal-versions__iso {
	font-size: var(--lc-text-xs);
	line-height: 1rem;
	color: var(--lc-color-text-tertiary);
	font-variant-numeric: tabular-nums;
}

.legal-versions__badge--current {
	border-color: var(--lc-color-text-tertiary);
	color: var(--lc-color-text-primary);
}

.legal-versions__links,
.legal-versions__more {
	flex-basis: 100%;
	font-size: var(--lc-text-xs);
	line-height: 1rem;
	color: var(--lc-color-text-tertiary);
}

.legal-versions__more {
	margin: 1rem 0 0;
}

.legal-doc__meta a {
	color: var(--lc-color-interactive-text);
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* --------------------------------------------------------------------------
 * Home page document list
 * -------------------------------------------------------------------------- */
.legal-index {
	margin: 2rem 0 0;
	padding: 0;
	list-style: none;
}

.legal-index > li + li {
	margin-top: 1.5rem;
	padding-top: 1.5rem;
	border-top: 1px solid var(--lc-color-border-subtle);
}

.legal-index h2 {
	margin: 0;
	font-size: var(--lc-text-lg);
	line-height: 1.75rem;
	font-weight: var(--lc-weight-medium);
}

.legal-index a {
	color: var(--lc-color-interactive-text);
	text-decoration: underline;
	text-underline-offset: 4px;
}

.legal-index p {
	margin: 0.25rem 0 0;
	font-size: var(--lc-text-sm);
	line-height: var(--lc-leading-relaxed);
	color: var(--lc-color-text-tertiary);
}

.legal-index .legal-index__meta {
	font-size: var(--lc-text-xs);
	line-height: 1rem;
	margin-top: 0.5rem;
}

.legal-index__meta a {
	text-underline-offset: 2px;
}

/* --------------------------------------------------------------------------
 * Print — legal pages get printed; drop chrome colours and show link targets.
 * -------------------------------------------------------------------------- */
@media print {
	.legal-page,
	body {
		background: #fff;
	}
	.legal-doc {
		max-width: none;
		padding: 0;
	}
	.legal-doc__body a[href^="http"]::after {
		content: " (" attr(href) ")";
		font-weight: 400;
		color: var(--lc-color-text-tertiary);
	}
	.legal-versions {
		display: none;
	}
}
