/* ==========================================================================
   1. DESIGN TOKENS (theme: Blue accent · Lively motion · glow on)
   ========================================================================== */
:root {
    /* Surfaces */
    --bg:          #0d1117;
    --bg-card:     #141b2b;
    --bg-inset:    #161d2b;
    --bg-btn:      #0d1117;
    --bg-scrim:    rgba(13, 17, 23, 0.72);

    /* Text */
    --text:        #c9d1d9;
    --text-strong: #f0f6fc;
    --text-soft:   #aeb8c4;
    --text-muted:  #8b949e;
    --text-faint:  #6e7886;

    /* Lines */
    --border:      #21262d;
    --border-card: #2a3450;
    --border-btn:  #30363d;
    --divider:     #232c3e;

    /* Accent */
    --ac:      rgb(88, 166, 255);
    --ac-10:   rgba(88, 166, 255, 0.10);
    --ac-12:   rgba(88, 166, 255, 0.12);
    --ac-22:   rgba(88, 166, 255, 0.22);
    --ac-45:   rgba(88, 166, 255, 0.45);

    /* Channel brands (contact overlay) */
    --yt:        rgb(248, 81, 73);
    --yt-10:     rgba(248, 81, 73, 0.10);
    --yt-45:     rgba(248, 81, 73, 0.45);
    --yt-shadow: 0 6px 16px rgba(248, 81, 73, 0.24);

    /* Motion (Lively) */
    --dur:      .22s;
    --ease:     cubic-bezier(.34, 1.56, .64, 1);
    --cardlift: -4px;
    --btnlift:  -3px;
    --press:    1px;
    --scale:    1.03;

    /* Elevation (glow on) */
    --card-shadow: 0 16px 44px rgba(0, 0, 0, 0.5), 0 6px 22px rgba(88, 166, 255, 0.18);
    --btn-shadow:  0 6px 16px rgba(88, 166, 255, 0.24);

    /* Type */
    --font-display: 'Space Grotesk', sans-serif;
    --font-body:    'Spline Sans', sans-serif;
    --font-mono:    'JetBrains Mono', monospace;
}

/* ==========================================================================
   2. RESET & BASE
   ========================================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.is-locked { overflow: hidden; }

.accent { color: var(--ac); }

.page {
    max-width: 1160px;
    margin: 0 auto;
}

/* ==========================================================================
   3. NAV
   ========================================================================== */
.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 48px;
    border-bottom: 1px solid var(--border);
}

.nav__brand {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.01em;
    color: var(--text-strong);
}

.nav__links {
    display: flex;
    gap: 34px;
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.nav__links a {
    color: var(--text);
    text-decoration: none;
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
    transition: color var(--dur), border-color var(--dur);
}

.nav__links a:hover { color: var(--ac); border-color: var(--ac); }
.nav__links a.is-active { color: var(--text-strong); border-color: var(--ac); }

/* Contact opens the modal, so it's a button dressed as a nav link */
.nav__contact {
    all: unset;
    cursor: pointer;
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
    color: var(--text);
    transition: color var(--dur), border-color var(--dur);
}

.nav__contact:hover { color: var(--ac); border-color: var(--ac); }

/* ==========================================================================
   4. HERO
   ========================================================================== */
.hero {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 48px;
    align-items: center;
    padding: 64px 48px 60px;
}

.hero__title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 60px;
    line-height: 1.03;
    letter-spacing: -0.02em;
    margin: 0 0 16px;
    color: var(--text-strong);
}

.hero__subtitle {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 19px;
    color: var(--text-muted);
    margin: 0 0 26px;
}

.hero__lead {
    font-size: 18px;
    line-height: 1.62;
    color: var(--text-soft);
    max-width: 560px;
    margin: 0 0 28px;
}

/* Tag pills */
.tags {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.tag {
    font-family: var(--font-mono);
    font-size: 12.5px;
    padding: 7px 13px;
    border: 1px solid var(--border-card);
    border-radius: 20px;
    color: #b6c2d1;
    background: var(--bg-inset);
    transition: border-color var(--dur), color var(--dur), transform var(--dur) var(--ease);
}

.tag:hover {
    border-color: var(--ac);
    color: var(--ac);
    transform: translateY(-2px);
}

/* Profile card */
.profile {
    justify-self: end;
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 8px 24px 24px;
    transition: border-color var(--dur), box-shadow var(--dur);
}

.profile:hover { border-color: var(--ac); box-shadow: var(--card-shadow); }

.profile__name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 17px;
    letter-spacing: 0.01em;
    color: var(--text-strong);
    padding: 16px 0;
}

.profile__photo {
    border-top: 1px solid var(--divider);
    padding: 18px 0 0;
}

.profile__actions {
    padding: 18px 0 0;
}

.profile__social {
    display: flex;
    gap: 10px;
}

.profile__social .btn { flex: 1; }

.btn--block {
    width: 100%;
    margin-bottom: 10px;
}

/* Portrait photo slot (with placeholder fallback) */
.portrait {
    position: relative;
    display: block;
    overflow: hidden;
    border: 1px solid var(--border-card);
    background: var(--bg-inset);
}

.portrait--card {
    width: 100%;
    height: 188px;
    border-radius: 10px;
}

.portrait--circle {
    width: 120px;
    height: 120px;
    flex: none;
    border-radius: 50%;
}

.portrait img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* Sta SOPRA il monogramma .portrait__ph (che ha sfondo opaco).
       Se la foto manca, onerror rimuove l'<img> e riappare il placeholder. */
    z-index: 1;
}

.portrait__ph {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 38px;
    letter-spacing: 0.04em;
    color: var(--text-faint);
    text-align: center;
    background:
        radial-gradient(120% 120% at 50% 0%, var(--ac-10), transparent 60%),
        var(--bg-inset);
    user-select: none;
}

.portrait--circle .portrait__ph { font-size: 30px; }

/* ==========================================================================
   5. BUTTONS
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    padding: 10px 16px;
    border: 1px solid var(--border-btn);
    border-radius: 7px;
    background: var(--bg-btn);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    transition: transform var(--dur) var(--ease), border-color var(--dur),
                background var(--dur), color var(--dur), box-shadow var(--dur);
}

.btn:hover {
    border-color: var(--ac);
    background: var(--ac-10);
    color: var(--ac);
    transform: translateY(var(--btnlift)) scale(var(--scale));
    box-shadow: var(--btn-shadow);
}

.btn:active { transform: translateY(var(--press)) scale(0.99); }

.btn--accent {
    border-color: var(--ac);
    background: var(--ac-12);
    color: var(--ac);
}

.btn--accent:hover { background: var(--ac-22); }

/* Channel buttons (contact overlay): base .btn re-hued per brand via --ch-* */
.btn--channel {
    width: 100%;
    justify-content: space-between;
    padding: 13px 16px;
    font-size: 13px;
    border-color: var(--ch-rest);
}

.btn--channel:hover {
    border-color: var(--ch);
    background: var(--ch-tint);
    color: var(--ch);
    box-shadow: var(--ch-shadow);
}

.btn__label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.btn__ico { flex: none; color: var(--ch); }

.btn__handle { opacity: 0.6; }

.btn--yt { --ch: var(--yt); --ch-rest: var(--yt-45); --ch-tint: var(--yt-10); --ch-shadow: var(--yt-shadow); }
.btn--gh { --ch: var(--ac); --ch-rest: var(--ac-45); --ch-tint: var(--ac-10); --ch-shadow: var(--btn-shadow); }

/* ==========================================================================
   6. SECTION HEADING
   ========================================================================== */
.section-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 26px;
    padding: 0 48px;
}

.section-head h3 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0;
}

.section-head__rule {
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ==========================================================================
   7. PROJECT CARDS
   ========================================================================== */
.projects { padding-bottom: 56px; }

.project-card {
    margin: 0 48px 26px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 30px;
    transition: transform var(--dur) var(--ease), border-color var(--dur), box-shadow var(--dur);
}

.project-card:hover {
    border-color: var(--ac);
    box-shadow: var(--card-shadow);
    transform: translateY(var(--cardlift));
}

.project-card__head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
}

.project-card__num {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 34px;
    color: var(--ac);
    line-height: 1;
}

.project-card__title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 21px;
    margin: 0;
    color: var(--text-strong);
}

.project-card__meta {
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-top: 4px;
}

.project-card__body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    gap: 28px;
    align-items: start;
}

.project-card__info p {
    font-size: 14.5px;
    line-height: 1.62;
    color: var(--text-soft);
    margin: 0 0 18px;
}

.card-tags {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-faint);
    margin-bottom: 22px;
    line-height: 1.9;
}

.project-links {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ==========================================================================
   8. VIDEO FACADE (click-to-load YouTube)
   ========================================================================== */
.video {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
    border-radius: 6px;
}

.video__btn {
    all: unset;
    cursor: pointer;
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.video__btn:hover { filter: brightness(1.06); }

.video__thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.video__scrim {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.5));
}

.video__play {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: rgba(15, 12, 9, 0.62);
    backdrop-filter: blur(4px);
    border: 1.5px solid var(--ac);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.video__play::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-42%, -50%);
    width: 0;
    height: 0;
    border-left: 17px solid var(--ac);
    border-top: 11px solid transparent;
    border-bottom: 11px solid transparent;
}

.video__tag {
    position: absolute;
    left: 14px;
    bottom: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.82);
    background: rgba(0, 0, 0, 0.35);
    padding: 3px 8px;
    border-radius: 4px;
}

.video iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ==========================================================================
   9. FOOTER
   ========================================================================== */
.footer {
    border-top: 1px solid var(--border);
    padding: 28px 48px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-faint);
    flex-wrap: wrap;
    gap: 14px;
}

.footer__links { display: flex; gap: 24px; }

.footer__links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--dur);
}

.footer__links a:hover { color: var(--ac); }

/* ==========================================================================
   10. READER OVERLAY (case study)
   ========================================================================== */
@keyframes readerIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.reader {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg);
    overflow-y: auto;
    animation: readerIn .28s var(--ease) both;
}

.reader[hidden] { display: none; }

.reader__bar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 32px;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.reader__back {
    all: unset;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text);
    transition: color var(--dur), transform var(--dur) var(--ease);
}

.reader__back:hover { color: var(--ac); transform: translateX(-3px); }

.reader__crumb {
    display: flex;
    align-items: center;
    gap: 9px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 0.08em;
    color: var(--text-faint);
}

.reader__crumb .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ac);
}

.reader__close {
    all: unset;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 17px;
    color: var(--text-muted);
    line-height: 1;
    transition: color var(--dur);
}

.reader__close:hover { color: var(--ac); }

.reader__article {
    max-width: 760px;
    margin: 0 auto;
    padding: 60px 32px 120px;
}

.reader__kicker {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ac);
    margin-bottom: 18px;
}

.reader__title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 44px;
    line-height: 1.06;
    letter-spacing: -0.02em;
    color: var(--text-strong);
    margin: 0 0 18px;
}

.reader__lead {
    font-size: 20px;
    line-height: 1.55;
    color: var(--text-soft);
    margin: 0 0 26px;
}

.reader__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin: 0 0 12px;
}

.reader__article hr {
    border: 0;
    height: 1px;
    background: var(--border);
    margin: 38px 0;
}

.reader__article h2 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 25px;
    color: var(--text-strong);
    margin: 40px 0 14px;
}

.reader__article h2:first-of-type { margin-top: 0; }

.reader__article p {
    font-size: 17px;
    line-height: 1.75;
    color: #c2cbd6;
    margin: 0 0 18px;
}

.reader__article p strong { color: var(--text-strong); font-weight: 600; }

/* Signal-flow block */
.flow {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 10px;
    padding: 16px 20px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.95;
    color: var(--text-soft);
    margin: 0 0 18px;
}

.flow__dim { color: #c2cbd6; }

/* Mapping table */
.map {
    font-family: var(--font-mono);
    font-size: 12.5px;
    border: 1px solid var(--border-card);
    border-radius: 10px;
    overflow: hidden;
    margin: 0 0 22px;
}

.map__head,
.map__row {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    padding: 12px 16px;
}

.map__head {
    background: var(--bg-inset);
    color: var(--text-faint);
    letter-spacing: 0.06em;
    padding: 11px 16px;
}

.map__row {
    border-top: 1px solid var(--divider);
}

.map__row span:last-child { color: #c2cbd6; }

/* Pull quote */
.pull {
    border-left: 3px solid var(--ac);
    padding-left: 22px;
    font-size: 21px;
    font-style: italic;
    line-height: 1.5;
    color: var(--text-strong);
    margin: 30px 0;
}

/* Bio reader */
.bio-head {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 34px;
    flex-wrap: wrap;
}

.bio-head__name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 40px;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--text-strong);
    margin: 0;
}

.bio-head__role {
    font-family: var(--font-body);
    font-size: 17px;
    color: var(--text-muted);
    margin-top: 8px;
}

.bio-lead {
    font-size: 19px !important;
    line-height: 1.7 !important;
    color: #c2cbd6;
    margin: 0 0 20px;
}

.bio-lead em { color: var(--text-strong); font-style: normal; }

.reader__article--bio p { color: var(--text-soft); }
.reader__article--bio .bio-lead { color: #c2cbd6; }

.bio-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin: 0 0 30px;
}

.bio-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 10px;
    padding: 16px 18px;
}

.bio-card__label {
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 8px;
}

.bio-card__val {
    font-size: 14px;
    color: var(--text-strong);
    line-height: 1.7;
}

/* Contact modal — .reader variant that floats a card instead of a page */
@keyframes scrimIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.reader--modal {
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--bg-scrim);
    backdrop-filter: blur(6px);
    animation: scrimIn .28s var(--ease) both;
}

.reader__backdrop {
    position: absolute;
    inset: 0;
}

.contact-card {
    position: relative;
    width: min(430px, 100%);
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 20px 24px 24px;
    box-shadow: var(--card-shadow);
    animation: readerIn .28s var(--ease) both;
}

.contact-card__bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--divider);
    margin-bottom: 18px;
}

.contact-card__title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 27px;
    line-height: 1.1;
    letter-spacing: -0.01em;
    color: var(--text-strong);
    margin: 0 0 8px;
}

.contact-card__lead {
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--text-soft);
    margin: 0 0 22px;
}

.contact-card__actions {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
}

.contact-card__sig {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.05em;
    color: var(--text-faint);
    border-top: 1px solid var(--divider);
    padding-top: 14px;
}

/* ==========================================================================
   11. RESPONSIVE
   ========================================================================== */
@media screen and (max-width: 720px) {
    .nav { padding: 18px 24px; flex-wrap: wrap; gap: 14px; }
    .nav__links { gap: 22px; }
    .hero { padding: 44px 24px 40px; }
    .hero__title { font-size: 42px; }
    .section-head { padding: 0 24px; }
    .project-card { margin: 0 24px 26px; padding: 22px; }
    .footer { padding: 24px; }
    .reader__title { font-size: 32px; }
    .reader__lead { font-size: 17px; }
    .contact-card { padding: 18px 18px 20px; }
}

/* ==========================================================================
   12. ACCESSIBILITY
   ========================================================================== */

/* Skip link — hidden until focused via keyboard */
.skip-link {
    position: absolute;
    left: 16px;
    top: -100px;
    z-index: 100;
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--ac);
    color: #04122b;
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: top var(--dur) var(--ease);
}

.skip-link:focus { top: 16px; }

/* Visible keyboard focus on every interactive element */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.tag:focus-visible {
    outline: 2px solid var(--ac);
    outline-offset: 3px;
    border-radius: 6px;
}

/* Honor reduced-motion: no transforms, transitions, or scope animation */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .project-card:hover,
    .btn:hover,
    .tag:hover { transform: none; }
}
