/* ──────────────────────────────────────────────────────────────────────
   SERPENTINE FLOW — "La nostra storia" (9 fasi)
   ────────────────────────────────────────────────────────────────────── */

.sf-overlap-card {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, rgba(23, 70, 100, 0.13));
  border-radius: var(--radius-lg, 18px);
  box-shadow: var(--shadow-md, 0 10px 30px rgba(23, 70, 100, 0.08));
  margin-top: -3rem;
  padding: 2.5rem 2rem 2rem;
  overflow: hidden;
  position: relative;
  z-index: 2;
  font-family: 'DM Sans', system-ui, sans-serif;
}

.sf-header { text-align: center; max-width: 720px; margin: 0 auto 2.5rem; }
.sf-heading {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
  color: var(--primary, #174664);
  margin: 0.5rem 0 0.75rem;
  line-height: 1.2;
}
.sf-subheading { font-size: 0.95rem; color: var(--text-muted, #4a6170); margin: 0; line-height: 1.6; }

.sf-wrap { position: relative; width: 100%; aspect-ratio: 1200 / 720; max-width: 1100px; margin: 0 auto; }
.sf-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }

.sf-line {
  fill: none;
  stroke: var(--primary, #174664);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  marker-end: url(#sf-arrow);
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  opacity: 0;
  vector-effect: non-scaling-stroke;
}
.sf-line.sf-drawn { stroke-dashoffset: 0; opacity: 0.85; }

.sf-grid {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 0;
}
.sf-cell { display: flex; align-items: center; justify-content: center; }

.sf-card {
  position: relative;
  width: min(220px, 92%);
  aspect-ratio: 11 / 6;
  background: linear-gradient(135deg, var(--primary, #174664) 0%, var(--primary-light, #1e5a7e) 100%);
  color: #fff;
  border-radius: 10px;
  padding: 14px 18px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow:
    0 6px 18px rgba(23, 70, 100, 0.22),
    0 2px 4px rgba(23, 70, 100, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: default;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: box-shadow 0.25s, background 0.25s;
}
.sf-card::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.10);
  pointer-events: none;
}
.sf-card.sf-revealed { opacity: 1; transform: translateY(0) scale(1); }
.sf-card:hover {
  box-shadow:
    0 14px 32px rgba(23, 70, 100, 0.28),
    0 4px 10px rgba(42, 159, 214, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.10);
}
.sf-card-final { background: linear-gradient(135deg, var(--primary, #174664) 0%, var(--accent, #2a9fd6) 100%); }

.sf-num {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: rgba(208, 237, 248, 0.85);
  margin-bottom: 4px;
}
.sf-title { font-size: 14px; font-weight: 600; margin: 0 0 4px; line-height: 1.25; color: #fff; }
.sf-desc { font-size: 11px; margin: 0; color: rgba(255, 255, 255, 0.72); line-height: 1.4; font-style: italic; }

.sf-actions { text-align: center; margin-top: 1.5rem; }
#sf-replay-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 22px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--primary, #174664);
  background: var(--primary-xlight, #e8f2f8);
  border: 1px solid rgba(23, 70, 100, 0.18);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
#sf-replay-btn:hover {
  background: var(--accent-light, #d0edf8);
  transform: scale(1.03);
  box-shadow: 0 4px 12px rgba(42, 159, 214, 0.18);
}

@media (max-width: 760px) {
  .sf-overlap-card { padding: 2rem 1rem 1.5rem; }
  .sf-wrap { aspect-ratio: auto; max-width: 420px; }
  .sf-svg { display: none; }
  .sf-grid {
    position: static;
    grid-template-columns: 1fr;
    grid-template-rows: none;
    gap: 14px;
  }
  .sf-cell { grid-column: 1 !important; grid-row: auto !important; position: relative; }
  .sf-cell:has(.sf-card[data-phase="1"]) { order: 1; }
  .sf-cell:has(.sf-card[data-phase="2"]) { order: 2; }
  .sf-cell:has(.sf-card[data-phase="3"]) { order: 3; }
  .sf-cell:has(.sf-card[data-phase="4"]) { order: 4; }
  .sf-cell:has(.sf-card[data-phase="5"]) { order: 5; }
  .sf-cell:has(.sf-card[data-phase="6"]) { order: 6; }
  .sf-cell:has(.sf-card[data-phase="7"]) { order: 7; }
  .sf-cell:has(.sf-card[data-phase="8"]) { order: 8; }
  .sf-cell:has(.sf-card[data-phase="9"]) { order: 9; }
  .sf-card { width: 100%; aspect-ratio: auto; padding: 14px 18px; }
  .sf-cell + .sf-cell::before {
    content: ''; position: absolute;
    top: -14px; left: 50%;
    width: 2px; height: 14px;
    background: var(--primary, #174664);
    opacity: 0.6;
    transform: translateX(-50%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sf-line { stroke-dashoffset: 0; opacity: 0.85; }
  .sf-card { opacity: 1; transform: none; transition: none; }
}