/* Shared chrome for the preview pages, aligned on the RAGT brandbook.
 *
 * The art direction is transcribed from `template/brandbook_template.html` and
 * its stylesheets — the real site's own numbers, not our interpretation:
 *
 *   topbar     fixed, 16px inset; the nav is a floating WHITE card,
 *              max-width 1408, height 88, radius-m, shadow-xl,
 *              padding 0 24 0 32; content sits 104px below
 *   body grid  max-width 1216, padding 0 32, `240px 1fr`, gap 64
 *   side rail  sticky at 120px, red-600 kicker, Oswald title,
 *              13/20 links neutral-600 -> neutral-900
 *   footer     neutral-900, 96px top padding, neutral-800 hairline
 *   hero       red 34x2 rule, kicker at .3em tracking, Oswald uppercase title
 *
 * Colours go through this project's own tokens rather than being copied — and
 * that matters more than provenance: the brandbook's published CSS is STALE in
 * places. Its Yellow ramp is out of sync at every step and several of its
 * line-heights differ from the Figma file (see « Divergences avec le brandbook »
 * in the README). Pulling colour from `--palette-*` means this page shows the
 * current Figma values, not the brandbook's.
 *
 * Only the layout metrics, shadows and motion below are literals taken from the
 * brandbook — it carries them and the Figma variables do not. Those are not
 * colours and nothing suggests they have drifted.
 *
 * This is the page frame, not part of the shipped design system: the components
 * live in dist/ragt-components.css. */

/* Both font stylesheets are the brandbook's own saved Google Fonts responses,
   copied into `assets/` rather than re-requested from a guessed API URL. Their
   `src` URLs are absolute to fonts.gstatic.com.
   Note: « Google Sans Flex » IS published on Google Fonts, as a 1..1000
   variable font — the brandbook loads it. An earlier note in the README
   claiming otherwise was wrong. */
@import url('/preview/assets/font-google-sans-flex.css');
@import url('/preview/assets/font-display.css');

:root {
  /* --- brandbook metrics (literals: no Figma variable carries these) --- */
  --shell-width: 1408px;
  --content-width: 1216px;
  --header-height: 88px;
  --topbar-offset: 104px;
  --rail-width: 240px;
  --rail-gap: 64px;

  /* --shadow-s / -m / -l used to be restated here, in black. They are real
     tokens now (« 🎨 Foundations » -> tokens/_documented.scss) and arrive from
     ragt-tokens.css, which loads first — restating them here would silently
     win on :root and show the preview a shadow the design system does not
     ship. Only -xl is still ours: the page draws no fourth step. */
  --shadow-xl: 0 20px 25px -5px #0000001a, 0 10px 10px -5px #0000000a;

  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --duration-fast: .15s;

  --font-core: 'Google Sans Flex', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Oswald', 'Google Sans Flex', 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

/* The `hidden` attribute only gets `display: none` from the UA stylesheet, so
   any author rule setting `display` beats it — a `display: grid` scrim stayed
   on screen and greyed out the whole page. */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-core);
  font-size: 16px;
  background: var(--palette-neutral-100);
  color: var(--palette-neutral-900);
}

code, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

a { color: inherit; }

/* =========================================================================
   Topbar — the floating white nav card. Holds the navigation BETWEEN pages.
   ========================================================================= */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 300;
}

.topbar-pad { padding: 16px 16px 0; }

.nav-shell {
  max-width: var(--shell-width);
  height: var(--header-height);
  margin: 0 auto;
  padding: 0 24px 0 32px;
  background: var(--palette-neutral-white);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.nav-logo img {
  display: block;
  height: 26px; /* brandbook: .nav-logo img */
  width: auto;
}

.nav-main {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 0;
  overflow-x: auto;
}

/* Le menu principal est le composant `.ragt-tab` de la couche, pas une imitation
   — voir `src/styles/components/_nav.scss`. Ne restent ici que les ajustements
   de mise en page propres à la carte de 88px : pas de retour à la ligne, et une
   transition, que le composant ne porte pas. Toute règle de COULEUR ajoutée ici
   ferait diverger le menu du composant qu'il est censé démontrer. */
.nav-main .ragt-tab {
  white-space: nowrap;
  transition: color var(--duration-fast) ease;
}

/* `.nav-link` a été supprimé ici : c'était le menu maison — fond
   `marques.brand.100`, soulignement interne de 2px, 14/21 en `neutral.700` —
   remplacé par `.ragt-tab`. Plus rien ne le portait. Ne pas le réintroduire
   « pour ajuster » : le menu doit se casser en même temps que le composant si
   celui-ci change, sinon l'aperçu cesse de démontrer ce qu'il livre. */

.nav-meta {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 12px;
  line-height: 18px;
  color: var(--palette-neutral-500);
  white-space: nowrap;
}

.topbar-spacer { height: var(--topbar-offset); }

/* =========================================================================
   Page hero — the brandbook's language (red rule, spaced kicker, Oswald
   uppercase) at a compact scale. The brandbook's own hero is a 560px photo
   band; a component reference does not need one on every page.
   ========================================================================= */

.page-hero {
  background: var(--palette-neutral-900);
  padding: 48px 0 44px;
}

.ph-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ph-rule {
  width: 34px;
  height: 2px;
  background: var(--palette-red-600);
}

.ph-kicker {
  margin: 0;
  font-size: 12px;
  line-height: 18px;
  font-weight: 600;
  letter-spacing: .3em;
  text-indent: .3em;
  text-transform: uppercase;
  color: var(--palette-neutral-white);
}

.ph-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 44px;
  line-height: 1.02;
  font-weight: 700;
  letter-spacing: -.01em;
  text-transform: uppercase;
  color: var(--palette-neutral-white);
}

.ph-desc {
  margin: 0;
  max-width: 70ch;
  font-size: 16px;
  line-height: 28px;
  color: var(--palette-neutral-200);
}

/* =========================================================================
   Body grid — the rail carries the navigation WITHIN the page.
   ========================================================================= */

.cg-body {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 32px;
  display: grid;
  grid-template-columns: var(--rail-width) 1fr;
  align-items: start;
  gap: var(--rail-gap);
}

.cg-main {
  min-width: 0;
  padding: 48px 0 96px;
}

.side-nav {
  position: sticky;
  top: 120px; /* brandbook: clears the 104px topbar */
  align-self: start;
  padding: 48px 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.sn-header {
  padding-bottom: 20px;
  border-bottom: var(--borders-s) solid var(--palette-neutral-300);
}

.sn-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  line-height: 17px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--palette-red-600);
}

.sn-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 26px;
  font-weight: 600;
  letter-spacing: -.005em;
  color: var(--palette-neutral-900);
}

/* =========================================================================
   « Classes CSS » — l'inventaire, par section, de ce que la section démontre.
   Replié par défaut : c'est une référence qu'on vient chercher, pas quelque
   chose à lire en parcourant la page.
   ========================================================================= */

.cls {
  margin-top: var(--spacing-24);
  border: var(--borders-s) solid var(--palette-neutral-200);
  border-radius: var(--radius-s);
  background: var(--palette-neutral-white);
}

.cls > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--spacing-16);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--palette-neutral-600);
}

.cls > summary:focus-visible {
  outline: var(--borders-l) solid var(--palette-neutral-500);
  outline-offset: -2px;
}

.cls > summary .count {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--palette-neutral-500);
}

.cls-list {
  border-top: var(--borders-s) solid var(--palette-neutral-200);
  padding: var(--spacing-8) 0;
}

.cls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px var(--spacing-16);
  padding: 5px var(--spacing-16);
}

.cls-row:hover { background: var(--palette-neutral-100); }

.cls-name {
  font-size: 12px;
  color: var(--palette-neutral-900);
  cursor: pointer;
  white-space: nowrap;
}

.cls-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px var(--spacing-12);
  font-size: 11px;
  color: var(--palette-neutral-600);
  min-width: 0;
}

.cls-chain { overflow-wrap: anywhere; }
.cls-state { color: var(--palette-neutral-700); }

/* Global search. The results list sits IN FLOW rather than floating over the
   rail: `.side-nav` scrolls its own overflow, which would clip an absolutely
   positioned panel at the first long result list. */
.sn-search {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sn-search input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  font: inherit;
  font-size: 13px;
  line-height: 20px;
  color: var(--palette-neutral-900);
  background: var(--palette-neutral-white);
  border: var(--borders-s) solid var(--palette-neutral-300);
  border-radius: var(--radius-s);
  transition: border-color var(--duration-fast) ease;
}

.sn-search input::placeholder { color: var(--palette-neutral-500); }

.sn-search input:focus-visible {
  outline: 2px solid var(--palette-red-600);
  outline-offset: 1px;
  border-color: var(--palette-neutral-500);
}

.sn-results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 46vh;
  overflow-y: auto;
}

.sn-result {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 8px;
  border-radius: var(--radius-s);
  text-decoration: none;
}

.sn-result:hover,
.sn-result.is-active { background: var(--palette-neutral-100); }

.sn-result:focus-visible {
  outline: 2px solid var(--palette-red-600);
  outline-offset: -2px;
}

.sn-result .r-label {
  font-size: 13px;
  line-height: 19px;
  color: var(--palette-neutral-900);
  overflow-wrap: anywhere;
}

.sn-result .r-page {
  font-size: 10px;
  line-height: 15px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--palette-neutral-500);
}

.sn-empty {
  display: block;
  padding: 7px 8px;
  font-size: 12px;
  color: var(--palette-neutral-600);
}

.sn-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sn-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
  line-height: 20px;
  color: var(--palette-neutral-600);
  text-decoration: none;
  transition: color var(--duration-fast) ease;
}

.sn-link:hover,
.sn-link.is-active { color: var(--palette-neutral-900); }

.sn-num {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--palette-neutral-500);
  transition: color var(--duration-fast) ease;
}

.sn-link.is-active .sn-num { color: var(--palette-red-600); }

.sn-label { min-width: 0; }

/* A rail block: the mode switches live here rather than in the topbar. They
   are contextual controls, and the 88px card has no room for eleven pills. */
.sn-block {
  padding-top: 20px;
  border-top: var(--borders-s) solid var(--palette-neutral-300);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sn-block:first-child {
  padding-top: 0;
  border-top: 0;
}

.sn-block-title {
  font-size: 11px;
  line-height: 17px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--palette-neutral-500);
}

.switch { display: flex; flex-wrap: wrap; gap: 4px; }

button.pill {
  font: inherit;
  font-size: 12px;
  padding: 5px 10px;
  border: var(--borders-s) solid var(--palette-neutral-300);
  border-radius: var(--radius-full);
  background: var(--palette-neutral-white);
  color: var(--palette-neutral-700);
  cursor: pointer;
  transition: background var(--duration-fast) ease, border-color var(--duration-fast) ease;
}

button.pill:hover { border-color: var(--marques-brand-500); }

button.pill[aria-pressed='true'] {
  background: var(--marques-brand-600);
  border-color: var(--marques-brand-600);
  color: var(--palette-neutral-white);
}

/* =========================================================================
   Content
   ========================================================================= */

/* The topbar is `position: fixed`, so a section scrolled to its own top lands
   underneath it. This applies to the rail links and to a result opened from the
   global search alike — both end up as a hash on a section. */
section { margin-bottom: 96px; scroll-margin-top: calc(var(--topbar-offset) + 16px); }
section:last-child { margin-bottom: 0; }

section > h2 {
  font-family: var(--font-display);
  font-size: 32px;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -.005em;
  margin: 0 0 8px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--palette-neutral-900);
}

section > h2 .count,
section > h2 .fig {
  font-family: var(--font-core);
  font-size: 12px;
  line-height: 18px;
  color: var(--palette-neutral-500);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

section > .note,
section > .uses {
  margin: 0 0 24px;
  font-size: 14px;
  line-height: 25px;
  color: var(--palette-neutral-700);
  max-width: 78ch;
}

/* =========================================================================
   Footer
   ========================================================================= */

.site-footer {
  background: var(--palette-neutral-900);
  padding: 96px 0 0;
  color: var(--palette-neutral-300);
}

.footer-grid {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 32px 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 48px 64px;
  align-items: start;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
  max-width: 300px;
}

.footer-brand img { display: block; height: 30px; width: auto; }

.footer-brand p {
  margin: 0;
  font-size: 14px;
  line-height: 21px;
  color: var(--palette-neutral-400);
}

.footer-col { display: flex; flex-direction: column; gap: 20px; }

.footer-col-title {
  font-size: 11px;
  line-height: 17px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--palette-neutral-500);
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.footer-col a {
  font-size: 14px;
  line-height: 21px;
  color: var(--palette-neutral-300);
  text-decoration: none;
  transition: color var(--duration-fast) ease;
}

.footer-col a:hover { color: var(--palette-neutral-white); }

.footer-bottom {
  border-top: var(--borders-s) solid var(--palette-neutral-800);
}

.footer-bottom div {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 24px 32px 40px;
}

.footer-bottom p {
  margin: 0;
  font-size: 12px;
  line-height: 18px;
  letter-spacing: .03em;
  color: var(--palette-neutral-500);
}

/* =========================================================================
   Bits
   ========================================================================= */

.copied {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--palette-neutral-900);
  color: var(--palette-neutral-white);
  font-size: 12px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-l);
  opacity: 0;
  transition: opacity var(--duration-fast) ease;
  pointer-events: none;
  z-index: 400;
}
.copied.show { opacity: 1; }

.error { padding: 24px; max-width: 70ch; }
.error code { background: var(--palette-neutral-200); padding: 2px 5px; border-radius: 3px; }

/* =========================================================================
   Responsive — the brandbook drops its rail at 980px.
   ========================================================================= */

@media (max-width: 980px) {
  .cg-body {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .side-nav {
    position: static;
    max-height: none;
    padding: 32px 0 0;
    overflow: visible;
  }
  .footer-grid { grid-template-columns: 1fr; }
}

/* 640px, et non 599 : ce seuil-ci n'a jamais eu de provenance brandbook — il
   recopiait le seuil phone du design system, qui est passé à 640px avec la
   table « 📐 Grid & Layout » du 16-09. Les laisser désaccordés ouvrait une
   bande de 41px où l'échelle typographique basculait en phone sans que les
   marges du chrome suivent. Le 980px au-dessus, lui, vient bien du brandbook
   et ne bouge pas. */
@media (max-width: 640px) {
  .cg-body, .ph-inner, .footer-grid, .footer-bottom div { padding-inline: 16px; }
  .ph-title { font-size: 32px; }
  .nav-shell { padding-inline: 16px; gap: 16px; }
}
