/* ==========================================================================
   Home · Proyectos a medida — 2026-10-23 · carrusel 2026-10-30
   Plantilla: templates/_partials/home/home-medida.tpl · JS: assets/js/home-medida.js
   Carrusel de tarjetas verticales (como tado.com) que asoma hasta el borde derecho de la ventana. Al pulsar, un único
   panel (position:absolute sobre .mlmed__stage) crece con clip-path desde la tarjeta hasta todo el ancho. Móvil: pantalla
   completa. Cabecera y flechas: patrón .mlsec__head / .mlsec__nav (home-sections.css). Sin JS: detalles debajo.
   ========================================================================== */
.mlmed {
  --mlmed-ink: #1b2140;
  --mlmed-ink-soft: #4a5170;
  --mlmed-on-photo: #ffffff;
  --mlmed-scrim: rgba(12, 16, 32, .40);
  --mlmed-deep: rgba(10, 13, 26, .82);
  --mlmed-card: #f2f4f8;
  --mlmed-focus: #8fb4ff;
  --mlmed-ease: cubic-bezier(.65, 0, .35, 1);
  padding: 32px 0 40px;
}
/* mismo borde que el resto de bloques (escritorio: 1860 + 16; móvil: 16) */
.mlmed__inner-wrap {
  max-width: var(--ml-max, 1860px);
  margin-inline: auto;
  padding-inline: var(--ml-gutter, 16px);
  box-sizing: border-box;
}
html.mlmed-lock { overflow: hidden; }
/* custom.css pone backdrop-filter en section#main de la home: crea un bloque contenedor y el panel fixed (móvil)
   dejaba de ocupar la pantalla. Solo mientras está abierto. */
html.mlmed-lock body#index #content-wrapper section#main { backdrop-filter: none !important; }

/* ---- Carrusel ---- */
.mlmed__stage { position: relative; }
/* Abierto: el escenario crece para que quepa el detalle (el panel lo cubre entero) */
.mlmed.is-js.is-open .mlmed__stage { min-height: min(620px, calc(100vh - 140px)); }
.mlmed__track {
  position: relative; display: flex; gap: 12px; overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  margin-right: calc(50% - 50vw);        /* asoma hasta el borde derecho de la ventana */
  padding: 4px var(--ml-gutter, 16px) 4px 0;
}
.mlmed__track::-webkit-scrollbar { display: none; }
/* 04/11: 50vw incluye media barra de scroll (Windows: 7,5 px) → el track sobresalía y la home tenía scroll horizontal.
   Se recorta en el primer antepasado a todo el ancho; clip (no hidden): no crea contenedor de scroll ni afecta a sticky/fixed. */
body#index section#wrapper { overflow-x: clip; }

/* ---- Tarjeta ---- */
.mlmed .mlmed__tile {
  position: relative; display: block; flex: 0 0 clamp(250px, 22vw, 300px); aspect-ratio: 4 / 5; overflow: hidden;
  border-radius: 20px; scroll-snap-align: start;
  color: var(--mlmed-on-photo); text-decoration: none; background: var(--mlmed-ink);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: filter .35s ease;
}
@media (max-width: 640px) { .mlmed .mlmed__tile { flex-basis: min(78vw, 300px); } }
.mlmed .mlmed__tile img {
  position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: cover;
  transition: transform .9s cubic-bezier(.2, .7, .2, 1);
}
/* Degradado arriba para leer el título sobre cualquier foto */
.mlmed__tile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(12, 16, 32, .72) 0%, rgba(12, 16, 32, .25) 42%, rgba(12, 16, 32, 0) 65%); }
.mlmed__body { position: absolute; inset: 0 0 auto; z-index: 1; display: grid; gap: 8px; padding: 24px 24px 0; }
.mlmed__name {
  display: block; margin: 0; font-size: 22px; font-weight: 500; line-height: 1.1;   /* 23/10: 700 → 500 (Outfit gruesa no gusta) */
  letter-spacing: -.01em; text-wrap: balance;
}
.mlmed__desc { display: block; margin: 0; max-width: 30ch; font-size: 14px; font-weight: 200; line-height: 1.4; opacity: .9; }
.mlmed__plus {
  position: absolute; right: 16px; bottom: 16px; z-index: 1; display: grid; place-items: center; width: 44px; height: 44px;
  border-radius: 50%; background: rgba(255, 255, 255, .9); color: var(--mlmed-ink); transition: transform .3s ease, background .3s ease;
}
.mlmed__plus svg { width: 16px; height: 16px; }
.mlmed__solid svg { width: 12px; height: 12px; }
.mlmed .mlmed__tile:hover, .mlmed .mlmed__tile:focus { color: var(--mlmed-on-photo); text-decoration: none; }
.mlmed__tile:hover img { transform: scale(1.05); }
.mlmed__tile:hover .mlmed__plus { background: #fff; transform: rotate(90deg); }
.mlmed__tile:focus-visible { outline: 3px solid var(--mlmed-focus); outline-offset: -3px; }
/* Con un proyecto abierto, el resto se apaga (test-desplegado.png) */
.mlmed.is-open .mlmed__tile { filter: brightness(.3) saturate(.6); }

/* ---- Panel ---- */
.mlmed__panel { color: var(--mlmed-on-photo); }
.mlmed.is-js .mlmed__panel {
  position: absolute; inset: 0; z-index: 5; margin: 0; overflow: hidden; border-radius: 20px; background: var(--mlmed-ink);
  clip-path: inset(0 round 20px); transition: clip-path .62s var(--mlmed-ease);
}
.mlmed.is-js .mlmed__panel[hidden] { display: none !important; }
@media (max-width: 640px) {
  .mlmed.is-js.is-open .mlmed__stage { min-height: 0; }
  .mlmed.is-js .mlmed__panel {
    position: fixed; inset: 0; z-index: 1000; overflow-y: auto; overscroll-behavior: contain; border-radius: 0;
    padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

.mlmed__detail { position: relative; min-height: 100%; overflow: hidden; background: var(--mlmed-ink); }
.mlmed__panel > .mlmed__detail + .mlmed__detail { margin-top: 8px; }
.mlmed.is-js .mlmed__panel > .mlmed__detail + .mlmed__detail { margin-top: 0; }
.mlmed.is-js .mlmed__detail { position: absolute; inset: 0; overflow: hidden; }
.mlmed.is-js .mlmed__detail.can-scroll { overflow-y: auto; }   /* solo si el contenido no cabe (lo decide el JS) */
.mlmed.is-js .mlmed__detail[hidden] { display: none !important; }
@media (max-width: 640px) { .mlmed.is-js .mlmed__detail { position: relative; inset: auto; min-height: 100%; overflow: visible; } }
/* Mientras se expande o cambia de proyecto (aún sin .is-ready), sin scroll: evita que asome la barra */
.mlmed.is-js .mlmed__panel:not(.is-ready),
.mlmed.is-js .mlmed__panel:not(.is-ready) .mlmed__detail { overflow: hidden; }
.mlmed .mlmed__detail-bg { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: cover; }
.mlmed__detail::before { content: ""; position: absolute; inset: 0; z-index: 1; background: var(--mlmed-deep); }

.mlmed__inner {
  position: relative; z-index: 2; min-height: 100%;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); grid-template-rows: 1fr auto;
  gap: 24px 56px; padding: clamp(24px, 3vw, 56px);
}
/* Entrada con escalado hacia dentro: no desborda, así no aparece barra de scroll al terminar */
.mlmed.is-js .mlmed__inner { opacity: 0; transform: scale(.985); transition: opacity .35s ease, transform .45s cubic-bezier(.2, .7, .2, 1); }
.mlmed.is-js .mlmed__panel.is-ready .mlmed__inner { opacity: 1; transform: none; }
@media (max-width: 1100px) { .mlmed__inner { grid-template-columns: 1fr; grid-template-rows: auto; gap: 16px; padding-block: 64px 20px; } }

.mlmed__text { align-self: center; display: grid; gap: 18px; max-width: 58ch; }
.mlmed .mlmed__dname {
  margin: 0; color: var(--mlmed-on-photo); font-size: clamp(32px, 3.4vw, 56px); line-height: 1.02;
  font-weight: 500 !important;   /* custom.css fuerza h1–h6 a 200 con !important; aquí 500, como la tarjeta */
  letter-spacing: -.015em; text-wrap: balance;
}
.mlmed__dname:focus { outline: none; }
.mlmed .mlmed__lead { margin: 0; font-size: 18px; line-height: 1.55; color: var(--mlmed-on-photo); }
.mlmed .mlmed__uses-t, .mlmed .mlmed__prods-t { margin: 6px 0 0; font-size: 16px; font-weight: 700; color: var(--mlmed-on-photo); }
.mlmed__uses { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.mlmed__uses li { padding: 6px 14px; border-radius: 999px; background: rgba(255, 255, 255, .12); font-size: 15px; font-weight: 600; }

.mlmed__prods { align-self: center; display: grid; gap: 12px; }
.mlmed__prodlist {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(max(140px, calc(50% - 8px)), 1fr));
  gap: 8px; margin: 0; padding: 0; list-style: none;
}
.mlmed__prod { display: grid; grid-template-rows: auto auto; background: var(--mlmed-card); color: var(--mlmed-ink); }
.mlmed__prod-img { position: relative; aspect-ratio: 16 / 10; overflow: hidden; }
.mlmed__prodlist:has(> :nth-child(3)) .mlmed__prod-img { aspect-ratio: 5 / 2; }
.mlmed .mlmed__prod-img img {
  position: absolute; top: 14px; left: 16px; width: calc(100% - 32px); height: calc(100% - 20px); max-width: none;
  object-fit: contain; mix-blend-mode: multiply;
}
.mlmed__prod-text { padding: 10px 16px 16px; }
.mlmed .mlmed__prod-name { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.25; color: var(--mlmed-ink); }
.mlmed .mlmed__prod-note { margin: 4px 0 0; font-size: 14px; color: var(--mlmed-ink-soft); }
.mlmed__stat { display: grid; align-content: center; justify-items: start; gap: 4px; padding: 24px 22px; min-height: 100%; }
.mlmed__stat strong { font-size: 56px; font-weight: 500; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.mlmed__stat span { font-size: 15px; color: var(--mlmed-ink-soft); }
@media (max-width: 640px) { .mlmed__stat strong { font-size: 34px; } }

.mlmed__actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; }
.mlmed .mlmed__solid {
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 26px; border-radius: 999px;
  background: var(--mlmed-on-photo); color: var(--mlmed-ink); font-size: 15px; font-weight: 700; text-decoration: none;
}
.mlmed .mlmed__solid:hover { background: #dfe6f5; color: var(--mlmed-ink); text-decoration: none; }
.mlmed .mlmed__more { color: var(--mlmed-on-photo); font-weight: 600; text-decoration: underline; text-underline-offset: 4px; }
.mlmed .mlmed__more:hover { color: var(--mlmed-on-photo); }
.mlmed__solid:focus-visible, .mlmed__more:focus-visible, .mlmed__ctl:focus-visible { outline: 3px solid var(--mlmed-focus); outline-offset: 3px; }

/* ---- Controles del panel: cerrar (esquina) y anterior/siguiente ---- */
.mlmed .mlmed__ctl {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; min-width: 44px;
  border: 0; border-radius: 999px; background: rgba(255, 255, 255, .14); color: var(--mlmed-on-photo);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; touch-action: manipulation;
}
.mlmed .mlmed__ctl:hover { background: rgba(255, 255, 255, .26); }
.mlmed__ctl svg { width: 16px; height: 16px; flex: none; }
.mlmed .mlmed__close { position: absolute; top: 16px; right: 16px; z-index: 6; width: 48px; height: 48px; padding: 0; }
.mlmed__pager { position: absolute; right: 16px; bottom: 16px; z-index: 6; display: flex; gap: 8px; }
.mlmed__pager .mlmed__ctl { padding: 0 16px; }
.mlmed .mlmed__close, .mlmed__pager { display: none; }
.mlmed.is-js .mlmed__close, .mlmed.is-js .mlmed__pager { display: inline-flex; }
@media (max-width: 640px) {
  .mlmed { padding:32px 0 0 }
  .mlmed.is-js .mlmed__close { position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); right: calc(12px + env(safe-area-inset-right, 0px)); }
  .mlmed.is-js .mlmed__pager { position: relative; right: auto; bottom: auto; justify-content: space-between; padding: 0 16px 24px; z-index: 3; }
  .mlmed__pager .mlmed__ctl span { max-width: 13ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  .mlmed__tile img, .mlmed__tile, .mlmed.is-js .mlmed__panel, .mlmed.is-js .mlmed__inner { transition: none !important; }
  .mlmed__tile:hover img { transform: none; }
}

/* 19/11/2026 · «Cómo trabajamos» como barra de progreso (ref. NUEVO DISENO/progreso-barra.png): pista gris neutra entre el
   primer y el último punto; el relleno verde avanza con el scroll (scroll-driven animation sobre la view-timeline --mlp,
   desde que la franja asoma por abajo hasta que llega bajo la cabecera: inset superior --mlp-top, lo mide el script).
   Cada punto se enciende (pop + pulso) y su texto aparece en fundido al llegarle el relleno (clase .is-on, script). */
.mlmed .mlmed-steps {
  --mlp-green: #146536; --mlp-grey: #d5d9e0; --mlp-dot: 22px;
  position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0;
  margin: 4px 0 40px !important; padding: 0 !important; list-style: none;
  view-timeline: --mlp block; view-timeline-inset: var(--mlp-top, 140px) 0px;
}
.mlmed .mlmed-steps::before,
.mlmed .mlmed-steps::after {
  content: ""; position: absolute; top: calc(var(--mlp-dot) / 2 - 2px); left: 12.5%; right: 12.5%;
  height: 4px; border-radius: 2px; background: var(--mlp-grey);
}
.mlmed .mlmed-steps::after { background: var(--mlp-green); transform-origin: 0 50%; transform: scaleX(var(--mlp-p, 1)); }
.mlmed .mlmed-steps.is-ready::after { transform: scaleX(var(--mlp-p, 0)); }
@supports (animation-timeline: view()) {
  .mlmed .mlmed-steps.is-ready::after { animation: mlp-fill linear both; animation-timeline: --mlp; animation-range: entry 0% contain 100%; }
}
@keyframes mlp-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.mlmed .mlmed-steps li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 0; padding: 0 10px; border: 0; text-align: center; }
.mlmed .mlmed-steps__dot {
  position: relative; z-index: 1; flex: none; box-sizing: border-box; width: var(--mlp-dot); height: var(--mlp-dot); margin-bottom: 10px;
  border: 3px solid var(--mlp-grey); border-radius: 50%; background: #fff; transition: border-color .3s ease;
}
.mlmed .mlmed-steps__dot::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--mlp-grey); transition: background-color .3s ease; }
.mlmed .mlmed-steps strong { color: var(--mlmed-ink); font-size: 15px; font-weight: 600; line-height: 1.3; }
.mlmed .mlmed-steps__txt { max-width: 30ch; color: var(--mlmed-ink-soft); font-size: 14px; line-height: 1.5; }
.mlmed .mlmed-steps.is-ready strong,
.mlmed .mlmed-steps.is-ready .mlmed-steps__txt { opacity: 0; transform: translateY(8px); transition: opacity .45s ease, transform .45s ease; }
.mlmed .mlmed-steps li.is-on strong { opacity: 1; transform: none; transition-delay: .12s; }
.mlmed .mlmed-steps li.is-on .mlmed-steps__txt { opacity: 1; transform: none; transition-delay: .22s; }
.mlmed .mlmed-steps li.is-on .mlmed-steps__dot { border-color: var(--mlp-green); animation: mlp-pop .5s cubic-bezier(.34, 1.56, .64, 1); }
.mlmed .mlmed-steps li.is-on .mlmed-steps__dot::after { background: var(--mlp-green); }
.mlmed .mlmed-steps li.is-on .mlmed-steps__dot::before {
  content: ""; position: absolute; inset: -3px; border: 2px solid var(--mlp-green); border-radius: 50%; animation: mlp-pulse .8s ease-out forwards;
}
@keyframes mlp-pop { 0% { transform: scale(1); } 45% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes mlp-pulse { from { opacity: .7; transform: scale(1); } to { opacity: 0; transform: scale(2.3); } }
@media (max-width: 767px) {
  .mlmed .mlmed-steps { --mlp-dot: 18px; margin: 0 0 24px !important; }
  .mlmed .mlmed-steps li { padding: 0 4px; }
  .mlmed .mlmed-steps__dot { margin-bottom: 6px; border-width: 2px; }
  .mlmed .mlmed-steps__dot::after { inset: 3px; }
  .mlmed .mlmed-steps strong { font-size: 12px; }
  .mlmed .mlmed-steps__txt { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .mlmed .mlmed-steps.is-ready::after { animation: none; transform: scaleX(1); }
  .mlmed .mlmed-steps li.is-on .mlmed-steps__dot,
  .mlmed .mlmed-steps li.is-on .mlmed-steps__dot::before { animation: none; }
  .mlmed .mlmed-steps.is-ready strong, .mlmed .mlmed-steps.is-ready .mlmed-steps__txt { transition: none; }
}

/* 20/11/2026 (Álvaro): flechas del carrusel debajo de las tarjetas, alineadas a la derecha */
.mlmed .mlmed__nav { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
