/*
 * Editorial core 1.1 — Carnet de terrain grenoblois, une page une enquête.
 * Shared typography, reading rhythm and accessible content primitives only.
 * Page-specific composition lives in assets/css/pages/.
 */

body.dg-editorial {
  --dg-paper: #f8f4ed;
  --dg-surface: #fffdf8;
  --dg-ink: #18324a;
  --dg-text: #2d4653;
  --dg-muted: #60717a;
  --dg-line: #d8d4cb;
  --dg-rust: #ad5938;
  --dg-rust-soft: #f1dfd4;
  --dg-sage: #dce7df;
  --dg-blue-soft: #dfeaf0;
  --dg-plum: #79405e;
  --dg-shadow: 0 20px 55px -44px rgba(24, 50, 74, 0.55);
  --dg-measure: 70ch;
  --dg-heading-measure: 42rem;
  --dg-section-space: clamp(2.75rem, 5vw, 4.5rem);
  background: var(--dg-paper);
  color: var(--dg-text);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.7;
}

body.dg-editorial .dg-page {
  min-width: 0;
  overflow-wrap: anywhere;
}

body.dg-editorial .dg-shell,
body.dg-editorial .dg-page .container {
  margin-inline: auto;
  max-width: 1180px;
  padding-inline: clamp(1.25rem, 4vw, 3rem);
}

html.js body.dg-editorial img[data-dg-media] {
  opacity: 0;
  transition: opacity 180ms ease;
}

html.js body.dg-editorial .is-loaded > img[data-dg-media],
html.js body.dg-editorial img[data-dg-media].is-loaded {
  opacity: 1;
}

html.js body.dg-editorial .is-failed > img[data-dg-media],
html.js body.dg-editorial img[data-dg-media].is-failed {
  opacity: 0;
}

body.dg-editorial .dg-page h1,
body.dg-editorial .dg-page h2,
body.dg-editorial .dg-page h3 {
  color: var(--dg-ink);
  font-family: var(--font-title);
  font-weight: 600;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

body.dg-editorial .dg-page :where(h2, h3, h4, [id]) {
  scroll-margin-top: 7rem;
}

body.dg-editorial .dg-page h1 {
  font-size: clamp(2.7rem, 5.2vw, 4rem);
  line-height: 1;
  margin: 0;
  max-width: 16ch;
}

body.dg-editorial .dg-page h2 {
  font-size: clamp(2rem, 3.8vw, 2.75rem);
  line-height: 1.06;
  margin: 0;
  max-width: min(100%, var(--dg-heading-measure));
}

body.dg-editorial .dg-page h3 {
  font-size: clamp(1.35rem, 2.3vw, 1.7rem);
  line-height: 1.15;
  margin: 0 0 0.75rem;
}

body.dg-editorial .dg-page p,
body.dg-editorial .dg-page li {
  text-wrap: pretty;
}

body.dg-editorial .dg-page a {
  color: #68334e;
  text-decoration-color: rgba(121, 64, 94, 0.5);
  text-decoration-thickness: 0.09em;
  text-underline-offset: 0.2em;
}

body.dg-editorial .dg-page a:hover {
  color: var(--dg-rust);
  text-decoration-color: currentColor;
}

body.dg-editorial .dg-page :focus-visible,
body.dg-editorial .dg-toc :focus-visible {
  outline: 3px solid #2b7693;
  outline-offset: 4px;
}

.dg-kicker {
  color: var(--dg-rust);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  margin: 0 0 0.85rem;
  text-transform: uppercase;
}

.dg-lede {
  color: var(--dg-text);
  font-family: var(--font-title);
  font-size: clamp(1.3rem, 2.1vw, 1.6rem);
  line-height: 1.42;
  margin: 1.5rem 0;
  max-width: 65ch;
}

.dg-meta {
  color: var(--dg-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.9rem;
  gap: 0.35rem 1rem;
  margin: 1.25rem 0 0;
}

.dg-hero {
  background: var(--dg-surface);
  border-bottom: 1px solid var(--dg-line);
  min-height: 0;
  padding-block: clamp(2.75rem, 5vw, 4.5rem);
}

.dg-hero__inner {
  align-items: center;
  display: grid;
  gap: clamp(2rem, 6vw, 5rem);
  grid-template-columns: minmax(0, 1fr);
}

.dg-hero__copy {
  max-width: 760px;
}

.dg-hero__visual {
  min-width: 0;
}

.dg-editorial-image {
  align-self: center;
  margin: 0;
  min-width: 0;
  position: relative;
  width: 100%;
}

.dg-editorial-image img {
  aspect-ratio: 4 / 3;
  border: 1px solid color-mix(in srgb, var(--dg-ink) 18%, transparent);
  display: block;
  height: auto;
  object-fit: cover;
  width: 100%;
}

.dg-editorial-image figcaption {
  color: currentColor;
  font-size: 0.78rem;
  line-height: 1.35;
  margin: 0.85rem 0 0;
  max-width: 48ch;
  opacity: 0.82;
}

.dg-note {
  background: var(--dg-rust-soft);
  border: 1px solid color-mix(in srgb, var(--dg-rust) 42%, var(--dg-line));
  border-radius: 10px;
  color: var(--dg-ink);
  margin: 1.5rem 0;
  max-width: 68ch;
  padding: 1rem 1.15rem;
}

.dg-note > :last-child {
  margin-bottom: 0;
}

.dg-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-top: 1.5rem;
}

.dg-button {
  align-items: center;
  background: var(--dg-ink);
  border: 1px solid var(--dg-ink);
  border-radius: 999px;
  color: var(--dg-surface) !important;
  display: inline-flex;
  font-size: 0.95rem;
  font-weight: 700;
  justify-content: center;
  min-height: 44px;
  padding: 0.65rem 1.15rem;
  text-decoration: none !important;
}

.dg-button:hover {
  background: var(--dg-rust);
  border-color: var(--dg-rust);
}

.dg-button--quiet {
  background: transparent;
  color: var(--dg-ink) !important;
}

.dg-section,
body.dg-editorial .dg-page .dg-section--surface,
body.dg-editorial .dg-page .dg-section--tint {
  background: transparent;
  min-height: 0;
  padding-block: var(--dg-section-space);
}

body.dg-editorial .dg-page .dg-section-head {
  display: block;
  margin-bottom: clamp(1.5rem, 3vw, 2.25rem);
  max-width: var(--dg-heading-measure);
}

body.dg-editorial .dg-page .dg-section-head > * + * {
  margin-top: 0.75rem;
}

body.dg-editorial .dg-page .dg-section-head .dg-kicker {
  margin-bottom: 0;
}

.dg-section-lede {
  color: var(--dg-muted);
  font-size: 1.0625rem;
  margin: 0;
  max-width: 68ch;
}

.dg-prose {
  max-width: var(--dg-measure);
}

.dg-prose > * + * {
  margin-top: 1rem;
}

.dg-prose h3 {
  margin-top: 2rem;
}

.dg-prose ul,
.dg-prose ol {
  padding-inline-start: 1.25rem;
}

.dg-prose li + li {
  margin-top: 0.45rem;
}

.dg-columns {
  display: grid;
  gap: clamp(1.5rem, 4vw, 3.5rem);
  grid-template-columns: minmax(0, 1fr);
}

.dg-card-list {
  display: grid;
  gap: 0;
  grid-template-columns: minmax(0, 1fr);
  list-style: none;
  margin: 0;
  max-width: var(--dg-measure);
  padding: 0;
}

body.dg-editorial .dg-page .dg-card {
  background: transparent;
  border: 0;
  border-radius: 0;
  border-top: 1px solid var(--dg-line);
  box-shadow: none;
  padding: clamp(1.15rem, 2.5vw, 1.6rem) 0;
}

.dg-card > :last-child {
  margin-bottom: 0;
}

.dg-card dd {
  margin: 0;
}

.dg-card__label {
  color: var(--dg-rust);
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  margin-bottom: 0.55rem;
  text-transform: uppercase;
}

.dg-checklist {
  display: grid;
  gap: 0;
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
}

.dg-checklist li {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--dg-line);
  border-radius: 0;
  padding: 1rem 0 1rem 2.5rem;
  position: relative;
}

.dg-checklist li::before {
  color: var(--dg-rust);
  content: "✓";
  font-weight: 700;
  height: auto;
  left: 0;
  position: absolute;
  top: 1rem;
  width: 1.5rem;
}

.dg-facts {
  display: grid;
  gap: 0;
  margin: 1.5rem 0 0;
}

.dg-facts > div {
  border-top: 1px solid var(--dg-line);
  padding-block: 1rem;
}

.dg-facts dt {
  color: var(--dg-ink);
  font-weight: 700;
}

.dg-facts dd {
  margin: 0.25rem 0 0;
}

.dg-table-wrap {
  overflow-x: auto;
}

.dg-table {
  border-collapse: collapse;
  min-width: 680px;
  width: 100%;
}

.dg-table th,
.dg-table td {
  border-bottom: 1px solid var(--dg-line);
  padding: 1rem;
  text-align: left;
  vertical-align: top;
}

.dg-table th {
  color: var(--dg-ink);
  font-size: 0.84rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dg-timeline {
  counter-reset: dg-step;
  list-style: none;
  margin: 1.5rem 0 0;
  max-width: 70ch;
  padding: 0;
}

.dg-timeline li {
  counter-increment: dg-step;
  padding: 0 0 1.5rem 3.8rem;
  position: relative;
}

.dg-timeline li::before {
  align-items: center;
  background: var(--dg-ink);
  border-radius: 50%;
  color: var(--dg-surface);
  content: counter(dg-step);
  display: flex;
  font-weight: 700;
  height: 2.5rem;
  justify-content: center;
  left: 0;
  position: absolute;
  top: 0;
  width: 2.5rem;
}

.dg-timeline li:not(:last-child)::after {
  background: var(--dg-line);
  content: "";
  height: calc(100% - 2.5rem);
  left: 1.22rem;
  position: absolute;
  top: 2.5rem;
  width: 1px;
}

.dg-disclosure {
  border-top: 1px solid var(--dg-line);
}

.dg-disclosure__item {
  border-bottom: 1px solid var(--dg-line);
}

.dg-disclosure summary {
  align-items: center;
  color: var(--dg-ink);
  cursor: pointer;
  display: grid;
  font-family: var(--font-title);
  font-size: 1.3rem;
  font-weight: 600;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr) 2rem;
  list-style: none;
  min-height: 60px;
  padding-block: 1rem;
}

.dg-disclosure summary::-webkit-details-marker {
  display: none;
}

.dg-disclosure summary::after {
  align-items: center;
  border: 1px solid var(--dg-line);
  border-radius: 50%;
  content: "+";
  display: flex;
  font-family: var(--font-body);
  font-size: 1.25rem;
  font-weight: 500;
  height: 2rem;
  justify-content: center;
  width: 2rem;
}

.dg-disclosure details[open] summary::after {
  content: "−";
}

.dg-disclosure__body {
  max-width: 68ch;
  padding: 0 2.75rem 1.25rem 0;
}

body.dg-editorial .dg-page .dg-sources {
  background: transparent;
  border-top: 1px solid var(--dg-line);
  padding-block: var(--dg-section-space);
}

.dg-sources h2 {
  font-family: var(--font-body) !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
  letter-spacing: 0 !important;
  margin-bottom: 1rem !important;
}

.dg-sources li + li {
  margin-top: 0.5rem;
}

.dg-sources a {
  align-items: center;
  display: inline-flex;
  min-height: 44px;
}

.dg-toc {
  background: var(--dg-surface);
  border-bottom: 1px solid var(--dg-line);
}

.dg-toc .dg-shell {
  padding-block: 0.85rem;
}

.dg-toc details {
  max-width: 100%;
}

.dg-toc summary {
  color: var(--dg-ink);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
  list-style: none;
  min-height: 44px;
  padding-block: 0.55rem;
}

.dg-toc summary::-webkit-details-marker {
  display: none;
}

.dg-toc summary::before {
  content: "+";
  display: inline-block;
  margin-right: 0.65rem;
  width: 1rem;
}

.dg-toc details[open] summary::before {
  content: "−";
}

.dg-toc ol {
  display: grid;
  gap: 0.35rem 1.5rem;
  grid-template-columns: minmax(0, 1fr);
  list-style: none;
  margin: 0;
  padding: 0.25rem 0 1rem;
}

.dg-toc a {
  align-items: center;
  color: var(--dg-muted);
  display: flex;
  font-size: 0.9rem;
  line-height: 1.35;
  min-height: 44px;
  padding-block: 0.45rem;
  text-decoration: none;
}

.dg-toc a:hover,
.dg-toc a[aria-current="location"] {
  color: var(--dg-rust);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

@media (min-width: 48rem) {
  .dg-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dg-card-list--3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .dg-facts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dg-facts > div {
    border-left: 1px solid var(--dg-line);
    border-top: 0;
    padding: 0 1.25rem;
  }

  .dg-facts > div:first-child {
    border-left: 0;
    padding-left: 0;
  }

  .dg-toc ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 47.99rem) {
  body.dg-editorial {
    font-size: 17px;
    line-height: 1.65;
  }

  body.dg-editorial .dg-page h1 {
    font-size: clamp(2.35rem, 10.8vw, 2.8rem);
    max-width: none;
  }

  body.dg-editorial .dg-page h2 {
    font-size: clamp(1.9rem, 9vw, 2.35rem);
    max-width: none;
  }

  .dg-lede {
    font-size: 1.16rem;
    line-height: 1.38;
  }

  .dg-meta {
    display: grid;
  }

  .dg-table-wrap {
    margin-inline: -1.25rem;
    padding-inline: 1.25rem;
  }

  .dg-hero {
    padding-block: 1.5rem 2.5rem;
  }

  .dg-editorial-image img {
    aspect-ratio: 16 / 10;
  }

  .dg-section,
  body.dg-editorial .dg-page .dg-section--surface,
  body.dg-editorial .dg-page .dg-section--tint {
    padding-block: clamp(2.25rem, 10vw, 3rem);
  }
}

@media print {
  .site-header,
  .site-footer,
  .dg-toc,
  .dg-actions {
    display: none !important;
  }

  body.dg-editorial,
  .dg-section,
  .dg-hero {
    background: var(--dg-surface) !important;
  }

  .dg-card,
  .dg-note,
  .dg-checklist li {
    box-shadow: none !important;
    break-inside: avoid;
  }
}

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