:root {
    --bg-color: #f2f2f2;
    --text-color: #2e3744;
    --text-muted: #5f6e84;
}

body {
    font-family: 'Faustina', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.25;
    color: var(--text-color);
    max-width: 1000px;
    margin: 20px auto;
    padding: 0 20px;
    background-color: var(--bg-color);
    background-attachment: fixed;
    background-image: 
        linear-gradient(to right, var(--bg-color) 0px, transparent 60px, transparent calc(100% - 60px), var(--bg-color) 100%),
        linear-gradient(to bottom, var(--bg-color) 0px, transparent 60px, transparent calc(100% - 60px), var(--bg-color) 100%),
        url("assets/notebook-dark.png");
}

h1, h2, .macro-area-title { 
    font-family: 'Archivo', -apple-system, sans-serif;
}

h1 { 
    color: var(--text-color); 
    font-size: 3.6rem;
    font-weight: 900;
    font-variation-settings:
        "wdth" 100;
    margin-bottom: 8px;
    letter-spacing: -0.035em;
    margin: auto;
    text-align: center;

}

/* h1 span {
    background: linear-gradient(90deg, #15186e, #163882, #036446, #8c3506);
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    
    filter: hue-rotate(0deg) contrast(120%);
    animation: shiftHue 15s infinite linear;
} 

@keyframes shiftHue {
    to { filter: hue-rotate(360deg) contrast(120%); }
}*/

.subtitle {
    font-family: 'Faustina', -apple-system, sans-serif;
    font-size: 1.4rem;
    font-weight: 600;
    color: #323c4b;
    text-align: center;
    margin-top: 0px;
    margin-bottom: 10px;
    min-height: 2rem; /* Evita oscillazioni di layout */
}

.wolf-icon {
  padding-top: 10px;
  display: inline-block;
  width: 1.2em; /* Regola la dimensione desiderata */
  height: 1.5em;
  
  /* Gradiente di sfondo */
  background: currentColor;  
  
  /* Maschera SVG */
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36"><path d="M14.858 9.497c.475 2.326-.182 4.236-2.921 4.638-2.741.403-6.7 3.898-8.848-1.798C1.844 9.038 1.092 2.234 2.628 2.009c1.537-.226 11.756 5.162 12.23 7.488z"/><path d="M12.784 9.851c.865 1.392-2.205 3.833-3.844 4.568-1.639.736-2.915-.66-4.173-4.1-.55-1.503-1.234-5.532-.634-5.802.599-.268 7.785 3.942 8.651 5.334z"/><path d="M21.372 9.497c-.458 2.326.176 4.236 2.818 4.638 2.644.403 6.464 3.898 8.536-1.798 1.201-3.3 1.927-10.103.445-10.329-1.483-.225-11.342 5.163-11.799 7.489z"/><path d="M23.373 9.851c-.835 1.392 2.127 3.833 3.708 4.568 1.581.736 2.812-.66 4.026-4.1.531-1.503 1.19-5.532.611-5.802-.577-.268-7.509 3.942-8.345 5.334z"/><path d="M32.347 26.912c0-.454-.188-1.091-.407-1.687.585.028 1.519.191 2.77.817-.008-.536-.118-.984-.273-1.393.041.02.075.034.116.055-1.104-3.31-3.309-5.517-3.309-5.517h2.206c-2.331-4.663-4.965-8.015-8.075-9.559-1.39-.873-3.688-1.338-7.373-1.339h-.003c-3.696 0-5.996.468-7.385 1.346-3.104 1.547-5.734 4.896-8.061 9.552H4.76s-2.207 2.206-3.311 5.517l.084-.039c-.201.392-.307.847-.282 1.377 1.263-.632 2.217-.792 2.813-.818-.189.513-.343 1.044-.386 1.475-.123.371-.191.812-.135 1.343 3.207-1.458 4.707-1.25 6.457-.375C11.213 31.29 14.206 34 18.001 34c3.793 0 6.746-2.794 7.958-6.416 1.458-1.25 3.708-.875 6.416.416.066-.413.036-.773-.036-1.093l.008.005z"/><path d="M34.553 24.704c-.437-1.313-3.665-3.101-6.973-4.513.26-.664.42-1.401.42-2.191 0-2.761-1.791-5-4-5s-4 2.239-4 5c0 3 4 10-2.001 11.118-5.125-.955-2.954-6.201-2.212-9.58.072-.276.125-.559.158-.853.034-.245.055-.476.055-.685 0-2.761-1.791-5-4-5s-4 2.239-4 5c0 .79.16 1.527.421 2.191-3.308 1.412-6.535 3.2-6.973 4.513C3.655 23.6 4.759 23.6 4.759 23.6s-1.104 2.208-1.104 3.312c2.67-1.78 5.339-2.122 7.429-.452C12.297 30.083 14 33 18.001 30.124c3.999 2.876 5.7-.04 6.912-3.662 2.092-1.673 4.763-1.33 7.434.45 0-1.104-1.103-3.312-1.103-3.312s1.103.001 3.309 1.104z"/><path d="M11 17s0-1.5 1.5-1.5S14 17 14 17v1.5s0 1.5-1.5 1.5-1.5-1.5-1.5-1.5V17zm11 0s0-1.5 1.5-1.5S25 17 25 17v1.5s0 1.5-1.5 1.5-1.5-1.5-1.5-1.5V17zm-7.061 9.156c-1.021.208 2.041 3.968 3.062 3.968 1.02 0 4.082-3.76 3.062-3.968s-5.103-.208-6.124 0z"/></svg>');
  mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36"><path d="M14.858 9.497c.475 2.326-.182 4.236-2.921 4.638-2.741.403-6.7 3.898-8.848-1.798C1.844 9.038 1.092 2.234 2.628 2.009c1.537-.226 11.756 5.162 12.23 7.488z"/><path d="M12.784 9.851c.865 1.392-2.205 3.833-3.844 4.568-1.639.736-2.915-.66-4.173-4.1-.55-1.503-1.234-5.532-.634-5.802.599-.268 7.785 3.942 8.651 5.334z"/><path d="M21.372 9.497c-.458 2.326.176 4.236 2.818 4.638 2.644.403 6.464 3.898 8.536-1.798 1.201-3.3 1.927-10.103.445-10.329-1.483-.225-11.342 5.163-11.799 7.489z"/><path d="M23.373 9.851c-.835 1.392 2.127 3.833 3.708 4.568 1.581.736 2.812-.66 4.026-4.1.531-1.503 1.19-5.532.611-5.802-.577-.268-7.509 3.942-8.345 5.334z"/><path d="M32.347 26.912c0-.454-.188-1.091-.407-1.687.585.028 1.519.191 2.77.817-.008-.536-.118-.984-.273-1.393.041.02.075.034.116.055-1.104-3.31-3.309-5.517-3.309-5.517h2.206c-2.331-4.663-4.965-8.015-8.075-9.559-1.39-.873-3.688-1.338-7.373-1.339h-.003c-3.696 0-5.996.468-7.385 1.346-3.104 1.547-5.734 4.896-8.061 9.552H4.76s-2.207 2.206-3.311 5.517l.084-.039c-.201.392-.307.847-.282 1.377 1.263-.632 2.217-.792 2.813-.818-.189.513-.343 1.044-.386 1.475-.123.371-.191.812-.135 1.343 3.207-1.458 4.707-1.25 6.457-.375C11.213 31.29 14.206 34 18.001 34c3.793 0 6.746-2.794 7.958-6.416 1.458-1.25 3.708-.875 6.416.416.066-.413.036-.773-.036-1.093l.008.005z"/><path d="M34.553 24.704c-.437-1.313-3.665-3.101-6.973-4.513.26-.664.42-1.401.42-2.191 0-2.761-1.791-5-4-5s-4 2.239-4 5c0 3 4 10-2.001 11.118-5.125-.955-2.954-6.201-2.212-9.58.072-.276.125-.559.158-.853.034-.245.055-.476.055-.685 0-2.761-1.791-5-4-5s-4 2.239-4 5c0 .79.16 1.527.421 2.191-3.308 1.412-6.535 3.2-6.973 4.513C3.655 23.6 4.759 23.6 4.759 23.6s-1.104 2.208-1.104 3.312c2.67-1.78 5.339-2.122 7.429-.452C12.297 30.083 14 33 18.001 30.124c3.999 2.876 5.7-.04 6.912-3.662 2.092-1.673 4.763-1.33 7.434.45 0-1.104-1.103-3.312-1.103-3.312s1.103.001 3.309 1.104z"/><path d="M11 17s0-1.5 1.5-1.5S14 17 14 17v1.5s0 1.5-1.5 1.5-1.5-1.5-1.5-1.5V17zm11 0s0-1.5 1.5-1.5S25 17 25 17v1.5s0 1.5-1.5 1.5-1.5-1.5-1.5-1.5V17zm-7.061 9.156c-1.021.208 2.041 3.968 3.062 3.968 1.02 0 4.082-3.76 3.062-3.968s-5.103-.208-6.124 0z"/></svg>');
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;


}

#carousel-text::after {
    content: '|';
    margin-left: 3px;
    color: var(--text-color);
    animation: cursore 0.75s step-end infinite;
}

.intro {
    font-size: 1.15rem;    
    color: var(--text-muted);
    margin: 0 auto 50px auto;
    text-align: center;
    max-width: 700px;
}

.macro-area-title {
    font-size: 1.5rem;
    font-variation-settings:
        "wdth" 110;
    color: var(--text-color);
    margin-top: 50px;
    margin-bottom: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); 
    gap: 15px; 
    margin-bottom: 20px;
}

.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
    border-radius: 20px;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.card { 
    background: white; 
    border-radius: 5px; 
    height: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(15, 23, 42, 0.04);
    box-shadow: 0 4px 10px -1px rgba(15, 23, 42, 0.03), 0 2px 4px -1px rgba(15, 23, 42, 0.02);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Contenitore per l'immagine della copertina intera */
.card-cover {
    width: 100%;
    height: 220px;
    background-color: #f8fafc;
    overflow: hidden;
    position: relative;
    border-bottom: 1px solid rgba(15, 23, 42, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-cover img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
    padding: 12px;
    box-sizing: border-box;
}

/* Effetto zoom sulla copertina al passaggio del mouse */
/* .card-link:hover .card-cover img {
    transform: scale(1.04);
} */

/* Il gradiente colorato si applica come linea superiore */
/* .card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: var(--materia-gradient);
    z-index: 2;
} */

/* Contenuto testuale strutturato per spingere il pulsante in basso */
.card-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* .card-link:hover {
    transform: translateY(-6px);
    box-shadow: 0 22px 30px -5px rgba(15, 23, 42, 0.08), 0 12px 15px -5px rgba(15, 23, 42, 0.04);
} */

.card h2 { 
    margin: 0 0 12px 0; 
    color: var(--text-color); 
    font-family: 'Archivo', -apple-system, sans-serif;
    font-size: 1.3rem; 
    font-variation-settings:
        "wdth" 80; 
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.2s ease;
}

.card p {
    font-family: 'Archivo', -apple-system, sans-serif;
    font-size: 0.95rem;
    font-variation-settings:
        "wdth" 85;
    line-height: 1.4;
    letter-spacing: -0.01em;
    margin: 0 0 24px 0;
    color: var(--text-muted);
    flex-grow: 1; /* Spinge il pulsante sul fondo della card */
}

.card-link:hover .card h2 {
    color: var(--hover-color);
}

/* Il pulsante di download centrato che riprende il gradiente dinamico */
.download-btn {
    display: block;
    width: fit-content;
    margin: 0 auto;
    padding: 5px 15px;
    background: var(--materia-gradient);
    color: white;
    font-family: 'Archivo';
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 3px;
    text-align: center;
    transition: transform 0.2s ease, filter 0.2s ease;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.card-link:hover .download-btn {
    filter: brightness(1.10);
    /* transform: scale(1.03); */
}

/* -----------------------------------------------------------------
   TAVOLOZZA GRADIENTI ARMONIZZATA PER MACRO-AREE
----------------------------------------------------------------- */
.matematica     { --materia-gradient: linear-gradient(90deg, #0247b6, #3b82f6); --hover-color: #2563eb; } 
.fisica         { --materia-gradient: linear-gradient(90deg, #4B0082, #6f02bc); --hover-color: #4f46e5; } 
.chimica        { --materia-gradient: linear-gradient(90deg, #008080, #00b1b1); --hover-color: #0d9488; } 
.biologia       { --materia-gradient: linear-gradient(90deg, #00755E, #00a987); --hover-color: #059669; } 
.scienze-terra  { --materia-gradient: linear-gradient(90deg, #007BA7, #0297cd); --hover-color: #0284c7; } 

.letteratura-it { --materia-gradient: linear-gradient(90deg, #882D17, #d74b27); --hover-color: #ea580c; } 
.letteratura-en { --materia-gradient: linear-gradient(90deg, #C94F00, #ec5f00); --hover-color: #d97706; } 
.letteratura-la { --materia-gradient: linear-gradient(90deg, #7e2b02, #d34600); --hover-color: #b45309; } 

.storia         { --materia-gradient: linear-gradient(90deg, #C80815, #ed0918); --hover-color: #991b1b; } 
.storia-arte    { --materia-gradient: linear-gradient(90deg, #8A7500, #b59a01); --hover-color: #be185d; } 
.filosofia      { --materia-gradient: linear-gradient(90deg, #66023C, #a30160); --hover-color: #e23eb1; } 

/* -----------------------------------------------------------------
   GRIGLIA DI SOLE ANTEPRIME
----------------------------------------------------------------- */
.book-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.book-thumb-cover {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 10px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.book-thumb-cover img {
    display: block;
    width: 100%;
    aspect-ratio: 5 / 7;
    object-fit: cover;
}

.book-thumb:hover .book-thumb-cover,
.book-thumb:focus-visible .book-thumb-cover {
    transform: translateY(-4px);
    box-shadow: 0 14px 20px -5px rgba(15, 23, 42, 0.15), 0 8px 10px -5px rgba(15, 23, 42, 0.06);
}

/* Linguetta diagonale "Incompleto: solo testo" sulle copertine -- stesso
   principio del .github-corner ma incollata sull'angolo dell'immagine.
   Il contenitore (.book-thumb-cover o .modal-cover) deve avere
   position: relative + overflow: hidden perche' funzioni. */
.ribbon {
    position: absolute;
    top: 17px;
    left: -42px;
    width: 150px;
    padding: 7px 0;
    background: #e73f0c;
    color: #fff;
    font-family: 'Archivo', sans-serif;
    font-size: 0.68rem;
    font-weight: 900;
    text-align: center;
    text-transform: uppercase;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);    
    transform: rotate(-45deg);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    z-index: 3;
    pointer-events: none;
}

/* -----------------------------------------------------------------
   MODALE DI DETTAGLIO
----------------------------------------------------------------- */
#book-modal {
    border: none;
    border-radius: 20px;
    padding: 0;
    max-width: 720px;
    width: 90vw;
    background: white;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
}

#book-modal::backdrop {
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
}

#modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: none;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.06);
    color: var(--text-color);
    font-size: 1rem;
    cursor: pointer;
    z-index: 2;
}

#modal-close:hover {
    background: rgba(15, 23, 42, 0.12);
}

.modal-content {
    display: flex;
    gap: 28px;
    padding: 32px;
}

.modal-cover {
    flex-shrink: 0;
    width: 220px;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
}

.modal-cover img {
    display: block;
    width: 100%;
    box-shadow: 0 8px 16px -4px rgba(15, 23, 42, 0.15);
}

.modal-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-width: 0;
}

.modal-info h2 {
    margin: 0 0 12px 0;
    font-family: 'Archivo', -apple-system, sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    font-variation-settings:
        "wdth" 85;
    color: var(--text-color);
}

.modal-info p {
    font-family: 'Faustina', -apple-system, serif;
    font-size: 0.98rem;
    line-height: 1.5;
    color: var(--text-muted);
    flex-grow: 1;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.modal-btn {
    display: block;
    text-align: center;
    padding: 10px 18px;
    border-radius: 8px;
    text-decoration: none;
    font-family: 'Archivo';
    font-weight: 500;
    font-size: 0.95rem;
    background: var(--materia-gradient);
    color: white;
    transition: filter 0.2s ease;
}

.modal-btn:hover {
    filter: brightness(1.1);
}

.modal-btn-secondary {
    background: white;
    color: var(--hover-color);
    border: 1.5px solid var(--hover-color);
    transition: background-color 0.2s ease, filter 0.2s ease;
}

.modal-btn-secondary:hover {
    background: color-mix(in srgb, var(--hover-color) 8%, white);
}

.modal-btn-disabled {
    background: #e2e8f0;
    color: #94a3b8;
    border: 1.5px solid #e2e8f0;
    cursor: not-allowed;
    pointer-events: none;
}

@media (max-width: 640px) {
    #book-modal {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .modal-content {
        flex-direction: column;
        padding: 24px;
    }

    .modal-cover {
        width: 100%;
        max-width: 260px;
        margin: 0 auto;
    }
}

/* Struttura del footer informativo */
.footer {
    margin-top: 90px;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    border-top: 1px solid #e2e8f0;
    padding-top: 30px;
    padding-bottom: 30px;
    background-color: var(--bg-color);

}

.footer p {
    margin: 6px 0;
}

.footer a {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
}

.footer a:hover {
    text-decoration: underline;
}

.license-badge {
    display: inline-block;
    margin-top: 10px;
    padding: 4px 10px;
    background-color: #e2e8f0;
    color: #475569;
    border-radius: 6px;
    font-family: 'Archivo';
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.05em;
}

/* -----------------------------------------------------------------
   GITHUB CORNER (SVG + ANIMAZIONE)
----------------------------------------------------------------- */
.github-corner {
    position: absolute;
    top: 0;
    right: 0;
    border: 0;
    z-index: 9999;
    width: 80px;
    height: 80px;
    overflow: hidden;
}

.github-corner svg {
    fill: url(#github-gradient); /* Sempre a gradiente */
    color: var(--bg-color);
    width: 80px;
    height: 80px;
    transition: transform 0.2s ease; /* Puoi animare la scalata invece del colore */
}

.github-corner:hover svg {
    transform: scale(1.05); /* Giusto un accenno di zoom sull'angolo */
}

/* Al passaggio del mouse il corner si colora con il blu della matematica */
.github-corner:hover .octo-arm {
    animation: octocat-wave 560ms ease-in-out;
}

/* Animazione dell'icona (saluto dell'Octocat) */
@keyframes octocat-wave {
    0%, 100% { transform: rotate(0); }
    20%, 60% { transform: rotate(-25deg); }
    40%, 80% { transform: rotate(10deg); }
}

/* Ottimizzazione per dispositivi mobile: disattiva l'animazione */
@media (max-width: 500px) {
    .github-corner:hover .octo-arm { animation: none; }
    .github-corner .octo-arm { animation: octocat-wave 560ms ease-in-out; }
}

/* -----------------------------------------------------------------
   BANNER INFORMATIVO SUPERIORE
----------------------------------------------------------------- */
.info-banner {
    max-width: 750px;
    margin: 0 auto 20px auto;
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-left: 5px solid #f59e0b;
    border-radius: 16px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    color: #78350f;
    font-size: 0.95rem;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.03);
}

.banner-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.banner-content {
    line-height: 1.5;
}

.banner-content strong {
    color: #451a03;
}