* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3d5a6b;
    --secondary-color: #e27563;
    --text-color: #333;
    --bg-color: #f5f5f5;
    --white: #fff;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --max-width: 900px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    overflow: hidden;
    background: #fff;
    box-shadow: var(--shadow);
}

.header-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    background: #fff;
    padding: 0.35rem 1.5rem 0.25rem;
    border-bottom: 1px solid #eee;
    min-height: 110px;
    transition: all 0.25s ease;
    position: relative;
}

body.scrolled .header-bar,
.force-compact .header-bar {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    min-height: 75px; /* ~30% plus bas que 110px */
    padding: 0.2rem 1rem;
    gap: 0.35rem;
}

body.scrolled .header-bar::after,
.force-compact .header-bar::after {
    content: "";
    display: block;
    flex: 0 0 120px; /* espace miroir du logo pour centrer le menu */
}

.header-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
    background: #fff;
    transition: all 0.25s ease;
}

.header-logo a {
    display: inline-block;
}

.logo-img {
    max-width: 170px;
    height: auto;
    transition: max-width 0.25s ease;
}

body.scrolled .header-logo,
.force-compact .header-logo {
    justify-content: flex-start;
}

body.scrolled .logo-img,
.force-compact .logo-img {
    max-width: 120px;
}

/* Header Carousel */
.header-carousel {
    position: relative;
    width: 100%;
    height: 400px;
    overflow: hidden;
    background-color: #000;
    transition: height 0.6s ease, opacity 0.6s ease;
}

/* Quand on scroll, le carrousel disparaît */
body.scrolled .header-carousel {
    height: 0;
    opacity: 0;
    min-height: 0;
    pointer-events: none;
}

.force-compact .header-carousel {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.carousel-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.carousel-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.carousel-slide.active {
    opacity: 1;
}

.carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 50%;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(255, 255, 255, 0.7);
    border: none;
    color: #333;
    font-size: 2rem;
    padding: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
    z-index: 10;
}

.carousel-btn:hover {
    background-color: rgba(255, 255, 255, 0.9);
}

.carousel-btn.prev {
    left: 1rem;
}

.carousel-btn.next {
    right: 1rem;
}

/* Navigation */
.navbar {
    flex: 1;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: transparent;
    transition: all 0.3s ease;
}

.nav-menu {
    display: flex;
    list-style: none;
    justify-content: center;
    gap: 2.5rem;
    padding: 0.35rem 0;
    margin: 0;
}

.nav-menu a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    transition: color 0.3s;
    padding: 0.4rem 0;
    border-bottom: 2px solid transparent;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.nav-menu a:hover,
.nav-menu a.active {
    color: var(--secondary-color);
    border-bottom: 2px solid var(--secondary-color);
}

body.scrolled .navbar {
    justify-content: center;
    align-items: center;
    transform: translateY(-4px);
}

body.scrolled .nav-menu,
.force-compact .nav-menu {
    width: 100%;
    justify-content: center;
}

.admin-link {
    display: none;
}

/* Container */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem;
    min-height: calc(100vh - 200px);
}

/* Hero Section */
.hero {
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 1.5rem 0;
}

.hero h2 {
    color: var(--primary-color);
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.hero p {
    color: var(--text-color);
    font-size: 1.2rem;
    opacity: 0.8;
}

/* Gallery */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.poster-card {
    background: var(--white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.poster-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.poster-image {
    width: 100%;
    height: 350px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.poster-card:hover .poster-image {
    transform: scale(1.1);
}

.poster-info {
    padding: 1.5rem;
}

.poster-info h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1.3rem;
    font-weight: 600;
}

.poster-info p {
    color: var(--text-color);
    font-size: 0.95rem;
    opacity: 0.8;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Piece Detail */
.piece-detail {
    background: var(--white);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

.piece-header {
    margin-bottom: 2rem;
    text-align: center;
}

.piece-title {
    color: var(--primary-color);
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

/* Layout: Affiche à gauche, contenu à droite */
.piece-content-wrapper.layout-sidebar-left {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 3rem;
    align-items: start;
}

/* Layout: Affiche à droite, contenu à gauche */
.piece-content-wrapper.layout-sidebar-right {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 3rem;
    align-items: start;
}

.piece-content-wrapper.layout-sidebar-right .piece-poster-column {
    order: 2;
}

.piece-content-wrapper.layout-sidebar-right .piece-info-column {
    order: 1;
}

/* Layout: Affiche en haut */
.piece-content-wrapper.layout-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.piece-content-wrapper.layout-top .piece-poster-column {
    max-width: 400px;
}

.piece-poster-column {
    position: sticky;
    top: 135px; /* garde l'affiche visible sous le bandeau (75px header + 40px marge) */
    padding-top: 0.5rem;
    align-self: flex-start; /* Empêche l'affiche de se décaler en bas de page */
}

.piece-poster {
    width: 100%;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.piece-info-column {
    flex: 1;
}

.info-section {
    margin-bottom: 2rem;
}

.info-section h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1.3rem;
    font-weight: 600;
}

.info-section p {
    line-height: 1.8;
    margin-bottom: 0;
    white-space: pre-line;
}

/* Old styles for compatibility */
.piece-content {
    display: grid;
    gap: 2rem;
}

.piece-info {
    margin-bottom: 2rem;
}

.piece-info h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1.3rem;
    font-weight: 600;
}

.piece-info p {
    line-height: 1.8;
    margin-bottom: 1rem;
}

.piece-video {
    margin: 2rem 0;
}

.video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 8px;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Contact Page */
.contact-section {
    background: var(--white);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

.contact-section h2 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 2rem;
    text-align: center;
    font-weight: 600;
}

.contact-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.info-card {
    text-align: center;
    padding: 1.5rem;
    background: var(--bg-color);
    border-radius: 8px;
}

.info-card h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-weight: 600;
    white-space: nowrap;
}

.info-card p {
    word-break: break-word;
    overflow-wrap: break-word;
}

.contact-form {
    max-width: 600px;
    margin: 0 auto;
}

.contact-form h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: 600;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    font-weight: 600;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
}

/* Admin Page */
.admin-container {
    max-width: 1200px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.admin-header h2 {
    color: var(--primary-color);
    font-weight: normal;
}

.admin-list {
    background: var(--white);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

.piece-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--bg-color);
    border-radius: 8px;
    cursor: move;
}

.piece-item.dragging {
    opacity: 0.5;
}

.drag-handle {
    cursor: grab;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.piece-item img {
    width: 80px;
    height: 120px;
    object-fit: cover;
    border-radius: 4px;
}

.piece-item-info {
    flex: 1;
}

.piece-item-info h4 {
    color: var(--primary-color);
    margin-bottom: 0.25rem;
    font-weight: normal;
}

.piece-item-actions {
    display: flex;
    gap: 0.5rem;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--white);
    padding: 2rem;
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-weight: normal;
}

.preview-image {
    max-width: 100%;
    margin-top: 1rem;
    border-radius: 4px;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
    font-family: inherit;
}

.btn:hover {
    background-color: #6d3410;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-danger {
    background-color: #c44;
}

.btn-danger:hover {
    background-color: #a33;
}

.btn-secondary {
    background-color: #666;
}

.btn-secondary:hover {
    background-color: #555;
}

/* Footer */
footer {
    background-color: var(--white);
    color: var(--text-color);
    text-align: center;
    padding: 1.5rem;
    margin-top: 3rem;
    border-top: 1px solid #eee;
    font-size: 0.9rem;
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--primary-color);
    font-size: 1.2rem;
}

/* Responsive */
@media (max-width: 768px) {
    .header-bar {
        padding: 0.5rem 1rem 0.25rem;
    }

    .logo-img {
        max-width: 150px;
    }

    body.scrolled .header-bar {
        grid-template-columns: auto 1fr;
        gap: 0.25rem;
    }

    .nav-menu {
        gap: 1.25rem;
        font-size: 0.95rem;
    }

    .header-carousel {
        height: 50vh;
        min-height: 300px;
        max-height: 420px;
    }

    .hero h2 {
        font-size: 2rem;
    }

    .gallery {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 1rem;
    }

    /* Piece detail layouts on mobile */
    .piece-content-wrapper.layout-sidebar-left,
    .piece-content-wrapper.layout-sidebar-right {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .piece-content-wrapper.layout-sidebar-right .piece-poster-column {
        order: 1;
    }

    .piece-content-wrapper.layout-sidebar-right .piece-info-column {
        order: 2;
    }

    .piece-poster-column {
        position: relative;
        top: 0;
    }

    .piece-poster {
        max-width: 100%;
    }
}
