/*
 * Tinkrite legal documents — privacy policy and terms of service.
 *
 * The --tk-* palette is NOT declared here. It lives in ../../assets/tokens.css, which both pages
 * link immediately before this file, so these documents read as a continuation of the app without
 * carrying their own copy of the colours. Never paste token values back into this file: the point
 * of the split is that tinkrite.com has exactly one palette, shared with the landing page.
 *
 * TYPEFACE is the deliberate exception, which is why --tk-font is set below rather than in
 * tokens.css. The app's Baloo 2 is NOT used here. These are legal documents: a plain, familiar
 * face reads better over long prose than a rounded display font, and using the system UI font
 * means there is no font file to download at all — no @font-face, no WOFF2, nothing that could be
 * mistaken for a third-party request on a page whose section 2 promises none. The landing page is
 * brand surface rather than prose, so it does use Baloo 2, self-hosted from ../../assets/fonts/.
 *
 * Everything is relative and self-contained. No CDN, no script, no analytics, no web font — a
 * privacy policy that phoned a third party to render itself would refute its own section 2.
 */

/* ----------------------------------------------------------- local vars --
 * Everything else comes from tokens.css. Only the typeface differs, for the reason above.
 */
:root {
  --tk-font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

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

/* Anchor links from the contents list must not land with the heading jammed against the
   viewport edge, and must not fight a reader who prefers no motion. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  padding: var(--tk-space-xxl) var(--tk-space-lg) var(--tk-space-huge);
  background-color: var(--tk-background);
  color: var(--tk-text-primary);
  font-family: var(--tk-font);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.tk-skip {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: var(--tk-space-sm) var(--tk-space-lg);
  background: var(--tk-surface);
  border-radius: var(--tk-radius-md);
  box-shadow: var(--tk-shadow-card);
  font-weight: 700;
}

.tk-skip:focus {
  left: var(--tk-space-lg);
  top: var(--tk-space-lg);
  z-index: 10;
}

/* --------------------------------------------------------------- header --
 * login.tsx renders the mark above the wordmark; here they sit on one line so the document
 * title stays high on the page.
 */
.tk-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--tk-space-lg);
  width: 100%;
  max-width: var(--tk-measure);
  margin: 0 auto var(--tk-space-xl);
}

.tk-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--tk-space-md);
  text-decoration: none;
}

.tk-brand-mark {
  width: 44px;
  height: 44px;
  display: block;
  flex: none;
  /* ../../assets/icon.svg is the app icon, full-bleed square: the stores mask it, the web has to
     round it itself. Same 22% the landing pages use, so the mark is one shape across the site. */
  border-radius: 22%;
}

/* The app's wordmark, in the app's colour. Tracking is only slightly negative: login.tsx pulls
   Baloo in by 1px because its rounded forms sit loose, which a normal UI font does not. */
.tk-brand-name {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.4px;
  color: var(--tk-primary);
}

/* ----------------------------------------------------------------- card --
 * DictationCard.tsx: white, radius 28, warm card shadow.
 */
.tk-doc {
  max-width: var(--tk-measure);
  margin: 0 auto;
  padding: var(--tk-space-xxxl);
  background-color: var(--tk-surface);
  border-radius: var(--tk-radius-xxl);
  box-shadow: var(--tk-shadow-card);
}

/* ------------------------------------------------------------ typography -- */
h1,
h2,
h3 {
  color: var(--tk-text-primary);
  /* Only a hair of negative tracking: a UI font at heading sizes needs far less pulling in than
     the app's rounded display face does. */
  letter-spacing: -0.2px;
  text-wrap: balance;
}

/* typography.ts titleLarge, scaled up: this is a document title, not a section heading. */
h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
}

h2 {
  margin: var(--tk-space-huge) 0 var(--tk-space-md);
  padding-top: var(--tk-space-xl);
  border-top: 2px solid var(--tk-primary-light);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}

/* The rule above a heading is a separator between sections, so the first one has nothing to
   separate from. */
.tk-doc > h2:first-of-type {
  border-top: 0;
  padding-top: 0;
}

h3 {
  margin: var(--tk-space-xxl) 0 var(--tk-space-sm);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
}

p,
li {
  /* textPrimary, not textSecondary: on a document the prose IS the content, and secondary
     would render the whole page as a caption. */
  color: var(--tk-text-primary);
}

p {
  margin: 0 0 var(--tk-space-lg);
}

ul,
ol {
  margin: 0 0 var(--tk-space-lg);
  padding-inline-start: var(--tk-space-xxl);
}

li {
  margin-bottom: var(--tk-space-sm);
}

li::marker {
  color: var(--tk-primary);
}

strong {
  font-weight: 700;
}

/* typography.ts caption — the effective date under the title. */
.tk-meta {
  margin: var(--tk-space-sm) 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--tk-text-secondary);
}

.tk-lede {
  margin-top: var(--tk-space-xl);
  font-size: 17px;
  color: var(--tk-text-secondary);
}

hr {
  height: 0;
  margin: var(--tk-space-xxl) 0;
  border: 0;
  border-top: 1px solid var(--tk-border);
}

a {
  color: var(--tk-primary);
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--tk-radius-sm);
}

a:hover {
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--tk-primary);
  outline-offset: 2px;
}

/* -------------------------------------------------------------- contents -- */
.tk-toc {
  margin: var(--tk-space-xxl) 0 0;
  padding: var(--tk-space-xl) var(--tk-space-xxl);
  background-color: var(--tk-border-light);
  border-radius: var(--tk-radius-lg);
}

.tk-toc h2 {
  margin: 0 0 var(--tk-space-md);
  padding-top: 0;
  border-top: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--tk-text-secondary);
}

.tk-toc ol {
  margin: 0;
  padding-inline-start: var(--tk-space-xl);
  columns: 2;
  column-gap: var(--tk-space-xxl);
}

.tk-toc li {
  margin-bottom: var(--tk-space-xs);
  /* Keep a wrapped entry from splitting across the column break. */
  break-inside: avoid;
}

.tk-toc a {
  font-weight: 600;
  color: var(--tk-text-primary);
}

.tk-toc a:hover {
  color: var(--tk-primary);
}

/* --------------------------------------------------------------- tables --
 * Both documents lean on tables heavily (the data inventory, the recipients, the retention
 * periods). The wrapper is what keeps a wide table from widening the PAGE on a narrow phone:
 * the table scrolls inside its own box and the body never scrolls sideways.
 */
.tk-table-wrap {
  overflow-x: auto;
  margin: 0 0 var(--tk-space-xl);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius-lg);
  /* Announce that this region is scrollable, and make it keyboard-reachable. */
  -webkit-overflow-scrolling: touch;
}

.tk-table-wrap:focus-visible {
  outline: 2px solid var(--tk-primary);
  outline-offset: 2px;
}

table {
  width: 100%;
  min-width: 34rem;
  border-collapse: collapse;
  font-size: 15px;
}

caption {
  padding: var(--tk-space-md) var(--tk-space-lg);
  border-bottom: 1px solid var(--tk-border);
  background-color: var(--tk-surface);
  color: var(--tk-text-secondary);
  font-size: 13px;
  font-weight: 700;
  text-align: start;
}

th,
td {
  padding: var(--tk-space-md) var(--tk-space-lg);
  text-align: start;
  vertical-align: top;
}

thead th {
  background-color: var(--tk-primary-light);
  color: var(--tk-text-primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr + tr th,
tbody tr + tr td {
  border-top: 1px solid var(--tk-border);
}

tbody th {
  font-weight: 700;
}

/* ---------------------------------------------------------- placeholders --
 * Unfilled [[TOKEN]] values. Highlighted so one cannot reach production unnoticed — this is a
 * legal document, and "[[COMPANY_NAME]]" published as the controller's name is worse than a
 * broken layout. Kept visible in print for the same reason.
 */
.tk-todo {
  padding: 1px 6px;
  border-radius: var(--tk-radius-sm);
  background-color: var(--tk-yellow-surface);
  color: var(--tk-yellow-text);
  font-weight: 700;
  /* Deliberately NOT white-space: nowrap: [[HOSTING_PROVIDER_ADDRESS]] is ~29 characters of
     bold text, wider than a narrow phone's column and wider than some table cells, so keeping
     it unbreakable would widen its container rather than wrap. Breaking a placeholder across
     two lines is ugly for as long as it is unfilled, and correct for that whole time. */
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------- legal notices --
 * The LCEN art. 6-III identity block: label/value pairs, so a <dl> rather than a table. Two
 * columns on a wide viewport, stacked below it.
 */
.tk-legal {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--tk-space-sm) var(--tk-space-xl);
  margin: 0;
  padding: var(--tk-space-xl) var(--tk-space-xxl);
  background-color: var(--tk-border-light);
  border-radius: var(--tk-radius-lg);
}

.tk-legal dt {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--tk-text-secondary);
  /* Nudge the label onto the same baseline as its value, which is 16px. */
  padding-top: 3px;
}

.tk-legal dd {
  margin: 0;
  color: var(--tk-text-primary);
}

@media (max-width: 600px) {
  .tk-legal {
    grid-template-columns: 1fr;
    gap: 0;
    padding: var(--tk-space-lg);
  }

  .tk-legal dd {
    margin-bottom: var(--tk-space-lg);
  }

  .tk-legal dd:last-child {
    margin-bottom: 0;
  }
}

/* ----------------------------------------------------------------- note -- */
.tk-note {
  margin: 0 0 var(--tk-space-xl);
  padding: var(--tk-space-lg) var(--tk-space-xl);
  border: 1px solid var(--tk-border);
  border-inline-start: 4px solid var(--tk-primary);
  border-radius: var(--tk-radius-lg);
  background-color: var(--tk-primary-light);
}

.tk-note > :last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------- footer -- */
.tk-footer {
  max-width: var(--tk-measure);
  margin: var(--tk-space-xxl) auto 0;
  padding: 0 var(--tk-space-xxxl);
  color: var(--tk-text-secondary);
  font-size: 14px;
  text-align: center;
}

.tk-footer p {
  margin: 0 0 var(--tk-space-xs);
  color: inherit;
}

/* ----------------------------------------------------------- responsive -- */
@media (max-width: 600px) {
  body {
    padding: var(--tk-space-lg) var(--tk-space-md) var(--tk-space-xxxl);
  }

  .tk-doc {
    padding: var(--tk-space-xl);
    border-radius: var(--tk-radius-xl);
  }

  .tk-footer {
    padding: 0 var(--tk-space-lg);
  }

  h1 {
    font-size: 26px;
  }

  h2 {
    font-size: 20px;
    margin-top: var(--tk-space-xxxl);
  }

  .tk-brand-name {
    font-size: 26px;
  }

  .tk-brand-mark {
    width: 36px;
    height: 36px;
  }

  /* Two columns of contents in ~300px is unreadable. */
  .tk-toc ol {
    columns: 1;
  }

  .tk-toc {
    padding: var(--tk-space-lg);
  }
}

/* --------------------------------------------------------------- print --
 * Legal documents get printed and filed. Drop the app's surface treatment, which only costs
 * ink, and let the tables use the full page.
 */
@media print {
  body {
    padding: 0;
    background: #fff;
    color: #000;
    font-size: 11pt;
    line-height: 1.5;
  }

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

  .tk-header,
  .tk-footer {
    max-width: none;
    padding: 0;
  }

  /* Navigation is meaningless on paper; the contents list has no page numbers to point at. */
  .tk-toc,
  .tk-skip {
    display: none;
  }

  /* The class selectors are not redundant: .tk-lede and .tk-meta set a colour by class, which
     outspecifies a bare element selector, so without them the opening paragraph and the
     effective date print as low-contrast grey. */
  h1,
  h2,
  h3,
  p,
  li,
  th,
  td,
  caption,
  .tk-lede,
  .tk-meta,
  .tk-footer,
  .tk-footer p,
  .tk-legal dt,
  .tk-legal dd {
    color: #000;
  }

  /* Flat on paper — the tinted panels only cost ink. */
  .tk-legal,
  .tk-note {
    background: none;
    border: 1px solid #999;
  }

  h2,
  h3 {
    /* Never leave a heading stranded at the foot of a page. */
    break-after: avoid;
    page-break-after: avoid;
  }

  .tk-table-wrap {
    overflow: visible;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  table {
    min-width: 0;
  }

  thead th {
    background: #eee;
  }

  /* An unfilled placeholder must be as obvious on paper as on screen. */
  .tk-todo {
    background: #ffe9a8;
    color: #000;
    border: 1px solid #000;
  }

  /* A printed document loses its hyperlinks, so spell the destination out. */
  a[href^='http']::after {
    content: ' (' attr(href) ')';
    font-weight: 400;
    font-size: 0.9em;
  }
}
