/* Librito: a paper booklet for the eguahe.com landing. Without JavaScript the pages sit in a row that slides;
   librito.js turns the box into a book (.librito--listo). The paper never changes with the theme, only the shadow. */
.librito {
    --librito-papel: #f3eedb;
    --librito-tinta: var(--tinta, #2b2226);
    --librito-boton: rgba(255, 255, 255, 0.6);
    --librito-borde: rgba(43, 34, 38, 0.2);
    --librito-sombra: 0 24px 34px -20px rgba(64, 40, 18, 0.55), 0 3px 8px -3px rgba(64, 40, 18, 0.22);
    position: relative;
    color: var(--librito-tinta);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-tema="claro"]) .librito {
        --librito-tinta: var(--tinta, #f3ece6);
        --librito-boton: rgba(255, 255, 255, 0.07);
        --librito-borde: rgba(243, 236, 230, 0.26);
        --librito-sombra: 0 30px 46px -18px rgba(0, 0, 0, 0.9), 0 6px 16px -4px rgba(0, 0, 0, 0.65);
    }
}

:root[data-tema="oscuro"] .librito {
    --librito-tinta: var(--tinta, #f3ece6);
    --librito-boton: rgba(255, 255, 255, 0.07);
    --librito-borde: rgba(243, 236, 230, 0.26);
    --librito-sombra: 0 30px 46px -18px rgba(0, 0, 0, 0.9), 0 6px 16px -4px rgba(0, 0, 0, 0.65);
}

/* Without JavaScript: every page, readable, in a row that slides. */
.librito:not(.librito--listo) {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 6px 4px 18px;
}

.librito:not(.librito--listo) img {
    flex: 0 0 auto;
    width: 78%;
    max-width: 340px;
    height: auto;
    scroll-snap-align: center;
    border-radius: 2px;
    box-shadow: var(--librito-sombra);
}

/* The book. */
.librito--listo {
    outline: none;
}

.librito--listo:focus-visible .librito__marco {
    outline: 2px solid currentColor;
    outline-offset: 10px;
    border-radius: 3px;
}

.librito__oculto {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.librito__marco {
    position: relative;
    width: 100%;
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.librito__marco--coger {
    cursor: grab;
}

.librito__marco--arrastra {
    cursor: grabbing;
}

.librito__mesa,
.librito__escena {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.librito__mesa {
    transition: opacity 0.15s ease;
}

.librito__mesa--fuera {
    opacity: 0;
}

.librito__escena {
    perspective-origin: 50% 50%;
}

.librito__pagina {
    position: absolute;
    top: 0;
    z-index: 0;
    width: 50%;
    height: 100%;
    overflow: hidden;
    background: var(--librito-papel) center / 100% 100% no-repeat;
}

.librito__pagina--izq {
    left: 0;
    border-radius: 3px 0 0 3px;
}

.librito__pagina--der {
    left: 50%;
    border-radius: 0 3px 3px 0;
}

/* One page at a time (--librito-hojas: 1, read by librito.js): the spine is the left edge of the frame. The table is
   twice as wide and starts one page to the left; what passes the spine is cut away, as if it went behind the book. */
.librito--una .librito__mesa {
    left: -100%;
    width: 200%;
    clip-path: inset(-25% -25% -25% 50%);
}

/* The valley of the spine. librito.js draws the same shade on a lying sheet, so nothing jumps when it lands. */
.librito__pagina::before {
    content: "";
    position: absolute;
    top: 0;
    width: 9%;
    height: 100%;
    z-index: 1;
}

.librito__pagina--izq::before {
    right: 0;
    background: linear-gradient(to left, rgba(60, 40, 20, 0.16), rgba(60, 40, 20, 0));
}

.librito__pagina--der::before {
    left: 0;
    background: linear-gradient(to right, rgba(60, 40, 20, 0.16), rgba(60, 40, 20, 0));
}

/* Shadow that the turning sheet throws on the page below. */
.librito__sombra {
    position: absolute;
    top: 0;
    width: 400%;
    height: 100%;
    opacity: 0;
    z-index: 2;
    will-change: transform, opacity;
}

.librito__pagina--der .librito__sombra {
    right: 100%;
    transform-origin: 100% 0;
    background: linear-gradient(to right, rgba(36, 24, 12, 0), #24180c 25%, #24180c 75%, rgba(36, 24, 12, 0.3) 88%, rgba(36, 24, 12, 0));
}

.librito__pagina--izq .librito__sombra {
    left: 100%;
    transform-origin: 0 0;
    background: linear-gradient(to left, rgba(36, 24, 12, 0), #24180c 25%, #24180c 75%, rgba(36, 24, 12, 0.3) 88%, rgba(36, 24, 12, 0));
}

/* The turning sheet: bands that share an edge, each with its two faces. */
.librito__hoja {
    position: absolute;
    z-index: 1;
    top: 0;
    left: 50%;
    width: 0;
    height: 0;
    transform-style: preserve-3d;
    visibility: hidden;
}

.librito__hoja--viva {
    visibility: visible;
}

.librito__tira {
    position: absolute;
    top: 0;
    left: 0;
    transform-style: preserve-3d;
    transform-origin: 0 0;
    will-change: transform;
}

.librito__cara {
    position: absolute;
    overflow: hidden;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    /* No colour under a printed page: it would show as a light seam where two bands meet (Firefox). */
    background: transparent no-repeat;
}

.librito__cara--dorso {
    transform: rotateY(180deg);
}

.librito__luz {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Blank paper: the same cream as the printed pages, with the slow mottling of real paper. On a turning sheet the
   layers are placed in sheet coordinates by librito.js, so the bands line up. */
.librito__papel {
    background:
        radial-gradient(ellipse 70% 45% at 28% 22%, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0) 70%) 0 0 / 100% 100% no-repeat,
        radial-gradient(ellipse 55% 60% at 78% 68%, rgba(150, 118, 76, 0.06), rgba(150, 118, 76, 0) 70%) 0 0 / 100% 100% no-repeat,
        radial-gradient(ellipse 40% 30% at 35% 85%, rgba(150, 118, 76, 0.045), rgba(150, 118, 76, 0) 70%) 0 0 / 100% 100% no-repeat,
        var(--librito-papel);
}

/* Controls. */
.librito__mandos {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    margin-top: 30px;
}

.librito__boton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--librito-borde);
    border-radius: 50%;
    background: var(--librito-boton);
    color: inherit;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.librito__boton:hover {
    transform: translateY(-1px);
}

.librito__boton:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.librito__boton[aria-disabled="true"] {
    opacity: 0.32;
    cursor: default;
    transform: none;
}

.librito__boton svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.librito__boton--pausar {
    width: 36px;
    height: 36px;
}

.librito__boton--pausar svg {
    width: 16px;
    height: 16px;
}

.librito__boton--pausar .librito__icono1,
.librito__boton--parado .librito__icono0 {
    display: none;
}

.librito__boton--parado .librito__icono1 {
    display: inline;
}

.librito--calma .librito__boton--pausar {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .librito__boton {
        transition: none;
    }
}
