/*TAQUIN*/
:root {
    --couleurTitres: rgb(190, 119, 119);
    --couleurTitresMuted: rgb(212, 160, 160);
}

.taquin {
    width: min(90vmin, 500px);
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    border: 0.5px solid var(--couleurTitresMuted);
    border-radius: 10px;
    padding: 2px;
    background-color: var(--couleurTitres);
}
.piece {
    width: calc(100% / var(--nbrPiecesPerLine));
    aspect-ratio: calc(1 / var(--ratioImage));
    background: var(--image-taquin);
    background-size: calc(var(--nbrPiecesPerLine) * 100%);
    background-color: aqua;
    border-radius: 6px;
    font-size: 3em;
    text-align: center;
    transition: background-position 0.15s ease;
    box-sizing: border-box;
    color: var(--couleurTitres);
}
#pieceInvisible {
    visibility: hidden;
}

/*************************************/
/*STRUCTURE*/
body {
    font-family: sans-serif;
    max-width: 98vw;
    background-color: rgb(211, 211, 211);
}
.c1 {
    display: grid;
    grid-template-columns: auto;
    grid-template-rows: auto auto auto;
    gap: 10px;
    justify-content: center;
    padding: 1.5rem 0;
}

/*HEADER*/
header {
    grid-row: 1/2;
    grid-column: 1/2;
    display: flex;
    align-items: center;
    gap: 1rem;
    width: min(90vw, 90vh, 500px);
    padding-bottom: 0.75rem;
    border-bottom: 0.5px solid var(--couleurTitresMuted);
}
h1 {
    flex: 1;
    padding: 0;
    margin: 0;
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--couleurTitres);
    letter-spacing: 0.01em;
}
h2 { color: var(--couleurTitres); font-size: 1.2em; }
h3 { color: rgb(230, 166, 177); font-size: small; }

.admin-link {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: rgb(120, 100, 100);
    text-decoration: none;
    border: 0.5px solid var(--couleurTitresMuted);
    border-radius: 6px;
    padding: 5px 10px;
    white-space: nowrap;
    transition: background 0.15s;
}
.admin-link:hover { background: rgba(190, 119, 119, 0.08); }
.admin-link svg {
    width: 13px;
    height: 13px;
    opacity: 0.5;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
}

/*SCENE*/
#scene {
    grid-row: 2/3;
    grid-column: 1/2;
    display: flex;
    justify-content: center;
}

/*FOOTER - CONTROLS*/
footer {
    grid-row: 3/4;
    grid-column: 1/2;
}
.controls {
    display: flex;
    align-items: center;
    gap: 8px;
    width: min(90vw, 90vh, 500px);
}
.ctrl-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: 0.5px solid var(--couleurTitresMuted);
    border-radius: 6px;
    background: transparent;
    color: var(--couleurTitres);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
}
.ctrl-btn:hover { background: rgba(190, 119, 119, 0.08); }
.ctrl-btn svg {
    width: 16px;
    height: 16px;
    stroke: var(--couleurTitres);
    fill: none;
    stroke-width: 1.5;
}
.ctrl-spacer { flex: 1; }
.ctrl-separator {
    width: 0.5px;
    height: 24px;
    background: var(--couleurTitresMuted);
    flex-shrink: 0;
}
.select-wrap {
    position: relative;
}
.select-wrap select {
    height: 36px;
    padding: 0 1.75rem 0 0.6rem;
    border: 0.5px solid var(--couleurTitresMuted);
    border-radius: 6px;
    background: transparent;
    color: rgb(120, 100, 100);
    font-size: 13px;
    appearance: none;
    cursor: pointer;
}
.select-wrap::after {
    content: '';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--couleurTitresMuted);
    pointer-events: none;
}
.ctrl-btn.auto-on {
    background: var(--couleurTitres);
    color: white;
    border-color: var(--couleurTitres);
}
/* Effet de balayage synchronisé avec le son */
.piece {
    position: relative;
    overflow: hidden;
}
/* Voile sombre sur la pièce en lecture */
.piece::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.1s ease;
    pointer-events: none;
    z-index: 1;
}
.piece.en-lecture::before {
    background: rgba(0, 0, 0, 0.35);
}
/* Balayage lumineux par-dessus le voile */
.piece::after {
    content: '';
    position: absolute;
    top: 0;
    left: -60%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
    animation: none;
    pointer-events: none;
    z-index: 2;
}
.piece.en-lecture::after {
    animation: balayage var(--seg-duration, 0.5s) linear forwards;
}
@keyframes balayage {
    from { left: -60%; }
    to   { left: 110%; }
}