:root {
    /* Color Palette - Minimalist Monochrome with a touch of warmth */
    --bg-color: #fafafa;
    --text-main: #1a1a1a;
    --text-muted: #666666;
    --accent-color: #000000;
    --surface-color: #eeeeee;
    --nav-bg: rgba(255, 255, 255, 0.8);
    --border-color: #eee;
    
    /* Botón Back to Top */
    --btn-bg: #1a1a1a;
    --btn-text: #ffffff;
    
    /* Typography */
    --font-main: -apple-system, "BlinkMacSystemFont", 'Montserrat', "Segoe UI", "Roboto", sans-serif;
    
    /* Spacing */
    --container-width: 1600px;
    --container-small: 800px;
}

body.dark-mode {
    --bg-color: #121212;
    --text-main: #d0d0d0;
    --text-muted: #888888;
    --accent-color: #ffffff;
    --surface-color: #2a2a2a;
    --nav-bg: rgba(18, 18, 18, 0.8);
    --border-color: #333;
    
    /* Botón Back to Top - dark mode */
    --btn-bg: #333333;
    --btn-text: #e0e0e0;
}

/* Animations */
.fade-in-section {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
    will-change: opacity, transform;
}

.fade-in-section.visible {
    opacity: 1;
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .fade-in-section {
        transition: none;
        transform: none;
    }
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    overflow-x: hidden;
    width: 100%;
}

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    cursor: none; /* For custom cursor */
    width: 100%;
    max-width: 100vw;
}

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

/* Focus Visible for Keyboard Navigation */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 4px;
    border-radius: 4px;
}

/* Remove default outline for mouse users */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
    outline: none;
}

/* Custom Cursor */

.cursor-dot,
.cursor-outline {
    position: fixed;
    top: 0;
    left: 0;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    z-index: 10002;
    pointer-events: none;
    /* mix-blend-mode: difference; Optional: nice effect against dark backgrounds but can be tricky */
}

.cursor-dot {
    width: 8px;
    height: 8px;
    background-color: var(--text-main); /* Black */
}

.cursor-outline {
    width: 30px;
    height: 30px;
    border: 1px solid rgba(0, 0, 0, 0.5); /* Semi-transparent black */
    transition: width 0.2s, height 0.2s, background-color 0.2s, border-color 0.2s;
}

body.dark-mode .cursor-outline {
    border-color: rgba(255, 255, 255, 0.5);
}

body:hover .cursor-outline {
    width: 30px;
    height: 30px;
}

/* Hover state via class added by JS */
body.hovering .cursor-outline {
    width: 50px;
    height: 50px;
    background-color: rgba(26, 26, 26, 0.1);
    border-color: transparent;
}


/* Layout */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 2rem;
}

.small-container {
    max-width: var(--container-small);
}

section {
    padding: clamp(32px, 5vw, 48px) 0; /* Tighter elastic padding */
}

/* Reduce spacing for gallery to connect better with hero */
.gallery-section {
    padding-top: clamp(30px, 4vw, 50px); /* Further adjustment: "una chispa" less air */
    padding-bottom: 20px; /* Reduced from 40px to close gap to About */
    margin-bottom: 0;
}


/* Specific spacing for About to give it more air on top */
.about-section {
    padding-top: 24px; /* Final adjustment for visual continuity with gallery */
    padding-bottom: 30px; /* Reduced from 60px to close gap to footer */
    display: flex;
    justify-content: center;
    flex-direction: column; /* Ensure vertical stacking */
    align-items: center; /* Center items horizontally */
}

.contact-section {
    padding: 40px 0; /* Reduced from 60px for better proportion with less content */
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 2rem;
    display: flex;
    justify-content: flex-start; /* Clean start to control alignment manually */
    align-items: center;
    z-index: 100;
    background: var(--nav-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color); /* Added border for better separation in dark mode */
}

.logo {
    display: inline-flex;
    align-items: baseline; /* Key change per Option B */
    text-decoration: none;
    color: var(--text-main);
}

.logo-text {
    font-weight: 700;
    font-size: 22px;
    letter-spacing: -0.5px;
    line-height: 1;
    font-family: system-ui, -apple-system, Segoe UI, Inter, Helvetica, Arial, sans-serif; /* Preserving font-family */
}

.logo-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;

    margin-left: 4px;           /* NUNCA negativo aquí */
    transform: translateY(0.5px); /* baja */
    position: relative;
    flex-shrink: 0;
}

/* reflejo */
.logo-dot::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
}

/* brillo pequeño */
.logo-dot::before {
    content: "";
    position: absolute;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    left: 2px;
    top: 2px;
    background: rgba(255, 255, 255, 0.45);
}

   /* Dark Mode Logo Refinements */
body.dark-mode .logo-dot {
    color: #bfbfbf; /* Slightly darker than text */
}

/* modo oscuro: baja un poco los brillos */
body.dark-mode .logo-dot::after {
    background: rgba(255, 255, 255, 0.10);
}

body.dark-mode .logo-dot::before {
    background: rgba(255, 255, 255, 0.22);
}

.nav-links {
    margin-left: auto; /* Push links to the right */
    margin-right: 1.5rem; /* Reduced from 3rem to bring closer to controls */
    display: flex;
    gap: 2rem; /* Reduced from 3rem */
    list-style: none;
    align-items: center;
    line-height: 1;
}

/* Hide social links row in desktop menu */
.nav-social-row {
    display: none;
    margin-top: auto; /* Push to bottom in mobile menu */
    opacity: 1; /* Ensure full visibility */
}

/* Hide legacy social links if any remain */
.nav-links .social-link,
.nav-links .nav-spacer {
    display: none;
}

.nav-links a {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.04em; /* Tightened from 0.05em */
    position: relative;
    color: var(--text-muted);
    transition: color 0.3s, opacity 0.3s;
    opacity: 0.75; /* Lower contrast as requested */
}

.nav-links a:hover {
    color: var(--text-main);
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0%;
    height: 1px;
    background-color: var(--text-main);
    transition: width 0.3s ease;
}

.nav-links a:hover::after {
    width: 100%;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: none;
    height: 24px; /* Same as logo and SVG */
}

/* Nav Controls Container */
.nav-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem; /* Tightened from 1rem */
    height: 24px; /* Same as logo and SVG */
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: none;
    cursor: none;
    color: var(--text-main);
    padding: 0;
    transition: transform 0.3s ease, color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    height: 24px; /* Same as logo and SVG */
    width: 24px;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.theme-toggle svg {
    display: block;
}

/* Flash Animation */
.flash-ray {
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform-origin: center;
}

/* When Body is NOT dark mode (Light Mode), Flash is ON */
body:not(.dark-mode) .flash-ray {
    opacity: 1;
    transform: scale(1);
}

/* When Body is Dark Mode, Flash is OFF */
body.dark-mode .flash-ray {
    opacity: 0;
    transform: scale(0);
}

/* Hero Section */
.hero-section {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    text-align: center;
    height: auto;
    min-height: 0;
    padding: clamp(7rem, 12vh, 9rem) 0 clamp(1rem, 2vh, 1.5rem); /* Reduced bottom padding to pull gallery up */
    margin-bottom: 0;
}

.greeting {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-bottom: 0.25rem;
    letter-spacing: 0.1em;
}

.headline {
    font-size: 4rem; /* Will be responsive via media queries */
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 0; /* No CTA, no bottom margin needed */
    letter-spacing: -0.02em;
    font-family: var(--font-main);
}


/* About Section */
.about-section h2, .contact-section h2, .section-header h2 {
    font-size: 2.0rem; /* Reduced to ~2.0rem for better hierarchy */
    margin-bottom: 2rem;
    letter-spacing: -0.03em;
}

.about-section p {
    font-size: 1.5rem;
    line-height: 1.7;
    color: var(--text-muted);
    font-weight: 300;
    max-width: 720px;
    text-align: left;
}

/* Text Highlight Utility */
.text-highlight {
    color: var(--text-main);
}

/* Dark Mode Text Highlight */
body.dark-mode .text-highlight {
    color: var(--accent-color);
}

/* Gallery Section - Background unified with body */
.section-header {
    text-align: center;
    margin-bottom: 3rem;
}


.gallery-grid {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.gallery-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    background-color: var(--surface-color);
    border-radius: 6px;
    width: 100%;
}

.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.6s ease, opacity 0.5s ease;
    opacity: 0;
    /* Protección contra descarga */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none; /* Previene menú en iOS */
}

.gallery-item img.loaded {
    opacity: 1;
}

.gallery-item:hover img.loaded {
    transform: scale(1.02);
}



/* Contact Section */

.contact-section {
    text-align: center;
    padding: 20px 0 30px;
    background-color: transparent;
    margin-top: 0;
}

/* Contact Section */
.footer-divider {
    width: 60px;
    height: 1px;
    background: rgba(0, 0, 0, 0.08);
    margin: 10px auto 30px;
}

body.dark-mode .footer-divider {
    background: rgba(255, 255, 255, 0.12);
}

.footer-note {
    text-align: center;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 400;
    margin-bottom: 0.25rem;
    margin-top: 0;
    opacity: 0.65;
    letter-spacing: 0.02em;
}

.email-link {
    display: inline-block;
    font-size: 2.6rem; /* Increased for final weight */
    letter-spacing: 0.02em;
    font-weight: 700;
    margin: 0.5rem 0 2rem; /* Reduced top margin since Note is above */
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 8px;
    transition: text-decoration-color 0.3s;
}

.email-link:hover {
    text-decoration-color: transparent;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.social-links a {
    color: var(--text-muted);
    font-size: 1rem;
    text-transform: uppercase;
}

.social-links a:hover {
    color: var(--text-main);
}

/* Footer */
footer {
    text-align: center;
    padding: 1.25rem 2rem;
    color: var(--text-muted);
    font-size: 0.7rem; /* Reduced from 0.8rem (~12% smaller) */
    border-top: 1px solid var(--border-color);
    opacity: 0.85; /* Slightly reduced opacity */
}

footer p {
    line-height: 1.6;
    max-width: 100%;
}

footer a {
    color: var(--text-muted);
    text-decoration: underline;
    transition: color 0.3s;
}

footer a:hover {
    color: var(--text-main);
}

/* Responsive */
/* Tablets */
@media (max-width: 1024px) and (min-width: 769px) {
}

@media (max-width: 768px) {
    /* Hide custom cursor on mobile - visual noise */
    .cursor-dot,
    .cursor-outline {
        display: none !important;
    }

    body {
        cursor: auto !important; /* Restore default cursor */
    }

    .container {
        padding: 0 1rem; /* Default mobile padding */
    }

    .hero-section {
        padding-top: 72px; /* Exact height of fixed navbar */
        padding-bottom: 0; /* Let margins control the rhythm */
    }

    /* DECISIÓN FINAL - Escala matemática */
    .greeting {
        margin-top: 24px !important; /* Header -> 24px -> Subtítulo */
        margin-bottom: 32px !important; /* Subtítulo -> 32px -> Título */
        display: block;
    }

    .headline {
        margin-bottom: 40px !important; /* Título -> 40px -> Fotos */
    }

    .gallery-section {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    .about-section {
        padding-top: 24px; /* Maintain the agreed 24px rhythm here too */
    }

    .gallery-grid {
        gap: 12px;
        padding-left: 0;
        padding-right: 0;
        width: 100%;
        margin: 0;
    }

    .gallery-column {
        gap: 12px;
    }

    .gallery-item {
        width: 100%;
    }

    /* Fix Nav Controls (Toggle + Hamburger) together */
    .nav-controls {
        position: fixed;
        right: 20px;
        top: 18px;
        z-index: 200;
        display: flex;
        gap: 0.75rem;
        align-items: center;
        /* Ensure background doesn't interfere but buttons are clickable */
    }

    .hamburger {
        /* Reset individual fixed positioning since parent is now fixed */
        position: static;
        z-index: auto;
    }

    .email-link {
        font-size: 1.5rem;
        word-break: break-all;
        margin-bottom: 0.75rem !important; /* Reduce gap to icons (~12px) */
    }

    .gallery-item img {
        width: 100%;
        height: auto;
        display: block;
        transition: opacity 0.2s ease; /* Faster fade-in on mobile */
    }

    .about-section p {
        font-size: 1.05rem; /* Reduced for mobile */
        line-height: 1.7; /* Increased breathing room as requested */
        max-width: 32ch; /* Comfortable reading width on mobile */
    }

    .about-section h2 {
        font-size: 1.6rem;
        margin-bottom: 1.25rem;
    }

    /* Prevent horizontal overflow */
    body, html {
        overflow-x: hidden;
        max-width: 100vw;
    }

    * {
        max-width: 100%;
    }

    .gallery-section,
    .about-section,
    .contact-section {
        overflow-x: hidden;
        max-width: 100vw;
    }

    .headline {
        font-size: 2rem;
    }


    /* Mobile Navigation Menu */
    .navbar .nav-links {
        position: fixed;
        top: 72px;
        right: 0;
        height: calc(100vh - 72px);
        width: auto;
        min-width: 0; /* Remove min-width to fit content tightly */
        background-color: var(--bg-color);
        display: flex;
        flex-direction: column;
        justify-content: flex-start; /* Align to top */
        align-items: flex-start;
        padding: 4rem 2.5rem; /* Add top padding to position text */
        gap: 2rem;
        margin: 0;
        transform: translateX(100%);
        transition: transform 0.35s ease-out;
        z-index: 9999;
        list-style: none;
        visibility: hidden;
        border-left: 1px solid var(--border-color);
        box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
    }

    .navbar .nav-links.nav-active {
        transform: translateX(0);
        visibility: visible;
    }

    .navbar .nav-links li {
        opacity: 1;
        width: auto;
    }

    /* Hide desktop nav-social-row */
    .nav-social-row {
        display: none;
    }

    /* Mobile Navigation Menu Rules */
    .nav-links img,
    .nav-links svg {
        pointer-events: none; /* Prevent interference */
    }

    /* Override for social icons to be clickable */
    .nav-social-row svg {
        pointer-events: auto;
    }
    
    .navbar .nav-links .nav-social-row {
         display: block;
         width: 100%;
         margin-top: auto; /* Push to bottom */
    }

    .social-icons {
        display: flex;
        flex-direction: column; /* Vertical stack */
        gap: 1.5rem; /* Space between icons */
        align-items: center; /* Center aligned */
        width: 100%;
    }

    .nav-links .social-icon {
        color: var(--text-main);
        opacity: 1; /* Force full visibility overriding .nav-links a */
        transition: color 0.3s ease, transform 0.3s ease;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .nav-links .social-icon:hover {
        opacity: 0.8; /* Slight feedback on hover */
        transform: translateY(-2px);
    }

    .social-icon svg {
        width: 18px; /* Reduced from 20px to 18px */
        height: 18px;
        /* stroke-width removed as we are using fill icons now */
    }

    /* Staggered Animation for all items */
    .navbar .nav-links li {
        opacity: 0; /* Hide initially for animation */
        transform: translateX(20px);
        transition: opacity 0.4s ease, transform 0.4s ease;
    }

    .navbar .nav-links.nav-active li {
        opacity: 1;
        transform: translateX(0);
    }

    /* Delays for each item to creating cascading effect */
    .navbar .nav-links.nav-active li:nth-child(1) { transition-delay: 0.1s; }
    .navbar .nav-links.nav-active li:nth-child(2) { transition-delay: 0.2s; }
    .navbar .nav-links.nav-active li:nth-child(3) { transition-delay: 0.3s; } /* Social Row */

    .navbar .nav-links a:not(.social-icon) {
        color: var(--text-main);
        font-size: 1.4rem;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        font-weight: 500;
        /* opacity removal handled by li parent */
    }

    .navbar .nav-links a::after {
        display: none;
    }

    /* Navbar adjustments for mobile */
    .navbar {
        z-index: 10000;
        justify-content: space-between;
        padding: 1.5rem;
        align-items: center;
    }

    /* Hamburger button */
    .hamburger {
        display: flex;
        flex-direction: column;
        gap: 6px;
        z-index: 10001;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0;
    }

    .hamburger span {
        width: 30px;
        height: 2px;
        background-color: var(--text-main);
        transition: all 0.3s ease;
        display: block;
    }

    /* Hamburger Animation */
    .hamburger.toggle .line1 {
        transform: rotate(-45deg) translate(-5px, 6px);
    }

    .hamburger.toggle .line2 {
        opacity: 0;
    }

    .hamburger.toggle .line3 {
        transform: rotate(45deg) translate(-5px, -6px);
    }

    /* Body scroll lock when menu is open */
    body.menu-open {
        overflow: hidden;
    }

    /* Hide old overlay div if it exists */
    .nav-overlay {
        display: none;
    }

    .logo {
        align-self: center;
        vertical-align: middle;
    }

    .nav-controls {
        align-self: center;
    }
    
    /* Prevent cursor freeze on button children */
    .theme-toggle svg, 
    .theme-toggle path, 
    .theme-toggle circle {
        pointer-events: none;
    }
}


@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    @keyframes fadeInUp {
        from { opacity: 0; }
        to   { opacity: 1; }
    }
}


/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background-color: var(--btn-bg);
    color: var(--btn-text);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 9990; /* Below lightbox, above content */
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background-color: var(--text-muted);
    transform: translateY(-5px);
}

/* Scroll Progress Bar */
.scroll-progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: transparent;
    z-index: 10001; /* Above navbar */
}

.scroll-progress-bar {
    height: 100%;
    background-color: var(--text-main);
    width: 0%;
    transition: width 0.1s;
}
