/* ==========================================================================
   OsmoTools : jeux de réflexion ([osmova_sudoku], [osmova_sudoku_difficile], [osmova_sudoku_expert], [osmova_morpion])
   Grilles et signes dessinés en CSS, aucune image externe. Même langage visuel que arcade.css (.oar).
   ========================================================================== */

.orf {
    --orf-noir: #0A0A0A;
    --orf-gris: #6B6B6B;
    --orf-gris-bg: #F6F7F9;
    --orf-border: #E5E7EB;
    --orf-blue: #0064FF;
    --orf-rouge: #C8102E;
    --orf-vert: #1D8A4E;
    --orf-tapis: #EEF1F6;
    --orf-trait: #0A0A0A;
    --orf-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    position: relative;
    margin: 0 0 40px;
    padding: 24px 28px 28px;
    border: 1px solid var(--orf-border);
    border-radius: 16px;
    background: #fff;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--orf-noir);
}

.orf *,
.orf *::before,
.orf *::after {
    box-sizing: border-box;
}

.orf [hidden] {
    display: none !important;
}

.orf .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.orf :focus-visible {
    outline: 3px solid color-mix(in srgb, var(--orf-blue) 55%, white);
    outline-offset: 2px;
}

/* ---------- En-tête ---------- */

.orf__tete {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    justify-content: space-between;
    align-items: flex-end;
    margin: 0 0 16px;
}

.orf__badge {
    display: inline-block;
    margin: 0 0 8px;
    padding: 4px 10px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--orf-blue) 9%, white);
    color: var(--orf-blue);
    font: 700 11px/1.4 var(--orf-mono);
    letter-spacing: .08em;
    text-transform: uppercase;
}

.orf .orf__titre {
    margin: 0;
    font-size: 1.5rem;
    line-height: 1.25;
}

.orf__compteurs {
    display: flex;
    gap: 6px;
    margin: 0;
}

.orf__compteurs > div {
    min-width: 84px;
    padding: 6px 12px;
    border: 1px solid var(--orf-border);
    border-radius: 10px;
    background: var(--orf-gris-bg);
}

.orf__compteurs dt {
    color: var(--orf-gris);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.orf__compteurs dd {
    margin: 0;
    font: 700 16px/1.3 var(--orf-mono);
    font-variant-numeric: tabular-nums;
}

/* ---------- Boutons ---------- */

.orf__barre {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
}

.orf__btn {
    display: inline-flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    min-height: 42px;
    margin: 0;
    padding: 8px 14px;
    border: 1px solid var(--orf-border);
    border-radius: 10px;
    background: #fff;
    color: var(--orf-noir);
    font-family: inherit;
    font-weight: 700;
    font-size: 14px;
    line-height: 1.2;
    cursor: pointer;
    touch-action: manipulation;
}

.orf__btn:hover {
    border-color: var(--orf-noir);
    background: var(--orf-gris-bg);
}

.orf__btn:disabled {
    opacity: .45;
    cursor: default;
}

.orf__btn:disabled:hover {
    border-color: var(--orf-border);
    background: #fff;
}

.orf__btn--main {
    border-color: var(--orf-blue);
    background: var(--orf-blue);
    color: #fff;
}

.orf__btn--main:hover {
    border-color: color-mix(in srgb, var(--orf-blue) 80%, black);
    background: color-mix(in srgb, var(--orf-blue) 80%, black);
    color: #fff;
}

.orf__btn[aria-pressed="true"] {
    border-color: var(--orf-blue);
    background: color-mix(in srgb, var(--orf-blue) 9%, white);
    color: var(--orf-blue);
}

.orf__ico {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.orf__lien {
    padding: 6px 0;
    border: 0;
    background: none;
    color: var(--orf-gris);
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

/* ---------- Réglages en pastilles ---------- */

.orf__reglage {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 14px;
    padding: 0;
    border: 0;
}

.orf__reglage legend {
    width: 100%;
    margin: 0 0 8px;
    padding: 0;
    color: var(--orf-gris);
    font-weight: 600;
    font-size: 13px;
}

.orf__reglage label {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    min-height: 40px;
    padding: 6px 14px;
    border: 1px solid var(--orf-border);
    border-radius: 999px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.orf__reglage label:has(input:checked) {
    border-color: var(--orf-blue);
    background: color-mix(in srgb, var(--orf-blue) 7%, white);
}

.orf__reglage input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--orf-blue);
}

.orf__hint {
    margin: 0 0 12px;
    color: var(--orf-gris);
    font-size: 13px;
    line-height: 1.5;
}

/* ---------- Sudoku ---------- */

.orf__jeu {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 272px;
    gap: 24px;
    align-items: start;
    padding: 18px;
    border-radius: 14px;
    background: var(--orf-tapis);
}

.orf__plateau {
    position: relative;
    width: min(100%, 540px);
    margin: 0 auto;
}

.orf__grille {
    display: grid;
    grid-template-columns: repeat(9, minmax(0, 1fr));
    aspect-ratio: 1;
    overflow: hidden;
    border: 2px solid var(--orf-trait);
    border-radius: 10px;
    background: #fff;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.orf.is-pause .orf__grille,
.orf.is-attente .orf__grille {
    visibility: hidden;
}

.orf__su {
    display: contents;
}

.orf__case {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
    border-right: 1px solid #D5DAE2;
    border-bottom: 1px solid #D5DAE2;
    background: #fff;
    color: var(--orf-blue);
    font: 600 clamp(18px, 4.6vw, 28px) / 1 var(--orf-mono);
    cursor: pointer;
}

.orf__case.is-c8 {
    border-right: 0;
}

.orf__case.is-l8 {
    border-bottom: 0;
}

.orf__case.is-c2,
.orf__case.is-c5 {
    border-right: 2px solid var(--orf-trait);
}

.orf__case.is-l2,
.orf__case.is-l5 {
    border-bottom: 2px solid var(--orf-trait);
}

.orf__case.is-zone {
    background: #EEF3FC;
}

.orf__case.is-meme {
    background: #D3E2FF;
}

.orf__case.is-sel {
    background: #B5CEFF;
}

.orf__case:focus-visible {
    z-index: 1;
    outline-offset: -3px;
}

.orf__case.is-donne {
    color: var(--orf-noir);
    font-weight: 800;
}

.orf__case.is-aide {
    color: var(--orf-vert);
    font-weight: 800;
}

.orf__case.is-faux,
.orf__case.is-conflit:not(.is-donne) {
    color: var(--orf-rouge);
}

.orf__case.is-conflit::after,
.orf__case.is-faux::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--orf-rouge) 12%, transparent);
    pointer-events: none;
}

.orf__notes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    padding: 2px;
    color: #4B5563;
    font: 600 clamp(8px, 2vw, 12px) / 1 var(--orf-mono);
}

.orf__notes span {
    display: flex;
    justify-content: center;
    align-items: center;
}

.orf__notes span.is-meme {
    border-radius: 3px;
    background: var(--orf-blue);
    color: #fff;
}

.orf__voile {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    border-radius: 10px;
    background: var(--orf-gris-bg);
    animation: orf-fondu .25s ease-out;
}

.orf__v-carte {
    max-width: 300px;
    padding: 22px 22px 20px;
    border: 1px solid var(--orf-border);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 12px 32px rgba(13, 13, 13, .1);
    text-align: center;
}

.orf .orf__v-t {
    margin: 0 0 6px;
    font-weight: 800;
    font-size: 1.25rem;
    line-height: 1.25;
}

.orf .orf__v-p {
    margin: 0 0 16px;
    color: var(--orf-gris);
    font-size: 14px;
    line-height: 1.5;
}

.orf.is-attente .orf__v-btn {
    display: none;
}

.orf__panneau {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.orf__bandeau {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: #fff;
    box-shadow: inset 0 0 0 2px var(--orf-vert);
    font-weight: 700;
    font-size: 15px;
    line-height: 1.4;
    text-align: center;
    animation: orf-fondu .25s ease-out;
}

.orf__pave {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.orf__chiffre {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    aspect-ratio: 1.15;
    margin: 0;
    padding: 0;
    border: 1px solid var(--orf-border);
    border-radius: 12px;
    background: #fff;
    color: var(--orf-blue);
    font-family: var(--orf-mono);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.orf__chiffre:hover {
    border-color: var(--orf-blue);
}

.orf__chiffre:active {
    background: color-mix(in srgb, var(--orf-blue) 12%, white);
}

.orf__c-n {
    font-weight: 700;
    font-size: 26px;
    line-height: 1;
}

.orf__c-r {
    margin-top: 3px;
    color: var(--orf-gris);
    font-weight: 600;
    font-size: 11px;
    line-height: 1;
}

.orf__chiffre.is-complet {
    color: #B8BEC8;
}

.orf.is-notes .orf__chiffre {
    border-style: dashed;
    border-color: color-mix(in srgb, var(--orf-blue) 45%, white);
}

.orf.is-notes .orf__c-n {
    font-size: 18px;
}

.orf__actions {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.orf__actions .orf__btn {
    flex-direction: column;
    gap: 3px;
    min-height: 56px;
    padding: 6px 2px;
    font-size: 11.5px;
}

.orf__case-opt {
    display: flex;
    gap: 8px;
    align-items: center;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.orf__case-opt input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--orf-blue);
}

.orf__panneau .orf__hint {
    margin: -4px 0 0;
}

.orf__imprimable {
    display: none;
}

/* ---------- Morpion ---------- */

.orf__reglages {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 24px;
}

.orf__zone {
    padding: 18px;
    border-radius: 14px;
    background: var(--orf-tapis);
}

.orf .orf__statut {
    min-height: 1.5em;
    margin: 0 0 14px;
    font-weight: 700;
    font-size: 16px;
    line-height: 1.5;
    text-align: center;
}

.orf__statut.is-fin {
    color: var(--orf-blue);
}

.orf__morpion {
    --n: 3;
    display: grid;
    grid-template-columns: repeat(var(--n), minmax(0, 1fr));
    gap: 8px;
    width: min(100%, 372px);
    aspect-ratio: 1;
    margin: 0 auto;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.orf__morpion.is-grand {
    gap: 1px;
    width: min(100%, 600px);
    padding: 1px;
    border-radius: 8px;
    background: #CBD2DC;
}

.orf__mligne {
    display: contents;
}

.orf__mcase {
    position: relative;
    min-width: 0;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 1px 0 #CDD3DD;
    cursor: pointer;
}

.orf__morpion.is-grand .orf__mcase {
    border-radius: 0;
    box-shadow: none;
}

.orf__mcase:hover:not(.is-x):not(.is-o) {
    background: color-mix(in srgb, var(--orf-blue) 6%, white);
}

.orf.is-fini .orf__mcase,
.orf.is-reflechit .orf__mcase {
    cursor: default;
}

.orf__mcase:focus-visible {
    z-index: 1;
    outline-offset: -3px;
}

/* X : deux barres croisées ; O : un anneau. Tailles relatives à la case. */
.orf__mcase.is-x::before,
.orf__mcase.is-x::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 62%;
    height: 11%;
    border-radius: 99px;
    background: var(--orf-noir);
    transform: translate(-50%, -50%) rotate(45deg);
    animation: orf-pose .18s ease-out;
}

.orf__mcase.is-x::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.orf__mcase.is-o::before {
    content: '';
    position: absolute;
    inset: 20%;
    border: max(2px, calc(var(--t, 40px) * .1)) solid var(--orf-blue);
    border-radius: 50%;
    animation: orf-pose .18s ease-out;
}

.orf__morpion.is-grand .orf__mcase.is-x::before,
.orf__morpion.is-grand .orf__mcase.is-x::after {
    height: 14%;
}

.orf__morpion.is-grand .orf__mcase.is-o::before {
    inset: 18%;
    border-width: 2.5px;
}

.orf__mcase.is-dernier,
.orf__morpion.is-grand .orf__mcase.is-dernier {
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--orf-blue) 35%, white);
}

.orf__mcase.is-gagne {
    background: #FFF1B8;
}

.orf__morpion:not(.is-grand) .orf__mcase.is-o::before {
    border-width: 9px;
}

/* ---------- Statistiques, aide ---------- */

.orf__options {
    margin-top: 20px;
    padding-top: 8px;
    border-top: 1px solid var(--orf-border);
}

.orf__details {
    margin: 0;
    padding: 10px 0;
}

.orf__details + .orf__details {
    border-top: 1px solid var(--orf-border);
}

.orf__details summary {
    width: fit-content;
    padding: 4px 0;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}

.orf__details[open] summary {
    margin-bottom: 10px;
}

.orf__table-wrap {
    overflow-x: auto;
}

.orf__stats {
    width: 100%;
    margin: 0 0 10px;
    border-collapse: collapse;
    font-size: 14px;
}

.orf__stats th,
.orf__stats td {
    padding: 7px 8px;
    border-bottom: 1px solid var(--orf-border);
    text-align: left;
}

.orf__stats td {
    font: 600 14px var(--orf-mono);
}

.orf__aide {
    margin: 0;
    padding-left: 18px;
    color: var(--orf-gris);
    font-size: 14px;
    line-height: 1.55;
}

.orf__aide li {
    margin: 0 0 6px;
}

@keyframes orf-fondu {
    from {
        opacity: 0;
    }
}

@keyframes orf-pose {
    from {
        opacity: 0;
        scale: .6;
    }
}

/* ---------- Tablette et mobile ---------- */

@media (max-width: 860px) {
    .orf__jeu {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
    }

    .orf__panneau {
        width: min(100%, 540px);
        margin: 0 auto;
    }

    .orf__pave {
        grid-template-columns: repeat(9, 1fr);
        gap: 4px;
    }

    .orf__chiffre {
        aspect-ratio: auto;
        height: 54px;
        border-radius: 10px;
    }

    .orf__c-n {
        font-size: 22px;
    }

    .orf__bandeau {
        order: -1;
    }
}

@media (max-width: 640px) {
    .orf {
        padding: 16px 10px 18px;
    }

    .orf__tete {
        padding: 0 4px;
    }

    .orf .orf__titre {
        font-size: 1.25rem;
    }

    .orf__compteurs {
        width: 100%;
    }

    .orf__compteurs > div {
        flex: 1 1 0;
        min-width: 0;
        padding: 5px 8px;
    }

    .orf__compteurs dt {
        font-size: 10px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .orf__barre .orf__btn {
        flex: 1 1 0;
        flex-direction: column;
        gap: 3px;
        min-height: 52px;
        padding: 6px 2px;
        font-size: 12px;
        text-align: center;
    }

    .orf__reglage {
        gap: 6px;
        padding: 0 4px;
    }

    .orf__reglage label {
        min-height: 38px;
        padding: 6px 11px;
        font-size: 13px;
    }

    .orf__niveaux {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 5px;
    }

    .orf__niveaux label {
        gap: 5px;
        justify-content: center;
        padding: 6px 4px;
    }

    .orf__niveaux input {
        width: 14px;
        height: 14px;
    }

    .orf__jeu,
    .orf__zone {
        padding: 6px;
        border-radius: 10px;
    }

    .orf__grille {
        border-radius: 8px;
    }

    .orf__case {
        font-size: clamp(18px, 6vw, 26px);
    }

    .orf__notes {
        padding: 1px;
        font-size: clamp(8px, 2.5vw, 11px);
    }

    .orf__chiffre {
        height: 50px;
    }

    .orf__c-r {
        font-size: 10px;
    }

    .orf__reglages {
        grid-template-columns: minmax(0, 1fr);
    }

    .orf__morpion {
        gap: 6px;
    }

    .orf__morpion:not(.is-grand) .orf__mcase.is-o::before {
        border-width: 7px;
    }

    .orf__morpion.is-grand .orf__mcase.is-o::before {
        inset: 16%;
        border-width: 2px;
    }

    .orf__morpion.is-grand .orf__mcase.is-x::before,
    .orf__morpion.is-grand .orf__mcase.is-x::after {
        width: 70%;
        height: 15%;
    }

    .orf__options {
        padding: 8px 4px 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .orf__voile,
    .orf__bandeau,
    .orf__mcase::before,
    .orf__mcase::after {
        animation: none !important;
    }
}

/* ---------- Impression : la grille de départ seule, en noir sur blanc ---------- */

@media print {
    /* Le bloc imprimable est ajouté directement dans <body> : on masque tout le reste, sans pages blanches. */
    body.orf-imprime > *:not(.orf__imprimable) {
        display: none !important;
    }

    body.orf-imprime > .orf__imprimable {
        display: block;
        color: #000;
        font-family: 'Plus Jakarta Sans', Arial, sans-serif;
    }

    .orf__imprimable .orf__i-t {
        margin: 0 0 4mm;
        font-weight: 800;
        font-size: 16pt;
        text-align: center;
    }

    .orf__imprimable .orf__i-p {
        margin: 0 0 8mm;
        font-size: 10pt;
        text-align: center;
    }

    .orf__imprimable .orf__i-g {
        display: grid;
        grid-template-columns: repeat(9, 17mm);
        width: max-content;
        margin: 0 auto;
        border: 2pt solid #000;
    }

    .orf__imprimable .orf__i-g span {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 17mm;
        border-right: .5pt solid #777;
        border-bottom: .5pt solid #777;
        font: 700 20pt Arial, sans-serif;
    }

    .orf__imprimable .orf__i-g span.is-c2,
    .orf__imprimable .orf__i-g span.is-c5 {
        border-right: 2pt solid #000;
    }

    .orf__imprimable .orf__i-g span.is-l2,
    .orf__imprimable .orf__i-g span.is-l5 {
        border-bottom: 2pt solid #000;
    }

    .orf__imprimable .orf__i-g span.is-c8 {
        border-right: 0;
    }

    .orf__imprimable .orf__i-g span.is-l8 {
        border-bottom: 0;
    }

    .orf__imprimable .orf__i-s {
        margin: 10mm 0 0;
        font-size: 9pt;
        text-align: center;
    }
}
