/* =========================================
   Carousel Component
   ========================================= */
.carousel-section-container {
    font-family: var(--font-body);
    padding: 20px 15px;
    background-color: transparent;
    width: 100%;
    margin: 0 auto;
}

.carousel-wrapper {
    position: relative;
    width: 100%;
    margin: 0 auto;
}

.carousel-container {
    position: relative;
    width: 100%;
    height: 280px;
    overflow: hidden;
}

.carousel-track {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.25, 0.8, 0.25, 1); /* Smooth slide transition */
    will-change: transform; /* Hint GPU acceleration for smoother animations */
}

.carousel-slide {
    min-width: 33.333%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px; /* Reduced padding for smaller gaps */
    box-sizing: border-box;
}

.carousel-slide picture {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.carousel-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    border-radius: 8px; /* Restored for soft image corners */
    cursor: pointer; /* Add pointer to indicate clickable */
}

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 15px;
    padding: 0 15px;
    flex-wrap: wrap;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-grey-400);
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.6;
}

.dot:hover {
    background-color: var(--color-secondary-green);
    opacity: 0.8;
    transform: scale(1.1);
}

.dot.active {
    background-color: var(--color-secondary-green);
    opacity: 1;
    transform: scale(1.2);
}

/* Navigation Arrows – funktional, subtil */
.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background-color: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 50%;
    color: var(--color-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.carousel-container:hover .carousel-arrow {
    opacity: 1;
    visibility: visible;
}

.carousel-arrow:hover {
    background-color: rgba(255, 255, 255, 1);
    color: var(--color-primary-dark);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-50%) scale(1.05);
}

.carousel-arrow:active {
    transform: translateY(-50%) scale(0.98);
}

.carousel-arrow-left {
    left: 12px;
}

.carousel-arrow-right {
    right: 12px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .carousel-track {
        transition: none;
    }
    .carousel-arrow,
    .dot {
        transition: none;
    }
    #lightbox-overlay {
        transition: none;
    }
}

/* Hover effect on carousel images for better click affordance */
.carousel-image:hover {
    transform: scale(1.02);
    transition: transform 0.2s ease;
}

/* Responsive Design for Carousel */
@media (max-width: 991px) {
    /* Show 2 images on tablets */
    .carousel-slide {
        min-width: 50%;
    }
}

@media (max-width: 767px) {
    .carousel-section-container {
        padding: 15px;
        /* Symmetrisches Padding für mittige Ausrichtung */
    }
    
    .carousel-container {
        height: 220px;
        touch-action: pan-y; /* Vertikales Scrollen erlaubt, horizontales für Swipe */
        max-width: 100%;
        margin-left: auto;
        margin-right: auto;
    }
    
    .carousel-slide {
        min-width: 50%;
        padding: 8px;
    }
    
    .dot {
        width: 6px;
        height: 6px;
    }

    /* Pfeile mobil ausblenden – Swipe + Autoscroll + Dots nutzen */
    .carousel-arrow {
        display: none;
    }
}

@media (max-width: 480px) {
    /* Show 1 image on small mobile */
    .carousel-slide {
        min-width: 100%;
        padding: 6px;
    }
    
    .carousel-section-container {
        padding: 15px;
    }
    
    .carousel-container {
        height: 180px;
    }
    
    .carousel-dots {
        gap: 6px;
        margin-top: 12px;
    }
}

/* Lightbox Styles */
#lightbox-overlay {
    position: absolute; /* Changed to absolute to respect scroll position */
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh; /* Cover the full viewport height */
    background-color: var(--color-overlay-dark); /* Even darker for full focus */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    opacity: 1;
    transition: opacity 0.3s ease;
}

#lightbox-overlay.lightbox-hidden {
    opacity: 0;
    pointer-events: none;
}

#lightbox-modal {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.lightbox-content-wrapper {
    position: relative; /* Positioning context for buttons */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 95vw;  /* More space on mobile portrait */
    max-height: 95vh;
}

#lightbox-image {
    max-width: 100%;
    max-height: calc(100% - 75px);
    object-fit: contain;
}

#lightbox-caption {
    margin-top: 15px;
    color: var(--color-white);
    text-align: center;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    line-height: 1.4;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
}

#lightbox-close {
    position: absolute;
    top: 10px;   /* Consistent small spacing */
    right: 10px;  /* Consistent small spacing */
    width: clamp(32px, 8vw, 40px);
    height: clamp(32px, 8vw, 40px);
    font-size: clamp(1.5rem, 5vw, 2rem);
    font-weight: bold;
    color: var(--color-white);
    background: none;
    border: none;
    cursor: pointer;
    z-index: 11;
    text-shadow: 0 1px 3px var(--color-overlay-dark-strong);
}

.lightbox-arrow {
    position: absolute; /* Position relative to the fixed modal */
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(var(--color-secondary-green-rgb), 0.7);
    border: none;
    border-radius: 50%;
    color: var(--color-white);
    cursor: pointer;
    width: clamp(44px, 12vw, 55px);
    height: clamp(44px, 12vw, 55px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    z-index: 11;
}

.lightbox-arrow:hover {
    background-color: rgba(var(--color-secondary-green-rgb), 1);
}

#lightbox-prev {
    left: 10px;
}

#lightbox-next {
    right: 10px;
}

/* DESKTOP / LANDSCAPE STYLES: Fixed Frame for stable buttons */
@media (min-width: 768px) and (orientation: landscape) {
    #lightbox-modal {
        position: relative; /* Become the positioning context on desktop */
        width: 90vw;
        height: 90vh;
        max-width: 1400px;
        max-height: 900px;
    }

    .lightbox-content-wrapper {
        position: static; /* Reset positioning context */
    }

    #lightbox-close {
        right: 0; /* Position relative to the new context */
        top: 0;
    }

    #lightbox-prev {
        left: -50px; /* Move arrows outside on desktop */
    }

    #lightbox-next {
        right: -50px; /* Move arrows outside on desktop */
    }
}

/* Prevent body scroll when lightbox is open */
body.body-lightbox-open {
    overflow: hidden;
}

/* Tablet Portrait Adjustments */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    #lightbox-caption {
        font-size: 1.2rem;
    }

    .lightbox-arrow {
        width: 55px;
        height: 55px;
    }

    #lightbox-close {
        width: 40px;
        height: 40px;
        font-size: 2rem;
    }
}

/* =========================================
   Team Grid Component
   ========================================= */
.team-section-container {
    font-family: var(--font-body);
    padding: 50px 20px;
    background-color: var(--color-white);
}

.team-section-container .container {
    max-width: 1520px;
}

/* Demo page modifier - transparent background, no padding (container already in section-alt) */
.team-section-container--demo {
    background-color: transparent;
    padding: 0;
}

.team-intro {
    width: 100%;
    margin: 0 auto 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--color-border-light);
}

.team-intro-text {
    max-width: 560px;
    margin: 0 auto 0.75rem;
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--color-text-muted);
}

.team-intro-hint {
    max-width: 560px;
    margin: 0 auto;
    font-size: 0.9rem;
    color: var(--color-text-subtle);
    line-height: 1.5;
}

.team-section-title {
    text-align: center;
    font-size: 2.8rem;
    font-weight: bold;
    color: var(--color-text);
    margin-bottom: 50px;
}

.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 30px;
    max-width: 1520px;
    margin: 0 auto;
    align-items: start;
}

.team-card {
    background: var(--color-white);
    border-radius: 12px;
    box-shadow: var(--shadow-team-card);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid var(--color-grey-300);
    position: relative; /* Add for positioning context */
    display: flex;
    flex-direction: column;
    height: 100%;
}

.team-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-team-card-hover);
}

.team-card-header {
    display: flex;
    align-items: flex-start;
    padding: 20px;
    position: relative;
    cursor: pointer;
    list-style: none; /* Hide default marker in Firefox */
    min-height: 190px;
}

.team-card-header::-webkit-details-marker {
    display: none; /* Hide default marker in Chrome/Safari */
}

.team-member-image {
    width: 85px;
    height: 114px;
    border-radius: 12px;
    margin-right: 20px;
    border: 4px solid var(--color-white);
    box-shadow: var(--shadow-sm);
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    flex-shrink: 0;
    background-color: var(--color-divider-dark); /* Fallback */
}

/* Placeholder for team members without photo */
.team-member-image--placeholder {
    background-color: var(--color-divider);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-grey-450);
    font-size: 2rem;
    font-weight: bold;
}

.team-member-summary {
    text-align: left;
    flex-grow: 1;
    min-width: 0;
}

.role-badges {
    margin: 6px 0 2px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.role-badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 0.78rem;
    line-height: 1;
    font-weight: 600;
    color: var(--color-text);
    background-color: var(--color-primary-bg-light);
    border: 1px solid var(--color-secondary-green-border);
    border-radius: 999px;
    white-space: nowrap;
}

.team-member-name {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-dark);
}

.team-member-title {
    margin: 4px 0 0;
    color: var(--color-text-muted);
    font-size: 0.95rem;
    line-height: 1.4;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
}

.team-member-specialization {
    margin: 8px 0 0;
    color: var(--color-text-dark);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
}

.team-card-details {
    max-height: 0;
    overflow: hidden;
    padding: 0 25px;
    text-align: left;
    background-color: var(--color-surface-raised);
    border-top: 1px solid var(--color-border-light);
}

.team-card-details p {
    margin: 0;
    padding: 15px 0;
    color: var(--color-text-dark);
    font-size: 1rem;
}

.team-card-details .details-content {
    padding: 15px 0;
}

.team-card-details h4 {
    font-size: 1.1rem;
    color: var(--color-text);
    margin-top: 10px;
    margin-bottom: 8px;
    font-weight: 600;
    border-bottom: 1px solid var(--color-divider);
    padding-bottom: 5px;
}

.team-card-details ul {
    list-style: none;
    padding-left: 5px;
    margin-top: 0;
    margin-bottom: 10px;
}

.team-card-details ul ul {
    padding-left: 20px;
    margin-top: 5px;
}

.team-card-details li {
    margin-bottom: 5px;
    color: var(--color-text-dark);
    position: relative;
    padding-left: 20px;
    line-height: 1.5;
}

.team-card-details li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--color-secondary-green);
    font-weight: bold;
}

.team-card-details strong {
    font-weight: 600;
    color: var(--color-text-dark);
}

.personal-note {
    margin-top: 20px;
    padding: 15px;
    background-color: var(--color-light-grey);
    font-style: italic;
    color: var(--color-grey-800);
}

.team-card[open] > .team-card-details {
    max-height: 0px; /* Prevent expansion */
    padding: 10px 25px;
}

/* Team Modal Styles */
#team-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(var(--color-black-rgb), 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
}

body.modal-open {
    overflow: hidden;
}

#team-overlay.visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease;
}

#team-modal {
    position: relative;
    max-width: 680px;
    width: calc(100% - 40px);
    max-height: 90vh;
    overflow-y: auto;
    background: var(--color-white);
    border-radius: 12px;
    box-shadow: var(--shadow-modal);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

#team-overlay.visible #team-modal {
    transform: scale(1);
}

#modal-content-container .team-card {
    box-shadow: none;
    border: none;
    margin: 10px;
}

#modal-content-container .team-card:hover {
    transform: none;
}

#modal-content-container .team-member-image {
    width: 170px;
    height: 228px;
    margin-right: 30px;
}

#modal-content-container .team-card-details {
    max-height: none;
}

#modal-content-container .team-card-header {
    cursor: default;
}

#modal-content-container .team-card .expand-icon {
    display: none;
}

/* Improve title wrapping inside modal, especially on mobile */
#modal-content-container .team-member-title,
#modal-content-container .team-member-name {
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
}

#close-modal-button {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--color-grey-800);
    cursor: pointer;
    line-height: 1;
    z-index: 10;
    background: none;
    border: none;
    padding: 0;
}

#close-modal-button:hover {
    color: var(--color-black);
}

@media (max-width: 1199px) {
    .team-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
    .team-card-header {
        min-height: 180px;
    }
}

@media (max-width: 767px) {
    .team-section-title {
        font-size: 2.2rem;
    }
    .team-grid {
        grid-template-columns: 1fr;
    }
    .team-card-header {
        min-height: 0;
    }
}
