/* AI Copilot, GET /copilot: the question, the field to ask, and the four
   analyses as pictures. [D78; mock docs/mockups/copilot.html]

     .copilot           the page, a container: a phone's layout below 560
                        pixels of it, the wide one from there
     .copilot-hero      the question and the field, centred
     .copilot-field     the field: a pill from 560 pixels, two lines below,
                        so the examples fit
     .copilot-hint      the example questions over the empty field, which
                        app.js types one after the other (.copilot-hint-line,
                        .copilot-caret); without script the placeholder
                        shows the first
     .copilot-tab       the Tab key, which takes the example shown, beside
                        the arrow while it does (.can-take, app.js)
     .copilot-soon      under the field once a question was sent: nothing
                        answers yet
     .copilot-analyses  the four analyses, two by two on a phone and four in
                        a row from 860 pixels, each a picture with its name
                        and one line under it
     .copilot-picture   a picture: the mesh of its analysis (.is-content,
                        .is-funnel, .is-health, .is-bans), the motif drawn
                        over it in glass (.copilot-motif) and grain

   The pictures are decoration and look the same in both themes, as the
   portraits do: their colours are the --copilot-* tokens, which the dark
   blocks leave out. Their motifs are sized in units of the picture's width
   (cqw), so they scale with it; on a phone, where the picture is square,
   the motif grows into the room. */

.copilot {
    container: copilot / inline-size;
}

/* ------------------------------------------------------------------------
   The question and the field
   ------------------------------------------------------------------------ */

/* The question stands well below the top of the page: a little on a
   phone, and from 560 pixels by the height of the window, so a short
   laptop window keeps the analyses in sight. */
.copilot-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: var(--space-10);
    text-align: center;
}

.copilot-title {
    max-width: 18ch;
    font-size: var(--text-3xl);
    letter-spacing: -0.03em;
    line-height: 1.12;
    text-wrap: balance;
}

.copilot-field {
    display: flex;
    align-items: flex-end;
    gap: var(--space-2);
    width: 100%;
    max-width: 720px;
    margin-top: var(--space-6);
    padding: var(--space-2) var(--space-2) var(--space-2) var(--space-5);
    border: 1px solid var(--color-border);
    border-radius: 28px;
    background: var(--color-surface);
    box-shadow: var(--shadow-ask);
    text-align: left;
    cursor: text;
    transition: border-color var(--duration-fast) var(--ease-in-out),
                box-shadow var(--duration-normal) var(--ease-out);
}

/* A field's border while it is used, calmer than a form field's black:
   the control border, at 3:1 on the surface. */
.copilot-field:focus-within {
    border-color: var(--color-control-border);
    box-shadow: var(--shadow-ask-focus);
}

.copilot-field-text {
    position: relative;
    flex: 1 1 auto;
    align-self: center;
    min-width: 0;
}

/* Two lines on a phone, which the examples need; the field keeps that
   height, so it never jumps as they change. app.js grows it with a longer
   question. */
.copilot-input {
    display: block;
    width: 100%;
    min-height: 3em;
    max-height: 12em;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--color-text);
    font: inherit;
    font-size: var(--text-md);
    line-height: 1.5;
    resize: none;
    outline: none;
}

.copilot-input::placeholder {
    color: var(--color-text-subtle);
    opacity: 1;
}

.copilot-hint {
    position: absolute;
    inset: 0 0 auto;
    height: 3em;
    overflow: hidden;
    color: var(--color-text-subtle);
    font-size: var(--text-md);
    line-height: 1.5;
    pointer-events: none;
}

.copilot-field.has-text .copilot-hint {
    visibility: hidden;
}

.copilot-hint-line {
    position: absolute;
    inset: 0 0 auto;
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

/* A question read leaves upwards, a little blurred, as the next one is
   typed. With reduced motion it goes at once (base.css). */
.copilot-hint-line.is-out {
    animation: copilot-hint-out 520ms var(--ease-out) both;
}

@keyframes copilot-hint-out {
    to {
        opacity: 0;
        filter: blur(4px);
        transform: translateY(-0.7em);
    }
}

/* The caret after the letters typed, gone while the field has the
   browser's own. */
.copilot-caret {
    display: inline-block;
    width: 1.5px;
    height: 1.15em;
    margin-left: 1px;
    background: currentColor;
    vertical-align: -0.2em;
    animation: copilot-blink 1.05s steps(1) infinite;
}

.copilot-field:focus-within .copilot-caret {
    display: none;
}

@keyframes copilot-blink {
    50% {
        opacity: 0;
    }
}

/* The Tab key, where there is a keyboard, while Tab takes the example:
   after a click or a key in the empty field (app.js). */
.copilot-tab {
    display: none;
    flex: none;
    align-self: center;
    padding: 2px 7px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text-subtle);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    line-height: 1.5;
}

@media (hover: hover) and (pointer: fine) {
    .copilot-field.can-take:not(.has-text) .copilot-tab:not([hidden]) {
        display: block;
    }
}

.copilot-send {
    display: grid;
    flex: none;
    place-items: center;
    width: var(--control-height);
    height: var(--control-height);
    padding: 0;
    border: 0;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    color: var(--color-on-primary);
    cursor: pointer;
    transition: background-color var(--duration-fast) var(--ease-in-out),
                transform var(--duration-fast) var(--ease-in-out);
}

.copilot-send .icon {
    stroke-width: 2.25;
}

@media (hover: hover) {
    .copilot-send:hover {
        background: var(--color-primary-hover);
    }
}

.copilot-send:active {
    transform: scale(0.94);
}

.copilot-send:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

.copilot-soon {
    max-width: 44ch;
    margin-top: var(--space-3);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    text-wrap: balance;
}

/* From the width of a tablet: one line, the field a pill. */
@container copilot (min-width: 560px) {
    .copilot-hero {
        padding-top: clamp(var(--space-16), 12vh, calc(2 * var(--space-16)));
    }

    .copilot-title {
        max-width: none;
        font-size: 2.25rem;
    }

    .copilot-field {
        margin-top: var(--space-8);
        padding: 9px 9px 9px 26px;
        border-radius: var(--radius-full);
    }

    .copilot-input {
        min-height: 1.5em;
    }

    .copilot-hint {
        height: 1.5em;
    }

    .copilot-hint-line {
        display: block;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* ------------------------------------------------------------------------
   The four analyses
   ------------------------------------------------------------------------ */

.copilot-section {
    margin-top: var(--space-10);
}

.copilot-section-title {
    margin-bottom: var(--space-3);
    font-size: var(--text-lg);
    letter-spacing: -0.015em;
}

@container copilot (min-width: 560px) {
    .copilot-section {
        margin-top: var(--space-16);
    }

    .copilot-section-title {
        margin-bottom: var(--space-4);
    }
}

.copilot-analyses {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-5) var(--space-3);
    list-style: none;
}

@container copilot (min-width: 860px) {
    .copilot-analyses {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: var(--space-4);
    }
}

.copilot-analysis {
    display: flex;
    flex-direction: column;
    color: inherit;
    text-decoration: none;
}

.copilot-analysis-name {
    margin-top: var(--space-3);
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    line-height: 1.3;
}

.copilot-analysis-line {
    margin-top: 2px;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    line-height: 1.4;
}

.copilot-analysis:focus-visible {
    outline: none;
}

.copilot-analysis:focus-visible .copilot-picture {
    outline: 2px solid var(--color-focus);
    outline-offset: 3px;
}

/* A picture: square on a phone, 4 by 3 from 560 pixels. */
.copilot-picture {
    position: relative;
    display: block;
    aspect-ratio: 1;
    max-width: 100%;
    overflow: hidden;
    border-radius: var(--radius-md);
    container-type: inline-size;
    isolation: isolate;
}

@container copilot (min-width: 560px) {
    .copilot-picture {
        aspect-ratio: 4 / 3;
    }
}

.copilot-motif {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    scale: 1.22;
    transition: transform 420ms var(--ease-out);
}

@container copilot (min-width: 560px) {
    .copilot-motif {
        scale: none;
    }
}

@media (hover: hover) {
    .copilot-analysis:hover .copilot-motif {
        transform: scale(1.045);
    }
}

/* Grain over all of it, as on the sign in panel: it kills the banding of a
   soft gradient and gives the picture its texture. A noise filter in grey,
   as a data URI, which the content security policy allows for images. */
.copilot-grain {
    position: absolute;
    inset: 0;
    z-index: 2;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: var(--copilot-grain-opacity);
    mix-blend-mode: overlay;
    pointer-events: none;
}

/* The meshes: a dark ground and the glows of one colour each. */
.copilot-picture.is-content {
    background:
        radial-gradient(75% 65% at 0% 108%, var(--copilot-content-1), transparent 72%),
        radial-gradient(65% 75% at 108% 108%, var(--copilot-content-2), transparent 70%),
        radial-gradient(55% 60% at 104% 36%, var(--copilot-content-3), transparent 72%),
        var(--copilot-content-base);
}

.copilot-picture.is-funnel {
    background:
        radial-gradient(80% 70% at 100% 106%, var(--copilot-funnel-1), transparent 72%),
        radial-gradient(50% 42% at 76% 112%, var(--copilot-funnel-2), transparent 70%),
        radial-gradient(70% 60% at -6% -6%, var(--copilot-funnel-3), transparent 70%),
        var(--copilot-funnel-base);
}

/* A bright arc from the top across to the bottom right, dark below it. */
.copilot-picture.is-health {
    background:
        radial-gradient(150% 120% at -8% 118%, transparent 44%, var(--copilot-health-2) 58%, var(--copilot-health-1) 66%, transparent 80%),
        radial-gradient(70% 70% at -4% -10%, var(--copilot-health-3), transparent 70%),
        var(--copilot-health-base);
}

.copilot-picture.is-bans {
    background:
        radial-gradient(75% 70% at -4% 108%, var(--copilot-bans-1), transparent 72%),
        radial-gradient(60% 55% at 104% 112%, var(--copilot-bans-2), transparent 70%),
        radial-gradient(60% 55% at 100% -6%, var(--copilot-bans-3), transparent 72%),
        var(--copilot-bans-base);
}

/* Frosted glass, what the motifs are made of. */
.copilot-reel,
.copilot-step,
.copilot-phone {
    border: 1px solid var(--copilot-glass-rim);
    background: var(--copilot-glass);
    box-shadow: var(--copilot-glass-shadow), inset 0 1px 0 var(--copilot-glass-shine);
    -webkit-backdrop-filter: blur(10px) saturate(150%);
    backdrop-filter: blur(10px) saturate(150%);
}

/* Content analysis: three reels with a person in each. */
.copilot-reel {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 27cqw;
    aspect-ratio: 9 / 16;
    overflow: hidden;
    border-radius: 3cqw;
}

.copilot-reel.is-left {
    opacity: 0.7;
    transform: translate(-50%, -50%) translateX(-21cqw) translateY(2cqw) rotate(-9deg) scale(0.88);
}

.copilot-reel.is-right {
    opacity: 0.7;
    transform: translate(-50%, -50%) translateX(21cqw) translateY(2cqw) rotate(9deg) scale(0.88);
}

.copilot-reel.is-front {
    z-index: 1;
    background: var(--copilot-glass-front);
    transform: translate(-50%, -50%);
}

.copilot-figure {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 92%;
    fill: var(--copilot-figure);
}

.copilot-reel.is-front .copilot-figure {
    fill: var(--copilot-figure-front);
}

/* Funnel analysis: plays, visits, clicks and subscribers, narrowing to
   the right. */
.copilot-funnel {
    display: flex;
    align-items: center;
    gap: 3cqw;
}

.copilot-step {
    width: 7cqw;
    height: 54cqw;
    border-radius: var(--radius-full);
}

.copilot-step:nth-child(2) {
    height: 40cqw;
}

.copilot-step:nth-child(3) {
    height: 26cqw;
}

.copilot-step:nth-child(4) {
    height: 12cqw;
    border-color: transparent;
    background: var(--copilot-ink);
    box-shadow: 0 0 18px var(--copilot-glow), var(--copilot-glass-shadow);
}

/* Account health: a steady pulse, fading in from the left. */
.copilot-pulse {
    width: 80cqw;
    overflow: visible;
    filter: drop-shadow(0 0 5px var(--copilot-glow));
}

.copilot-pulse-line {
    fill: none;
    stroke: url(#copilot-pulse-fade);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.copilot-pulse-from {
    stop-color: var(--copilot-ink);
    stop-opacity: 0;
}

.copilot-pulse-mid {
    stop-color: var(--copilot-ink);
    stop-opacity: 0.9;
}

.copilot-pulse-to {
    stop-color: var(--copilot-ink);
}

.copilot-pulse-dot {
    fill: var(--copilot-ink);
}

/* Ban analysis: a phone, banned, and another behind it. */
.copilot-phone {
    position: absolute;
    top: 50%;
    left: 50%;
    display: grid;
    place-items: center;
    width: 25cqw;
    aspect-ratio: 9 / 18.5;
    border-radius: 4.4cqw;
}

.copilot-phone.is-back {
    opacity: 0.6;
    transform: translate(-50%, -50%) translateX(-15cqw) translateY(1cqw) rotate(-11deg) scale(0.9);
}

.copilot-phone.is-front {
    z-index: 1;
    background: var(--copilot-glass-front);
    transform: translate(-50%, -50%) translateX(4cqw) rotate(4deg);
}

.copilot-phone-notch {
    position: absolute;
    top: 6%;
    left: 50%;
    width: 30%;
    height: 4.2%;
    border-radius: var(--radius-full);
    background: var(--copilot-notch);
    transform: translateX(-50%);
}

.copilot-phone .copilot-phone-ban {
    width: 13cqw;
    height: 13cqw;
    color: var(--copilot-ink);
    stroke-width: 1.75;
    filter: drop-shadow(0 0 8px var(--copilot-glow));
}
