:root {
    --bg-color: #f8f9fa;
    --text-color: #2c3e50;
    --accent-color: #3C3B6E;
    --card-bg: rgba(255, 255, 255, 0.9);
    --tooltip-bg: rgba(30, 30, 30, 0.95);
    --font-main: 'Outfit', sans-serif;

    /* Escala de opinión: rojo y azul de bandera, blanco en el centro.
       El blanco del centro no es #fff puro: un relleno blanco sobre el fondo
       blanco de la gráfica no tendría contraste, así que lleva un matiz apenas
       perceptible y las burbujas neutrales llevan además un borde marcado. */
    --color-enemy: #B22234;
    --color-neutral: #F3F1FA;
    --color-friend: #3C3B6E;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.container {
    width: 95%;
    max-width: 1400px;
    padding: 2rem;
    text-align: center;
}

header {
    margin-bottom: 2rem;
}

h1 {
    font-size: 3rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -1px;
    /* Dos paradas, no tres: un tono blanco al centro desaparecería sobre el
       fondo claro de la página al recortarse como texto. */
    background: linear-gradient(90deg, var(--color-enemy), var(--color-friend));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2 {
    font-weight: 300;
    margin: 0.5rem 0;
    color: #555;
    font-size: 1.5rem;
}

.highlight {
    font-weight: 600;
    color: var(--text-color);
    position: relative;
    z-index: 1;
}

.highlight::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 0;
    width: 100%;
    height: 8px;
    background: rgba(60, 59, 110, 0.2);
    z-index: -1;
}

.subtitle {
    color: #7f8c8d;
    font-size: 1rem;
    margin-top: 0.5rem;
}

/* Legend */
.legend-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
    gap: 15px;
    font-size: 0.9rem;
    color: #666;
}

.legend-bar {
    width: 200px;
    height: 4px;
    background: linear-gradient(90deg, var(--color-enemy), var(--color-neutral), var(--color-friend));
    border-radius: 2px;
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 5px;
}

/* Chart Container */
/* Panel de error, por si la gráfica no puede dibujarse. */
.error-panel {
    padding: 2.5rem;
    text-align: left;
    color: #B22234;
    font-size: 0.95rem;
}

.error-panel p {
    color: #666;
    line-height: 1.5;
}

.error-panel .hint {
    font-size: 0.85rem;
    color: #888;
}

.error-panel code {
    background: #f4f4f4;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.85em;
}

/* Resumen de cifras, arriba de la gráfica. */
.resumen {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 2.5rem;
    margin: 0 0 1.5rem 0;
}

.resumen-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.resumen-cifra {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}

.resumen-etiqueta {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #999;
}

/* Nota metodológica al pie. */
.nota-alcance {
    margin-top: 3rem;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    padding: 2rem 2.5rem;
    text-align: left;
}

.nota-alcance h3 {
    margin: 0 0 1rem 0;
    font-size: 1.2rem;
}

.nota-alcance p {
    line-height: 1.6;
    color: #555;
    margin: 0 0 1rem 0;
}

.nota-alcance p:last-child {
    margin-bottom: 0;
}

#chart-container {
    width: 100%;
    /* Altura medida, no estimada: reproduciendo la simulación de fuerzas de d3
       el enjambre ocupa ~200px de alto con su distribución natural (entre 900 y
       1336px de ancho). Con el eje al fondo, 300px lo alojan sin apretarlo y sin
       dejar el lienzo medio vacío como los 600px originales. */
    height: 300px;
    position: relative;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    overflow: hidden;
    /* Dotted background pattern */
    background-image: radial-gradient(#e0e0e0 1px, transparent 1px);
    background-size: 20px 20px;
}

/* Leyenda de tamaño, debajo de la gráfica: vivía dentro del SVG con una
   posición fija desde el fondo, lo que la ataba a la altura del contenedor. */
.size-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem 1.5rem;
    margin-top: 1rem;
    font-size: 0.8rem;
    color: #777;
}

.size-legend-titulo {
    font-weight: bold;
    color: #666;
}

.size-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.size-swatch {
    display: inline-block;
    border-radius: 50%;
    background: #ccc;
    border: 1px solid white;
    box-shadow: 0 0 0 1px #e0e0e0;
    flex-shrink: 0;
}

.size-swatch--sm {
    width: 8px;
    height: 8px;
}

.size-swatch--lg {
    width: 22px;
    height: 22px;
}

.size-swatch--central {
    width: 18px;
    height: 18px;
    background: #ccc;
    border: 2px dashed #222;
    box-shadow: none;
}

/* Etiqueta flotante mínima: nombre y calificación. Deliberadamente pequeña —
   lo que la hacía estorbosa antes era el bloque largo de texto, no el seguir
   al cursor. `position: fixed` + coordenadas de viewport evita tener que
   corregir por el scroll de la página. */
.hover-label {
    position: fixed;
    z-index: 100;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--tooltip-bg);
    color: white;
    padding: 6px 11px;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    transition: opacity 0.12s ease;
}

.hover-label.hidden {
    opacity: 0;
    visibility: hidden;
}

.hover-label .hover-punto {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.5);
    flex-shrink: 0;
}

.hover-label .hover-cal {
    color: #bbb;
}

/* Panel de detalle: posición fija debajo de la gráfica, en lugar de un tooltip
   que seguía al cursor tapando burbujas y los números del eje. El min-height
   evita que la página salte al entrar y salir de una burbuja. */
.detalle {
    margin-top: 1rem;
    min-height: 150px;
    background: var(--tooltip-bg);
    color: white;
    padding: 1.2rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    text-align: left;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.detalle--vacio {
    align-items: center;
}

.detalle-vacio {
    margin: 0;
    color: #9a9a9a;
    font-style: italic;
}

.detalle h3 {
    margin: 0 0 6px 0;
    font-size: 1.15rem;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 6px;
}

.detalle .meta {
    font-size: 0.8rem;
    color: #bbb;
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.2rem;
}

.detalle .desc {
    line-height: 1.5;
}

/* Cita textual del libro, en inglés y sin traducir. */
.detalle .cita {
    margin-top: 10px;
    padding-left: 12px;
    border-left: 2px solid rgba(255,255,255,0.35);
    font-style: italic;
    line-height: 1.45;
    color: #e6e6e6;
}

/* Search Box */
.controls {
    margin-top: 2rem;
}

#search-box {
    padding: 10px 20px;
    width: 300px;
    border: 2px solid #eee;
    border-radius: 30px;
    font-size: 1rem;
    font-family: var(--font-main);
    transition: all 0.3s ease;
    outline: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

#search-box:focus {
    border-color: var(--accent-color);
    box-shadow: 0 5px 15px rgba(60, 59, 110, 0.15);
    width: 320px;
}

/* El susurrador: mismo lenguaje de tarjeta que las otras secciones. */
.susurrador-section {
    margin-top: 3rem;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    padding: 2rem 2.5rem;
    text-align: left;
}

.susurrador-original {
    font-weight: 400;
    font-size: 1rem;
    color: #999;
    font-style: italic;
    margin-left: 0.4rem;
}

.susurros {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.susurro {
    border-left: 3px solid var(--accent-color);
    padding-left: 1.2rem;
}

.susurro-cabecera {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.6rem;
}

.susurro-momento {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
}

.susurro-pagina {
    font-size: 0.8rem;
    color: #aaa;
    white-space: nowrap;
}

.susurro-contexto,
.susurro-desenlace {
    font-size: 0.9rem;
    line-height: 1.55;
    color: #555;
    margin: 0 0 0.8rem 0;
}

.susurro-desenlace {
    margin-bottom: 0;
    font-style: italic;
    color: #777;
}

/* Las citas van en inglés, textuales, como en el resto del proyecto. */
.susurro-cita {
    margin: 0 0 0.8rem 0;
    padding: 0.7rem 1rem;
    background: #f6f6f9;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #33324e;
    font-style: italic;
}

.susurro-cita--presentacion {
    margin-top: 1rem;
    max-width: 70ch;
}

.susurrador-nota {
    margin: 1.5rem 0 0 0;
    padding-top: 1rem;
    border-top: 1px solid #f0f0f0;
    font-size: 0.8rem;
    line-height: 1.5;
    color: #999;
}

/* To-do Section */
.todo-section {
    margin-top: 3rem;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    padding: 2rem 2.5rem;
    text-align: left;
}

.todo-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0 0 0.3rem 0;
}

.todo-subtitle {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin: 0 0 1.5rem 0;
}

.todo-list {
    list-style: none;
    padding: 0;
    margin: 0;
    columns: 2;
    column-gap: 2rem;
}

@media (max-width: 800px) {
    .todo-list {
        columns: 1;
    }
}

.todo-list li {
    break-inside: avoid;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.todo-list label {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1.4;
    color: #444;
    transition: color 0.2s;
}

.todo-list input[type="checkbox"] {
    margin-top: 3px;
    accent-color: var(--accent-color);
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.todo-list label:has(input:checked) {
    text-decoration: line-through;
    color: #bbb;
}

.todo-ref {
    color: #aaa;
    font-size: 0.8rem;
    white-space: nowrap;
    margin-left: 4px;
}

footer {
    margin-top: 3rem;
    font-size: 0.8rem;
    color: #999;
}

footer a {
    color: var(--accent-color);
    text-decoration: none;
}
