/* ============================================================
   css/novel.css – Visual Novel Engine Styles
   ============================================================ */

/* ── Novel Inline Section ── */
/* No fixed/absolute: renders in the page document flow */
#novel-overlay {
    display: block;
    padding: 0 24px 56px;
    opacity: 0;
    transition: opacity 1.2s cubic-bezier(0.2, 0.8, 0.2, 1), transform 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    transform: translateY(24px);
    pointer-events: none;
}

#novel-overlay.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ── Container Layout ── */
.novel-container {
    display: flex;
    align-items: center;
    /* Alineación a media altura */
    justify-content: center;
    gap: 24px;
    max-width: 1000px;
    margin: 0 auto;
    position: relative;
}

/* ── Guanchito Character ── */
.guanchito-character {
    width: 25vw;
    min-width: 180px;
    max-width: 280px;
    object-fit: contain;
    filter: drop-shadow(0 10px 25px rgba(0, 0, 0, 0.5));
    animation: floatCharacter 4s ease-in-out infinite;
    z-index: 2;
    /* Ajuste para que se apoye bien en el borde inferior */
    margin-bottom: -10px;
}

@keyframes floatCharacter {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-12px);
    }
}

/* ── Interactive Area (Right column) ── */
.novel-interact-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 0px;
    /* Sin margen para que quede centrado real */
}

/* ── Dialog Box (Bocadillo Nube) ── */
.novel-dialog {
    background: var(--dialog-bg);
    border: 2px solid rgba(212, 168, 67, .5);
    border-radius: 40px;
    /* Forma de nube/óvalo */
    padding: 24px 32px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
    position: relative;
    z-index: 1;
    text-align: center;
}

/* Pico del bocadillo (estilo nube apuntando a Guanchito a la izquierda) */
.novel-dialog::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
    left: -12px;
    width: 24px;
    height: 24px;
    background: var(--dialog-bg);
    border-left: 2px solid rgba(212, 168, 67, .5);
    border-bottom: 2px solid rgba(212, 168, 67, .5);
    border-bottom-left-radius: 5px;
    z-index: -1;
}

.novel-dialog::before {
    display: none;
    /* Eliminar el pseudo anterior */
}


/* Corner shimmer */
.novel-dialog::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% {
        opacity: 0;
        transform: scaleX(0);
        transform-origin: left;
    }

    50% {
        opacity: 1;
        transform: scaleX(1);
        transform-origin: left;
    }

    100% {
        opacity: 0;
        transform: scaleX(0);
        transform-origin: right;
    }
}

/* (Speaker area removed for new layout) */

/* ── Text Area ── */
#novel-text {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text);
    min-height: 3.5em;
    margin-bottom: 20px;
}

/* Cursor blink while typing */
#novel-text.typing::after {
    content: '▋';
    color: var(--gold);
    animation: blink .8s step-end infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: 0
    }
}

/* ── Choices (Grid 2x2) ── */
.novel-choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.novel-choice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    color: var(--text);
    font-size: .90rem;
    font-weight: 500;
    font-weight: 500;
    animation: fastFadeUp .3s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

/* Si es el último elemento y es un número impar, que ocupe las dos columnas */
.novel-choice:last-child:nth-child(odd) {
    grid-column: span 2;
}

.novel-choice:nth-child(1) {
    animation-delay: .03s;
}

.novel-choice:nth-child(2) {
    animation-delay: .06s;
}

.novel-choice:nth-child(3) {
    animation-delay: .09s;
}

.novel-choice:nth-child(4) {
    animation-delay: .12s;
}

.novel-choice:nth-child(5) {
    animation-delay: .15s;
}

@keyframes fastFadeUp {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.novel-choice:hover {
    background: rgba(var(--navy-light), 0.5);
    border-color: rgba(212, 168, 67, .4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
}


.novel-choice-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* ── Back Button (shown inside sections) ── */
.novel-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-dim);
    font-size: .88rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 50px;
    border: 1px solid var(--card-border);
    cursor: pointer;
    transition: var(--transition);
    background: none;
    margin-top: 48px;
}

.novel-back-btn:hover {
    color: var(--gold);
    border-color: rgba(212, 168, 67, .3);
}

/* ── Page Transition Wrapper ── */
#page-content {
    transition: opacity .4s var(--ease), transform .4s var(--ease);
}

#page-content.page-exit {
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
}

#page-content.page-enter {
    animation: fadeUp .5s var(--ease) both;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    #novel-overlay {
        padding: 0 12px 24px;
    }

    .novel-container {
        gap: 12px;
        /* Permitir que el contenedor reduzca su tamaño sin desbordar */
        width: 100%;
    }

    .guanchito-character {
        /* Mantiene la relación de tamaño original (~25vw) sin encogerse en exceso */
        width: 25vw;
        min-width: 110px;
        max-width: 180px;
        margin-bottom: -10px;
    }

    .novel-dialog {
        padding: 16px 14px 12px;
        border-radius: 20px;
    }

    #novel-text {
        font-size: clamp(0.75rem, 3.5vw, 0.95rem);
        margin-bottom: 12px;
        min-height: 2.5em;
    }

    .novel-choices {
        gap: 6px;
    }

    .novel-choice {
        /* Reducir radicalmente paddings y tipografía para que todo encaje en línea */
        padding: 6px 4px;
        font-size: clamp(0.55rem, 2vw, 0.75rem);
        gap: 3px;
        line-height: 1.1;
    }

    .novel-choice-key {
        min-width: 18px;
        height: 18px;
        font-size: 0.6rem;
        border-radius: 4px;
    }

    .novel-choice-icon {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {

    /* Forzar mayor compactación en móviles muy estrechos sin envolver ni mover */
    .novel-container {
        gap: 8px;
    }

    .novel-dialog {
        padding: 12px 10px 10px;
    }

    .novel-choice {
        padding: 5px 3px;
        font-size: 0.55rem;
    }
}