/* =========================================================================
   puissance-4.css — /jeux/puissance-4. Complète morpion.css (en-tête,
   panneau, score, cartes d'explication).
   ========================================================================= */

.p4 {
    --p4-rouge: #F43F5E;
    --p4-rouge-fonce: #BE123C;
    --p4-jaune: #FACC15;
    --p4-jaune-fonce: #CA8A04;
    --p4-cadre: #3B2A9E;
    --p4-trou: var(--bg-color);
}
html.dark-mode .p4 { --p4-cadre: #2D1F7A; }

.p4-cadre { width: min(100%, 460px); display: grid; gap: 6px; }

/* Rangée d'aperçu : le jeton qui tombera dans la colonne survolée. */
.p4-apercu { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 0 10px; height: 44px; }
.p4-apercu__case { border-radius: 50%; aspect-ratio: 1; align-self: end; max-height: 100%; justify-self: center; width: 80%; opacity: 0; transition: opacity 0.15s ease; }
.p4-apercu__case.est-rouge { background: var(--p4-rouge); opacity: 0.7; }
.p4-apercu__case.est-jaune { background: var(--p4-jaune); opacity: 0.7; }

.p4-plateau {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    padding: 10px;
    border-radius: 18px;
    background: var(--p4-cadre);
    box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.25), var(--shadow-card);
}
.p4-colonne {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 6px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
    transition: background 0.15s ease;
}
.p4-colonne:hover:not(:disabled),
.p4-colonne:focus-visible { background: rgba(255, 255, 255, 0.1); }
.p4-colonne:focus-visible { outline: 3px solid var(--p4-jaune); outline-offset: 2px; }
.p4-colonne:disabled { cursor: default; }

/* Trou du plateau : le jeton y est dessiné par ::after, pour pouvoir le
   faire tomber sans toucher au trou lui-même. */
.p4-case {
    position: relative;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--p4-trou);
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.45);
}
.p4-case::after {
    content: "";
    position: absolute;
    inset: 6%;
    border-radius: 50%;
    opacity: 0;
}
.p4-case.est-rouge::after { opacity: 1; background: radial-gradient(circle at 35% 30%, #FDA4AF, var(--p4-rouge) 45%, var(--p4-rouge-fonce)); }
.p4-case.est-jaune::after { opacity: 1; background: radial-gradient(circle at 35% 30%, #FEF08A, var(--p4-jaune) 45%, var(--p4-jaune-fonce)); }
/* --chute : nombre de cases traversées, posé par le script (CSSOM). */
.p4-case.tombe::after { animation: p4-chute calc(0.12s + var(--chute, 1) * 0.06s) cubic-bezier(0.5, 0, 0.9, 0.6); }
@keyframes p4-chute {
    from { transform: translateY(calc(var(--chute, 1) * -116%)); }
    to   { transform: translateY(0); }
}
.p4-case.est-gagnant::after { box-shadow: 0 0 0 3px #FFFFFF, 0 0 16px 4px rgba(255, 255, 255, 0.7); }
.p4-case.est-dernier::before {
    content: "";
    position: absolute;
    z-index: 1;
    inset: 40%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
}

.p4-boutons { display: flex; flex-wrap: wrap; gap: 8px; }
.p4-boutons .btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }
.p4 [hidden] { display: none !important; }

@media (max-width: 560px) {
    .p4-plateau,
    .p4-colonne,
    .p4-apercu { gap: 4px; }
    .p4-plateau { padding: 6px; }
}
@media (prefers-reduced-motion: reduce) {
    .p4-case.tombe::after { animation: none; }
}
