/* =============================================================
   Aitia — Pagina interna (dossier NAF / elenco feuillets)
   Override per il markup esistente generato da Gutenberg
   (tabella core/table con <mark>/<a> wrappati, senza classi custom).
   
   Target: la tabella dentro la .mrc_page-content (o il container che
   avvolge la single-page del dossier). Usiamo un CONTAINER WRAPPER
   .mrc_naf da aggiungere manualmente al blocco Gruppo che contiene la
   tabella (unica modifica necessaria in editor, o aggiunta via hook).
   
   Se non vuoi toccare l'editor, sostituisci `.mrc_naf table` con
   `.entry-content table` (pi  generico).
   ============================================================= */

/* === Container (opzionale, ma consigliato) =================== */
.mrc_naf {
    max-width: 1080px;
    margin: 0 auto;
    padding: 40px 32px 64px;
    color: #1b1b1b;
}

/* === Tabella ================================================= */
.mrc_naf table,
.entry-content table {     /* fallback */
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0 0;
    font-size: 14px;
    color: #3a3a3a;
    border: none !important;
}

/* Rimuove i bordi inline che WP mette sulle celle */
.mrc_naf table td,
.mrc_naf table th,
.entry-content table td,
.entry-content table th {
    border: none !important;
}

/* --- Intestazioni (prima riga tbody -> la trattiamo come thead) --- */
.mrc_naf table tbody tr:first-child td,
.entry-content table tbody tr:first-child td {
    text-align: left;
    font-family: var(--wp--preset--font-family--source-serif-pro, Georgia, serif);
    font-style: italic;
    font-weight: 500;
    font-size: 14px;
    color: #8e7e2e !important;
    padding: 10px 14px 12px !important;
    border-bottom: 1px solid #b1b1b1 !important;
    background: transparent !important;
    letter-spacing: .01em;
    text-transform: none;
}

/* Nascondi eventuali <mark> dentro la riga di intestazione */
.mrc_naf table tbody tr:first-child mark,
.entry-content table tbody tr:first-child mark {
    color: inherit !important;
    background: transparent !important;
}

/* --- Righe di contenuto --- */
.mrc_naf table tbody tr:not(:first-child),
.entry-content table tbody tr:not(:first-child) {
    transition: background .15s ease;
}

.mrc_naf table tbody tr:not(:first-child):nth-child(odd),
.entry-content table tbody tr:not(:first-child):nth-child(odd) {
    background: #fcfbf7;
}

.mrc_naf table tbody tr:not(:first-child):hover,
.entry-content table tbody tr:not(:first-child):hover {
    background: rgba(190, 170, 73, .08);
}

.mrc_naf table tbody tr:not(:first-child) td,
.entry-content table tbody tr:not(:first-child) td {
    padding: 14px !important;
    border-bottom: 1px solid #d9d4c7 !important;
    vertical-align: middle;
    font-size: 14px;
    color: #3a3a3a;
}

/* --- Colonna 1: Dossier (NAF 19093) --- */
.mrc_naf table tbody tr:not(:first-child) td:nth-child(1) a,
.entry-content table tbody tr:not(:first-child) td:nth-child(1) a {
    font-family: var(--wp--preset--font-family--source-serif-pro, Georgia, serif);
    font-size: 17px !important;
    font-weight: 500 !important;
    color: #1b1b1b !important;
    text-decoration: none !important;
    border-bottom: 1px solid #BEAA49;
    padding-bottom: 1px;
    background: transparent !important;
}

.mrc_naf table tbody tr:not(:first-child) td:nth-child(1) a:hover {
    color: #8e7e2e !important;
    border-bottom-color: #8e7e2e;
}

/* --- Colonna 2: Feuillet (numero) --- */
.mrc_naf table tbody tr:not(:first-child) td:nth-child(2),
.entry-content table tbody tr:not(:first-child) td:nth-child(2) {
    width: 90px;
}

.mrc_naf table tbody tr:not(:first-child) td:nth-child(2) a,
.entry-content table tbody tr:not(:first-child) td:nth-child(2) a {
    font-variant-numeric: tabular-nums;
    font-family: var(--wp--preset--font-family--source-serif-pro, Georgia, serif);
    font-size: 20px !important;
    font-weight: 500 !important;
    color: #8e7e2e !important;
    text-decoration: none !important;
    border-bottom: none !important;
    background: transparent !important;
}

.mrc_naf table tbody tr:not(:first-child) td:nth-child(2) a:hover {
    color: #1b1b1b !important;
}

/* Neutralizza i <mark> blu inline su col 1 e 2 */
.mrc_naf table tbody td mark,
.entry-content table tbody td mark {
    background: transparent !important;
    color: inherit !important;
}

/* --- Colonna 3: Image (miniatura) --- */
.mrc_naf table tbody tr:not(:first-child) td:nth-child(3),
.entry-content table tbody tr:not(:first-child) td:nth-child(3) {
    width: 76px;
}

.mrc_naf table tbody tr:not(:first-child) td:nth-child(3) img,
.entry-content table tbody tr:not(:first-child) td:nth-child(3) img {
    display: inline-block;
    width: 48px !important;
    height: auto !important;
    max-width: 48px;
    background: #fdfcf8;
    border: 1px solid #d9d4c7;
    padding: 3px;
    box-shadow: 2px 3px 0 rgba(0, 0, 0, .04);
    transition: transform .2s ease;
}

.mrc_naf table tbody tr:not(:first-child):hover td:nth-child(3) img,
.entry-content table tbody tr:not(:first-child):hover td:nth-child(3) img {
    transform: translateY(-1px) rotate(-.5deg);
}

/* --- Colonna 4: Année du cours --- */
.mrc_naf table tbody tr:not(:first-child) td:nth-child(4),
.entry-content table tbody tr:not(:first-child) td:nth-child(4) {
    font-variant-numeric: tabular-nums;
    color: #3a3a3a;
    width: 140px;
    font-size: 14px;
}

/* --- Colonna 5: Notions présentes --- */
.mrc_naf table tbody tr:not(:first-child) td:nth-child(5),
.entry-content table tbody tr:not(:first-child) td:nth-child(5) {
    font-family: var(--wp--preset--font-family--source-serif-pro, Georgia, serif);
    font-style: italic;
    font-size: 15px;
    color: #1b1b1b;
    line-height: 1.6;
}

/* === Responsive ============================================== */
@media (max-width: 820px) {
    .mrc_naf {
        padding: 24px 16px 48px;
    }

    .mrc_naf table,
    .mrc_naf table tbody,
    .mrc_naf table tr,
    .mrc_naf table td,
    .entry-content table,
    .entry-content table tbody,
    .entry-content table tr,
    .entry-content table td {
        display: block;
        width: 100% !important;
    }

    .mrc_naf table tbody tr:first-child,
    .entry-content table tbody tr:first-child {
        display: none;  /* nasconde l'header su mobile */
    }

    .mrc_naf table tbody tr:not(:first-child),
    .entry-content table tbody tr:not(:first-child) {
        display: grid !important;
        grid-template-columns: 76px 1fr;
        gap: 2px 14px;
        padding: 14px 0 !important;
        border-bottom: 1px solid #d9d4c7 !important;
        background: transparent !important;
    }

    .mrc_naf table tbody tr:not(:first-child) td,
    .entry-content table tbody tr:not(:first-child) td {
        border-bottom: none !important;
        padding: 2px 0 !important;
    }

    /* Miniatura su mobile occupa 4 righe della grid */
    .mrc_naf table tbody tr:not(:first-child) td:nth-child(3),
    .entry-content table tbody tr:not(:first-child) td:nth-child(3) {
        grid-row: span 4;
        grid-column: 1;
    }

    /* Le altre celle vanno nella seconda colonna */
    .mrc_naf table tbody tr:not(:first-child) td:nth-child(1),
    .mrc_naf table tbody tr:not(:first-child) td:nth-child(2),
    .mrc_naf table tbody tr:not(:first-child) td:nth-child(4),
    .mrc_naf table tbody tr:not(:first-child) td:nth-child(5),
    .entry-content table tbody tr:not(:first-child) td:nth-child(1),
    .entry-content table tbody tr:not(:first-child) td:nth-child(2),
    .entry-content table tbody tr:not(:first-child) td:nth-child(4),
    .entry-content table tbody tr:not(:first-child) td:nth-child(5) {
        grid-column: 2;
        width: auto !important;
    }
}
