/* Portfolio light theme — Matteo Cavalleri */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
    --hud-bg: #f1f2ef;
    --hud-surface: #ffffff;
    --hud-surface-2: #e7e9e3;
    --hud-cyan: #3f5f9f;
    --hud-cyan-dim: rgba(63, 95, 159, 0.08);
    --hud-cyan-border: rgba(63, 95, 159, 0.18);
    --hud-orange: #b45309;
    --hud-green: #0f766e;
    --hud-red: #b42318;
    --hud-yellow: #ca8a04;
    --hud-purple: #7c3aed;
    --hud-text: #263238;
    --hud-text-dim: #65717b;
    --hud-surface: #ffffff;
    --ink: #111827;
    --line: #d7dce2;
    --shadow: 0 18px 48px rgba(15, 23, 42, 0.10);
    --px: clamp(20px, 5vw, 72px);
    --max-w: 1160px;
    --radius: 8px;
    --font-body: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
section[id] { scroll-margin-top: 88px; }
:focus-visible { outline: 2px solid var(--hud-cyan); outline-offset: 3px; border-radius: 4px; }
body {
    font-family: var(--font-body);
    background:
        linear-gradient(90deg, rgba(63,95,159,.045) 1px, transparent 1px),
        linear-gradient(180deg, rgba(15,23,42,.035) 1px, transparent 1px),
        var(--hud-bg);
    background-size: 52px 52px;
    color: var(--hud-text);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}
body::after, .hud-grid, .corner { display: none; }

nav {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between; gap: 24px;
    padding: 0 var(--px);
    height: 68px;
    background: rgba(241, 242, 239, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
}
.nav-logo {
    font-family: var(--font-mono);
    font-size: .9rem; font-weight: 700;
    color: var(--ink); text-decoration: none;
    letter-spacing: .02em; text-transform: lowercase;
}
.nav-logo span { color: var(--hud-cyan); }
.nav-links { display: flex; gap: 22px; list-style: none; align-items: center; }
.nav-links a {
    font-family: var(--font-mono);
    font-size: .72rem; font-weight: 600;
    letter-spacing: .04em; text-transform: uppercase;
    color: var(--hud-text-dim); text-decoration: none;
    transition: color .2s;
}
.nav-links a:hover, .nav-links .active { color: var(--hud-cyan); }
.nav-status {
    display: inline-flex; align-items: center; gap: 8px;
    font-family: var(--font-mono);
    font-size: .68rem; letter-spacing: .04em;
    color: var(--hud-text-dim);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 10px;
    background: #fff;
}
.nav-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--hud-green); }

#hero {
    min-height: calc(100vh - 68px);
    display: grid;
    grid-template-columns: minmax(0, 760px) minmax(260px, 420px);
    gap: clamp(32px, 7vw, 80px);
    align-items: center;
    padding: clamp(72px, 10vw, 132px) var(--px) 76px;
    position: relative;
}
.hero-inner { max-width: 760px; }
.hero-eyebrow, .section-label {
    font-family: var(--font-mono);
    font-size: .76rem; letter-spacing: .12em; text-transform: uppercase;
    color: var(--hud-cyan);
    margin-bottom: 14px;
}
.hero-eyebrow::before { content: ''; }
.hero-title {
    font-size: clamp(3rem, 8vw, 6.4rem);
    font-weight: 800;
    line-height: .94;
    letter-spacing: 0;
    color: var(--ink);
    margin-bottom: 24px;
}
.hero-title .dim { color: #475569; }
.hero-title .accent { color: #475569; }
.hero-sub {
    font-size: clamp(1rem, 2vw, 1.2rem);
    color: var(--hud-text-dim);
    max-width: 620px;
    line-height: 1.75;
    margin-bottom: 34px;
}
.hero-ctas { display: flex; flex-wrap: wrap; gap: 12px; }
.btn-primary, .btn-outline, .contact-btn {
    display: inline-flex; align-items: center; gap: 10px;
    min-height: 44px;
    padding: 10px 18px;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: .76rem; font-weight: 700;
    letter-spacing: .04em; text-transform: uppercase;
    text-decoration: none;
    transition: transform .2s, border-color .2s, background .2s, color .2s;
}
.btn-primary {
    background: #3f5f9f;
    color: #fff;
    border: 1px solid var(--hud-cyan);
    box-shadow: 0 10px 24px rgba(31, 122, 77, .18);
}
.btn-outline, .contact-btn {
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line);
}
.btn-primary::before, .btn-primary::after { display: none; }
.btn-primary:hover, .btn-outline:hover, .contact-btn:hover {
    transform: translateY(-1px);
    border-color: var(--hud-cyan);
    color: var(--hud-cyan);
}
.btn-primary:hover { color: #fff; background: #334e87; }

.hero-stats {
    display: flex; gap: 18px; flex-wrap: wrap;
    margin-top: 42px;
}
.hero-stats > div {
    background: rgba(255,255,255,.86);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    min-width: 150px;
    padding: 16px 18px;
}
.stat-num {
    font-size: 2rem; font-weight: 800; line-height: 1;
    color: var(--hud-cyan);
}
.stat-num .unit { font-size: 1.05rem; color: var(--hud-cyan); }
.stat-label {
    font-family: var(--font-mono);
    font-size: .68rem; letter-spacing: .05em;
    color: var(--hud-text-dim); text-transform: uppercase;
    margin-top: 6px;
}
.hero-visual {
    width: 100%;
    max-width: 420px;
    justify-self: end;
    aspect-ratio: 4 / 5;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        linear-gradient(135deg, rgba(63,95,159,.14), transparent 58%),
        linear-gradient(315deg, rgba(124,58,237,.10), transparent 68%),
        repeating-linear-gradient(0deg, rgba(17,24,39,.06) 0 1px, transparent 1px 18px),
        #fff;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.hero-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.hero-photo-placeholder {
    display: flex;
    height: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 28px;
    text-align: center;
    color: var(--hud-cyan);
}
.hero-photo-placeholder i {
    font-size: clamp(3rem, 8vw, 5rem);
    color: var(--hud-cyan);
}
.hero-photo-placeholder span {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--ink);
}
.hero-photo-placeholder small {
    font-family: var(--font-mono);
    color: var(--hud-text-dim);
}

.section-wrap {
    padding: clamp(64px, 8vw, 104px) var(--px);
    position: relative;
}
.section-wrap::before {
    content: '';
    position: absolute; top: 0; left: var(--px); right: var(--px);
    height: 1px; background: var(--line);
}
.section-inner { max-width: var(--max-w); margin: 0 auto; }
.section-title {
    font-size: clamp(1.8rem, 4vw, 3rem);
    font-weight: 800;
    letter-spacing: 0;
    color: var(--ink);
    margin-bottom: 12px;
}
.section-desc {
    font-size: 1rem; color: var(--hud-text-dim);
    max-width: 680px; line-height: 1.75;
}

.about-grid, .now-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 34px;
}
.about-card, .now-card, .contact-inner {
    background: rgba(255,255,255,.94);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: 0 10px 30px rgba(31, 55, 39, .06);
}
.about-card::before, .about-card::after, .now-card::before, .now-card::after,
.contact-inner::before, .contact-inner::after { display: none; }
.about-card-icon, .now-icon {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    border-radius: 999px;
    background: var(--hud-cyan-dim);
    color: var(--hud-cyan);
    margin-bottom: 14px;
}
.about-card h3, .now-card h4 {
    font-size: 1rem; font-weight: 800;
    letter-spacing: 0; text-transform: none;
    color: var(--ink); margin-bottom: 8px;
}
.about-card p, .now-card p, .contact-inner p {
    font-size: .95rem; color: var(--hud-text-dim); line-height: 1.75;
}

.skill-section { margin-top: 32px; display: flex; flex-direction: column; gap: 18px; }
.skill-cat-label, .stack-row-label {
    font-family: var(--font-mono);
    font-size: .72rem; font-weight: 700;
    letter-spacing: .08em; text-transform: uppercase;
    color: var(--hud-cyan);
}
.skill-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.skill-tag, .portfolio-tech span, .now-tag {
    display: inline-flex; align-items: center;
    gap: 8px;
    border: 1px solid var(--hud-cyan-border);
    background: var(--hud-cyan-dim);
    color: var(--hud-cyan);
    border-radius: 999px;
    padding: 5px 11px;
    font-family: var(--font-mono);
    font-size: .72rem; font-weight: 600;
    letter-spacing: .02em;
    text-decoration: none;
}
.now-tag i {
    width: 12px;
    min-width: 12px;
    text-align: center;
    font-size: .62rem;
    line-height: 1;
}
.now-tag .fa-circle { font-size: .42rem; }
.now-tag span { line-height: 1.35; }
.skill-tag[href]:hover { background: #fff; }
.skill-tag.c-orange { color: var(--hud-orange); background: rgba(180,83,9,.08); border-color: rgba(180,83,9,.20); }
.skill-tag.c-green { color: #0e7490; background: rgba(14,116,144,.08); border-color: rgba(14,116,144,.20); }

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 18px;
    margin-top: 34px;
}
.portfolio-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none; color: inherit; display: flex; flex-direction: column;
    box-shadow: 0 12px 34px rgba(27, 48, 35, .08);
    transition: transform .2s, box-shadow .2s, border-color .2s;
}
.portfolio-card::before, .portfolio-card::after { display: none; }
.portfolio-card:hover {
    border-color: var(--hud-cyan-border);
    box-shadow: var(--shadow);
    transform: translateY(-4px);
}
.portfolio-img, .portfolio-img-placeholder {
    width: 100%; height: 210px; object-fit: cover; display: block;
    border-bottom: 1px solid var(--line);
}
.portfolio-img { opacity: .96; }
.portfolio-img-placeholder {
    display: grid; place-items: center;
    background: linear-gradient(135deg, #e8eef8, #fff);
    font-family: var(--font-mono);
    font-size: .8rem; letter-spacing: .12em;
    color: var(--hud-cyan);
}
.portfolio-body { padding: 22px; flex: 1; display: flex; flex-direction: column; }
.portfolio-status {
    align-self: flex-start;
    display: inline-flex; align-items: center; gap: 6px;
    font-family: var(--font-mono);
    font-size: .68rem; font-weight: 700;
    letter-spacing: .04em; text-transform: uppercase;
    padding: 4px 10px; margin-bottom: 14px;
    border-radius: 999px;
}
.status-done { border: 1px solid rgba(15,118,110,.20); color: var(--hud-green); background: rgba(15,118,110,.08); }
.status-wip { border: 1px solid rgba(180,83,9,.22); color: var(--hud-orange); background: rgba(180,83,9,.08); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.portfolio-tag {
    font-family: var(--font-mono);
    font-size: .72rem; font-weight: 600;
    letter-spacing: .06em; text-transform: uppercase;
    color: var(--hud-text-dim); margin-bottom: 8px; display: block;
}
.portfolio-card h3 {
    font-size: 1.28rem; font-weight: 800;
    color: var(--ink);
    margin-bottom: 10px; line-height: 1.25;
}
.portfolio-card:nth-child(1) h3 { color: #0e7490; }
.portfolio-card:nth-child(2) h3 { color: #16453b; }
.portfolio-card:nth-child(3) h3 { color: var(--hud-cyan); }
.portfolio-card:nth-child(4) h3 { color: var(--hud-purple); }
.portfolio-card:nth-child(1) .portfolio-tech span {
    color: #0e7490;
    background: rgba(14,116,144,.08);
    border-color: rgba(14,116,144,.20);
}
.portfolio-card:nth-child(2) .portfolio-tech span {
    color: #7d6f65;
    background: rgba(181,141,144,.10);
    border-color: rgba(181,141,144,.28);
}
.portfolio-card:nth-child(3) .portfolio-tech span {
    color: var(--hud-cyan);
    background: var(--hud-cyan-dim);
    border-color: var(--hud-cyan-border);
}
.portfolio-card:nth-child(4) .portfolio-tech span {
    color: var(--hud-purple);
    background: rgba(124,58,237,.08);
    border-color: rgba(124,58,237,.20);
}
.portfolio-card p { font-size: .95rem; color: var(--hud-text-dim); line-height: 1.65; }
.portfolio-tech { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 0; }

.stack-chip {
    display: inline-flex; flex-direction: column; gap: 4px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: var(--radius);
    padding: 12px 14px; min-width: 122px;
    text-decoration: none; color: inherit;
    transition: border-color .2s, transform .2s;
}
a.stack-chip:hover { border-color: var(--hud-cyan); transform: translateY(-1px); }
.stack-chip i { color: var(--hud-cyan); font-size: 1rem; margin-bottom: 2px; }
.stack-chip span {
    font-size: .76rem; font-weight: 800;
    letter-spacing: 0; text-transform: none;
    color: var(--ink);
}
.stack-chip small { font-family: var(--font-mono); font-size: .68rem; color: var(--hud-text-dim); }
.stack-panel {
    border-color: var(--line) !important;
    background: linear-gradient(135deg, rgba(63,95,159,.06), rgba(124,58,237,.05)) !important;
    border-radius: var(--radius);
    overflow: hidden;
}
.stack-panel > div:nth-child(1),
.stack-panel > div:nth-child(2) { display: none; }
.stack-chip {
    --chip-color: var(--hud-cyan);
    --chip-bg: var(--hud-cyan-dim);
    --chip-border: var(--hud-cyan-border);
    border-color: var(--chip-border);
    background: linear-gradient(180deg, #fff, var(--chip-bg));
}
.stack-chip i,
.stack-chip span { color: var(--chip-color); }
.stack-chip:hover { border-color: var(--chip-color); }
.chip-matlab { --chip-color: #3f5f9f; --chip-bg: rgba(63,95,159,.08); --chip-border: rgba(63,95,159,.20); }
.chip-simulink { --chip-color: #7c3aed; --chip-bg: rgba(124,58,237,.08); --chip-border: rgba(124,58,237,.20); }
.chip-modelica { --chip-color: #0f766e; --chip-bg: rgba(15,118,110,.08); --chip-border: rgba(15,118,110,.20); }
.chip-python { --chip-color: #ca8a04; --chip-bg: rgba(202,138,4,.10); --chip-border: rgba(202,138,4,.24); }
.chip-js { --chip-color: #b45309; --chip-bg: rgba(180,83,9,.09); --chip-border: rgba(180,83,9,.22); }
.chip-github { --chip-color: #374151; --chip-bg: rgba(55,65,81,.08); --chip-border: rgba(55,65,81,.18); }
.chip-html { --chip-color: #dc2626; --chip-bg: rgba(220,38,38,.08); --chip-border: rgba(220,38,38,.18); }
.chip-web { --chip-color: #16453b; --chip-bg: rgba(181,141,144,.10); --chip-border: rgba(181,141,144,.28); }

.now-card-hdr { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.now-icon { flex-shrink: 0; margin-bottom: 0; }
.now-icon.orange, .now-tag.orange, .now-icon.green, .now-tag.green {
    border-color: var(--hud-cyan-border); color: var(--hud-cyan); background: var(--hud-cyan-dim);
}
.now-card {
    --now-color: var(--hud-cyan);
    --now-bg: var(--hud-cyan-dim);
    --now-border: var(--hud-cyan-border);
    border-color: var(--now-border);
    background: linear-gradient(180deg, #fff, var(--now-bg));
}
.now-card h4 { color: var(--now-color); }
.now-card .now-icon,
.now-card .now-tag,
.now-card .now-icon.orange,
.now-card .now-tag.orange,
.now-card .now-icon.green,
.now-card .now-tag.green {
    color: var(--now-color);
    background: var(--now-bg);
    border-color: var(--now-border);
}
.now-study { --now-color: #3f5f9f; --now-bg: rgba(63,95,159,.08); --now-border: rgba(63,95,159,.20); }
.now-arc { --now-color: #7c3aed; --now-bg: rgba(124,58,237,.08); --now-border: rgba(124,58,237,.20); }
.now-scada { --now-color: #0e7490; --now-bg: rgba(14,116,144,.08); --now-border: rgba(14,116,144,.20); }
.now-ilystetic { --now-color: #16453b; --now-bg: rgba(181,141,144,.10); --now-border: rgba(181,141,144,.28); }
.now-consulting { --now-color: #b45309; --now-bg: rgba(180,83,9,.08); --now-border: rgba(180,83,9,.22); }
.contact-inner { max-width: 660px; margin: 34px auto 0; text-align: center; }
.contact-inner p { margin-bottom: 26px; }
.contact-links { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

footer {
    border-top: 1px solid var(--line);
    padding: 24px var(--px);
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
    background: #fff;
}
footer p {
    font-family: var(--font-mono);
    font-size: .72rem; letter-spacing: .03em;
    color: var(--hud-text-dim);
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #e7e9e3; }
::-webkit-scrollbar-thumb { background: #aab3bd; border-radius: 99px; }

@media (max-width: 900px) {
    .nav-status { display: none; }
    .nav-links { gap: 14px; }
    #hero { grid-template-columns: 1fr; }
    .hero-visual { justify-self: start; max-width: 360px; }
}
@media (max-width: 700px) {
    nav { height: auto; min-height: 64px; align-items: flex-start; padding-top: 14px; padding-bottom: 14px; }
    .nav-links { display: none; }
    .about-grid, .now-grid { grid-template-columns: 1fr; }
    .hero-stats > div { flex: 1 1 130px; }
    .section-wrap { padding-top: 56px; padding-bottom: 56px; }
    footer { flex-direction: column; align-items: flex-start; }
}

/* ===== Scroll reveal animations ===== */
.reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity .7s ease, transform .7s ease;
    will-change: opacity, transform;
}
.reveal.is-visible {
    opacity: 1;
    transform: none;
}
.portfolio-grid .portfolio-card.reveal { transition-delay: 0s; }
.portfolio-grid .portfolio-card.reveal:nth-child(2) { transition-delay: .08s; }
.portfolio-grid .portfolio-card.reveal:nth-child(3) { transition-delay: .16s; }
.portfolio-grid .portfolio-card.reveal:nth-child(4) { transition-delay: .24s; }
.now-grid .now-card.reveal:nth-child(2) { transition-delay: .06s; }
.now-grid .now-card.reveal:nth-child(3) { transition-delay: .12s; }
.now-grid .now-card.reveal:nth-child(4) { transition-delay: .18s; }
.now-grid .now-card.reveal:nth-child(5) { transition-delay: .24s; }

/* ===== Hero eyebrow accent dot ===== */
.hero-eyebrow { display: inline-flex; align-items: center; gap: 10px; }
.eyebrow-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--hud-cyan);
    box-shadow: 0 0 0 4px rgba(63,95,159,.14);
    animation: dotPulse 2.4s ease-in-out infinite;
}
@keyframes dotPulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(63,95,159,.14); transform: scale(1); }
    50%      { box-shadow: 0 0 0 7px rgba(63,95,159,.06); transform: scale(.92); }
}

/* ===== Tabular figures on metrics ===== */
.stat-num, .stat-label { font-variant-numeric: tabular-nums; }

/* ===== Equal-height now-grid ===== */
.now-grid { grid-auto-rows: 1fr; }

/* ===== Portfolio status dot live pulse ===== */
.status-done .status-dot,
.status-wip .status-dot {
    position: relative;
    box-shadow: 0 0 0 0 currentColor;
    animation: statusPulse 2.6s ease-out infinite;
}
@keyframes statusPulse {
    0%   { box-shadow: 0 0 0 0 currentColor; opacity: .85; }
    70%  { box-shadow: 0 0 0 6px transparent; opacity: 1; }
    100% { box-shadow: 0 0 0 0 transparent; opacity: .85; }
}

/* ===== Portfolio card subtle image zoom ===== */
.portfolio-card { position: relative; }
.portfolio-card .portfolio-img { transition: transform .55s ease, opacity .3s; }
.portfolio-card:hover .portfolio-img { transform: scale(1.035); opacity: 1; }

/* ===== Nav active link underline ===== */
.nav-links a {
    position: relative;
    padding-bottom: 4px;
}
.nav-links a::after {
    content: '';
    position: absolute;
    left: 0; right: 100%;
    bottom: 0;
    height: 2px;
    background: var(--hud-cyan);
    transition: right .25s ease;
}
.nav-links a:hover::after,
.nav-links a.active::after { right: 0; }

/* ===== Hero photo subtle float ===== */
@keyframes heroFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}
.hero-visual { animation: heroFloat 7s ease-in-out infinite; }

/* ===== Reduced motion: disable all animations & transitions ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
    .reveal { opacity: 1; transform: none; }
    .hero-visual { animation: none; }
}
