/*
 * Daniele Maddaluno — portfolio
 * Visual language carried over from the former Indigo Jekyll theme:
 * Helvetica Neue, soft greys, indigo accent, centered home header and
 * list separators with a small square marker.
 */

/* ---------- Tokens ---------- */

:root {
    --bg: #fff;
    --text: #666;
    --heading: #222;
    --strong: #000;
    --muted: #757575;   /* small secondary text (AA on --bg) */
    --faint: #999;      /* large, decorative text only */
    --accent: #4b0082;
    --border: #ededed;
    --surface: #fafafa;
    --shadow: 0 2px 6px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .08);

    /* Project context tags (keys match contexts in config.js) */
    --ctx-tech: #4b0082;
    --ctx-education: #0f766e;
    --ctx-trading: #b45309;

    --font-sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
    --font-mono: Consolas, "Liberation Mono", Menlo, Courier, monospace;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b0b0c;
        --text: #b3b3b3;
        --heading: #ededed;
        --strong: #fff;
        --muted: #8f8f8f;
        --faint: #777;
        --accent: #b98cff;
        --border: #26262a;
        --surface: #141416;
        --shadow: 0 2px 6px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .5);

        --ctx-tech: #b98cff;
        --ctx-education: #4fd1c5;
        --ctx-trading: #f6ad55;

        color-scheme: dark;
    }
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 62.5%;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font: 1.6rem/1.5 var(--font-sans);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-sans);
    color: var(--heading);
    line-height: 1.25;
}

h1 {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -1px;
}

h2 { font-size: 2.2rem; }
h3 { font-size: 2rem; }

p {
    margin: 0 0 2rem;
    line-height: 1.7;
    font-weight: 300;
    letter-spacing: .4px;
}

a {
    color: var(--accent);
    font-weight: 300;
    text-decoration: underline;
    text-underline-offset: 2px;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 2px;
}

strong {
    font-weight: 500;
    color: var(--strong);
}

ul li,
ol li {
    line-height: 1.7;
    font-weight: 300;
}

code {
    padding: 2px 4px;
    font: 1.3rem var(--font-mono);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
}

img {
    max-width: 100%;
}

.wrapper {
    max-width: 810px;
    margin: 0 auto;
    padding: 0 20px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- Separator with the Indigo square marker ---------- */

.list,
.footer {
    position: relative;
    border-top: 1px solid var(--border);
}

.list::before,
.footer::before {
    content: "";
    position: absolute;
    top: -5px;
    left: 50%;
    width: 9px;
    height: 9px;
    margin-left: -5px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg);
    box-shadow: 0 0 0 5px var(--bg);
}

/* ---------- Home header ---------- */

.header-home {
    margin: 0 auto;
    padding-top: 125px;
    text-align: center;
}

.avatar {
    display: block;
    width: 125px;
    height: 125px;
    margin: 0 auto 25px;
    border-radius: 50%;
    object-fit: cover;
    transition: box-shadow .2s, opacity .2s;
}

.avatar:hover {
    box-shadow: 0 0 4px rgba(0, 0, 0, .18), 0 0 12px rgba(0, 0, 0, .15);
    opacity: .9;
}

.header-home .title {
    margin: 0 0 13px;
    font-size: 4rem;
}

.header-home .description {
    width: 70%;
    margin: 0 auto 30px;
    font-size: 1.85rem;
    font-weight: 300;
    color: var(--faint);
    letter-spacing: 0;
}

.header-home .bio {
    display: block;
    margin-top: 15px;
}

.social {
    display: flex;
    justify-content: center;
    gap: 4px;
}

.social a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    color: var(--strong);
    transition: color .2s ease-in-out;
}

.social a:hover {
    color: var(--accent);
}

.social svg {
    width: 22px;
    height: 22px;
}

/* ---------- Navigation ---------- */

.filters ul,
.nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.filters li,
.nav li {
    display: inline-block;
}

.nav a {
    display: inline-block;
    font-weight: 300;
    text-decoration: none;
}

/* Project filters: same look as the old Indigo home navigation */
.filters {
    min-height: 52px; /* keeps the layout still while the list loads */
    margin-top: 40px;
    text-align: center;
}

.filters button {
    position: relative;
    padding: 7px 15px;
    border: 0;
    background: none;
    font: 300 2rem/1.5 var(--font-sans);
    color: var(--accent);
    cursor: pointer;
    transition: color .3s ease-in-out;
}

.filters button:hover {
    color: var(--text);
}

.filters button[aria-pressed="true"] {
    color: var(--heading);
}

.filters button[aria-pressed="true"]::after {
    content: "";
    position: absolute;
    right: 15px;
    bottom: 2px;
    left: 15px;
    height: 1px;
    background: currentColor;
}

.filters .count {
    margin-left: 4px;
    font-size: 1.2rem;
    vertical-align: super;
    color: var(--muted);
}

.nav {
    position: absolute;
    top: 0;
    right: 0;
    padding: 0 13px;
}

.nav a {
    padding: 20px 10px;
    font-size: 1.5rem;
}

.nav a[aria-current="page"] {
    color: var(--heading);
}

.nav a:hover {
    color: var(--text);
}

/* ---------- Inner pages ---------- */

.page {
    margin-top: 125px;
}

.page > h1 {
    margin: 0 0 1.5rem;
    text-align: center;
}

.page > .lead {
    max-width: 560px;
    margin: 0 auto 4rem;
    text-align: center;
    color: var(--muted);
}

/* ---------- Project lists ---------- */

.list {
    margin-top: 30px;
    padding-top: 30px;
}

.item {
    width: 95%;
    margin: 0 auto;
    padding: 22px 0;
}

.item[hidden] {
    display: none;
}

/* Labels above each project title: colored context tag + neutral type */
.labels {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag,
.kind {
    --tag: var(--muted);

    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--surface);
    background: color-mix(in srgb, var(--tag) 11%, transparent);
    font-size: 1.1rem;
    font-weight: 500;
    line-height: 1.6;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--tag);
}

.tag[data-context="tech"] { --tag: var(--ctx-tech); }
.tag[data-context="education"] { --tag: var(--ctx-education); }
.tag[data-context="trading"] { --tag: var(--ctx-trading); }

.kind {
    padding: 1px 9px;
    border: 1px solid var(--border);
    background: none;
    color: var(--muted);
}

/* Rule between visible items only, so filtering never leaves a leading rule */
.item:not([hidden]) ~ .item {
    border-top: 1px dashed var(--border);
}

.item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}

.item .title {
    margin: 0;
    font-size: 2rem;
    font-weight: 500;
}

.item .title a {
    color: var(--heading);
    font-weight: 500;
    text-decoration: none;
    transition: color .2s ease-in-out;
}

.item:hover .title a,
.item .title a:focus-visible {
    color: var(--accent);
}

.item .date {
    flex-shrink: 0;
    font-size: 1.4rem;
    font-weight: 300;
    color: var(--faint);
    white-space: nowrap;
    transition: color .2s ease-in-out;
}

.item:hover .date {
    color: var(--muted);
}

.item .desc {
    margin: 8px 0 10px;
    letter-spacing: .2px;
}

.meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 18px;
    font-size: 1.35rem;
    color: var(--muted);
}

.meta .dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border-radius: 50%;
    background: var(--dot, var(--faint));
    vertical-align: -1px;
}

.meta .links {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px 14px;
}

.meta a {
    font-weight: 400;
    text-decoration: none;
}

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

.status,
.empty {
    padding: 30px 0;
    text-align: center;
    color: var(--muted);
}

.sync {
    margin: 10px 0 0;
    font-size: 1.3rem;
    text-align: center;
    color: var(--muted);
}

/* ---------- Prose (privacy page) ---------- */

.prose {
    max-width: 640px;
    margin: 0 auto;
}

.prose h2 {
    margin: 4rem 0 1rem;
    font-size: 2rem;
}

.prose ul {
    padding-left: 2rem;
    margin: 0 0 2rem;
}

/* ---------- 404 ---------- */

.lost {
    padding: 125px 0 40px;
    text-align: center;
}

.lost .avatar {
    width: 110px;
    height: 110px;
    margin-bottom: 10px;
}

/* ---------- Footer ---------- */

.footer {
    margin: 60px 0 0;
    padding: 40px 0;
    font-size: 1.3rem;
    text-align: center;
    color: var(--muted);
}

.footer p {
    margin: 0 0 6px;
    letter-spacing: 0;
}

.footer a,
.linklike {
    padding: 0 0 1px;
    border: 0;
    border-bottom: 1px solid transparent;
    background: none;
    font: inherit;
    font-weight: 300;
    color: var(--heading);
    text-decoration: none;
    cursor: pointer;
    transition: border-color .3s ease-in-out;
}

.footer a:hover,
.linklike:hover {
    border-color: var(--faint);
}

/* ---------- Consent banner ---------- */

.consent {
    position: fixed;
    right: 16px;
    bottom: 16px;
    left: 16px;
    z-index: 100;
    max-width: 560px;
    margin: 0 auto;
    padding: 16px 20px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    box-shadow: var(--shadow);
    font-size: 1.4rem;
}

.consent[hidden] {
    display: none;
}

.consent p {
    margin: 0 0 12px;
    line-height: 1.6;
    letter-spacing: 0;
}

.consent-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.consent button {
    min-width: 96px;
    padding: 8px 18px;
    border: 1px solid var(--accent);
    border-radius: 4px;
    background: transparent;
    font: inherit;
    color: var(--accent);
    cursor: pointer;
    transition: background-color .2s, color .2s;
}

.consent button:hover {
    background: var(--accent);
    color: var(--bg);
}

/* ---------- Motion ---------- */

.animated {
    animation: fade-in-down .6s .3s both;
}

@keyframes fade-in-down {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .animated {
        animation: none;
    }

    * {
        transition: none !important;
    }
}

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
    .header-home {
        padding-top: 60px;
    }

    .header-home .title {
        font-size: 3.2rem;
    }

    .header-home .description {
        width: 100%;
        font-size: 1.6rem;
    }

    .filters button {
        padding: 7px 9px;
        font-size: 1.8rem;
    }

    .filters button[aria-pressed="true"]::after {
        right: 9px;
        left: 9px;
    }

    .nav {
        position: static;
        padding: 0;
        text-align: center;
    }

    .nav a {
        padding: 16px 8px;
    }

    .page {
        margin-top: 30px;
    }

    .item {
        width: 100%;
    }

    .consent-actions button {
        flex: 1;
    }
}
