/* ============================================================
   Shared chapter page styles — SQUALP / Isoar V2
   Used by: architecture-fonctionnelle.html, organisation.html, …
   ============================================================ */

@view-transition { navigation: auto; }

:root {
  --mondrian-red: #D4213D;
  --mondrian-blue: #1B3F8B;
  --mondrian-yellow: #F5C518;
  --mondrian-black: #1A1A1A;
  --mondrian-white: #F7F4EF;
  --mondrian-cream: #FAF8F3;
  --mondrian-line: 4px;
  --page-bg: #2C3E50;
}

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

body {
  background: var(--page-bg);
  min-height: 100vh;
  font-family: 'DM Sans', sans-serif;
  color: var(--mondrian-black);
  overflow-x: hidden;
}

/* === Top navigation bar (shared) === */
.page-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 16px 36px;
  background: var(--mondrian-black);
  border-bottom: 4px solid var(--mondrian-red);
  overflow: hidden;
  transition:
    max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    border-bottom-width 0.3s ease;
  max-height: 220px;
}
.page-bar.is-collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-bottom-width: 0;
}
.page-bar__toggle {
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.28);
  color: white;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: 'Space Mono', monospace;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.page-bar__toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.55);
  transform: translateY(-1px);
}
.page-bar-show {
  position: fixed;
  top: 0;
  right: 24px;
  z-index: 100;
  background: var(--mondrian-yellow);
  color: var(--mondrian-black);
  border: 2px solid var(--mondrian-black);
  border-top: none;
  padding: 7px 18px;
  cursor: pointer;
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.18s ease, color 0.18s ease, transform 0.2s ease;
}
.page-bar-show[hidden] {
  display: none;
}
.page-bar-show:hover {
  background: var(--mondrian-red);
  color: white;
  transform: translateY(2px);
}
.page-bar__home {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  background: var(--mondrian-white);
  color: var(--mondrian-black);
  padding: 6px 18px;
  border: 2px solid var(--mondrian-black);
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease;
}
.page-bar__home:hover { transform: translateY(-1px); background: var(--mondrian-yellow); }
.page-bar__crumbs {
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.page-bar__crumbs a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  transition: color 0.15s ease;
}
.page-bar__crumbs a:hover { color: var(--mondrian-yellow); }
.page-bar__crumbs .sep { margin: 0 10px; color: rgba(255,255,255,0.3); }
.page-bar__crumbs [aria-current] { color: var(--mondrian-yellow); font-weight: 700; }
.page-bar__back {
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mondrian-black);
  background: var(--mondrian-yellow);
  padding: 9px 18px;
  border: 2px solid var(--mondrian-black);
  text-decoration: none;
  font-weight: 700;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
}
.page-bar__back:hover {
  background: var(--mondrian-red);
  color: white;
  transform: translateX(-2px);
}

/* === Chapter content card === */
.chapter-content {
  max-width: 1280px;
  margin: 36px auto 60px;
  background: var(--mondrian-cream);
  border: 4px solid var(--mondrian-black);
  box-shadow: 0 30px 80px rgba(0,0,0,0.4);
}
.chapter-content__header {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 28px 56px 24px;
  border-bottom: 4px solid var(--mondrian-black);
  background: var(--mondrian-white);
}
.chapter-badge {
  background: var(--mondrian-red);
  color: white;
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 9px 18px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}
.chapter-content__header h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.6rem, 2.6vw, 2.5rem);
  font-weight: 900;
  line-height: 1;
  color: var(--mondrian-black);
  flex: 1;
}
.chapter-content__body {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
}

/* Text column */
.chapter-text {
  padding: 38px 42px 38px 56px;
  border-right: 4px solid var(--mondrian-black);
}
.chapter-text h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  font-weight: 900;
  margin-bottom: 14px;
  color: var(--mondrian-black);
}
.chapter-lead {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.1rem;
  line-height: 1.55;
  color: var(--mondrian-black);
  font-weight: 500;
  margin-bottom: 18px;
  border-left: 4px solid var(--mondrian-red);
  padding-left: 18px;
}
.chapter-text p {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.96rem;
  line-height: 1.6;
  color: rgba(26,26,26,0.85);
  margin-bottom: 14px;
}
.chapter-bullets { margin: 12px 0 18px 0; padding-left: 0; list-style: none; }
.chapter-bullets li {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem;
  line-height: 1.55;
  color: rgba(26,26,26,0.85);
  padding-left: 26px;
  margin-bottom: 10px;
  position: relative;
}
.chapter-bullets li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 12px;
  height: 12px;
  background: var(--mondrian-red);
  border: 2px solid var(--mondrian-black);
}
.chapter-tag {
  margin-top: 22px;
  padding: 14px 18px;
  background: var(--mondrian-blue);
  color: white;
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  font-style: italic;
  border: 3px solid var(--mondrian-black);
}

/* === Modules grid (Architecture fonctionnelle) — flow with connectors === */
.modules-grid {
  padding: 36px 40px 40px;
  background: var(--mondrian-cream);
}

/* Flow grid: 5 columns (3 cells + 2 arrow gaps).
   Default: 4 module rows (Architecture fonctionnelle).
   .is-three-rows: 3 module rows (Architecture technique). */
.mg-flow {
  display: grid;
  grid-template-columns: 1fr 26px 1fr 26px 1fr;
  grid-template-rows:
    auto 22px
    auto 22px
    auto 22px
    auto 22px
    auto 26px
    auto;
  gap: 0;
}
.mg-flow.is-three-rows {
  grid-template-rows:
    auto 22px
    auto 22px
    auto 22px
    auto 26px
    auto;
}
.mg-title {
  grid-column: 1 / 6;
  grid-row: 1;
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 900;
  text-align: center;
  background: var(--mondrian-white);
  padding: 14px 20px;
  border: 3px solid var(--mondrian-black);
}
.mg-squalp {
  grid-column: 1 / 6;
  grid-row: 11;
  text-align: center;
  background: var(--mondrian-white);
  border: 3px solid var(--mondrian-black);
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.mg-squalp-logo {
  display: block;
  height: 40px;
  width: auto;
  max-width: 80%;
}
.mg-squalp-tagline {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 0.92rem;
  color: rgba(26,26,26,0.75);
}

.module-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 8px;
  border: 3px solid var(--mondrian-black);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 3px 3px 0 var(--mondrian-black);
  min-height: 84px;
  text-align: center;
}
.module-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--mondrian-black);
}
.module-card.mod-blue { background: var(--mondrian-blue); color: white; }
.module-card.mod-red { background: var(--mondrian-red); color: white; }
.module-card.mod-yellow { background: var(--mondrian-yellow); color: var(--mondrian-black); }
.module-card.mod-gray { background: #6b7380; color: white; }
.mod-name {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
}
.mod-acronym {
  font-family: 'Space Mono', monospace;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  margin-top: 8px;
  opacity: 0.9;
}

/* Multi-line card variant (Architecture technique cards with title + list) */
.module-card.mod-multi {
  align-items: stretch;
  justify-content: flex-start;
  padding: 14px 14px 16px;
  text-align: left;
  min-height: 116px;
}
.mod-multi .mod-name {
  font-family: 'Playfair Display', serif;
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1.05;
  padding-bottom: 7px;
  border-bottom: 2px solid rgba(255,255,255,0.45);
  margin-bottom: 8px;
}
.module-card.mod-yellow.mod-multi .mod-name { border-bottom-color: rgba(0,0,0,0.35); }
.mod-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  line-height: 1.4;
  font-weight: 500;
}
.mod-list li {
  padding: 1px 0;
  letter-spacing: 0.005em;
}
.mod-tagline {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 0.88rem;
  line-height: 1.3;
  font-weight: 500;
}

/* Text-only footer (Architecture technique) */
.mg-text-footer {
  grid-column: 1 / 6;
  text-align: center;
  background: var(--mondrian-white);
  border: 3px solid var(--mondrian-black);
  padding: 18px 24px;
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1.2;
  color: var(--mondrian-blue);
  letter-spacing: 0.005em;
}

/* Connector arrows (red Mondrian) */
.arr {
  display: block;
  position: relative;
  pointer-events: none;
}
.arr-right {
  width: 100%;
  height: 14px;
  align-self: center;
}
.arr-right::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 7px;
  height: 2px;
  background: var(--mondrian-red);
  transform: translateY(-50%);
}
.arr-right::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 0;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid var(--mondrian-red);
  transform: translateY(-50%);
}
.arr-down {
  height: 100%;
  width: 14px;
  justify-self: center;
}
.arr-down::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 7px;
  width: 2px;
  background: var(--mondrian-red);
  transform: translateX(-50%);
}
.arr-down::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 8px solid var(--mondrian-red);
  transform: translateX(-50%);
}

/* === MCD vertical diagram (Organisation) === */
.mcd-vertical {
  padding: 36px 38px;
  background: var(--mondrian-cream);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.mcd-vertical-title {
  background: var(--mondrian-white);
  border: 3px solid var(--mondrian-black);
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 900;
  text-align: center;
  padding: 14px 16px;
  line-height: 1.15;
}
.mcd-section { display: flex; flex-direction: column; gap: 6px; }
.mcd-section-label {
  background: var(--mondrian-white);
  border: 2px solid var(--mondrian-black);
  font-family: 'Playfair Display', serif;
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
  padding: 7px 12px;
  font-style: italic;
}
.mcd-section-blocks {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}
.mcd-block {
  padding: 12px 6px;
  text-align: center;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 0.76rem;
  line-height: 1.2;
  color: white;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--mondrian-black);
  box-shadow: 2px 2px 0 var(--mondrian-black);
}
.mcd-block.mcd-red { background: var(--mondrian-red); }
.mcd-block.mcd-blue { background: var(--mondrian-blue); }
.mcd-vertical-footer {
  margin-top: 8px;
  padding: 14px 18px;
  background: var(--mondrian-blue);
  color: white;
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  border: 3px solid var(--mondrian-black);
}

/* === Chapter pagination (prev / next) === */
.chapter-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 4px solid var(--mondrian-black);
  background: var(--mondrian-white);
}
.chapter-nav__item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 22px 32px;
  text-decoration: none;
  color: var(--mondrian-black);
  transition: background 0.2s ease, transform 0.2s ease;
  position: relative;
}
.chapter-nav__prev { border-right: 4px solid var(--mondrian-black); text-align: left; }
.chapter-nav__next { text-align: right; align-items: flex-end; }
.chapter-nav__item:hover {
  background: var(--mondrian-cream);
}
.chapter-nav__prev:hover { transform: translateX(-3px); }
.chapter-nav__next:hover { transform: translateX(3px); }
.chapter-nav__label {
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mondrian-red);
  font-weight: 700;
}
.chapter-nav__title {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
}
.chapter-nav__hint {
  font-family: 'Space Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(26,26,26,0.5);
  margin-top: 4px;
  font-weight: 700;
}
.chapter-nav__item.is-coming {
  pointer-events: none;
  opacity: 0.55;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 8px,
    rgba(0,0,0,0.025) 8px,
    rgba(0,0,0,0.025) 16px
  );
}

/* === Mobile === */
@media (max-width: 900px) {
  .page-bar { padding: 12px 18px; gap: 10px; }
  .page-bar__home { font-size: 0.85rem; padding: 5px 12px; letter-spacing: 0.14em; }
  .page-bar__crumbs { font-size: 0.6rem; letter-spacing: 0.1em; }
  .page-bar__crumbs .sep { margin: 0 6px; }
  .page-bar__back { font-size: 0.62rem; padding: 7px 12px; }
  .page-bar__toggle { width: 32px; height: 32px; font-size: 0.78rem; }
  .page-bar-show { font-size: 0.66rem; padding: 6px 14px; right: 12px; }

  .chapter-content { margin: 18px auto 30px; }
  .chapter-content__header { padding: 22px 22px 18px; gap: 14px; flex-wrap: wrap; }
  .chapter-content__header h1 { font-size: 1.2rem; }
  .chapter-badge { font-size: 0.6rem; padding: 6px 12px; }
  .chapter-content__body { grid-template-columns: 1fr; }
  .chapter-text {
    padding: 24px 22px;
    border-right: none;
    border-bottom: 4px solid var(--mondrian-black);
  }
  .chapter-lead { font-size: 1rem; padding-left: 14px; }
  .chapter-text p { font-size: 0.9rem; }
  .chapter-text h2 { font-size: 1.1rem; }
  .chapter-tag { font-size: 0.88rem; }

  .modules-grid { padding: 22px 18px; }
  .mg-flow {
    grid-template-columns: 1fr 18px 1fr 18px 1fr;
    grid-template-rows:
      auto 16px
      auto 16px
      auto 16px
      auto 16px
      auto 20px
      auto;
  }
  .mg-title { font-size: 1.05rem; padding: 10px 14px; }
  .mg-squalp { padding: 10px 14px; }
  .mg-squalp-logo { height: 30px; }
  .mg-squalp-tagline { font-size: 0.78rem; }
  .module-card { padding: 10px 4px; min-height: 64px; }
  .mod-name { font-size: 0.78rem; }
  .mod-acronym { font-size: 0.56rem; margin-top: 5px; letter-spacing: 0.14em; }
  .module-card.mod-multi { padding: 10px 8px; min-height: 90px; }
  .mod-multi .mod-name { font-size: 0.78rem; padding-bottom: 5px; margin-bottom: 5px; }
  .mod-list { font-size: 0.66rem; line-height: 1.3; }
  .mod-tagline { font-size: 0.7rem; }
  .mg-text-footer { padding: 12px 14px; font-size: 0.84rem; }
  .arr-right, .arr-down { height: 100%; width: 100%; }
  .arr-right::after { border-top-width: 4px; border-bottom-width: 4px; border-left-width: 6px; }
  .arr-down::after { border-left-width: 4px; border-right-width: 4px; border-top-width: 6px; }

  .mcd-vertical { padding: 22px 16px; }
  .mcd-section-blocks { gap: 5px; }
  .mcd-block { font-size: 0.66rem; min-height: 50px; padding: 8px 4px; }
  .mcd-section-label { font-size: 0.78rem; }
  .mcd-vertical-footer { font-size: 0.84rem; }

  .chapter-nav { grid-template-columns: 1fr; }
  .chapter-nav__item { padding: 16px 22px; }
  .chapter-nav__prev { border-right: none; border-bottom: 4px solid var(--mondrian-black); }
  .chapter-nav__next { text-align: right; align-items: flex-end; }
  .chapter-nav__title { font-size: 0.95rem; }
  .chapter-nav__label { font-size: 0.6rem; }
}
