/* =====================================================
   ARCHIVO GENERAL SAN JUAN — instructivo.css
   Requiere shared.css cargado antes.
   ===================================================== */

/* Compensa la cabecera sticky del design system al saltar a un ancla */
html { scroll-padding-top: calc(var(--header-h, 80px) + 16px); }

/* ─── Clases de home.css reutilizadas aquí ────────── */
.sec-label {
  font-family: var(--fu);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--cp-dk);
  margin-bottom: 8px;
}

.sec-title {
  font-family: var(--fu);
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 700;
  color: var(--ct);
  margin-bottom: 12px;
  line-height: 1.2;
}

.sec-sub {
  font-family: var(--fb);
  font-size: 16px;
  color: var(--ct2);
  line-height: 1.75;
  max-width: 60ch;
  margin-bottom: 32px;
}

.faq-list {
  display: flex;
  flex-direction: column;
  max-width: 780px;
}

.faq-item { border-bottom: 1px solid var(--cbrd); }
.faq-item:first-child { border-top: 1px solid var(--cbrd); }

.faq-q {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  gap: 16px;
  font-family: var(--fu);
  font-size: 16px;
  font-weight: 600;
  color: var(--ct);
  text-align: left;
  transition: color 0.15s;
}

.faq-q:hover { color: var(--cp-dk); }

.faq-q svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--ct3);
  transition: transform 0.25s var(--ease), color 0.15s;
}

.faq-item.open .faq-q svg {
  transform: rotate(45deg);
  color: var(--cp-dk);
}

.faq-item.open .faq-q { color: var(--cp-dk); }

.faq-a {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s var(--ease);
}

.faq-item.open .faq-a { max-height: 600px; }

.faq-a-inner {
  font-family: var(--fb);
  font-size: 16px;
  color: var(--ct2);
  line-height: 1.75;
  padding-bottom: 20px;
}

/* ─── Page layout ─────────────────────────────────── */
.pg-instructivo { flex: 1; }

/* ─── Hero ────────────────────────────────────────── */
.instr-hero {
  background: var(--cmuted);
  border-bottom: 1px solid var(--cbrd);
  padding: 56px 24px 48px;
  text-align: center;
}

.instr-hero h1 {
  font-family: var(--fu);
  font-size: clamp(24px, 4vw, 40px);
  font-weight: 700;
  color: var(--ct);
  max-width: 28ch;
  margin: 0 auto 16px;
  line-height: 1.2;
}

.instr-hero p {
  font-family: var(--fb);
  font-size: clamp(16px, 1.5vw, 18px);
  color: var(--ct2);
  max-width: 54ch;
  margin: 0 auto;
  line-height: 1.7;
}

.instr-hero-chips {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.instr-hero-chip {
  font-family: var(--fu);
  font-size: 13px;
  font-weight: 600;
  background: var(--csurf);
  border: 1px solid var(--cbrd2);
  border-radius: 9999px;
  padding: 6px 16px;
  color: var(--ct2);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.instr-hero-chip:hover {
  border-color: oklch(from var(--cp) l c h / 0.5);
  color: var(--cp-dk);
}

/* ─── Layout principal ────────────────────────────── */
.instr-layout {
  max-width: 1060px;
  margin: 0 auto;
  padding: 48px 24px 80px;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

/* ─── TOC sidebar ─────────────────────────────────── */
.instr-toc {
  position: sticky;
  top: calc(var(--header-h, 80px) + 16px);
  max-height: calc(100vh - var(--header-h, 80px) - 32px);
  overflow-y: auto;
}

.toc-heading {
  font-family: var(--fu);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ct3);
  margin-bottom: 10px;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.toc-list > li > a {
  font-family: var(--fu);
  font-size: 13px;
  font-weight: 600;
  color: var(--ct2);
  text-decoration: none;
  padding: 5px 8px;
  border-radius: 6px;
  display: block;
  transition: background 0.12s, color 0.12s;
}

.toc-list > li > a:hover {
  background: oklch(from var(--cp) l c h / 0.08);
  color: var(--cp-dk);
}

.toc-list ol {
  list-style: none;
  padding-left: 12px;
  margin-top: 1px;
  margin-bottom: 4px;
}

.toc-list ol a {
  font-family: var(--fu);
  font-size: 12px;
  color: var(--ct3);
  text-decoration: none;
  padding: 3px 8px;
  border-radius: 5px;
  display: block;
  transition: color 0.12s;
}

.toc-list ol a:hover { color: var(--cp-dk); }

/* ─── Secciones ───────────────────────────────────── */
.instr-section { margin-bottom: 8px; }

.instr-section-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 32px;
}

.instr-badge {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: var(--cp);
  color: var(--cton);
  border-radius: 10px;
  font-family: var(--fu);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.instr-section-desc {
  font-family: var(--fb);
  font-size: 16px;
  color: var(--ct2);
  line-height: 1.7;
  max-width: 58ch;
  margin-top: 6px;
}

.instr-subsection { margin-bottom: 36px; }

.instr-h3 {
  font-family: var(--fu);
  font-size: 17px;
  font-weight: 700;
  color: var(--ct);
  margin-bottom: 14px;
  padding-bottom: 9px;
  border-bottom: 2px solid var(--cbrd);
}

.instr-body {
  font-family: var(--fb);
  font-size: 16px;
  color: var(--ct2);
  line-height: 1.72;
  max-width: 64ch;
  margin-bottom: 16px;
}

.instr-divider {
  border: none;
  border-top: 1px solid var(--cbrd);
  margin: 52px 0;
}

/* ─── Pasos numerados ─────────────────────────────── */
.instr-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.instr-step {
  display: flex;
  gap: 16px;
  position: relative;
  padding-bottom: 24px;
}

.instr-step:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 15px;
  top: 34px;
  bottom: 0;
  width: 2px;
  background: var(--cbrd);
}

.step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: oklch(from var(--cp) l c h / 0.1);
  color: var(--cp-dk);
  border: 2px solid oklch(from var(--cp) l c h / 0.28);
  border-radius: 9999px;
  font-family: var(--fu);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-body { padding-top: 4px; }

.step-body strong {
  font-family: var(--fu);
  font-size: 15px;
  font-weight: 700;
  color: var(--ct);
  display: block;
  margin-bottom: 4px;
}

.step-body p {
  font-family: var(--fb);
  font-size: 15px;
  color: var(--ct2);
  line-height: 1.65;
}

.step-body code {
  font-family: monospace;
  font-size: 14px;
  background: var(--cmuted);
  border: 1px solid var(--cbrd2);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--cp-dk);
}

/* ─── Grilla de filtros ───────────────────────────── */
.instr-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.filter-card {
  background: var(--csurf);
  border: 1px solid var(--cbrd);
  border-radius: 10px;
  padding: 14px 16px;
}

.filter-card strong {
  font-family: var(--fu);
  font-size: 13px;
  font-weight: 700;
  color: var(--ct);
  display: block;
  margin-bottom: 4px;
}

.filter-card p {
  font-family: var(--fb);
  font-size: 13px;
  color: var(--ct2);
  line-height: 1.5;
}

/* ─── Hint / nota ─────────────────────────────────── */
.instr-hint {
  font-family: var(--fb);
  font-size: 13.5px;
  color: var(--ct3);
  line-height: 1.6;
  padding: 10px 14px;
  background: var(--cmuted);
  border-left: 3px solid var(--cbrd2);
  border-radius: 0 8px 8px 0;
  margin-top: 12px;
}

/* ─── Asides / callouts ───────────────────────────── */
.instr-aside {
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 16px;
  font-family: var(--fb);
  font-size: 14.5px;
  line-height: 1.65;
}

.instr-aside--info {
  background: oklch(from var(--cp) l c h / 0.06);
  border: 1px solid oklch(from var(--cp) l c h / 0.2);
  color: var(--ct);
}

.instr-aside--warn {
  background: oklch(from var(--cwarn) l c h / 0.1);
  border: 1px solid oklch(from var(--cwarn) l c h / 0.3);
  color: var(--ct);
}

.instr-aside strong { font-family: var(--fu); }

/* ─── Tarjetas de fondos ──────────────────────────── */
.instr-fondos-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fondo-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--csurf);
  border: 1px solid var(--cbrd);
  border-radius: 12px;
  padding: 16px 20px;
  transition: border-color 0.15s;
}

.fondo-card:hover {
  border-color: oklch(from var(--cp) l c h / 0.4);
}

.fondo-card-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: oklch(from var(--cp) l c h / 0.09);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cp-dk);
}

.fondo-card-icon svg { width: 20px; height: 20px; }

.fondo-card-name {
  font-family: var(--fu);
  font-size: 15px;
  font-weight: 700;
  color: var(--ct);
  display: block;
  margin-bottom: 4px;
}

.fondo-card-desc {
  font-family: var(--fb);
  font-size: 14px;
  color: var(--ct2);
  line-height: 1.6;
}

/* ─── Mockup de resultado del buscador ───────────── */
.instr-mockup {
  background: var(--csurf);
  border: 1px solid var(--cbrd);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 20px;
  pointer-events: none;
}

.mockup-source {
  font-family: var(--fu);
  font-size: 12px;
  color: var(--ct3);
  margin-bottom: 6px;
}

.mockup-title {
  font-family: var(--fu);
  font-size: 17px;
  font-weight: 600;
  color: var(--cp-dk);
  margin-bottom: 8px;
}

.mockup-snippet {
  font-family: var(--fb);
  font-size: 15px;
  color: var(--ct2);
  line-height: 1.65;
  margin-bottom: 12px;
}

.mockup-snippet mark {
  background: oklch(from var(--cp-lt) l c h / 0.45);
  color: inherit;
  border-radius: 2px;
  padding: 0 2px;
}

.mockup-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.mockup-btn-pill {
  font-family: var(--fu);
  font-size: 12px;
  font-weight: 600;
  background: oklch(from var(--cp-lt) l c h / 0.35);
  color: oklch(32% 0.13 40);
  border-radius: 9999px;
  padding: 5px 14px;
}

.mockup-link {
  font-family: var(--fu);
  font-size: 13px;
  color: var(--cp-dk);
}

/* ─── Leyenda dl ──────────────────────────────────── */
.instr-legend {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  font-size: 14px;
  font-family: var(--fb);
  color: var(--ct2);
  margin-top: 16px;
}

.instr-legend dt {
  font-family: var(--fu);
  font-weight: 700;
  color: var(--ct);
  white-space: nowrap;
}

/* ─── State badges ────────────────────────────────── */
.state-badge {
  display: inline-block;
  font-family: var(--fu);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 9999px;
  padding: 3px 10px;
}

.state-badge--pending  {
  background: oklch(from var(--cwarn) l c h / 0.15);
  color: oklch(45% 0.14 85);
}

.state-badge--progress {
  background: oklch(45% 0.16 250 / 0.12);
  color: oklch(32% 0.14 250);
}

.state-badge--available {
  background: oklch(from var(--cok) l c h / 0.12);
  color: var(--cok-dk);
}

.state-badge--done {
  background: oklch(48% 0 0 / 0.1);
  color: var(--ct2);
}

.state-badge--error {
  background: oklch(from var(--cerr) l c h / 0.1);
  color: oklch(38% 0.2 29);
}

/* ─── Timeline horizontal (Flujo B) ──────────────── */
.instr-timeline {
  display: flex;
  align-items: flex-start;
  margin: 20px 0;
  overflow-x: auto;
  padding-bottom: 4px;
}

.timeline-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 110px;
  position: relative;
}

.timeline-dot {
  width: 16px;
  height: 16px;
  border-radius: 9999px;
  background: var(--cbrd2);
  border: 2px solid var(--cbrd2);
  flex-shrink: 0;
  z-index: 1;
}

.timeline-dot--active {
  background: var(--cp);
  border-color: var(--cp);
}

.timeline-dot--done {
  background: var(--cok);
  border-color: var(--cok);
}

.timeline-connector {
  position: absolute;
  top: 7px;
  left: 50%;
  right: -50%;
  height: 2px;
  background: var(--cbrd);
  z-index: 0;
}

.timeline-node:last-child .timeline-connector { display: none; }

.timeline-label {
  text-align: center;
  margin-top: 10px;
  padding: 0 4px;
}

.timeline-label p {
  font-family: var(--fb);
  font-size: 12px;
  color: var(--ct3);
  line-height: 1.5;
  margin-top: 6px;
}

/* ─── Timeline vertical (Flujo C) ─────────────────── */
.instr-timeline--vertical {
  flex-direction: column;
  align-items: stretch;
  overflow-x: visible;
  padding-bottom: 0;
  margin-bottom: 0;
}

.timeline-node-v {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  position: relative;
  padding-bottom: 22px;
}

.timeline-node-v:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 16px;
  bottom: 0;
  width: 2px;
  background: var(--cbrd);
}

.timeline-dot-v {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 9999px;
  border: 2px solid var(--cbrd2);
  background: var(--cbrd2);
  margin-top: 2px;
}

.timeline-dot-v--active { background: var(--cp); border-color: var(--cp); }
.timeline-dot-v--done   { background: var(--cok); border-color: var(--cok); }
.timeline-dot-v--error  { background: var(--cerr); border-color: var(--cerr); }

.timeline-content-v p {
  font-family: var(--fb);
  font-size: 14px;
  color: var(--ct2);
  line-height: 1.6;
  margin-top: 4px;
}

/* ─── Mockup email ────────────────────────────────── */
.email-mockup {
  border: 1px solid var(--cbrd);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}

.email-header {
  background: var(--cmuted);
  border-bottom: 1px solid var(--cbrd);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.email-from {
  font-family: var(--fu);
  font-size: 12px;
  color: var(--ct3);
}

.email-subject {
  font-family: var(--fu);
  font-weight: 700;
  color: var(--ct);
  font-size: 13px;
  line-height: 1.3;
}

.email-body {
  padding: 16px;
  background: var(--csurf);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.email-body p {
  font-family: var(--fb);
  font-size: 14px;
  color: var(--ct2);
  line-height: 1.65;
}

.email-cta-block {
  display: inline-block;
  background: var(--cp);
  color: var(--cton);
  border-radius: 9999px;
  padding: 9px 22px;
  font-family: var(--fu);
  font-size: 13px;
  font-weight: 600;
  align-self: flex-start;
  margin-top: 4px;
}

.email-footer-tag {
  padding: 8px 16px;
  background: var(--cmuted);
  border-top: 1px solid var(--cbrd);
  font-family: var(--fu);
  font-size: 12px;
  color: var(--ct3);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.email-turno-box {
  margin: 4px 0;
  background: oklch(from var(--cok) l c h / 0.07);
  border-left: 4px solid var(--cok);
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
  font-family: var(--fb);
  font-size: 14px;
  color: var(--ct);
  line-height: 1.7;
}

/* ─── Tarjetas tipo de búsqueda ───────────────────── */
.instr-tipos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.tipo-card {
  background: var(--csurf);
  border: 1.5px solid var(--cbrd2);
  border-radius: 12px;
  padding: 16px;
}

.tipo-icon {
  width: 36px;
  height: 36px;
  background: oklch(from var(--cp) l c h / 0.09);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cp-dk);
  margin-bottom: 10px;
}

.tipo-icon svg { width: 18px; height: 18px; }

.tipo-card strong {
  font-family: var(--fu);
  font-size: 14px;
  font-weight: 700;
  color: var(--ct);
  display: block;
  margin-bottom: 6px;
}

.tipo-card p {
  font-family: var(--fb);
  font-size: 13px;
  color: var(--ct2);
  line-height: 1.6;
  margin-bottom: 8px;
}

.tipo-fondos {
  font-family: var(--fu);
  font-size: 11px;
  font-weight: 600;
  color: var(--ct3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Wizard preview ──────────────────────────────── */
.wizard-preview {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.wizard-preview-step {
  background: var(--csurf);
  border: 1.5px solid var(--cbrd2);
  border-radius: 12px;
  padding: 16px;
  flex: 1;
  min-width: 150px;
}

.wizard-preview-step--active {
  border-color: var(--cp);
  background: oklch(from var(--cp) l c h / 0.04);
}

.wizard-preview-num {
  width: 28px;
  height: 28px;
  border-radius: 9999px;
  background: var(--cp);
  color: var(--cton);
  font-family: var(--fu);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.wizard-preview-step:not(.wizard-preview-step--active) .wizard-preview-num {
  background: var(--cmuted);
  color: var(--ct3);
}

.wizard-preview-title {
  font-family: var(--fu);
  font-size: 14px;
  font-weight: 700;
  color: var(--ct);
  margin-bottom: 6px;
}

.wizard-preview-desc {
  font-family: var(--fb);
  font-size: 13px;
  color: var(--ct2);
  line-height: 1.55;
}

.wizard-preview-arrow {
  font-size: 20px;
  color: var(--ct3);
  align-self: center;
  flex-shrink: 0;
  margin-top: 14px;
}

/* ─── CTA de sección ──────────────────────────────── */
.instr-cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--cbrd);
}

/* ─── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 860px) {
  .instr-layout {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 28px 20px 60px;
  }

  .instr-toc {
    position: static;
    overflow: visible;
    background: var(--cmuted);
    border: 1px solid var(--cbrd);
    border-radius: 12px;
    padding: 16px 20px;
  }

  .toc-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .toc-list > li { flex: 1 1 auto; }
  .toc-list > li > a { white-space: nowrap; }
  .toc-list ol { display: none; }
}

@media (max-width: 560px) {
  .instr-hero { padding: 40px 20px 36px; }

  .instr-section-header {
    flex-direction: column;
    gap: 12px;
  }

  .wizard-preview {
    flex-direction: column;
  }

  .wizard-preview-arrow {
    transform: rotate(90deg);
    align-self: center;
    margin-top: 0;
  }

  .instr-timeline {
    flex-direction: column;
    align-items: stretch;
    overflow-x: visible;
  }

  .timeline-node {
    flex-direction: row;
    align-items: flex-start;
    min-width: unset;
    gap: 12px;
    padding-bottom: 16px;
    position: relative;
  }

  .timeline-node:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 7px;
    top: 16px;
    bottom: 0;
    width: 2px;
    height: unset;
    right: unset;
    background: var(--cbrd);
  }

  .timeline-connector { display: none; }

  .timeline-label {
    text-align: left;
    margin-top: 0;
    padding: 0;
  }

  .instr-tipos-grid { grid-template-columns: 1fr; }

  .instr-cta {
    flex-direction: column;
  }

  .instr-cta .gsj-button {
    width: 100%;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fondo-card,
  .toc-list > li > a,
  .instr-hero-chip,
  .faq-a {
    transition: none;
  }
}
