/*
 * Home — the page's own rules (OD-128d, 2026-11-23), loaded only by the Home (/ and /en) after base.css and site.css, in the same
 * cascade layer (`pages`). Section 02 «Organiza con nosotros» (docs/m14/HOME-SECTION-02.md): the course of the seven services
 * from the idea to the finish, and its 3D stage (home3d/circuit.js). Moved out of site.css, whose shared budget was spent; its
 * scroll-driven animations stay in site.css's one guarded block (MotionSafetyTest). Complete without JavaScript, WebGL or motion.
 */
@layer pages {
    /* ---- 3 · The integral service — «Circuito» (Home section 02; OD-84, OD-91, OD-114, OD-128d) --------------------------- */
    /* The service as a course: from the start (the idea) to the finish (the goal), the services as checkpoints. */
    .c-home-services.l-band--ink {
        --color-bg: #0c0712;
        --color-focus-gap: #0c0712;
        --color-muted: #c9c4d3;
        --route-node: 3rem;
        --route-gap: 4rem;
        background:
            radial-gradient(70% 45% at 0% 0%, rgb(45 29 71 / 0.9), rgb(45 29 71 / 0) 70%),
            radial-gradient(55% 40% at 100% 100%, rgb(0 145 179 / 0.2), rgb(0 145 179 / 0) 70%),
            #0c0712;
    }

    .c-home-services__grid {
        display: grid;
        gap: var(--space-l);
    }

    /* The 3D track (shown only while it runs). Phones and tablets: between the heading and the route, in the flow — nothing
       passes under it (OD-112), tall enough for the track to read; desktop: under the heading, in view the whole way down. */
    .c-home-services__aside {
        display: contents;
    }

    .c-circuit {
        position: relative;
        block-size: min(66svh, 116vw, 40rem);
        margin-inline: calc(var(--gutter) * -1);
        background: radial-gradient(80% 60% at 50% 50%, rgb(45 29 71 / 0.5), rgb(12 7 18 / 0) 72%);
    }

    .c-circuit__canvas {
        display: block;
        inline-size: 100%;
        block-size: 100%;
    }

    .c-route,
    .c-route__course {
        position: relative;
    }

    /* The line, from the start's centre to the finish's; the runner rides its tip with the scroll (site.css, guarded). */
    .c-route__line,
    .c-route__runner {
        position: absolute;
        inset-block: calc(var(--route-node) / 2);
        inset-inline-start: calc(var(--route-node) / 2 - 2px);
        inline-size: 4px;
        pointer-events: none;
    }

    .c-route__line {
        block-size: calc(100% - var(--route-node));
        overflow: visible;
        fill: none;
        stroke-width: 3;
        vector-effect: non-scaling-stroke;
    }

    .c-route__track {
        stroke: rgb(255 255 255 / 0.14);
    }

    .c-route__trace {
        stroke: url("#route-trace");
        stroke-dasharray: 1;
        stroke-dashoffset: 0;
    }

    .c-route__runner {
        z-index: 1;
        opacity: 0;
    }

    .c-route__runner::before {
        content: "";
        position: absolute;
        inset: -0.5rem auto auto -0.375rem;
        inline-size: 1rem;
        block-size: 1rem;
        border-radius: 50%;
        background: radial-gradient(#ffffff 0 24%, #5ce1ff 42%, rgb(92 225 255 / 0) 72%);
        box-shadow: 0 0 1.25rem 0.25rem rgb(92 225 255 / 0.5);
    }

    /* The start and the finish; each sends a ring of light when the course reaches it. */
    .c-route__end {
        position: relative;
        display: grid;
        place-items: center;
        inline-size: var(--route-node);
        block-size: var(--route-node);
        border: 2px solid #5ce1ff;
        border-radius: 50%;
        background: #0c0712;
        color: #5ce1ff;
    }

    .c-route__end .c-icon {
        --icon-size: 1.375rem;
    }

    .c-route__end--finish {
        border-color: #ffb547;
        background: #ffb547;
        color: #0c0712;
        box-shadow: 0 0 0 0.5rem rgb(255 181 71 / 0.15);
    }

    .c-route__end::after,
    .c-route__pin::after {
        content: "";
        position: absolute;
        inset: -3px;
        border: inherit;
        border-radius: 50%;
        opacity: 0;
        pointer-events: none;
    }

    .c-route__list {
        display: grid;
        gap: var(--space-s);
        margin: var(--space-m) 0 var(--space-m) var(--route-gap);
        padding: 0;
        list-style: none;
    }

    /* A checkpoint. */
    .c-route__stop {
        position: relative;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-areas: "icon title" "icon text";
        column-gap: var(--space-m);
        row-gap: var(--space-2xs);
        align-items: start;
        padding: var(--space-s) var(--space-l) var(--space-s) var(--space-s);
        border: var(--border-hairline) solid rgb(255 255 255 / 0.1);
        border-radius: var(--radius-m);
        background: linear-gradient(135deg, rgb(255 255 255 / 0.06), rgb(255 255 255 / 0.015));
        transition:
            border-color var(--dur-fast) var(--ease-standard),
            background-color var(--dur-fast) var(--ease-standard);
    }

    .c-route__stop > * {
        margin: 0;
    }

    /* Its pin on the line: a turquoise ring whose core lights, with a ping, at the screen's middle. */
    .c-route__pin {
        position: absolute;
        inset-block-start: calc(var(--space-s) + 0.9rem);
        inset-inline-start: calc((var(--route-gap) - var(--route-node) / 2) * -1 - 0.625rem);
        inline-size: 1.25rem;
        block-size: 1.25rem;
        border: 3px solid #5ce1ff;
        border-radius: 50%;
        background: #0c0712;
    }

    .c-route__pin::before {
        content: "";
        position: absolute;
        inset: 2px;
        border-radius: 50%;
        background: #b8f2ff;
        box-shadow: 0 0 0.75rem 0.2rem rgb(92 225 255 / 0.7);
        opacity: 0;
    }

    /* Its light (scroll timeline, `.js-motion`): the card and the frame of its icon. */
    .c-route__stop::after,
    .c-route__icon::after {
        content: "";
        position: absolute;
        z-index: -1;
        inset: calc(var(--border-hairline) * -1);
        border: var(--border-hairline) solid rgb(92 225 255 / 0.6);
        border-radius: var(--radius-m);
        opacity: 0;
        pointer-events: none;
    }

    .c-route__stop::after {
        border-inline-start: 3px solid #5ce1ff;
        background: linear-gradient(90deg, rgb(0 171 209 / 0.18), rgb(0 171 209 / 0) 70%);
    }

    .c-route__icon::after {
        inset: -3px;
        border: 2px solid #5ce1ff;
        box-shadow: 0 0 1rem rgb(92 225 255 / 0.45), inset 0 0 0.75rem rgb(92 225 255 / 0.3);
    }

    .c-route__stop:hover,
    .c-route__stop:focus-within {
        border-color: rgb(92 225 255 / 0.7);
    }

    /* The card whose piece the 3D track is showing (circuit.js): the amber of the piece being built. */
    .is-3d .c-route__stop.is-current {
        border-color: rgb(255 181 71 / 0.9);
    }

    .c-route__icon {
        position: relative;
        isolation: isolate;
        grid-area: icon;
        display: grid;
        place-items: center;
        inline-size: 3rem;
        block-size: 3rem;
        border-radius: var(--radius-m);
        background: rgb(0 171 209 / 0.16);
        color: #5ce1ff;
        transition: color var(--dur-fast) var(--ease-standard);
    }

    .is-3d .is-current .c-route__icon {
        color: #ffb547;
    }

    .c-route__icon .c-icon {
        --icon-size: 1.5rem;
    }

    .c-route__number {
        position: absolute;
        z-index: -1;
        inset-block-start: 50%;
        inset-inline-end: var(--space-s);
        font-family: var(--font-display);
        font-size: 3.75rem;
        font-weight: var(--weight-bold);
        line-height: 1;
        color: rgb(255 255 255 / 0.08);
        transform: translateY(-50%);
        pointer-events: none;
        display: none;
    }

    @supports (-webkit-text-stroke: 1px black) {
        .c-route__number {
            color: transparent;
            -webkit-text-stroke: 1.5px rgb(255 255 255 / 0.14);
        }
    }

    .c-route__title {
        grid-area: title;
        font-family: var(--font-display);
        font-size: var(--text-l);
        letter-spacing: var(--tracking-caps);
        text-transform: uppercase;
    }

    .c-route__title a {
        color: var(--color-text);
        text-decoration: none;
    }

    .c-route__title a::after {
        content: "";
        position: absolute;
        inset: 0;
    }

    .c-route__stop:hover .c-route__title a {
        color: #b8f2ff;
        text-decoration: underline;
        text-underline-offset: 0.2em;
    }

    .c-route__text {
        grid-area: text;
        max-inline-size: 40rem;
        color: var(--color-muted);
    }

    /* The closing note, then the way to the services. */
    .c-route__note {
        max-inline-size: 40rem;
        margin: var(--space-m) 0 var(--space-m) var(--route-gap);
        padding: var(--space-s) var(--space-m);
        border-inline-start: 3px solid #ffb547;
        background: rgb(255 181 71 / 0.06);
        color: var(--color-muted);
    }

    .c-route__note + p {
        margin-inline-start: var(--route-gap);
    }

    /* Phones: a compact checkpoint. */
    @media (max-width: 48rem) {
        .c-home-services.l-band--ink {
            --route-node: 2.25rem;
            --route-gap: 2.75rem;
        }

        .c-route__stop {
            grid-template-areas: "icon title" "text text";
            align-items: center;
            column-gap: var(--space-s);
            padding: var(--space-s);
        }

        .c-route__icon {
            inline-size: 2.25rem;
            block-size: 2.25rem;
        }

        .c-route__icon .c-icon {
            --icon-size: 1.25rem;
        }

        .c-route__pin {
            inset-block-start: calc(var(--space-s) + 0.5rem);
        }

        .c-route__title {
            font-size: var(--text-m);
        }

        .c-route__end .c-icon {
            --icon-size: 1.125rem;
        }
    }

    /* Phones and tablets tall enough (OD-128h, replacing OD-112 here): the 3D track pins under the header from the first card to
       the end of the course, opaque — the cards slide under it as under the header — and shows the card at the reading line
       under it (--route-eye, the runner's line too; --route-lit, where a card lights: same middle). Its row is reserved as soon
       as the 3D is due (is-3d-soon, site-home-3d.js), so nothing jumps when it starts. Held sideways: in the flow, the tour. */
    @media (max-width: 63.99rem) and (min-height: 34rem) {
        .c-home-services:is(.is-3d, .is-3d-soon) {
            --stage-h: clamp(12rem, 47svh - var(--header-h), 30rem);
            --route-eye: 61% 39%;
            --route-lit: 22% 0px;
        }

        :is(.is-3d, .is-3d-soon) > .c-home-services__grid {
            grid-template-rows: auto var(--stage-h) auto;
        }

        :is(.is-3d, .is-3d-soon) .c-circuit {
            display: block; /* its room, lit, while the scene is on its way */
            grid-area: 2 / 1 / 4; /* over the course's row too: its sticky range ends with the course */
            align-self: start;
            position: sticky;
            inset-block-start: var(--header-h);
            z-index: 2;
            block-size: var(--stage-h);
            background: radial-gradient(80% 70% at 50% 55%, rgb(45 29 71 / 0.6), rgb(12 7 18 / 0) 75%), #0c0712;
            box-shadow: 0 1px 0 rgb(92 225 255 / 0.22), 0 0.75rem 1.5rem -0.75rem rgb(0 0 0 / 0.8);
        }

        :is(.is-3d, .is-3d-soon) .c-route {
            grid-area: 3 / 1;
        }
    }

    /* The number behind a card from 90rem. */
    @media (min-width: 90rem) {
        .c-route__stop {
            padding-inline-end: 7rem;
        }

        .c-route__number {
            display: block;
        }
    }

    @media (min-width: 64rem) {
        .c-home-services__grid {
            grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
            gap: var(--grid-gap);
            align-items: start;
        }

        .c-home-services__aside {
            display: block;
            position: sticky;
            inset-block-start: calc(var(--header-h) + var(--space-l));
        }

        .c-circuit {
            block-size: min(100svh - var(--header-h) - 2 * var(--space-l) - 24rem, 30rem);
            min-block-size: 16rem;
            margin-block-start: calc(var(--space-xl) * -0.5);
            margin-inline: 0;
        }
    }

    @media (forced-colors: active) {
        .c-route__stop::after,
        .c-route__icon::after,
        .c-route__pin::before,
        .c-route__runner,
        .c-route__number {
            display: none;
        }
    }
}
