:root {
    --bg-color: #f1e7bf;
    /* More intense warm yellow */
    --text-primary: #000;
    --text-secondary: #555;
    --accent: #d0c8a8;
    /* Adjusted accent to match deeper yellow */
    --highlight: #000;
    --sky-blue: #1b418a;
    --font-main: 'Inter', sans-serif;
    --font-mono: 'Space Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    height: 100vh;
    overflow-x: hidden;
    overflow-y: hidden; /* Home is active by default, so we hide scroll */
    display: flex;
    flex-direction: column;
}

/* Header Style */
.main-header {
    position: relative;
    z-index: 100;
    padding: 3rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--accent);
}

.logo {
    font-family: var(--font-mono);
    font-size: 5rem;
    /* Significant increase */
    letter-spacing: 1.2rem;
    font-weight: 400;
    line-height: 1;
}

.header-nav {
    display: flex;
    gap: 2rem;
    margin-top: 4.5rem;
}

.nav-link {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    /* Increased from 0.7rem */
    color: var(--text-secondary);
    text-decoration: none;
    transition: 0.3s;
}

.nav-link.active,
.nav-link:hover {
    color: var(--highlight);
}

/* Main Archive Container */
.archive-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    position: relative;
}

/* Project Strip (New Carousel) */
.project-strip {
    display: flex;
    padding: 1.5rem 5%;
    border-bottom: 1px solid var(--accent);
    gap: 4rem;
    overflow-x: auto;
    scrollbar-width: none;
    /* Hide scrollbar for clean look */
}

.project-strip::-webkit-scrollbar {
    display: none;
}

.project-item {
    min-width: 250px;
    cursor: pointer;
    opacity: 0.4;
    transition: 0.4s;
}

.project-item[data-id="l6"] {
    min-width: 120px; /* Closer for short titles */
}

.project-item.active,
.project-item:hover {
    opacity: 1;
    transform: translateY(-10px);
}

.item-index {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--highlight);
    margin-bottom: 0.5rem;
}

.item-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02rem;
    line-height: 1.2;
    white-space: normal;
    /* Allow wrapping */
    max-width: 220px;
    /* Force wrap if too long */
}

.item-preview {
    width: 100%;
    margin: 1rem 0;
    overflow: hidden;
    filter: grayscale(1) contrast(1.2);
    transition: 0.5s ease;
}

.project-item.active .item-preview,
.project-item:hover .item-preview {
    filter: grayscale(0) contrast(1);
}

.item-preview img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

.item-desc {
    font-size: 0.8rem;
    color: var(--sky-blue);
}

/* Scroll Hint */
.archive-header {
    display: flex;
    justify-content: flex-start;
    padding-top: 2rem;
}

.scroll-hint {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-secondary);
    letter-spacing: 0.1rem;
    opacity: 0.6;
    animation: pulseScroll 2s infinite ease-in-out;
}

@keyframes pulseScroll {
    0%, 100% { transform: translateX(0); opacity: 0.4; }
    50% { transform: translateX(5px); opacity: 1; }
}

/* Detail View Area */
.detail-view {
    flex: 1;
    display: flex;
    align-items: flex-start;
    padding: 4rem 5% 150px 5%; /* Bottom padding matches skyline + margin */
    overflow: visible;
}

.coord-tag {
    font-family: var(--font-mono);
    font-size: 1rem; /* Increased from 0.6rem */
    color: var(--sky-blue); /* Changed from accent to sky-blue for visibility */
    margin-bottom: 0.5rem;
    font-weight: 500;
}

#detail-title {
    font-size: 4rem;
    font-weight: 300;
    margin-bottom: 2rem;
    letter-spacing: -0.1rem;
}

#detail-body {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-secondary);
    max-width: 100%; /* Removed 600px restriction */
    /* No max-height here, use page scroll */
}

.project-text h4 {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--sky-blue) !important; /* Forced blue */
    letter-spacing: 0.2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.conceptual-para, .technical-para {
    margin-bottom: 1.5rem;
    max-width: 600px; /* Keep text readable while layout is wide */
}

.project-text h4 {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--accent);
    margin-top: 2rem;
    margin-bottom: 1rem;
    letter-spacing: 0.1em;
}

.conceptual-para em, .conclusion-para em {
    color: var(--text-primary);
}

.conclusion-para {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

/* Project Layout (Two Columns) */
.project-layout {
    display: flex;
    gap: 4rem;
    align-items: flex-start;
    width: 100%;
}

.project-text {
    flex: 1;
    min-width: 400px;
}

.project-media {
    flex: 1.5;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    /* Removed position: sticky to stop the scrolling effect */
}

.video-container {
    width: 100%;
    aspect-ratio: 16/9;
    background: transparent; /* Changed from #000 to avoid black borders */
    overflow: hidden;
    position: relative;
}

.video-container.natural-video {
    aspect-ratio: 2.35 / 1; /* Typical ultrawide ratio to hide baked-in bars */
}

.video-container.natural-video video {
    object-fit: cover; /* Zoom in to crop the bars */
}

.video-container.vertical-video {
    aspect-ratio: 9/16;
    width: auto;
    height: 750px; /* Match typical text block height */
    max-height: 80vh;
    margin: 0 auto;
}

.sintaxis-viewer {
    width: 100%;
    height: 600px; /* Much larger */
    background: #000;
    border: 1px solid var(--accent);
    cursor: crosshair;
    overflow: hidden;
    position: relative;
}

#sintaxis-bg-canvas {
    z-index: 0;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Restore contain to avoid any cropping */
}

.photo-grid-symmetric {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    width: 100%;
}

.photo-grid-symmetric img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    transition: transform 0.4s ease, filter 0.4s ease;
    cursor: pointer;
    border: 1px solid transparent;
}

.photo-grid-symmetric img:hover {
    transform: scale(1.02);
    border-color: var(--accent);
}

/* Around Layout for Sintaxis */
.around-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, auto);
    gap: 1rem;
    width: 100%;
}

.center-video {
    grid-column: 2 / span 2;
    grid-row: 1 / span 3;
    width: 100%;
    aspect-ratio: 9/16;
    max-height: 450px; /* Slightly smaller for better margins */
    justify-self: center;
    align-self: center; /* Center vertically in the grid */
    margin: 2rem 0; /* Add margin top and bottom */
    background: transparent;
}

.photo-grid-around {
    display: contents;
}

.photo-grid-around.grid-4 {
    grid-template-rows: repeat(2, 1fr);
}

.photo-grid-around.grid-4 img {
    aspect-ratio: 3/2;
}

.photo-grid-around img {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
    transition: transform 0.4s ease, border-color 0.4s ease;
    cursor: pointer;
    border: 1px solid transparent;
}

.photo-grid-around img:hover {
    transform: scale(1.05);
    border-color: var(--accent);
    z-index: 10;
}

/* Specific placements: 3 photos on the left, 3 on the right */
.photo-grid-around img:nth-child(1) { grid-column: 1; grid-row: 1; }
.photo-grid-around img:nth-child(2) { grid-column: 1; grid-row: 2; }
.photo-grid-around img:nth-child(3) { grid-column: 1; grid-row: 3; }
.photo-grid-around img:nth-child(4) { grid-column: 4; grid-row: 1; }
.photo-grid-around img:nth-child(5) { grid-column: 4; grid-row: 2; }
.photo-grid-around img:nth-child(6) { grid-column: 4; grid-row: 3; }

/* Lightbox Styles */
.lightbox {
    display: none;
    position: fixed;
    z-index: 1000;
    padding-top: 50px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.9);
    justify-content: center;
    align-items: center;
}

.lightbox-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 1000px;
    max-height: 80vh;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

.lightbox-prev, .lightbox-next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px;
    margin-top: -50px;
    color: white;
    font-weight: bold;
    font-size: 30px;
    transition: 0.6s ease;
    user-select: none;
    font-family: var(--font-mono);
}

.lightbox-next {
    right: 50px;
}

.lightbox-prev {
    left: 50px;
}

.lightbox-prev:hover, .lightbox-next:hover {
    color: var(--accent);
}

.media-carousel-horizontal {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

.media-carousel-horizontal img {
    height: 150px;
    width: auto;
    object-fit: cover;
    filter: grayscale(1);
    transition: 0.3s;
    cursor: pointer;
}

.media-carousel-horizontal img:hover {
    filter: grayscale(0);
}

/* Madrid Skyline: Subtle & Faithful Background */
.madrid-skyline {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    height: 120px;
    background-color: #1b418a;
    /* Deep rich blue from screenshot */
    opacity: 1;
    /* Increased opacity for foreground effect */
    z-index: 150;
    /* Foreground overlay */
    pointer-events: none;
    /* Don't block clicks */
    transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
    clip-path: polygon(0% 100%,
            2% 100%, 4% 75%, 6% 75%, 5% 100%,
            /* KIO */
            7% 100%, 9% 75%, 11% 75%, 10% 100%,
            /* KIO */
            15% 100%, 15% 40%, 16% 40%, 16% 42%, 17% 42%, 17% 40%, 18% 40%, 18% 100%,
            /* Cepsa */
            20% 100%, 20% 35%, 23% 35%, 23% 100%,
            /* PwC */
            25% 100%, 25% 30%, 26% 25%, 27% 30%, 27% 100%,
            /* Cristal */
            29% 100%, 29% 38%, 31% 38%, 31% 100%,
            /* Espacio */

            /* Pirulí Detail */
            50.5% 100%, 50.5% 25%,
            50.1% 25%, 50.1% 18%,
            50.75% 14%, 50.75% 5%,
            /* Needle */
            50.85% 5%, 50.85% 14%,
            51.5% 18%, 51.5% 25%,
            51.1% 25%, 51.1% 100%,

            /* New buildings extending to the right */
            58% 100%, 58% 65%, 60% 65%, 60% 100%,
            /* Mid-rise block */
            65% 100%, 65% 55%, 66% 55%, 66% 45%, 70% 45%, 70% 55%, 71% 55%, 71% 100%,
            /* Edificio España silhouette */
            78% 100%, 78% 50%, 82% 50%, 82% 100%,
            /* Torre Picasso silhouette */
            88% 100%, 88% 35%, 91% 35%, 91% 100%,
            /* Torre Caleido silhouette */
            94% 100%, 94% 80%, 95% 80%, 95% 100%,
            /* Small gap block */

            /* Edificio Carrión (Schweppes) */
            96% 100%, 96% 45%, 97.5% 45%, 97.5% 60%, 100% 60%,

            100% 100%, 100% 98%, 0% 98%);
}

/* Home View Styles */
.home-view {
    position: fixed;
    inset: 0;
    top: 100px;
    /* Below header */
    /* background removed to let skyline show through */
    z-index: 50;
    display: flex;
    padding: 0 5%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

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

.home-content {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 4rem; /* Reduced from 8rem to move closer to letters */
}

.statement-box {
    flex: 1;
    max-width: 600px;
}

.tag {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    border-left: 2px solid var(--highlight);
    padding-left: 1rem;
}

.statement-text {
    font-size: 1.2rem;
    font-weight: 300;
    line-height: 1.6;
    color: var(--text-primary);
    letter-spacing: -0.02rem;
}

.nostalgia-item {
    flex: 1.8; /* Significantly increased from 1.2 */
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-left: -18rem; /* Shifted even further left to overlap/move closer to text */
    margin-top: -50px;
}

.postal-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16/10; /* Slightly wider and more immersive */
    background: transparent;
    overflow: hidden;
    border: none !important;
    box-shadow: none !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.postal-frame canvas {
    transition: opacity 0.5s ease;
}

.postal-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.glitch-overlay {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0px, transparent 2px);
    pointer-events: none;
}

.postal-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-secondary);
    text-align: right;
}

/* Hide main container when home is active */
.archive-container.hidden {
    opacity: 0;
    pointer-events: none;
}

.archive-container {
    transition: opacity 0.6s ease;
}

/* Contact View */
.contact-view {
    flex: 1;
    display: none; /* Changed from fixed to flex-flow */
    justify-content: center;
    align-items: center;
    padding: 4rem 5%;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.contact-view.active {
    display: flex;
    opacity: 1;
}

.contact-container {
    text-align: center;
}

.contact-methods {
    display: flex;
    gap: 6rem;
    justify-content: center;
    align-items: center;
}

.contact-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.contact-item:hover {
    transform: scale(1.1);
    color: var(--sky-blue);
}

.contact-icon {
    width: 80px;
    height: 80px;
    stroke: currentColor;
    transition: 0.3s;
}

.contact-label {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.2rem;
    opacity: 0.7;
}

.hidden {
    display: none !important;
}

/* Info View */
.info-view {
    flex: 1;
    display: none;
    align-items: center;
    padding: 2rem 5%;
    overflow-y: hidden;
}

.info-view.active {
    display: flex;
}

.info-layout {
    display: flex;
    gap: 5rem;
    align-items: center;
    width: 100%;
    max-width: 1200px;
}

.info-text {
    flex: 1.8;
    max-width: 1000px;
    transform: translateY(-30px);
}

.info-bio {
    font-size: 1.15rem;
    line-height: 1.9;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.info-bio strong {
    color: var(--text-primary);
    font-weight: 600;
}

.info-point-cloud {
    flex: 2;
    height: 65vh;
    min-height: 400px;
    max-height: 700px;
    position: relative;
    border-radius: 8px;
    overflow: visible;
    transform: translate(120px, -80px);
}

.info-point-cloud canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}