/* ============================================================
   legal.css — Terms & Privacy pages (terms.html, privacy.html).
   Header and footer come from base.css. Phone layout ≤ 980px,
   the same breakpoint base.css uses for the header.
   ============================================================ */

:root {
  --legal-bg: #f6f5f9;
  --legal-body: #3c3450;
  --legal-muted: #5b5070;
  --legal-muted-2: #6e6388;
  --legal-num: #7a6f92;
  --legal-brand: #6b3bb5;
  --legal-brand-dark: #4b2a8a;
  --legal-brand-hover: #5a2ca0;
  --legal-brand-soft: #f2e9fb;
  --legal-line: #efeaf6;
  --legal-dot: #a57be6;
  --legal-font-num: "Space Grotesk", "Montserrat", system-ui, sans-serif;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--legal-bg);
}

/* ---- Page ---- */

.legal-page {
  max-width: 1160px;
  margin: 0 auto;
  padding: 40px 32px 32px;
  -webkit-font-smoothing: antialiased;
}

.legal-page a:focus-visible,
.legal-page button:focus-visible,
.legal-page summary:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}

.legal-page svg {
  display: block;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Terms / Privacy switch ---- */

.legal-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(43, 31, 68, 0.08);
}

.legal-switch a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--legal-muted);
  white-space: nowrap;
}

.legal-switch a:hover {
  color: var(--ink);
}

.legal-switch a[aria-current="page"] {
  background: var(--legal-brand);
  color: #ffffff;
}

/* ---- Title ---- */

.legal-page h1 {
  margin-top: 20px;
  font-size: 44px;
  line-height: 52px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.legal-meta {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: var(--legal-muted);
}

.legal-updated {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--legal-brand);
}

.legal-sep {
  color: #c9bfdc;
}

.legal-layout {
  margin-top: 32px;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

/* ---- Table of contents ---- */

.legal-toc {
  position: sticky;
  top: 100px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.legal-toc details {
  display: block;
}

.legal-toc summary {
  list-style: none;
  margin: 0 0 10px 12px;
  font-size: 12.5px;
  line-height: 16px;
  font-weight: 700;
  color: var(--legal-muted-2);
  pointer-events: none;
}

.legal-toc summary::-webkit-details-marker {
  display: none;
}

.legal-toc summary .legal-count {
  display: none;
}

.legal-toc ol {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legal-toc ol a {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: var(--legal-body);
  transition: background 0.15s, color 0.15s;
}

.legal-toc ol a span {
  flex: none;
  width: 20px;
  font-family: var(--legal-font-num);
  font-weight: 600;
  color: var(--legal-num);
}

.legal-toc ol a:hover {
  background: rgba(255, 255, 255, 0.75);
  color: var(--legal-brand);
}

.legal-toc ol a.is-active {
  background: #ffffff;
  color: var(--legal-brand);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(43, 31, 68, 0.1);
}

.legal-toc ol a.is-active span {
  color: var(--purple);
}

.legal-help {
  padding: 16px;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(43, 31, 68, 0.06);
}

.legal-help p {
  font-size: 13px;
  line-height: 18px;
  font-weight: 700;
}

.legal-help a {
  display: inline-block;
  margin-top: 6px;
  font-size: 14px;
  line-height: 20px;
}

/* ---- Document ---- */

.legal-doc {
  padding: 48px 56px 56px;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(43, 31, 68, 0.05), 0 16px 40px rgba(43, 31, 68, 0.06);
}

.legal-doc strong {
  font-weight: 700;
  color: var(--ink);
}

.legal-intro {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 36px;
  border-bottom: 1px solid var(--legal-line);
  font-size: 18px;
  line-height: 1.7;
  color: var(--legal-body);
}

.legal-doc section {
  margin-top: 48px;
  scroll-margin-top: 100px;
}

.legal-doc h2 {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 22px;
  line-height: 28px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.legal-n {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--legal-brand-soft);
  color: var(--legal-brand);
  font-family: var(--legal-font-num);
  font-size: 15px;
  font-weight: 700;
}

.legal-doc h3 {
  margin-top: 8px;
  font-size: 17px;
  line-height: 24px;
  font-weight: 700;
}

.legal-body {
  margin-top: 14px;
  padding-left: 50px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 16px;
  line-height: 1.75;
  color: var(--legal-body);
}

.legal-body ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legal-body li {
  position: relative;
  padding-left: 22px;
}

.legal-body li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: calc(0.875em - 3.5px);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--legal-dot);
}

.legal-link {
  color: var(--legal-brand);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.legal-link:hover {
  color: var(--legal-brand-dark);
}

.legal-contact {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #f7f3fd;
  border: 1px solid #ece3f8;
}

.legal-contact div {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
}

.legal-contact-icon {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #ffffff;
  color: var(--legal-brand);
}

.legal-contact-label {
  flex: none;
  width: 72px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: var(--legal-muted-2);
}

.legal-contact .legal-link {
  font-size: 15px;
  line-height: 20px;
  overflow-wrap: anywhere;
}

/* ---- Back to top ---- */

.legal-totop {
  position: fixed;
  right: 32px;
  bottom: 32px;
  z-index: 5;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--legal-brand);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(107, 59, 181, 0.35);
}

.legal-totop:hover {
  background: var(--legal-brand-hover);
}

.legal-totop[hidden] {
  display: none;
}

/* ---- Responsive ---- */

@media (max-width: 980px) {
  .legal-page {
    padding: 20px 16px 32px;
  }

  .legal-switch {
    display: flex;
  }

  .legal-switch a {
    flex: 1;
    height: 44px;
    padding: 0 8px;
  }

  .legal-page h1 {
    margin-top: 22px;
    font-size: 30px;
    line-height: 36px;
  }

  .legal-meta {
    margin-top: 10px;
    font-size: 13px;
  }

  .legal-layout {
    display: block;
    margin-top: 20px;
  }

  .legal-toc {
    position: static;
    display: block;
  }

  .legal-help {
    display: none;
  }

  .legal-toc details {
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(43, 31, 68, 0.08);
    overflow: hidden;
  }

  .legal-toc summary {
    pointer-events: auto;
    cursor: pointer;
    margin: 0;
    height: 52px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 15px;
    color: var(--ink);
  }

  .legal-toc summary:hover {
    background: #faf8fd;
  }

  .legal-toc summary .legal-count {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--legal-muted-2);
  }

  .legal-chev {
    transition: transform 0.2s;
  }

  .legal-toc details[open] .legal-chev {
    transform: rotate(180deg);
  }

  .legal-toc ol {
    padding: 6px 6px 8px;
    border-top: 1px solid var(--legal-line);
  }

  .legal-toc ol a {
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 10px;
    font-size: 15px;
  }

  .legal-toc ol a span {
    width: 22px;
  }

  .legal-toc ol a.is-active {
    box-shadow: none;
    background: var(--lavender);
  }

  .legal-doc {
    margin-top: 16px;
    padding: 22px 18px 28px;
    border-radius: 20px;
    box-shadow: 0 1px 2px rgba(43, 31, 68, 0.05), 0 12px 28px rgba(43, 31, 68, 0.06);
  }

  .legal-intro {
    gap: 12px;
    font-size: 16.5px;
    padding-bottom: 26px;
  }

  .legal-doc section {
    margin-top: 36px;
    scroll-margin-top: calc(var(--header-h) + 16px);
  }

  .legal-doc h2 {
    gap: 12px;
    font-size: 19px;
    line-height: 24px;
  }

  .legal-n {
    width: 32px;
    height: 32px;
  }

  .legal-body {
    margin-top: 12px;
    padding-left: 0;
    line-height: 1.7;
  }

  .legal-contact-label {
    width: 64px;
  }

  .legal-totop {
    right: 20px;
    bottom: 20px;
  }

  /* Room under the footer links so the back-to-top button doesn't cover them. */
  .site-footer {
    padding-bottom: 84px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .legal-page * {
    transition: none !important;
  }
}
