/*
 * Lienzo de diapositiva, formas, texto, capas de selección/caret y miniaturas.
 *
 * La diapositiva se construye siempre a su tamaño natural (1280 × 720 px para
 * 16:9 a 96 dpi) y el zoom se aplica al contenedor con `transform: scale()`.
 * Así el texto se mide una sola vez a zoom 1 y el salto de línea no cambia al
 * acercar o alejar, como en PowerPoint.
 */

/* ---------- Contenedor de la diapositiva ---------- */

.slide-wrap {
    position: relative;
    margin: 24px;
    flex: 0 0 auto;
}

.slide-scaler {
    transform-origin: top left;
}

.slide {
    position: relative;
    overflow: hidden;
    background: var(--ppt-slide-bg);
    box-shadow: var(--ppt-slide-shadow);
    cursor: default;
}

.thumb__frame .slide { box-shadow: none; }

.slide__bg {
    position: absolute;
    inset: 0;
}

/* ---------- Formas ---------- */

.shape {
    position: absolute;
    box-sizing: border-box;
}

.shape__geom {
    position: absolute;
    inset: 0;
    overflow: visible;
    pointer-events: none;
}

.shape__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
    user-select: none;
}

.shape__text {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.shape.is-editing .shape__text { pointer-events: auto; }

/* Prompt de marcador de posición vacío ("Haga clic para agregar título") */
.shape__prompt {
    position: absolute;
    inset: 0;
    color: var(--ppt-text-muted);
    pointer-events: none;
    user-select: none;
}

.shape__text-block {
    position: absolute;
}

/*
 * Cada línea se ancla por su línea de base: con `font-size` y `line-height` a 0
 * el "strut" del contenedor desaparece y todos los runs —de cualquier tamaño—
 * se alinean exactamente sobre el `top` del elemento, que es la base calculada
 * por el divisor de líneas. Sin esto, mezclar tamaños en una línea desalinearía
 * el texto respecto de la medición.
 */
.line {
    position: absolute;
    font-size: 0;
    line-height: 0;
    white-space: pre;
}

.line__marker {
    position: absolute;
    line-height: normal;
    vertical-align: baseline;
    white-space: pre;
}

.run {
    line-height: normal;
    vertical-align: baseline;
    white-space: pre;
}

.run--spell-error {
    text-decoration: underline wavy var(--ppt-spell-error);
    text-decoration-skip-ink: none;
}

/* ---------- Capas de interacción ---------- */

.layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.layer-selection .sel-rect {
    position: absolute;
    background: var(--ppt-text-selection);
}

.layer-caret .caret {
    position: absolute;
    width: 1.5px;
    background: var(--ppt-text);
}

.layer-caret .caret.is-blinking {
    animation: caret-blink 1.06s steps(1) infinite;
}

@keyframes caret-blink {
    0%, 50% { opacity: 1; }
    50.01%, 100% { opacity: 0; }
}

/* Marco y tiradores de la forma seleccionada */
.sel-frame {
    position: absolute;
    outline: 1px solid var(--ppt-shape-selection);
    pointer-events: none;
}

.sel-frame--editing {
    outline-style: dashed;
}

.handle {
    position: absolute;
    width: 8px;
    height: 8px;
    margin: -4px 0 0 -4px;
    background: #FFFFFF;
    border: 1px solid var(--ppt-shape-selection);
    border-radius: 50%;
    pointer-events: auto;
}

.handle--nw, .handle--se { cursor: nwse-resize; }
.handle--ne, .handle--sw { cursor: nesw-resize; }
.handle--n, .handle--s { cursor: ns-resize; }
.handle--w, .handle--e { cursor: ew-resize; }

.handle--rot {
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    cursor: grab;
}

/* Marquesina de selección múltiple */
.marquee {
    position: absolute;
    border: 1px dashed var(--ppt-shape-selection);
    background: rgba(196, 62, 28, 0.08);
    pointer-events: none;
}

/* ---------- Guías y cuadrícula ---------- */

.layer-grid {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.5;
}

.guide {
    position: absolute;
    background: #E36C09;
    pointer-events: auto;
}

.guide--v { top: 0; bottom: 0; width: 1px; margin-left: -0.5px; cursor: ew-resize; }
.guide--h { left: 0; right: 0; height: 1px; margin-top: -0.5px; cursor: ns-resize; }

/* Guías inteligentes de alineación (aparecen al arrastrar) */
.smart-guide {
    position: absolute;
    background: var(--ppt-shape-selection);
    pointer-events: none;
}

.smart-guide--v { width: 1px; }
.smart-guide--h { height: 1px; }

/* ---------- Panel de miniaturas ---------- */

.thumb {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 3px 2px;
    cursor: pointer;
}

.thumb__num {
    width: 16px;
    padding-top: 2px;
    color: var(--ppt-text-muted);
    font-size: var(--ppt-font-size-ui-sm);
    text-align: right;
    user-select: none;
}

.thumb__frame {
    position: relative;
    flex: 1;
    background: var(--ppt-slide-bg);
    border: 1px solid var(--ppt-border);
    overflow: hidden;
}

.thumb.is-active .thumb__frame {
    border-color: var(--ppt-accent);
    box-shadow: 0 0 0 1px var(--ppt-accent);
}

.thumb.is-selected .thumb__frame {
    border-color: var(--ppt-accent);
}

.thumb.is-hidden .thumb__frame { opacity: 0.45; }

.thumb__canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Marca de diapositiva oculta */
.thumb__hidden-mark {
    position: absolute;
    left: 2px;
    top: 2px;
    color: var(--ppt-text-muted);
    font-size: 10px;
}

/* Separador de arrastre para reordenar */
.thumb__drop-line {
    height: 2px;
    margin: 0 2px;
    background: var(--ppt-accent);
}

/* ---------- Entrada oculta para IME ---------- */

.ime-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    border: 0;
    outline: none;
    resize: none;
    overflow: hidden;
    background: transparent;
    color: transparent;
    caret-color: transparent;
    z-index: 5;
}
