@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600&family=DM+Sans:wght@300;400;500&display=swap');

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

:root {
  --paper:    #f5f2ea;
  --paper2:   #efeae0;
  --paper3:   #e6e0d2;
  --ink:      #1e1d18;
  --muted:    #7a7870;
  --border:   rgba(30,29,24,0.16);
  --border-soft: rgba(30,29,24,0.08);
  --c-gis:    #2e9e88;
  --c-env:    #c49a18;
  --c-tool:   #7c6fcd;
  --c-arch:   #c2712a;
  --ff-serif: 'Playfair Display', Georgia, serif;
  --ff-sans:  'DM Sans', system-ui, sans-serif;
  --ff-mono:  ui-monospace, 'SF Mono', Menlo, monospace;
}

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ff-sans);
  font-weight: 300;
  line-height: 1.6;
  min-height: 100vh;
  padding: 28px;
}

a { color: inherit; text-decoration: none; }

/* MAP FRAME */
.sheet {
  max-width: 1300px;
  margin: 0 auto;
  border: 1px solid var(--border);
  background: var(--paper);
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: calc(100vh - 56px);
}

/* CARTOUCHE */
.cartouche {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
}

.cartouche-title-wrap {
  padding: 32px 36px 28px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cartouche-eyebrow {
  font-family: var(--ff-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.cartouche-title {
  font-family: var(--ff-serif);
  font-size: clamp(38px, 4.5vw, 56px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin-top: 4px;
}

.cartouche-subtitle {
  font-family: var(--ff-sans);
  font-size: 15px;
  font-weight: 300;
  color: var(--muted);
  margin-top: 10px;
  max-width: 560px;
}
.cartouche-subtitle strong {
  color: var(--ink);
  font-weight: 400;
}
.cartouche-bio {
  font-size: 13px;
  color: var(--muted);
  margin-top: 14px;
  max-width: 480px;
  line-height: 1.6;
  font-style: italic;
}


.north-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.north-logo {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  color: var(--ink);
  transition: background 0.15s, color 0.15s;
}
.north-logo:hover {
  background: var(--ink);
  color: var(--paper);
}
.north-logo svg { width: 15px; height: 15px; }

.north-label {
  font-family: var(--ff-mono);
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

/* BODY LAYOUT */
.body {
  display: grid;
  grid-template-columns: 1fr 260px;
}

.map-area {
  padding: 36px;
  border-right: 1px solid var(--border);
  min-height: 600px;
}

.map-section-label {
  font-family: var(--ff-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.map-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-soft);
}

/* WORKS GRID */
.works-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
@media (max-width: 1050px) { .works-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .works-grid { grid-template-columns: 1fr; } }

.work-card {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}
.work-card:hover {
  border-color: var(--border);
  transform: translateY(-2px);
}

.work-card.featured { grid-column: span 2; }
@media (max-width: 1050px) { .work-card.featured { grid-column: span 2; } }
@media (max-width: 640px)  { .work-card.featured { grid-column: span 1; } }

.card-img-wrap {
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--paper3);
  position: relative;
}
.work-card.featured .card-img-wrap { aspect-ratio: 16/7; }
@media (max-width: 1050px) { .work-card.featured .card-img-wrap { aspect-ratio: 16/7; } }

.card-img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  filter: grayscale(15%) brightness(0.95);
  transition: transform 0.5s cubic-bezier(0.25,0.46,0.45,0.94), filter 0.4s;
}
.work-card:hover .card-img { transform: scale(1.03); filter: grayscale(0%) brightness(0.92); }

.card-img-placeholder {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  background: var(--paper3);
}

.card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  border-top: 1px solid var(--border-soft);
  position: relative;
}

.card-swatch,
.card-fig { display: none; }

.card-cat {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  font-family: var(--ff-mono);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  padding: 2px 6px;
}
.card-cat.s-gis  { color: var(--c-gis);  background: rgba(46,158,136,0.08); }
.card-cat.s-env  { color: var(--c-env);  background: rgba(196,154,24,0.10); }
.card-cat.s-tool { color: var(--c-tool); background: rgba(124,111,205,0.10); }
.card-cat.s-arch { color: var(--c-arch); background: rgba(194,113,42,0.10); }
.card-swatch.s-gis  { background: var(--c-gis); }
.card-swatch.s-env  { background: var(--c-env); }
.card-swatch.s-tool { background: var(--c-tool); }
.card-swatch.s-arch { background: var(--c-arch); }

.card-fig {
  font-family: var(--ff-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.card-title {
  font-family: var(--ff-serif);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.18;
  color: var(--ink);
  margin-top: 2px;
}

.card-desc {
  font-size: 12.5px;
  font-weight: 300;
  color: var(--muted);
  line-height: 1.55;
  margin-top: 6px;
  text-wrap: pretty;
}
.card-meta {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-soft);
  font-family: var(--ff-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.card-meta span { white-space: nowrap; }

/* LEGEND */
.legend {
  padding: 36px 30px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.legend-block-title {
  font-family: var(--ff-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
}

.legend-entries {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.legend-swatch {
  width: 22px;
  height: 14px;
  flex-shrink: 0;
  margin-top: 2px;
  border: 1px solid rgba(30,29,24,0.08);
}
.legend-swatch.s-gis  { background: var(--c-gis); }
.legend-swatch.s-env  { background: var(--c-env); }
.legend-swatch.s-tool { background: var(--c-tool); }
.legend-swatch.s-arch { background: var(--c-arch); }
.legend-swatch.s-all  {
  background: linear-gradient(135deg, var(--c-gis) 0%, var(--c-gis) 25%, var(--c-env) 25%, var(--c-env) 50%, var(--c-tool) 50%, var(--c-tool) 75%, var(--c-arch) 75%);
}

.legend-entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  padding: 6px 8px 6px 4px;
  margin: -6px -8px -6px -4px;
  font: inherit;
  color: inherit;
  transition: background 0.15s;
  border-left: 2px solid transparent;
}
.legend-entry:hover { background: rgba(30,29,24,0.04); }
.legend-entry.active {
  background: rgba(30,29,24,0.06);
  border-left-color: var(--ink);
}
.legend-entry.active .legend-name { color: var(--ink); }

.legend-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.legend-name {
  font-family: var(--ff-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.legend-count {
  font-family: var(--ff-mono);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

/* BIO */
.legend-bio {
  font-size: 13px;
  font-style: italic;
  color: var(--ink);
  line-height: 1.6;
  opacity: 0.7;
}

/* CONTACT */
.legend-contact {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.legend-contact a {
  font-size: 12px;
  font-weight: 400;
  color: var(--ink);
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 4px;
  transition: border-color 0.15s;
  display: inline-block;
}
.legend-contact a:hover { border-color: var(--ink); }
.legend-contact-label {
  font-family: var(--ff-mono);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 2px;
}


/* ── MAP FOOTER (échelle + nord) ── */
.map-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 40px;
  padding-top: 22px;
  border-top: 1px solid var(--border-soft);
}

/* Échelle cartographique */
.echelle {
  display: flex;
  flex-direction: column;
  gap: 6px;
  user-select: none;
}
.echelle-bar {
  display: flex;
  height: 10px;
  width: 150px;
  border: 1px solid var(--border);
}
.echelle-stop {
  flex: 1;
  height: 100%;
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  padding: 0;
  position: relative;
}
.echelle-stop:last-child { border-right: none; }
.echelle-stop:nth-child(odd) { background: var(--ink); }
.echelle-stop:nth-child(even) { background: transparent; }
.echelle-stop::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 5px; height: 5px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.2s;
}
.echelle-stop:nth-child(odd)::after  { background: var(--paper); }
.echelle-stop:nth-child(even)::after { background: var(--ink); }
.echelle-stop.active::after { opacity: 1; }
.echelle-captions {
  display: flex;
  width: 150px;
  font-family: var(--ff-mono);
  font-size: 7.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.echelle-captions span { flex: 1; text-align: center; transition: color 0.2s; }
.echelle-captions span:first-child { text-align: left; }
.echelle-captions span:last-child  { text-align: right; }
.echelle-captions span.active { color: var(--ink); font-weight: 500; }

/* Social links (bottom of legend) */
.legend-socials {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.social-icon {
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.social-icon:hover { background: var(--ink); color: var(--paper); }
.social-icon svg { width: 14px; height: 14px; }

/* ── SCALE (works-grid only, footer stays fixed) ── */
.works-grid { overflow-anchor: none; }
.map-footer { overflow-anchor: auto; }

html[data-scale="compact"] .works-grid { gap: 10px; }
html[data-scale="compact"] .card-body  { padding: 10px 14px 12px; }
html[data-scale="compact"] .card-title { font-size: 14px; }
html[data-scale="compact"] .card-desc  { font-size: 11px; }

html[data-scale="spacious"] .works-grid { gap: 28px; }
html[data-scale="spacious"] .card-body  { padding: 20px 22px 22px; }
html[data-scale="spacious"] .card-title { font-size: 20px; }
html[data-scale="spacious"] .card-desc  { font-size: 14px; }


/* RESPONSIVE */
@media (max-width: 880px) {
  body { padding: 14px; }
  .cartouche { grid-template-columns: 1fr; }
  .cartouche-title-wrap { padding: 24px 22px 20px; }
.body { grid-template-columns: 1fr; }
  .map-area { padding: 24px 22px; border-right: 0; border-bottom: 1px solid var(--border); }
  .legend { padding: 26px 22px; }
}
