/* === RESET & VARIABLES === */
:root {
    --bg-color: #050505;       /* Negro profundo */
    --fg-color: #d0d0d0;       /* Gris claro (Texto general) */
    
    /* PALETA TÁCTICA */
    --accent: #00ff41;         /* Verde Matrix */
    --cyan: #00ffcc;           /* Cyan Neón */
    
    --dim: #4d4d4d;            /* Gris apagado */
    --gap: 10px;               /* Espacio entre paneles (Reducido) */
    
    --border: 1px solid var(--accent);
}

body {
    background-color: var(--bg-color);
    color: var(--fg-color);
    font-family: 'Quantico', sans-serif;
    margin: 0;
    
    /* CAMBIO: Padding reducido para ganar altura */
    padding: 5px; 
    
    height: 100vh;
    box-sizing: border-box;
    overflow: hidden;
}

/* === LAYOUT === */
.desktop {
    display: grid;
    grid-template-columns: 280px 1fr; 
    grid-template-rows: 40px 1fr; /* Barra superior un poco más compacta (40px) */
    gap: var(--gap);
    height: 100%;
}

/* === BARRA SUPERIOR === */
.top-bar {
    grid-column: 1 / -1;
    background: #000;
    border: var(--border);
    box-shadow: inset 0 0 10px rgba(0, 255, 65, 0.1);
    color: var(--cyan);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    font-size: 1em;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 0 5px rgba(0, 255, 204, 0.6);
}

/* Enlace de perfil en la barra */
.top-link {
    text-decoration: none;
    color: var(--accent); /* Verde por defecto */
    font-weight: bold;
    transition: all 0.3s ease;
}
.top-link:hover {
    color: #fff !important;
    text-shadow: 0 0 10px var(--accent);
    background: transparent !important;
}

/* === SIDEBAR (IZQUIERDA) === */
.sidebar {
    border: var(--border);
    padding: 15px; /* Padding optimizado */
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: #000;
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.05);
    overflow-y: auto; /* Permite scroll si el contenido total es muy alto */
    flex-shrink: 0;   /* Evita que se aplaste */
}

.sidebar h3 {
    border-bottom: 1px dashed var(--accent);
    padding-bottom: 5px;
    margin: 0 0 10px 0;
    font-size: 0.8em;
    color: var(--accent);
    text-shadow: 0 0 4px rgba(0, 255, 65, 0.4);
}

/* Navegación Sidebar */
.nav-links { list-style: none; padding: 0; margin: 0; }
.nav-links li { margin-bottom: 5px; }

.nav-links a {
    color: var(--fg-color);
    text-decoration: none;
    display: block;
    padding: 4px;
    border: 1px solid transparent;
    transition: all 0.2s;
    font-size: 0.9em;
}

.nav-links a:hover {
    border-color: var(--accent);
    background: rgba(0, 255, 65, 0.1);
    color: var(--accent);
    text-shadow: 0 0 5px var(--accent);
}
.nav-links a::before { content: "> "; color: var(--dim); }
.nav-links a:hover::before { content: "# "; color: var(--accent); }

/* === VENTANA PRINCIPAL (DERECHA) === */
.main-window {
    border: var(--border);
    padding: 25px;
    overflow-y: auto;
    background: rgba(0,0,0,0.92);
    position: relative;
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.05);
}

/* Etiqueta de Título de Ventana */
.window-title {
    position: absolute;
    top: 0;
    left: 0;
    background: var(--accent);
    color: #000;
    padding: 2px 8px;
    font-size: 0.75em;
    font-weight: bold;
    letter-spacing: 1px;
}

/* === TIPOGRAFÍA & ELEMENTOS === */
h1 { 
    color: var(--accent); 
    text-shadow: 0 0 8px rgba(0, 255, 65, 0.6);
    margin-top: 0;
    text-transform: none; 
    letter-spacing: 1px;
}

h3 { 
    color: var(--accent); 
    margin-top: 25px; 
    border-bottom: 1px dotted var(--dim);
    padding-bottom: 5px;
}

.main-window a { 
    color: var(--cyan); 
    text-decoration: none; 
    border-bottom: 1px solid var(--cyan);
    transition: all 0.2s;
}
.main-window a:hover {
    background-color: var(--cyan);
    color: #000;
    box-shadow: 0 0 10px var(--cyan);
}

blockquote { border-left: 3px solid var(--accent); padding-left: 15px; color: #888; font-style: italic; }
code { background: #0a0a0a; padding: 2px 6px; border: 1px solid var(--dim); color: var(--cyan); font-family: 'IBM Plex Mono', monospace; font-size: 0.9em; }
img { max-width: 100%; border: 1px solid var(--dim); padding: 5px; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #000; }
::-webkit-scrollbar-thumb { background: var(--accent); border: 1px solid #000; }

/* Estilos Haikus Visuales */
.haiku-wrapper { margin-bottom: 40px; border-bottom: 1px dashed #333; padding-bottom: 30px; }
.haiku-row { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; justify-content: center; }
.haiku-img-container { flex: 1 1 250px; max-width: 100%; }
.haiku-img-container img { width: 100%; height: auto; border: 1px solid var(--accent); filter: grayscale(100%); transition: filter 0.3s ease; }
.haiku-img-container img:hover { filter: grayscale(0%); box-shadow: 0 0 15px rgba(0, 255, 65, 0.3); }
.haiku-text-container { flex: 1 1 200px; text-align: center; color: var(--fg-color); }
.haiku-title { font-family: 'Quantico', sans-serif; text-transform: none; letter-spacing: 2px; margin-bottom: 10px; color: var(--accent); text-shadow: 0 0 5px rgba(0, 255, 65, 0.5); border-bottom: none !important; padding-bottom: 0; }
.haiku-lines { font-size: 1em; line-height: 1.6; font-family: 'IBM Plex Mono', monospace; }
.haiku-credits { margin-top: 30px; border-top: 1px solid var(--dim); padding-top: 10px; font-size: 0.7em; color: #666; font-family: monospace; }

@media (max-width: 768px) {
    body { padding: 0; overflow: auto; height: auto; }
    .desktop { display: flex; flex-direction: column; height: auto; gap: 0; }
    .main-window { overflow: visible; height: auto; border: none; border-top: 1px solid var(--accent); }
    .sidebar { border: none; border-bottom: 1px solid var(--accent); }
}

/* === MÓDULO POESÍA === */
.poema-container {
    text-align: center;
    font-family: 'IBM Plex Mono', monospace;
    color: var(--fg-color);
    max-width: 600px;
    margin: 0 auto; /* Centrado en la página */
}

.estrofa {
    /* Aquí controlas el espacio entre VERSOS */
    line-height: 1.8; 
    
    /* Aquí controlas el espacio entre ESTROFAS */
    margin-bottom: 10px; /* <--- JUEGA CON ESTO (Ponle 10px o 5px si quieres más pegado) */
    
    /* Esto permite que el Enter funcione como salto de línea normal */
    white-space: pre-line; 
}

/* === MÓDULO DE POESÍA AUTOMÁTICA === */

.poema-auto {
    max-width: 650px;
    margin: 0 auto;        /* Centrado horizontal */
    text-align: center;    /* Texto centrado */
    color: var(--fg-color);
    font-family: 'IBM Plex Mono', monospace;
}

/* AQUÍ ESTÁ EL TRUCO: */
/* Markdown convierte tus bloques de texto en etiquetas <p> */
.poema-auto p {
    /* 1. Comportamiento de Versos */
    line-height: 1.6;          /* Espacio entre versos (apretadito) */
    white-space: pre-line;     /* ¡CLAVE! Hace que 1 Enter sea 1 salto de linea */
    
    /* 2. Comportamiento de Estrofas */
    margin-bottom: 25px;       /* Espacio grande entre estrofas */
    margin-top: 0;
}

/* === FUERZA BRUTA: LISTAS COMPACTAS DASHBOARD === */
ul.terminal-list {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

ul.terminal-list li {
    /* Esto elimina el espacio entre filas */
    margin-bottom: 0 !important;
    padding: 2px 0 !important;
    
    /* Esto aplasta la altura de la línea de texto */
    line-height: 1.2 !important; 
    
    /* Asegura alineación */
    display: flex !important;
    align-items: baseline !important;
}

/* ESTO ES CLAVE: Si Markdown metió un <p> invisible, lo matamos aquí */
ul.terminal-list li p {
    margin: 0 !important;
    padding: 0 !important;
    display: inline !important;
}

/* Ajuste para los enlaces dentro de la lista */
ul.terminal-list li a {
    display: inline-block !important;
    border: none !important;
}

/* === MÓDULO DE FRECUENCIAS (AUDIO) === */
.frecuencia-container {
    max-width: 700px;
    margin: 0 auto;
    font-family: 'IBM Plex Mono', monospace;
}

/* Carátula */
.track-cover {
    text-align: center;
    margin-bottom: 20px;
}
.track-cover img {
    max-width: 300px; /* Tamaño controlado */
    border: 1px solid var(--accent);
    padding: 5px;
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.1);
}

/* Datos Técnicos */
.track-meta {
    border-top: 1px dashed var(--dim);
    border-bottom: 1px dashed var(--dim);
    padding: 5px 0;
    margin-bottom: 25px;
    text-align: center;
    font-size: 0.8em;
    color: var(--cyan);
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* Reproductor Local */
.local-player {
    width: 100%;
    height: 40px;
    border-radius: 0;
    margin-bottom: 20px;
    /* Filtro Hacker: Invierte colores y ajusta tono para que se vea verdoso/oscuro */
    filter: invert(90%) sepia(20%) hue-rotate(90deg);
    outline: none;
}

/* Wrappers para Embeds (SoundCloud/YouTube) */
.embed-wrapper iframe {
    width: 100%;
    border: 1px solid var(--dim);
}

/* Descripción */
.track-description {
    color: var(--fg-color);
    line-height: 1.6;
    margin-top: 30px;
    white-space: pre-line; /* Respeta los Enters si pones letras de canciones */
}

/* === MÓDULO FRECUENCIAS (GRID TÁCTICO) === */
.freq-grid {
    display: grid;
    /* 2 Columnas: Izquierda (300px fija), Derecha (El resto) */
    grid-template-columns: 300px 1fr; 
    /* 2 Filas: Arriba (Auto según player), Abajo (El resto) */
    grid-template-rows: auto 1fr;     
    gap: 15px;
    max-width: 900px; 
    margin: 0 auto;
    min-height: 400px; /* Altura mínima para asegurar que haya espacio para decorar */
}

/* 1. NUEVO: RACK IZQUIERDO (Contenedor Flex) */
.freq-left-rack {
    grid-column: 1 / 2;    
    grid-row: 1 / 3;
    /* Flexbox para distribuir verticalmente */
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Empuja elementos a los extremos */
    height: 100%;
    padding-right: 15px; /* Espacio con la columna derecha */
}

/* Decoración de Texto Superior e Inferior */
.rack-deco {
    text-align: center;
    font-size: 0.7em;
    color: var(--dim);
    font-family: 'IBM Plex Mono', monospace;
    letter-spacing: 1px;
    padding: 10px 0;
}
.rack-deco.top {
    border-bottom: 1px dotted #333;
    margin-bottom: auto; /* Empuja hacia arriba si sobra espacio */
}
.rack-deco.bottom {
    border-top: 1px dotted #333;
    margin-top: auto; /* Empuja hacia abajo si sobra espacio */
}

/* El Contenedor de la Carátula (Cuadrado Perfecto) */
.freq-cover {
    width: 100%;           
    aspect-ratio: 1 / 1;   
    /* Importante: que no se encoja si falta espacio */
    flex-shrink: 0;
    margin: 20px 0; /* Un poco de aire arriba y abajo de la imagen */
    
    border: 1px solid var(--accent);
    background: #000;
    position: relative;
    box-sizing: border-box; 
    padding: 0;            
    overflow: hidden;     
}

.freq-cover img {
    width: 100% !important;        
    height: 100% !important;       
    object-fit: cover;             
    display: block !important;
    border: none !important;       
    padding: 0 !important;         
    margin: 0 !important;
    filter: grayscale(80%);
    transition: filter 0.5s;
}
.freq-cover:hover img { filter: grayscale(0%); }

/* 2. PANEL REPRODUCTOR (Arriba Derecha) - Sin cambios mayores */
.freq-player {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    border: 1px solid var(--dim);
    background: rgba(0,20,0,0.3);
    position: relative;
    min-height: 150px;
}

/* 3. PANEL DATOS (Abajo Derecha) - Sin cambios mayores */
.freq-data {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    border: 1px dashed var(--dim);
    padding: 15px;
    position: relative;
}

/* Estilos Internos */
.panel-label {
    position: absolute;
    top: -8px;
    right: 10px;
    background: #000;
    padding: 0 5px;
    font-size: 0.6em;
    color: var(--dim);
    border: 1px solid #333;
}

.meta-tags {
    font-size: 0.8em;
    margin-bottom: 15px;
    border-bottom: 1px dotted #333;
    padding-bottom: 5px;
    font-family: 'IBM Plex Mono', monospace;
}

.track-text {
    font-size: 0.9em;
    line-height: 1.6;
    color: #ccc;
    white-space: pre-line;
}

/* Ajuste para que los iframes llenen el hueco */
.embed-fit iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* === RESPONSIVO (MÓVIL) === */
@media (max-width: 768px) {
    .freq-grid {
    grid-template-columns: 1fr; /* Una sola columna */
    grid-template-rows: auto;   /* Filas automáticas */
    }
    
    /* En móvil, la carátula ya no ocupa 2 filas, sino que va arriba sola */
    .freq-cover {
    /* Fuerza la carátula a ser el 90% del espacio disponible */
    width: 90%;      
    /* Pero nunca más grande de 300px (opcional, para tablets) */
    max-width: 300px; 
    margin: 15px auto; /* Centrado horizontal */
    }
    
    .freq-player, .freq-data {
    grid-column: 1 / -1;
    grid-row: auto;
    }
}

/* Responsive Táctico */
@media (max-width: 768px) {
    body { padding: 0; overflow: auto; height: auto; }
    
    .desktop { 
        display: flex; 
        flex-direction: column; 
        height: auto; 
        gap: 0; 
    }

    /* ORDEN DE APILAMIENTO EN MÓVIL */
    /* 1. Barra Superior (Siempre arriba) */
    .top-bar { order: 1; }
    
    /* 2. Contenido (Lo que importa, va segundo) */
    .main-window { 
        order: 2; 
        overflow: visible; 
        height: auto; 
        border: none; 
        /* Borde solo abajo para separar del menú */
        border-bottom: 1px solid var(--accent); 
    }
    
    /* 3. Menú Lateral (Pasa al final de la página) */
    .sidebar { 
        order: 3; 
        border: none; 
        /* Un poco de aire al final */
        padding-bottom: 50px; 
    }
}

/* Parche para Tablets (Entre 700px y 1200px) */
@media (min-width: 700px) and (max-width: 1200px) {
    body {
    min-height: 100dvh;
    overflow-y: scroll; /* Fuerza el scroll si es necesario */
    }

    /* Si tienes un footer fijo, des-fíjalo en tablets */
    footer, .bottom-line {
    position: relative; /* Ya no flota, ahora ocupa su espacio real */
    margin-top: 2rem;   /* Empújalo un poco hacia abajo */
    }
}

/* === PAGEFIND OVERRIDE (Estilo Hacker) === */
:root {
  --pagefind-ui-scale: 0.8;
  --pagefind-ui-primary: var(--accent);
  --pagefind-ui-text: var(--fg-color);
  --pagefind-ui-background: #000;
  --pagefind-ui-border: var(--dim);
  --pagefind-ui-tag: var(--dim);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 0px;
  --pagefind-ui-image-border-radius: 0px;
  --pagefind-ui-image-box-ratio: 3 / 2;
  --pagefind-ui-font: 'IBM Plex Mono', monospace;
}

/* Forzar colores oscuros en la caja de input */
.pagefind-ui__search-input {
  background-color: #050505 !important;
  color: var(--accent) !important;
  border: 1px solid var(--accent) !important;
  font-family: 'Quantico', sans-serif !important;
}

/* Resultados */
.pagefind-ui__result {
  border-bottom: 1px dashed var(--dim) !important;
  padding: 10px 0 !important;
}

.pagefind-ui__result-title {
  font-family: 'Quantico', sans-serif !important;
  color: var(--cyan) !important;
}

.pagefind-ui__result-excerpt {
  color: #888 !important;
  font-size: 0.85em !important;
}

/* Botón de limpiar */
.pagefind-ui__search-clear {
  background-color: transparent !important;
  color: var(--accent) !important;
}

/* === CONTROL DE SCROLL EN RESULTADOS === */
.pagefind-ui__drawer {
  /* 1. Altura Máxima Táctica */
  max-height: 50vh; /* Nunca ocupará más del 50% de la altura de la pantalla */
  
  /* 2. Scroll Interno */
  overflow-y: auto; 
  
  /* 3. Estética */
  border-bottom: 1px solid var(--accent);
  padding-right: 5px; /* Espacio para que el scroll no tape texto */
  margin-bottom: 15px;
  
  /* Sombra interna para indicar que hay más contenido abajo */
  box-shadow: inset 0 -15px 15px -15px rgba(0, 255, 65, 0.2);
}

/* === BOTÓN "VER MÁS RESULTADOS" === */
.pagefind-ui__button {
  background-color: transparent !important;
  color: var(--accent) !important;
  border: 1px solid var(--accent) !important;
  border-radius: 0px !important; /* Bordes cuadrados */
  font-family: 'Quantico', sans-serif !important;
  font-size: 0.8em !important;
  text-transform: uppercase;
  margin-top: 15px !important;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* Efecto Hover (Al pasar el mouse) */
.pagefind-ui__button:hover {
  background-color: var(--accent) !important;
  color: #000 !important; /* Texto negro sobre fondo verde */
  box-shadow: 0 0 10px var(--accent); /* Resplandor */
}