/* ============================================
   LEGAL PAGE STYLES — HighFlowAI
   Shared across all long-form policy pages:
     – privacy.html
     – terms.html
     – cookies.html
     – disclaimer.html
     – refund.html

   Depends on commonStyles.css being loaded first.

   Design intent: editorial reading experience for
   document-heavy pages. Generous line-length,
   clear hierarchy, sticky table-of-contents on the
   left, prose right. No marketing flourishes.
   ============================================ */


/* ============================================
   1. HERO
   Constrained, calm. The legal pages don't need
   to sell — they need to set context (what this
   document is, when it was last updated).
   ============================================ */
.legal-hero {
  padding-top: 160px;
  padding-bottom: 64px;
  border-bottom: 1px solid var(--border-subtle);
}

.legal-hero-inner {
  max-width: 720px;
}

.legal-display {
  font-size: clamp(2.2rem, 4.5vw, 3.4rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin: 24px 0 24px;
}

.legal-display .serif {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
}

.legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 32px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}

.legal-meta strong {
  color: var(--text-mid);
  font-weight: 500;
}


/* ============================================
   2. MAIN GRID
   Two-column on desktop:
     [ sticky TOC ][ document body ]
   Stacks below 960px and the TOC becomes a
   collapsible inline summary at the top instead.
   ============================================ */
.legal-main {
  padding-top: clamp(56px, 8vw, 96px);
  padding-bottom: var(--section-pad);
}

.legal-grid {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: clamp(48px, 7vw, 96px);
  align-items: start;
}

@media (max-width: 960px) {
  .legal-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}


/* ============================================
   3. TABLE OF CONTENTS
   Sticky on desktop so it travels with the reader.
   On mobile/tablet it sits above the prose as a
   scannable summary — same content, no JS toggle.
   ============================================ */
.legal-toc {
  position: sticky;
  top: 96px;
  align-self: start;
  font-size: 0.92rem;
}

.legal-toc-heading {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.legal-toc ol {
  list-style: none;
  counter-reset: toc;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legal-toc li {
  counter-increment: toc;
}

.legal-toc a {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  color: var(--text-mid);
  font-size: 0.92rem;
  line-height: 1.4;
  transition: color var(--transition-fast);
  border-left: 1px solid transparent;
  padding-left: 14px;
  margin-left: -14px;
}

.legal-toc a::before {
  content: counter(toc, decimal-leading-zero);
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  padding-top: 1px;
  transition: color var(--transition-fast);
}

.legal-toc a:hover {
  color: var(--accent);
  border-left-color: var(--accent);
}

.legal-toc a:hover::before {
  color: var(--accent);
}

@media (max-width: 960px) {
  .legal-toc {
    position: static;
    padding: 24px 0;
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
  }
}


/* ============================================
   4. DOCUMENT BODY
   The prose. Generous measure, clear hierarchy.
   No surface treatment — these pages live and die
   on legibility, not visual flair.
   ============================================ */
.legal-body {
  max-width: 720px;
  color: var(--text-primary);
  font-size: 1rem;
  line-height: 1.7;
}


/* ----  Section headings  ---- */
.legal-body section {
  padding: 0;
  margin-top: 64px;
  scroll-margin-top: 96px;     /* offset for sticky nav on TOC links */
}

.legal-body section:first-child {
  margin-top: 0;
}

.legal-body h2 {
  font-size: clamp(1.5rem, 2.6vw, 1.95rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text-headline);
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.legal-body h2 .legal-num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  color: var(--accent);
  font-weight: 500;
  text-transform: uppercase;
  padding-top: 4px;
  flex-shrink: 0;
}

.legal-body h3 {
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-headline);
  margin-top: 32px;
  margin-bottom: 12px;
}


/* ----  Prose elements  ---- */
.legal-body p {
  margin-bottom: 16px;
  color: var(--text-primary);
}

.legal-body p:last-child {
  margin-bottom: 0;
}

.legal-body strong {
  color: var(--text-headline);
  font-weight: 500;
}

.legal-body em {
  font-style: italic;
  color: var(--text-headline);
}

.legal-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(var(--accent-rgb), 0.4);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--transition-fast);
}

.legal-body a:hover {
  text-decoration-color: var(--accent);
}


/* ----  Lists  ---- */
.legal-body ul,
.legal-body ol {
  margin: 0 0 20px;
  padding-left: 24px;
}

.legal-body ul li,
.legal-body ol li {
  margin-bottom: 8px;
  padding-left: 8px;
}

.legal-body ul li::marker {
  color: var(--accent);
}

.legal-body ol li::marker {
  color: var(--text-mid);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.legal-body ul li:last-child,
.legal-body ol li:last-child {
  margin-bottom: 0;
}


/* ----  Definition rows (label / description) ---- */
.legal-defs {
  list-style: none;
  padding: 0;
  margin: 16px 0 24px;
  display: flex;
  flex-direction: column;
}

.legal-defs li {
  display: grid;
  grid-template-columns: minmax(140px, 180px) 1fr;
  gap: 24px;
  padding: 14px 0;
  border-top: 1px solid var(--border-subtle);
  align-items: baseline;
}

.legal-defs li:last-child {
  border-bottom: 1px solid var(--border-subtle);
}

.legal-defs dt,
.legal-defs .label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-mid);
  font-weight: 500;
}

.legal-defs dd,
.legal-defs .desc {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.6;
}

@media (max-width: 600px) {
  .legal-defs li {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 12px 0;
  }
}


/* ----  Callout / important note  ---- */
.legal-callout {
  margin: 24px 0;
  padding: 20px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  line-height: 1.6;
}

.legal-callout p:last-child {
  margin-bottom: 0;
}

.legal-callout strong {
  color: var(--accent);
}


/* ----  Capitalized legalese block (limitation of liability, etc.) ---- */
.legal-allcaps {
  font-size: 0.88rem;
  line-height: 1.6;
  letter-spacing: 0.01em;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 20px 24px;
  border-radius: var(--radius-sm);
  margin: 20px 0;
  text-transform: uppercase;
  font-weight: 500;
}


/* ============================================
   5. CONTACT BLOCK (footer of each policy)
   Standard pattern for "how to reach us" details
   at the end of legal documents.
   ============================================ */
.legal-contact {
  margin-top: 64px;
  padding: 32px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.legal-contact h3 {
  margin-top: 0 !important;
  margin-bottom: 16px !important;
  font-size: 1rem !important;
  font-family: var(--font-mono) !important;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent) !important;
  font-weight: 500;
}

.legal-contact p {
  margin-bottom: 6px;
  font-size: 0.95rem;
  line-height: 1.6;
}

.legal-contact p:last-child {
  margin-bottom: 0;
}


/* ============================================
   6. RESPONSIVE TWEAKS
   ============================================ */
@media (max-width: 768px) {
  .legal-hero {
    padding-top: 130px;
    padding-bottom: 48px;
  }

  .legal-body section {
    margin-top: 48px;
  }

  .legal-body h2 {
    flex-direction: column;
    gap: 6px;
  }

  .legal-body h2 .legal-num {
    padding-top: 0;
  }
}