// m12c1.jsx — Módulo 1 · Clase 1.1 «Líneas de impulso: diseño e instalación (API RP 551)»
// Después de m12-lib.jsx. Exporta SCENES_M12C1. Incluye preguntas dentro del video.

// ── Qué es ─────────────────────────────────────────────────────────────────
function S_What({ start, dur }) {
  const t = useTime(); const s = start;
  const lt = Math.max(0, t - s);
  const pulse = (lt * 0.5) % 1;
  const path = [[560, 470], [560, 600], [1080, 600], [1080, 700]];
  const seg = (f) => { const L = [130, 520, 100]; const tot = 750; let d = f * tot; for (let i = 0; i < 3; i++) { if (d <= L[i]) { const [a, b] = [path[i], path[i + 1]]; const k = d / L[i]; return [a[0] + (b[0] - a[0]) * k, a[1] + (b[1] - a[1]) * k]; } d -= L[i]; } return path[3]; };
  const [px, py] = seg(pulse);
  const lab = (x, y, txt, a, anchor = 'start') => <text x={x} y={y} fill={TL4.ink} fontFamily={DISP4} fontSize="22" fontWeight="700" textAnchor={anchor} opacity={pop4(t, s + a).op}>{txt}</text>;
  return (
    <SceneM4 start={start} dur={dur}>
      <HeadM14 s={s} dur={dur} kicker="Qué es una línea de impulso">El tubo que lleva <span style={{ color: TL4.orangeD }}>la presión del proceso</span> hasta el transmisor.</HeadM14>
      <svg style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', overflow: 'visible' }}>
        <Pipe x={240} y={420} w={700} label="tubería de proceso" />
        <Line d="M560 465 L560 600 L1080 600 L1080 690" color={TL4.ink} w={12} />
        <Line d="M560 465 L560 600 L1080 600 L1080 690" color={LIQ} w={6} />
        <Valve x={560} y={520} vertical />
        <rect x={1040} y={690} width="80" height="40" rx="6" fill={TL4.mut} />
        <Tx x={1080} y={800} />
        <circle cx={px} cy={py} r="12" fill={TL4.orange} />
        {lab(600, 525, 'válvula raíz (bloqueo)', 2)}
        {lab(820, 580, 'línea de impulso', 3.5, 'middle')}
        {lab(1140, 715, 'manifold o válvula de servicio', 5)}
        {lab(1140, 810, 'transmisor', 6)}
        {lab(560, 360, 'toma de proceso', 1, 'middle')}
      </svg>
      <RowsM14 s={s} t={t} x={1300} y={300} w={520} cols="1fr" at0={8} step={2.6} rows={[
        ['Debe transmitir la presión sin agregar errores: ni columnas de líquido ocultas, ni bolsas de gas.', '', TL4.blue],
        ['API RP 551 dedica un capítulo a su diseño porque ahí nacen muchos errores de medición.', '', TL4.orange],
      ]} />
    </SceneM4>
  );
}

// ── Errores ────────────────────────────────────────────────────────────────
function S_Errors({ start, dur }) {
  const t = useTime(); const s = start;
  const lt = Math.max(0, t - s);
  const P = (i) => pop4(t, s + 1.2 + i * 2.2).op;
  const panel = (x, title, c, i, body) => (
    <g opacity={P(i)}>
      <rect x={x} y={270} width="500" height="440" rx="18" fill={TL4.paper} stroke={c} strokeWidth="3" />
      <text x={x + 250} y={316} fill={c} fontFamily={DISP4} fontSize="25" fontWeight="700" textAnchor="middle">{title}</text>
      {body}
    </g>
  );
  const bob = Math.sin(lt * 3) * 4;
  return (
    <SceneM4 start={start} dur={dur}>
      <HeadM14 s={s} dur={dur} kicker="Lo que sale mal">Tres errores típicos <span style={{ color: TL4.orangeD }}>que no se ven desde el panel</span>.</HeadM14>
      <svg style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', overflow: 'visible' }}>
        {panel(140, 'Gas en línea de líquido', '#d7263d', 0, <>
          <Line d="M240 380 L240 450 Q240 410 330 410 Q420 410 420 470 L420 600" color={TL4.ink} w={14} />
          <Line d="M240 380 L240 450 Q240 410 330 410 Q420 410 420 470 L420 600" color={LIQ} w={8} />
          <ellipse cx={330} cy={410 + bob * 0.2} rx="34" ry="9" fill="#fff" stroke={TL4.mut} strokeWidth="2" />
          <Tx x={420} y={650} />
          <text x={330} y={372} fill="#d7263d" fontFamily={DISP4} fontSize="18" textAnchor="middle">burbuja en el punto alto</text>
        </>)}
        {panel(710, 'Líquido en línea de gas', TL4.orange, 1, <>
          <Line d="M800 650 L800 570 Q800 620 890 620 Q980 620 980 570 L980 512" color={TL4.ink} w={14} />
          <Line d="M800 650 L800 570 Q800 620 890 620 Q980 620 980 570 L980 512" color={GAS} w={8} />
          <ellipse cx={890} cy={616} rx="38" ry="8" fill={LIQ} />
          <Tx x={980} y={480} />
          <text x={890} y={690} fill={TL4.orangeD} fontFamily={DISP4} fontSize="18" textAnchor="middle">condensado en el punto bajo</text>
        </>)}
        {panel(1280, 'Ramas a distinta temperatura', TL4.blue, 2, <>
          <Line d="M1420 380 L1420 600" color={TL4.ink} w={14} /><Line d="M1420 380 L1420 600" color={'#b8d4f5'} w={8} />
          <Line d="M1640 380 L1640 600" color={TL4.ink} w={14} /><Line d="M1640 380 L1640 600" color={'#f2b48a'} w={8} />
          <text x={1420} y={630} fill={TL4.blueD} fontFamily={DISP4} fontSize="18" textAnchor="middle">fría: más densa</text>
          <text x={1640} y={630} fill={TL4.orangeD} fontFamily={DISP4} fontSize="18" textAnchor="middle">al sol: menos densa</text>
          <text x={1530} y={680} fill={TL4.mut} fontFamily={DISP4} fontSize="18" textAnchor="middle">error de cero en un DP</text>
        </>)}
      </svg>
      <div style={{ position: 'absolute', left: 140, top: 740, width: 1640, fontFamily: DISP4, fontSize: 23, color: TL4.mut, opacity: pop4(t, s + 9).op }}>
        En los tres casos hay una columna de fluido que no debería estar, y el transmisor la suma o la resta a la medición.
      </div>
    </SceneM4>
  );
}

// ── Gas ────────────────────────────────────────────────────────────────────
function S_Gas({ start, dur }) {
  const t = useTime(); const s = start;
  const lt = Math.max(0, t - s);
  const drop = (k) => { const f = ((lt * 0.35 + k / 3) % 1); return [1060 - f * 420, 300 + f * 220]; };
  return (
    <SceneM4 start={start} dur={dur}>
      <HeadM14 s={s} dur={dur} kicker="Gas y vapor seco">En gas, el transmisor va <span style={{ color: TL4.orangeD }}>arriba de la toma</span>.</HeadM14>
      <svg style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', overflow: 'visible' }}>
        <Pipe x={240} y={600} w={760} fill={GAS} label="gas" />
        <Line d="M640 555 L1060 300" color={TL4.ink} w={12} />
        <Line d="M640 555 L1060 300" color={GAS} w={6} />
        <Valve x={668} y={538} />
        <Tx x={1100} y={330} />
        {[0, 1, 2].map(k => { const [x, y] = drop(k); return <circle key={k} cx={x} cy={y} r="8" fill={LIQ} />; })}
        <text x={905} y={452} fill={TL4.blueD} fontFamily={DISP4} fontSize="20" textAnchor="middle" transform="rotate(-31 905 452)">el condensado regresa al proceso</text>
        <text x={640} y={680} fill={TL4.mut} fontFamily={DISP4} fontSize="20" textAnchor="middle">toma arriba de la tubería</text>
      </svg>
      <RowsM14 s={s} t={t} x={1260} y={430} w={560} cols="1fr" at0={4} step={2.6} rows={[
        ['Pendiente continua hacia el proceso, sin puntos bajos.', '', TL4.blue],
        ['Si no se puede subir, se pone un pote con drenaje en el punto bajo.', '', TL4.orange],
      ]} />
    </SceneM4>
  );
}

// ── Líquido ────────────────────────────────────────────────────────────────
function S_Liq({ start, dur }) {
  const t = useTime(); const s = start;
  const lt = Math.max(0, t - s);
  const bub = (k) => { const f = ((lt * 0.35 + k / 3) % 1); return [1000 - f * 360, 760 - f * 240]; };
  return (
    <SceneM4 start={start} dur={dur}>
      <HeadM14 s={s} dur={dur} kicker="Líquidos">En líquido, el transmisor va <span style={{ color: TL4.orangeD }}>abajo de la toma</span>.</HeadM14>
      <svg style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', overflow: 'visible' }}>
        <Pipe x={240} y={460} w={760} label="líquido" />
        <circle cx={640} cy={470} r="12" fill={TL4.ink} />
        <Line d="M640 470 L1000 760" color={TL4.ink} w={12} />
        <Line d="M640 470 L1000 760" color={LIQ} w={6} />
        <Valve x={690} y={545} />
        <Tx x={1040} y={830} />
        {[0, 1, 2].map(k => { const [x, y] = bub(k); return <circle key={k} cx={x} cy={y} r="9" fill="#fff" stroke={TL4.mut} strokeWidth="2" />; })}
        <text x={850} y={600} fill={TL4.blueD} fontFamily={DISP4} fontSize="20" textAnchor="middle" transform="rotate(35 850 600)">las burbujas suben al proceso</text>
        <text x={520} y={560} fill={TL4.mut} fontFamily={DISP4} fontSize="20" textAnchor="middle">toma lateral</text>
      </svg>
      <RowsM14 s={s} t={t} x={1260} y={330} w={560} cols="1fr" at0={4} step={2.6} rows={[
        ['Pendiente continua hacia el transmisor, sin puntos altos.', '', TL4.blue],
        ['Venteo en el punto más alto para purgar el gas al arrancar.', '', TL4.ok],
        ['Si el transmisor queda arriba, la columna de líquido se corrige en el cero.', '', TL4.orange],
      ]} />
    </SceneM4>
  );
}

// ── Vapor ──────────────────────────────────────────────────────────────────
function S_Steam({ start, dur }) {
  const t = useTime(); const s = start;
  const potY = 450;
  return (
    <SceneM4 start={start} dur={dur}>
      <HeadM14 s={s} dur={dur} kicker="Vapor de agua">En vapor, <span style={{ color: TL4.orangeD }}>agua condensada protege</span> al transmisor.</HeadM14>
      <svg style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', overflow: 'visible' }}>
        <Pipe x={200} y={330} w={980} fill={STEAM} label="vapor" />
        <rect x={786} y={270} width="12" height="120" fill={TL4.ink} />
        <text x={792} y={255} fill={TL4.mut} fontFamily={DISP4} fontSize="18" textAnchor="middle">placa de orificio</text>
        {[[460, TL4.orangeD, 'H'], [940, TL4.blue, 'L']].map(([x, c, n]) => (
          <g key={n} opacity={pop4(t, s + 1.5).op}>
            <Line d={`M${x + 90} 375 L${x + 90} ${potY}`} w={10} />
            <rect x={x + 50} y={potY} width="80" height="70" rx="10" fill={LIQ} stroke={TL4.ink} strokeWidth="3" />
            <Line d={x < 700 ? `M${x + 90} ${potY + 70} L${x + 90} 800 L1050 800 L1050 822` : `M${x + 90} ${potY + 70} L${x + 90} 760 L1110 760 L1110 822`} w={10} color={TL4.ink} />
            <Line d={x < 700 ? `M${x + 90} ${potY + 70} L${x + 90} 800 L1050 800 L1050 822` : `M${x + 90} ${potY + 70} L${x + 90} 760 L1110 760 L1110 822`} w={5} color={LIQ} />
            <text x={x < 700 ? x + 38 : x + 142} y={potY + 66} fill={c} fontFamily={MONO4} fontSize="20" fontWeight="700" textAnchor={x < 700 ? 'end' : 'start'}>pote {n}</text>
          </g>
        ))}
        <line x1={460} y1={potY + 35} x2={1110} y2={potY + 35} stroke={TL4.orangeD} strokeWidth="2" strokeDasharray="8 8" opacity={pop4(t, s + 4).op} />
        <text x={760} y={potY + 25} fill={TL4.orangeD} fontFamily={DISP4} fontSize="20" fontWeight="700" textAnchor="middle" opacity={pop4(t, s + 4).op}>misma altura</text>
        <Tx x={1080} y={890} dp />
      </svg>
      <RowsM14 s={s} t={t} x={1300} y={500} w={520} cols="1fr" at0={6} step={2.6} rows={[
        ['Los potes de condensado fijan el nivel del agua: a la misma altura, no hay error de cero.', '', TL4.orange],
        ['Las líneas se llenan con agua antes del arranque; el vapor nunca toca el sensor.', '', TL4.blue],
      ]} />
    </SceneM4>
  );
}

// ── Toma ───────────────────────────────────────────────────────────────────
function S_Tap({ start, dur }) {
  const t = useTime(); const s = start;
  const cx = 520, cy = 600, R = 200;
  const arc = (a0, a1, c, op) => { const p = (a) => [cx + R * Math.cos(a * Math.PI / 180), cy - R * Math.sin(a * Math.PI / 180)]; const [x0, y0] = p(a0), [x1, y1] = p(a1); return <path d={`M${cx} ${cy} L${x0} ${y0} A${R} ${R} 0 0 ${a1 > a0 ? 0 : 1} ${x1} ${y1} Z`} fill={c} opacity={op} />; };
  return (
    <SceneM4 start={start} dur={dur}>
      <HeadM14 s={s} dur={dur} kicker="Dónde hacer la toma">La posición de la toma en el tubo <span style={{ color: TL4.orangeD }}>depende del fluido</span>.</HeadM14>
      <svg style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', overflow: 'visible' }}>
        <circle cx={cx} cy={cy} r={R} fill="#fff" stroke={TL4.ink} strokeWidth="5" />
        <g opacity={pop4(t, s + 1.2).op}>{arc(45, 135, 'rgba(47,134,230,0.35)', 1)}</g>
        <g opacity={pop4(t, s + 3).op}>{arc(-45, 0, 'rgba(46,160,90,0.35)', 1)}{arc(180, 225, 'rgba(46,160,90,0.35)', 1)}</g>
        <g opacity={pop4(t, s + 4.8).op}>{arc(240, 300, 'rgba(215,38,61,0.25)', 1)}</g>
        <text x={cx} y={cy - R - 24} fill={TL4.blueD} fontFamily={DISP4} fontSize="22" fontWeight="700" textAnchor="middle" opacity={pop4(t, s + 1.2).op}>gas: arriba</text>
        <text x={cx + R + 24} y={cy + 60} fill={TL4.ok} fontFamily={DISP4} fontSize="22" fontWeight="700" opacity={pop4(t, s + 3).op}>líquido y vapor: al costado</text>
        <text x={cx} y={cy + R + 44} fill="#d7263d" fontFamily={DISP4} fontSize="22" fontWeight="700" textAnchor="middle" opacity={pop4(t, s + 4.8).op}>nunca abajo: sedimentos</text>
      </svg>
      <RowsM14 s={s} t={t} x={1120} y={330} w={700} cols="1fr" at0={6} step={2.6} rows={[
        ['Gas: en la mitad superior, para que no entre líquido a la línea.', '', TL4.blue],
        ['Líquido: en el costado, hasta 45° por debajo de la horizontal; arriba entraría gas y abajo sólidos.', '', TL4.ok],
        ['Vapor: en el costado, para que el condensado llene los potes.', '', TL4.orange],
      ]} />
    </SceneM4>
  );
}

// ── Materiales ─────────────────────────────────────────────────────────────
function S_Mat({ start, dur }) {
  const t = useTime(); const s = start;
  return (
    <SceneM4 start={start} dur={dur}>
      <HeadM14 s={s} dur={dur} kicker="Diámetro, material y protección">Corta, del diámetro correcto <span style={{ color: TL4.orangeD }}>y protegida del clima</span>.</HeadM14>
      <RowsM14 s={s} t={t} cols="360px 1fr" rows={[
        ['Diámetro', 'Tubing de 1/2" o tubo equivalente: con 1/4" se tapa fácil y responde lento.', TL4.blue],
        ['Material', 'Acero inoxidable 316 en general; aleaciones especiales para fluidos corrosivos.', TL4.ok],
        ['Longitud y pendiente', 'Lo más corta posible, con pendiente de 1:12 hacia donde deben escurrir líquido o gas.', TL4.orange],
        ['Temperatura', 'Traceado y aislamiento si el fluido congela o solidifica; protección del sol para ramas de un DP.', '#d7263d'],
        ['Alternativa', 'Sellos remotos o montaje directo cuando el fluido tapa, cristaliza o es muy viscoso.', TL4.mut],
      ]} />
    </SceneM4>
  );
}

// ── Manifold de 3 válvulas ─────────────────────────────────────────────────
function S_Manifold({ start, dur }) {
  const t = useTime(); const s = start;
  const lt = Math.max(0, t - s);
  const step = lt < 3 ? 0 : lt < 7 ? 1 : lt < 11 ? 2 : lt < 15 ? 3 : 4;
  const st = [
    { H: false, L: false, E: false, txt: 'Fuera de servicio: todo cerrado' },
    { H: false, L: false, E: true, txt: '1 · Abrir la ecualizadora' },
    { H: true, L: false, E: true, txt: '2 · Abrir lentamente el bloqueo de alta (H)' },
    { H: true, L: false, E: false, txt: '3 · Cerrar la ecualizadora' },
    { H: true, L: true, E: false, txt: '4 · Abrir el bloqueo de baja (L): en servicio' },
  ][step];
  const cx = 760;
  return (
    <SceneM4 start={start} dur={dur}>
      <HeadM14 s={s} dur={dur} kicker="Manifold de 3 válvulas">Poner un DP en servicio <span style={{ color: TL4.orangeD }}>sin someterlo a toda la presión de un lado</span>.</HeadM14>
      <svg style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', overflow: 'visible' }}>
        <Line d={`M${cx - 260} 300 L${cx - 260} 640`} w={12} color={TL4.ink} /><Line d={`M${cx - 260} 300 L${cx - 260} 640`} w={6} color={st.H ? LIQ : '#dde6f0'} />
        <Line d={`M${cx + 260} 300 L${cx + 260} 640`} w={12} color={TL4.ink} /><Line d={`M${cx + 260} 300 L${cx + 260} 640`} w={6} color={st.L ? LIQ : '#dde6f0'} />
        <Line d={`M${cx - 260} 520 L${cx + 260} 520`} w={12} color={TL4.ink} /><Line d={`M${cx - 260} 520 L${cx + 260} 520`} w={6} color={st.E ? LIQ : '#dde6f0'} />
        <text x={cx - 260} y={280} fill={TL4.orangeD} fontFamily={MONO4} fontSize="22" fontWeight="700" textAnchor="middle">desde la toma H</text>
        <text x={cx + 260} y={280} fill={TL4.blue} fontFamily={MONO4} fontSize="22" fontWeight="700" textAnchor="middle">desde la toma L</text>
        <Valve x={cx - 260} y={420} vertical open={st.H} size={28} />
        <Valve x={cx + 260} y={420} vertical open={st.L} size={28} />
        <Valve x={cx} y={520} open={st.E} size={28} />
        <text x={cx - 320} y={428} fill={TL4.ink} fontFamily={DISP4} fontSize="20" textAnchor="end">bloqueo H</text>
        <text x={cx + 320} y={428} fill={TL4.ink} fontFamily={DISP4} fontSize="20">bloqueo L</text>
        <text x={cx} y={490} fill={TL4.ink} fontFamily={DISP4} fontSize="20" textAnchor="middle">ecualizadora</text>
        <rect x={cx - 300} y={640} width="600" height="110" rx="16" fill={TL4.paper} stroke={TL4.blueD} strokeWidth="4" />
        <text x={cx} y={705} fill={TL4.blueD} fontFamily={DISP4} fontSize="26" fontWeight="700" textAnchor="middle">transmisor DP</text>
      </svg>
      <div style={{ position: 'absolute', left: 1240, top: 360, width: 600, fontFamily: DISP4 }}>
        <div style={{ fontFamily: MONO4, fontSize: 16, letterSpacing: '0.2em', color: TL4.mut, textTransform: 'uppercase' }}>Puesta en servicio</div>
        <div style={{ marginTop: 14, fontSize: 32, fontWeight: 700, color: TL4.ink, lineHeight: 1.25 }}>{st.txt}</div>
        <div style={{ marginTop: 22, fontSize: 22, color: TL4.mut, lineHeight: 1.4, opacity: pop4(t, s + 16).op }}>Para sacarlo: cerrar L, abrir la ecualizadora y cerrar H. Nunca las tres abiertas con el proceso en marcha.</div>
      </div>
    </SceneM4>
  );
}

// ── Otros manifolds ────────────────────────────────────────────────────────
function S_Other({ start, dur }) {
  const t = useTime(); const s = start;
  return (
    <SceneM4 start={start} dur={dur}>
      <HeadM14 s={s} dur={dur} kicker="Otros arreglos">Uno para cada tipo de medición <span style={{ color: TL4.orangeD }}>y de riesgo</span>.</HeadM14>
      <svg style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', overflow: 'visible' }}>
        <g opacity={pop4(t, s + 2).op}>
          <Line d="M415 600 L415 800" w={8} /><Valve x={415} y={660} vertical size={18} /><Line d="M415 730 L470 730" w={8} /><Valve x={490} y={730} size={14} color={TL4.mut} />
          <rect x={375} y={800} width="80" height="40" rx="8" fill={TL4.paper} stroke={TL4.blueD} strokeWidth="3" />
        </g>
        <g opacity={pop4(t, s + 4.6).op}>
          <Line d="M880 600 L880 800" w={8} /><Line d="M1040 600 L1040 800" w={8} /><Line d="M880 730 L1040 730" w={8} />
          <Valve x={880} y={660} vertical size={18} /><Valve x={1040} y={660} vertical size={18} /><Valve x={960} y={730} size={18} />
          <rect x={850} y={800} width="220" height="40" rx="8" fill={TL4.paper} stroke={TL4.blueD} strokeWidth="3" />
        </g>
        <g opacity={pop4(t, s + 7).op}>
          <Line d="M1425 600 L1425 800" w={8} /><Line d="M1585 600 L1585 800" w={8} /><Line d="M1425 730 L1585 730" w={8} />
          <Valve x={1425} y={660} vertical size={18} /><Valve x={1585} y={660} vertical size={18} /><Valve x={1505} y={730} size={18} />
          <Line d="M1425 770 L1370 770" w={6} /><Valve x={1352} y={770} size={13} color={TL4.mut} />
          <Line d="M1585 770 L1640 770" w={6} /><Valve x={1658} y={770} size={13} color={TL4.mut} />
          <rect x={1395} y={800} width="220" height="40" rx="8" fill={TL4.paper} stroke={TL4.blueD} strokeWidth="3" />
        </g>
      </svg>
      <InfoCardM4 x={160} y={280} w={510} h={260} no={1} accent={TL4.blue} title="2 válvulas" sub="Bloqueo y venteo para transmisores de presión manométrica o absoluta: se aísla y se despresuriza el instrumento antes de retirarlo." appear={s + 1.4} t={t} />
      <InfoCardM4 x={705} y={280} w={510} h={260} no={2} accent={TL4.orange} title="3 válvulas" sub="Bloqueo H, bloqueo L y ecualizadora: el estándar de los transmisores de presión diferencial." appear={s + 4} t={t} />
      <InfoCardM4 x={1250} y={280} w={510} h={260} no={3} accent={'#d7263d'} title="5 válvulas" sub="Suma venteos o drenajes en cada lado: se purga cada rama por separado. Usado en gas, vapor y fluidos tóxicos." appear={s + 6.5} t={t} />
    </SceneM4>
  );
}

// ── Cabeza estática ────────────────────────────────────────────────────────
function S_Head({ start, dur }) {
  const t = useTime(); const s = start;
  return (
    <SceneM4 start={start} dur={dur}>
      <HeadM14 s={s} dur={dur} kicker="La columna de la línea">Una línea llena de líquido <span style={{ color: TL4.orangeD }}>suma su propia presión</span>.</HeadM14>
      <svg style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', overflow: 'visible' }}>
        <Pipe x={200} y={330} w={560} label="toma" />
        <Line d="M480 375 L480 760" w={12} /><Line d="M480 375 L480 760" w={6} color={LIQ} />
        <Tx x={480} y={830} />
        <line x1={620} y1={375} x2={620} y2={770} stroke={TL4.orangeD} strokeWidth="3" />
        <path d="M605 390 L620 375 L635 390 M605 755 L620 770 L635 755" fill="none" stroke={TL4.orangeD} strokeWidth="3" />
        <text x={650} y={580} fill={TL4.orangeD} fontFamily={MONO4} fontSize="26" fontWeight="700">h = 2 m</text>
      </svg>
      <div style={{ position: 'absolute', left: 900, top: 320, width: 900, fontFamily: MONO4, fontSize: 32, fontWeight: 700, color: TL4.blueD, opacity: pop4(t, s + 2).op }}>ΔP = ρ · g · h</div>
      <RowsM14 s={s} t={t} x={900} y={400} w={900} cols="1fr" at0={3.5} step={2.6} rows={[
        ['Agua: 1 000 × 9,81 × 2 = 19 620 Pa ≈ 19,6 kPa de más en la lectura.', '', TL4.orange],
        ['Se corrige en el cero del transmisor (supresión), siempre que la línea esté llena y a temperatura estable.', '', TL4.blue],
        ['En gas, la columna es despreciable; en líquidos y en líneas con sello, nunca.', '', TL4.mut],
      ]} />
    </SceneM4>
  );
}

const Q_L1 = {
  id: 'li1-burbuja', q: 'Una línea de líquido tiene una burbuja de gas atrapada en un punto alto. ¿Qué pasa con la medición?',
  options: ['Nada: el gas no pesa', 'La columna de líquido queda incompleta y la lectura tiene error', 'Mejora la respuesta del transmisor', 'Solo cambia la temperatura'],
  answer: 1, explain: 'La burbuja reemplaza parte de la columna de líquido que el transmisor suponía llena: la lectura se desvía. Por eso en líquido la línea baja sin puntos altos y lleva venteo.',
  hints: ['Justamente porque el gas casi no pesa, falta el peso de la columna de líquido que debería estar.', null, 'La burbuja no ayuda: amortigua y agrega error.', 'El problema es la columna de líquido incompleta, no la temperatura.'],
};
const Q_L2 = {
  id: 'li2-gas', q: 'En un servicio de gas, ¿dónde se instala el transmisor?',
  options: ['Abajo de la toma', 'Arriba de la toma, con la línea subiendo', 'A cualquier altura', 'Dentro de un pote de condensado'],
  answer: 1, explain: 'Con el transmisor arriba, cualquier condensado escurre de regreso al proceso y la línea queda llena de gas.',
  hints: ['Así el condensado se acumularía en la línea y en el transmisor.', null, 'La altura importa: define hacia dónde escurre el condensado.', 'Los potes son para vapor de agua, no para gas.'],
};
const Q_L3 = {
  id: 'li3-manifold', q: 'Al poner en servicio un transmisor DP con manifold de 3 válvulas, ¿qué se abre primero?',
  options: ['El bloqueo de baja (L)', 'El bloqueo de alta (H)', 'La ecualizadora', 'Las tres a la vez'],
  answer: 2, explain: 'Con la ecualizadora abierta, los dos lados de la celda ven la misma presión mientras se abre el bloqueo de alta: el sensor nunca recibe toda la presión de un solo lado.',
  hints: ['Abrir un bloqueo con la ecualizadora cerrada pondría toda la presión de un solo lado.', 'Primero hay que igualar los dos lados.', null, 'Nunca las tres abiertas con el proceso en marcha: se pierde la medición y puede haber flujo por el manifold.'],
};
const Q_L4 = {
  id: 'li4-cabeza', q: 'Un transmisor está 1,5 m por debajo de la toma, con la línea llena de agua. ¿Cuánta presión de más ve?',
  options: ['1,5 kPa', '9,8 kPa', '14,7 kPa', '147 kPa'],
  answer: 2, explain: 'ρ·g·h = 1 000 × 9,81 × 1,5 ≈ 14 700 Pa ≈ 14,7 kPa, que se corrige en el cero del transmisor.',
  hints: ['Falta multiplicar por la gravedad: 9,81.', 'Eso corresponde a 1 m de agua, no a 1,5 m.', null, 'Revisa las unidades: 14 700 Pa son 14,7 kPa.'],
};

const SCENES_M12C1 = [
  { C: (p) => <TitleCardM4 {...p} claseNo={1} title="Líneas de impulso: diseño e instalación" dudur="5 min" objetivo="Qué es una línea de impulso, los errores que provoca, cómo se instala para gas, líquido y vapor, dónde se hace la toma, los manifolds y la corrección por columna de líquido según API RP 551. Con preguntas en el camino." />, dur: 14, label: 'Apertura' },
  { C: S_What, dur: 21, label: 'Qué es' },
  { C: S_Errors, dur: 22, label: 'Errores' },
  { C: QuizSceneM4, dur: 12, label: 'Pregunta 1', quiz: Q_L1 },
  { C: S_Gas, dur: 18, label: 'Gas' },
  { C: S_Liq, dur: 20, label: 'Líquido' },
  { C: S_Steam, dur: 20, label: 'Vapor' },
  { C: QuizSceneM4, dur: 10, label: 'Pregunta 2', quiz: Q_L2 },
  { C: S_Tap, dur: 18, label: 'Toma' },
  { C: S_Mat, dur: 19, label: 'Materiales' },
  { C: S_Manifold, dur: 27, label: 'Manifold' },
  { C: QuizSceneM4, dur: 10, label: 'Pregunta 3', quiz: Q_L3 },
  { C: S_Other, dur: 18, label: 'Otros arreglos' },
  { C: S_Head, dur: 20, label: 'Columna' },
  { C: QuizSceneM4, dur: 12, label: 'Pregunta 4', quiz: Q_L4 },
  { C: (p) => <><ClosingM4 {...p} line="Gas sube, líquido baja, vapor usa potes; la toma depende del fluido, el manifold protege la celda y la columna de líquido se corrige en el cero." activity="Revisa un DP de tu planta: ¿la toma, la pendiente y el manifold siguen estas reglas?" /><QuizScoreM4 {...p} /></>, dur: 16, label: 'Cierre' },
];
window.SCENES_M12C1 = SCENES_M12C1;
