/* The footer comes from the shared shell (same footer as the landing page and apps). */
/* Tokens and the self-hosted brand fonts. The pages are hashed legal
   documents, so the fonts load from here instead of a preload tag. */
@import url("/shared/cryex-theme.css");
@import url("/shared/cryex-shell.css");

/*
 * Legal pages (/terms, /privacy). Their HTML is hashed (server/app.js), so
 * layout changes happen here only. The pages cannot set data-theme="light",
 * so the light content tokens are pinned here; this selector wins over the
 * theme's dark-mode block by source order.
 */
:root:not([data-theme="dark"]) {
  color-scheme: light;
  --cx-canvas: #f4f6f8;
  --cx-surface: #ffffff;
  --cx-surface-muted: #e9edf2;
  --cx-border: #d5dbe3;
  --cx-ink: #0b1220;
  --cx-ink-muted: #4a5568;
  --cx-accent-ink: #4a7a00;
  --cx-danger: #b42318;
  --cx-focus: #0b1220;
}

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

html {
  scroll-behavior: smooth;
}

body {
  min-width: 280px;
  margin: 0;
  background: var(--cx-surface);
  color: var(--cx-ink);
  font: var(--cx-weight-regular) var(--cx-text-md) / 1.7 var(--cx-font-sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--cx-accent-ink);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--cx-ink);
}

a:focus-visible {
  border-radius: 4px;
  outline: none;
  box-shadow: var(--cx-focus-ring);
}

.skip-link {
  position: fixed;
  z-index: var(--cx-z-toast);
  top: 12px;
  left: 12px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--cx-radius);
  background: var(--cx-brand-ink);
  color: var(--cx-text);
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: none;
}

/* One page width, matching the shared footer, so header, title, contents
   and footer share a left edge. */
.legal-header__inner,
.legal-hero__inner,
.legal-layout {
  width: min(1180px, calc(100% - 2 * var(--cx-space-4)));
  margin-inline: auto;
}

/* ---- Header ---- */

.legal-header {
  border-bottom: 1px solid var(--cx-border);
  background: var(--cx-surface);
}

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

.legal-brand {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
}

.legal-brand img {
  display: block;
  width: auto;
  height: 28px;
}

.legal-home {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 0 var(--cx-space-4);
  border: 1px solid var(--cx-border);
  border-radius: var(--cx-radius);
  color: var(--cx-ink);
  font-size: var(--cx-text-sm);
  font-weight: var(--cx-weight-bold);
  text-decoration: none;
}

.legal-home:hover {
  border-color: var(--cx-ink-faint);
}

/* ---- Title block ---- */

.legal-hero {
  border-bottom: 1px solid var(--cx-border);
  background: var(--cx-canvas);
}

.legal-hero__inner {
  padding-block: var(--cx-space-8) var(--cx-space-7);
}

.eyebrow {
  margin: 0 0 var(--cx-space-3);
  color: var(--cx-accent-ink);
  font-size: var(--cx-text-xs);
  font-weight: var(--cx-weight-heavy);
  letter-spacing: var(--cx-tracking-caps);
  text-transform: uppercase;
}

h1,
h2,
h3 {
  color: var(--cx-ink);
  font-family: var(--cx-font-display);
  font-weight: var(--cx-weight-bold);
  letter-spacing: var(--cx-tracking-tight);
}

h1 {
  margin: 0;
  font-size: clamp(2.25rem, 6vw, 3.5rem);
  line-height: 1.05;
}

.legal-summary {
  max-width: 65ch;
  margin: var(--cx-space-4) 0 0;
  color: var(--cx-ink-muted);
  font-size: var(--cx-text-lg);
  line-height: 1.6;
}

.legal-version {
  margin: var(--cx-space-4) 0 0;
  color: var(--cx-ink-muted);
  font-size: var(--cx-text-sm);
}

/* ---- Contents + article ---- */

.legal-layout {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(0, 72ch);
  gap: clamp(36px, 6vw, 80px);
  padding-block: var(--cx-space-7) var(--cx-space-8);
}

.legal-toc {
  position: sticky;
  top: var(--cx-space-5);
  align-self: start;
}

.legal-toc strong {
  display: block;
  margin-bottom: var(--cx-space-2);
  font-size: 13px;
}

.legal-toc div {
  display: grid;
}

.legal-toc a {
  display: flex;
  min-height: 40px;
  align-items: center;
  padding: 4px var(--cx-space-3);
  border-left: 2px solid var(--cx-border);
  color: var(--cx-ink-muted);
  font-size: 13px;
  font-weight: var(--cx-weight-medium);
  line-height: 1.3;
  text-decoration: none;
}

.legal-toc a:hover {
  border-left-color: var(--cx-accent-ink);
  background: var(--cx-canvas);
  color: var(--cx-ink);
}

.legal-article {
  width: 100%;
  min-width: 0;
  max-width: 72ch;
}

.legal-notice {
  margin: 0 0 var(--cx-space-6);
  padding: var(--cx-space-4) var(--cx-space-5);
  border: 1px solid var(--cx-border);
  border-left: 5px solid var(--cx-accent);
  border-radius: var(--cx-radius-lg);
  background: var(--cx-canvas);
}

.legal-notice strong {
  display: block;
  margin-bottom: var(--cx-space-1);
}

.legal-article section {
  padding-block: var(--cx-space-2) var(--cx-space-5);
  scroll-margin-top: var(--cx-space-5);
}

.legal-article section + section {
  padding-top: var(--cx-space-6);
  border-top: 1px solid var(--cx-border);
}

.legal-article h2 {
  margin: 0 0 var(--cx-space-3);
  font-size: clamp(1.5rem, 3vw, 1.875rem);
  line-height: 1.2;
}

.legal-article h3 {
  margin: var(--cx-space-5) 0 var(--cx-space-2);
  font-size: var(--cx-text-lg);
  line-height: 1.3;
}

.legal-article p {
  margin: 0 0 var(--cx-space-4);
}

.legal-article ul {
  margin: var(--cx-space-2) 0 var(--cx-space-4);
  padding-left: var(--cx-space-5);
}

.legal-article li {
  margin: 6px 0;
  padding-left: var(--cx-space-1);
}

.plain-table {
  width: 100%;
  margin: var(--cx-space-4) 0 var(--cx-space-5);
  border-collapse: collapse;
  font-size: var(--cx-text-sm);
  line-height: 1.55;
}

.plain-table :where(th, td) {
  padding: var(--cx-space-3);
  border: 1px solid var(--cx-border);
  text-align: left;
  vertical-align: top;
}

.plain-table th {
  background: var(--cx-canvas);
  font-weight: var(--cx-weight-bold);
}

.legal-contact {
  padding: var(--cx-space-5);
  border: 1px solid var(--cx-border);
  border-radius: var(--cx-radius-lg);
}

.legal-contact dl {
  display: grid;
  grid-template-columns: minmax(120px, 0.5fr) 1fr;
  gap: var(--cx-space-2) var(--cx-space-4);
  margin: 0;
}

.legal-contact dt {
  color: var(--cx-ink-muted);
  font-weight: var(--cx-weight-bold);
}

.legal-contact dd {
  margin: 0;
}

.not-published {
  color: var(--cx-danger);
  font-weight: var(--cx-weight-bold);
}

/* ---- Mobile: contents become a compact chip list above the text ---- */

@media (max-width: 920px) {
  .legal-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--cx-space-6);
    padding-top: var(--cx-space-5);
  }

  .legal-toc {
    position: static;
  }

  .legal-toc div {
    display: flex;
    flex-wrap: wrap;
    gap: var(--cx-space-2);
  }

  .legal-toc a {
    min-height: 40px;
    padding: 0 var(--cx-space-3);
    border: 1px solid var(--cx-border);
    border-radius: var(--cx-radius-pill);
  }

  .legal-toc a:hover {
    border-color: var(--cx-accent-ink);
  }

  .plain-table {
    display: block;
    overflow-x: auto;
  }

  .legal-contact dl {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .legal-contact dd + dt {
    margin-top: var(--cx-space-3);
  }
}

@media (max-width: 560px) {
  .legal-hero__inner {
    padding-block: var(--cx-space-6) var(--cx-space-5);
  }

  .legal-notice {
    padding: var(--cx-space-4);
  }
}

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