/* ===========================
   FORENSIC ARCHITECTURE STYLE
   Portafolio Juan Cortes
   =========================== */

:root {
    /* Colores de la imagen original */
    --color-bg: #0a0a0a;
    --color-bg-alt: #121212;

    --color-salmon: #E89A8F;
    --color-peach: #EBA898;
    --color-beige: #E8D5B7;
    --color-cream: #F5E6D3;
    --color-sand: #EDD9C0;
    --color-gray: #8C9BA5;

    --color-text: #FFFFFF;
    --color-text-dim: rgba(255, 255, 255, 0.65);
    --color-text-subtle: rgba(255, 255, 255, 0.35);
    --color-line: rgba(255, 255, 255, 0.08);

    /* Tipografía estilo Forensic Architecture */
    --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

    /* Espaciado preciso */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;

    /* Transiciones suaves */
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===========================
   Reset Minimalista
   =========================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden; /* Prevenir scroll horizontal */
}

body {
    font-family: var(--font-sans);
    font-weight: 300;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    overflow-x: hidden; /* Prevenir scroll horizontal */
    max-width: 100vw; /* Limitar ancho al viewport */
}

/* ===========================
   Tipografía
   =========================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 100px;
    background-color: var(--color-bg);
    border-bottom: 1px solid var(--color-line);
    padding: var(--space-5) var(--space-6);
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

@media (max-width: 767px) {
    .header {
        height: 60px;
        padding: var(--space-3) var(--space-4);
    }

    .header-title {
        font-size: 11px;
    }

    .header-subtitle {
        font-size: 12px;
    }
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.header-title {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--color-text);
}

.header-subtitle {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 300;
    color: var(--color-text-subtle);
    letter-spacing: 0.5px;
}

.header-name {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

@media (max-width: 767px) {
    .header-name {
        gap: var(--space-2);
    }
}

.name-text {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--color-text-dim);
}

@media (max-width: 767px) {
    .name-text {
        font-size: 10px;
    }
}

.bio-btn {
    width: 24px;
    height: 24px;
    background: none;
    border: 1px solid var(--color-line);
    color: var(--color-text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    font-family: var(--font-mono);
    font-size: 17px;
    line-height: 1;
    padding: 0;
}

.bio-btn:hover {
    border-color: var(--color-text);
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.05);
}

@media (max-width: 767px) {
    .bio-btn {
        width: 20px;
        height: 20px;
        font-size: 15px;
    }
}

/* Language Toggle Button */
.lang-btn {
    width: auto;
    min-width: 32px;
    height: 24px;
    background: none;
    border: 1px solid var(--color-line);
    color: var(--color-text-dim);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    margin-right: var(--space-3);
    padding: 0 var(--space-2);
}

.lang-text {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.05em;
    line-height: 1;
}

.lang-btn:hover {
    border-color: var(--color-text);
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.05);
}

@media (max-width: 767px) {
    .lang-btn {
        min-width: 28px;
        height: 20px;
        margin-right: var(--space-2);
    }

    .lang-text {
        font-size: 8px;
    }
}

/* ===========================
   Contenedor Principal
   =========================== */
.main-container {
    margin-top: 0;
    padding: 0;
    height: calc(100vh - 100px); /* Altura exacta disponible */
    overflow: hidden; /* Sin scroll */
}

@media (max-width: 767px) {
    .main-container {
        height: auto; /* Auto height en mobile para timeline */
        min-height: calc(100vh - 60px);
        overflow-x: hidden;
        overflow-y: visible;
        width: 100%;
        max-width: 100vw;
    }
}

.sankey-container {
    width: 100%;
    height: 100%;
    padding: 0;
    overflow: hidden; /* SIN SCROLL - todo debe caber */
    position: relative;
}

@media (max-width: 767px) {
    .sankey-container {
        height: auto;
        overflow: visible;
        width: 100%;
        max-width: 100vw;
    }
}

/* Desktop: SIN scroll horizontal, todo cabe en viewport */
@media (min-width: 1024px) {
    .sankey-container {
        overflow: hidden; /* SIN SCROLL en ninguna dirección */
    }
}

.sankey-chart {
    display: block;
    max-width: 100%; /* Limitar al ancho del contenedor */
    width: 100%;
}

/* ===========================
   Elementos SVG
   =========================== */
.year-marker {
    cursor: default;
}

.year-bar {
    transition: opacity var(--transition);
}

.year-bar:hover {
    opacity: 0.8;
}

.year-label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.5px;
    fill: var(--color-text-dim);
    text-anchor: middle;
    transition: all var(--transition);
}

.year-group-clickable {
    cursor: pointer;
    transition: all var(--transition);
}

.year-group-clickable:hover .year-label {
    fill: rgba(255, 255, 255, 0.9);
    font-size: 11px;
}

.year-group-clickable:hover .year-line {
    stroke: rgba(255, 255, 255, 0.6);
    stroke-width: 1.5;
}

.project-node {
    cursor: pointer;
    transition: all var(--transition);
}

.project-bar {
    transition: all var(--transition);
}

.project-node:hover .project-bar {
    opacity: 0.9;
    filter: brightness(1.15);
}

/* Hover effect en nombres de proyectos - background rojo, texto blanco */
text.project-name-text {
    cursor: pointer;
    transition: all 0.2s ease;
}

text.project-name-text:hover {
    fill: #FFFFFF !important;
    font-weight: 500;
}

.project-label {
    font-family: var(--font-sans);
    font-size: 9px;
    font-weight: 300;
    letter-spacing: 0.3px;
    fill: var(--color-text-subtle);
    text-anchor: start;
    transition: fill var(--transition);
}

.project-node:hover .project-label {
    fill: var(--color-text-dim);
}

.flow-line {
    fill: none;
    stroke-opacity: 0.15;
    transition: stroke-opacity var(--transition);
    mix-blend-mode: lighten;
}

.flow-line:hover {
    stroke-opacity: 0.35;
}

.category-label {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 400;
    letter-spacing: 0.5px;
    fill: var(--color-text-subtle);
    text-transform: uppercase;
}

.grid-line {
    stroke: var(--color-line);
    stroke-width: 1;
    stroke-dasharray: 2, 4;
    opacity: 0.3;
}

.node-bar {
    transition: opacity var(--transition);
}

.node-bar:hover {
    opacity: 0.7;
}

/* ===========================
   Panel de Detalles
   =========================== */
.project-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 480px;
    height: 100vh;
    background-color: var(--color-bg-alt);
    border-left: 1px solid var(--color-line);
    z-index: 1000;
    overflow-y: auto;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.project-panel.active {
    right: 0;
}

/* Expanded fullscreen state */
.project-panel.expanded {
    right: 0;
    left: 0;
    max-width: 100%;
    width: 100%;
    background-color: var(--color-bg);
    border-left: none;
}

.project-panel.expanded .panel-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-8) var(--space-6);
}

.project-panel.expanded .panel-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-7);
    margin-bottom: var(--space-8);
}

.project-panel.expanded .panel-summary .panel-header {
    grid-column: 1 / -1;
}

/* Pulse animation for expand button */
@keyframes expandPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 4px rgba(255, 255, 255, 0);
    }
}

.project-panel.expanded .expand-btn {
    transform: rotate(45deg);
    animation: none;
}

.close-btn, .expand-btn {
    position: absolute;
    top: var(--space-5);
    width: 36px;
    height: 36px;
    background: var(--color-bg);
    border: 1px solid var(--color-line);
    color: var(--color-text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10001;
    border-radius: 2px;
}

.close-btn {
    right: var(--space-5);
}

.expand-btn {
    right: calc(var(--space-5) + 52px);
    animation: expandPulse 2s ease-in-out infinite;
}

.close-btn:hover, .expand-btn:hover {
    border-color: var(--color-text);
    color: var(--color-text);
    background: var(--color-bg-alt);
    transform: scale(1.1);
}

.expand-btn:hover {
    animation: none;
}

/* Translate Text Button */
.translate-btn {
    position: absolute;
    top: var(--space-5);
    right: calc(var(--space-5) + 104px);
    width: auto;
    min-width: 40px;
    height: 36px;
    background: var(--color-bg);
    border: 1px solid var(--color-line);
    color: var(--color-text-dim);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10001;
    border-radius: 2px;
    padding: 0 var(--space-3);
}

.translate-btn.visible {
    display: flex;
}

.translate-text {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.05em;
}

.translate-btn:hover {
    border-color: var(--color-text);
    color: var(--color-text);
    background: var(--color-bg-alt);
    transform: scale(1.1);
}

/* Visual hint for expand button */
.expand-btn::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: var(--color-salmon);
    border-radius: 50%;
    opacity: 0.8;
}

.project-panel.expanded .expand-btn::after {
    display: none;
}

.panel-content {
    padding: var(--space-7) var(--space-6);
}

/* Expanded content - hidden by default */
.expanded-content {
    display: none;
    margin-top: var(--space-8);
}

.project-panel.expanded .expanded-content {
    display: block;
}

.expanded-section {
    margin-bottom: var(--space-7);
    border-top: 1px solid var(--color-line);
    padding-top: var(--space-5);
}

.section-title {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--color-text-dim);
    margin-bottom: var(--space-4);
}

.section-text {
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.7;
    color: var(--color-text);
    max-width: 80ch;
}

.expanded-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-5);
    margin: var(--space-7) 0;
}

.gallery-image-container {
    width: 100%;
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-bg);
    border: 1px solid var(--color-line);
    overflow: hidden;
}

.gallery-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Mobile responsive */
@media (max-width: 768px) {
    /* Hide expand button on mobile - always expanded */
    .expand-btn {
        display: none !important;
    }

    /* Mobile project panel always takes full width */
    .project-panel {
        width: 100vw;
        max-width: 100vw;
    }

    /* Auto-expand view on mobile */
    .project-panel .panel-summary {
        display: block;
    }

    .project-panel.expanded .panel-summary {
        display: block;
    }

    .project-panel .expanded-content {
        display: block;
        margin-top: var(--space-6);
    }

    .project-panel .panel-content {
        padding: var(--space-6) var(--space-4);
    }

    .project-panel.expanded .panel-content {
        padding: var(--space-6) var(--space-4);
    }

    /* Single column gallery */
    .expanded-gallery {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    .gallery-image-container {
        height: 300px;
    }

    /* Adjust close button position */
    .close-btn {
        width: 40px;
        height: 40px;
        top: var(--space-4);
        right: var(--space-4);
    }

    /* Adjust translate button position for mobile */
    .translate-btn {
        top: var(--space-4);
        right: calc(var(--space-4) + 48px);
        width: 40px;
        height: 40px;
        min-width: 40px;
        font-size: 11px;
        z-index: 10001;
    }

    .translate-btn.visible {
        display: flex !important;
    }

    /* Translate button in fullscreen research panel on mobile */
    #researchPanel.research-panel-fullscreen .translate-btn.visible {
        display: flex !important;
        position: fixed;
        top: var(--space-4);
        right: calc(var(--space-4) + 48px);
    }

    #researchPanel.research-panel-fullscreen .close-btn {
        position: fixed;
        top: var(--space-4);
        right: var(--space-4);
    }

    /* Better spacing for panel header on mobile */
    .panel-header {
        margin-bottom: var(--space-5);
        padding-top: 0;
    }

    .panel-title {
        font-size: 18px;
        line-height: 1.2;
    }

    .panel-meta {
        font-size: 12px;
    }

    /* Image adjustments */
    .panel-image {
        margin: var(--space-5) 0;
        max-height: 300px;
    }

    /* Better text readability on mobile */
    .panel-description, .section-text {
        font-size: 14px;
        line-height: 1.6;
    }

    /* Tech items smaller on mobile */
    .tech-item {
        font-size: 11px;
        padding: 4px 8px;
    }

    /* Larger tap targets for mobile */
    .panel-link {
        padding: var(--space-4);
        margin: var(--space-5) 0;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Better touch experience for overlay */
    #overlay {
        -webkit-tap-highlight-color: transparent;
    }

    /* Smooth scrolling on mobile */
    .project-panel {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* Prevent text selection during swipes */
    .project-panel * {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Allow text selection for reading content */
    .panel-description,
    .section-text,
    .panel-title {
        -webkit-user-select: text;
        user-select: text;
    }
}

.panel-header {
    margin-bottom: var(--space-6);
    padding-top: var(--space-2);
}

.panel-title {
    font-family: var(--font-sans);
    font-size: 20px;
    font-weight: 400;
    letter-spacing: -0.2px;
    color: var(--color-text);
    margin-bottom: var(--space-3);
    line-height: 1.3;
}

.panel-meta {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.5px;
    color: var(--color-text-dim);
    text-transform: uppercase;
}

.meta-separator {
    margin: 0 var(--space-2);
    color: var(--color-text-subtle);
}

.panel-collaboration {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 400;
    font-style: italic;
    color: var(--color-text-dim);
    margin-top: var(--space-3);
    display: none;
}

.panel-collaboration.visible {
    display: block;
}

.panel-image {
    width: 100%;
    height: auto;
    max-height: 280px;
    object-fit: cover;
    margin-bottom: var(--space-6);
    border: 1px solid var(--color-line);
}

.panel-body {
    padding-top: var(--space-2);
}

.panel-description {
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 300;
    line-height: 1.7;
    color: var(--color-text-dim);
    margin-bottom: var(--space-6);
}

.panel-tech {
    margin-bottom: var(--space-6);
    padding-top: var(--space-5);
    border-top: 1px solid var(--color-line);
}

.tech-label {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--color-text-subtle);
    display: block;
    margin-bottom: var(--space-3);
}

.tech-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.related-projects-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.related-project-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) var(--space-3);
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    transition: var(--transition);
}

.related-project-item:hover {
    background-color: rgba(255, 255, 255, 0.08);
    transform: translateX(4px);
}

.related-project-title {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 400;
    color: var(--color-text);
}

.related-project-year {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 300;
    color: var(--color-text-dim);
}

.tech-item {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 400;
    padding: var(--space-2) var(--space-3);
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-line);
    color: var(--color-text-dim);
    letter-spacing: 0.3px;
}

/* Panel Actions - Container for buttons */
.panel-actions {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-top: var(--space-4);
}

.panel-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--color-text);
    text-decoration: none;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-text);
    transition: all var(--transition);
    background: transparent;
    cursor: pointer;
}

.panel-link:hover {
    background-color: var(--color-text);
    color: var(--color-bg);
}

.panel-link svg {
    width: 10px;
    height: 10px;
}

.expand-project-btn {
    display: inline-flex !important;
}

.expand-project-btn svg {
    width: 14px;
    height: 14px;
}

.panel-link.hidden {
    display: none;
}

/* Ensure both buttons are visible */
#expandProjectBtn {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* ===========================
   Research Full Text Section
   =========================== */

.research-metadata {
    display: block;
}

.research-full-text {
    display: none;
}

/* When showing full text only - FULLSCREEN */
#researchPanel.research-panel-fullscreen {
    right: 0;
    left: 0;
    max-width: 100%;
    width: 100%;
    background-color: var(--color-bg);
    border-left: none;
}

#researchPanel.research-panel-fullscreen .panel-content {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-8) var(--space-6);
}

/* Ensure translate button is visible in fullscreen mode */
#researchPanel.research-panel-fullscreen .translate-btn.visible {
    display: flex !important;
    position: fixed;
    top: var(--space-5);
    right: calc(var(--space-5) + 52px);
}

.research-panel-text-only .research-metadata {
    display: none;
}

.research-panel-text-only .research-full-text {
    display: block;
}

.research-panel-text-only .panel-header {
    margin-bottom: var(--space-6);
    border-bottom: 1px solid var(--color-line);
    padding-bottom: var(--space-5);
}

.research-text-content {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.7;
    color: var(--color-text-dim);
}

/* Styling for the full research text */
.research-text-content h3 {
    font-family: var(--font-sans);
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
    margin-top: var(--space-6);
    margin-bottom: var(--space-4);
    letter-spacing: -0.3px;
}

.research-text-content h4 {
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    margin-top: var(--space-5);
    margin-bottom: var(--space-3);
}

.research-text-content p {
    margin-bottom: var(--space-5);
    text-align: justify;
}

.research-text-content em,
.research-text-content i {
    font-style: italic;
    color: rgba(255, 255, 255, 0.8);
}

.research-text-content strong,
.research-text-content b {
    font-weight: 600;
    color: var(--color-text);
}

.research-text-content blockquote {
    border-left: 3px solid var(--color-line);
    padding-left: var(--space-5);
    margin: var(--space-6) 0;
    font-style: italic;
    color: rgba(255, 255, 255, 0.7);
}

.research-text-content ul,
.research-text-content ol {
    margin-left: var(--space-6);
    margin-bottom: var(--space-5);
}

.research-text-content li {
    margin-bottom: var(--space-3);
}

.research-text-content a {
    color: var(--color-text);
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.3);
    transition: all var(--transition);
}

.research-text-content a:hover {
    text-decoration-color: var(--color-text);
}

/* ===========================
   Bio Panel
   =========================== */
.bio-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 480px;
    height: 100vh;
    background-color: var(--color-bg-alt);
    border-left: 1px solid var(--color-line);
    z-index: 1000;
    overflow-y: auto;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.bio-panel.active {
    right: 0;
}

/* ===========================
   Overlay
   =========================== */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* ===========================
   Footer
   =========================== */
.footer {
    display: none; /* Ocultar footer para maximizar espacio en viewport */
}

.footer-text {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.5px;
    color: var(--color-text-subtle);
    text-align: center;
}

/* ===========================
   Loading
   =========================== */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-bar {
    width: 200px;
    height: 1px;
    background-color: var(--color-line);
    position: relative;
    overflow: hidden;
}

.loading-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    background-color: var(--color-text);
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(300%);
    }
}

/* ===========================
   Mobile Timeline View - Forensic Architecture Style
   =========================== */
.mobile-timeline {
    width: 100%;
    max-width: 100vw;
    padding: 0;
    display: none; /* Hidden by default, shown in mobile JS */
    overflow-x: hidden;
}

/* Filtros Mobile - Forensic Architecture Style */
.mobile-filters {
    position: sticky;
    top: 60px;
    z-index: 50;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-line);
    border-top: 1px solid var(--color-line);
}

.filter-section {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-line);
}

.filter-section:last-child {
    border-bottom: none;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}

.filter-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 1.2px;
    text-transform: uppercase;
    display: block;
    -webkit-font-smoothing: antialiased;
}

.filter-count {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.65);
    letter-spacing: 0.5px;
    -webkit-font-smoothing: antialiased;
}

.year-filters,
.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.year-filter-btn,
.category-filter-btn {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.65);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 5px 10px;
    cursor: pointer;
    letter-spacing: 0.5px;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    display: inline-block;
}

.year-filter-btn.active,
.year-filter-btn:active {
    border-color: #FFFFFF;
    background-color: #FFFFFF;
    color: #0a0a0a;
}

.year-filter-btn.all {
    border-color: rgba(255, 255, 255, 0.2);
    font-weight: 500;
}

.year-filter-btn.all.active {
    background-color: #ff0000;
    color: #FFFFFF;
    border-color: #ff0000;
}

/* Stats bar - Forensic Architecture data style */
.filter-stats {
    padding: var(--space-3) var(--space-4);
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
    position: relative;
}

/* Línea vertical separadora */
.filter-stats::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 25%;
    bottom: 25%;
    width: 1px;
    background: rgba(255, 255, 255, 0.08);
}

.stat-item {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.stat-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 15px;
    font-weight: 500;
    color: #FFFFFF;
    letter-spacing: 0.5px;
    -webkit-font-smoothing: antialiased;
}

.stat-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 1px;
    text-transform: uppercase;
    -webkit-font-smoothing: antialiased;
}

/* Timeline content con padding */
.timeline-content {
    padding: var(--space-4) var(--space-4) var(--space-6) var(--space-4);
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

.timeline-year-block {
    margin-bottom: var(--space-7);
    width: 100%;
    overflow-x: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.timeline-year-block.collapsed {
    max-height: 0;
    margin-bottom: 0;
    opacity: 0;
    overflow: hidden;
}

.timeline-year-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    width: 100%;
    overflow: hidden;
    transition: all 0.2s ease;
}

.timeline-year-header:active {
    opacity: 0.7;
}

.timeline-year-header:active .timeline-year-label {
    color: #ff0000;
}

.timeline-year-line {
    flex: 1;
    min-width: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    position: relative;
}

/* Detalle técnico FA - pequeño marcador en la línea */
.timeline-year-line::before {
    content: '';
    position: absolute;
    left: 0;
    top: -2px;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
}

.timeline-year-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: #FFFFFF;
    min-width: 50px;
    max-width: 50px;
    text-align: right;
    flex-shrink: 0;
    white-space: nowrap;
    display: block;
    -webkit-font-smoothing: antialiased;
}

.timeline-projects-grid {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
    width: 100%;
    overflow: visible;
}

.timeline-project-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    background-color: #0a0a0a;
    cursor: pointer;
    min-height: 56px;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    max-height: 56px;
}

.timeline-project-row.expanded {
    max-height: 300px;
    background-color: rgba(10, 10, 10, 0.98);
}

.timeline-project-row.expanded .timeline-project-content {
    padding: 20px 12px !important;
}

.timeline-project-row.expanded .project-full-description {
    max-height: 200px;
    opacity: 1;
    margin-top: 12px;
}

.timeline-project-row:active {
    background-color: #ff0000;
}

.timeline-project-row:active .timeline-project-title {
    color: #FFFFFF;
}

.timeline-project-row:active .timeline-project-meta {
    color: rgba(255, 255, 255, 0.8);
}

.timeline-project-row:active .timeline-project-index {
    color: rgba(255, 255, 255, 0.6);
}

.timeline-project-index {
    font-family: -apple-system, BlinkMacSystemFont, 'IBM Plex Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.35);
    text-align: center;
    letter-spacing: 0.8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    flex-shrink: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.timeline-category-bar {
    width: 3px;
    min-width: 3px;
    flex-shrink: 0;
    align-self: stretch;
    display: block;
}

.timeline-project-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.timeline-project-title {
    font-family: -apple-system, BlinkMacSystemFont, 'IBM Plex Sans', sans-serif;
    font-size: 15px;
    font-weight: 400;
    color: #FFFFFF;
    line-height: 1.4;
    letter-spacing: 0.1px;
    margin: 0 0 6px 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.timeline-project-meta {
    font-family: -apple-system, BlinkMacSystemFont, 'IBM Plex Mono', monospace;
    font-size: 10px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.project-full-description {
    font-family: -apple-system, BlinkMacSystemFont, 'IBM Plex Sans', sans-serif;
    font-size: 13px;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.6;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.timeline-project-arrow {
    width: 24px;
    min-width: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.4;
}

.timeline-project-arrow svg {
    width: 12px;
    height: 12px;
    stroke: rgba(255, 255, 255, 0.65);
    stroke-width: 1.5;
}

/* ===========================
   Responsive Design
   =========================== */

/* Tablets */
@media (max-width: 1024px) and (min-width: 768px) {
    .header {
        padding: var(--space-4) var(--space-5);
    }

    .main-container {
        margin-top: 85px;
        padding: var(--space-5) 0;
    }

    .sankey-container {
        min-height: 700px;
        padding: var(--space-5) var(--space-4);
    }

    .project-panel {
        max-width: 420px;
    }

    .panel-content {
        padding: var(--space-6) var(--space-5);
    }

    .panel-image {
        max-height: 240px;
    }

    /* Adjust translate button position for tablet */
    .translate-btn {
        top: var(--space-5);
        right: calc(var(--space-5) + 90px);
    }
}

/* Mobile Mediano (480px-767px) - CON SCROLL vertical para Timeline */
@media (max-width: 767px) and (min-width: 480px) {
    :root {
        --space-5: 18px;
        --space-6: 22px;
        --space-7: 28px;
    }

    body {
        overflow-x: hidden;
        overflow-y: scroll;
        height: 100vh;
        width: 100vw;
        position: relative;
    }

    .main-container {
        overflow-y: visible;
        overflow-x: hidden;
        min-height: auto;
        height: auto;
        width: 100%;
        max-width: 100vw;
    }

    .sankey-container {
        overflow: visible;
        height: auto;
        width: 100%;
        max-width: 100vw;
    }

    .header-title {
        font-size: 10px;
        letter-spacing: 0.35px;
    }

    .header-subtitle {
        font-size: 10px;
    }

    .year-label {
        font-size: 8px;
    }

    .project-label {
        font-size: 6px;
    }

    .category-label {
        font-size: 8px;
        font-weight: 500;
    }

    .panel-content {
        padding: var(--space-5) var(--space-4);
    }

    .panel-title {
        font-size: 16px;
        line-height: 1.35;
    }

    .panel-description {
        font-size: 13px;
        line-height: 1.6;
    }

    .close-btn {
        width: 32px;
        height: 32px;
        top: var(--space-3);
        right: var(--space-3);
    }
}

/* Mobile Pequeño (<480px) - CON SCROLL vertical para Timeline */
@media (max-width: 479px) {
    :root {
        --space-5: 16px;
        --space-6: 20px;
        --space-7: 24px;
    }

    body {
        overflow-x: hidden;
        overflow-y: scroll;
        height: 100vh;
        width: 100vw;
        position: relative;
    }

    .main-container {
        overflow-y: visible;
        overflow-x: hidden;
        min-height: auto;
        height: auto;
        width: 100%;
        max-width: 100vw;
    }

    .sankey-container {
        overflow: visible;
        height: auto;
        width: 100%;
        max-width: 100vw;
    }

    .timeline-year-label {
        font-size: 12px;
        min-width: 45px;
        max-width: 45px;
    }

    .timeline-project-title {
        font-size: 12px;
    }

    .timeline-project-meta {
        font-size: 8px;
    }

    .mobile-filters {
        top: 60px;
    }

    .filter-label {
        font-size: 8px;
    }

    .year-filter-btn,
    .category-filter-btn {
        font-size: 9px;
        padding: 4px 8px;
    }

    .stat-value {
        font-size: 13px;
    }

    .stat-label {
        font-size: 7px;
    }

    .header-title {
        font-size: 10px;
        letter-spacing: 0.3px;
        font-weight: 500;
    }

    .header-subtitle {
        font-size: 9px;
        line-height: 1.3;
    }

    .year-label {
        font-size: 7px;
        font-weight: 500;
    }

    .project-label {
        font-size: 6px;
    }

    .category-label {
        font-size: 7px;
        font-weight: 500;
    }

    .panel-content {
        padding: var(--space-5) var(--space-4);
    }

    .panel-title {
        font-size: 15px;
        line-height: 1.3;
        margin-bottom: var(--space-3);
    }

    .panel-description {
        font-size: 12px;
        line-height: 1.6;
    }

    .panel-meta {
        font-size: 8px;
    }

    .tech-item {
        font-size: 8px;
        padding: 5px 8px;
    }

    .close-btn {
        width: 30px;
        height: 30px;
        top: var(--space-3);
        right: var(--space-3);
        font-size: 16px;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .main-container {
        margin-top: 60px;
    }

    .sankey-container {
        min-height: 400px;
    }

    .panel-image {
        max-height: 150px;
    }
}

/* Touch optimizations para mobile */
@media (max-width: 767px) {
    /* Área de toque más grande para elementos interactivos */
    .project-node {
        cursor: pointer;
        touch-action: manipulation;
    }

    .close-btn {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .panel-link {
        touch-action: manipulation;
        min-height: 44px; /* iOS mínimo recomendado */
        display: inline-flex;
        align-items: center;
    }

    /* Mejor scroll en mobile */
    body {
        -webkit-overflow-scrolling: touch;
    }

    /* Prevenir zoom en inputs */
    input, select, textarea {
        font-size: 16px;
    }
}

/* ===========================
   Scrollbar personalizada
   =========================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===========================
   Selección de texto
   =========================== */
::selection {
    background-color: var(--color-salmon);
    color: var(--color-bg);
}

::-moz-selection {
    background-color: var(--color-salmon);
    color: var(--color-bg);
}
