/* BettaBuilder — Legal & Policies
   Design tokens mirrored from the BettaBuilder Figma marketplace design system. */

:root {
  /* Surfaces */
  --bg: #f2f2f2;
  --surface: #ffffff;

  /* Text */
  --text: #1d1d1d;
  --text-secondary: #3d3d3d;
  --text-muted: #6a6a6a;

  /* Lines */
  --border: #e2e2e2;
  --border-strong: #d2d2d2;

  /* Brand */
  --brand: #ff7c1d;
  --brand-dark: #d95f06;
  --brand-tint: #fff2e8;
  --info-tint: #e3eef8;

  /* Shape */
  --radius-card: 14px;
  --radius-control: 8px;
  --shadow-card: 0 1px 0 0 var(--border);

  --focus: #1a73e8;
  --maxw: 1140px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.62;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand);
  color: #fff;
  padding: 12px 20px;
  z-index: 100;
  font-weight: 600;
  border-radius: 0 0 var(--radius-control) 0;
}
.skip-link:focus { left: 0; }

a { color: var(--brand-dark); }
a:focus-visible,
button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
}
.brand__mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: block;
  border-radius: 10px;
}
.brand__name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.brand__label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ---------- Primary nav ---------- */
.site-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.site-nav__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}
.site-nav a {
  display: block;
  padding: 13px 14px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--brand);
}

/* ---------- Layout ---------- */
.layout {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 24px 64px;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.layout--single { grid-template-columns: minmax(0, 1fr); }

/* ---------- Sidebar (on-page contents) ---------- */
.toc {
  position: sticky;
  top: 68px;
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px 14px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}
.toc h2 {
  margin: 0 0 10px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 0;
  padding: 0;
}
.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: toc;
  font-size: 13px;
}
.toc li { counter-increment: toc; margin: 0 0 1px; }
.toc a {
  display: block;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.45;
}
.toc a::before { content: counter(toc) ". "; color: var(--brand); font-weight: 700; }
.toc a:hover { background: var(--bg); color: var(--text); }

/* ---------- Document ---------- */
.doc {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 40px 44px 48px;
  counter-reset: section;
}
.doc__eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand);
  margin: 0 0 10px;
}
.doc h1 {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.22;
  letter-spacing: -0.03em;
  margin: 0 0 14px;
}
.doc__intro {
  font-size: 16px;
  color: var(--text-secondary);
  margin: 0 0 8px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.doc h2 {
  counter-increment: section;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -0.02em;
  margin: 40px 0 12px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  scroll-margin-top: 68px;
}
.doc h2::before {
  content: counter(section) ". ";
  color: var(--brand);
}
.doc > section:first-of-type h2 { border-top: 0; padding-top: 0; margin-top: 30px; }

.doc h3 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 24px 0 6px;
  color: var(--text);
}

.doc p { margin: 0 0 13px; color: var(--text-secondary); }
.doc section > p:last-child { margin-bottom: 0; }

/* Numbered clause lists: N.1, N.2 ... */
.clauses {
  list-style: none;
  counter-reset: clause;
  margin: 0 0 13px;
  padding: 0;
}
.clauses > li {
  counter-increment: clause;
  position: relative;
  padding-left: 46px;
  margin-bottom: 11px;
  color: var(--text-secondary);
}
.clauses > li::before {
  content: counter(section) "." counter(clause);
  position: absolute;
  left: 0;
  top: 0;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 14px;
}

/* Nested lettered list */
.sub-list {
  list-style: lower-alpha;
  margin: 9px 0 4px;
  padding-left: 22px;
}
.sub-list li { margin-bottom: 5px; }
.sub-list li::marker { color: var(--text-muted); }

/* Plain bulleted list */
.bullets { margin: 9px 0 13px; padding-left: 20px; color: var(--text-secondary); }
.bullets li { margin-bottom: 5px; }
.bullets li::marker { color: var(--brand); }

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

/* Contact block */
.contact-card {
  background: var(--bg);
  border-radius: var(--radius-control);
  padding: 18px 20px;
  margin: 16px 0 13px;
}
.contact-card > p:first-child {
  margin: 0 0 10px;
  color: var(--text);
}
.contact-card dl { margin: 0; }
.contact-card dt {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 12px;
}
.contact-card dt:first-of-type { margin-top: 0; }
.contact-card dd { margin: 2px 0 0; color: var(--text); font-weight: 500; }

/* Cross links between policies */
.doc-footer-nav {
  margin-top: 44px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}
.doc-footer-nav h2 {
  border: 0;
  padding: 0;
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  counter-increment: none;
}
.doc-footer-nav h2::before { content: none; }
.doc-footer-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.doc-footer-nav a {
  display: inline-block;
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.doc-footer-nav a:hover { border-color: var(--brand); color: var(--brand-dark); }

/* ---------- Home ---------- */
.hero {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 40px 44px;
  margin-bottom: 20px;
}
.hero h1 {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.22;
  letter-spacing: -0.03em;
  margin: 0 0 14px;
}
.hero p { margin: 0 0 12px; color: var(--text-secondary); max-width: 70ch; }
.hero p:last-child { margin-bottom: 0; }

.policy-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.policy-card {
  display: block;
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 24px 24px 26px;
  text-decoration: none;
  color: inherit;
  height: 100%;
}
.policy-card:hover { box-shadow: 0 1px 0 0 var(--brand), 0 6px 20px rgba(29, 29, 29, 0.07); }
.policy-card h2 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.policy-card p { margin: 0 0 14px; color: var(--text-muted); font-size: 14px; }
.policy-card span { font-weight: 700; color: var(--brand-dark); font-size: 14px; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  padding: 24px;
  font-size: 13.5px;
}
.site-footer__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  justify-content: space-between;
  align-items: center;
}
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 18px; }
.site-footer a { color: var(--text-secondary); text-decoration: none; font-weight: 500; }
.site-footer a:hover { color: var(--brand-dark); }
.site-footer p { margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 20px 16px 48px; }
  .toc { position: static; max-height: none; }
  .doc { padding: 28px 22px 34px; }
  .hero { padding: 28px 22px; }
}

@media (max-width: 600px) {
  .site-header__inner { padding: 14px 16px; }
  .site-nav__inner { padding: 0 8px; }
  .site-nav a { padding: 12px 10px; font-size: 13px; }
  .doc h1, .hero h1 { font-size: 26px; }
  .doc h2 { font-size: 18px; }
  .doc { padding: 22px 18px 28px; }
  .hero { padding: 22px 18px; }
  .clauses > li { padding-left: 38px; }
  .site-footer__inner { justify-content: flex-start; }
}

/* ---------- Mobile: document-only view ----------
   Each policy is linked directly from the BettaBuilder app, which supplies its
   own navigation, so on phones the page shows just the branded header and the
   document itself: no tab bar, no "On this page" contents, no Overview link.
   Tablet (768px) and desktop keep the full site chrome. */
@media (max-width: 767px) {
  .site-nav,
  .toc,
  .footer-overview {
    display: none;
  }

  /* no sticky tab bar to clear */
  .doc h2 { scroll-margin-top: 12px; }
}

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

@media print {
  .site-nav, .toc, .doc-footer-nav, .skip-link { display: none; }
  body { background: #fff; font-size: 11pt; }
  .doc { box-shadow: none; padding: 0; }
  .layout { display: block; padding: 0; }
}
