/*
 * Legal pages redesign (Terms & Conditions, Privacy Policy, Cookies Policy), loaded after
 * style_index_min.css. Every rule is scoped to main.sd-legal. Same dark hero as the About page, then the
 * document in a white card on the light ground; on large screens the contents list stays beside it while
 * reading (legal_toc.js marks the section being read). Same texts as before.
 */

/* ------------------------------------------------------------------ Tokens */

.sd-legal {
  --sd-text: #1B2333;
  --sd-body: #3B4658;
  --sd-muted: #5F6A7D;
  --sd-ground: #F2F4F7;
  --sd-card: #FFFFFF;
  --sd-line: #E2E8F0;
  --sd-navy: #111827;
  --sd-green: #50D878;
  --sd-green-text: #157A43;
  display: flow-root;
  background: var(--sd-ground);
}

/* style_index_min.css gives every section a 100px bottom margin; spacing here is set per block */
.sd-legal section {
  margin-bottom: 0;
}

/* ------------------------------------------------------------------ Hero (as on the About page) */

.sd-legal-hero {
  position: relative;
  overflow: hidden;
  padding: 4rem 0 7rem;
  background-color: var(--sd-navy);
  background-image:
    radial-gradient(ellipse 50% 90% at 50% 0%, rgba(80, 216, 120, 0.16) 0%, transparent 70%),
    radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 100% 100%, 22px 22px;
}

.sd-legal-hero-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

/* Legal icon in a white circle */
.sd-legal-hero-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 0 0 8px rgba(80, 216, 120, 0.15), 0 16px 32px -12px rgba(0, 0, 0, 0.6);
}

.sd-legal-title {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -1px;
  color: #FFFFFF;
  text-wrap: balance;
}

/* Effective date as a small pill */
.sd-legal-lead {
  margin: 0;
  padding: 0.375rem 0.875rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.875rem;
  font-weight: 600;
  color: #C9D2E0;
}

/* ------------------------------------------------------------------ Layout: contents beside the document */

.sd-legal-layout {
  position: relative;
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
  align-items: start;
  gap: 2rem;
  margin-top: -4rem;
  padding-bottom: 5rem;
}

/* Contents: a card that stays in view while reading */
.sd-legal-toc {
  position: sticky;
  top: 6.5rem;
  max-height: calc(100vh - 8rem);
  overflow-y: auto;
  padding: 1.5rem 1.25rem;
  border: 1px solid var(--sd-line);
  border-radius: 1.25rem;
  background: var(--sd-card);
  box-shadow: 0 24px 48px -32px rgba(17, 24, 39, 0.35);
}

.sd-legal .sd-legal-toc h3 {
  margin: 0 0 0.75rem;
  padding: 0 0.5rem;
  font-size: 0.75rem;
  line-height: 1.4;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sd-green-text);
}

.sd-legal .sd-legal-toc ol {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: sd-toc;
}

.sd-legal .sd-legal-toc li {
  counter-increment: sd-toc;
}

.sd-legal .sd-legal-toc a {
  position: relative;
  display: flex;
  gap: 0.625rem;
  padding: 0.5rem;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  line-height: 1.35;
  font-weight: 600;
  color: var(--sd-muted);
  text-decoration: none;
  transition: background-color .2s ease, color .2s ease;
}

/* Section number before each entry */
.sd-legal .sd-legal-toc a::before {
  content: counter(sd-toc, decimal-leading-zero);
  flex: none;
  min-width: 1.375rem;
  font-variant-numeric: tabular-nums;
  color: #A0AABA;
  transition: color .2s ease;
}

.sd-legal .sd-legal-toc a:hover {
  background: var(--sd-ground);
  color: var(--sd-text);
}

/* The section being read (class is-active, set by legal_toc.js) */
.sd-legal .sd-legal-toc a.is-active {
  background: rgba(80, 216, 120, 0.12);
  color: var(--sd-text);
}

.sd-legal .sd-legal-toc a.is-active::before {
  color: var(--sd-green-text);
}

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

.sd-legal-doc {
  min-width: 0;
  padding: 3rem 3.5rem;
  border: 1px solid var(--sd-line);
  border-radius: 1.5rem;
  background: var(--sd-card);
  box-shadow: 0 32px 64px -36px rgba(17, 24, 39, 0.35);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--sd-body);
}

.sd-legal .sd-legal-doc h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.6px;
  color: var(--sd-text);
}

/* Each numbered section starts after a thin line; anchors stop below the floating top bar */
.sd-legal .sd-legal-doc h3,
.sd-legal .sd-legal-doc h4 {
  scroll-margin-top: 7rem;
  color: var(--sd-text);
}

.sd-legal .sd-legal-doc h3 {
  margin: 2.5rem 0 0.875rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--sd-line);
  font-size: 1.375rem;
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.sd-legal .sd-legal-doc h4 {
  margin: 1.75rem 0 0.625rem;
  font-size: 1.0625rem;
  line-height: 1.4;
  font-weight: 700;
}

.sd-legal .sd-legal-doc p,
.sd-legal .sd-legal-doc .lp-secondary-subtitle {
  margin: 0 0 1rem;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--sd-body);
}

.sd-legal .sd-legal-doc b,
.sd-legal .sd-legal-doc strong {
  font-weight: 700;
  color: var(--sd-text);
}

.sd-legal .sd-legal-doc a {
  font-weight: 600;
  color: var(--sd-green-text);
  text-decoration: underline;
  text-decoration-color: rgba(21, 122, 67, 0.35);
  text-underline-offset: 3px;
  transition: text-decoration-color .2s ease;
}

.sd-legal .sd-legal-doc a:hover {
  text-decoration-color: currentColor;
}

/* Lists with small green bullets */
.sd-legal .sd-legal-doc ul {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin: 0.5rem 0 1rem;
  padding: 0;
  list-style: none;
}

.sd-legal .sd-legal-doc ul > li {
  position: relative;
  padding-left: 1.375rem;
}

.sd-legal .sd-legal-doc ul > li::before {
  content: "";
  position: absolute;
  top: 0.68em;
  left: 0.25rem;
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 50%;
  background: var(--sd-green);
}

/* Tables in a rounded frame that scrolls sideways on narrow screens */
.sd-legal-table {
  margin: 1.25rem 0 1.5rem;
  overflow-x: auto;
  border: 1px solid var(--sd-line);
  border-radius: 1rem;
}

.sd-legal .sd-legal-table .table {
  min-width: 30rem;
  margin: 0;
  font-size: 0.9375rem;
  --bs-table-bg: transparent;
}

.sd-legal .sd-legal-table th {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--sd-line);
  background: var(--sd-ground);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sd-muted);
}

.sd-legal .sd-legal-table td {
  padding: 0.875rem 1rem;
  border-color: var(--sd-line);
  color: var(--sd-body);
}

.sd-legal .sd-legal-table tr:last-child td {
  border-bottom: 0;
}

/* "Customize Cookies" shown as a button (same element and behaviour) */
.sd-legal .sd-legal-action {
  display: inline-flex;
  align-items: center;
  padding: 0.625rem 1.25rem;
  border-radius: 0.625rem;
  background: var(--sd-navy);
  font-weight: 700;
  color: #FFFFFF;
  cursor: pointer;
  transition: background-color .2s ease, transform .2s ease;
}

.sd-legal .sd-legal-action:hover {
  background: #1F2A3D;
  transform: translateY(-1px);
}

/* ------------------------------------------------------------------ Tablets and phones */

@media (max-width: 991.98px) {
  /* Contents above the document, no longer sticky */
  .sd-legal-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
  }

  .sd-legal-toc {
    position: static;
    max-height: none;
  }

  .sd-legal .sd-legal-toc ol {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.125rem 0.75rem;
  }

  .sd-legal-doc {
    padding: 2.25rem 2rem;
  }
}

@media (max-width: 575.98px) {
  .sd-legal-hero {
    padding: 3rem 0 5.5rem;
  }

  .sd-legal-layout {
    margin-top: -3rem;
    padding-bottom: 3rem;
  }

  .sd-legal-toc {
    padding: 1.125rem 0.75rem;
    border-radius: 1rem;
  }

  .sd-legal .sd-legal-toc ol {
    grid-template-columns: minmax(0, 1fr);
  }

  .sd-legal-doc {
    padding: 1.75rem 1.25rem;
    border-radius: 1.125rem;
    font-size: 0.9375rem;
  }

  .sd-legal .sd-legal-doc p,
  .sd-legal .sd-legal-doc .lp-secondary-subtitle {
    font-size: 0.9375rem;
  }

  .sd-legal .sd-legal-doc h3 {
    margin-top: 2rem;
    padding-top: 2rem;
    font-size: 1.1875rem;
  }

  /* Tighter tables, still scrolling sideways when needed */
  .sd-legal .sd-legal-table .table {
    min-width: 24rem;
    font-size: 0.875rem;
  }

  .sd-legal .sd-legal-table th,
  .sd-legal .sd-legal-table td {
    padding: 0.625rem 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sd-legal .sd-legal-toc a,
  .sd-legal .sd-legal-action {
    transition: none;
  }
}
