/*
 * Quisco legal pages — privacy policy, cookie policy, terms and conditions.
 *
 * These three documents are static files in `public/`, outside Next.js and
 * therefore outside PandaCSS: nothing here can read a token at build time. Every
 * value below is copied from the design system by hand, and each block says
 * where from, so the two can be compared when a token changes:
 *
 *   colours   apps/webapp/quisco-ui/panda-config/colors.ts
 *   spacing   apps/webapp/quisco-ui/panda-config/spacing.ts
 *   type      apps/webapp/quisco-ui/panda-config/typography.ts
 *   shadows   apps/webapp/quisco-ui/panda-config/shadows.ts
 *   widths    apps/webapp/quisco-ui/components/PageContainer/PageContainer.tsx
 *
 * The theme class on <html> is the same `light`/`dark` the app sets, so a page
 * opened from the footer keeps whatever the reader already chose.
 */

/* ── tokens ─────────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;

  --surface0: #fafafa;
  --surface1: #ffffff;
  --surface-muted: #f1f0ed;
  --surface-footer: #fcfcfb;
  --on-surface: #000000;
  --overlay1: #0000001a;
  --overlay3: #00000054;
  --overlay5: #00000080;
  --action: #2c73ff;
  --action-highlight: #2c73ff1a;
  --shadow: #e6e7eb;
  /* Link colour: `action` reads well on white, but the same blue on the dark
     card is under 4.5:1, so dark mode borrows `color1`, which is the token the
     app already uses for blue that has to stay readable on a dark surface. */
  --link: #2c73ff;

  --elevation-card: 0 12px 40px -22px rgba(21, 25, 28, 0.22);

  /* spacing: xs 4, sm 8, md 12, lg 16, xl 24, 2xl 32, 3xl 40, 4xl 48, 6xl 64 */
  --header-height: 64px;
  --page-max: 1280px;
  /* Narrower than the app's container on purpose: a legal document is read
     line by line, and 1280px of running text is not. */
  --reading-max: 860px;

  /* The system stack, not the app's Poppins. These six files are served
     straight from `public/`, so a brand typeface here would mean either a
     third-party request on a cookie notice or a second copy of the font in the
     repo — neither is worth it for three documents nobody reads for the
     typography. The reader gets the face their OS renders text in best. */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

html.dark {
  color-scheme: dark;

  --surface0: #000000;
  --surface1: #171c1f;
  --surface-muted: #ffffff14;
  --surface-footer: #1c2226;
  --on-surface: #ffffff;
  --overlay1: #ffffff1a;
  --overlay3: #ffffff54;
  --overlay5: #ffffff80;
  --action: #2c73ff;
  --action-highlight: #9cbdff1a;
  --shadow: #9090901a;
  --link: #b7d7fa;
}

/* ── reset ──────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--surface0);
  color: var(--on-surface);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

/* Every anchor target clears the sticky header when jumped to. */
[id] {
  scroll-margin-top: calc(var(--header-height) + 24px);
}

/* ── layout ─────────────────────────────────────────────────────────────── */
.legal-container {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: 16px;
}

@media (min-width: 768px) {
  .legal-container {
    padding-inline: 24px;
  }
}

.legal-skip {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 12px 16px;
  border-radius: 0 0 12px 0;
  background: var(--action);
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  z-index: 20;
}

.legal-skip:focus {
  left: 0;
}

/* ── header ─────────────────────────────────────────────────────────────── */
.legal-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--shadow);
  /* The app header's frosted plate, same recipe as widgets/Header. */
  background: color-mix(in srgb, var(--surface1) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}

.legal-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--header-height);
}

.legal-logo {
  display: block;
  flex: none;
  color: var(--on-surface);
  --legal-logo-bg: var(--surface1);
}

.legal-logo svg {
  display: block;
}

.legal-header__right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.legal-nav {
  display: none;
  align-items: center;
  gap: 4px;
}

@media (min-width: 992px) {
  .legal-nav {
    display: flex;
  }
}

.legal-nav a {
  padding: 8px 12px;
  border-radius: 9999px;
  color: var(--overlay5);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.legal-nav a:hover {
  background: var(--surface-muted);
  color: var(--on-surface);
}

.legal-nav a[aria-current="page"] {
  background: var(--action-highlight);
  color: var(--link);
}

/* The locale pair, as a segmented control on the app's inset track. */
.legal-locale {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 9999px;
  background: var(--surface-muted);
}

.legal-locale a {
  padding: 6px 10px;
  border-radius: 9999px;
  color: var(--overlay5);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-decoration: none;
  text-transform: uppercase;
}

.legal-locale a:hover {
  color: var(--on-surface);
}

.legal-locale a[aria-current="true"] {
  background: var(--surface1);
  color: var(--on-surface);
}

/* ── document ───────────────────────────────────────────────────────────── */
.legal-main {
  padding-block: 32px 64px;
}

@media (min-width: 768px) {
  .legal-main {
    padding-block: 48px 96px;
  }
}

.legal-doc {
  max-width: var(--reading-max);
  margin-inline: auto;
  padding: 24px;
  border: 1px solid var(--shadow);
  border-radius: 24px;
  background: var(--surface1);
  box-shadow: var(--elevation-card);
}

@media (min-width: 768px) {
  .legal-doc {
    padding: 48px 56px;
  }
}

.legal-doc__title {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

@media (min-width: 768px) {
  .legal-doc__title {
    font-size: 32px;
  }
}

.legal-doc__meta {
  margin: 8px 0 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--shadow);
  color: var(--overlay5);
  font-size: 14px;
  line-height: 1.5;
}

.legal-doc h2 {
  margin: 40px 0 12px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}

.legal-doc h3 {
  margin: 28px 0 8px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}

.legal-doc h2:first-child,
.legal-doc h3:first-child {
  margin-top: 0;
}

.legal-doc p,
.legal-doc li {
  /* 1.7 rather than the `normal` 1.5: the design system's line heights are set
     for interface text, and this is several thousand words of running prose. */
  font-size: 16px;
  line-height: 1.7;
}

.legal-doc p {
  margin: 0 0 16px;
}

.legal-doc ul {
  margin: 0 0 16px;
  padding-left: 24px;
}

.legal-doc li {
  margin-bottom: 8px;
}

.legal-doc li:last-child {
  margin-bottom: 0;
}

.legal-doc strong {
  font-weight: 600;
}

.legal-doc a {
  color: var(--link);
  text-decoration: none;
  word-break: break-word;
}

.legal-doc a:hover {
  text-decoration: underline;
}

.legal-doc > :last-child {
  margin-bottom: 0;
}

/* ── table of contents ──────────────────────────────────────────────────── */
.legal-toc {
  margin: 0 0 16px;
}

.legal-toc ul {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 768px) {
  .legal-toc ul {
    grid-template-columns: 1fr 1fr;
    column-gap: 16px;
  }
}

.legal-toc li {
  margin: 0;
}

/* Full-strength text rather than the muted link colour: this is a list of
   fifteen section names, and it has to be readable, not decorative. */
.legal-doc .legal-toc__link {
  display: block;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--on-surface);
  font-size: 14px;
  line-height: 1.4;
}

.legal-doc .legal-toc__link:hover {
  background: var(--surface-muted);
  text-decoration: none;
}

/* ── footer ─────────────────────────────────────────────────────────────── */
.legal-footer {
  border-top: 1px solid var(--shadow);
  background: var(--surface-footer);
  padding-block: 32px;
}

.legal-footer__inner {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (min-width: 768px) {
  .legal-footer__inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.legal-footer__brand {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.legal-footer__brand .legal-logo {
  --legal-logo-bg: var(--surface-footer);
}

.legal-footer__tagline {
  margin: 0;
  color: var(--overlay5);
  font-size: 14px;
  line-height: 1.5;
}

.legal-footer__links {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 768px) {
  .legal-footer__links {
    align-items: flex-end;
  }
}

.legal-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}

.legal-footer nav a {
  color: var(--overlay5);
  font-size: 14px;
  line-height: 1.2;
  text-decoration: none;
}

.legal-footer nav a:hover {
  color: var(--on-surface);
}

.legal-footer__copy {
  margin: 0;
  color: var(--overlay3);
  font-size: 12px;
  line-height: 1.2;
}

/* ── print ──────────────────────────────────────────────────────────────── */
@media print {
  .legal-header,
  .legal-footer,
  .legal-skip {
    display: none;
  }

  .legal-doc {
    max-width: none;
    padding: 0;
    border: 0;
    box-shadow: none;
  }
}
