/*
 * The pages of the legal texts (/cgu, /confidentialite, /mentions-legales), built from docs/legal/*.md (tools/legal). A file of
 * the site, never a style inside the page: the Content-Security-Policy (`style-src 'self'`) applies to them as it is.
 * Palette and fonts of apps/web/src/styles/app.css; three themes: clair (default), sombre (the device, or the choice of the site),
 * nuit (red on black, the choice of the site, read by legal-theme.js). The dark themes are for the screen only: paper is always
 * black on white. Readable from 280 px, with the text at 200 %, and on paper. The widths are in em: they follow the size of
 * text the reader chose.
 */

@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/assets/instrument-sans-latin-Jr9s1muL.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0100-017F, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 650;
  font-display: swap;
  src: url('/assets/bricolage-grotesque-latin-DKdpl5tj.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0100-017F, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --font: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Bricolage Grotesque', var(--font);
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --bg: #e4ddcc;
  --card: #f7f4ec;
  --text: #142219;
  --text-2: #34443a;
  --accent: #24432f;
  --accent-contrast: #f7f4ec;
  --accent-soft: rgba(36, 67, 47, 0.1);
  --separator: rgba(20, 34, 25, 0.14);
  --hover: rgba(20, 34, 25, 0.07);
  --focus-ring: 0 0 0 2px var(--card), 0 0 0 4px var(--accent);
  --radius: 26px;
  --radius-sm: 12px;
  --hit: 44px;
}

/* Sombre: the device asks for it, unless the site was set to clair or nuit. On screen only: never on paper. */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme='light']):not([data-theme='night']) {
    color-scheme: dark;
    --bg: #142219;
    --card: #1c3326;
    --text: #f7f4ec;
    --text-2: #cdd5cb;
    --accent: #aed5bc;
    --accent-contrast: #142219;
    --accent-soft: rgba(174, 213, 188, 0.12);
    --separator: rgba(247, 244, 236, 0.14);
    --hover: rgba(247, 244, 236, 0.08);
  }
}

@media screen {
  :root[data-theme='dark'] {
    color-scheme: dark;
    --bg: #142219;
    --card: #1c3326;
    --text: #f7f4ec;
    --text-2: #cdd5cb;
    --accent: #aed5bc;
    --accent-contrast: #142219;
    --accent-soft: rgba(174, 213, 188, 0.12);
    --separator: rgba(247, 244, 236, 0.14);
    --hover: rgba(247, 244, 236, 0.08);
  }

  /* Nuit: red on black, minimal brightness, as the site. */
  :root[data-theme='night'] {
    color-scheme: dark;
    --bg: #000000;
    --card: #070000;
    --text: #ff6a5e;
    --text-2: #f0564a;
    --accent: #ff5a4f;
    --accent-contrast: #000000;
    --accent-soft: rgba(255, 70, 60, 0.14);
    --separator: rgba(255, 70, 60, 0.24);
    --hover: rgba(255, 60, 50, 0.1);
    --focus-ring: 0 0 0 2px #000000, 0 0 0 4px rgba(255, 106, 94, 0.9);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(120% 60% at 50% 0%, var(--accent-soft) 0%, transparent 70%), var(--bg);
  color: var(--text);
  font: 400 1rem/1.6 var(--font);
  overflow-wrap: break-word;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

a:hover {
  text-decoration-thickness: 2px;
}

a:focus-visible,
.legal-main:focus-visible {
  outline: none;
  border-radius: 6px;
  box-shadow: var(--focus-ring);
}

.legal-main:focus {
  outline: none;
}

/* « Aller au texte »: hidden until the keyboard reaches it. */
.legal-skip {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  min-height: var(--hit);
  padding: 0 16px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  text-decoration: none;
}

.legal-skip:focus {
  top: 12px;
}

/* The top: the logo, and « Ouvrir PosteChasse », under it when the line is too narrow for both. */
.legal-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  max-width: calc(48rem + 32px);
  margin: 0 auto;
  padding: 16px 16px 8px;
}

.legal-brand {
  display: inline-flex;
  align-items: center;
  min-height: var(--hit);
  max-width: 100%;
  line-height: 0;
}

.legal-logo {
  display: block;
  width: auto;
  max-width: 100%;
  height: 32px;
}

.legal-logo--dark {
  display: none;
}

@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .legal-logo--light {
    display: none;
  }

  :root:not([data-theme='light']) .legal-logo--dark {
    display: block;
  }
}

@media screen {
  :root[data-theme='dark'] .legal-logo--light,
  :root[data-theme='night'] .legal-logo--light {
    display: none;
  }

  :root[data-theme='dark'] .legal-logo--dark,
  :root[data-theme='night'] .legal-logo--dark {
    display: block;
  }

  :root[data-theme='night'] .legal-logo {
    filter: grayscale(1) sepia(1) saturate(6) hue-rotate(-50deg) brightness(0.6);
  }
}

.legal-back,
.legal-footer__home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  min-height: var(--hit);
  padding: 6px 18px;
  border-radius: 22px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
}

.legal-back:hover,
.legal-footer__home:hover {
  filter: brightness(1.08);
}

/* The three texts, as tabs. */
.legal-nav {
  max-width: calc(48rem + 32px);
  margin: 0 auto;
  padding: 8px 16px 16px;
}

.legal-nav__list,
.legal-footer__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.legal-nav__list a {
  display: inline-flex;
  align-items: center;
  min-height: var(--hit);
  padding: 0 16px;
  border: 1px solid var(--separator);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.legal-nav__list a:hover {
  background: var(--hover);
}

.legal-nav__list a[aria-current='page'] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

.legal-layout {
  max-width: 76rem;
  margin: 0 auto;
  padding: 0 16px;
}

/* The text: a card of reading width. */
.legal-article {
  max-width: 48rem;
  margin: 0 auto;
  padding: 32px 40px 40px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 1px 2px rgba(20, 34, 25, 0.06);
}

/* A word of a title too long for its line: cut by the French hyphenation (narrow screens below), never anywhere. */
.legal-article h1,
.legal-article h2,
.legal-article h3,
.legal-toc__title {
  font-family: var(--font-display);
  font-weight: 650;
  line-height: 1.2;
  overflow-wrap: break-word;
}

/* A small phone, or a phone with large text (352 px at the usual size): a long word of a title may not fit its line. */
@media (max-width: 22em) {
  .legal-article h1,
  .legal-article h2,
  .legal-article h3 {
    -webkit-hyphens: auto;
    hyphens: auto;
  }
}

.legal-article h1 {
  margin: 0 0 12px;
  font-size: 2rem;
}

.legal-article h2 {
  margin: 40px 0 12px;
  padding-top: 24px;
  border-top: 1px solid var(--separator);
  font-size: 1.4rem;
}

.legal-article h3 {
  margin: 28px 0 8px;
  font-size: 1.15rem;
}

.legal-article p {
  margin: 0 0 14px;
}

.legal-article .legal-version {
  display: inline-block;
  margin-bottom: 20px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text-2);
  font-weight: 600;
}

.legal-article ul,
.legal-article ol {
  margin: 0 0 16px;
  padding-left: 1.4rem;
}

.legal-article li {
  margin: 0 0 8px;
}

.legal-article li > ul,
.legal-article li > ol,
.legal-article li > p {
  margin-top: 8px;
}

.legal-article li::marker {
  color: var(--text-2);
}

/* An item of a list that is only a link: a target of a finger. */
.legal-article .legal-link-item {
  margin: 0;
}

.legal-article .legal-link-item a {
  display: inline-flex;
  align-items: center;
  min-height: var(--hit);
}

.legal-article strong {
  font-weight: 650;
}

.legal-article code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--hover);
  font-family: var(--mono);
  font-size: 0.9em;
  overflow-wrap: break-word;
}

.legal-nowrap {
  white-space: nowrap;
}

.legal-table {
  margin: 0 0 20px;
}

.legal-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.legal-table th,
.legal-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--separator);
  text-align: left;
  vertical-align: top;
}

.legal-table th {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 650;
}

.legal-table th:first-child {
  border-top-left-radius: var(--radius-sm);
}

.legal-table th:last-child {
  border-top-right-radius: var(--radius-sm);
}

.legal-table td:first-child {
  font-weight: 600;
}

/* The sommaire of the long texts: folded under the date (phone, tablet), or beside the text (large screen). */
.legal-toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.legal-toc a {
  display: flex;
  align-items: center;
  min-height: var(--hit);
  padding: 4px 8px;
  margin: 0 -8px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  line-height: 1.3;
}

.legal-toc a:hover {
  background: var(--hover);
  color: var(--accent);
}

.legal-toc--side {
  display: none;
}

.legal-toc__title {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.legal-article .legal-toc--fold {
  margin: 0 0 24px;
  padding: 0 16px;
  border: 1px solid var(--separator);
  border-radius: var(--radius-sm);
}

.legal-toc--fold summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--hit);
  font-weight: 650;
  list-style: none;
  cursor: pointer;
}

.legal-toc--fold summary::-webkit-details-marker {
  display: none;
}

/* The chevron of the fold, drawn by two borders: down when closed, up when open. */
.legal-toc--fold summary::after {
  content: '';
  width: 8px;
  height: 8px;
  margin: -4px 4px 0 auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.legal-toc--fold[open] summary::after {
  margin-top: 4px;
  transform: rotate(-135deg);
}

.legal-toc--fold summary:focus-visible {
  outline: none;
  border-radius: var(--radius-sm);
  box-shadow: var(--focus-ring);
}

.legal-toc--fold[open] summary {
  border-bottom: 1px solid var(--separator);
}

.legal-toc--fold ol {
  padding: 6px 0 10px;
}

.legal-article .legal-toc--fold li {
  margin: 0;
}

.legal-footer {
  max-width: 48rem;
  margin: 0 auto;
  padding: 24px 16px 40px;
  color: var(--text-2);
  font-size: 0.95rem;
  text-align: center;
}

.legal-footer__list {
  justify-content: center;
  gap: 0 4px;
  margin-bottom: 8px;
}

.legal-footer__list a {
  display: inline-flex;
  align-items: center;
  min-height: var(--hit);
  padding: 0 10px;
  color: var(--text-2);
  border-radius: var(--radius-sm);
}

.legal-footer__list a[aria-current='page'] {
  color: var(--text);
  font-weight: 600;
}

.legal-footer p {
  margin: 0 0 12px;
}

/* A large screen: the sommaire stays beside the text, the top as wide as both (1100 px at the usual size of text). */
@media (min-width: 68.75em) {
  .legal-header,
  .legal-nav {
    max-width: calc(17rem + 24px + 48rem + 32px);
  }

  .legal-layout {
    display: grid;
    grid-template-columns: 17rem minmax(0, 48rem);
    justify-content: center;
    align-items: start;
    gap: 24px;
  }

  .legal-toc--side {
    position: sticky;
    top: 16px;
    display: block;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 16px 20px;
    border-radius: var(--radius);
    background: var(--card);
    font-size: 0.95rem;
  }

  .legal-article .legal-toc--fold {
    display: none;
  }

  .legal-layout > .legal-main:only-child {
    grid-column: 2;
  }
}

/* A phone, or a tablet with large text: closer to the edges, tables in cards (720 px at the usual size of text). */
@media screen and (max-width: 45em) {
  .legal-header {
    padding: 12px 16px 4px;
  }

  .legal-logo {
    height: 28px;
  }

  .legal-back {
    padding: 6px 14px;
  }

  .legal-nav {
    padding: 8px 16px 12px;
  }

  .legal-layout {
    padding: 0 8px;
  }

  .legal-article {
    padding: 22px 18px 28px;
    border-radius: 22px;
  }

  .legal-article h1 {
    font-size: 1.6rem;
  }

  .legal-article h2 {
    margin-top: 32px;
    padding-top: 20px;
    font-size: 1.25rem;
  }

  .legal-table table,
  .legal-table tbody,
  .legal-table tr,
  .legal-table td {
    display: block;
    width: 100%;
  }

  .legal-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .legal-table tr {
    margin: 0 0 12px;
    padding: 10px 14px;
    border: 1px solid var(--separator);
    border-radius: var(--radius-sm);
  }

  .legal-table td {
    padding: 6px 0;
    border-bottom: 0;
  }

  .legal-table td + td {
    border-top: 1px solid var(--separator);
  }

  /* Drawn for the eye only: a screen reader already says the header of the column (the roles of the table). */
  .legal-table td::before {
    content: attr(data-label);
    content: attr(data-label) / '';
    display: block;
    color: var(--text-2);
    font-size: 0.8rem;
    font-weight: 650;
    letter-spacing: 0.02em;
  }

  /* The first cell is the subject of the card: its words are enough, without the label of its column. */
  .legal-table td:first-child::before {
    display: none;
  }

  .legal-table td:first-child {
    padding-top: 2px;
    font-weight: 650;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* On paper: the text alone, black on white, the addresses of the links written out. */
@media print {
  :root,
  :root[data-theme] {
    color-scheme: light;
    --bg: #ffffff;
    --card: #ffffff;
    --text: #000000;
    --text-2: #333333;
    --accent: #000000;
    --accent-soft: #eeeeee;
    --separator: #bbbbbb;
  }

  @page {
    margin: 16mm 14mm;
  }

  body {
    background: #ffffff;
    font-size: 11pt;
    line-height: 1.45;
  }

  .legal-skip,
  .legal-back,
  .legal-nav,
  .legal-toc,
  .legal-article .legal-toc--fold,
  .legal-footer nav,
  .legal-footer__home {
    display: none;
  }

  .legal-logo--light {
    display: block !important;
    filter: none !important;
  }

  .legal-logo--dark {
    display: none !important;
  }

  .legal-header,
  .legal-layout {
    display: block;
    max-width: none;
    padding: 0;
  }

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

  .legal-article a[href^='http']::after,
  .legal-article a[href^='/']::after {
    content: ' (' attr(href) ')';
    font-size: 0.85em;
    overflow-wrap: anywhere;
  }

  /* The links between the texts and to the site: their whole address on paper. */
  .legal-article a[href^='/']::after {
    content: ' (postechasse.fr' attr(href) ')';
  }

  .legal-article h2,
  .legal-article h3 {
    break-after: avoid;
  }

  .legal-article li,
  .legal-table tr {
    break-inside: avoid;
  }

  .legal-table th {
    background: #eeeeee;
  }

  .legal-footer {
    padding: 12pt 0 0;
    text-align: left;
  }
}
