/**
 * Interactive Story Watt — Reader CSS
 * Estilos del eReader y la ficha de historia.
 * Prefijo: .watt-* para evitar conflictos.
 */

/* ============== Reader layout ============== */
.watt-reader {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 32px;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

@media (max-width: 900px) {
    .watt-reader {
        grid-template-columns: 1fr;
    }
    .watt-historia-sidebar {
        order: 2;
        border-top: 1px solid #e6e6e6;
        border-left: none !important;
    }
}

/* ============== Ficha de historia (header) ============== */
.watt-historia-header {
    grid-column: 1 / -1;
    display: flex;
    gap: 32px;
    padding: 32px;
    background: linear-gradient(135deg, #fff 0%, #fafafa 100%);
    border-bottom: 1px solid #e6e6e6;
    flex-wrap: wrap;
}

.watt-historia-cover {
    flex: 0 0 240px;
    max-width: 240px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.15);
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 2/3;
}

.watt-historia-cover img,
.watt-historia-cover .watt-cover-placeholder {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.watt-historia-info {
    flex: 1;
    min-width: 280px;
}

.watt-historia-generos {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.watt-genero {
    background: #ff500a;
    color: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.watt-historia-title {
    font-size: 32px;
    font-weight: 800;
    margin: 0 0 8px;
    color: #1a1a1a;
    line-height: 1.2;
}

.watt-historia-autor {
    color: #666;
    margin: 0 0 12px;
    font-size: 15px;
}

.watt-historia-autor a {
    color: #ff500a;
}

.watt-historia-stats {
    color: #888;
    font-size: 14px;
    margin: 0 0 16px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.watt-historia-sinopsis {
    color: #444;
    font-size: 15px;
    line-height: 1.7;
    margin: 0 0 24px;
    padding: 16px;
    background: #fff;
    border-radius: 8px;
    border-left: 4px solid #ff500a;
}

.watt-historia-sinopsis p {
    margin: 0 0 12px;
}

.watt-historia-sinopsis p:last-child {
    margin-bottom: 0;
}

.watt-historia-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

/* ============== Botón Votar ============== */
.watt-voto-btn,
.watt-lib-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 2px solid #ff500a;
    color: #ff500a;
    padding: 10px 16px;
    border-radius: 22px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.15s;
    font-family: inherit;
}

.watt-voto-btn:hover,
.watt-lib-btn:hover {
    background: #ff500a;
    color: #fff;
}

.watt-voto-btn.is-voted,
.watt-lib-btn.is-in-list {
    background: #ff500a;
    color: #fff;
}

.watt-voto-icon {
    font-size: 16px;
}

.watt-voto-count {
    background: rgba(0,0,0,0.1);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 13px;
}

.watt-voto-btn.is-voted .watt-voto-count {
    background: rgba(255,255,255,0.2);
}

/* ============== Sidebar capítulos ============== */
.watt-historia-sidebar {
    background: #fafafa;
    border-right: 1px solid #e6e6e6;
    padding: 24px 20px;
    align-self: start;
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.watt-historia-sidebar h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    margin: 0 0 16px;
}

.watt-capitulo-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.watt-capitulo-item {
    border-bottom: 1px solid #f0f0f0;
}

.watt-capitulo-item a {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 10px 8px;
    color: #555;
    font-size: 14px;
    transition: all 0.15s;
    border-radius: 6px;
    position: relative;
}

.watt-capitulo-item a:hover {
    background: #fff;
    color: #1a1a1a;
}

.watt-capitulo-item.is-current a {
    background: #ff500a;
    color: #fff;
    font-weight: 600;
}

.watt-cap-num {
    font-size: 11px;
    opacity: 0.7;
    min-width: 22px;
    font-weight: 700;
}

.watt-cap-title {
    flex: 1;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.watt-cap-decision {
    color: #ff500a;
    font-weight: 700;
}

.watt-capitulo-item.is-current .watt-cap-decision {
    color: #fff;
}

/* ============== Capítulo (eReader real) ============== */
.watt-capitulo {
    padding: 40px 48px;
    max-width: 760px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 768px) {
    .watt-capitulo {
        padding: 24px 16px;
    }
}

.watt-capitulo-header {
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
    text-align: center;
}

.watt-capitulo-title {
    font-size: 28px;
    margin: 0 0 6px;
    color: #1a1a1a;
    line-height: 1.3;
    font-weight: 800;
}

.watt-capitulo-meta {
    color: #999;
    font-size: 13px;
    display: flex;
    justify-content: center;
    gap: 8px;
    align-items: center;
}

/* ============== Variables de tema ============== */
.watt-capitulo,
.watt-capitulo * {
    box-sizing: border-box;
}

.watt-capitulo-body {
    font-size: 18px;
    line-height: 1.85;
    color: #1a1a1a;
    font-family: 'Georgia', 'Times New Roman', serif;
    transition: font-family 0.2s, font-size 0.2s, color 0.2s, background 0.2s;
}

/* Temas */
.watt-app.watt-theme-light .watt-capitulo-body {
    color: #1a1a1a;
}
.watt-app.watt-theme-sepia .watt-capitulo-body {
    color: #3a2d1c;
}
.watt-app.watt-theme-dark .watt-capitulo-body {
    color: #e8e6e3;
}
.watt-app.watt-theme-amoled .watt-capitulo-body {
    color: #e8e8e8;
}

.watt-app.watt-theme-dark {
    background: #1a1c1f;
}
.watt-app.watt-theme-amoled {
    background: #000;
}

.watt-app.watt-theme-dark .watt-capitulo,
.watt-app.watt-theme-amoled .watt-capitulo {
    background: transparent;
}

.watt-app.watt-theme-dark .watt-capitulo-header,
.watt-app.watt-theme-amoled .watt-capitulo-header {
    border-bottom-color: #2e3136;
}

.watt-app.watt-theme-dark .watt-capitulo-meta,
.watt-app.watt-theme-amoled .watt-capitulo-meta {
    color: #888;
}

.watt-app.watt-font-sans .watt-capitulo-body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 16px;
}

.watt-app.watt-font-mono .watt-capitulo-body {
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 15px;
}

/* ============== Bloques de párrafo (con comentarios inline) ============== */
.watt-parrafo-block {
    position: relative;
    margin: 0 0 18px;
    padding-left: 38px;
    min-height: 24px;
}

.watt-parrafo-content p {
    margin: 0 0 16px;
}

.watt-parrafo-content h1,
.watt-parrafo-content h2,
.watt-parrafo-content h3 {
    margin: 24px 0 12px;
    line-height: 1.3;
}

.watt-parrafo-content img {
    max-width: 100%;
    border-radius: 6px;
    margin: 12px 0;
}

.watt-parrafo-content blockquote {
    border-left: 4px solid #ff500a;
    padding: 8px 16px;
    margin: 16px 0;
    color: inherit;
    font-style: italic;
    background: rgba(255, 80, 10, 0.05);
    border-radius: 0 6px 6px 0;
}

.watt-com-toggle {
    position: absolute;
    left: 0;
    top: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid #ddd;
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
    font-size: 13px;
    font-weight: 600;
    padding: 0;
    line-height: 1;
}

.watt-parrafo-block:hover .watt-com-toggle {
    opacity: 1;
}

.watt-com-toggle.has-comments {
    opacity: 1;
    background: #ff500a;
    color: #fff;
    border-color: #ff500a;
}

.watt-com-count {
    font-size: 13px;
    line-height: 1;
}

/* ============== Popover comentarios ============== */
.watt-com-popover {
    position: absolute;
    left: 38px;
    top: 30px;
    width: 360px;
    max-width: calc(100vw - 80px);
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 50;
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    color: #1a1a1a;
}

.watt-com-popover.is-open {
    display: block;
}

.watt-com-list {
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
}

.watt-comentario {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.watt-comentario:last-child {
    border-bottom: none;
}

.watt-comentario-avatar {
    border-radius: 50%;
    flex: 0 0 36px;
}

.watt-comentario-body {
    flex: 1;
    min-width: 0;
}

.watt-comentario-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-size: 12px;
    color: #999;
    margin-bottom: 4px;
}

.watt-comentario-author {
    font-weight: 700;
    color: #1a1a1a;
}

.watt-comentario-contenido {
    color: #1a1a1a;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.watt-empty-comentarios {
    color: #999;
    font-size: 14px;
    text-align: center;
    padding: 16px;
}

.watt-com-form textarea,
.watt-com-form input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    color: #1a1a1a;
    font-size: 14px;
    font-family: inherit;
    margin-bottom: 8px;
}

.watt-com-form textarea {
    min-height: 60px;
    resize: vertical;
}

.watt-com-form button {
    background: #ff500a;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
}

.watt-com-form button:hover {
    background: #e74400;
}

.watt-com-error {
    color: #d63638;
    font-size: 12px;
    margin-bottom: 8px;
}

/* ============== Decisiones ramificadas ============== */
.watt-capitulo-footer {
    margin-top: 60px;
    padding-top: 32px;
    border-top: 1px solid #f0f0f0;
}

.watt-app.watt-theme-dark .watt-capitulo-footer,
.watt-app.watt-theme-amoled .watt-capitulo-footer {
    border-top-color: #2e3136;
}

.watt-decision-panel {
    text-align: center;
    padding: 40px 24px;
    background: linear-gradient(135deg, #fff5f5 0%, #fff 100%);
    border-radius: 16px;
    border: 2px dashed #ff500a;
    margin: 0 auto;
    max-width: 600px;
}

.watt-app.watt-theme-dark .watt-decision-panel,
.watt-app.watt-theme-amoled .watt-decision-panel {
    background: rgba(255, 80, 10, 0.05);
}

.watt-decision-decoration {
    margin-bottom: 12px;
}

.watt-decision-icon {
    font-size: 32px;
    color: #ff500a;
    display: inline-block;
    animation: watt-pulse 2s infinite;
}

@keyframes watt-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.watt-decision-title {
    font-size: 22px;
    margin: 0 0 8px;
    color: #ff500a;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 800;
}

.watt-decision-sub {
    color: #888;
    font-size: 14px;
    margin: 0 0 24px;
}

.watt-opciones {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 480px;
    margin: 0 auto;
}

.watt-opcion-btn {
    display: block;
    padding: 16px 24px;
    background: #fff;
    border: 2px solid #ff500a;
    color: #1a1a1a;
    border-radius: 10px;
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.watt-opcion-btn:hover {
    background: #ff500a;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(255, 80, 10, 0.25);
}

.watt-opcion-btn:active {
    transform: translateY(0);
}

/* ============== Siguiente capítulo / fin ============== */
.watt-next-cap-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 32px;
    background: linear-gradient(135deg, #ff500a, #ff8a00);
    color: #fff !important;
    text-decoration: none;
    border-radius: 12px;
    text-align: center;
    transition: all 0.2s;
    max-width: 600px;
    margin: 0 auto;
}

.watt-next-cap-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 80, 10, 0.35);
}

.watt-next-cap-btn > span:first-child {
    font-size: 13px;
    text-transform: uppercase;
    opacity: 0.9;
    letter-spacing: 1px;
}

.watt-next-cap-btn strong {
    font-size: 18px;
    margin: 4px 0;
}

.watt-next-arrow {
    font-size: 24px;
    margin-top: 4px;
}

.watt-end-of-story {
    text-align: center;
    padding: 40px 24px;
    color: #1a1a1a;
    background: linear-gradient(135deg, #fff5f5, #fff);
    border-radius: 16px;
    max-width: 600px;
    margin: 0 auto;
}

.watt-end-of-story h3 {
    color: #ff500a;
    margin: 0 0 8px;
    font-size: 22px;
}

.watt-end-of-story p {
    margin: 0;
    color: #666;
}

/* ============== Story Map (innovación) ============== */
.watt-story-map-trigger {
    text-align: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #f0f0f0;
}

.watt-story-map-trigger button {
    background: transparent;
    border: 1px solid #ddd;
    color: #555;
    padding: 10px 20px;
    border-radius: 22px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.15s;
    font-family: inherit;
}

.watt-story-map-trigger button:hover {
    background: #f3f3f4;
    border-color: #ff500a;
    color: #ff500a;
}

.watt-story-map-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.watt-story-map-modal.is-open {
    display: flex;
}

.watt-story-map-content {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    max-width: 800px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.watt-story-map-content h2 {
    margin: 0 0 8px;
    font-size: 24px;
    color: #1a1a1a;
}

.watt-story-map-content p {
    color: #666;
    margin: 0 0 24px;
    font-size: 14px;
}

.watt-story-map-svg {
    width: 100%;
    min-height: 300px;
    background: #fafafa;
    border-radius: 8px;
}

.watt-story-map-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #888;
}

.watt-story-map-close:hover {
    color: #1a1a1a;
}

/* ============== Toolbar reader (tema/fuente/tamaño) ============== */
.watt-reader-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid #e6e6e6;
    position: sticky;
    top: 64px;
    z-index: 50;
}

.watt-app.watt-theme-dark .watt-reader-toolbar,
.watt-app.watt-theme-amoled .watt-reader-toolbar {
    background: #1a1c1f;
    border-bottom-color: #2e3136;
}

.watt-toolbar-title {
    font-size: 13px;
    color: #888;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 300px;
}

.watt-toolbar-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.watt-toolbar-btn {
    background: transparent;
    border: 1px solid #ddd;
    color: #555;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
    font-family: inherit;
}

.watt-toolbar-btn:hover {
    background: #f3f3f4;
    border-color: #ff500a;
    color: #ff500a;
}

.watt-toolbar-btn.is-active {
    background: #ff500a;
    color: #fff;
    border-color: #ff500a;
}

.watt-toolbar-sep {
    color: #ddd;
    margin: 0 4px;
}

.watt-app.watt-theme-dark .watt-toolbar-btn,
.watt-app.watt-theme-amoled .watt-toolbar-btn {
    color: #ccc;
    border-color: #2e3136;
}

.watt-app.watt-theme-dark .watt-toolbar-btn:hover,
.watt-app.watt-theme-amoled .watt-toolbar-btn:hover {
    background: #232529;
    border-color: #ff500a;
    color: #ff500a;
}

/* ============== Responsive reader ============== */
@media (max-width: 600px) {
    .watt-historia-header {
        flex-direction: column;
        padding: 24px 16px;
        text-align: center;
    }
    .watt-historia-cover {
        max-width: 200px;
        margin: 0 auto;
    }
    .watt-historia-actions {
        justify-content: center;
    }
    .watt-capitulo {
        padding: 20px 12px;
    }
    .watt-capitulo-title {
        font-size: 22px;
    }
    .watt-capitulo-body {
        font-size: 17px;
    }
    .watt-com-popover {
        width: calc(100vw - 40px);
        left: 0;
    }
    .watt-decision-panel {
        padding: 24px 16px;
    }
    .watt-toolbar-title {
        display: none;
    }
    .watt-toolbar-controls {
        gap: 4px;
    }
    .watt-toolbar-btn {
        padding: 4px 8px;
        font-size: 12px;
    }
}
