/* =====================================================================
   LearnSNSI Academy - tema chiaro
   Base: token, layout, tipografia, componenti comuni.
   ===================================================================== */

:root {
    --bg: #f3f6f9;
    --surface: #ffffff;
    --surface-2: #f7f9fb;
    --ink: #0b1d2e;
    --ink-2: #33475b;
    --muted: #6a7b8c;
    --line: #e2e8ef;
    --line-strong: #cfd9e3;

    --ocean: #0b4f8a;
    --sea: #0e7fbf;
    --lagoon: #17b3c1;
    --accent: #0a6fb3;
    --accent-soft: rgba(14, 127, 191, .09);
    --gold: #b8904a;
    --ok: #0f9d7a;
    --ok-soft: rgba(15, 157, 122, .1);
    --warn: #b7791f;
    --danger: #c2413b;

    --grad: linear-gradient(120deg, var(--ocean) 0%, var(--sea) 48%, var(--lagoon) 100%);
    --radius: 16px;
    --radius-sm: 10px;
    --shadow-1: 0 1px 2px rgba(11, 29, 46, .04), 0 4px 14px rgba(11, 29, 46, .05);
    --shadow-2: 0 2px 6px rgba(11, 29, 46, .06), 0 18px 40px rgba(11, 45, 80, .12);

    --serif: 'Cormorant Garamond', Georgia, serif;
    --sans: 'DM Sans', system-ui, sans-serif;
    --ease: cubic-bezier(.2, .8, .2, 1);

    /* compatibilità con gli stili esistenti */
    --text: var(--ink);
    --border: var(--line);
    --panel: var(--surface);
    --accent2: var(--ok);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    color: var(--ink);
    font-family: var(--sans);
    font-weight: 400;
    font-size: 15.5px;
    background:
        radial-gradient(1200px 600px at 85% -10%, rgba(23, 179, 193, .08), transparent 60%),
        radial-gradient(900px 500px at -10% 10%, rgba(11, 79, 138, .06), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

::selection { background: rgba(23, 179, 193, .25); }

/* ------------------------------------------------------------------ layout */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 248px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, .78);
    backdrop-filter: blur(18px) saturate(1.4);
    border-right: 1px solid var(--line);
}

.brand {
    display: block;
    padding: 1.5rem 1.5rem 1.3rem;
    font-family: var(--serif);
    font-size: 1.65rem;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--ink);
    text-decoration: none;
}

.brand span {
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.sidebar nav { flex: 1; overflow: auto; padding: .4rem .8rem 1rem; }

.nav-label {
    padding: 1.2rem .8rem .5rem;
    color: var(--muted);
    font-size: .64rem;
    font-weight: 500;
    letter-spacing: .22em;
    text-transform: uppercase;
}

.sidebar nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .7rem .85rem;
    margin: 2px 0;
    border-radius: 10px;
    color: var(--ink-2);
    text-decoration: none;
    transition: background .2s var(--ease), color .2s var(--ease), transform .2s var(--ease);
}

.sidebar nav a:hover { background: var(--accent-soft); color: var(--ink); transform: translateX(2px); }

.sidebar nav a.active {
    color: var(--ocean);
    font-weight: 500;
    background: linear-gradient(90deg, rgba(14, 127, 191, .12), rgba(23, 179, 193, .04));
}

.sidebar nav a.active::before {
    content: "";
    position: absolute;
    left: -.8rem;
    top: 20%;
    bottom: 20%;
    width: 3px;
    border-radius: 3px;
    background: var(--grad);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: .7rem;
    margin: .8rem;
    padding: .8rem;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-1);
}

.sidebar-avatar {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--grad);
    color: #fff;
    font-size: .95rem;
}

.sidebar-user-text { min-width: 0; flex: 1; }
.sidebar-user-name { font-size: .85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-level { font-size: .7rem; color: var(--muted); margin-top: .1rem; }

.main-wrap { margin-left: 248px; width: calc(100% - 248px); }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    height: 60px;
    padding: 0 2.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: rgba(243, 246, 249, .75);
    backdrop-filter: blur(14px) saturate(1.3);
    border-bottom: 1px solid rgba(226, 232, 239, .7);
    color: var(--ink-2);
    font-weight: 500;
}

.top-link { color: var(--accent); text-decoration: none; font-weight: 500; }

.menu-button {
    display: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--ink);
    padding: .45rem .7rem;
}

.page-wrap { padding: 2.2rem 2.4rem 4rem; max-width: 1440px; margin: auto; }

/* ------------------------------------------------------------------ tipografia */

h1, h2, h3 { font-family: var(--serif); font-weight: 500; color: var(--ink); letter-spacing: -.005em; }
h1 { font-size: clamp(2rem, 3.2vw, 2.9rem); line-height: 1.1; margin: .25rem 0 .8rem; }
h2 { font-size: 1.6rem; line-height: 1.2; margin: 1.8rem 0 .9rem; }
h3 { font-size: 1.25rem; }

.muted { color: var(--muted); line-height: 1.65; }

.kicker {
    display: inline-block;
    font-size: .68rem;
    font-weight: 500;
    letter-spacing: .2em;
    text-transform: uppercase;
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.content-html { line-height: 1.8; color: var(--ink-2); }
.content-html img, .content-html iframe { max-width: 100%; border-radius: var(--radius-sm); }

/* ------------------------------------------------------------------ superfici */

.panel, .card, .side {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
}

/* Intestazione con riflessi d'acqua animati */
.hero {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    padding: 2.6rem 2.8rem;
    margin-bottom: 2rem;
    border-radius: 22px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-1);
}

.hero::before {
    content: "";
    position: absolute;
    inset: -40%;
    z-index: -1;
    background:
        radial-gradient(35% 45% at 20% 30%, rgba(23, 179, 193, .20), transparent 70%),
        radial-gradient(30% 40% at 80% 20%, rgba(14, 127, 191, .16), transparent 70%),
        radial-gradient(40% 50% at 60% 90%, rgba(11, 79, 138, .10), transparent 70%);
    animation: caustiche 22s ease-in-out infinite alternate;
}

.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 40%, rgba(255, 255, 255, .85));
}

@keyframes caustiche {
    0% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
    50% { transform: translate3d(4%, -3%, 0) rotate(8deg) scale(1.08); }
    100% { transform: translate3d(-3%, 4%, 0) rotate(-6deg) scale(1.02); }
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    grid-auto-rows: 1fr;            /* tutte le schede della griglia hanno la stessa altezza */
    gap: 1.2rem;
}

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 1.4rem 1.4rem 1.2rem;
    color: var(--ink);
    text-decoration: none;
    transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .35s var(--ease);
}

.card h2 {
    margin: .5rem 0 .6rem;
    font-size: 1.55rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.4em;
}

.card h2 a { color: inherit; text-decoration: none; }

.card > .muted {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card .actions { margin-top: auto; padding-top: .6rem; margin-bottom: 0; }

/* bordo sfumato che compare al passaggio del mouse */
.card::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: var(--grad);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity .35s var(--ease);
    pointer-events: none;
}

.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); border-color: transparent; }
.card:hover::before { opacity: 1; }

.stats { display: flex; gap: 2rem; flex-wrap: wrap; margin-top: 1.2rem; }
.stat strong {
    display: block;
    font-family: var(--serif);
    font-size: 1.9rem;
    font-weight: 600;
    line-height: 1.1;
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.stat span { font-size: .75rem; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }

/* ------------------------------------------------------------------ pulsanti */

.btn {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .7rem 1.2rem;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 500;
    font-size: .92rem;
    text-decoration: none;
    cursor: pointer;
    transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease), background .25s var(--ease);
}

.btn:hover { transform: translateY(-1px); border-color: var(--sea); box-shadow: 0 6px 18px rgba(14, 127, 191, .15); }
.btn:active { transform: translateY(0); }

.btn.primary {
    border: 0;
    color: #fff;
    background: var(--grad);
    background-size: 160% 100%;
    box-shadow: 0 8px 22px rgba(14, 127, 191, .28);
}

.btn.primary:hover { background-position: 100% 0; box-shadow: 0 12px 28px rgba(14, 127, 191, .38); }

/* riflesso che attraversa il pulsante */
.btn.primary::after {
    content: "";
    position: absolute;
    top: 0;
    left: -60%;
    width: 40%;
    height: 100%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .45), transparent);
    transform: skewX(-20deg);
    transition: left .7s var(--ease);
}

.btn.primary:hover::after { left: 130%; }

.btn.danger { color: var(--danger); border-color: rgba(194, 65, 59, .35); background: rgba(194, 65, 59, .04); }
.btn.danger:hover { border-color: var(--danger); box-shadow: 0 6px 18px rgba(194, 65, 59, .15); }

.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin: 1.1rem 0; }

/* ------------------------------------------------------------------ liste */

.list { display: flex; flex-direction: column; gap: .6rem; }

.list-row {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: .95rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--ink);
    text-decoration: none;
    transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
}

a.list-row:hover { transform: translateX(3px); border-color: rgba(14, 127, 191, .35); box-shadow: var(--shadow-1); }
.list-row > span:last-child { color: var(--accent); font-size: .9rem; white-space: nowrap; }

.num {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--ocean);
    font-weight: 500;
    font-size: .85rem;
}

/* ------------------------------------------------------------------ form */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.2rem; }
.field { display: flex; flex-direction: column; gap: .4rem; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: .78rem; font-weight: 500; color: var(--ink-2); }

input, textarea, select {
    width: 100%;
    padding: .72rem .85rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--sea);
    box-shadow: 0 0 0 4px rgba(14, 127, 191, .12);
}

textarea { min-height: 110px; resize: vertical; }

.search { display: flex; gap: .6rem; margin-bottom: 1.2rem; max-width: 640px; }

/* ------------------------------------------------------------------ messaggi */

.message {
    padding: .9rem 1.1rem;
    margin-bottom: 1.2rem;
    border-radius: 12px;
    border: 1px solid rgba(15, 157, 122, .25);
    background: var(--ok-soft);
    color: #0b6e56;
    animation: sale .45s var(--ease) backwards;
}

.message.error, .error {
    border-color: rgba(194, 65, 59, .3);
    background: rgba(194, 65, 59, .06);
    color: var(--danger);
}

.empty {
    padding: 1.4rem;
    border: 1px dashed var(--line-strong);
    border-radius: 14px;
    color: var(--muted);
    background: rgba(255, 255, 255, .5);
}

.crumbs { margin-bottom: 1.1rem; color: var(--muted); font-size: .82rem; }
.crumbs a { color: var(--accent); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ colonne e tabelle */

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.6rem; align-items: start; }
.side { padding: 1.3rem; position: sticky; top: 80px; }
.side h2 { font-size: 1.3rem; margin-top: 1.2rem; }

.table-wrap {
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
}

.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .85rem 1rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { color: var(--muted); font-weight: 500; font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; background: var(--surface-2); }
.table tbody tr { transition: background .2s; }
.table tbody tr:hover { background: rgba(14, 127, 191, .04); }
.table tr:last-child td { border-bottom: 0; }

/* ------------------------------------------------------------------ entrata progressiva */

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

.hero, .grid > *, .list > *, .outline > *, .panel, .table-wrap { animation: sale .6s var(--ease) backwards; }
.grid > *:nth-child(2), .list > *:nth-child(2), .outline > *:nth-child(2) { animation-delay: .06s; }
.grid > *:nth-child(3), .list > *:nth-child(3), .outline > *:nth-child(3) { animation-delay: .12s; }
.grid > *:nth-child(4), .list > *:nth-child(4), .outline > *:nth-child(4) { animation-delay: .18s; }
.grid > *:nth-child(5), .list > *:nth-child(5), .outline > *:nth-child(5) { animation-delay: .24s; }
.grid > *:nth-child(n+6), .list > *:nth-child(n+6), .outline > *:nth-child(n+6) { animation-delay: .3s; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ------------------------------------------------------------------ responsive */

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .3s var(--ease); background: rgba(255, 255, 255, .96); box-shadow: var(--shadow-2); }
    .sidebar.open { transform: none; }
    .main-wrap { margin-left: 0; width: 100%; }
    .menu-button { display: block; }
    .page-wrap { padding: 1.2rem 1rem 3rem; }
    .topbar { padding: 0 1rem; }
    .hero { padding: 1.8rem 1.4rem; border-radius: 18px; }
    .form-grid, .two-col { grid-template-columns: 1fr; }
    .field.full { grid-column: auto; }
    .side { position: static; }
    .list-row { grid-template-columns: 38px 1fr; }
    .list-row > span:last-child { grid-column: 2; }
    .grid { grid-template-columns: 1fr; grid-auto-rows: auto; }
}
