/* ============================================================================
   Terms / Legal Page — Dragon Skin v4
   Compact hero + single prose section (mirrors subprocessors / faq idioms)
   Rendered body carries a demoted legal-policy suite: h3 + h4 headings and
   long ALL-CAPS statutory paragraphs, so heading wrapping and anchor-jump
   offsets are handled defensively below.
   ============================================================================ */

/* ─────────────── HERO ─────────────── */
.terms-hero {
  position: relative;
  overflow: hidden;
  min-height: clamp(280px, 40vh, 440px);
  /* dark gradient is the fallback; a CMS hero photo (set as background-image
     by terms.js) overrides it. Matches .subs-hero / .faq-hero. */
  background: linear-gradient(135deg, #0f1a14 0%, #1C1912 40%, #12100A 100%);
  background-size: cover;
  background-position: center;
}

.terms-hero .hero-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 20px 60px;
}

.terms-hero .hero-overlay-title {
  font: var(--cm-w-bold) clamp(32px, 6vw, 72px)/1.05 var(--cm-font-display);
  margin: 0;
}

/* ─────────────── PROSE SECTION ─────────────── */
.terms-section {
  max-width: 860px;
  margin: 0 auto;
  padding: clamp(40px, 6vw, 72px) clamp(16px, 5vw, 40px) clamp(60px, 8vw, 100px);
}

/* ─────────────── PROSE BODY (data-content="body") ─────────────── */
.terms-body {
  font: var(--cm-w-regular) clamp(15px, 1.8vw, 17px)/1.7 var(--cm-font-ui);
  color: var(--cm-text-secondary);
}

.terms-body h1,
.terms-body h2,
.terms-body h3,
.terms-body h4 {
  font-family: var(--cm-font-display);
  font-weight: var(--cm-w-bold);
  color: var(--cm-text-primary);
  letter-spacing: 0.02em;
  margin: 1.6em 0 0.6em;
  line-height: 1.15;
  /* Long legal section titles must wrap cleanly rather than overflow the
     column; anchor jumps (#fragment) land with breathing room below the top
     of the viewport. The site nav is absolutely positioned inside the hero
     and scrolls away, so a modest offset is sufficient. */
  overflow-wrap: break-word;
  word-break: break-word;
  scroll-margin-top: 1.5rem;
}
.terms-body h1 { font-size: clamp(26px, 4vw, 40px); }
.terms-body h2 { font-size: clamp(22px, 3vw, 30px); }
.terms-body h3 { font-size: clamp(18px, 2.4vw, 22px); }
.terms-body h4 {
  font-size: clamp(16px, 2vw, 18px);
  letter-spacing: 0.03em;
  color: var(--cm-text-secondary);
}
.terms-body > :first-child { margin-top: 0; }

.terms-body p {
  margin: 0 0 1.2em;
  /* ALL-CAPS statutory clauses can contain very long unbroken tokens. */
  overflow-wrap: break-word;
  scroll-margin-top: 1.5rem;
}
.terms-body p:last-child { margin-bottom: 0; }

.terms-body ul,
.terms-body ol {
  margin: 0.5em 0 1.2em 1.2em;
  padding: 0;
}
.terms-body li { margin-bottom: 0.55em; }

/* Anchor targets injected inline (e.g. <a id="fragment">) land clear of the
   viewport top even though the nav scrolls away with the hero. */
.terms-body [id] { scroll-margin-top: 1.5rem; }

.terms-body a {
  color: var(--cm-text-link);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s;
}
.terms-body a:hover {
  color: color-mix(in srgb, var(--cm-text-link) 80%, #fff);
}

.terms-body strong {
  color: var(--cm-text-primary);
  font-weight: var(--cm-w-bold);
}
.terms-body em { font-style: italic; }

.terms-body code {
  background: var(--cm-bg-elevated);
  border: 1px solid var(--cm-border-subtle);
  border-radius: var(--cm-radius-sm);
  padding: 1px 5px;
  font-size: 0.875em;
}

/* ─────────────── MARKDOWN TABLES ─────────────── */
/* Tables render as direct children of .terms-body with no wrapper element, so
   the table itself becomes the scroll container on narrow viewports. */
.terms-body table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 0 0 1.4em;
  font-size: 0.875em;
}
.terms-body table:last-child { margin-bottom: 0; }

.terms-body th,
.terms-body td {
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--cm-border-subtle);
}

.terms-body thead th {
  background: var(--cm-bg-elevated);
  color: var(--cm-text-primary);
  font-weight: var(--cm-w-bold);
  border-bottom: 1px solid var(--cm-border-subtle);
}

.terms-body tbody tr:last-child td { border-bottom: none; }

/* ─────────────── SKELETON LOADING ─────────────── */
.terms-body.skeleton {
  position: relative;
  overflow: hidden;
  min-height: 240px;
  border-radius: var(--cm-radius-lg);
  background: var(--cm-bg-surface);
}
.terms-body.skeleton > * { visibility: hidden; }
.terms-body.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    color-mix(in srgb, var(--cm-bg-elevated) 60%, transparent) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: skeletonPulse 1.6s ease-in-out infinite;
}

@keyframes skeletonPulse {
  0% { background-position: -100% 0; }
  100% { background-position: 200% 0; }
}

/* ─────────────── EMPTY STATE ─────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--cm-text-tertiary);
  font: var(--cm-w-medium) 16px/1.5 var(--cm-font-ui);
}

/* ─────────────── RESPONSIVE ─────────────── */
@media (max-width: 600px) {
  .terms-hero .hero-overlay { padding: 64px 18px 48px; }
  .terms-body th,
  .terms-body td { padding: 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .terms-body.skeleton::after { animation: none; }
}
