/* Charly Muro 1.0.0 — estilos del muro (idénticos a la demo aprobada v0.4). Prefijo chm- en todo. */
.chm {
  --chm-bg: #0A0A0B;
  --chm-ink: #F2F1ED;
  --chm-mute: #9A9AA0;
  --chm-line: #2C2C30;
  --chm-blue: #2342E0;
  --chm-blue-l: #8FA2FF;
  --chm-mono: 'DM Mono', ui-monospace, monospace;
  position: relative;
  background: var(--chm-bg);
  color: var(--chm-ink);
  -webkit-tap-highlight-color: transparent;
}
.chm *, .chm *::before, .chm *::after { box-sizing: border-box; }

/* ---------- Escenario ---------- */
.chm-stage {
  position: relative;
  height: var(--chm-h, calc(100svh - var(--chm-offset, 168px)));   /* pantalla menos cabecera y título */
  min-height: 420px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
  cursor: grab;
  contain: layout paint;
}
.chm-stage:focus-visible { box-shadow: inset 0 0 0 2px var(--chm-blue-l); }
.chm.is-dragging .chm-stage { cursor: grabbing; }
/* Margen lateral proporcional (igual que sideMargin() en el JS) */
.chm { --chm-m: clamp(28px, 8vw, 160px); }
.chm.is-coarse { --chm-m: clamp(14px, 5vw, 32px); }
/* Fundido hacia el negro: márgenes laterales, borde superior/inferior suave y viñeta esférica */
.chm-stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background:
    linear-gradient(to right, var(--chm-bg) 0, rgba(10,10,11,.92) calc(var(--chm-m) * .45), rgba(10,10,11,.55) calc(var(--chm-m) * .8), rgba(10,10,11,0) calc(var(--chm-m) * 1.5)),
    linear-gradient(to left,  var(--chm-bg) 0, rgba(10,10,11,.92) calc(var(--chm-m) * .45), rgba(10,10,11,.55) calc(var(--chm-m) * .8), rgba(10,10,11,0) calc(var(--chm-m) * 1.5)),
    linear-gradient(to bottom, rgba(10,10,11,.75) 0, rgba(10,10,11,0) 56px),
    linear-gradient(to top, rgba(10,10,11,.75) 0, rgba(10,10,11,0) 56px),
    radial-gradient(110% 100% at 50% 50%, rgba(10,10,11,0) 55%, rgba(10,10,11,.55) 100%);
}
/* 1.1.0 · Esfera flotante: sin bandas laterales rectas (el desvanecimiento lo hace la esfera),
   solo un fundido suave arriba/abajo y una viñeta elíptica */
.chm.is-sphere .chm-stage::after {
  background:
    linear-gradient(to bottom, rgba(10,10,11,.6) 0, rgba(10,10,11,0) 64px),
    linear-gradient(to top, rgba(10,10,11,.6) 0, rgba(10,10,11,0) 64px),
    radial-gradient(ellipse 58% 62% at 50% 50%, rgba(10,10,11,0) 70%, rgba(10,10,11,.4) 100%);
}
.chm-layer { position: absolute; inset: 0; z-index: 0; isolation: isolate; }

/* Radio de 8 px en pantalla: el JS lo compensa según la escala de cada foto,
   así se ve igual en el centro, en los bordes y con zoom. */
.chm-tile {
  position: absolute; left: 0; top: 0;
  border-radius: 8px; overflow: hidden;
  transform-origin: 50% 50%;
  will-change: transform, opacity;
  backface-visibility: hidden;
}
.chm-tile.is-leaving { transition: opacity .45s ease; opacity: 0 !important; pointer-events: none; }
.chm-tile img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transition: opacity .5s ease, filter .35s ease;
  pointer-events: none; -webkit-user-drag: none;
}
.chm-tile.is-in img { opacity: 1; }
/* 1.1.1 · Elementor y Blocksy aplican "img { height: auto }" con la misma prioridad: la foto debe
   llenar siempre su recuadro (recorte "cover"), también cuando el muro alarga una foto para igualar columnas */
.chm .chm-tile img { width: 100%; height: 100%; max-width: none; object-fit: cover; }
@media (hover: hover) and (pointer: fine) {
  .chm-tile img { filter: brightness(.88); }
  .chm-tile:hover img { filter: none; }
}

/* ---------- Barra de controles ---------- */
/* Barra flotante compacta: solo filtros + Shuffle */
.chm-bar {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 8;
  display: flex; gap: 2px; align-items: center;
  padding: 3px; border-radius: 999px;
  background: rgba(10,10,11,.72);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 1px solid rgba(242,241,237,.08);
  max-width: calc(100% - 24px);
}
.chm-filters {
  display: flex; gap: 2px; align-items: center; min-width: 0;
  overflow-x: auto; scrollbar-width: none; touch-action: pan-x; border-radius: 999px;
}
.chm-filters::-webkit-scrollbar { display: none; }
.chm-bar > .chm-pill, .chm-bar > .chm-sep { flex: 0 0 auto; }
.chm-pill {
  flex: 0 0 auto; min-height: 30px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 999px; background: transparent; color: rgba(242,241,237,.78);
  font: 500 10px/1 var(--chm-mono); letter-spacing: .14em; text-transform: uppercase;
  white-space: nowrap; cursor: pointer; transition: background-color .25s, color .25s;
}
.chm-pill:hover { color: var(--chm-ink); background: rgba(242,241,237,.07); }
.chm-pill:focus-visible { outline: 2px solid var(--chm-blue-l); outline-offset: 1px; }
.chm-pill[aria-pressed="true"] { background: var(--chm-ink); color: var(--chm-bg); }
.chm-pill small { font-size: 9px; opacity: .5; letter-spacing: .04em; }
.chm-pill.chm-ico { width: 30px; padding: 0; }
.chm-pill svg { width: 15px; height: 15px; flex: 0 0 auto; }
.chm-shuffle svg { transform: rotate(var(--chm-rot, 0deg)); transition: transform .8s cubic-bezier(.2,.8,.2,1); }
.chm-shuffle:hover { color: var(--chm-blue-l); background: rgba(35,66,224,.14); }
.chm-sep { flex: 0 0 auto; width: 1px; height: 14px; background: rgba(242,241,237,.14); margin: 0 3px; }
.chm.is-coarse .chm-pill { min-height: 40px; padding: 0 13px; }
.chm.is-coarse .chm-pill.chm-ico { width: 40px; padding: 0; }
@media (max-width: 420px) {
  .chm-pill small { display: none; }
  .chm.is-coarse .chm-pill { padding: 0 10px; letter-spacing: .1em; }
}

/* ---------- Cursor propio (solo ratón) ---------- */
.chm-cursor { position: absolute; left: 0; top: 0; z-index: 7; pointer-events: none; opacity: 0; transition: opacity .2s; }
.chm.is-fine .chm-stage { cursor: none; }
.chm.is-fine.is-hover .chm-cursor { opacity: 1; }
.chm-ring {
  position: absolute; width: 78px; height: 78px; margin: -39px 0 0 -39px;
  border: 1px solid rgba(242,241,237,.5); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font: 500 10px/1 var(--chm-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--chm-ink);
  transition: transform .3s cubic-bezier(.2,.8,.2,1), background-color .3s, border-color .3s;
}
.chm-ring::before {
  content: ""; position: absolute; top: 9px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px;
  border-radius: 50%; background: var(--chm-blue);
}
.chm.is-dragging .chm-ring { transform: scale(.72); }
.chm.is-view .chm-ring { background: rgba(10,10,11,.4); border-color: rgba(242,241,237,.9); }
.chm-cap {
  position: absolute; left: 50px; top: -6px; white-space: nowrap;
  font: 11px/1.4 var(--chm-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--chm-ink);
  text-shadow: 0 1px 10px rgba(0,0,0,.8); opacity: 0; transition: opacity .25s;
}
.chm.is-view:not(.is-dragging) .chm-cap { opacity: 1; }

/* ---------- Aviso ---------- */
.chm-hint {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 6; margin: 0;
  font: 11px/1 var(--chm-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--chm-mute);
  white-space: nowrap; pointer-events: none; transition: opacity .6s;
}
.chm.is-touched .chm-hint { opacity: 0; }
/* ---------- Táctil: el muro se mueve directamente dentro de la página ----------
   Dentro del muro: arrastre libre (touch-action: none). Fuera: la página se desplaza.
   La altura deja siempre una franja libre arriba/abajo para poder seguir desplazando la página. */
.chm.is-coarse .chm-stage {
  touch-action: none;
  overscroll-behavior: contain;
  height: var(--chm-h-m, 66svh);
  cursor: default;
}

/* ---------- Vista lista ---------- */
.chm-list { display: none; }
.chm.is-list .chm-stage { display: none; }
.chm.is-list .chm-list { display: block; columns: 4 240px; column-gap: 18px; padding: 24px 40px 48px; }
.chm.is-list .chm-bar { position: sticky; top: 12px; left: auto; transform: none; margin: 12px auto 0; width: max-content; }
.chm.is-coarse.is-list .chm-list { columns: 2; column-gap: 10px; padding: 16px 12px 32px; }
.chm-li {
  display: block; width: 100%; margin: 0 0 18px; padding: 0; border: 0; border-radius: 2px; overflow: hidden;
  background: var(--c, #1a1a1c); aspect-ratio: var(--ar); break-inside: avoid; cursor: zoom-in;
}
.chm.is-coarse .chm-li { margin-bottom: 10px; }
.chm-li img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chm-li:focus-visible { outline: 2px solid var(--chm-blue-l); outline-offset: 2px; }

/* ---------- Visor (PhotoSwipe) ---------- */
.pswp {
  --pswp-bg: #0A0A0B;
  --pswp-placeholder-bg: #141416;
  --pswp-icon-color: #F2F1ED;
  --pswp-icon-color-secondary: #0A0A0B;
  --pswp-icon-stroke-color: #0A0A0B;
  --pswp-icon-stroke-width: 1px;
}
.pswp__counter { font: 12px/1 'DM Mono', monospace; letter-spacing: .14em; opacity: .75; margin-top: 18px; }
.chm-pcap {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; text-align: center; pointer-events: none;
  padding: 16px 20px calc(18px + env(safe-area-inset-bottom, 0px));
  font: 11px/1.5 'DM Mono', monospace; letter-spacing: .1em; text-transform: uppercase; color: #C9C9CE;
}
.chm-pcap:empty { display: none; }
.chm-pcap::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: #2342E0; margin-right: 10px; vertical-align: 1px;
}
/* 1.5.0 · Crédito de autoría: discreto, abajo a la derecha y fuera de la imagen (en la franja inferior del visor). */
.chm-pcred {
  position: absolute; z-index: 3; right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(18px + env(safe-area-inset-bottom, 0px)); max-width: calc(100% - 32px); text-align: right;
  font: 400 11px/1.5 'DM Mono', monospace; letter-spacing: .08em; color: #858585;
}
.chm-pcred[hidden] { display: none; }
.pswp--zoomed-in .chm-pcred { visibility: hidden; }
.pswp .chm-pcred a, .pswp .chm-pcred a:visited {
  color: #A0A0A0; text-decoration: none; pointer-events: auto; border-bottom: 1px solid #292929; padding-bottom: 1px;
}
.pswp .chm-pcred a:hover { color: #C9C9CE; border-bottom-color: #858585; }
.chm-pcred a:focus-visible { outline: 1px solid #A0A0A0 !important; outline-offset: 3px; border-radius: 1px; }
@media (max-width: 767px) { .chm-pcred.has-cap { bottom: calc(44px + env(safe-area-inset-bottom, 0px)); } }

/* ---------- Respaldo sin JavaScript ---------- */
.chm-muro { position: relative; background: #0A0A0B; }
.chm-muro script.chm-data { display: none; }
.chm-noscript { list-style: none; margin: 0; padding: 24px; columns: 4 220px; column-gap: 16px; }
.chm-noscript li { break-inside: avoid; margin: 0 0 16px; }
.chm-noscript img { width: 100%; height: auto; display: block; border-radius: 8px; }

@media (prefers-reduced-motion: reduce) {
  .chm-tile img, .chm-ring, .chm-hint, .chm-pill svg { transition: none !important; }
}
