/* ============================================================
   base.css — design system v0 — reset minimal + base typography
   Owner: xilrian-agent (XA) · 2026-05-08
   ============================================================
   Pré-requis : tokens.css chargé avant.
   Volontairement minimal — les agents peuvent ajouter leur propre
   reset par-dessus si besoin (ex. cultural-library a des modales,
   PA a des audio players, etc.).
   ============================================================ */

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

/* ----- HTML root ----- */
html {
  font-size: 100%;       /* respecte la pref user (16px ≈ 1rem) */
  line-height: var(--ds-line-height-normal);
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

/* ----- Body baseline ----- */
body {
  margin: 0;
  font-family: var(--surface-font-family-body, var(--ds-font-family-sans));
  font-size: var(--ds-font-size-base);
  font-weight: var(--ds-font-weight-normal);
  line-height: var(--ds-line-height-normal);
  /* Color laissé aux agents : --surface-color-text + --surface-color-bg */
  color: var(--surface-color-text, #1a1a1a);
  background-color: var(--surface-color-bg, #fafafa);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ----- Headings — rythme typographique ----- */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--ds-space-4) 0;
  font-family: var(--surface-font-family-heading, var(--ds-font-family-sans));
  font-weight: var(--ds-font-weight-semibold);
  line-height: var(--ds-line-height-tight);
}

h1 { font-size: var(--ds-font-size-3xl); }
h2 { font-size: var(--ds-font-size-2xl); }
h3 { font-size: var(--ds-font-size-xl); }
h4 { font-size: var(--ds-font-size-lg); }
h5 { font-size: var(--ds-font-size-md); }
h6 { font-size: var(--ds-font-size-base); }

/* ----- Paragraphs + body text ----- */
p {
  margin: 0 0 var(--ds-space-4) 0;
}

/* ----- Links — neutres, agents customisent ----- */
a {
  color: var(--surface-color-link, currentColor);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--ds-transition-fast);
}

a:hover {
  color: var(--surface-color-link-hover, var(--surface-color-link, currentColor));
}

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

/* ----- Lists ----- */
ul, ol {
  margin: 0 0 var(--ds-space-4) 0;
  padding-left: var(--ds-space-5);
}

li + li {
  margin-top: var(--ds-space-1);
}

/* ----- Blockquote ----- */
blockquote {
  margin: 0 0 var(--ds-space-4) 0;
  padding: var(--ds-space-2) var(--ds-space-4);
  border-left: var(--ds-border-width-4) solid var(--surface-color-rule, #ccc);
  font-style: italic;
}

/* ----- Code & pre ----- */
code, kbd, samp {
  font-family: var(--ds-font-family-mono);
  font-size: 0.95em;
  padding: 0.1em 0.3em;
  background: var(--surface-color-code-bg, rgba(0, 0, 0, 0.05));
  border-radius: var(--ds-radius-sm);
}

pre {
  margin: 0 0 var(--ds-space-4) 0;
  padding: var(--ds-space-4);
  background: var(--surface-color-code-bg, rgba(0, 0, 0, 0.05));
  border-radius: var(--ds-radius-base);
  overflow-x: auto;
  font-family: var(--ds-font-family-mono);
  font-size: var(--ds-font-size-sm);
  line-height: var(--ds-line-height-snug);
}

pre code {
  padding: 0;
  background: transparent;
  border-radius: 0;
}

/* ----- Horizontal rule ----- */
hr {
  margin: var(--ds-space-6) 0;
  border: none;
  border-top: var(--ds-border-width-1) solid var(--surface-color-rule, #e0e0e0);
}

/* ----- Tables ----- */
table {
  width: 100%;
  margin: 0 0 var(--ds-space-4) 0;
  border-collapse: collapse;
  font-size: var(--ds-font-size-sm);
}

th, td {
  padding: var(--ds-space-2) var(--ds-space-3);
  text-align: left;
  border-bottom: var(--ds-border-width-1) solid var(--surface-color-rule, #e0e0e0);
}

th {
  font-weight: var(--ds-font-weight-semibold);
}

/* ----- Images & media — responsive par défaut ----- */
img, picture, video, canvas, svg, audio {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ----- Form elements — héritage typographique ----- */
input, button, textarea, select {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

/* ----- Accessibility — focus visible ----- */
:focus-visible {
  outline: 2px solid var(--surface-color-focus, currentColor);
  outline-offset: 2px;
}

/* ----- Long-form content (articles, RA papers) ----- */
.ds-prose {
  max-width: var(--ds-container-narrow);
  line-height: var(--ds-line-height-loose);
}

.ds-prose h2,
.ds-prose h3 {
  margin-top: var(--ds-space-7);
}

.ds-prose img,
.ds-prose figure {
  margin: var(--ds-space-5) 0;
}

.ds-prose figcaption {
  margin-top: var(--ds-space-2);
  font-size: var(--ds-font-size-sm);
  font-style: italic;
  text-align: center;
  color: var(--surface-color-muted, #666);
}
