/*
 * Service pages redesigned under the Servicios direction (OD-104; docs/m14/SERVICE-EVENT-CREATION.md) — the rules of
 * templates/site/service_area.twig, loaded only by it after base.css and site.css, in the `pages` layer. Each area keeps its
 * module colour of the Servicios dial (`p-area--N`); the scene's layers keep fixed colours (they live on the night and purple
 * bands, in both themes); everything else uses the design-system tokens. Complete without JavaScript, WebGL or motion (each
 * 3D block keeps its still drawing) and nothing is laid over informative text (OD-103a).
 */
@layer pages {
    .p-area {
        --sv-1: #effcff;
        --sv-2: #5ce1ff;
        --sv-3: #8c6bc2;
        --sv-4: #ffb547;
        --sv-5: #0091b3;
        --sv-6: #bfacdd;
        --sv-7: #f2c66b;
        --sv-spectrum: linear-gradient(90deg, var(--sv-1) 0 14.28%, var(--sv-2) 0 28.57%, var(--sv-3) 0 42.85%, var(--sv-4) 0 57.14%, var(--sv-5) 0 71.42%, var(--sv-6) 0 85.71%, var(--sv-7) 0);
        --area: var(--sv-2);
    }

    .p-area--1 { --area: var(--sv-1); }
    .p-area--2 { --area: var(--sv-2); }
    .p-area--3 { --area: var(--sv-3); }
    .p-area--4 { --area: var(--sv-4); }
    .p-area--5 { --area: var(--sv-5); }
    .p-area--6 { --area: var(--sv-6); }
    .p-area--7 { --area: var(--sv-7); }

    /* ---- The scene (both blocks): the still drawing under the canvas, in a viewfinder; the 3D replaces it once it runs. */
    .c-ar-art {
        position: relative;
        isolation: isolate;
        inline-size: 100%;
        aspect-ratio: 3 / 2;
        pointer-events: none;
    }

    .c-ar-art::before {
        content: "";
        position: absolute;
        z-index: -1;
        inset: 0;
        --corner: linear-gradient(var(--color-link), var(--color-link));
        background:
            var(--corner) left top / 1.5rem 2px no-repeat,
            var(--corner) left top / 2px 1.5rem no-repeat,
            var(--corner) right top / 1.5rem 2px no-repeat,
            var(--corner) right top / 2px 1.5rem no-repeat,
            var(--corner) left bottom / 1.5rem 2px no-repeat,
            var(--corner) left bottom / 2px 1.5rem no-repeat,
            var(--corner) right bottom / 1.5rem 2px no-repeat,
            var(--corner) right bottom / 2px 1.5rem no-repeat;
        opacity: 0.55;
    }

    .c-ar-art::after {
        content: "";
        position: absolute;
        z-index: -2;
        inset: 10%;
        border-radius: 50%;
        background: radial-gradient(closest-side, rgb(0 145 179 / 0.3), rgb(0 145 179 / 0));
    }

    .c-ar-still,
    .c-ar-canvas {
        position: absolute;
        inset: 0;
        inline-size: 100%;
        block-size: 100%;
    }

    .c-ar-still {
        transition: opacity var(--dur-slow) var(--ease-standard);
    }

    .c-ar-hero.is-3d .c-ar-still,
    .c-ar-scope.is-3d .c-ar-still {
        opacity: 0;
    }

    /* ---- Opening band: the breadcrumb, the module number, the name and its promise beside the scene; the area's colour along
       its foot, inside the seven modules' spectrum. */
    .c-ar-hero {
        --band-space: var(--rhythm-m);
        background:
            radial-gradient(55% 75% at 78% 50%, rgb(0 145 179 / 0.28), rgb(0 145 179 / 0) 70%),
            radial-gradient(45% 60% at 0% 100%, rgb(140 107 194 / 0.3), rgb(140 107 194 / 0) 70%),
            var(--color-bg);
    }

    .c-ar-hero::after {
        content: none;
    }

    .c-ar-hero::before {
        content: "";
        position: absolute;
        inset-inline: 0;
        inset-block-end: 0;
        block-size: 0.25rem;
        background: var(--sv-spectrum);
    }

    .c-ar-hero__grid {
        display: grid;
        gap: var(--space-l) var(--grid-gap);
        align-items: center;
    }

    /* Long single words (CRONOMETRAJE, PROMOCIONALES) never break inside: the size follows the column, not the other way. */
    .c-ar-hero h1 {
        max-inline-size: none;
        font-size: clamp(1.75rem, 1.36rem + 2.59vw, 4rem); /* 30 px at 320, 59 px at 1440: PROMOCIONALES fits its column at every width */
        overflow-wrap: normal;
        word-break: normal;
        hyphens: manual;
    }

    .c-ar-hero .c-page-hero__eyebrow {
        display: inline-flex;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--space-2xs) var(--space-s);
        justify-self: start;
    }

    .c-ar-hero__module {
        padding: 0.15em 0.6em;
        border: var(--border-hairline) solid var(--area);
        border-radius: var(--radius-s);
        color: var(--area);
        font-family: var(--font-display);
        font-variant-numeric: tabular-nums lining-nums;
    }

    .c-ar-hero .c-page-hero__lead {
        color: var(--color-text);
    }

    /* The caption under the scene names the symbol in front (only while the 3D runs; the list below says it for everyone). */
    .c-ar-caption {
        display: none;
        min-block-size: 1.5em;
        margin: var(--space-s) 0 0;
        font-family: var(--font-display);
        font-size: var(--text-l);
        font-weight: var(--weight-semibold);
        text-align: center;
        color: var(--color-text);
    }

    .c-ar-hero.is-3d .c-ar-caption {
        display: block;
    }

    .c-ar-hero.is-3d .c-ar-caption:empty {
        display: none; /* a scene that shows the service's own symbol names nothing */
    }

    @media (min-width: 64rem) {
        .c-ar-hero__grid {
            grid-template-columns: minmax(0, 6fr) minmax(0, 6fr);
        }
    }

    /* ---- Introduction: the words beside the photograph in its viewfinder. */
    .c-ar-intro__grid {
        display: grid;
        gap: var(--space-xl) var(--grid-gap);
        align-items: center;
    }

    .c-ar-frame {
        position: relative;
    }

    .c-ar-frame::after {
        content: "";
        position: absolute;
        inset: calc(-1 * var(--space-2xs));
        --corner: linear-gradient(var(--color-signal), var(--color-signal));
        background:
            var(--corner) left top / 2rem 3px no-repeat,
            var(--corner) left top / 3px 2rem no-repeat,
            var(--corner) right bottom / 2rem 3px no-repeat,
            var(--corner) right bottom / 3px 2rem no-repeat;
        pointer-events: none;
    }

    /* An area without a photograph shows its own drawn cover (never another area's picture). */
    .c-ar-cover {
        aspect-ratio: 3 / 2;
        border-radius: var(--radius-m);
        background:
            linear-gradient(rgb(191 172 221 / 0.12) 1px, transparent 1px) 0 0 / 1.5rem 1.5rem,
            linear-gradient(90deg, rgb(191 172 221 / 0.12) 1px, transparent 1px) 0 0 / 1.5rem 1.5rem,
            radial-gradient(closest-side, rgb(140 107 194 / 0.45), rgb(140 107 194 / 0)),
            var(--brand-purple);
    }

    .c-ar-cover .c-mk {
        display: block;
        inline-size: 100%;
        block-size: 100%;
    }

    /* The cover in 3D (OD-106a): the drawing stays underneath as the still form and gives way once the scene runs. */
    .c-ar-cover .c-mk {
        transition: opacity var(--dur-slow) var(--ease-standard);
    }

    .c-ar-cover-box.is-3d .c-mk {
        opacity: 0;
    }

    @media (min-width: 64rem) {
        .c-ar-intro__grid {
            grid-template-columns: minmax(0, 6fr) minmax(0, 6fr);
        }
    }

    /* ---- What the area includes: the night band; the scene beside the items. Desktop: the scene sticky in its own column;
       phones and tablets: above the list, not sticky — no item ever passes under it. Each item a numbered layer in the
       colour of its part of the scene; the one pointed at or read leads. */
    .c-ar-scope {
        --color-bg: #0c0712;
        --color-focus-gap: #0c0712;
        background:
            radial-gradient(50% 40% at 15% 30%, rgb(45 29 71 / 0.95), rgb(45 29 71 / 0) 75%),
            radial-gradient(40% 35% at 100% 100%, rgb(0 145 179 / 0.18), rgb(0 145 179 / 0) 70%),
            var(--color-bg);
    }

    .c-ar-scope__grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: var(--space-l);
    }

    .c-ar-scope__title {
        order: -2;
    }

    .c-ar-scope__stage {
        order: -1; /* after the words in the document, before them on screen */
    }

    .c-ar-scope__body {
        display: grid;
        gap: var(--space-m);
    }

    .c-ar-scope__body > * {
        margin: 0;
    }

    .c-ar-readout {
        position: absolute;
        inset-block-start: var(--space-s);
        inset-inline-start: var(--space-s);
        display: none;
        align-items: baseline;
        gap: var(--space-3xs);
        margin: 0;
        font-family: var(--font-display);
        font-weight: var(--weight-bold);
        line-height: 1;
        color: var(--layer-lead, var(--color-link));
        font-variant-numeric: tabular-nums lining-nums;
    }

    .c-ar-readout [data-area-readout] {
        font-size: var(--text-3xl);
    }

    .c-ar-readout__total {
        font-size: var(--text-s);
        letter-spacing: var(--tracking-label);
        color: var(--color-muted);
    }

    .c-ar-scope.is-3d.has-active .c-ar-readout {
        display: flex;
    }

    /* A wall of tiles shows every number on its tiles: no counter over them (OD-109). */
    .c-ar-scope.is-3d.has-active[data-scene*="/tiles."] .c-ar-readout {
        display: none;
    }

    .c-ar-scope__list {
        counter-reset: ar-layer;
        gap: var(--space-xs);
        border: 0;
    }

    .c-ar-scope__list .c-scope__item {
        --layer: var(--sv-2);
        counter-increment: ar-layer;
        position: relative;
        isolation: isolate;
        align-items: center;
        gap: var(--space-m);
        padding: var(--space-s) var(--space-m);
        overflow: hidden;
        border: var(--border-hairline) solid var(--color-border);
        border-radius: var(--radius-m);
        background: linear-gradient(135deg, rgb(241 237 248 / 0.06), rgb(241 237 248 / 0.015));
        font-size: var(--text-m);
        transition:
            transform var(--dur-moderate) var(--ease-standard),
            border-color var(--dur-fast) var(--ease-standard);
    }

    /* Its universal symbol, in its colour (the same the scene acts out). */
    .c-ar-scope__icon {
        flex: none;
        box-sizing: content-box;
        inline-size: 1.5rem;
        block-size: 1.5rem;
        padding: 0.45rem;
        border-radius: 50%;
        background: color-mix(in srgb, var(--layer) 18%, transparent);
        color: var(--layer);
    }

    /* The layer's number in its colour, and its rail (the base rule's dash becomes the number). */
    .c-ar-scope__list .c-scope__item::before {
        content: counter(ar-layer, decimal-leading-zero);
        content: counter(ar-layer, decimal-leading-zero) / "";
        inline-size: auto;
        block-size: auto;
        background: none;
        color: var(--layer);
        font-family: var(--font-display);
        font-size: var(--text-l);
        font-weight: var(--weight-bold);
        font-variant-numeric: tabular-nums lining-nums;
        transform: none;
    }

    .c-ar-scope__list .c-scope__item::after {
        content: "";
        position: absolute;
        z-index: -1;
        inset: 0;
        border-inline-start: 0.25rem solid var(--layer);
        background: radial-gradient(70% 160% at 0% 50%, color-mix(in srgb, var(--layer) 20%, transparent), transparent 70%);
        opacity: 0.35;
        transition: opacity var(--dur-moderate) var(--ease-standard);
    }

    /* The eight colours of the symbols, in turn (lists of 11 and 15 items start again at the ninth). */
    .c-ar-scope__list .c-scope__item:nth-child(8n + 1) { --layer: #effcff; }
    .c-ar-scope__list .c-scope__item:nth-child(8n + 2) { --layer: #ffb547; }
    .c-ar-scope__list .c-scope__item:nth-child(8n + 3) { --layer: #5ce1ff; }
    .c-ar-scope__list .c-scope__item:nth-child(8n + 4) { --layer: #bfacdd; }
    .c-ar-scope__list .c-scope__item:nth-child(8n + 5) { --layer: #f2c66b; }
    .c-ar-scope__list .c-scope__item:nth-child(8n + 6) { --layer: #0091b3; }
    .c-ar-scope__list .c-scope__item:nth-child(8n + 7) { --layer: #8c6bc2; }
    .c-ar-scope__list .c-scope__item:nth-child(8n + 8) { --layer: #b8f2ff; }

    .c-ar-scope__list .c-scope__item.is-active,
    .c-ar-scope__list .c-scope__item:hover {
        border-color: var(--layer);
    }

    .c-ar-scope__list .c-scope__item.is-active::after,
    .c-ar-scope__list .c-scope__item:hover::after {
        opacity: 1;
    }

    .c-ar-scope:has(.c-scope__item:nth-child(8n + 1).is-active) { --layer-lead: #effcff; }
    .c-ar-scope:has(.c-scope__item:nth-child(8n + 2).is-active) { --layer-lead: #ffb547; }
    .c-ar-scope:has(.c-scope__item:nth-child(8n + 3).is-active) { --layer-lead: #5ce1ff; }
    .c-ar-scope:has(.c-scope__item:nth-child(8n + 4).is-active) { --layer-lead: #bfacdd; }
    .c-ar-scope:has(.c-scope__item:nth-child(8n + 5).is-active) { --layer-lead: #f2c66b; }
    .c-ar-scope:has(.c-scope__item:nth-child(8n + 6).is-active) { --layer-lead: #0091b3; }
    .c-ar-scope:has(.c-scope__item:nth-child(8n + 7).is-active) { --layer-lead: #8c6bc2; }
    .c-ar-scope:has(.c-scope__item:nth-child(8n + 8).is-active) { --layer-lead: #b8f2ff; }

    @media (min-width: 64rem) {
        .c-ar-scope__grid {
            grid-template-columns: minmax(0, 6fr) minmax(0, 6fr);
            column-gap: var(--space-2xl);
            align-items: start;
        }

        .c-ar-scope__title {
            grid-column: 1 / -1;
        }

        .c-ar-scope__stage {
            position: sticky;
            inset-block-start: calc(var(--header-h) + var(--space-l));
            grid-column: 1;
            grid-row: 2;
        }

        .c-ar-scope__body {
            grid-column: 2;
            grid-row: 2;
        }

        .c-ar-scope__list .c-scope__item.is-active {
            transform: translate3d(-0.5rem, 0, 0);
        }
    }

    /* ---- The closing line, as a statement between two rules of the spectrum. */
    .c-ar-closing {
        --band-space: var(--rhythm-m);
        text-align: center;
    }

    .c-ar-closing .c-company__closing {
        position: relative;
        max-inline-size: 26ch;
        margin: 0 auto;
        padding: var(--space-l) 0;
        border: 0;
        font-size: var(--text-3xl);
        line-height: var(--leading-heading);
    }

    .c-ar-closing .c-company__closing::before,
    .c-ar-closing .c-company__closing::after {
        content: "";
        position: absolute;
        inset-inline: 30%;
        block-size: 0.25rem;
        background: var(--sv-spectrum);
    }

    .c-ar-closing .c-company__closing::before {
        inset-block-start: 0;
    }

    .c-ar-closing .c-company__closing::after {
        inset-block-end: 0;
    }

    /* ---- The call to action: the night panel (as on Servicios), the area's drawing in its own column. */
    .p-area .c-cta__inner {
        --color-bg: #0c0712;
        --color-text: #f1edf8;
        --color-muted: #bfacdd;
        --color-border: #4a2f74;
        --color-link: #5ce1ff;
        --color-link-hover: #b8f2ff;
        --color-focus: #5ce1ff;
        --color-focus-gap: #0c0712;
        --color-signal: #00abd1;
        --color-primary: #5ce1ff;
        --color-primary-hover: #8ae9ff;
        --color-on-primary: #0c0712;
        position: relative;
        isolation: isolate;
        grid-template-areas: "art" "text" "actions";
        overflow: hidden;
        padding: var(--space-xl) var(--space-m) var(--space-l);
        border-radius: var(--radius-m);
        background:
            radial-gradient(55% 90% at 88% 45%, rgb(0 145 179 / 0.32), rgb(0 145 179 / 0) 70%),
            radial-gradient(50% 80% at 0% 100%, rgb(140 107 194 / 0.35), rgb(140 107 194 / 0) 70%),
            var(--color-bg);
        box-shadow: 0 2.5rem 4rem -3rem rgb(12 7 18 / 0.75);
        color: var(--color-text);
        color-scheme: dark;
    }

    .p-area .c-cta__inner::before {
        content: "";
        position: absolute;
        inset-inline: 0;
        inset-block-start: 0;
        block-size: 0.25rem;
        background: var(--sv-spectrum);
    }

    .p-area .c-cta__text {
        grid-area: text;
    }

    .p-area .c-cta__title {
        font-size: var(--text-3xl);
        line-height: var(--leading-display);
    }

    .p-area .c-cta__lead {
        color: var(--color-muted);
    }

    .p-area .c-cta__actions {
        grid-area: actions;
    }

    .p-area .c-cta__secondary {
        color: var(--color-link);
    }

    .p-area .c-cta__art {
        grid-area: art;
        justify-self: center;
        inline-size: min(100%, 18rem);
    }

    .c-ar-cta__drawing {
        display: block;
        inline-size: 100%;
        block-size: auto;
    }

    @media (min-width: 64rem) {
        .p-area .c-cta__inner {
            grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
            grid-template-areas: "text art" "actions art";
            align-items: center;
            column-gap: var(--space-2xl);
            padding: var(--space-2xl);
        }

        .p-area .c-cta__actions {
            align-self: start;
        }

        .p-area .c-cta__art {
            justify-self: end;
            inline-size: min(100%, 24rem);
        }
    }

    /* ---- The other areas: chips with their module's colour. */
    .c-ar-others [data-module] .c-other-services__link {
        gap: var(--space-2xs);
    }

    .c-ar-others [data-module] .c-other-services__link::before {
        content: "";
        inline-size: 0.625rem;
        aspect-ratio: 1;
        border: var(--border-hairline) solid var(--color-border-strong);
        border-radius: 50%;
        background: var(--m);
    }

    .c-ar-others [data-module="1"] { --m: var(--sv-1); }
    .c-ar-others [data-module="2"] { --m: var(--sv-2); }
    .c-ar-others [data-module="3"] { --m: var(--sv-3); }
    .c-ar-others [data-module="4"] { --m: var(--sv-4); }
    .c-ar-others [data-module="5"] { --m: var(--sv-5); }
    .c-ar-others [data-module="6"] { --m: var(--sv-6); }
    .c-ar-others [data-module="7"] { --m: var(--sv-7); }

    /* ---- Motion: the opening words rise once; the items and the statement arrive when revealed. ---- */
    @media (prefers-reduced-motion: no-preference) {
        .c-ar-hero__inner > * {
            animation: c-hero-rise var(--dur-slow) var(--ease-enter) backwards;
        }

        .c-ar-hero__inner > h1 {
            animation-delay: var(--stagger);
        }

        .c-ar-hero__inner > .c-page-hero__lead {
            animation-delay: calc(var(--stagger) * 3);
        }

        .js-motion .c-ar-scope__list.is-revealed .c-scope__item {
            animation: c-hero-rise var(--dur-slow) var(--ease-enter) backwards;
            animation-delay: calc(var(--stagger) * var(--n, 0));
        }

        .js-motion .c-ar-closing .c-company__closing.is-revealed::before,
        .js-motion .c-ar-closing .c-company__closing.is-revealed::after {
            animation: c-ar-draw calc(var(--dur-cinematic) * 1.2) var(--ease-enter) backwards;
        }

        .js-motion .p-area .c-cta__art.is-revealed .c-ar-cta__drawing {
            animation: c-ar-rise calc(var(--dur-cinematic) * 1.4) var(--ease-enter) backwards;
        }

        /* With motion allowed the 3D usually takes over within a second: the still drawing waits that long before it shows,
           so the symbols rising are never preceded by the finished drawing (it shows anyway if the 3D never starts). */
        .c-ar-still {
            animation: c-ar-wait var(--dur-slow) var(--ease-enter) backwards;
            animation-delay: calc(var(--dur-cinematic) * 1.5);
        }

        .c-ar-hero.is-3d .c-ar-still,
        .c-ar-scope.is-3d .c-ar-still {
            animation-name: none;
        }
    }

    .c-ar-scope__list .c-scope__item:nth-child(2) { --n: 1; }
    .c-ar-scope__list .c-scope__item:nth-child(3) { --n: 2; }
    .c-ar-scope__list .c-scope__item:nth-child(4) { --n: 3; }
    .c-ar-scope__list .c-scope__item:nth-child(5) { --n: 4; }
    .c-ar-scope__list .c-scope__item:nth-child(n + 6) { --n: 5; }

    @keyframes c-ar-wait {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }

    @keyframes c-ar-draw {
        from {
            transform: scaleX(0);
        }

        to {
            transform: none;
        }
    }

    @keyframes c-ar-rise {
        from {
            opacity: 0;
            transform: translate3d(0, 1rem, 0) scale(0.92);
        }

        to {
            opacity: 1;
            transform: none;
        }
    }

    @media (forced-colors: active) {
        .c-ar-art::before,
        .c-ar-art::after,
        .c-ar-hero::before,
        .c-ar-frame::after,
        .p-area .c-cta__inner::before,
        .c-ar-scope__list .c-scope__item::after,
        .c-ar-closing .c-company__closing::before,
        .c-ar-closing .c-company__closing::after {
            display: none;
        }
    }

    @media print {
        .c-ar-canvas {
            display: none;
        }

        .c-ar-still {
            opacity: 1;
        }
    }
}
