/* ==========================================================================
   VARIABLES (paleta original, sin cambios)
   ========================================================================== */
:root {
    --vino-oscuro: #4A1519;
    --vino-medio: #8C3A36;
    --verde-oliva: #5B6346;
    --rosa-grisaceo: #E3D7D0;

    --azul-titulo: #2C4A5E;
    --crema: #F4F1EA;
    --salvia: #A3AB8E;
    --blanco: #FFFFFF;

    --fuente-titulos: 'Inter', sans-serif;
    --fuente-editorial: 'Cormorant Garamond', serif;
    --fuente-logo: 'Montserrat', sans-serif;

    --marco: 12px;
    --gutter: 16px;

    --degradado-marco: linear-gradient(to right,
        #4A1519 0%,
        #45161a 35%,
        #683238 50%,
        #A89691 65%,
        #F4F1EA 100%
    );
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    background: linear-gradient(to bottom,
        var(--crema) 0%,
        var(--rosa-grisaceo) 45%,
        var(--salvia) 100%
    );
    background-attachment: scroll;
    color: var(--vino-oscuro);
    font-family: var(--fuente-titulos);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 0 var(--gutter) 24px var(--gutter);
}

img { max-width: 100%; }

/* ==========================================================================
   ACCESIBILIDAD
   ========================================================================== */
.skip-link {
    position: fixed;
    top: -100px;
    left: calc(var(--marco) + 8px);
    z-index: 100001;
    background: var(--vino-oscuro);
    color: var(--blanco);
    padding: 0.6rem 1rem;
    border-radius: 4px;
    font-size: 0.85rem;
    text-decoration: none;
}

.skip-link:focus { top: calc(var(--marco) + 8px); }

:focus-visible {
    outline: 2px solid var(--vino-medio);
    outline-offset: 3px;
}

.site-header :focus-visible,
.btn-cerrar:focus-visible {
    outline-color: var(--blanco);
}

/* ==========================================================================
   MARCO PERIMETRAL SEGURO PARA CELULARES
   ========================================================================== */
.linea-marco {
    position: fixed;
    z-index: 999;
    pointer-events: none;
    background: var(--degradado-marco);
}

.marco-superior { top: 0; left: 0; width: 100%; height: var(--marco); }
.marco-inferior { bottom: 0; left: 0; width: 100%; height: var(--marco); }
.marco-izquierdo { top: 0; left: 0; width: var(--marco); height: 100%; background: var(--vino-oscuro); }
.marco-derecho { top: 0; right: 0; width: var(--marco); height: 100%; background: var(--blanco); }

/* ==========================================================================
   CABECERA EN DEGRADÉ ORIGINAL
   ========================================================================== */
.site-header {
    width: calc(100% + (var(--gutter) * 2));
    margin: 0 calc(var(--gutter) * -1) 2.5rem;
    padding: 2rem 1.5rem 1.2rem;
    position: relative;
    z-index: 100;
    background: var(--degradado-marco);
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
}

.sigla-cib {
    font-size: 4rem;
    font-weight: 900;
    color: var(--blanco);
    line-height: 1;
    letter-spacing: -0.04em;
    font-family: var(--fuente-logo);
}

.texto-titulo {
    display: flex;
    flex-direction: column;
    font-size: 1rem;
    font-weight: 400;
}

.sub-carpinelo {
    font-size: 1.3rem;
    font-weight: 900;
    color: var(--blanco);
    line-height: 1;
    letter-spacing: 0.05em;
    margin-bottom: 0.1rem;
    font-family: var(--fuente-logo);
}

.titulo-principal {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--blanco);
    line-height: 1.1;
    letter-spacing: 0.02em;
    opacity: 0.9;
}

.main-nav {
    display: flex;
    gap: 1.2rem;
    margin-top: 0.8rem;
}

.nav-link {
    color: var(--blanco);
    text-decoration: none;
    font-size: 0.9rem;
    padding-bottom: 2px;
    border-bottom: 2px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.nav-link:hover { color: var(--rosa-grisaceo); }

.nav-link.active {
    color: var(--rosa-grisaceo);
    border-bottom-color: var(--rosa-grisaceo);
}

/* ==========================================================================
   ESTRUCTURA Y GRILLAS
   ========================================================================== */
.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding-bottom: 4rem;
}

.seccion-proyecto {
    margin-bottom: 4.5rem;
    scroll-margin-top: 1.5rem;
}

.titulo-azul {
    font-family: var(--fuente-titulos);
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--azul-titulo);
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(44, 74, 94, 0.2);
    padding-bottom: 0.4rem;
}

.bloque-texto { max-width: 800px; }

.lead-paragraph {
    font-family: var(--fuente-editorial);
    font-size: 1.4rem;
    color: var(--vino-oscuro);
    line-height: 1.45;
    margin-bottom: 1.5rem;
    text-wrap: pretty;
}

.texto-acrostico p {
    font-size: 0.95rem;
    margin-bottom: 0.4rem;
    color: var(--vino-medio);
}

.grid-editorial {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
    gap: 1.5rem;
}

.grid-editorial-grandes {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 768px) {
    .grid-editorial-grandes { grid-template-columns: repeat(2, 1fr); }
}

/* ==========================================================================
   CAJAS Y CONTROL DE IMÁGENES (no se salen del cuadro)
   ========================================================================== */
.card-item {
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 1rem;
    border-radius: 4px;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    overflow: hidden;
}

.image-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: 100%;
}

.image-wrapper2 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 110px;
}

/* Texto a la izquierda y acróstico pequeño a la derecha en pantallas anchas */
@media (min-width: 768px) {
    .bloque-texto {
        display: grid;
        grid-template-columns: 1fr 110px;
        gap: 2rem;
        align-items: center;
    }

    .bloque-texto .lead-paragraph { margin-bottom: 0; }
}

/* Imagen principal */
.seccion-hero { margin-bottom: 3.5rem; }

.hero {
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 0.6rem 0.6rem 0.8rem;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.hero-image {
    max-height: 78vh;
    max-height: 78dvh;
    object-fit: cover;
}

.main-image {
    width: 100%;
    height: auto;
    max-width: 100%;
    object-fit: contain;
    border-radius: 2px;
    display: block;
}

/* Las imágenes con JS se pueden ampliar */
.js .card-item .main-image,
.js .hero .main-image,
.js .image-wrapper2 .main-image {
    cursor: zoom-in;
    transition: opacity 0.2s ease;
}

.js .card-item .main-image:hover,
.js .hero .main-image:hover,
.js .image-wrapper2 .main-image:hover { opacity: 0.92; }

.placeholder-imagen, .placeholder-imagen-tecnica, .placeholder-render {
    width: 100%;
    background: rgba(74, 21, 25, 0.05);
    border: 1px dashed var(--vino-medio);
    color: var(--vino-oscuro);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 0.95rem;
    text-align: center;
    padding: 1rem;
}

.placeholder-imagen { aspect-ratio: 4 / 3; }
.placeholder-imagen-tecnica { aspect-ratio: 16 / 9; }
.placeholder-render { aspect-ratio: 16 / 10; background: rgba(91, 99, 70, 0.08); }

.cota { font-size: 0.8rem; opacity: 0.7; font-weight: 400; margin-top: 0.2rem; }

.image-caption {
    display: block;
    font-size: 0.75rem;
    color: var(--vino-medio);
    font-style: italic;
}

/* Animación de aparición: solo si hay JS (sin JS todo se ve) */
.js .reveal {
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.js .reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================================================
   VISOR COMPACTO Y ZOOM NATIVO
   ========================================================================== */
.visor-modal {
    border: none;
    background: rgba(42, 21, 25, 0.85);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    width: 100vw;
    height: 100vh;
    width: 100dvw;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100vh;
    max-width: 100dvw;
    max-height: 100dvh;
    padding: 0;
    margin: 0;
}

.visor-modal::backdrop { background: transparent; }

.visor-modal[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-container {
    width: 100%;
    height: 100%;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pinch-zoom pan-x pan-y;
    -webkit-overflow-scrolling: touch;
}

.visor-modal #imagen-expandida {
    max-width: 95vw;
    max-height: 90vh;
    max-height: 90dvh;
    object-fit: contain;
    touch-action: manipulation;
}

.btn-cerrar {
    position: fixed;
    top: max(20px, env(safe-area-inset-top));
    right: max(20px, env(safe-area-inset-right));
    background: var(--vino-oscuro);
    color: var(--blanco);
    border: 2px solid var(--blanco);
    font-size: 1.8rem;
    font-weight: 700;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    z-index: 99999;
    line-height: 1;
}

/* Bloquea el scroll del fondo sin saltar al inicio de la página */
body.modal-abierto { overflow: hidden; }

/* ==========================================================================
   INTRODUCCIÓN (vino sólido). Se oculta sola por CSS: nunca bloquea la página
   ========================================================================== */
.intro-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background-color: var(--vino-oscuro);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: introSalida 1s cubic-bezier(0.85, 0, 0.15, 1) 2.2s forwards;
}

.intro-content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.intro-logo {
    font-family: var(--fuente-editorial);
    font-size: 3.8rem;
    font-weight: 400;
    font-style: italic;
    color: var(--blanco);
    letter-spacing: 0.1em;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    text-align: center;
    animation: scaleBranding 2s ease-out forwards;
}

.intro-subtitulo {
    font-family: var(--fuente-titulos);
    font-size: 0.95rem;
    font-weight: 400;
    font-style: normal;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    opacity: 0.85;
    color: var(--blanco);
}

.intro-subtitulo2 {
    font-family: var(--fuente-titulos);
    font-size: 0.5rem;
    font-weight: 500;
    font-style: italic;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    opacity: 0.85;
    color: var(--blanco);
}

@keyframes scaleBranding {
    from { transform: scale(0.95); opacity: 0; filter: blur(4px); }
    to { transform: scale(1); opacity: 1; filter: blur(0); }
}

@keyframes introSalida {
    from { transform: translateY(0); visibility: visible; }
    to { transform: translateY(-100%); visibility: hidden; }
}

@media (max-width: 768px) {
    .intro-logo { font-size: 2.8rem; }
    .intro-subtitulo { font-size: 0.7rem; }
}

/* ==========================================================================
   FONDO FIJO
   ========================================================================== */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image: url('fondo.png');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    opacity: 0.35;
    pointer-events: none;
}

/* ==========================================================================
   VIDEO (YouTube)
   ========================================================================== */
.video-box { max-width: 900px; }

.video-marco {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: rgba(91, 99, 70, 0.08);
    border: 1px dashed var(--vino-medio);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-marco.vertical {
    aspect-ratio: 9 / 16;
    max-width: 360px;
    max-height: 80vh;
    max-height: 80dvh;
    margin: 0 auto;
}

.video-marco.con-video {
    border: 0;
    background: var(--vino-oscuro);
}

.video-respaldo { margin-top: 0.6rem; font-size: 0.8rem; }

.video-respaldo a {
    color: var(--vino-medio);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.video-respaldo a:hover { color: var(--vino-oscuro); }

.video-vacio {
    color: var(--vino-oscuro);
    font-weight: 500;
    font-size: 0.95rem;
    text-align: center;
    padding: 1rem;
}

.video-marco iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ==========================================================================
   PIE DE PÁGINA
   ========================================================================== */
.site-footer {
    padding: 2rem 0;
    text-align: center;
    border-top: 1px solid rgba(74, 21, 25, 0.1);
}

.site-footer p { font-size: 0.75rem; color: var(--vino-medio); }

/* ==========================================================================
   MOVIMIENTO REDUCIDO
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    .intro-overlay,
    .intro-logo { animation-duration: 0.01s; animation-delay: 0s; }

    .js .reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }
}
