:root {
    --primary-color: #31849b;
    --secondary-color: #17105f;
    --text-color: #333;
    --bg-color: #f4f4f4;
    --white: #ffffff;
    --link-color: #31849b;
    --link-hover: #17105f;
    --max-width: 1200px;
    --font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Global Reset */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
}

/* Layout Utilities */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1rem;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    text-decoration: none;
    color: var(--link-color);
    transition: color 0.3s ease;
}

a:hover {
    color: var(--link-hover);
}

/* Header Placeholder (Sticky Wrapper) */
#header-placeholder {
    position: sticky;
    position: -webkit-sticky;
    top: 0;
    z-index: 1100;
    width: 100%;
}

/* Header */
header {
    background: var(--white);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 1000;
}

.header-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 1rem;
    gap: 1rem;
}

@media (min-width: 992px) {
    .header-container {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

/* Branding */
.header-branding {
    flex-shrink: 0;
    width: 100%;
    /* Mobile full width for logo/menu alignment */
    position: relative;
}

@media (min-width: 992px) {
    .header-branding {
        width: auto;
    }
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
}

.logo img {
    height: 60px;
    /* Constrain logo size */
    width: auto;
}

.branding-text {
    display: flex;
    flex-direction: column;
}

.company-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--secondary-color);
    line-height: 1.2;
}

.company-tagline {
    font-size: 0.8rem;
    color: var(--text-color);
    letter-spacing: 1px;
}

@media (max-width: 480px) {
    .logo {
        gap: 0.5rem;
        /* Reduce gap */
    }

    .logo img {
        height: 45px;
        /* Smaller logo */
    }

    .company-name {
        font-size: 1.2rem;
        /* Smaller text */
    }

    .company-tagline {
        font-size: 0.65rem;
        /* Smaller tagline */
        letter-spacing: 0.5px;
    }
}

/* Navigation */
.main-nav {
    width: auto;
    /* Changed from 100% to auto for flex row */
    display: flex;
    justify-content: flex-end;
    /* Align hamburger to right */
    align-items: center;
}

@media (min-width: 992px) {
    .main-nav {
        width: auto;
        display: block;
        /* Reset if needed or keep flex */
    }
}

#nav-list {
    display: none;
    /* Hidden on mobile by default */
    flex-direction: column;
    align-items: center;
    /* Center items on mobile */
    list-style: none;
    padding: 0;
    margin: 0;
    width: auto;
    /* Changed from 100% to auto to fit content */
    border-top: 1px solid #eee;
    padding-top: 1rem;
    margin-top: 1rem;
    position: absolute;
    top: 60px;
    /* Adjust based on header height */
    right: 0;
    background: #fff;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-radius: 0 0 0 8px;
    padding: 1rem 2rem;
    z-index: 1000;
}

/* Ensure container allows absolute positioning context if needed, or adjust */
.header-container {
    position: relative;
}

#nav-list.active {
    display: flex;
}

@media (min-width: 992px) {
    #nav-list {
        display: flex;
        flex-direction: row;
        margin-top: 0;
        gap: 1.5rem;
        /* Increased spacing for better separation */
        width: auto;
        padding-top: 0;
        border-top: none;
        position: static;
        /* Reset absolute positioning */
        box-shadow: none;
        background: transparent;
        padding: 0;
    }

    .header-container {
        position: static;
        /* Reset if needed */
    }
}

.main-nav a {
    color: var(--text-color);
    padding: 0.5rem 0;
    /* Removed horizontal padding to fit text width */
    font-weight: 600;
    border-radius: 0;
    /* Removed border radius for underline style */
    font-family: var(--font-heading);
    transition: all 0.3s ease;
    display: inline-block;
    /* Only take necessary width */
    text-align: center;
    width: auto;
    /* Auto width */
    font-size: 0.95rem;
    position: relative;
    /* For pseudo-element */
    margin: 0.2rem 0;
    /* Vertical spacing on mobile */
}

@media (min-width: 992px) {
    .main-nav a {
        width: auto;
        margin: 0;
        padding: 0.5rem 0;
    }
}

/* Dynamic Hover Effect (Underline) */
.main-nav a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 50%;
    background-color: var(--primary-color);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.main-nav a:hover::after {
    width: 100%;
}

.main-nav a:hover {
    color: var(--primary-color);
    background: transparent;
    /* No background on hover */
}

/* Removed persistent active background */
.main-nav a.active {
    color: var(--primary-color);
    background: transparent;
}

/* Optional: keep active underline? User said "no se mantiene activado", so maybe not even underline? */
/* Let's leave the color active but no background, as per request "no se mantiene activado ni marcada" implies removing the heavy marking */


/* Mobile Menu Button */
.menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1001;
}

.menu-toggle span {
    display: block;
    width: 100%;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 3px;
    transition: all 0.3s ease;
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -6px);
}

@media (min-width: 992px) {
    .menu-toggle {
        display: none;
    }
}

/* Secondary Info Bar */
.header-secondary-bar {
    background: var(--primary-color);
    color: white;
    font-size: 0.85rem;
    padding: 0.5rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.secondary-content {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.secondary-content a {
    color: white;
}

.secondary-content .separator {
    opacity: 0.5;
}

@media (max-width: 768px) {
    .header-secondary-bar {
        font-size: 0.7rem;
        padding: 0.2rem 0;
    }

    .secondary-content {
        gap: 0.5rem;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        /* Allow wrapping */
        line-height: 1.2;
    }

    .secondary-content span,
    .secondary-content a {
        display: inline-block;
        white-space: nowrap;
        /* Keep individual items on one line if possible */
    }

    .secondary-content .separator {
        display: none;
        /* Hide separators on mobile to save space/clean layout */
    }
}

/* ID Proyectos Styles */
.process-section-compact {
    border: 1px solid rgba(0, 78, 124, 0.1);
    background: linear-gradient(to bottom, #ffffff, #f9fcfe);
    padding: 2.5rem;
    border-radius: 8px;
}

.fp7-container {
    display: flex;
    flex-direction: column;
    /* Stack vertically for all screens as requested */
    align-items: center;
    text-align: center;
    gap: 1.5rem;
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.02);
}

.fp7-text {
    width: 100%;
    max-width: 600px;
    /* Limit text width for readability */
}

/* Link/Image wrapper inside fp7-container */
.fp7-container>a {
    display: block;
    transition: transform 0.3s ease;
}

.fp7-container>a:hover {
    transform: scale(1.05);
}

.fp7-container img {
    height: 80px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

@media (max-width: 768px) {
    .process-section-compact {
        padding: 1rem;
    }

    .fp7-container {
        padding: 1.5rem;
        gap: 1.5rem;
    }
}

/* I+D Projects Specific Styles */
.id-hero-wrapper {
    text-align: center;
    margin: 0 0 1.5rem 0;
    /* Removed top margin */
    padding-top: 0;
    /* Removed top padding */
}

.id-title {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-top: 0;
    /* Ensure no default margin */
    margin-bottom: 0.8rem;
    border-bottom: 2px solid var(--secondary-color);
    display: inline-block;
    padding-bottom: 0.4rem;
}

.id-intro {
    font-size: 1.1rem;
    color: #444;
    font-weight: 500;
    margin-top: 0.5rem;
    line-height: 1.4;
}

.project-title {
    text-align: center;
    font-size: 2rem;
    margin-top: 0;
    /* Ensure no default margin */
    margin-bottom: 1.5rem;
    color: var(--secondary-color);
}

.project-description-wrapper {
    max-width: 800px;
    margin: 0 auto;
}

.project-description {
    text-align: center;
    font-size: 1.1rem;
    line-height: 1.6;
    color: #444;
    margin-bottom: 2rem;
}

.olicematic-image-container {
    height: 350px;
    background: white;
    margin-bottom: 2.5rem;
    border: 1px solid #eee;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.olicematic-image {
    padding: 2rem;
    max-height: 100%;
    width: auto;
}

.fp7-description {
    font-size: 1.05rem;
    margin: 0;
    line-height: 1.6;
    color: #555;
}

.fp7-link {
    color: var(--secondary-color);
    text-decoration: underline;
    font-weight: 700;
}

.closing-text {
    text-align: center;
    font-style: italic;
    color: #666;
    /* approximate var(--text-muted) if not defined, assuming it was a guess */
    margin-top: 3rem;
    font-size: 1.1rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

@media (max-width: 768px) {
    .olicematic-image-container {
        height: auto;
        min-height: 200px;
    }

    .olicematic-image {
        padding: 1rem;
        width: 100%;
        height: auto;
    }
}

/* Main Layout */
.main-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 2rem 0;
}

/* Sidebar removed, main content centered/full */
/*
@media (min-width: 768px) {
  .main-grid {
    grid-template-columns: 300px 1fr;
  }
}
*/

/* Hero / Slider */
.hero-slider {
    position: relative;
    width: 100%;
    height: 400px;
    overflow: hidden;
    margin-bottom: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.hero-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    /* Parallax effect */
    background-repeat: no-repeat;
    /* Prevent double images */
    opacity: 0;
    transition: opacity 1s ease-in-out;
}

.hero-slide.active {
    opacity: 1;
}

.hero-content-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
}

.hero-content {
    text-align: center;
    color: white;
    padding: 0 20px;
}

.hero-content h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.hero-content p {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.hero-buttons {
    margin-top: 1rem;
}

.btn-hero {
    font-size: 1rem;
    padding: 0.8rem 2rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    /* Try to keep on one line */
}

@media (max-width: 480px) {
    .btn-hero {
        font-size: 0.8rem;
        /* Smaller font for mobile */
        padding: 0.6rem 1rem;
        /* Compact padding */
        letter-spacing: 0.5px;
        width: auto;
        max-width: 100%;
        white-space: normal;
        /* Allow wrap if screen is extremely small, but preferred one line via font size */
    }
}



.hero-dots {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 3;
}

.dot {
    width: 12px;
    height: 12px;
    background-color: rgba(255, 255, 255, 0.5);
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
}

.dot.active {
    background-color: white;
    transform: scale(1.2);
}

/* Main Content */
.content {
    background: var(--white);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.hero-text {
    font-size: 1.25rem;
    color: var(--secondary-color);
    text-align: center;
    margin-bottom: 2rem;
    font-weight: bold;
}

.services-list {
    background: #f9f9f9;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.services-list ul {
    list-style-type: none;
    padding: 0;
}

.services-list li {
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
    position: relative;
}

.services-list li::before {
    content: "✓";
    color: var(--primary-color);
    position: absolute;
    left: 0;
    font-weight: bold;
}

.btn {
    display: inline-block;
    background: var(--primary-color);
    color: var(--white);
    padding: 0.8rem 1.5rem;
    border-radius: 25px;
    font-weight: bold;
}

.btn:hover {
    background: var(--secondary-color);
    color: var(--white);
}

/* Cómo trabajamos Section Optimization */
.steps-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    /* Aumentado para dar aire */
    justify-content: center;
}

.step-card {
    flex: 1 1 300px;
    /* Más flexible y con ancho base */
    max-width: 400px;
    box-sizing: border-box;
    padding: 1.5rem;
    /* Más padding interno como en la imagen */
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    /* Sombra más suave */
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.step-image-container {
    width: 100%;
    height: 220px;
    /* Ajustado para mejor proporción */
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f8f8f8;
}

.step-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.step-card:hover .step-image {
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .step-card {
        flex: 0 0 100%;
        margin-bottom: 1rem;
    }

    .step-image-container {
        height: 200px;
    }
}

/* Services Grid */
.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

@media (min-width: 992px) {
    .service-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.service-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    padding: 1.5rem;
    text-align: center;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.service-card:hover {
    transform: translateY(-5px);
}

.service-image-container {
    width: 100%;
    height: 200px;
    margin-bottom: 1rem;
    overflow: hidden;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.service-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.service-image-contain {
    object-fit: contain;
}

.service-card h4 {
    color: var(--secondary-color);
    margin: 0.5rem 0 1rem;
    font-size: 1.2rem;
}

.service-card p {
    font-size: 0.95rem;
    color: #555;
    line-height: 1.5;
}

/* Clients */
.clients {
    margin-top: 3rem;
    text-align: center;
    border-top: 1px solid #eee;
    padding-top: 2rem;
}

.clients h3 {
    color: #777;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1.5rem;
}

.client-logos {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.client-logos img {
    max-width: 100px;
    height: auto;
    transition: transform 0.3s ease;
}

.client-logos img:hover {
    transform: scale(1.1);
}

/* Footer */
footer {
    background: var(--primary-color);
    color: var(--white);
    padding: 1rem 0;
    margin-top: 2rem;
    text-align: center;
}

.footer-content {
    display: flex;
    justify-content: center;
}

.footer-merged {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    /* Compact font size */
    width: 100%;
}

.footer-merged .separator {
    opacity: 0.5;
    margin: 0 0.2rem;
}

.phone-item {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.footer-merged a {
    color: var(--white);
    text-decoration: none;
}

@media (max-width: 768px) {
    .footer-merged {
        font-size: 0.6rem;
        gap: 0.1rem;
    }

    .footer-merged .separator {
        margin: 0;
    }
}

.grant-info {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Canva Embed Responsive Sizing */
.canva-embed {
    width: 80% !important;
    /* Reduced width for desktop */
}

@media (max-width: 768px) {
    .canva-embed {
        width: 100% !important;
        /* Full width for mobile */
    }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .main-grid {
        padding: 1rem 0;
    }

    .content {
        padding: 1.5rem;
    }

    .hero-slider {
        height: 300px;
    }

    .hero-slide {
        background-attachment: scroll;
        /* Disable parallax on mobile to prevent excessive zooming/cropping */
        background-position: center center;
        /* Focus on center of image to show main content */
        background-size: cover;
        /* Ensure it covers the area */
    }

    .hero-text h2 {
        font-size: 1.1rem;
        /* Reduced font size for mobile to fit in fewer lines */
        line-height: 1.2;
        padding: 0 0.5rem;
        /* Add some padding to prevent edge touching */
    }
}

/* About Page Styles */
.about-hero-text {
    margin-bottom: 1rem !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.about-hero-text h2 {
    margin-top: 0;
    margin-bottom: 0;
}

/* Services Page Styles */
.services-hero-text {
    margin-bottom: 0.5rem !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.services-hero-text h2 {
    margin-top: 0;
    margin-bottom: 0;
}

/* Projects Page Styles */
.projects-hero-text {
    margin-bottom: 0.5rem !important;
    /* Override default hero-text margin */
}

.projects-hero-text h2 {
    margin-bottom: 0;
    margin-top: 0;
}

.sectors-intro {
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 0.5rem;
    /* Reduced spacing */
    line-height: 1.3;
}

.timeline-container {
    max-width: 900px;
    margin: 0 auto 3rem auto;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    /* Tighter vertical spacing between items */
}

.timeline-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.5rem;
    background: #fdfdfd;
    padding: 1rem;
    /* Compact padding */
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

.timeline-content {
    flex: 1;
    min-width: 280px;
}

.timeline-year {
    color: var(--primary-color);
    font-size: 1.6rem;
    margin-top: 0;
    display: inline;
    margin-right: 0.8rem;
}

.timeline-text {
    font-size: 1.05rem;
    color: #333;
    margin: 0;
    line-height: 1.4;
    display: inline;
}

.timeline-image-wrapper {
    width: 180px;
    /* Slightly smaller */
    height: 130px;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    /* Prevent shrinking */
}

.timeline-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (max-width: 768px) {
    .sectors-intro {
        font-size: 1.3rem;
        margin-bottom: 0.5rem;
    }

    .timeline-container {
        margin-bottom: 2rem;
        gap: 0.8rem;
    }

    .timeline-item {
        padding: 0.8rem;
        gap: 1rem;
    }

    .timeline-image-wrapper {
        width: 140px;
        /* Reduced width for mobile */
        height: 100px;
        /* Reduced height for mobile */
        margin-top: 0.5rem;
    }
}

/* Contact Page Styles */
.contact-card {
    background: #f0f7fa;
    /* Light blue/gray to stand out from white */
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    display: inline-block;
    text-align: center;
    max-width: 500px;
    width: 100%;
    border: 1px solid #d1e3e8;
    margin-bottom: 2rem;
}

.contact-card p {
    margin-bottom: 0.3rem;
    line-height: 1.3;
    font-size: 1.05rem;
    color: #444;
}

.contact-card strong {
    color: var(--secondary-color);
}

.map-responsive {
    overflow: hidden;
    padding-bottom: 56.25%;
    /* 16:9 aspect ratio */
    position: relative;
    height: 0;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.map-responsive iframe {
    left: 0;
    top: 0;
    height: 100%;
    width: 100%;
    position: absolute;
}