/* Portfolio 1cartograph — feuille unique, mobile d'abord.
   Thème : clair/sombre automatique (prefers-color-scheme), forçable via
   <html data-theme="light|dark"> (voir assets/js/theme.js). */

:root {
  color-scheme: light dark;
  --bg: light-dark(#fbfbf9, #121513);
  --surface: light-dark(#f0f2ee, #1a1e1b);
  --text: light-dark(#1d211e, #e8ebe7);
  --muted: light-dark(#575f59, #a3aba5);
  --border: light-dark(#d5dad4, #2d332f);
  --accent: light-dark(#2f6b45, #7bc596);
  --accent-strong: light-dark(#255838, #9bd8b1);
  --on-accent: light-dark(#ffffff, #0e1a12);
  --focus: light-dark(#1a4fd6, #8ab4ff);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}
main { flex: 1; }
img, svg { max-width: 100%; height: auto; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 6vw, 2.8rem); margin: 0 0 .5rem; }
h2 { font-size: 1.4rem; margin: 2.5rem 0 .75rem; }
h3 { font-size: 1.1rem; margin: 0 0 .4rem; }
p { margin: 0 0 1rem; }
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { color: var(--accent-strong); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

.wrap { width: 100%; max-width: 68rem; margin-inline: auto; padding-inline: 1rem; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 42rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.todo { background: #fff3a8; color: #3a2e00; padding: 0 .3em; border-radius: 3px; font-weight: 600; }

.skip {
  position: absolute; left: .5rem; top: -4rem; z-index: 100;
  background: var(--accent); color: var(--on-accent); padding: .6rem 1rem; border-radius: var(--radius);
}
.skip:focus { top: .5rem; }

/* ---------- En-tête et navigation ---------- */
.site-header { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--border); }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; padding-block: .5rem; }
.brand {
  margin-right: auto; font-weight: 700; font-size: 1.2rem; letter-spacing: -.01em;
  color: var(--text); text-decoration: none; padding-block: .3rem;
}
.brand span { color: var(--accent); }
.btn-plain {
  font: inherit; color: var(--text); background: transparent; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius); padding: .45rem .8rem; min-height: 2.75rem;
}
.btn-plain:hover { background: var(--surface); }
.nav { flex-basis: 100%; }
html.js .nav { display: none; }
html.js .nav.open { display: block; }
.tabs { list-style: none; margin: 0; padding: 0; }
.tabs a {
  display: block; padding: .8rem .5rem; color: var(--text); text-decoration: none;
  border-left: 3px solid transparent; font-weight: 500;
}
.tabs a:hover { background: var(--surface); }
.tabs a[aria-current="page"] { border-left-color: var(--accent); color: var(--accent); font-weight: 700; }
.nav-aside { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .5rem; border-top: 1px solid var(--border); margin-top: .5rem; }
.nav-aside a { font-size: .85rem; color: var(--muted); }
.nav-aside a[aria-current="page"] { color: var(--text); font-weight: 600; }
.theme-btn { font-size: .85rem; color: var(--muted); min-height: 2.25rem; padding: .2rem .7rem; }

@media (min-width: 48em) {
  .menu-btn { display: none; }
  .nav, html.js .nav { display: flex !important; flex: 1; flex-basis: auto; align-items: center; gap: 1rem; }
  .tabs { display: flex; gap: .25rem; }
  .tabs a { border-left: 0; border-bottom: 3px solid transparent; padding: .9rem .9rem .7rem; }
  .tabs a[aria-current="page"] { border-bottom-color: var(--accent); }
  .nav-aside { margin: 0 0 0 auto; padding: 0; border: 0; flex-wrap: nowrap; }
  .nav-aside a { white-space: nowrap; }
}

/* ---------- Pied de page ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 4rem; padding-block: 1.5rem; font-size: .875rem; color: var(--muted); }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; justify-content: space-between; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }

/* ---------- Contenu ---------- */
.page-head { padding-block: 2.5rem 1rem; }
.hero { padding-block: 3rem 1rem; }
.cards { list-style: none; margin: 1.5rem 0 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); }
.card {
  display: flex; flex-direction: column; height: 100%; padding: 1.1rem 1.2rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.card p { color: var(--muted); margin-bottom: .75rem; }
.card :last-child { margin-bottom: 0; }
a.card { text-decoration: none; color: var(--text); transition: border-color .15s; }
a.card:hover, a.card:focus-visible { border-color: var(--accent); }
a.card h3 { color: var(--accent); }
.card .more { margin-top: auto; font-weight: 600; color: var(--accent); }
.card img { border-radius: 6px; margin-bottom: .75rem; width: 100%; background: var(--bg); }
.btn {
  display: inline-block; padding: .7rem 1.2rem; min-height: 2.75rem; border-radius: var(--radius);
  background: var(--accent); color: var(--on-accent); font-weight: 600; text-decoration: none; border: 0; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--accent-strong); color: var(--on-accent); }
.btn[aria-disabled="true"] { background: var(--surface); color: var(--muted); border: 1px dashed var(--border); cursor: not-allowed; }

/* Grille D3 des 30 jours */
.grid30 { position: relative; max-width: 40rem; margin-top: 1rem; }
.grid30 svg { display: block; width: 100%; height: auto; overflow: visible; }
.grid30 .cell rect { fill: transparent; stroke: var(--border); stroke-width: 2; }
.grid30 .cell text { fill: var(--muted); font: 600 22px var(--font); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.grid30 .cell.on rect { fill: var(--accent); stroke: var(--accent); }
.grid30 .cell.on text { fill: var(--on-accent); }
.grid30 a.cell { cursor: pointer; outline: none; }
.grid30 a.cell:hover rect, .grid30 a.cell:focus-visible rect { stroke: var(--focus); stroke-width: 5; }
.tip {
  position: absolute; z-index: 5; pointer-events: none; max-width: 15rem; padding: .45rem .7rem;
  background: var(--text); color: var(--bg); border-radius: 6px; font-size: .85rem; line-height: 1.35;
  transform: translate(-50%, calc(-100% - 8px)); box-shadow: 0 2px 8px rgb(0 0 0 / .25);
}
.tip[hidden] { display: none; }
.legend { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin-top: .75rem; font-size: .875rem; color: var(--muted); }
.legend i { display: inline-block; width: .9rem; height: .9rem; border-radius: 3px; margin-right: .4rem; vertical-align: -.1rem; border: 2px solid var(--border); }
.legend i.on { background: var(--accent); border-color: var(--accent); }

/* Galerie de cartes */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: 1rem 0 1.5rem; }
.toolbar select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .5rem .8rem; min-height: 2.75rem;
}
.gallery { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); }
.gallery figure { margin: 0; }
.gallery .thumb { display: block; width: 100%; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); cursor: zoom-in; }
.gallery .thumb { aspect-ratio: 4 / 3; }
.gallery .thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery figcaption { padding-top: .5rem; font-size: .9rem; }
.gallery figcaption strong { display: block; font-size: 1rem; }
.gallery figcaption span { color: var(--muted); }
.year-block h2 { margin: 2rem 0 1rem; }
.year-block:first-child h2 { margin-top: 0; }
.gallery li.target .thumb { outline: 3px solid var(--accent); outline-offset: 3px; }

dialog.lightbox {
  width: min(96vw, 64rem); max-height: 96vh; padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--text); overflow: auto;
}
dialog.lightbox::backdrop { background: rgb(0 0 0 / .75); }
.lb-body { display: grid; gap: 0; }
.lb-body img { width: 100%; max-height: 62vh; object-fit: contain; background: var(--surface); }
.lb-text { padding: 1rem 1.25rem 1.25rem; }
.lb-text h2 { margin: 0 0 .25rem; font-size: 1.3rem; }
.lb-text dl { margin: .75rem 0 0; display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; font-size: .9rem; }
.lb-text dt { color: var(--muted); }
.lb-text dd { margin: 0; }
.lb-nav { display: flex; gap: .5rem; padding: 0 1.25rem 1.25rem; flex-wrap: wrap; }
.lb-close { position: absolute; top: .5rem; right: .5rem; background: var(--bg); }
body:has(dialog[open]) { overflow: hidden; }


/* Contrôles : vues, puces, filtres */
.controls { display: flex; flex-direction: column; gap: 1rem; margin: 1rem 0 1.5rem; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.25rem; }
.filters[hidden], .chips[hidden], .theme-filter[hidden] { display: none; }
.theme-filter { display: flex; align-items: center; gap: .5rem; }
.theme-filter select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .4rem .7rem; min-height: 2.5rem; max-width: 100%;
}
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 1.5rem; background: var(--surface); align-self: flex-start; }
.seg-btn { font: inherit; color: var(--text); background: transparent; border: 0; border-radius: 999px; padding: .5rem 1rem; min-height: 2.5rem; cursor: pointer; }
.seg-btn:hover { background: var(--border); }
.seg-btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .75rem; }
.controls .chips, .toolbar .chips { margin-top: 0; }
.chip {
  font: inherit; font-size: .9rem; color: var(--text); background: transparent; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; padding: .3rem .85rem; min-height: 2.25rem;
}
.chip:hover { background: var(--surface); }
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--surface); font-weight: 700; }
.badge { display: inline-block; align-self: flex-start; font-size: .75rem; font-weight: 600; padding: .1rem .55rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); margin-bottom: .4rem; }

/* Visualisations */
.viz-card img { aspect-ratio: 4 / 3; object-fit: cover; }
.badge-line { color: var(--muted); font-weight: 600; margin-bottom: .5rem; }
.embed { margin-top: 1.5rem; }
.embed iframe { display: block; width: 100%; height: min(78vh, 720px); min-height: 420px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.embed img { display: block; width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.embed-actions { margin: .75rem 0 0; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.25rem; margin: 1.5rem 0 0; max-width: 44rem; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }

/* Divers */
.project { display: grid; gap: 1rem; padding: 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1.25rem; }
.project img { border-radius: 8px; width: 100%; max-width: 28rem; }
.project h2 { margin: 0 0 .5rem; }
.project ul { padding-left: 1.2rem; margin: 0 0 1rem; }
@media (min-width: 48em) { .project { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.project.is-todo { border-style: dashed; }

.prose { max-width: 44rem; }
.prose h2 { margin-top: 2.5rem; }
.prose dt { font-weight: 600; margin-top: .75rem; }
.prose dd { margin: 0; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
