/* =========================
   WORKS PAGE
========================= */

.works-page {
    background-color: var(--color-background);
    color: var(--color-text);
}


/* =========================
   NAV OVERRIDE
========================= */

/*
 * Na Home a Nav começa invisível porque
 * hero-intro.js é responsável pelo reveal.
 *
 * Na página Works ela deve aparecer
 * imediatamente.
 */

.works-page .nav {
    opacity: 1;
    visibility: visible;
}


/* =========================
   WORKS HERO
========================= */

.works-hero {
    position: relative;

    height: 100svh;

    display: flex;
    flex-direction: column;

    overflow: hidden;
}


.works-hero__inner {
    width: 100%;
    height: 100%;

    display: grid;

    grid-template-rows:
        80px
        1fr
        auto
        48px;
}


/* =========================
   CURSOR PROJECT PREVIEW
========================= */

.works-hero__cursor-preview {
    position: absolute;

    top: 0;
    left: 0;

    width: clamp(
        180px,
        16vw,
        240px
    );

    aspect-ratio: 16 / 10;

    z-index: 5;

    pointer-events: none;

    opacity: 0;

    transform:
        translate3d(0, 0, 0)
        scale(0.96);

    will-change:
        transform,
        opacity;

    overflow: hidden;
}


.works-hero__cursor-image {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: cover;

    user-select: none;
    -webkit-user-drag: none;
}


/* =========================
   TITLE
========================= */

.works-hero__title {
    grid-row: 2;

    align-self: center;

    margin: 0;
    padding-inline: var(--gutter-page);

    font-family: var(--font-display);

    font-size: min(
        var(--font-display-desktop),
        10.94svh
    );

    font-weight: var(--weight-bold);

    line-height: 0.85;
    letter-spacing: 0;
}


/*
 * Each line sits in its own mask for the
 * entrance reveal (works-hero-title.js). A
 * line keeps the title's line-height, so the
 * title is laid out exactly as plain lines.
 * The "j" of "Projects" hangs about 0.18em
 * below its line, so every line reaches
 * 0.25em lower and its mask gives that space
 * back: the clip holds the whole glyph and
 * the next line keeps its place.
 */

.works-hero__title-mask {
    display: block;

    margin-bottom: -0.25em;

    overflow: hidden;
}


.works-hero__title-line {
    display: block;

    padding-bottom: 0.25em;
}


/*
 * Until the reveal script takes over, the
 * lines wait below their masks. The class is
 * set before the first paint (works/index.html)
 * and only while JavaScript runs.
 */

@media (prefers-reduced-motion: no-preference) {

    .works-title-pending .works-hero__title-line {
        transform: translateY(115%);
    }

}


/* =========================
   DISCIPLINES MARQUEE
========================= */

.works-hero__marquee {
    grid-row: 3;

    width: 100%;

    overflow: hidden;
}


.works-hero__marquee-track {
    width: max-content;

    display: flex;
    align-items: center;

    animation:
        works-hero-marquee
        41.54s
        linear
        infinite;
}


.works-hero__marquee-group {
    display: flex;
    align-items: center;

    gap: var(--marquee-gap);

    padding-right: var(--marquee-gap);

    flex-shrink: 0;
}


.works-hero__marquee span {
    font-family: var(--font-mono);

    font-size: var(--font-label-desktop);
    font-weight: var(--weight-regular);

    line-height: 1.2;

    white-space: nowrap;
}


/* =========================
   MARQUEE MOVEMENT
========================= */

/*
 * The track holds three copies of the tags and
 * moves by exactly one per loop, so the strip
 * stays covered on screens up to two copies wide
 * (about 4800px at 16px). With only two copies,
 * screens wider than one copy saw a gap at the end
 * of each loop. The durations are set for one copy.
 */

@keyframes works-hero-marquee {

    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(calc(-100% / 3));
    }

}


/* =========================
   REDUCED MOTION
========================= */

/*
 * Reduced motion starts the loop paused; the
 * motion toggle (js/motion-toggle.js) pauses
 * or plays it for everyone.
 */

@media (prefers-reduced-motion: reduce) {
    .works-hero__marquee-track {
        animation-play-state: paused;
    }
}

[data-motion="paused"] .works-hero__marquee-track {
    animation-play-state: paused;
}

[data-motion="playing"] .works-hero__marquee-track {
    animation-play-state: running;
}


/* =========================
   PROJECTS
========================= */

.projects {
    width: 100%;
}


/* =========================
   PROJECT
========================= */

.project {
    --project-frame: var(--space-16);
    --project-cta-gap: var(--space-48);
    --project-rhythm: var(--space-120);

    min-height: 100svh;

    display: flex;
    align-items: center;

    padding: var(--project-rhythm) var(--gutter-page);
}


.project__inner {
    width: 100%;
    max-width: 820px;

    margin-inline: auto;

    display: flex;
    flex-direction: column;
}


/* =========================
   COUNTER
========================= */

.project__counter {
    margin: 0;

    font-family: var(--font-mono);

    font-size: min(
        var(--font-label-desktop),
        1.56vh
    );

    font-weight: var(--weight-regular);
    line-height: 1.2;

    color: var(--color-text);
}


/* =========================
   PROJECT VISUAL
========================= */

.project__visual {
    position: relative;

    width: 90%;
    aspect-ratio: 16 / 10;

    align-self: center;

    display: block;

    text-decoration: none;

    /*
     * Finger drags reach the slider on every
     * touch screen: vertical swipes still scroll
     * the page, horizontal ones move the front
     * card. Without it the browser claims a
     * horizontal swipe as a pan and cancels the
     * drag. Home sets the same pan-y on its
     * slides (works-slider.js).
     */

    touch-action: pan-y pinch-zoom;
}


/*
 * height: auto lets the width/height attributes on
 * the lazy-loaded boards (2–6) reserve each image's
 * 16:9 box before it downloads, instead of acting
 * as a fixed pixel height.
 */

.project__image {
    position: absolute;

    display: block;

    height: auto;

    object-fit: cover;
}


/* Back */

.project__image--back {
    width: 76%;

    top: 0;
    left: 12%;

    z-index: 1;
}


/* Middle */

.project__image--middle {
    width: 88%;

    top: 5%;
    left: 6%;

    z-index: 2;
}


/* Front */

.project__image--front {
    width: 100%;

    left: 0;
    bottom: 0;

    z-index: 3;
}


/* =========================
   PROJECT HEADER
========================= */

.project__header {
    width: 90%;

    align-self: center;

    display: flex;
    align-items: baseline;
    justify-content: space-between;

    margin-bottom: var(--project-frame);
}


/* =========================
   PROJECT INFORMATION
========================= */

.project__info {
    width: 90%;

    align-self: center;

    margin-top: var(--project-frame);

    display: flex;
    align-items: flex-end;
    justify-content: space-between;

    gap: var(--project-cta-gap);
}


.project__description {
    display: flex;
    flex-direction: column;

    gap: var(--text-pair-gap);
}


.project__title {
    margin: 0;

    font-family: var(--font-display);

    font-size: min(
        var(--font-body-desktop),
        1.95svh
    );

    font-weight: var(--weight-bold);

    line-height: 1.1;

    color: var(--color-text);
}


.project__subtitle {
    margin: 0;

    font-family: var(--font-mono);

    font-size: min(
        var(--font-body-desktop),
        1.95svh
    );

    font-weight: var(--weight-bold);

    line-height: 1.3;

    color: var(--color-text);
}


.project__services,
.project__link {
    margin: 0;

    font-family: var(--font-mono);

    font-size: min(
        var(--font-body-desktop),
        1.95svh
    );

    font-weight: var(--weight-regular);

    line-height: 1.3;

    color: var(--color-text);
}


.project__link {
    text-decoration: none;
}


.project__link:hover {
    opacity: 0.6;
}


.project__link:active {
    opacity: 1;
    color: #000000;
}

/* =========================
   WORKS PAGE — DESKTOP
========================= */

/*
 * The disciplines marquee follows the Home Hero
 * marquee (hero.css): 16px on shorter screens,
 * growing with the screen height to 18px at
 * 1023px tall. Its row keeps the height of the
 * 16px line it was laid out with (16px × 1.2), so
 * the title and the Hero stay where they are. The
 * line keeps that line's leading (16px × 0.2) and
 * grows upward from the row's bottom edge, so the
 * text stays on the same baseline.
 */

@media (min-width: 1025px) {

    .works-hero__marquee-track {
        height: calc(var(--font-label-desktop) * 1.2);

        align-items: flex-end;
    }

    .works-hero__marquee span {
        font-size: clamp(
            var(--font-label-desktop),
            1.76svh,
            var(--font-marquee-desktop)
        );
        line-height: calc(1em + var(--font-label-desktop) * 0.2);
    }


    /*
     * A project no longer fills a screen of its
     * own (min-height: 100svh), which made the gap
     * between projects grow with the screen height.
     * It is as tall as its content plus 160px above
     * and below, so every project sits 320px from
     * the next on any Desktop screen.
     */

    .project {
        --project-rhythm: var(--space-160);

        min-height: 0;
    }
}

/*
 * A larger size makes a longer loop (2402px at
 * 16px, 2637px at 18px), so the loop runs longer
 * to keep the 16px speed of about 57.8px/s:
 * 41.54s scaled by the loop length. Between 910px
 * and 1022px tall the size grows with the screen
 * height, so the duration steps up through that
 * range in four bands, each within about 1% of
 * the exact speed.
 */

@media (min-width: 1025px) and (min-height: 910px) {
    .works-hero__marquee-track { animation-duration: 42.11s; }
}

@media (min-width: 1025px) and (min-height: 939px) {
    .works-hero__marquee-track { animation-duration: 43.107s; }
}

@media (min-width: 1025px) and (min-height: 967px) {
    .works-hero__marquee-track { animation-duration: 44.103s; }
}

@media (min-width: 1025px) and (min-height: 995px) {
    .works-hero__marquee-track { animation-duration: 45.1s; }
}

@media (min-width: 1025px) and (min-height: 1023px) {
    .works-hero__marquee-track { animation-duration: 45.608s; }
}

/* =========================
   WORKS PAGE — LARGE TABLET (PORTRAIT)
========================= */

/*
 * iPad Pro portrait keeps the Desktop layout but
 * takes the Tablet rhythm: projects 240px apart
 * (120px above and below each) and Dom Studio 24%
 * of a screen below the Hero. The last project
 * ends at its own content, so only the shared
 * section gap (global.css) separates it from
 * Contact, as Works does on Home.
 */

@media (min-width: 1025px) and (max-width: 1199px) and (orientation: portrait) {

    .project {
        --project-rhythm: var(--space-120);
    }

    .project:first-child {
        padding-top: max(120px, 24svh);
    }

    .project:last-of-type {
        padding-bottom: 0;
    }
}

/* =========================
   WORKS PAGE — TABLET
========================= */

/*
 * Same responsive system as the Home Tablet:
 *
 *   Hero      mirrors .hero (hero.css): 72px / 40px
 *             grid rows, 80px display title,
 *             16px marquee with 32px gaps.
 *
 *   Projects  labels on the 48px page edges like
 *             .works (works.css), 18px names and
 *             links, 15px counter. The stack is
 *             centered 56px from the screen edges.
 *
 *   Contact   already shared through contact.css.
 */

@media (min-width: 768px) and (max-width: 1024.98px) {

    /* =========================
       HERO
    ========================= */

    .works-hero__inner {
        grid-template-rows:
            72px
            1fr
            auto
            40px;
    }

    .works-hero__title {
        font-size: var(--font-display-tablet);
        line-height: 0.85;
    }

    /*
     * The marquee row keeps the height of the 12px
     * line the Tablet Hero was laid out with (12px ×
     * 1.2), and the 16px line grows upward from its
     * bottom edge on the same baseline, as on the
     * Home Hero. Its tallest letters reach just past
     * that row, so the strip only clips sideways; a
     * clipping box loses the zero minimum width of a
     * scroll container, so it is set back here.
     *
     * The 16px loop is 2297.69px long, so it runs
     * for 52.185s (2297.69 / 44.03) and keeps the
     * Tablet speed of about 44px/s.
     */

    .works-hero__marquee {
        min-width: 0;

        overflow-x: clip;
        overflow-y: visible;
    }

    .works-hero__marquee-track {
        height: calc(12px * 1.2);

        align-items: flex-end;

        animation-duration: 52.185s;
    }

    .works-hero__marquee span {
        font-size: var(--font-marquee-tablet);
        line-height: calc(1em + 12px * 0.2);
    }


    /* =========================
       PROJECTS — RHYTHM
    ========================= */

    /*
     * A project no longer reserves a screen of its
     * own. It is as tall as its content plus the
     * base 120px padding above and below, so every
     * project sits 240px from the next.
     */

    .project {
        min-height: 0;
    }

    /*
     * Dom Studio sits 24% of a screen below the
     * Hero (about 246px at 768x1024), never less
     * than the base 120px padding.
     */

    .project:first-child {
        padding-top: max(120px, 24svh);
    }


    /* =========================
       PROJECT
    ========================= */

    .project__inner {
        max-width: none;
    }

    .project__header,
    .project__info {
        width: 100%;
    }

    .project {
        --project-frame: var(--space-32);
    }

    /*
     * 56px from the screen edges: the 48px page
     * padding plus 8px on each side (656px wide
     * at 768px).
     */

    .project__visual {
        width: calc(100% - 16px);
    }


    /* =========================
       TYPOGRAPHY
    ========================= */

    .project__title {
        font-size: 18px;
    }

    .project__counter {
        font-size: var(--font-label-tablet);
    }

    .project__subtitle,
    .project__services,
    .project__link {
        font-size: 18px;
    }


    /* =========================
       PROJECTS → CONTACT
    ========================= */

    /*
     * The section gap before Contact (global.css:
     * min(88px, 8.59svh)) drops to the 48px Tablet
     * spacing, scaled the same way. With the last
     * project's 120px padding and Contact's own
     * 72px top padding, Ocean Brazil also sits
     * 240px from "Let's talk.". Contact itself is
     * untouched.
     */

    main > .contact {
        margin-top: min(48px, 4.69svh);
    }
}


/* =========================
   WORKS PAGE — MOBILE
========================= */

/*
 * Same responsive system as the Home Mobile:
 *
 *   Hero      mirrors .hero (hero.css): 48px / 32px
 *             grid rows, 60px display title inside
 *             the 20px page margins, 14px marquee
 *             with 24px gaps.
 *
 *   Projects  mirror .works (works.css): 20px page
 *             margins, full-width stack, 16px names
 *             and links, 13px counter.
 *
 *   Contact   already shared through contact.css.
 */

@media (max-width: 767.98px) {

    /* =========================
       HERO
    ========================= */

    .works-hero__inner {
        grid-template-rows:
            48px
            1fr
            auto
            32px;
    }

    .works-hero__title {
        font-size: var(--font-display-mobile);
        line-height: 0.86;
    }

    /*
     * Same as Tablet with the 11px line the Mobile
     * Hero was laid out with: the 14px line grows
     * upward from the bottom of that row on the same
     * baseline. The 14px loop is 1958.5px long, so
     * it runs for 50.762s (1958.5 / 38.58) and keeps
     * the Mobile speed of about 38.6px/s.
     */

    .works-hero__marquee {
        min-width: 0;

        overflow-x: clip;
        overflow-y: visible;
    }

    .works-hero__marquee-track {
        height: calc(11px * 1.2);

        align-items: flex-end;

        animation-duration: 50.762s;
    }

    .works-hero__marquee span {
        font-size: var(--font-marquee-mobile);
        line-height: calc(1em + 11px * 0.2);
    }


    /* =========================
       PROJECTS — RHYTHM
    ========================= */

    /*
     * A project no longer fills a screen of its
     * own. It is as tall as its content plus 120px
     * above and 60px below, so projects sit 180px
     * apart. The 60px below the last project keeps
     * the gap before Contact as it was.
     */

    .project {
        min-height: 0;
        padding-bottom: calc(var(--project-rhythm) / 2);
    }

    /*
     * Dom Studio sits 24% of a screen below the
     * Hero, the same proportion as on Tablet.
     */

    .project:first-child {
        padding-top: 24svh;
    }

    /*
     * A card flying out of the stack must not widen
     * the page: on phones any horizontal overflow
     * widens the layout viewport (the same reason
     * Contact clips on Mobile). clip does not create
     * a scroll container.
     */

    .projects {
        overflow-x: clip;
    }


    /* =========================
       PROJECT
    ========================= */

    /*
     * Name/counter row, stack and info share the
     * 20px page margins, and the stack keeps 20px
     * of air above and below it.
     */

    .project__header,
    .project__visual,
    .project__info {
        width: 100%;
    }

    .project {
        --project-frame: var(--space-20);
        --project-cta-gap: var(--space-12);
    }

    /*
     * The description takes the full width and
     * "View project →" closes the block on the
     * right edge, under the counter.
     */

    .project__info {
        flex-direction: column;
        align-items: stretch;
    }

    .project__link {
        align-self: flex-end;
    }


    /* =========================
       TYPOGRAPHY
    ========================= */

    .project__title {
        font-size: 16px;
    }

    .project__counter {
        font-size: var(--font-label-mobile);
    }

    .project__subtitle,
    .project__services,
    .project__link {
        font-size: 16px;
    }
}
