/* ─────────────────────────────────────────────────────────────────────
   SkinLogic legal pages — shared stylesheet
   ─────────────────────────────────────────────────────────────────────
   Loaded by /legal/terms/index.html, /legal/privacy/index.html, and
   /legal/cookies/index.html via absolute path /assets/legal.css.

   Design principles:
   - Match the app's brand palette (warm peach/rose canvas in light,
     near-black canvas in dark — same hex values as Theme.swift's
     BrandCanvas color set).
   - System font stack for body, with a Montserrat-like sans serif
     preference for headings to echo the in-app display type without
     requiring a web font download.
   - Generous line spacing and a comfortable reading measure (max
     65ch) — these documents are long, the reader's eye needs help.
   - Full light/dark mode adaptation via prefers-color-scheme so the
     pages match the device the user opened them from. */

:root {
  --canvas:        #fbf3ed;  /* Light BrandCanvas */
  --ink:           #2a323b;  /* Light BrandInk */
  --ink-muted:     rgba(42, 50, 59, 0.65);
  --ink-faint:     rgba(42, 50, 59, 0.45);
  --rule:          rgba(42, 50, 59, 0.12);
  --accent:        #803f4f;  /* Light BrandHero — wine rose */
  --accent-soft:   rgba(128, 63, 79, 0.08);
  --code-bg:       rgba(42, 50, 59, 0.06);
  --table-stripe:  rgba(42, 50, 59, 0.03);
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas:       #02101d;  /* Dark BrandCanvas — near-black */
    --ink:          #e8eff7;  /* Dark BrandInk — off-white */
    --ink-muted:    rgba(232, 239, 247, 0.70);
    --ink-faint:    rgba(232, 239, 247, 0.45);
    --rule:         rgba(232, 239, 247, 0.14);
    --accent:       #4fb3e0;  /* Dark BrandAccentInline — sky blue */
    --accent-soft:  rgba(79, 179, 224, 0.10);
    --code-bg:      rgba(232, 239, 247, 0.07);
    --table-stripe: rgba(232, 239, 247, 0.04);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── Layout ───────────────────────────────────────────────────────── */

.legal-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

@media (min-width: 768px) {
  .legal-page { padding: 56px 32px 96px; }
}

/* ── Top nav ──────────────────────────────────────────────────────── */

.legal-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 14px;
  margin-bottom: 48px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--rule);
}

.legal-nav a {
  color: var(--ink-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}

.legal-nav a:first-child {
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 16px;
  margin-right: 4px;
}

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

.legal-nav-sep {
  color: var(--ink-faint);
  user-select: none;
}

/* ── Article typography ───────────────────────────────────────────── */

.legal-content { max-width: 65ch; }

.legal-content h1 {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
}

.legal-content h2 {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin: 48px 0 16px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
}

/* The first H2 after the title block doesn't need a top rule (avoids
   double rules under the nav). */
.legal-content > h2:first-of-type { border-top: none; padding-top: 0; }

.legal-content h3 {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.35;
  margin: 32px 0 12px;
}

.legal-content h4 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  margin: 24px 0 8px;
  color: var(--ink-muted);
}

.legal-content p {
  margin: 0 0 16px;
  color: var(--ink);
}

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

.legal-content em { font-style: italic; }

.legal-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: opacity 0.15s ease;
}

.legal-content a:hover { opacity: 0.7; }

.legal-content code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 1px 6px;
  border-radius: 4px;
}

.legal-content hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 32px 0;
}

/* ── Lists ────────────────────────────────────────────────────────── */

.legal-content ul,
.legal-content ol {
  margin: 0 0 16px;
  padding-left: 28px;
}

.legal-content li {
  margin-bottom: 8px;
}

.legal-content li > p { margin-bottom: 8px; }

.legal-content ul li::marker { color: var(--ink-faint); }
.legal-content ol li::marker { color: var(--ink-muted); font-weight: 600; }

/* ── Blockquotes ──────────────────────────────────────────────────── */

.legal-content blockquote {
  margin: 16px 0;
  padding: 12px 20px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 6px 6px 0;
  color: var(--ink);
  font-style: italic;
}

.legal-content blockquote p { margin: 0; }

/* ── Tables ───────────────────────────────────────────────────────── */

.legal-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 15px;
  /* Allow horizontal scroll on narrow viewports rather than squashing */
  display: block;
  overflow-x: auto;
  white-space: normal;
}

.legal-content thead {
  background: var(--accent-soft);
}

.legal-content th,
.legal-content td {
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--rule);
}

.legal-content th {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.legal-content tbody tr:nth-child(even) td {
  background: var(--table-stripe);
}

/* ── Footer ───────────────────────────────────────────────────────── */

.legal-footer {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  font-size: 14px;
  color: var(--ink-muted);
}

.legal-footer a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.legal-footer p { margin: 0 0 8px; }

.legal-footer-fine {
  color: var(--ink-faint);
  font-size: 13px;
}

/* ── Reduced motion respect ───────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
