/* Mon Petit Labo — charte conservée (#1a3c5e / #ff6f61 / #e9f1fa, Poppins + Roboto Mono) */
@layer base, layout, components;
@view-transition { navigation: auto; }

@layer base {
  :root {
    color-scheme: light dark;
    --primary: #1a3c5e; --accent: #ff6f61; --ink: #0f2740;
    --bg: light-dark(#fff, #0e1a28);
    --light-bg: light-dark(#e9f1fa, #15263a);
    --card: light-dark(#fff, #1a2d44);
    --text: light-dark(#333, #dbe4ee);
    --muted: light-dark(#555, #a8b6c6);
    --heading: light-dark(#1a3c5e, #a9cdf3);
    --link: light-dark(#c2362a, #ff958a);
    --line: light-dark(#d5e1ef, #2a4260);
    --particle: light-dark(rgb(26 60 94 / .3), rgb(169 205 243 / .3));
    --radius: 12px;
    --shadow: 0 4px 12px rgb(0 0 0 / .12);
    --h1: clamp(1.75rem, 1.2rem + 2.4vw, 2.8rem);
  }
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { scroll-behavior: smooth; scroll-padding-top: 5rem; }
  body { font: 400 1rem/1.6 Poppins, system-ui, sans-serif; color: var(--text); background: var(--bg); min-height: 100dvh; display: flex; flex-direction: column; }
  main { flex: 1; }
  img { max-width: 100%; height: auto; display: block; }
  a { color: var(--link); }
  h1, h2, h3 { color: var(--heading); text-wrap: balance; line-height: 1.25; }
  :focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
  .skip { position: absolute; left: -999px; &:focus { left: 1rem; top: 1rem; z-index: 100; background: var(--bg); padding: .5rem 1rem; } }
  #bg-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; opacity: .1; pointer-events: none; }
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
}

@layer layout {
  .wrap { max-width: 1200px; margin-inline: auto; padding-inline: 1rem; }
  .narrow { max-width: 780px; }
  .section { margin-block: 3rem; }
  .center { text-align: center; }

  .site-header { background: var(--primary); color: #fff; text-align: center; padding: 1.25rem 1rem;
    .brand { display: inline-flex; flex-direction: column; align-items: center; gap: .25rem; color: inherit; text-decoration: none; font-weight: 600; font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.5rem); }
    img { width: auto; height: 64px; } }
  .home .site-header { padding-block: 2rem; img { height: 120px; } }

  .nav { position: sticky; top: 0; z-index: 50; background: var(--bg); box-shadow: 0 2px 4px rgb(0 0 0 / .1);
    .nav-toggle { display: none; }
    ul { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem 1.5rem; padding: 1rem; }
    a { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--heading); font-weight: 600;
      &:hover { color: var(--link); }
      &[aria-current] { color: var(--link); text-decoration: underline 3px var(--accent); text-underline-offset: 6px; } } }
  @media (max-width: 768px) {
    .nav { .nav-toggle { display: flex; width: 100%; justify-content: center; gap: .5rem; padding: .9rem; background: none; border: 0; font: 600 1rem Poppins, sans-serif; color: var(--heading); cursor: pointer; }
      ul { display: none; flex-direction: column; gap: 1rem; }
      &:has([aria-expanded="true"]) ul { display: flex; } }
  }

  .crumbs { padding-block: 1rem; font-size: .9rem;
    ol { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; }
    li + li::before { content: "›"; margin-right: .4rem; color: var(--muted); } }

  .hero { background: var(--light-bg); padding: 3rem 1rem; text-align: center;
    svg { width: 50px; height: 50px; fill: var(--accent); margin: 0 auto 1rem; }
    h1 { font-size: var(--h1); margin-bottom: 1rem; }
    p { font-size: 1.15rem; max-width: 800px; margin: 0 auto .75rem; } }
  .page-title { background: var(--light-bg); padding: 2.5rem 1rem; text-align: center;
    h1 { font-size: var(--h1); }
    p { max-width: 720px; margin: .75rem auto 0; font-size: 1.1rem; } }

  .sec-title { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); text-align: center; margin-bottom: 1.5rem; display: flex; justify-content: center; align-items: center; gap: .5rem; }
  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.5rem; }

  .quote { background: var(--accent); color: var(--ink); padding: 3rem 1rem; text-align: center; font-style: italic; margin-block: 3rem;
    svg { width: 40px; height: 40px; fill: var(--ink); margin: 0 auto 1rem; }
    p { font-size: clamp(1.1rem, 1rem + .5vw, 1.3rem); max-width: 800px; margin: 0 auto; }
    cite { display: block; margin-top: 1rem; font-weight: 600; } }

  .site-footer { background: var(--primary); color: #fff; padding: 2rem 1rem; text-align: center; margin-top: 3rem;
    .foot-links { display: flex; flex-wrap: wrap; justify-content: center; gap: .75rem 1.5rem; }
    a { color: color-mix(in srgb, var(--accent), white 25%); text-decoration: none; display: inline-flex; gap: .5rem; align-items: center; &:hover { text-decoration: underline; } } }
}

@layer components {
  .card { position: relative; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; transition: transform .3s ease; border: 1px solid var(--line);
    &:hover, &:has(:focus-visible) { transform: translateY(-6px); }
    img { width: 100%; height: 180px; object-fit: cover; background: linear-gradient(135deg, var(--primary), var(--accent)); }
    .card-body { padding: 1rem; }
    h3 { font-size: 1.2rem; margin-block: .25rem .5rem; a { color: inherit; text-decoration: none; display: flex; gap: .5rem; align-items: baseline; &::after { content: ""; position: absolute; inset: 0; } } }
    .mono { font: 400 .92rem/1.55 "Roboto Mono", monospace; color: var(--muted); } }
  .tag { font-size: .85rem; color: var(--link); font-weight: 600; }

  .carousel { position: relative;
    .track { display: flex; gap: 1.5rem; overflow-x: auto; scroll-snap-type: x mandatory; padding: 1rem; scroll-behavior: smooth; scrollbar-color: var(--accent) var(--light-bg); }
    .card { flex: 0 0 min(300px, 82vw); scroll-snap-align: start; }
    .controls { display: flex; justify-content: center; gap: 1rem; margin-top: 1rem; } }

  .btn { display: inline-flex; gap: .5rem; align-items: center; background: var(--primary); color: #fff; border: 1px solid var(--line); padding: .6rem 1.2rem; border-radius: 6px; font: 600 1rem Poppins, sans-serif; cursor: pointer; text-decoration: none;
    &:hover { background: var(--accent); color: var(--ink); } }
  .more { text-align: center; margin-top: 2rem; font-weight: 600; }

  .tile { display: block; padding: 1.5rem; background: var(--light-bg); border-radius: var(--radius); text-decoration: none; color: var(--text); border: 1px solid var(--line);
    i { font-size: 1.8rem; color: var(--accent); }
    h3 { margin-block: .5rem; }
    &:hover { border-color: var(--accent); } }

  .prose { padding-block: 1rem;
    h2 { font-size: 1.5rem; margin: 2rem 0 .75rem; }
    p, ul { margin-bottom: 1rem; max-width: 70ch; }
    ul { padding-left: 1.4rem; }
    li { margin-bottom: .4rem; }
    figure img { border-radius: var(--radius); width: 100%; max-height: 380px; object-fit: cover; background: linear-gradient(135deg, var(--primary), var(--accent)); aspect-ratio: 5 / 3; }
    .lead { font-size: 1.2rem; color: var(--heading); } }
  .keypoints { background: var(--light-bg); border-left: 6px solid var(--accent); border-radius: var(--radius); padding: 1rem 1.5rem; margin: 1.5rem 0; h2 { margin-top: 0; } }
  .meta { font-size: .9rem; color: var(--muted); }
  .chips { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; padding: 0 !important;
    li { background: var(--light-bg); border: 1px solid var(--line); padding: .2rem .8rem; border-radius: 99px; font-size: .9rem; margin: 0; } }
  .person { padding: 1.25rem; h3 { font-size: 1.15rem; } }
  mark.todo { background: #fff3b0; color: #222; padding: 0 .25rem; border-radius: 3px; }

  #search-form { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem;
    input { flex: 1 1 260px; padding: .7rem 1rem; font: 1rem Poppins, sans-serif; border: 2px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text); } }
  #results { list-style: none; padding: 0 !important; li { padding: 1rem 0; border-bottom: 1px solid var(--line); a { font-weight: 600; } p { margin: .25rem 0 0; } } }

  @supports (animation-timeline: view()) {
    .reveal { animation: rise linear both; animation-timeline: view(); animation-range: entry 0% cover 25%; }
    @keyframes rise { from { opacity: 0; translate: 0 24px; } }
  }
}
