/* =========================================================
   ScoreB - legal pages (terms.html + privacy.html)
   =========================================================
   Mobile first. Reuses the header from style.css
   (.match-page-header). Always light, whatever theme the
   rest of the site is using. Everything is scoped to .legal-* so no other
   page is affected.
   ========================================================= */

html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 64px); }

/* style.css makes html AND body overflow-x hidden on phones, which turns the body into
   its own scroller. Let the page itself scroll so the sticky header and chips behave. */
html, body.legal-page-body { height: auto; overflow-x: clip; }
html { color-scheme: light; }

.legal-page-body {
  --legal-card: #ffffff;
  --legal-text: #222222;
  --legal-dim: #5b6572;
  --legal-line: #e6e9ee;
  --legal-soft: #f1f8fd;
  --legal-link: #0b7bb0;
  --legal-chip: #ffffff;
}

.legal-wrap {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 12px calc(32px + env(safe-area-inset-bottom, 0px));
}

/* ---------- Title ---------- */
.legal-hero { padding: 20px 4px 12px; }
.legal-hero-top { display: flex; align-items: center; gap: 12px; }
.legal-hero-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--site-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.legal-hero h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  color: var(--legal-text);
  overflow-wrap: anywhere;
}
.legal-updated { margin: 10px 0 0; font-size: 13px; color: var(--legal-dim); }

/* ---------- Terms / Privacy switch ---------- */
.legal-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin: 6px 0 12px;
  background: var(--legal-card);
  border: 1px solid var(--legal-line);
  border-radius: 12px;
}
.legal-switch a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 8px 6px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  color: var(--legal-dim);
  -webkit-tap-highlight-color: transparent;
}
.legal-switch a:hover { color: var(--legal-text); }
.legal-switch a[aria-current="page"] { background: var(--site-blue); color: #fff; font-weight: 700; }
.legal-switch a:focus-visible,
.legal-toc a:focus-visible,
.legal-card a:focus-visible,
.legal-more a:focus-visible { outline: 2px solid var(--site-blue); outline-offset: 2px; }

/* ---------- Section chips (sticky, scroll sideways) ---------- */
.legal-toc {
  position: sticky;
  top: var(--header-h);
  z-index: 9;
  margin: 0 -12px 12px;
  padding: 8px 12px;
  background: #F2F2F2;
  border-bottom: 1px solid var(--legal-line);
}
.legal-toc ul {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.legal-toc ul::-webkit-scrollbar { display: none; }
.legal-toc li { flex: 0 0 auto; }
.legal-toc a {
  display: block;
  padding: 7px 12px;
  border: 1px solid var(--legal-line);
  border-radius: 999px;
  background: var(--legal-chip);
  color: var(--legal-dim);
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
}
.legal-toc a.is-active { background: var(--site-blue); border-color: var(--site-blue); color: #fff; font-weight: 500; }

/* ---------- Summary box ---------- */
.legal-summary {
  margin: 0 0 12px;
  padding: 14px 16px;
  background: var(--legal-soft);
  border: 1px solid #cfe8f7;
  border-left: 4px solid var(--site-blue);
  border-radius: 12px;
  color: var(--legal-text);
}
.legal-summary h3 { margin: 0 0 8px; font-size: 15px; }
.legal-summary ul { margin: 0; padding-left: 20px; }
.legal-summary li { margin: 4px 0; font-size: 14px; line-height: 1.55; }

/* ---------- Main card ---------- */
.legal-card {
  background: var(--legal-card);
  border: 1px solid var(--legal-line);
  border-radius: 14px;
  padding: 4px 16px;
  color: var(--legal-text);
  font-size: 15px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.legal-sec { padding: 18px 0; border-bottom: 1px solid var(--legal-line); }
.legal-sec:last-child { border-bottom: 0; }
.legal-sec h3 {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 17px;
  line-height: 1.3;
  color: var(--legal-text);
}
.legal-num {
  flex: 0 0 auto;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  margin-top: -1px;
  border-radius: 8px;
  background: rgba(14, 165, 233, 0.14);
  color: var(--legal-link);
  font-size: 13px;
  font-weight: 700;
  line-height: 26px;
  text-align: center;
}
.legal-sec p { margin: 8px 0; }
.legal-sec ul { margin: 8px 0; padding-left: 20px; }
.legal-sec li { margin: 6px 0; }
.legal-sec h4 { margin: 14px 0 4px; font-size: 14px; color: var(--legal-text); }
.legal-card a { color: var(--legal-link); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Bottom links ---------- */
.legal-more {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.legal-more a {
  flex: 1 1 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--legal-line);
  border-radius: 12px;
  background: var(--legal-card);
  color: var(--legal-link);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
.legal-copy { margin: 16px 4px 0; text-align: center; font-size: 12px; color: var(--legal-dim); }

/* ---------- Small phones ---------- */
@media (max-width: 380px) {
  .legal-wrap { padding-left: 10px; padding-right: 10px; }
  .legal-toc { margin-left: -10px; margin-right: -10px; padding-left: 10px; padding-right: 10px; }
  .legal-hero h2 { font-size: 20px; }
  .legal-switch a { font-size: 13px; padding: 8px 4px; }
  .legal-switch a i { display: none; }
  .legal-card { padding: 2px 14px; font-size: 14.5px; }
  .legal-sec h3 { font-size: 16px; }
}

/* ---------- Larger screens ---------- */
@media (min-width: 700px) {
  .legal-wrap { padding-left: 0; padding-right: 0; }
  .legal-toc { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
  .legal-hero h2 { font-size: 26px; }
  .legal-card { padding: 8px 28px; }
}

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