/* The legal pages (privacy-policy, terms-of-service, cookie-policy), styled like pixelbrewer.com.

   These are static pages and they cannot load the app's token bundle, so the values the site uses are
   copied here as custom properties. Source of truth: apps/pixel-brew/src/styles/_site-tokens.scss (the
   light and dark theme aliases) and libs/design-tokens (neutral and primary scales). Change a color
   there first, then here.

   Theme: legal-theme.js sets data-theme from the saved choice (localStorage 'app-theme', the same
   key the site uses). With no saved choice, or no JavaScript, prefers-color-scheme decides. */

@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/inter-latin-var.woff2') format('woff2');
}

@font-face {
  font-family: Gambetta;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/gambetta-400.woff2') format('woff2');
}

:root {
  --font-sans: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: Gambetta, Georgia, 'Times New Roman', serif;
  --measure: 70ch;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --nav-height: 4rem;
  --radius: 0.5rem;
  --motion-hover: 150ms ease;

  /* light theme (the site's light aliases) */
  --color-page: #f9fafb; /* neutral-50 */
  --color-surface: #ffffff;
  --color-text: #111827; /* neutral-900 */
  --color-text-2: #4b5563; /* neutral-600 */
  --color-text-3: #4b5563; /* meta text: neutral-600, the same as the site footer's meta text */
  --color-border: #e5e7eb; /* neutral-200 */
  --color-accent: #1d4ed8; /* primary-700 */
  --color-accent-fill: #2563eb; /* primary-600: the logo accent square */
  --color-dim: #d1d5db; /* neutral-300: the logo's dim square */
  --color-focus: #3b82f6; /* primary-500 */
  color-scheme: light;
}

/* The two dark blocks below must stay identical: one is the system choice, one is the saved choice. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --color-page: #111827;
    --color-surface: #1f2937;
    --color-text: #f9fafb;
    --color-text-2: #d1d5db;
    --color-text-3: #9ca3af;
    --color-border: #374151;
    --color-accent: #60a5fa;
    --color-dim: #4b5563;
    --color-focus: #60a5fa;
    color-scheme: dark;
  }
}

html[data-theme='dark'] {
  --color-page: #111827; /* neutral-900 */
  --color-surface: #1f2937; /* neutral-800 */
  --color-text: #f9fafb;
  --color-text-2: #d1d5db; /* neutral-300 */
  --color-text-3: #9ca3af; /* neutral-400 */
  --color-border: #374151; /* neutral-700 */
  --color-accent: #60a5fa; /* primary-400 */
  --color-dim: #4b5563; /* neutral-600 */
  --color-focus: #60a5fa;
  color-scheme: dark;
}

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

html {
  font-size: 1rem;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-block-size: 100svh;
  background: var(--color-page);
  color: var(--color-text);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--color-accent);
  text-underline-offset: 0.2em;
}

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  inset-block-start: -4rem;
  inset-inline-start: 1rem;
  z-index: 10;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  background: var(--color-text);
  color: var(--color-page);
  font-size: 0.875rem;
  text-decoration: none;
}

.skip-link:focus {
  inset-block-start: 0.75rem;
}

.wrap {
  inline-size: min(80rem, 100% - 2 * var(--gutter));
  margin-inline: auto;
}

/* The header: the site's bar, lifted one step above the page, with the logo and the three pages */
.site-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 5;
  border-block-end: 1px solid var(--color-border);
  background: var(--color-surface);
}

.header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
  min-block-size: var(--nav-height);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  margin-inline-end: auto;
  color: var(--color-text);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  text-decoration: none;
}

.mark {
  inline-size: 1.25rem;
  block-size: 1.25rem;
  fill: var(--color-text);
}

.mark .mark-accent {
  fill: var(--color-accent-fill);
}

.mark .mark-dim {
  fill: var(--color-dim);
}

.legal-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.legal-nav a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  color: var(--color-text-2);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition:
    background-color var(--motion-hover),
    color var(--motion-hover);
}

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

.legal-nav a[aria-current='page'] {
  color: var(--color-text);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.45em;
}

/* The page: one readable column */
main {
  inline-size: min(var(--measure), 100% - 2 * var(--gutter));
  margin-inline: auto;
  padding-block: clamp(3rem, 5vw, 5rem) clamp(4rem, 8vw, 7rem);
}

h1 {
  margin: 0 0 clamp(1.5rem, 3vw, 2.5rem);
  font-family: var(--font-display);
  font-size: clamp(2rem, 2.2vw + 1rem, 3.25rem);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

section {
  margin-block-start: clamp(1.75rem, 3vw, 2.5rem);
}

h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: clamp(1.375rem, 1vw + 1rem, 1.875rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

p {
  margin: 0.75rem 0;
  color: var(--color-text-2);
  font-size: 1rem;
  line-height: 1.6;
}

main footer {
  margin-block-start: clamp(3rem, 6vw, 4.5rem);
  padding-block-start: 1.25rem;
  border-block-start: 1px solid var(--color-border);
}

main footer p {
  margin: 0.25rem 0;
  color: var(--color-text-3);
  font-size: 0.875rem;
}

/* Rich blocks the renderer can emit (libs/legal/renderers/src/lib/html.ts renderBody): subheadings,
   lists, checklists, notes, tables and signature blocks. The site-shell page has no inline <style>, so
   this file styles them. */
h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.3;
}

main ul,
main ol {
  margin: 0.75rem 0;
  padding-inline-start: 1.5rem;
  color: var(--color-text-2);
  line-height: 1.6;
}

main li + li {
  margin-block-start: 0.25rem;
}

.checklist {
  padding-inline-start: 0;
  list-style: none;
}

.checklist li::before {
  content: '\2610';
  margin-inline-end: 0.5rem;
  color: var(--color-text-3);
}

.note {
  padding: 0.75rem 1rem;
  border-inline-start: 4px solid var(--color-accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--color-surface);
}

table {
  inline-size: 100%;
  margin: 1rem 0;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

th,
td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  color: var(--color-text-2);
  text-align: start;
  vertical-align: top;
}

th {
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 600;
}

.signature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 2rem;
  margin-block-start: 2rem;
}

.signature-grid h2 {
  font-size: 1.125rem;
}

.signature-line {
  margin-block-start: 3rem;
  border-block-start: 1px solid var(--color-text);
}

.signature-label {
  margin: 0.25rem 0;
  font-size: 0.875rem;
}

@media (prefers-reduced-motion: reduce) {
  .legal-nav a {
    transition: none;
  }
}

/* Print: black on white, no header, standard sizes. The site colors never reach paper. */
@media print {
  @page {
    margin: 2cm;
  }

  html,
  body {
    background: #ffffff;
    color: #000000;
  }

  body {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 11pt;
    line-height: 1.5;
  }

  .skip-link,
  .site-header {
    display: none;
  }

  main {
    inline-size: auto;
    padding: 0;
  }

  h1,
  h2 {
    color: #000000;
    font-family: inherit;
    font-weight: 700;
    break-after: avoid;
  }

  h1 {
    font-size: 20pt;
    border-block-end: 1px solid #000000;
    padding-block-end: 0.25em;
  }

  h2 {
    font-size: 14pt;
  }

  p,
  main footer p {
    color: #000000;
    font-size: 11pt;
    orphans: 3;
    widows: 3;
  }

  main footer p {
    font-size: 9pt;
  }

  main footer {
    border-block-start: 1px solid #000000;
  }

  a {
    color: #000000;
    text-decoration: underline;
  }

  section {
    break-inside: avoid;
  }

  h3 {
    color: #000000;
    font-size: 12pt;
    break-after: avoid;
  }

  main ul,
  main ol,
  th,
  td,
  .checklist li::before {
    color: #000000;
    font-size: 11pt;
  }

  .note,
  th {
    background: #ffffff;
  }

  .note {
    border-inline-start-color: #000000;
  }

  th,
  td {
    border-color: #000000;
  }

  tr {
    break-inside: avoid;
  }

  .signature-line {
    border-block-start-color: #000000;
  }
}

/* The /legal/ index: a wider page with one card for each policy. Each card carries a large icon,
   tilted and clipped by the card's bottom-right corner, the same watermark the Anchor page uses on its
   summary cards (bock-summary-card .summary-decoration.watermark: primary, opacity 0.14). */
main.legal-index {
  inline-size: min(75rem, 100% - 2 * var(--gutter));
  display: flex;
  flex-direction: column;
  gap: clamp(2rem, 4vw, 3rem);
}

.legal-index-header h1 {
  margin: 0;
  font-size: clamp(2.5rem, 3vw + 1rem, 4rem);
}

.legal-index-header p {
  max-inline-size: 34rem;
  margin: 0.875rem 0 0;
  font-size: 1.125rem;
}

.legal-index-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(18rem, 100%), 1fr));
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.legal-index-list li {
  display: flex;
}

.legal-index-list li + li {
  margin: 0;
}

.legal-entry {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  flex: 1;
  min-block-size: 16rem;
  padding: 2rem 2rem 1.75rem;
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
  transition:
    border-color var(--motion-hover),
    translate var(--motion-hover);
}

.legal-entry:hover {
  border-color: var(--color-accent);
  translate: 0 -2px;
}

.legal-entry-mark {
  position: absolute;
  inset-inline-end: -2.75rem;
  inset-block-end: -2.25rem;
  inline-size: 12.5rem;
  block-size: 12.5rem;
  fill: none;
  stroke: var(--color-accent-fill);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.14;
  rotate: -14deg;
  pointer-events: none;
  transition: rotate 400ms cubic-bezier(0.23, 1, 0.32, 1);
}

/* A small turn to the right on hover. */
.legal-entry:hover .legal-entry-mark {
  rotate: -6deg;
}

@media (prefers-reduced-motion: reduce) {
  .legal-entry-mark {
    transition: none;
  }
}

/* The title and the text keep clear of the watermark. The date line runs the full width, on one line. */
.legal-entry-title,
.legal-entry-text {
  padding-inline-end: 5.5rem;
}

.legal-entry-title,
.legal-entry-text,
.legal-entry-meta {
  position: relative;
}

.legal-entry-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  line-height: 1.1;
}

.legal-entry-text {
  color: var(--color-text-2);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.legal-entry-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-block-start: auto;
  color: var(--color-text-3);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.legal-entry-arrow {
  inline-size: 1rem;
  block-size: 1rem;
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: translate var(--motion-hover);
}

.legal-entry:hover .legal-entry-arrow {
  translate: 0.25rem 0;
}

/* Centered, with clear room above it (owner review). */
.legal-index-contact {
  margin: 2.5rem 0 0;
  text-align: center;
  font-size: 0.9375rem;
}

/* Page entrance: the same as the site's pages (the home hero, site-hero.component.scss): each block of
   the page rises in order. Values copied from _site-tokens.scss: --motion-hero-rise (560ms, ease-out
   curve) and --motion-stagger-step-slow (60ms, the slow Bock stagger step, in
   libs/design-tokens/src/tiers/semantic/shared.css, not _site-tokens.scss); the keyframe is hero-rise from styles/_keyframes.scss. It plays
   on every legal page, so moving between them looks the same as arriving from the site. */
:root {
  --motion-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --motion-page-rise: 560ms var(--motion-ease-out);
  --motion-page-step: 60ms;
}

@keyframes hero-rise {
  from {
    opacity: 0;
    transform: translateY(0.625rem);
  }
}

@media screen and (prefers-reduced-motion: no-preference) {
  main > * {
    animation: hero-rise var(--motion-page-rise) both;
    animation-delay: calc(var(--i, 0) * var(--motion-page-step));
  }

  main > :nth-child(2) {
    --i: 1;
  }
  main > :nth-child(3) {
    --i: 2;
  }
  main > :nth-child(4) {
    --i: 3;
  }
  main > :nth-child(5) {
    --i: 4;
  }
  main > :nth-child(6) {
    --i: 5;
  }
  main > :nth-child(7) {
    --i: 6;
  }
  main > :nth-child(n + 8) {
    --i: 7;
  }
}
