/* ============================================================
   MODAL CASE STUDY
   Hero scuro = ~1/3 del modal. Testo più grande ovunque.
   Desktop: nessuno scroll. Mobile: scroll permesso.
   ============================================================ */

.cs-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6,10,8,0.85);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1vh 2rem;
}
.cs-modal-overlay.open { display: flex; }

.cs-modal {
  background: #060a08;
  width: 100%;
  max-width: 960px;
  height: 96vh;
  max-height: 96vh;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ---- CHIUDI ---- */
.cs-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px; height: 32px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  background: transparent;
  color: rgba(255,255,255,0.5);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: border-color 0.2s, color 0.2s;
}
.cs-modal-close:hover { border-color: #4aad87; color: #4aad87; }

/* ---- HERO SCURO — occupa ~1/3 del modal ---- */
.cs-modal-hero {
  flex: 0 0 33%;
  padding: clamp(1.2rem, 3vh, 2.2rem) 2.5rem 0;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.cs-modal-hero canvas {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  opacity: 0.2; z-index: 0;
}
.cs-modal-hero::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(6,10,8,0.5) 0%, rgba(6,10,8,0.95) 100%);
  z-index: 1;
}
.cs-modal-hero-content {
  position: relative; z-index: 2;
  padding-bottom: clamp(0.8rem, 1.8vh, 1.5rem);
}

.cs-modal-eyebrow {
  font-family: 'Syne', sans-serif;
  font-size: clamp(0.7rem, 1.1vh, 0.78rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #4aad87;
  margin-bottom: clamp(0.4rem, 0.8vh, 0.6rem);
  display: flex;
  align-items: center;
  gap: 8px;
}
.cs-modal-eyebrow::before {
  content: '';
  width: 16px; height: 2px;
  background: #4aad87;
  display: inline-block;
  flex-shrink: 0;
}

.cs-modal-title {
  font-family: 'Syne', sans-serif;
  font-size: clamp(2.2rem, 5.5vh, 3.8rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
  margin-bottom: clamp(0.4rem, 0.9vh, 0.7rem);
  line-height: 1.0;
}

.cs-modal-desc {
  font-size: clamp(0.88rem, 1.6vh, 1.05rem);
  color: rgba(255,255,255,0.5);
  line-height: 1.55;
  margin-bottom: clamp(0.5rem, 1.1vh, 0.9rem);
  max-width: 620px;
}

.cs-modal-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 0;
}
.cs-modal-tag {
  font-family: 'Syne', sans-serif;
  font-size: clamp(0.7rem, 1.1vh, 0.78rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #4aad87;
  border: 1.5px solid rgba(74,173,135,0.3);
  padding: 3px 10px;
  border-radius: 100px;
}

/* ---- METRICS BAR ---- */
.cs-modal-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid rgba(255,255,255,0.06);
  position: relative;
  z-index: 2;
  background: #060a08;
  flex-shrink: 0;
}
.cs-modal-metric {
  padding: clamp(0.8rem, 1.6vh, 1.2rem) 1.5rem;
  border-right: 1px solid rgba(255,255,255,0.06);
}
.cs-modal-metric:last-child { border-right: none; }
.cs-modal-metric-val {
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.5rem, 3.2vh, 2.2rem);
  font-weight: 800;
  color: #4aad87;
  letter-spacing: -0.03em;
  line-height: 1;
}
.cs-modal-metric-lab {
  font-size: clamp(0.7rem, 1.1vh, 0.8rem);
  color: rgba(255,255,255,0.35);
  margin-top: 4px;
  line-height: 1.3;
}

/* ---- BODY CHIARO — occupa ~2/3 del modal ---- */
.cs-modal-body {
  background: var(--paper);
  padding: clamp(1.2rem, 2.5vh, 2rem) 2.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* --- Problema / Soluzione --- */
.cs-modal-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: clamp(1rem, 2vh, 1.6rem);
  flex-shrink: 0;
}
.cs-modal-col-label {
  font-family: 'Syne', sans-serif;
  font-size: clamp(0.68rem, 1.1vh, 0.76rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--green);
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cs-modal-col-label::before {
  content: '';
  width: 12px; height: 2px;
  background: var(--green);
  display: inline-block;
  flex-shrink: 0;
}
.cs-modal-col-title {
  font-family: 'Syne', sans-serif;
  font-size: clamp(1rem, 1.9vh, 1.25rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 0.4rem;
  line-height: 1.2;
}
.cs-modal-col-text {
  font-size: clamp(0.85rem, 1.4vh, 1rem);
  color: var(--muted);
  line-height: 1.6;
}

/* --- Pipeline --- */
.cs-modal-pipeline {
  display: grid;
  gap: 1.5px;
  background: var(--border);
  margin-bottom: clamp(1rem, 2vh, 1.6rem);
  flex-shrink: 0;
}
.cs-modal-step {
  background: var(--warm);
  padding: clamp(0.9rem, 1.8vh, 1.4rem) 1.2rem;
}
.cs-modal-step-num {
  font-family: 'Syne', sans-serif;
  font-size: clamp(0.65rem, 1vh, 0.72rem);
  font-weight: 700;
  color: var(--green-light);
  letter-spacing: 0.2em;
  margin-bottom: 0.3rem;
}
.cs-modal-step-title {
  font-family: 'Syne', sans-serif;
  font-size: clamp(0.88rem, 1.6vh, 1.05rem);
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-bottom: 0.2rem;
}
.cs-modal-step-sub {
  font-size: clamp(0.75rem, 1.2vh, 0.88rem);
  color: var(--muted);
  line-height: 1.3;
}

/* --- Decisioni — si espandono per riempire lo spazio rimanente --- */
.cs-modal-decisions {
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  flex: 1;
  margin-bottom: clamp(1rem, 2vh, 1.6rem);
}
.cs-modal-decision {
  font-size: clamp(0.85rem, 1.4vh, 1rem);
  color: var(--muted);
  line-height: 1.55;
  padding-left: 14px;
  border-left: 2px solid var(--green);
}
.cs-modal-decision strong {
  color: var(--ink);
  font-weight: 700;
}

/* ---- FOOTER ---- */
.cs-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: clamp(0.8rem, 1.5vh, 1.2rem);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.8rem;
  flex-shrink: 0;
}
.cs-modal-back {
  font-family: 'Syne', sans-serif;
  font-size: clamp(0.78rem, 1.2vh, 0.88rem);
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: color 0.2s;
}
.cs-modal-back:hover { color: var(--ink); }

/* ---- TABLET: testo ridotto, layout compatto ---- */
@media (max-width: 1024px) {
  .cs-modal { max-width: 92vw; }
  .cs-modal-hero { padding: 1.4rem 2rem 0; }
  .cs-modal-hero-content { padding-bottom: 1rem; }
  .cs-modal-title { font-size: clamp(1.8rem, 4vh, 2.6rem); }
  .cs-modal-desc { font-size: 0.88rem; }
  .cs-modal-eyebrow { font-size: 0.68rem; }
  .cs-modal-tag { font-size: 0.68rem; padding: 2px 8px; }
  .cs-modal-metric { padding: 0.8rem 1.2rem; }
  .cs-modal-metric-val { font-size: clamp(1.2rem, 2.8vh, 1.8rem); }
  .cs-modal-metric-lab { font-size: 0.7rem; }
  .cs-modal-body { padding: 1.2rem 2rem; }
  .cs-modal-col-title { font-size: clamp(0.9rem, 1.6vh, 1.1rem); }
  .cs-modal-col-text { font-size: 0.85rem; }
  .cs-modal-step { padding: 0.8rem 1rem; }
  .cs-modal-step-title { font-size: 0.88rem; }
  .cs-modal-step-sub { font-size: 0.75rem; }
  .cs-modal-decision { font-size: 0.85rem; }
  .cs-modal-back { font-size: 0.76rem; }
}

/* ---- MOBILE: scroll permesso, layout verticale ---- */
@media (max-width: 768px) {
  .cs-modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .cs-modal {
    max-width: 100%;
    height: auto;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f7f5f0;
  }

  .cs-modal-close {
    top: 0.8rem;
    right: 0.8rem;
    width: 28px; height: 28px;
    font-size: 11px;
  }

  .cs-modal-hero {
    flex: none;
    padding: 1.2rem 1.2rem 0;
    background: #060a08;
  }
  .cs-modal-hero-content { padding-bottom: 0.8rem; }

  .cs-modal-eyebrow { font-size: 0.62rem; margin-bottom: 0.3rem; }
  .cs-modal-title { font-size: 1.6rem; margin-bottom: 0.3rem; }
  .cs-modal-desc { font-size: 0.82rem; line-height: 1.5; margin-bottom: 0.5rem; }
  .cs-modal-tags { gap: 5px; }
  .cs-modal-tag { font-size: 0.62rem; padding: 2px 7px; }

  .cs-modal-metrics { grid-template-columns: repeat(3, 1fr); }
  .cs-modal-metric { padding: 0.7rem 0.8rem; }
  .cs-modal-metric-val { font-size: 1.2rem; }
  .cs-modal-metric-lab { font-size: 0.62rem; }

  .cs-modal-body {
    padding: 1.2rem;
    padding-bottom: 2rem;
    overflow: visible;
    flex: 1;
    min-height: 0;
  }

  .cs-modal-two-col {
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
  }
  .cs-modal-col-label { font-size: 0.62rem; }
  .cs-modal-col-title { font-size: 0.92rem; }
  .cs-modal-col-text { font-size: 0.82rem; line-height: 1.55; }

  .cs-modal-pipeline {
    grid-template-columns: 1fr 1fr !important;
    margin-bottom: 1rem;
  }
  .cs-modal-step { padding: 0.8rem; }
  .cs-modal-step-num { font-size: 0.58rem; }
  .cs-modal-step-title { font-size: 0.82rem; }
  .cs-modal-step-sub { font-size: 0.7rem; }

  .cs-modal-decisions {
    flex: none;
    justify-content: flex-start;
    gap: 0.8rem;
    margin-bottom: 1rem;
  }
  .cs-modal-decision { font-size: 0.82rem; padding-left: 10px; }
  .cs-modal-decision strong { color: #0a0a0a; }

  .cs-modal-footer {
    padding-top: 0.8rem;
    padding-bottom: 1.5rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }
  .cs-modal-footer .btn-primary {
    text-align: center;
    justify-content: center;
    padding: 0.8rem 1.5rem;
    font-size: 0.82rem;
  }
  .cs-modal-back {
    text-align: center;
    font-size: 0.76rem;
  }
}

/* ---- SMALL MOBILE: iPhone SE, Galaxy S8 ---- */
@media (max-width: 375px) {
  .cs-modal { max-height: 95vh; }
  .cs-modal-hero { padding: 1rem 1rem 0; }
  .cs-modal-hero-content { padding-bottom: 0.6rem; }
  .cs-modal-eyebrow { font-size: 0.58rem; gap: 5px; }
  .cs-modal-title { font-size: 1.35rem; }
  .cs-modal-desc { font-size: 0.75rem; line-height: 1.45; margin-bottom: 0.4rem; }
  .cs-modal-tag { font-size: 0.56rem; padding: 1px 6px; }

  .cs-modal-metric { padding: 0.5rem 0.6rem; }
  .cs-modal-metric-val { font-size: 1rem; }
  .cs-modal-metric-lab { font-size: 0.56rem; }

  .cs-modal-body { padding: 1rem; padding-bottom: 1.5rem; }
  .cs-modal-col-label { font-size: 0.58rem; }
  .cs-modal-col-title { font-size: 0.85rem; }
  .cs-modal-col-text { font-size: 0.75rem; }

  .cs-modal-pipeline { grid-template-columns: 1fr !important; }
  .cs-modal-step { padding: 0.6rem 0.8rem; }
  .cs-modal-step-num { font-size: 0.54rem; }
  .cs-modal-step-title { font-size: 0.76rem; }
  .cs-modal-step-sub { font-size: 0.65rem; }

  .cs-modal-decision { font-size: 0.75rem; padding-left: 8px; }
  .cs-modal-decisions { gap: 0.6rem; }

  .cs-modal-footer { gap: 0.5rem; padding-bottom: 1.2rem; }
  .cs-modal-footer .btn-primary { padding: 0.7rem 1.2rem; font-size: 0.76rem; }
  .cs-modal-back { font-size: 0.7rem; }
}
