/* Overlay popup notes */
.notes-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 22px;
    z-index: 2000;
    background:
        radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.16), transparent 45%),
        radial-gradient(circle at 80% 85%, rgba(255, 255, 255, 0.12), transparent 40%),
        rgba(8, 12, 24, 0.58);
    backdrop-filter: blur(12px);
}

@keyframes notesPopupEnter {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.notes-popup {
    display: flex;
    flex-direction: column;
    gap: 25px;
    padding: 30px 30px 24px;
    border-radius: 28px;
    min-width: 320px;
    max-width: min(860px, 94vw);
    width: 800px;
    min-height: 440px;
    max-height: min(860px, 92vh);
    height: auto;
    text-align: center;
    position: relative;
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.12));
    border: 1px solid rgba(255, 255, 255, 0.46);
    backdrop-filter: blur(24px) saturate(165%);
    -webkit-backdrop-filter: blur(24px) saturate(165%);
    box-shadow:
        0 26px 56px rgba(2, 8, 23, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.76),
        inset 0 -1px 0 rgba(255, 255, 255, 0.16);
    overflow-x: hidden;
    overflow-y: auto;
    scroll-behavior: smooth;
    color: #0f172a;
    opacity: 0;
    transform: translateY(18px) scale(0.985);
}

.notes-overlay.is-open .notes-popup {
    animation: notesPopupEnter 320ms cubic-bezier(0.2, 0.75, 0.2, 1) forwards;
}

.notes-popup::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(
      -45deg,
            rgba(255, 255, 255, 0.58) 0%,
            rgba(255, 255, 255, 0.14) 30%,
            rgba(255, 255, 255, 0.06) 52%,
            rgba(255, 255, 255, 0.20) 75%,
            rgba(255, 255, 255, 0.08) 100%
    );
  mix-blend-mode: screen;
    opacity: 0.86;
}

.notes-popup::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  pointer-events: none;

  background:
    radial-gradient(
            circle at 72% 18%,
            rgba(255, 255, 255, 0.74),
            rgba(255, 255, 255, 0.20) 25%,
      transparent 55%
    );
  opacity: 0.5;
}

.notes-popup > * {
  position: relative;
  z-index: 1;
}
.notes-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.52);
    border: 1px solid rgba(255, 255, 255, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    line-height: 1;
    color: rgba(15, 23, 42, 0.86);
    cursor: pointer;
    transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
    z-index: 10;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
}
.notes-close:hover {
    background: rgba(255, 255, 255, 0.82);
    transform: translateY(-1px) scale(1.03);
}

.notes-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    margin-bottom: 2px;
}

.notes-header img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
}

.notes-logo {
    width: 82px;
    height: 82px;
    padding: 13px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.85);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.48));
    box-shadow:
        0 10px 24px rgba(15, 23, 42, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    transition: transform 220ms ease, box-shadow 220ms ease;
}

.notes-logo:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow:
        0 14px 28px rgba(15, 23, 42, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 1);
}

.notes-header h3 {
    margin: 0;
    font-size: clamp(26px, 3.4vw, 34px);
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #0f172a;
}

.notes-header h6 {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    color: rgba(15, 23, 42, 0.62);
}

.notes-content {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 32px;
    margin-top: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scroll-behavior: smooth;
    padding: 6px 16px 12px;
    scroll-padding-left: 16px;
    scroll-snap-type: x proximity;
}

.general-topic {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 134px;
    flex: 0 0 auto;
    scroll-snap-align: start;
}

.general-topic h6 {
    margin: 0;
    font-size: 12px;
    color: rgba(15, 23, 42, 0.88);
    font-weight: 600;
    line-height: 1.3;
    white-space: normal;
}

.notes-content .lecture{
    display: flex;
    align-items: center;
    justify-content: center;
    width: 124px;
    height: 124px;
    padding: 10px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.44));
    border: 1px solid rgba(255, 255, 255, 0.82);
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.14);
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.notes-content .lecture:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 24px rgba(15, 23, 42, 0.18);
}

.lecture .topic {
    width: 90px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 200ms ease;
}

.lecture:hover .topic {
    transform: scale(1.12);
    cursor: pointer;
}

.view-notes {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 4px;
    gap: 2px;
    border:none;
    padding-top:4px;
    padding-bottom:4px;
    background: rgba(255, 255, 255, 0.72);
    border-radius: 8px;
}

.view-notes img {
    width: 20px;
    height: 20px;
}

.view-notes h6 {
    font-size: 12px;
    margin-top: 0px;
    font-weight: 300;
    color: #00000099;
}

.notes-detail {
    margin-top: 12px;
    padding: 14px 14px 12px;
    border-radius: 20px;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0.22));
    border: 1px solid rgba(255, 255, 255, 0.68);
    text-align: left;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 10px 26px rgba(2, 8, 23, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.7);
    color: #0f172a;
}

.notes-detail-hidden {
    display: none;
}

.notes-detail-label {
    display: inline-block;
    font-size: 10px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: rgba(15, 23, 42, 0.78);
    margin-bottom: 10px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.7);
}

.notes-detail-title {
    margin: 0;
    font-size: 22px;
    line-height: 1.2;
    color: #000000;
}

.notes-detail-description {
    margin: 8px 0 0;
    font-size: 14px;
    line-height: 1.5;
    color: rgba(0, 0, 0, 0.82);
}

.notes-doc-list {
    margin-top: 8px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    overflow-x: auto;
    padding: 4px 2px 8px;
}

.notes-doc-item {
    min-width: 92px;
    max-width: 104px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 7px;
    padding: 10px 8px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.82);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.1);
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.notes-doc-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.14);
}

.notes-doc-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.notes-doc-title {
    margin: 0;
    font-size: 11px;
    line-height: 1.3;
    color: rgba(15, 23, 42, 0.9);
    font-weight: 500;
}

.notes-content::-webkit-scrollbar,
.notes-doc-list::-webkit-scrollbar,
.notes-popup::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.notes-content::-webkit-scrollbar-thumb,
.notes-doc-list::-webkit-scrollbar-thumb,
.notes-popup::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.28);
}

.notes-content::-webkit-scrollbar-track,
.notes-doc-list::-webkit-scrollbar-track,
.notes-popup::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.22);
    border-radius: 999px;
}

@media (max-width: 900px) {
    .notes-overlay {
        padding: 12px;
    }

    .notes-popup {
        width: 100%;
        max-width: 100%;
        min-height: 0;
        max-height: 94vh;
        border-radius: 22px;
        padding: 20px 16px 16px;
    }

    .notes-logo {
        width: 70px;
        height: 70px;
    }

    .general-topic {
        width: 118px;
    }

    .notes-content .lecture {
        width: 108px;
        height: 108px;
    }

    .lecture .topic {
        width: 78px;
        height: 78px;
    }
}

/* ===================== */
/* DOCUMENTI SCARICABILI */
/* ===================== */

.notes-popup .notes-detail {
    margin-top: 6px;
    padding: 16px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.notes-popup .notes-detail.notes-detail-hidden {
    display: none;
}

.notes-detail-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    margin-bottom: 12px;
}

.notes-popup .notes-detail-label {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--color-primary);
}

.notes-detail-note {
    margin: 0;
    font-size: 13px;
    color: #5f5a57;
}

.notes-popup .notes-doc-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow: visible;
}

.notes-doc {
    display: flex;
    align-items: stretch;
    min-width: 0;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: inset 0 1px 0 #fff;
    animation: notesDocIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
    transition: box-shadow 0.2s ease, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.notes-doc:nth-child(2) { animation-delay: 0.03s; }
.notes-doc:nth-child(3) { animation-delay: 0.06s; }
.notes-doc:nth-child(4) { animation-delay: 0.09s; }
.notes-doc:nth-child(n+5) { animation-delay: 0.12s; }

@keyframes notesDocIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

@media (hover: hover) {
    .notes-doc:hover {
        transform: translateY(-1px);
        box-shadow: inset 0 1px 0 #fff, 0 10px 24px rgba(60, 20, 20, 0.08);
    }
}

.notes-doc-open {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: inherit;
    text-decoration: none;
    border-radius: 14px 0 0 14px;
}

.notes-doc-badge {
    flex: 0 0 auto;
    width: 38px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 6px 12px 6px 6px;
    background: var(--color-primary);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
}

.notes-doc-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
}

.notes-popup .notes-doc-title {
    margin: 0;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    white-space: normal;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--color-text);
}

.notes-doc-meta {
    font-size: 12px;
    color: #6b6461;
}

.notes-doc-download {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    border-left: 1px solid rgba(26, 26, 26, 0.07);
    border-radius: 0 14px 14px 0;
    color: var(--color-primary);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s ease;
}

.notes-doc-download svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.notes-doc-download:hover {
    background: rgba(159, 9, 9, 0.08);
}

.notes-doc-open:focus-visible,
.notes-doc-download:focus-visible {
    outline: 3px solid rgba(159, 9, 9, 0.45);
    outline-offset: -3px;
}

/* argomento selezionato */
.lecture .topic.is-selected {
    transform: scale(1.12);
}

.general-topic:has(.topic.is-selected) .lecture {
    box-shadow: 0 0 0 3px var(--color-primary), 0 10px 22px rgba(15, 23, 42, 0.14);
}

@media (max-width: 768px) {
    .notes-popup .notes-doc-list {
        grid-template-columns: 1fr;
    }

    .notes-doc-download span {
        display: none;
    }

    .notes-doc-download {
        padding: 0 16px;
    }
}


/* ===================== */
/* SCROLL DELLA SEZIONE  */
/* Intestazione e topic restano fissi; scorre solo l'elenco dei documenti. */
/* ===================== */

.modal-overlay .notes-popup {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* nessun elemento in alto può essere "schiacciato" dall'elenco */
.notes-popup > .modal-head,
.notes-popup > .notes-content {
    flex-shrink: 0;
}

/* con un topic aperto la popup ha un'altezza stabile: cambiando topic non salta */
.modal-overlay .notes-popup.has-detail {
    height: min(88vh, 740px);
}

.notes-popup .notes-detail {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.notes-popup .notes-detail.notes-detail-hidden {
    display: none;
}

.notes-detail-head {
    flex-shrink: 0;
}

.notes-popup .notes-doc-list {
    flex: 1 1 auto;
    min-height: 0;
    align-content: start;
    overflow-y: auto;
    overscroll-behavior: contain;
    margin-right: -6px;
    padding: 2px 6px 22px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(159, 9, 9, 0.35) transparent;
    /* sfumatura in fondo: segnala che ci sono altri documenti */
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent);
}

.notes-popup .notes-doc-list::-webkit-scrollbar {
    width: 6px;
}

.notes-popup .notes-doc-list::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(159, 9, 9, 0.35);
}

.notes-popup .notes-doc-list::-webkit-scrollbar-track {
    background: transparent;
}

/* con un topic aperto i cerchi diventano più piccoli: più spazio per l'elenco */
.notes-content .lecture,
.lecture .topic,
.general-topic {
    transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1), height 0.35s cubic-bezier(0.22, 1, 0.36, 1), transform 0.2s ease;
}

.notes-popup.has-detail .notes-content {
    gap: 14px;
    padding-top: 2px;
    padding-bottom: 6px;
}

.notes-popup.has-detail .general-topic {
    width: 92px;
    gap: 6px;
}

.notes-popup.has-detail .notes-content .lecture {
    width: 72px;
    height: 72px;
    padding: 6px;
}

.notes-popup.has-detail .lecture .topic {
    width: 50px;
    height: 50px;
}

.notes-popup.has-detail .general-topic h6 {
    font-size: 11px;
}

.modal-overlay .notes-popup.has-detail {
    gap: 12px;
}

.notes-popup.has-detail > .modal-head {
    margin-bottom: 4px;
}
