/* ==========================================================================
   Javier Fernandez-Budiman - Portfolio
   Minimal, strictly black-on-white. Single typeface (Inter); mono for code only.
   ========================================================================== */

/* --- Design tokens ------------------------------------------------------- */
:root {
    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;

    --bg: #ffffff;
    --ink: #000000;          /* headings, links, accents: strictly black */
    --ink-body: #1a1a1a;     /* paragraph text */
    --ink-muted: #6b6b6b;    /* teasers, labels */
    --ink-faint: #9b9b9b;    /* indices, footnotes */
    --line: rgba(0, 0, 0, 0.12);
    --line-strong: rgba(0, 0, 0, 0.28);

    --measure: 62ch;
    --page-max: 1140px;
    --gutter: clamp(1.25rem, 5vw, 4rem);
    --section-gap: clamp(4rem, 10vw, 7.5rem);
}

/* --- Reset / base -------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
}

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

body {
    background: var(--bg);
    color: var(--ink-body);
    font-family: var(--font-sans);
    font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

img {
    max-width: 100%;
    display: block;
    height: auto;
}

a {
    color: inherit;
    text-decoration: none;
}

::selection {
    background: var(--ink);
    color: var(--bg);
}

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

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--ink);
    color: var(--bg);
    padding: 0.6rem 1rem;
    z-index: 100;
}
.skip-link:focus {
    left: 0;
}

/* --- Layout helpers ------------------------------------------------------ */
.site-header,
.page,
.site-footer {
    width: 100%;
    max-width: var(--page-max);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

/* --- Header (minimal wordmark) ------------------------------------------ */
.site-header {
    padding-block: 1.6rem;
}
.brand {
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    color: var(--ink);
}
.brand:hover {
    opacity: 0.6;
}

/* --- Hero: name alongside About ----------------------------------------- */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
    padding-block: clamp(3.5rem, 8vw, 6.5rem) clamp(2.5rem, 6vw, 4.5rem);
}

.eyebrow {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin-bottom: 1.25rem;
}

.hero-name {
    font-weight: 800;
    font-size: clamp(1.9rem, 1rem + 4vw, 3.5rem);
    line-height: 1.04;
    letter-spacing: -0.03em;
    color: var(--ink);
    text-wrap: balance;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
}

/* Clean black résumé link: no border, no pill, no transform, just black + underline */
.resume-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    color: var(--ink);
    border-bottom: 1.5px solid var(--ink);
    padding-bottom: 2px;
}
.resume-link:hover {
    opacity: 0.6;
}
.resume-link .arrow {
    font-weight: 400;
}

.hero-socials {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.25rem;
    list-style: none;
    padding: 0;
    font-size: 0.9rem;
    font-weight: 800;
}
.hero-socials a {
    color: var(--ink-muted);
}
.hero-socials a:hover {
    color: var(--ink);
}

.about-socials {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-top: 1.25rem;
    font-size: 0.95rem;
    font-weight: 500;
}
.about-socials a {
    color: var(--ink-muted);
    border-bottom: 1px solid var(--line);
}
.about-socials a:hover {
    color: var(--ink);
    border-bottom-color: var(--ink);
}

/* About block (centered under name) */
.hero-about {
    padding-top: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.hero-about h2 {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin-bottom: 1.1rem;
    text-align: center;
    display: none; /* Hide 'ABOUT' heading for cleaner stacked layout */
}
.hero-about p {
    font-size: clamp(1.05rem, 1rem + 0.5vw, 1.3rem);
    line-height: 1.55;
    color: var(--ink-body);
    max-width: 65ch;
    margin: 0 auto 1.1rem;
    text-align: center;
}

/* --- Projects: image-forward card grid ---------------------------------- */
.work {
    padding-bottom: var(--section-gap);
}

.project-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(2rem, 5vw, 4rem) clamp(1.5rem, 4vw, 3rem);
}

/* Each card is a single link wrapping image + title (both navigate) */
.project-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.project-card-media {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    aspect-ratio: 4 / 3;
    background: #f4f4f4;
    border: 1px solid var(--line);
}
.project-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.2, 0.6, 0.2, 1);
}
/* Subtle wash that deepens on hover to "highlight" the image */
.project-card-media::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.04);
    opacity: 0;
    transition: opacity 0.4s ease;
}
.project-card:hover .project-card-media img,
.project-card:focus-visible .project-card-media img {
    transform: scale(1.05);
}
.project-card:hover .project-card-media::after,
.project-card:focus-visible .project-card-media::after {
    opacity: 1;
}

.project-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 1.25rem;
}
.project-card-index {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--ink-faint);
}
.project-card-title {
    font-weight: 700;
    font-size: clamp(1.4rem, 1rem + 1.6vw, 2.1rem);
    line-height: 1.08;
    letter-spacing: -0.02em;
    color: var(--ink);
    background-image: linear-gradient(var(--ink), var(--ink));
    background-size: 0% 2px;
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: background-size 0.35s ease;
}
.project-card:hover .project-card-title,
.project-card:focus-visible .project-card-title {
    background-size: 100% 2px;
}
.project-card-domain {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-muted);
}
.project-card-teaser {
    font-size: 1rem;
    color: var(--ink-muted);
    max-width: 46ch;
}
.project-card-cta {
    margin-top: 0.35rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink);
}
.project-card-cta .arrow {
    display: inline-block;
    transition: transform 0.3s ease;
}
.project-card:hover .project-card-cta .arrow,
.project-card:focus-visible .project-card-cta .arrow {
    transform: translateX(5px);
}

/* Graceful fallback list if JavaScript is unavailable */
.noscript-projects {
    margin: 0;
    padding-left: 1.1rem;
    line-height: 2;
}
.noscript-projects a {
    border-bottom: 1px solid var(--ink);
}

/* --- Status: "In Development" indicators -------------------------------- */
/* Card overlay: badge (top-left) + indeterminate progress bar (bottom) */
.status-badge {
    position: absolute;
    top: 0.8rem;
    left: 0.8rem;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.32rem 0.65rem;
    border-radius: 100px;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}
.status-badge .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f5a623;
    animation: badge-pulse 1.9s ease-out infinite;
}
@keyframes badge-pulse {
    0% { box-shadow: 0 0 0 0 rgba(245, 166, 35, 0.55); }
    70% { box-shadow: 0 0 0 7px rgba(245, 166, 35, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 166, 35, 0); }
}

.progress-track {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    height: 4px;
    background: rgba(255, 255, 255, 0.22);
    overflow: hidden;
}
.progress-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -40%;
    width: 40%;
    background: #f5a623;
    animation: progress-slide 1.9s ease-in-out infinite;
}
@keyframes progress-slide {
    0% { left: -40%; }
    100% { left: 100%; }
}
.project-card.is-in-progress .project-card-media img {
    opacity: 0.9;
}

/* Inline badge beside the title on a case-study page (light theme) */
.status-badge--inline {
    position: static;
    background: #fdf1dc;
    color: #8a5a00;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
.status-badge--inline .dot {
    animation: none;
}

/* In-development banner on a case-study page */
.dev-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding: 0.9rem 1.1rem;
    border: 1px solid var(--line);
    border-left: 3px solid #f5a623;
    border-radius: 8px;
    background: #fffaf0;
}
.dev-banner .dot {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f5a623;
}
.dev-banner p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--ink-body);
}

/* --- Case-study head + extras ------------------------------------------- */
.cs-eyebrow-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}
.cs-eyebrow-row .eyebrow {
    margin: 0;
}
#cs-extra {
    margin-top: clamp(2.5rem, 6vw, 3.5rem);
    padding-top: 1.75rem;
    border-top: 1px solid var(--line);
}
.extra-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: 0 !important;
}
.extra-links {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85rem;
    margin-top: 1.5rem;
}
.extra-links .source-link {
    margin-top: 0;
}
.source-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 1.5rem;
    font-weight: 600;
    color: var(--ink);
    border-bottom: 1.5px solid var(--ink);
    padding-bottom: 2px;
}
.source-link:hover {
    opacity: 0.6;
}

/* Inline prose link; long bare URLs must wrap rather than force a scrollbar. */
.inline-link {
    color: var(--ink);
    border-bottom: 1.5px solid var(--line);
    overflow-wrap: anywhere;
}
.inline-link:hover {
    border-bottom-color: var(--ink);
}

/* --- Case-study figures + lightbox -------------------------------------- */
.case-figure {
    margin: 1.5rem 0 2rem;
}
.case-figure-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem 0.9rem;
    align-items: start;
}
.case-figure-grid.is-gallery {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.case-figure-cell {
    min-width: 0;
}
.case-figure-item {
    display: block;
    width: 100%;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: #fafafa;
    cursor: zoom-in;
}
.case-figure-item--plate {
    background: #fff;
    padding: 0.85rem;
}
.case-figure-item img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 0.4s ease;
}
.case-figure-item:hover img,
.case-figure-item:focus-visible img {
    transform: scale(1.03);
}
.case-figure-label {
    display: block;
    margin-top: 0.45rem;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--ink-muted);
    text-align: center;
}
.case-figure figcaption {
    margin-top: 0.7rem;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--ink-muted);
}

/* Full-screen image lightbox (created on demand in project.js) */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: clamp(1rem, 4vw, 3rem);
    background: rgba(0, 0, 0, 0.88);
    cursor: zoom-out;
    animation: lightbox-in 0.2s ease;
}
.lightbox img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 6px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
@keyframes lightbox-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Footer (contact) --------------------------------------------------- */
.site-footer {
    padding-block: clamp(2.5rem, 6vw, 4rem);
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
}
.footer-contact {
    width: 100%;
    max-width: 650px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.footer-contact .footer-label {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin-bottom: 1.5rem;
    text-align: center;
}
.contact-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    width: 100%;
}
.contact-form input:nth-child(1) { grid-column: 1 / 2; }
.contact-form input:nth-child(2) { grid-column: 2 / 3; }
.contact-form textarea { grid-column: 1 / -1; }
.contact-form input,
.contact-form textarea {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg);
    color: var(--ink-body);
}
.contact-form input:focus,
.contact-form textarea:focus {
    outline: none;
    border-color: var(--ink);
}
.contact-form button {
    grid-column: 1 / -1;
    justify-self: center;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.8rem 2.5rem;
    border: none;
    border-radius: 6px;
    background: var(--ink);
    color: var(--bg);
    cursor: pointer;
    transition: opacity 0.2s;
    margin-top: 0.5rem;
}
.contact-form button:hover {
    opacity: 0.8;
}
.footer-legal {
    width: 100%;
    padding-top: 1.5rem;
    border-top: 1px solid var(--line);
    font-size: 0.8rem;
    color: var(--ink-faint);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
}

/* --- Project sub-pages (article) ---------------------------------------- */
.article {
    padding-block: clamp(2rem, 5vw, 3.5rem) var(--section-gap);
    max-width: 900px;
}
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ink-muted);
    margin-bottom: clamp(2rem, 5vw, 3rem);
}
.back-link:hover {
    color: var(--ink);
}
.article-title {
    font-weight: 800;
    font-size: clamp(2rem, 1rem + 4vw, 3.5rem);
    line-height: 1.04;
    letter-spacing: -0.03em;
    color: var(--ink);
    margin-block: 0.75rem 1.25rem;
}
.article-lead {
    font-size: clamp(1.15rem, 1rem + 0.8vw, 1.45rem);
    line-height: 1.5;
    color: var(--ink-body);
    max-width: var(--measure);
}
.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem 2.5rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--line);
}
.article-meta div {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.article-meta dt {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-faint);
}
.article-meta dd {
    margin: 0;
    font-weight: 600;
    color: var(--ink);
}

.article-figure {
    margin-block: clamp(2.5rem, 6vw, 4rem);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
}
.article-figure img {
    width: 100%;
    height: auto;
    cursor: zoom-in;
    transition: opacity 0.3s ease;
}
.article-figure img:hover {
    opacity: 0.92;
}

/* Long-form prose */
.prose {
    max-width: var(--measure);
}
.prose h2 {
    font-weight: 700;
    font-size: clamp(1.3rem, 1rem + 1.2vw, 1.7rem);
    letter-spacing: -0.01em;
    color: var(--ink);
    margin-top: clamp(2.5rem, 6vw, 3.5rem);
    margin-bottom: 1rem;
}
.prose h3 {
    font-weight: 700;
    font-size: clamp(1.05rem, 1rem + 0.5vw, 1.25rem);
    letter-spacing: -0.01em;
    color: var(--ink);
    margin-top: clamp(2rem, 4vw, 2.75rem);
    margin-bottom: 0.6rem;
}
.prose p {
    margin-bottom: 1.1rem;
    color: var(--ink-body);
}
.prose strong {
    color: var(--ink);
    font-weight: 600;
}
.prose ol,
.prose ul {
    margin-bottom: 1.1rem;
    padding-left: 1.25rem;
    color: var(--ink-body);
}
.prose li {
    margin-bottom: 0.5rem;
}
.prose code {
    font-family: var(--font-mono);
    font-size: 0.86em;
    background: #f4f4f4;
    padding: 0.1em 0.35em;
    border-radius: 4px;
}
.result-stat {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin-block: 1.5rem;
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--line);
    border-radius: 10px;
}
.result-value {
    font-weight: 800;
    font-size: 1.9rem;
    letter-spacing: -0.02em;
    color: var(--ink);
}
.result-label {
    color: var(--ink-muted);
}

/* --- Code blocks --------------------------------------------------------- */
.code-block {
    margin-block: 1.5rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: #fafafa;
}
.code-block figcaption {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    color: var(--ink-muted);
    padding: 0.55rem 0.95rem;
    border-bottom: 1px solid var(--line);
}
.code-block pre {
    margin: 0;
    padding: 1rem;
    overflow-x: auto;
}
.code-block code {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--ink);
}

.tech-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    list-style: none;
    padding: 0 !important;
    margin-top: 1.25rem;
}

/* Skills: label sits inline with its tag row to keep the block compact */
.skills {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    column-gap: 1.25rem;
    row-gap: 0.7rem;
    align-items: baseline;
    width: 100%;
    max-width: 44rem;
    margin: 1.5rem auto 0;
}
.skills dt {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--ink-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-align: right;
    white-space: nowrap;
}
.skills dd {
    margin: 0;
}
.skills .tech-tags {
    justify-content: flex-start;
    gap: 0.4rem;
    margin-top: 0;
}
.tech-tags li {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--ink-body);
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    margin: 0 !important;
}

/* --- Responsive ---------------------------------------------------------- */
@media (max-width: 820px) {
    .hero {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }
    .hero-about {
        padding-top: 0;
    }
    .skills {
        grid-template-columns: 1fr;
        row-gap: 0.35rem;
    }
    .skills dt {
        text-align: center;
    }
    .skills dt + dd {
        margin-bottom: 0.9rem;
    }
    .skills .tech-tags {
        justify-content: center;
    }
    .project-grid {
        grid-template-columns: 1fr;
    }
    .site-footer {
        padding-block: 2.5rem;
    }
    .contact-form {
        grid-template-columns: 1fr;
    }
    .contact-form input:nth-child(1),
    .contact-form input:nth-child(2) {
        grid-column: 1 / -1;
    }
}

/* --- Motion preferences -------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
