/* ==========================================================================
   Andrea Lestingi — Portfolio
   Paper / ink / one ultramarine accent. Serif text, mono only for zone data.
   ========================================================================== */

:root {
    color-scheme: light;
    --paper: #eff1f4;
    --panel: #e6e9ee;
    --ink: #15171c;
    --muted: #565d6a;
    --rule: #cbd0d8;
    --accent: #2a36d6;
    --accent-ink: #ffffff;
    --live: #1a8a57;

    --serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
    --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

    --gutter: clamp(1.25rem, 4vw, 2.5rem);
    --page: 1120px;
    --label-col: 13rem;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --paper: #0f1218;
    --panel: #161a22;
    --ink: #e7e9ee;
    --muted: #9aa1af;
    --rule: #272c37;
    --accent: #8e9bff;
    --accent-ink: #0f1218;
    --live: #4cc38a;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--serif);
    font-size: 1.125rem;
    line-height: 1.7;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
    font-optical-sizing: auto;
    overflow-x: hidden;
}

img { max-width: 100%; display: block; }
ul { list-style: none; }
button { font: inherit; color: inherit; }
a { color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.wrap { width: 100%; max-width: var(--page); margin: 0 auto; padding-inline: var(--gutter); }

.skip-link {
    position: absolute; left: var(--gutter); top: -4rem; z-index: 50;
    padding: 0.5rem 0.9rem; background: var(--accent); color: var(--accent-ink);
}
.skip-link:focus { top: 0.75rem; }

/* Text links: underline carries the affordance ---------------------------- */
.link {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.22em;
}
.link:hover { text-decoration-thickness: 2px; }

/* Header ------------------------------------------------------------------ */
.bar {
    position: sticky; top: 0; z-index: 20;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
}
.bar-inner { display: flex; align-items: center; gap: 2rem; min-height: 3.5rem; }
.brand { font-weight: 560; font-size: 1.1rem; letter-spacing: -0.005em; text-decoration: none; margin-right: auto; }

.bar-nav { display: flex; gap: 1.5rem; }
.bar-nav a {
    font-size: 1rem; color: var(--muted); text-decoration: none;
    padding-block: 0.25rem; border-bottom: 1px solid transparent;
}
.bar-nav a:hover { color: var(--ink); }
.bar-nav a.active { color: var(--ink); border-bottom-color: var(--accent); }

.controls { display: flex; gap: 0.4rem; }
.preference-button {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    min-height: 2.25rem; min-width: 2.25rem; padding: 0 0.7rem;
    background: transparent; border: 1px solid var(--rule); border-radius: 2px;
    font-size: 0.9rem; color: var(--muted); cursor: pointer;
}
.preference-button:hover { color: var(--ink); border-color: var(--muted); }
.menu-toggle { display: none; }

/* Hero -------------------------------------------------------------------- */
.hero { padding-block: clamp(3.5rem, 9vw, 7rem) clamp(3rem, 7vw, 5rem); }

.hero h1 {
    font-size: clamp(3rem, 9vw, 7rem);
    font-weight: 450; line-height: 0.98; letter-spacing: -0.035em;
    margin-bottom: clamp(1.5rem, 3vw, 2.25rem);
}
.hero-lead {
    max-width: 30em; font-size: clamp(1.3rem, 2.4vw, 1.75rem); line-height: 1.4;
    letter-spacing: -0.01em; margin-bottom: 2.25rem;
}
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1.5rem; margin-bottom: clamp(2.75rem, 6vw, 4.5rem); }

.btn {
    display: inline-flex; align-items: center; min-height: 2.9rem; padding: 0 1.4rem;
    background: var(--accent); color: var(--accent-ink);
    border-radius: 2px; text-decoration: none; font-weight: 500; font-size: 1.02rem;
}
.btn:hover { filter: brightness(1.12); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
.btn-ghost:hover { filter: none; background: var(--ink); color: var(--paper); }

/* The one memorable thing: a resolver answer ------------------------------- */
.zone {
    font-family: var(--mono); font-size: 0.875rem; line-height: 1.75;
    background: var(--panel); border: 1px solid var(--rule); border-radius: 2px;
    padding: 1.25rem 1.5rem; overflow-x: auto;
}
.zone-cmd { color: var(--muted); margin-bottom: 0.4rem; white-space: nowrap; }
.zone-cmd b { color: var(--accent); font-weight: 500; }
.zone-row {
    display: grid; grid-template-columns: 8ch 7ch minmax(0, 1fr); column-gap: 1.25ch;
    white-space: nowrap; color: var(--ink);
}
.zone-row dt, .zone-row dd { display: contents; }
.zone-name { color: var(--accent); }
.zone-type { color: var(--muted); }
.zone-val a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
.zone-val a:hover { color: var(--accent); }
.zone-note { color: var(--muted); }

@keyframes resolve { from { opacity: 0; } to { opacity: 1; } }
.zone-row { opacity: 0; animation: resolve 0.35s ease-out forwards; animation-delay: calc(0.35s + var(--i) * 0.16s); }

/* Sections ---------------------------------------------------------------- */
.sec { border-top: 1px solid var(--rule); padding-block: clamp(2.75rem, 6vw, 4.5rem); }
.sec-grid { display: grid; grid-template-columns: var(--label-col) minmax(0, 1fr); gap: 2rem clamp(2rem, 5vw, 4rem); }
.sec-title {
    position: sticky; top: 5rem; align-self: start;
    font-size: 1.5rem; font-weight: 500; line-height: 1.2; letter-spacing: -0.015em;
}
.sec-body { max-width: 44rem; }
.sec-body.wide { max-width: none; }

/* About */
.about-body p { margin-bottom: 1.15em; }
.about-body p:last-child { margin-bottom: 0; }
.portrait {
    width: 7rem; height: 7rem; margin-top: 1.5rem;
    object-fit: cover; border-radius: 2px; border: 1px solid var(--rule); filter: grayscale(0.35);
}

/* Skills: a plain table */
.skills > div {
    display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 0.5rem 2rem;
    padding-block: 1.1rem; border-bottom: 1px solid var(--rule);
}
.skills > div:first-child { padding-top: 0; }
.skills > div:last-child { border-bottom: 0; padding-bottom: 0; }
.skills dt { font-weight: 560; }
.skills ul { color: var(--muted); }
.skills li { display: inline; }
.skills li:not(:last-child)::after { content: ", "; }

/* Projects: ruled list */
.project { padding-block: 2rem; border-bottom: 1px solid var(--rule); display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }
.project:first-child { padding-top: 0; }
.project:last-child { border-bottom: 0; padding-bottom: 0; }
.project-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 1rem; }
.project h3 { font-size: 1.65rem; font-weight: 500; letter-spacing: -0.015em; line-height: 1.2; }
.project-status { font-style: italic; color: var(--muted); font-size: 1rem; }
.project-status.is-live { color: var(--live); }
.project p { color: var(--ink); max-width: 40em; }
.project-tech { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); line-height: 1.6; }
.project-tech span:not(:last-child)::after { content: ", "; }
.project-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; margin-top: 0.25rem; }


/* Project cards open a detail dialog ------------------------------------- */
.project { cursor: pointer; }
.project-open { background: none; border: 0; padding: 0; text-align: left; font: inherit; letter-spacing: inherit; color: inherit; cursor: pointer; }
.project:hover .project-open { color: var(--accent); }
.project-more { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

.modal {
    margin: auto; padding: 0; border: 1px solid var(--rule); border-radius: 2px;
    width: min(44rem, calc(100vw - 2rem)); max-height: min(46rem, calc(100dvh - 2rem));
    background: var(--paper); color: var(--ink); overflow: hidden;
    box-shadow: 0 24px 60px rgb(0 0 0 / 0.28);
}
.modal[open] { display: flex; animation: modal-in 0.2s ease-out; }
.modal::backdrop { background: rgb(10 12 18 / 0.6); animation: fade-in 0.2s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
body.modal-open { overflow: hidden; }

.modal-card { display: flex; flex-direction: column; width: 100%; min-height: 0; }
.modal-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
    padding: 1.5rem 1.75rem 1.1rem; border-bottom: 1px solid var(--rule);
}
.modal-head h2 { font-size: clamp(1.7rem, 4vw, 2.3rem); font-weight: 500; line-height: 1.1; letter-spacing: -0.02em; }
.modal-head .project-status { display: inline-block; margin-top: 0.35rem; }
.modal-close {
    flex-shrink: 0; display: grid; place-items: center; width: 2.4rem; height: 2.4rem;
    background: transparent; border: 1px solid var(--rule); border-radius: 2px; color: var(--muted); cursor: pointer;
}
.modal-close:hover { color: var(--ink); border-color: var(--muted); }

.modal-body { overflow-y: auto; padding: 1.5rem 1.75rem 2rem; overscroll-behavior: contain; }
.modal-body > * + * { margin-top: 1rem; }
.modal-body .detail-lead { font-size: 1.3rem; line-height: 1.45; letter-spacing: -0.01em; }
.modal-body h4 { margin-top: 2rem; font-size: 1.1rem; font-weight: 600; }
.modal-body h4 + * { margin-top: 0.5rem; }
.modal-body p { color: var(--ink); max-width: 38em; }
.modal-body ul { padding-left: 1.2rem; list-style: disc; display: grid; gap: 0.6rem; max-width: 38em; }
.modal-body li::marker { color: var(--accent); }
.modal-body .detail-tech { font-family: var(--mono); font-size: 0.82rem; color: var(--muted); }
.modal-body .detail-tech span:not(:last-child)::after { content: ", "; }

@media (max-width: 560px) {
    .modal { width: 100vw; max-height: 100dvh; height: 100dvh; border: 0; }
    .modal-head { padding: 1.1rem 1.1rem 0.9rem; }
    .modal-body { padding: 1.1rem 1.1rem 2rem; }
}
@media (prefers-reduced-motion: reduce) {
    .modal[open], .modal::backdrop { animation: none; }
}

/* Listening */
.listening { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.album-cover { width: 3.5rem; height: 3.5rem; object-fit: cover; border-radius: 2px; border: 1px solid var(--rule); }
.track-details { min-width: 0; flex: 1 1 14rem; }
.track-details h4 { font-size: 1.1rem; font-weight: 560; line-height: 1.3; }
.track-details p { color: var(--muted); font-size: 1rem; line-height: 1.4; }

/* Contact */
.contact-mail {
    display: inline-block; font-size: clamp(1.6rem, 4.6vw, 3rem); letter-spacing: -0.025em; line-height: 1.15;
    color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent);
    text-decoration-thickness: 2px; text-underline-offset: 0.18em; overflow-wrap: anywhere;
}
.contact-mail:hover { color: var(--accent); }
.contact-text { color: var(--muted); margin-top: 1.1rem; max-width: 34em; }
.contact-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1.75rem; margin-top: 1.5rem; }

/* Footer ------------------------------------------------------------------ */
.foot { border-top: 1px solid var(--rule); padding-block: 1.75rem; color: var(--muted); font-size: 0.95rem; }
.foot-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 2rem; }

/* Responsive -------------------------------------------------------------- */
@media (max-width: 860px) {
    .sec-grid { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
    .sec-title { position: static; }
    .skills > div { grid-template-columns: minmax(0, 1fr); gap: 0.15rem; }

    .menu-toggle { display: inline-flex; }
    .bar-nav {
        display: none; position: absolute; top: 100%; left: 0; right: 0;
        flex-direction: column; gap: 0; padding: 0.5rem var(--gutter) 1rem;
        background: var(--paper); border-bottom: 1px solid var(--rule);
    }
    .bar-nav.open { display: flex; }
    .bar-nav a { padding-block: 0.7rem; border-bottom: 0; }
    .bar-nav a.active { color: var(--accent); }
    .bar-inner { gap: 1rem; }
}

@media (max-width: 560px) {
    body { font-size: 1.0625rem; }
    .zone { padding: 1rem; font-size: 0.8rem; }
    .zone-row { grid-template-columns: 7ch 6ch minmax(0, 1fr); }
    .btn { width: 100%; justify-content: center; }
    .hero-actions { gap: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .zone-row { opacity: 1; animation: none; }
}
