/* Guerre de Sécession / Civil War — compléments au gabarit iw-page (main.css) */

.cw-page .guide-section[id] {
  scroll-margin-top: var(--cw-scroll-margin, calc(var(--header-height, 4rem) + 3.25rem + 0.75rem));
}

body.cw-page {
  --cw-us-blue: #0a2463;
  --cw-us-red: #d7263d;
  --cw-toc-height: 3.25rem;
  --cw-scroll-margin: calc(var(--header-height, 4rem) + var(--cw-toc-height) + 0.75rem);
}

.cw-toc-bar {
  position: sticky;
  top: var(--header-height, 4rem);
  z-index: 40;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid rgba(10, 36, 99, 0.12);
  backdrop-filter: blur(8px);
}

.cw-toc-bar__inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: var(--container-max, 72rem);
  margin: 0 auto;
  padding: 0.5rem 1rem;
  position: relative;
}

.cw-toc-bar__toggle {
  display: none;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(10, 36, 99, 0.2);
  border-radius: 8px;
  background: #fff;
  font-weight: 600;
  cursor: pointer;
}

.cw-toc-bar__list {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  overflow-x: auto;
  list-style: none;
  margin: 0;
  padding: 0;
}

.cw-toc-bar__list a {
  display: block;
  white-space: nowrap;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--cw-us-blue);
  text-decoration: none;
}

.cw-toc-bar__list a[aria-current="true"] {
  background: var(--cw-us-blue);
  color: #fff;
}

.cw-stats {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 768px) {
  .cw-stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

.cw-stat {
  position: relative;
  padding: 1.1rem 1rem;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(10, 36, 99, 0.1);
  box-shadow: 0 8px 24px rgba(10, 36, 99, 0.06);
  overflow: hidden;
}

.cw-stat::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(
    90deg,
    #0a2463 0%,
    #1e4a8a 14%,
    #3a86ff 28%,
    #ffffff 42%,
    #ffffff 58%,
    #fca5a5 72%,
    #d7263d 86%,
    #b91c1c 100%
  );
}

.cw-stat__num,
.cw-stat .num {
  display: block;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 800;
  color: var(--cw-us-blue);
}

.cw-stat__label,
.cw-stat .label {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: #3d3834;
}

.cw-anecdotes-theme {
  margin: 1.5rem 0 0.75rem;
  font-size: 1.05rem;
  color: #1a3d32;
  grid-column: 1 / -1;
}

.cw-anecdotes-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .cw-anecdotes-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.cw-anecdote {
  padding: 1rem 1.1rem;
  border-radius: var(--radius, 12px);
  border: 1px solid rgba(10, 36, 99, 0.1);
  background: #fff;
}

.cw-anecdote-num {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--cw-us-blue);
  margin-bottom: 0.35rem;
}

.cw-anecdote h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.cw-anecdote-source {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.78rem;
  font-style: italic;
  color: #64748b;
}

.cw-anecdote__link {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
}

@media (max-width: 767px) {
  .cw-toc-bar__toggle {
    display: inline-flex;
  }

  .cw-toc-bar__list {
    display: none;
    flex-direction: column;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: #fff;
    border-bottom: 1px solid rgba(10, 36, 99, 0.12);
    padding: 0.75rem 1rem;
    max-height: 60vh;
    overflow-y: auto;
  }

  .cw-toc-bar__list.is-open {
    display: flex;
  }
}

/* Stats : liseré drapeau US + base compteur */
.cw-page .iw-stats .iw-stat.cw-stat {
  position: relative;
  overflow: hidden;
  padding-top: calc(1rem + 4px);
}

.cw-page .iw-stats .iw-stat.cw-stat::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1;
  height: 4px;
  background: linear-gradient(
    90deg,
    #0a2463 0%,
    #1e4a8a 14%,
    #3a86ff 28%,
    #ffffff 42%,
    #ffffff 58%,
    #fca5a5 72%,
    #d7263d 86%,
    #b91c1c 100%
  );
}

/* Soldats : cadre pastel par camp */
.cw-soldiers-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 1.25rem;
  margin: 1rem 0 1.25rem;
}

.cw-soldier-card {
  margin: 0;
  border-radius: var(--radius, 14px);
  padding: 6px;
  background: var(--white, #fff);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.cw-soldier-card:hover {
  transform: translateY(-3px);
}

.cw-soldier-card img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: calc(var(--radius, 14px) - 6px);
}

.cw-soldier-card figcaption {
  padding: 0.6rem 0.5rem 0.25rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 0 0 calc(var(--radius, 14px) - 6px) calc(var(--radius, 14px) - 6px);
}

.cw-soldier-card--union {
  background: linear-gradient(160deg, #eef4ff 0%, #e3edfc 55%, #dce8fa 100%);
  box-shadow:
    0 0 0 1px rgba(147, 197, 253, 0.55),
    0 0 0 4px rgba(191, 219, 254, 0.35),
    0 10px 26px rgba(58, 134, 255, 0.1);
}

.cw-soldier-card--union:hover {
  box-shadow:
    0 0 0 1px rgba(147, 197, 253, 0.7),
    0 0 0 5px rgba(191, 219, 254, 0.45),
    0 14px 32px rgba(58, 134, 255, 0.14);
}

.cw-soldier-card--union figcaption {
  color: #1e4a8a;
  background: rgba(219, 234, 254, 0.55);
}

.cw-soldier-card--confed {
  background: linear-gradient(160deg, #fff5f3 0%, #fdeee8 55%, #fae8e0 100%);
  box-shadow:
    0 0 0 1px rgba(253, 186, 168, 0.55),
    0 0 0 4px rgba(254, 215, 170, 0.35),
    0 10px 26px rgba(194, 65, 12, 0.08);
}

.cw-soldier-card--confed:hover {
  box-shadow:
    0 0 0 1px rgba(253, 186, 168, 0.7),
    0 0 0 5px rgba(254, 215, 170, 0.45),
    0 14px 32px rgba(194, 65, 12, 0.12);
}

.cw-soldier-card--confed figcaption {
  color: #9a4a2e;
  background: rgba(254, 226, 226, 0.45);
}

.cw-subheading {
  margin: 1.5rem 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--iw-blue-dark, #0a2463);
}

/* Frise horizontale (aperçu chapitre 8) */
.cw-timeline-strip {
  margin: 0.75rem 0 1.5rem;
  padding: 1rem 0.5rem 0.25rem;
  border-radius: var(--radius, 14px);
  border: 1px solid var(--border, rgba(10, 36, 99, 0.12));
  background: linear-gradient(180deg, #fbfcfe 0%, #f1f3f8 100%);
}

.cw-timeline-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem 0.35rem 0.75rem;
}

.cw-timeline-rail {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0.85rem;
  min-width: min-content;
  position: relative;
  padding: 0.75rem 0 0.35rem;
}

.cw-timeline-rail::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0.35rem;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--iw-tl-neutral, #64748b) 0%,
    var(--iw-tl-us, #3a86ff) 25%,
    var(--iw-tl-uk, #d7263d) 55%,
    var(--iw-tl-us, #3a86ff) 80%,
    var(--iw-blue-dark, #0a2463) 100%
  );
  border-radius: 3px;
  opacity: 0.45;
}

.cw-timeline-mini {
  flex: 0 0 auto;
  width: min(220px, 72vw);
  position: relative;
  margin-top: 0.5rem;
  padding: 0.85rem 0.95rem;
  border-radius: var(--radius, 12px);
  border: 1px solid var(--border, #c5d0e0);
  background: var(--white, #fff);
  box-shadow: var(--shadow-sm, 0 6px 18px rgba(10, 36, 99, 0.08));
}

.cw-timeline-mini::before {
  content: "";
  position: absolute;
  top: -0.65rem;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 3px solid var(--white, #fff);
  box-shadow: 0 0 0 2px rgba(10, 36, 99, 0.15);
  z-index: 1;
}

.cw-timeline-mini--union {
  border-top: 3px solid var(--iw-tl-us, #3a86ff);
}

.cw-timeline-mini--union::before {
  background: var(--iw-tl-us, #3a86ff);
}

.cw-timeline-mini--confed {
  border-top: 3px solid var(--iw-tl-uk, #d7263d);
}

.cw-timeline-mini--confed::before {
  background: var(--iw-tl-uk, #d7263d);
}

.cw-timeline-mini--context {
  border-top: 3px solid var(--iw-tl-neutral, #64748b);
}

.cw-timeline-mini--context::before {
  background: var(--iw-tl-neutral, #64748b);
}

.cw-timeline-mini .date {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--iw-blue-dark, #0a2463);
}

.cw-timeline-mini h4 {
  margin: 0.35rem 0;
  font-size: 0.92rem;
  line-height: 1.3;
  color: var(--iw-ink, #14110e);
}

.cw-timeline-mini p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--iw-ink-soft, #3d3834);
}

.cw-battle-links {
  margin-top: 1rem;
}

.cw-battle-links a {
  font-weight: 600;
}

.cw-sources-grid {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.75rem;
}

@media (min-width: 520px) {
  .cw-sources-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.cw-source-link {
  display: block;
  padding: 0.85rem 1rem;
  border-radius: var(--radius, 12px);
  border: 1px solid var(--border, rgba(10, 36, 99, 0.12));
  background: var(--white, #fff);
  box-shadow: var(--shadow-sm, 0 4px 12px rgba(10, 36, 99, 0.06));
  color: var(--iw-blue, #3a86ff);
  font-weight: 700;
  font-size: 0.92rem;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cw-source-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md, 0 10px 24px rgba(10, 36, 99, 0.1));
  color: var(--iw-blue-dark, #0a2463);
}

.cw-source-link span {
  display: block;
  margin-top: 0.35rem;
  font-weight: 400;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--iw-ink-soft, #3d3834);
}

.cw-page .iw-tl-card .src {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.78rem;
  font-style: italic;
  color: var(--iw-ink-soft, #3d3834);
}

.cw-page .cw-note {
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--iw-blue, #3a86ff);
  border-radius: 0 var(--radius, 8px) var(--radius, 8px) 0;
  background: rgba(58, 134, 255, 0.08);
  font-size: 0.9rem;
  line-height: 1.6;
}
