/* Reseteo básico */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', sans-serif;
    color: #333;
    line-height: 1.6;
    background-color: #fff;
}

/* Tipografías */
h1, h2, h3 {
    font-family: 'Playfair Display', serif;
    color: #000;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Navegación */
nav {
    display: flex;
    justify-content: flex-start; /* keep logo + lang on the left, links will float right */
    align-items: center;
    padding: 20px 50px;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1000;
    border-bottom: 1px solid #eee;
}

.logo {
    font-weight: 700;
    letter-spacing: 2px;
    font-size: 1.2rem;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 20px;
    margin-left: auto; /* push links to the right */
}

.nav-links li a {
    font-size: 0.9rem;
    text-transform: uppercase;
    transition: color 0.3s;
}

.nav-links li a:hover {
    color: #777;
}

/* Header / Portada */
header {
    text-align: center;
    padding: 60px 20px;
    background-color: #fafafa;
}

header h1 {
    font-size: 4rem;
    margin-bottom: 10px;
    letter-spacing: 5px;
}

.dates {
    font-size: 1.5rem;
    font-weight: 300;
    margin-bottom: 30px;
}

.quote {
    font-style: italic;
    color: #555;
    margin-bottom: 40px;
    font-family: 'Playfair Display', serif;
}

.hero-image img {
    max-width: 100%;
    height: auto;
    max-height: 85vh; /* match Paint/Sculpture images (El llanto del DANA) */
    object-fit: contain; /* avoid cropping */
    border-radius: 5px;
    display: block;
    margin: 0 auto;
}

/* Contenedor General */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 60px 20px;
}

/* Intro */
#intro {
    text-align: center;
    max-width: 800px;
}

#intro h2 {
    font-size: 3rem;
    margin-bottom: 30px;
}

.bio-text {
    font-size: 1.1rem;
    text-align: justify;
}

/* Secciones de Galería */
.gallery-section {
    padding: 80px 50px;
    border-top: 1px solid #eee;
}

.section-title {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.intro-desc {
    margin-bottom: 40px;
    font-style: italic;
    color: #666;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 40px;
    margin-top: 30px;
}

/* Larger images for Paint and Sculpture sections */
#paint .gallery-grid,
#sculpture .gallery-grid {
    /* make columns larger so artworks display bigger on wider viewports */
    grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
    gap: 48px;
}

#paint .gallery-grid .art-piece img,
#sculpture .gallery-grid .art-piece img {
    /* allow even taller images in these sections */
    max-height: 85vh; /* allow taller images */
}

.art-piece {
    display: flex;
    flex-direction: column;
    min-height: 0; /* allow children to grow and avoid unexpected clipping in grids */
}

.art-piece img {
    width: 100%;
    height: auto; /* preserve aspect ratio and avoid cropping */
    max-height: 60vh;
    object-fit: contain;
    background: #fafafa; /* subtle background to frame images */
    padding: 8px;
    margin-bottom: 15px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-radius: 6px;
}

/* Prevent upscaling on large viewports when source images are limited in pixel width.
   The originals in `imagenes/originals/thumbs` are ~900px wide; cap renders to that width
   on wider screens so the browser doesn't upscale and produce blur. */
@media (min-width: 769px) {
    .art-piece img, .hero-image img { max-width: 900px; margin-left: auto; margin-right: auto; }
}

.art-piece img:hover {
    transform: scale(1.02);
}

/* Hover animations for pointer devices (mouse) - avoid on touch screens */
@media (hover: hover) and (pointer: fine) {
    .art-piece img {
        transition: transform 280ms cubic-bezier(.2,.9,.2,1), box-shadow 280ms ease;
        will-change: transform, box-shadow;
    }

    .art-piece img:hover,
    .art-piece img:focus {
        transform: translateY(-6px) scale(1.04);
        box-shadow: 0 18px 40px rgba(0,0,0,0.12);
    }

    .art-piece img:active {
        transform: translateY(-2px) scale(1.02);
        box-shadow: 0 10px 20px rgba(0,0,0,0.08);
    }
}

/* Respect user motion preferences */
@media (prefers-reduced-motion: reduce) {
    .art-piece img,
    .art-piece img:hover,
    .art-piece img:focus,
    .art-piece img:active {
        transition: none !important;
        transform: none !important;
        box-shadow: none !important;
    }
}

/* Keyboard focus styling for accessibility (use :focus-visible to avoid
   showing when clicked by mouse). This applies on all devices. */
.art-piece img:focus-visible {
    outline: 3px solid rgba(17,17,17,0.9);
    outline-offset: 6px;
    transform: translateY(-6px) scale(1.04);
    box-shadow: 0 20px 48px rgba(0,0,0,0.14);
}

/* Provide a subtle focus ring on the art-piece container as well */
.art-piece:focus-within {
    /* keep layout stable while indicating focus */
    box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}

.art-piece h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.art-piece p {
    font-size: 0.9rem;
    color: #555;
}

/* Ensure section texts are fully visible and wrap correctly in all languages */
.gallery-grid .art-piece h3,
.gallery-grid .art-piece p,
.bio-text,
.intro-desc,
.section-title,
footer p,
footer .info-item p {
    overflow: visible !important;
    white-space: normal !important;
    word-break: break-word !important;
}

/* Ensure gallery descriptions show full text */
.gallery-grid .art-piece p {
    display: block;
    overflow: visible;
    text-overflow: clip;
    max-height: none;
}

/* Footer */
footer {
    background-color: #111;
    color: #fff;
    text-align: center;
    padding: 80px 20px;
}

footer h2 {
    color: #fff;
    font-size: 3rem;
    margin-bottom: 20px;
}

.contact-info {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 40px;
    margin: 50px 0;
}

.info-item strong {
    display: block;
    margin-bottom: 5px;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

/* Ensure footer contact text uses a system font that contains accented glyphs */
.contact-info .info-item p {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Instagram link: icon + text alignment */
.contact-info .info-item a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: inherit;
}

.contact-info .info-item a svg {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    fill: currentColor;
}

/* Fancy hover: Instagram-like gradient and subtle lift */
.contact-info .info-item a {
    padding: 6px 8px;
    border-radius: 8px;
    transition: background 240ms ease, transform 160ms ease, color 240ms ease;
}

.contact-info .info-item a svg {
    transition: transform 160ms ease, filter 240ms ease;
}

.contact-info .info-item a:hover {
    background: radial-gradient(circle at 30% 30%, #fdf497 0%, #fd5949 30%, #d6249f 60%, #285AEB 100%);
    color: white;
    transform: translateY(-3px);
    text-decoration: none;
}

.contact-info .info-item a:hover svg {
    filter: brightness(0) invert(1);
    transform: translateY(-1px);
}

.copyright {
    font-size: 0.8rem;
    color: #777;
    margin-top: 40px;
}

/* Móvil */
@media (max-width: 768px) {
    header h1 { font-size: 2.5rem; }
    .nav-links { display: none; } /* Simple mobile fix */
    .gallery-grid { grid-template-columns: 1fr; }
    .contact-info { flex-direction: column; }
    /* Restore previous mobile hero sizing so iPhone layout remains unchanged */
    .hero-image img { max-height: 60vh; }
}

/* Mobile - prevent horizontal scroll on small devices and center images */
@media (max-width: 768px) {
    /* Prevent accidental horizontal scroll on iPhone due to large paddings */
    html, body { overflow-x: hidden; -webkit-overflow-scrolling: touch; }

    /* Reduce large paddings that could cause overflow */
    nav { padding: 12px 14px; }
    .gallery-section { padding: 24px 14px; }
    .container { padding: 24px 14px; }

    /* Center artwork content and make images fit without creating horizontal scroll */
    .art-piece { align-items: center; text-align: center; }
    .art-piece img {
        /* More conservative max width to avoid overflow while keeping images centered */
        width: auto; /* keep natural aspect ratio */
        max-width: 92%; /* leave a small gutter on each side */
        height: auto;
        margin: 0 auto;
        padding: 6px; /* slightly smaller padding on mobile */
        box-sizing: border-box;
        display: block;
    }

    /* Ensure hero image remains centered */
    .hero-image { display: flex; justify-content: center; }
    .hero-image img { margin: 0 auto; }

    /* Ensure Paint and Sculpture grids don't use large min-width columns on small screens */
    #paint .gallery-grid,
    #sculpture .gallery-grid {
        grid-template-columns: 1fr !important;
    }

    /* Prevent any grid children from causing overflow by allowing them to shrink */
    .gallery-grid, .gallery-grid > * { max-width: 100%; box-sizing: border-box; }
    .art-piece { min-width: 0; }
    .gallery-grid { overflow-x: hidden; }

    /* Additional defensive rules to prevent any overflow caused by large text, transforms or elements */
    html, body { width: 100%; }
    img, picture, svg, video { max-width: 100%; height: auto; display: block; }
    /* Allow the main headings to wrap and not push layout wider */
    header h1 { white-space: normal; word-break: break-word; max-width: 92%; margin-left: auto; margin-right: auto; }
    /* Ensure containers respect box sizing and don't overflow */
    .container, .gallery-section, nav, header, main { box-sizing: border-box; max-width: 100%; }
}

/* Language switcher */
.lang-switcher {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    margin-left: 16px;
}
.lang-switcher a {
    font-size: 0.8rem;
    padding: 6px 8px;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    border: 1px solid transparent;
    transition: background 160ms ease, color 160ms ease, transform 120ms ease;
}
.lang-switcher a:hover {
    background: #f3f3f3;
    transform: translateY(-1px);
}
.lang-switcher a.active {
    background: #111;
    color: #fff;
    border-color: #111;
}

@media (max-width: 768px) {
    .lang-switcher { gap: 6px; font-size: 0.75rem; margin-left: 8px; }
}

/* Language redirect consent banner */
.lang-banner {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 16px;
    background: rgba(17,17,17,0.95);
    color: #fff;
    padding: 14px 16px;
    border-radius: 8px;
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    z-index: 2000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.lang-banner p { margin: 0; font-size: 0.95rem; }
.lang-banner .actions { display: flex; gap: 8px; }
.lang-banner button {
    background: #fff;
    color: #111;
    border: none;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
}
.lang-banner button.secondary {
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.18);
}

@media (max-width: 480px) {
    .lang-banner { flex-direction: column; align-items: stretch; gap: 8px; }
    .lang-banner .actions { justify-content: flex-end; }
}

/* Staggered gallery reveal animation (Option B) */

.art-piece {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 320ms cubic-bezier(.2,.9,.2,1), transform 320ms cubic-bezier(.2,.9,.2,1);
}
.loaded .art-piece {
    opacity: 1;
    transform: none;
}

/* Slightly delay hero image for a pleasant entrance */
.hero-image { opacity: 0; transform: translateY(6px); transition: opacity 320ms ease, transform 320ms ease; }
.loaded .hero-image { opacity: 1; transform: none; }

/* Accessibility: respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .art-piece, .hero-image {
        transition: none !important;
        transform: none !important;
        opacity: 1 !important;
    }
}
