/* =========================================================
   Modal: legal pages (Terms of Use)
   Builds on styles.css tokens, nav, buttons and footer.
   ========================================================= */

:root {
  --nav-h: 68px;
  --doc-text: #c4ced8;
  --warn: #f2c25a;
  --warn-soft: rgba(242, 194, 90, .1);
}

/* ---------- Reading progress ---------- */
.read-progress {
  position: fixed; inset: 0 0 auto 0; z-index: 60;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px rgba(94, 200, 248, .6);
  transform-origin: 0 50%;
  transform: scaleX(var(--p, 0));
}

/* ---------- Header ---------- */
.legal-hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 140px 0 64px;
}
.legal-hero::after {
  /* the same white edge the landing page hero ends with */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 120px; z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, .55) 50%, transparent) bottom / 100% 1px no-repeat,
    radial-gradient(ellipse 50% 100% at 50% 100%, rgba(255, 255, 255, .07), transparent 70%);
}

/* Brand cubes floating on the right of the header */
.legal-deco {
  position: absolute; z-index: 0; pointer-events: none;
  right: max(40px, calc((100vw - var(--maxw)) / 2 + 90px));
  top: 132px;
  width: 280px; height: 230px;
}
.legal-deco::before {
  content: ""; position: absolute; inset: -40px;
  background: radial-gradient(closest-side, rgba(94, 200, 248, .16), transparent);
  filter: blur(10px);
}
.legal-deco .cf-a { left: 70px; top: 26px; --s: 112px; }
.legal-deco .cf-b { right: 0; bottom: 8px; --s: 52px; animation-delay: -3s; }
.legal-deco .cf-c { left: 0; bottom: 0; --s: 34px; animation-delay: -1.5s; }
.legal-deco .cf-b .cube { animation-duration: 24s; animation-direction: reverse; }
.legal-deco .cf-c .cube { animation-duration: 14s; }
.legal-hero .container { position: relative; z-index: 1; }

.footer-links [aria-current] { color: var(--text); }

.crumbs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 500; color: var(--muted); /* over the header glow, so no dimmer than --muted */
}
.crumbs a {
  color: var(--text);
  text-decoration: underline; text-decoration-color: rgba(255, 255, 255, .3);
  text-underline-offset: 3px;
  transition: text-decoration-color .2s;
}
.crumbs a:hover { text-decoration-color: currentColor; }
.crumbs [aria-current] { color: var(--accent); }

.legal-hero h1 {
  margin-top: 18px;
  font-size: clamp(42px, 6.4vw, 72px);
  line-height: 1.02;
  letter-spacing: -.045em;
  font-weight: 800;
}
.legal-lead {
  margin-top: 18px;
  max-width: 620px;
  font-size: clamp(17px, 1.5vw, 19px);
  color: var(--muted);
}

.legal-meta {
  margin-top: 28px;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.legal-meta li {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .035);
  border: 1px solid var(--border);
  font-size: 13.5px; font-weight: 500; color: var(--muted);
}
.legal-meta .ic { width: 15px; height: 15px; color: var(--accent); }

.legal-actions { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Short version ---------- */
.summary-wrap { margin-top: 56px; }
.summary {
  position: relative; overflow: hidden; isolation: isolate;
  border-radius: 24px;
  padding: 36px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-strong);
}
.summary::before {
  content: ""; position: absolute; z-index: -1; right: -120px; top: -160px;
  width: 460px; height: 360px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(94, 200, 248, .14), transparent);
}
.summary-head h2 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.summary-head p { margin-top: 6px; color: var(--muted); font-size: 15px; max-width: 620px; }

.summary-grid {
  margin-top: 28px;
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 28px 32px;
}
.summary-grid li { display: flex; gap: 14px; }
.s-ic {
  width: 38px; height: 38px; flex: none; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--accent-soft); border: 1px solid rgba(94, 200, 248, .18);
  color: var(--accent);
}
.s-ic .ic { width: 19px; height: 19px; }
.summary-grid b { display: block; font-size: 15.5px; font-weight: 600; letter-spacing: -.01em; line-height: 1.35; }
.summary-grid p { margin-top: 4px; font-size: 14.5px; line-height: 1.6; color: var(--muted); }

/* ---------- Layout ---------- */
.legal-layout {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  gap: 72px;
  padding-top: 72px;
  padding-bottom: 40px;
  align-items: start;
}

/* ---------- Table of contents ---------- */
.toc {
  position: sticky; top: calc(var(--nav-h) + 28px);
  max-height: calc(100vh - var(--nav-h) - 56px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
.toc-toggle { display: none; }
.toc-title {
  font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 12px 14px;
}
.toc ol { display: grid; gap: 1px; }
.toc a {
  position: relative;
  display: flex; align-items: baseline; gap: 12px;
  padding: 7px 12px 7px 14px;
  border-radius: 0 9px 9px 0;
  font-size: 14px; line-height: 1.4; color: var(--muted);
  border-left: 2px solid var(--border);
  transition: color .2s, background .2s, border-color .2s;
}
.toc a:hover { color: var(--text); background: rgba(255, 255, 255, .03); }
.toc .n {
  flex: none; width: 18px;
  font-size: 12px; font-weight: 600; color: var(--faint);
  font-variant-numeric: tabular-nums;
  transition: color .2s;
}
.toc a.active {
  color: var(--text);
  border-left-color: var(--accent);
  background: linear-gradient(90deg, rgba(94, 200, 248, .1), transparent);
}
.toc a.active .n { color: var(--accent); }

/* ---------- Document ---------- */
.doc { max-width: 760px; min-width: 0; }
.doc section {
  padding: 48px 0;
  border-top: 1px solid var(--border);
  scroll-margin-top: calc(var(--nav-h) + 20px);
}
.doc section:first-child { padding-top: 0; border-top: 0; }

.sec-head { display: flex; align-items: center; gap: 8px; }
.doc h2 {
  display: flex; align-items: center; gap: 14px;
  font-size: clamp(23px, 2.4vw, 28px);
  line-height: 1.25;
  letter-spacing: -.025em;
  font-weight: 700;
}
.sec-n {
  flex: none;
  font-size: 13px; font-weight: 700; letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--accent-soft);
  border: 1px solid rgba(94, 200, 248, .2);
}
.anchor {
  flex: none;
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  color: var(--faint);
  opacity: 0;
  transition: opacity .2s, color .2s, background .2s;
}
.anchor .ic { width: 16px; height: 16px; }
.sec-head:hover .anchor, .anchor:focus-visible { opacity: 1; }
.anchor:hover { color: var(--accent); background: var(--accent-soft); }

.tldr {
  margin: 20px 0 26px;
  display: flex; align-items: baseline; gap: 14px;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 15.5px; line-height: 1.6;
  color: var(--text);
}
.tldr > span {
  flex: none;
  font-size: 11.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}
.doc section > .clauses:first-of-type { margin-top: 22px; }
.doc .tldr + .clauses { margin-top: 0; }

/* Numbered clauses. The "4.2" labels are real text in the markup, so they are
   read out and can be referenced (WCAG 1.3.1). */
.clauses { display: grid; gap: 18px; }
.clauses > li {
  position: relative;
  padding-left: 54px;
  font-size: 16px; line-height: 1.75;
  color: var(--doc-text);
}
.cl-n {
  position: absolute; left: 0; top: .2em;
  font-size: 13px; font-weight: 600; line-height: 1.6;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
}
.cl-n::after { content: " "; } /* a word break for copy and paste */
.clauses strong, .clauses b { color: var(--text); font-weight: 600; }

.alpha { display: grid; gap: 8px; margin: 12px 0; }
.alpha > li { position: relative; padding-left: 34px; }
.al-n {
  position: absolute; left: 0;
  color: var(--faint); font-weight: 500;
}

.bullets { display: grid; gap: 8px; margin: 12px 0; }
.bullets > li { position: relative; padding-left: 24px; }
.bullets > li::before {
  /* a tiny block, nodding to the logo */
  content: ""; position: absolute; left: 4px; top: .72em;
  width: 7px; height: 7px; border-radius: 2px;
  background: var(--accent);
  transform: rotate(45deg);
  opacity: .8;
}

.doc a:not(.anchor):not(.contact-mail) {
  color: var(--accent-2);
  text-decoration: underline;
  text-decoration-color: rgba(94, 200, 248, .35);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color .2s, text-decoration-color .2s;
}
.doc a:not(.anchor):not(.contact-mail):hover { color: var(--accent); text-decoration-color: var(--accent); }

/* Definitions */
.defs {
  margin-top: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.defs > div {
  display: grid; grid-template-columns: 180px 1fr; gap: 16px;
  padding: 14px 18px;
  background: var(--surface);
}
.defs > div + div { border-top: 1px solid var(--border); }
.defs dt { color: var(--text); font-weight: 600; font-size: 15px; }
.defs dd { font-size: 15px; line-height: 1.65; }

/* Callouts */
.callout {
  display: flex; gap: 14px; align-items: flex-start;
  margin-top: 14px;
  padding: 16px 18px;
  border-radius: 14px;
  font-size: 15px; line-height: 1.65;
}
.callout .ic { width: 20px; height: 20px; margin-top: 1px; }
.callout.official {
  background: rgba(94, 200, 248, .06);
  border: 1px solid rgba(94, 200, 248, .22);
  color: var(--accent-2);
}
.callout.official p { font-weight: 600; font-size: 13.5px; letter-spacing: .03em; }
.callout.warn {
  margin-top: 26px;
  background: var(--warn-soft);
  border: 1px solid rgba(242, 194, 90, .25);
  color: #ead9b0;
}
.callout.warn .ic { color: var(--warn); }
.callout.warn b { color: #fbe7b4; }

/* Contact */
.contact-card {
  margin-top: 22px;
  display: flex; gap: 20px; align-items: flex-start;
  padding: 28px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 0% 0%, rgba(94, 200, 248, .12), transparent 55%),
    linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid rgba(94, 200, 248, .2);
}
.contact-ic {
  width: 48px; height: 48px; flex: none; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, #7dd4fb, var(--accent));
  color: var(--accent-ink);
  box-shadow: 0 12px 30px -10px rgba(94, 200, 248, .6);
}
.contact-ic .ic { width: 22px; height: 22px; }
.contact-body p { color: var(--doc-text); font-size: 16px; line-height: 1.65; }
.contact-mail {
  display: inline-block; margin-top: 12px;
  font-size: clamp(18px, 2.2vw, 22px); font-weight: 700; letter-spacing: -.02em;
  color: var(--text);
  border-bottom: 2px solid rgba(94, 200, 248, .45);
  transition: border-color .2s, color .2s;
  overflow-wrap: anywhere;
}
.contact-mail:hover { color: var(--accent-2); border-color: var(--accent); }
.contact-body small { display: block; margin-top: 12px; font-size: 13.5px; color: var(--faint); }

/* Version history */
.table-scroll { margin-top: 12px; overflow-x: auto; border-radius: 14px; }
.table-scroll:focus-visible { outline-offset: 2px; }
.history-title { margin-top: 40px; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.history {
  width: 100%; min-width: 420px;
  border-collapse: separate; border-spacing: 0;
  font-size: 14.5px;
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
}
.history th, .history td { text-align: left; padding: 12px 16px; }
.history th {
  font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--faint); background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.history td { color: var(--doc-text); background: var(--bg-elev); }
.history td:first-child { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Back to top + toast ---------- */
.back-top {
  position: fixed; right: 24px; bottom: 24px; z-index: 40;
  width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center;
  background: rgba(21, 29, 38, .85);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .8);
  opacity: 0; visibility: hidden; transform: translateY(12px); pointer-events: none;
  transition: opacity .25s, transform .25s var(--ease), border-color .2s, color .2s, visibility 0s linear .25s;
}
.back-top.show { opacity: 1; visibility: visible; transform: none; pointer-events: auto; transition-delay: 0s; }
.back-top:hover { color: var(--accent); border-color: rgba(94, 200, 248, .4); }
.back-top .ic { width: 20px; height: 20px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 70;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, .8);
  font-size: 14px; font-weight: 600;
  opacity: 0; transform: translate(-50%, 12px); pointer-events: none;
  transition: opacity .25s, transform .25s var(--ease);
}
.toast .ic { color: var(--accent); width: 17px; height: 17px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .legal-layout { grid-template-columns: 220px minmax(0, 1fr); gap: 48px; }
}

@media (max-width: 960px) {
  .legal-deco { display: none; }
  .legal-layout { grid-template-columns: 1fr; gap: 0; padding-top: 40px; }

  /* TOC becomes a sticky "On this page" bar */
  .toc {
    top: var(--nav-h);
    z-index: 30;
    max-height: none; overflow: visible;
    margin: 0 -24px 32px;
    padding: 10px 24px;
    background: rgba(8, 11, 15, .86);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border-bottom: 1px solid var(--border);
  }
  .toc-title { display: none; }
  .toc-toggle {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    text-align: left;
  }
  .toc-toggle-label {
    flex: none;
    font-size: 11.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
    color: var(--faint);
  }
  .toc-current {
    flex: 1; min-width: 0;
    font-size: 14.5px; font-weight: 600; line-height: 1.35;
  }
  .toc-toggle .ic { width: 18px; height: 18px; color: var(--muted); transition: transform .25s var(--ease); }
  .toc.open .toc-toggle .ic { transform: rotate(180deg); }

  .toc ol {
    position: absolute; left: 24px; right: 24px; top: calc(100% - 4px);
    max-height: min(60vh, 480px); overflow-y: auto;
    padding: 8px;
    border-radius: 14px;
    background: rgba(16, 22, 29, .98);
    border: 1px solid var(--border-strong);
    box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .9);
    opacity: 0; visibility: hidden; transform: translateY(-6px); pointer-events: none;
    transition: opacity .2s, transform .2s var(--ease), visibility 0s linear .2s;
  }
  .toc.open ol { opacity: 1; visibility: visible; transform: none; pointer-events: auto; transition-delay: 0s; }
  .toc a { border-left: 0; border-radius: 9px; padding: 10px 12px; font-size: 15px; }
  .toc a.active { background: var(--accent-soft); }

  .doc { max-width: none; }
  .doc section { scroll-margin-top: calc(var(--nav-h) + 84px); }
  html { scroll-padding-top: calc(var(--nav-h) + 84px); } /* nav + sticky "On this page" bar */
}

@media (max-width: 760px) {
  .legal-hero { padding: 116px 0 48px; }
  .summary-wrap { margin-top: 36px; }
  .summary { padding: 26px 22px; border-radius: 20px; }
  .summary-grid { grid-template-columns: 1fr; gap: 22px; }
  .doc section { padding: 40px 0; }
  .clauses > li { padding-left: 0; padding-top: 24px; }
  .cl-n { top: 0; }
  .tldr { flex-direction: column; gap: 4px; }
  .defs > div { grid-template-columns: 1fr; gap: 2px; }
  .contact-card { flex-direction: column; padding: 22px; }
  .anchor { opacity: .6; }
  .back-top { right: 16px; bottom: 16px; }
}

@media (max-width: 420px) {
  .toc { margin-inline: -16px; padding-inline: 16px; }
  .toc ol { left: 16px; right: 16px; }
  .legal-actions .btn { flex: 1 1 100%; }
}

/* ---------- Print ---------- */
@media print {
  @page { margin: 18mm 16mm; }
  :root { --doc-text: #222; }
  html, body { background: #fff !important; color: #111 !important; }
  body { font-size: 11pt; }
  .nav, .read-progress, .toc, .back-top, .toast, .legal-actions, .hero-bg,
  .legal-hero::after, .anchor, .footer-links, .motion-toggle, .summary::before { display: none !important; }
  .legal-hero { padding: 0 0 16pt; }
  .legal-hero h1, .doc h2, .summary-head h2, .history-title { color: #000; }
  .crumbs, .legal-lead, .legal-meta li, .summary-head p, .summary-grid p { color: #444 !important; }
  .legal-meta li, .summary, .tldr, .defs, .defs > div, .callout, .contact-card, .history th, .history td {
    background: none !important; border-color: #ccc !important; color: #222 !important; box-shadow: none !important;
  }
  .summary { border: 1px solid #ccc; padding: 14pt; }
  .summary-wrap { margin-top: 0; }
  .s-ic, .sec-n, .contact-ic { background: none !important; border: 1px solid #999 !important; color: #000 !important; box-shadow: none !important; }
  .legal-layout { display: block; padding-top: 20pt; }
  .doc { max-width: none; }
  .doc section { padding: 18pt 0; border-color: #ddd; }
  .clauses strong, .clauses b, .tldr > span, .defs dt, .contact-mail, .callout b { color: #000 !important; }
  .cl-n, .al-n { color: #555; }
  .clauses > li, .alpha > li, .defs > div, .callout { break-inside: avoid; }
  .doc h2 { break-after: avoid; }
  .doc a:not(.anchor)[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555; word-break: break-all; }
  .doc a { color: #000 !important; }
  .footer { margin-top: 20pt; padding: 12pt 0 0; border-color: #ddd; }
  .footer .brand { color: #000; }
  .legal { color: #555; }
  .js .reveal { opacity: 1 !important; transform: none !important; }
}
