/* =============================================================
   D3-Hub / Clash Report — data-story module
   Scope: .data-story — set by clashreport.php / layout.php
   Inherits site tokens from styles.css :root
   ============================================================= */

.data-story {
  font: 400 17px/1.65 var(--font-body);
  color: var(--text-dark);
  font-feature-settings: 'kern', 'liga', 'tnum';
  -webkit-font-smoothing: antialiased;

  /* local vars: only what has no site-token equivalent */
  --rule:      #e3e5e8;
  --ink-muted: #8a8a8a;

  /* status palette (semaforo esteso) */
  --c-new:      #888888;
  --c-active:   #d85a30;
  --c-reviewed: #1f4e96;
  --c-approved: #6cab44;

  /* layout grid */
  --col-text: 5fr;
  --col-graph: 7fr;
  --gutter:   3rem;
}

.data-story strong { font-weight: 600; }

.data-story a { color: var(--primary); text-decoration: none; border-bottom: 1px solid currentColor; }
.data-story a:hover { color: var(--text-dark); }

/* =============================================== hero */
.data-story .hero {
  padding: 100px 32px 80px;
  border-bottom: 1px solid var(--rule);
}
.data-story .hero-inner {
  max-width: 720px; margin: 0 auto;
}
.data-story .kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  color: var(--ink-muted);
  margin: 0 0 18px;
  font-weight: 500;
}
.data-story .hero h1 {
  font: 300 56px/1.05 var(--font-head);
  letter-spacing: -0.02em;
  margin: 0 0 24px;
  color: var(--text-dark);
}
.data-story .dek {
  font-size: 19px; line-height: 1.55;
  color: var(--text-light);
  margin: 0 0 56px;
  max-width: 640px;
}
.data-story .scroll-cue {
  display: inline-flex; align-items: center; gap: 12px;
  font-size: 13px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.data-story .scroll-cue svg { animation: ds-bob 2s ease-in-out infinite; }
@keyframes ds-bob {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(4px); }
}

/* =============================================== story / scrollytelling */
.data-story .story {
  width: 100%;
  display: grid;
  grid-template-columns: var(--col-text) var(--col-graph);
  gap: var(--gutter);
  align-items: start;
}

.data-story .text-column {
  padding: 80px 0;
  max-width: 560px;
  margin: 0 auto;
}
.data-story .step {
  min-height: 75vh;
  margin-bottom: 24vh;
  opacity: 0.32;
  transition: opacity 0.45s ease-out;
}
.data-story .step.is-active { opacity: 1; }
.data-story .step.step-final { min-height: auto; margin-bottom: 0; }

.data-story .step h2 {
  font: 500 32px/1.15 var(--font-head);
  letter-spacing: -0.015em;
  margin: 0 0 24px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 16px;
}
.data-story .step p {
  margin: 0 0 18px;
  color: var(--text-light);
  font-size: 17px;
}
.data-story .step ol,
.data-story .step ul { color: var(--text-light); padding-left: 22px; }
.data-story .step ol li,
.data-story .step ul li { margin-bottom: 12px; }

.data-story .callout {
  border-left: 2px solid var(--primary);
  padding: 4px 0 4px 16px;
  font-size: 16px;
  color: var(--text-dark);
  margin: 24px 0 !important;
}

.data-story .highlight {
  font-feature-settings: 'tnum';
  background: linear-gradient(180deg, transparent 60%, #fff5cb 60%);
  padding: 0 2px;
  font-weight: 500;
  color: var(--text-dark);
}

.data-story .byline {
  margin-top: 48px !important;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  font-size: 14px !important;
  color: var(--ink-muted) !important;
}

/* legenda inline */
.data-story .dot {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 50%; vertical-align: -1px;
  margin: 0 2px;
}
.data-story .dot-new      { background: var(--c-new); }
.data-story .dot-active   { background: var(--c-active); }
.data-story .dot-reviewed { background: var(--c-reviewed); }
.data-story .dot-approved { background: var(--c-approved); }

/* =============================================== sticky graphic */
.data-story .graphic-sticky {
  position: sticky;
  top: 1.5rem;
  height: calc(100vh - 3rem);
  display: flex;
  align-items: center;
  justify-content: center;
}
.data-story .graphic-inner {
  width: 100%;
  height: 88vh;
  background: var(--bg-light);
  border-radius: 4px;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
}
.data-story #vis {
  flex: 1; min-height: 0;
  position: relative;
}
.data-story #vis svg { display: block; width: 100%; height: 100%; }

/* fallback per quando #vis è in transizione */
.data-story #vis .placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--ink-muted);
  text-align: center;
  font-size: 14px;
  font-style: italic;
}

.data-story .legend {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  font-size: 13px;
  color: var(--text-light);
  min-height: 22px;
  font-feature-settings: 'tnum';
}
.data-story .legend-item { display: inline-flex; align-items: center; gap: 6px; }
.data-story .legend-swatch {
  width: 10px; height: 10px; border-radius: 50%;
}

/* =============================================== chart helpers */
.data-story .axis text {
  font: 400 11px var(--font-body);
  fill: var(--ink-muted);
}
.data-story .axis line,
.data-story .axis path {
  stroke: var(--rule);
  shape-rendering: crispEdges;
}
.data-story .axis-title {
  font: 500 12px var(--font-body);
  fill: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.data-story .gridline {
  stroke: var(--rule);
  stroke-dasharray: 1, 3;
}

.data-story .bar:hover,
.data-story .point:hover { cursor: pointer; }

.data-story .tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--text-dark);
  color: #fff;
  padding: 6px 10px;
  border-radius: 3px;
  font-size: 12px;
  font-feature-settings: 'tnum';
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}
.data-story .tooltip.is-visible { opacity: 1; }
.data-story .tooltip strong { color: #fff; }

/* =============================================== loading spinner */
.data-story #vis .loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  color: var(--ink-muted);
  font-size: 14px;
}
.data-story .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--rule);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: ds-spin 0.75s linear infinite;
}
@keyframes ds-spin {
  to { transform: rotate(360deg); }
}

/* =============================================== responsive */
@media (max-width: 900px) {
  .data-story .hero { padding: 60px 24px 50px; }
  .data-story .hero h1 { font-size: 36px; }
  .data-story .dek { font-size: 17px; }

  .data-story .story {
    grid-template-columns: 1fr;
    padding: 0 24px;
  }
  .data-story .text-column { padding: 40px 0 0; max-width: none; }
  .data-story .step { min-height: auto; margin-bottom: 16vh; opacity: 1; }
  .data-story .step h2 { font-size: 26px; }

  .data-story .graphic-sticky {
    position: sticky;
    top: var(--topbar-h, 64px);
    height: 60vh;
    z-index: 5;
    background: #fff;
    margin: 0 -24px 24px;
    padding: 0 12px;
  }
  .data-story .graphic-inner { height: 56vh; padding: 12px; }
}

/* =============================================== ch5 flow */
.data-story .flow-band { fill-opacity: 0.72; }
.data-story .flow-node { opacity: 0.85; }

/* =============================================== ch6 zombie lollipops */
.data-story .zombie-stem { stroke-width: 1.5; }
.data-story .zombie-dot  { stroke: var(--bg-light); stroke-width: 1.5; }

/* =============================================== reduced motion */
@media (prefers-reduced-motion: reduce) {
  .data-story * { animation: none !important; transition: none !important; }
  .data-story .step { opacity: 1; }
}
