/* =============================================================================
   Etapa 2 · stickers, textos y buscador de Pexels
   ============================================================================= */

/* ---- Elementos libres sobre la página ---------------------------------- */
.elemento { position: absolute; transform-origin: center center; }
.elemento-sticker img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.interactiva .elemento { cursor: move; touch-action: none; }
.interactiva .elemento:hover:not(.seleccionado) { outline: 1.5px dashed color-mix(in srgb, var(--brand-accent) 70%, transparent); outline-offset: 2px; }
.interactiva .elemento.seleccionado { outline: 1.5px solid var(--brand-accent); outline-offset: 3px; }
.interactiva .elemento.editando { cursor: text; }

/* Texto */
.texto-caja { width: 100%; }
.texto-contenido { display: inline-block; max-width: 100%; white-space: pre-wrap; overflow-wrap: break-word; line-height: 1.18; vertical-align: top; }
.texto-contenido[contenteditable="true"] { outline: none; caret-color: var(--brand-accent); min-width: 1em; }
.texto-contenido.fondo-globo {
    position: relative; background: var(--fondo, #fff); padding: .9cqw 1.6cqw; border-radius: 1.8cqw;
    box-shadow: 0 .25cqw .8cqw rgba(0,0,0,.18);
}
.texto-contenido.fondo-globo::after {
    content: ''; position: absolute; left: 22%; bottom: -1.3cqw;
    border-style: solid; border-width: 1.4cqw 1.2cqw 0 0; border-color: var(--fondo, #fff) transparent transparent transparent;
}
.texto-contenido.fondo-etiqueta { background: var(--fondo, #ff5c8a); padding: .45cqw 1.8cqw; border-radius: 999px; }

/* Manijas */
.manijas { position: absolute; inset: -3px; pointer-events: none; }
.manija { position: absolute; width: 12px; height: 12px; background: #fff; border: 1.5px solid var(--brand-accent); border-radius: 3px; pointer-events: auto; box-shadow: var(--elev-1); }
.manija.nw { left: -7px; top: -7px; cursor: nwse-resize; }
.manija.ne { right: -7px; top: -7px; cursor: nesw-resize; }
.manija.sw { left: -7px; bottom: -7px; cursor: nesw-resize; }
.manija.se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.manija.lado { width: 8px; height: 22px; border-radius: 4px; top: 50%; margin-top: -11px; cursor: ew-resize; }
.manija.lado.w { left: -5px; }
.manija.lado.e { right: -5px; }
.manija-giro {
    position: absolute; left: 50%; top: -38px; width: 26px; height: 26px; margin-left: -13px; border-radius: 50%;
    background: #fff; border: 1.5px solid var(--brand-accent); color: var(--brand-accent); pointer-events: auto; cursor: grab;
    display: flex; align-items: center; justify-content: center; box-shadow: var(--elev-2);
}
.manija-giro .ms { font-size: 16px; }
.manija-giro::after { content: ''; position: absolute; top: 100%; left: 50%; width: 1.5px; height: 12px; background: var(--brand-accent); }
.editando .manijas { display: none; }
/* Con el dedo: manijas más grandes, con un área de toque más amplia que el dibujo */
@media (pointer: coarse) {
    .manija { width: 18px; height: 18px; border-radius: 5px; }
    .manija.nw { left: -10px; top: -10px; } .manija.ne { right: -10px; top: -10px; }
    .manija.sw { left: -10px; bottom: -10px; } .manija.se { right: -10px; bottom: -10px; }
    .manija::before { content: ''; position: absolute; inset: -10px; }
    .manija.lado { width: 12px; height: 30px; margin-top: -15px; }
    .manija-giro { width: 34px; height: 34px; margin-left: -17px; top: -48px; }
}

/* ---- Filtros: la foto elegida con cada filtro ------------------------------ */
.tira-filtros {
    position: absolute; left: 0; right: 0; top: 0; z-index: 7; display: flex; gap: 10px; overflow-x: auto; scrollbar-width: thin;
    padding: 10px 12px 12px; background: var(--bg-1); border-bottom: 1px solid var(--border-1); box-shadow: var(--elev-2);
    animation: aparecer var(--motion-duration-short) var(--motion-easing-decelerate);
}
.muestra-filtro { flex-shrink: 0; border: none; background: none; padding: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px; width: 76px; }
.muestra-filtro-foto { display: block; width: 76px; height: 76px; border-radius: var(--radius-sm); overflow: hidden; box-shadow: 0 0 0 1px var(--border-1); background: var(--bg-3); }
.muestra-filtro-foto img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.muestra-filtro small { font-size: 11px; line-height: 14px; color: var(--fg-2); text-align: center; white-space: nowrap; }
.muestra-filtro:hover .muestra-filtro-foto { box-shadow: 0 0 0 2px var(--border-2); }
.muestra-filtro.activo .muestra-filtro-foto { box-shadow: 0 0 0 3px var(--brand-accent); }
.muestra-filtro.activo small { color: var(--brand-accent); font-weight: 600; }
@media (min-width: 861px) { .tira-filtros { padding: 12px 16px 14px; gap: 12px; } .muestra-filtro, .muestra-filtro-foto { width: 84px; } .muestra-filtro-foto { height: 84px; } }

.guia-centro { position: absolute; pointer-events: none; z-index: 7; background: #ff2d87; }
.guia-centro.v { left: 50%; top: 0; bottom: 0; width: 1px; }
.guia-centro.h { top: 50%; left: 0; right: 0; height: 1px; }

/* ---- Panel de stickers ----------------------------------------------------- */
.grilla-stickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.sticker-opcion {
    border: 1px solid var(--border-1); border-radius: var(--radius-md); background: var(--bg-2); padding: 10px 6px 6px; cursor: grab;
    display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 96px; justify-content: space-between;
}
.sticker-opcion img { width: 100%; height: 58px; object-fit: contain; pointer-events: none; }
.sticker-opcion span { font-size: 10.5px; line-height: 13px; color: var(--fg-2); text-align: center; }
.sticker-opcion:hover { border-color: var(--brand-accent); background: var(--brand-accent-soft); }
.sticker-opcion:active { cursor: grabbing; }
.grilla-stickers.sugeridos .sticker-opcion { background: var(--bg-1); }
.panel-cuerpo .fila-chips .chip { height: 30px; font-size: 12px; padding: 0 10px; }

/* ---- Panel de texto -------------------------------------------------------- */
.lista-estilos-texto { display: flex; flex-direction: column; gap: 8px; }
.estilo-texto {
    border: 1px solid var(--border-1); border-radius: var(--radius-md); background: var(--bg-1); padding: 14px 16px 10px; cursor: pointer;
    display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
}
.estilo-texto:hover { border-color: var(--brand-accent); background: var(--brand-accent-soft); }
.estilo-texto small { font-size: 11px; color: var(--fg-3); }
.muestra-texto { color: var(--fg-1); line-height: 1.2; }
.muestra-texto.fondo-globo { background: #fff; color: #141414; padding: 6px 12px; border-radius: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.2); position: relative; margin-bottom: 6px; }
.muestra-texto.fondo-globo::after { content: ''; position: absolute; left: 18px; bottom: -7px; border-style: solid; border-width: 8px 7px 0 0; border-color: #fff transparent transparent transparent; }
.muestra-texto.fondo-etiqueta { background: var(--fondo); color: #fff; padding: 4px 14px; border-radius: 999px; }

/* ---- Buscador de Pexels ---------------------------------------------------- */
.dialogo-pexels { width: min(1120px, 100%); height: 94dvh; }
@media (min-width: 861px) { .dialogo-pexels { height: min(820px, calc(100vh - 48px)); } }
.dialogo-pexels .dialogo-cabecera { padding-bottom: 12px; border-bottom: 1px solid var(--border-1); }
.cuerpo-pexels { position: relative; flex: 1; min-height: 0; display: flex; }
.iframe-pexels { border: 0; width: 100%; height: 100%; flex: 1; }
.cargando-pexels { position: absolute; inset: 0; background: rgba(255,255,255,.85); display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 500; }
.cargando-pexels .ms { animation: girar 1s linear infinite; color: var(--brand-accent); }
@keyframes girar { to { transform: rotate(360deg); } }
.pexels-sin-servidor { margin: auto; max-width: 460px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 32px; color: var(--fg-2); }
.pexels-sin-servidor > .ms { font-size: 40px; color: var(--brand-accent); }
.pexels-sin-servidor b { font-size: 18px; color: var(--fg-1); }
.pexels-sin-servidor code { font-family: var(--font-mono); font-size: 13px; background: var(--bg-3); padding: 1px 6px; border-radius: 4px; }
