/* Página de caso de un Trabajo (single-trabajo.php). Todo bajo .sd-caso. */
.sd-caso {
  --c-ink: var(--sd-text, #1E202B);
  --c-muted: var(--sd-text-muted, #5C5E6E);
  --c-gold: var(--sd-gold, #B5953C);
  --c-gold-text: var(--sd-gold-text, #8E7124);
  --c-bg: var(--sd-bg, #FAF9F6);
  --c-soft: var(--sd-bg-soft, #F1F0EA);
  --c-line: rgba(30, 32, 43, 0.1);
  --f-head: var(--sd-font-head, "Outfit", sans-serif);
  --f-body: "Figtree", sans-serif;
  background: var(--c-bg);
  color: var(--c-ink);
  font-family: var(--f-body);
  font-size: 1rem;
  line-height: 1.65;
  padding-block: clamp(40px, 7vw, 88px);
}
.sd-caso *, .sd-caso *::before, .sd-caso *::after { box-sizing: border-box; }

/* Regla de AGENTS.md: un enlace dentro del texto conserva la tipografía de su contexto (.elementor-kit-6 a impone Poppins) */
.sd-caso :is(p,dd,li) a { font: inherit; }
.sd-caso :is(p,dd,li) a:not([class]) { color: var(--c-gold-text); text-decoration: underline; text-underline-offset: 3px; }

.sd-caso__wrap { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: 16px; }
.sd-caso__wrap + .sd-caso__wrap { margin-top: clamp(48px, 7vw, 88px); }

.sd-caso .sd-caso__title {
  margin: 0;
  font-family: var(--f-head);
  font-weight: 800;
  font-size: clamp(2.3rem, 7.8vw, 5.3rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  color: var(--c-ink);
  overflow-wrap: break-word;
}
.sd-caso .sd-caso__subtitle { margin: 16px 0 0; max-width: 60ch; font-size: 1.15rem; color: var(--c-muted); }
.sd-caso .sd-caso__h2 {
  margin: 0 0 24px;
  font-family: var(--f-head);
  font-weight: 700;
  font-size: clamp(1.8rem, 4.5vw, 3.2rem);
  line-height: 1.12;
  letter-spacing: -0.025em;
  color: var(--c-ink);
}
.sd-caso__head + .sd-caso__compare { margin-top: clamp(28px, 4vw, 48px); }

/* Comparador: el después va encima y se recorta con clip-path; el input range cubre el marco */
.sd-caso__compare { margin-bottom: 0; }
.sd-caso__frame {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid var(--c-line);
  border-radius: 14px;
  background: var(--c-soft);
  /* El centro del pulgar nativo recorre de 22px a 100%-22px: la línea y el recorte siguen ese mismo punto */
  --x: calc(22px + (100% - 44px) * var(--v, 50) / 100);
}
.sd-caso .sd-caso__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: top center;
  border-radius: 0;
}
.sd-caso__frame--compare .sd-caso__img--after { clip-path: inset(0 0 0 var(--x)); }
.sd-caso__handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--x);
  z-index: 1;
  width: 2px;
  margin-left: -1px;
  background: #FFFFFF;
  box-shadow: 0 0 0 1px rgba(30, 32, 43, 0.25);
  pointer-events: none;
}
.sd-caso__handle svg {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  padding: 12px;
  border-radius: 50%;
  background: #FFFFFF;
  color: var(--c-ink);
  box-shadow: 0 4px 14px rgba(30, 32, 43, 0.25);
  transform: translate(-50%, -50%);
}
.sd-caso__range {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
  touch-action: pan-y; /* el scroll vertical del móvil sigue funcionando sobre la imagen */
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}
.sd-caso__range::-webkit-slider-thumb { -webkit-appearance: none; width: 44px; height: 44px; }
.sd-caso__range::-moz-range-thumb { width: 44px; height: 44px; border: 0; }
.sd-caso__range:focus-visible + .sd-caso__handle svg { outline: 3px solid var(--c-gold-text); outline-offset: 3px; }
.sd-caso__legend {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-family: var(--f-head);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--c-muted);
}

/* Datos del proyecto */
.sd-caso__project-grid { display: grid; gap: 32px; }
@media (min-width: 860px) { .sd-caso__project-grid { grid-template-columns: 1.4fr 1fr; gap: 56px; } }
.sd-caso__text > :first-child { margin-top: 0; }
.sd-caso__text p { margin: 0 0 1em; color: var(--c-ink); }
.sd-caso__aside { display: flex; flex-direction: column; align-items: flex-start; gap: 24px; }
.sd-caso__meta { width: 100%; margin: 0; border-top: 1px solid var(--c-line); }
.sd-caso__meta > div { display: grid; grid-template-columns: 7.5rem 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--c-line); }
.sd-caso__meta dt { font-family: var(--f-head); font-size: 0.85rem; font-weight: 600; color: var(--c-muted); }
.sd-caso__meta dd { margin: 0; }

.sd-caso .sd-caso__btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid var(--c-ink);
  border-radius: 10px;
  background: transparent;
  font-family: var(--f-head);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--c-ink);
  text-decoration: none;
}
.sd-caso .sd-caso__btn:hover { border-color: var(--c-gold); color: var(--c-gold-text); }
.sd-caso .sd-caso__btn--solid { background: var(--c-ink); color: #FFFFFF; }
.sd-caso .sd-caso__btn--solid:hover { background: #2E3140; border-color: #2E3140; color: #FFFFFF; }
.sd-caso :is(.sd-caso__btn, .sd-caso__card):focus-visible { outline: 3px solid var(--c-gold-text); outline-offset: 3px; }

/* Galería, llamada y relacionados */
.sd-caso__gallery-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.sd-caso__gallery-grid img { display: block; width: 100%; height: auto; border: 1px solid var(--c-line); border-radius: 12px; }

.sd-caso__cta { text-align: center; }
.sd-caso__cta > * { margin-inline: auto; }
.sd-caso__cta p { max-width: 46ch; margin-bottom: 24px; color: var(--c-muted); }

.sd-caso__related-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 20px; margin: 0; padding: 0; list-style: none; }
.sd-caso .sd-caso__card { display: block; color: var(--c-ink); text-decoration: none; border-radius: 12px; }
.sd-caso__card img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; object-position: top center; border: 1px solid var(--c-line); border-radius: 12px; }
.sd-caso .sd-caso__card-title { margin: 12px 0 0; font-family: var(--f-head); font-size: 1.15rem; font-weight: 700; line-height: 1.3; color: var(--c-ink); }
.sd-caso .sd-caso__card:hover .sd-caso__card-title { color: var(--c-gold-text); }

.sd-caso__sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .sd-caso .sd-caso__btn, .sd-caso .sd-caso__card-title { transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease; }
}
