/* Shared styling for the Termly-embedded legal pages (imprint.html, privacy.html).
   Same token approach as index.html: one value per token, light-dark() flips it,
   the plain value above it keeps older browsers on the light palette. */

:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --bg: light-dark(#ffffff, #000000);
  --text: #0b0b0c;
  --text: light-dark(#0b0b0c, #f5f5f7);
  --muted: #6e6e73;
  --muted: light-dark(#6e6e73, #a1a1a6);
  --faint: #8e8e93;
  --faint: light-dark(#8e8e93, #7c7c82);
  --line: rgba(0, 0, 0, 0.09);
  --line: light-dark(rgba(0, 0, 0, 0.09), rgba(255, 255, 255, 0.11));
  --tint: #f5f5f7;
  --tint: light-dark(#f5f5f7, #1a1a1d);

  --ease: cubic-bezier(.2, .8, .25, 1);
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
}

/* ---------- Theme toggle ---------- */

/* 44px is Apple's minimum tap target. Kept in sync with index.html. */
.theme-toggle {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 14px);
  right: 14px;
  z-index: 30;
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color .18s var(--ease), background .18s var(--ease), transform .18s var(--ease);
}

.theme-toggle:active { transform: scale(.92); }
.theme-toggle:hover { color: var(--text); background: var(--tint); }
.theme-toggle svg { width: 20px; height: 20px; display: block; }

:root[data-theme="dark"] .ic-moon,
:root:not([data-theme="dark"]) .ic-sun { display: none; }

@media (prefers-reduced-motion: reduce) {
  .theme-toggle { transition-duration: .01ms; }
}

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

.wrap {
  flex: 1;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  /* Matches the toggle's offset so the back pill and the toggle sit on one line. */
  padding: calc(env(safe-area-inset-top) + 14px) 24px 0;
}

/* Same 44px tap height as the theme toggle it sits next to. */
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin-bottom: 26px;
  padding: 0 17px 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 550;
  letter-spacing: -0.008em;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: color .18s var(--ease), background .18s var(--ease);
}

.back:hover { color: var(--text); background: var(--tint); }

.back svg { width: 16px; height: 16px; flex: none; }

/* ---------- Termly embed ---------- */

.embed {
  font-size: 15px;
  overflow-wrap: break-word;
}

/* Termly ships its own inline colours; neutralise them so the page stays
   readable in dark mode and consistent with the landing page. */
.embed,
.embed :where(p, li, td, th, span, div, h1, h2, h3, h4, h5, h6, strong, b, em) {
  color: var(--text) !important;
  background: transparent !important;
  font-family: inherit !important;
}

.embed :where(h1, h2, h3, h4) {
  line-height: 1.25;
  letter-spacing: -0.018em;
  margin-top: 1.8em;
}

.embed h1 { font-size: 26px; margin-top: 0; }
.embed h2 { font-size: 20px; }
.embed h3 { font-size: 17px; }

.embed a {
  color: var(--text) !important;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--faint);
}

.embed :where(table) {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.embed :where(td, th) {
  border: 1px solid var(--line) !important;
  padding: 8px 10px;
  vertical-align: top;
}

.embed :where(img, svg) { max-width: 100%; height: auto; }

/* Placeholder shown until Termly's script swaps in the real content.
   General sibling, not adjacent: Termly's <script> tag sits between the two. */
.loading {
  color: var(--faint);
  font-size: 15px;
  padding: 8px 0;
}

.embed:not(:empty) ~ .loading { display: none; }

/* ---------- Footer ---------- */

footer {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 48px 24px calc(env(safe-area-inset-bottom) + 32px);
  text-align: center;
}

.legal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  letter-spacing: -0.005em;
}

.legal a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 2px;
  -webkit-tap-highlight-color: transparent;
}

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

.legal [aria-current="page"] { color: var(--text); }

.legal .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--line);
}

.copyright {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--faint);
}
