/*
 * The asset studio, on top of the theme, the frame & the components of the assets page
 * (theme.css, site/frame.css & site/style.css): only what's the studio's own.
 */

.studio-muted {
    color: var(--theme-text-muted);
}

.studio-inline-icon {
    font-size: 1em;
    vertical-align: -0.125em;
}

/* The intro of the home page: the steps as an eyebrow, the title, & the sentence (centred & light) */

.studio-intro {
    text-align: center;

    h1 {
        margin-block: 0 var(--theme-space);
        font-weight: var(--theme-font-weight-light);
    }

    p:not(.studio-steps) {
        margin: 0;
        color: var(--theme-text-muted);
        font-size: var(--theme-font-size-lg);
        font-weight: var(--theme-font-weight-light);
    }
}

/* The steps: small spaced capitals, separated by small orange dots */

.studio-steps {
    --spacing: 0.25em;
    --gap: 0.9em;

    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--gap);
    align-items: center;
    justify-content: center;
    margin: 0 0 var(--theme-space-sm);
    color: var(--theme-text-muted);
    font-size: var(--theme-font-size-sm);
    font-weight: var(--theme-font-weight-medium);
    letter-spacing: var(--spacing);
    text-transform: uppercase;

    span {
        display: inline-flex;
        align-items: center;
    }

    span + span::before {
        width: 5px;
        height: 5px;
        margin-inline-end: var(--gap);
        border-radius: 50%;
        background: var(--theme-primary);
        content: "";
    }

    /* The spacing also follows the last letter: without it, the steps sit left of the centre */
    span:last-child {
        margin-inline-end: calc(-1 * var(--spacing));
    }
}

/* Sign out, a button which looks like the links of the header */

.studio-logout {
    margin: 0;
}

.studio-link {
    padding: 0;
    font: inherit;
    font-weight: var(--theme-font-weight-medium);
    color: var(--theme-text);
    cursor: pointer;
    background: none;
    border: 0;
}

.studio-link:hover {
    color: var(--theme-link-hover);
}

/* Login: the intro of the home page, centred on the screen */

.studio-login {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70dvh;
}

/* The form: the description, the templates as cards & the button */

.studio-form {
    display: flex;
    flex-direction: column;
    gap: var(--theme-space-lg);
    max-width: 50rem;
    margin-inline: auto;

    /* The description stands alone: the placeholder says what it's for */
    textarea {
        width: 100%;
        padding: var(--theme-space) var(--theme-space-lg);
        border: 1px solid var(--theme-border);
        border-radius: var(--theme-radius-lg);
        background: color-mix(in srgb, var(--theme-surface) 60%, transparent);
        backdrop-filter: blur(8px);
        color: var(--theme-text);
        font-weight: var(--theme-font-weight-light);
        resize: vertical;
        transition: border-color var(--theme-transition);
    }

    textarea:focus {
        border-color: var(--theme-primary);
        outline: none;
    }

    textarea::placeholder {
        color: var(--theme-text-muted);
    }

    fieldset {
        padding: 0;
        margin: 0;
        border: 0;
    }
}

.studio-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--theme-space);
    align-items: center;
    justify-content: space-between;
}

/* «as a [template ▾] with [model ▾]»: the selects read like words of the sentence, with orange arrows */

.studio-choices {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0 0.4em;
    align-items: baseline;
}

.studio-as {
    display: inline-flex;
    gap: 0.4em;
    align-items: baseline;
    color: var(--theme-text-muted);
    font-weight: var(--theme-font-weight-light);
}

.studio-select {
    position: relative;
    display: inline-flex;
    align-items: center;

    select {
        padding: 0 1.4em 0.1em 0;
        border: 0;
        background: none;
        color: var(--theme-text);
        font-weight: var(--theme-font-weight-medium);
        cursor: pointer;
        appearance: none;
    }

    select:focus-visible {
        border-radius: var(--theme-radius-sm);
        outline: 2px solid var(--theme-focus);
        outline-offset: 2px;
    }

    option {
        background: var(--theme-surface-raised);
        color: var(--theme-text);
    }

    .material-icons {
        position: absolute;
        right: 0;
        color: var(--theme-primary);
        font-size: 1.2em;
        pointer-events: none;
    }
}

/* Generate (& Try again): an action as orange text instead of a button */
.studio-generate {
    display: inline-flex;
    gap: var(--theme-space-xs);
    align-items: center;
    padding: 0;
    border: 0;
    background: none;
    color: var(--cd-orange-70);
    font: inherit;
    font-weight: var(--theme-font-weight-semibold);
    text-decoration: none;
    cursor: pointer;
    transition: color var(--theme-transition);

    &:hover {
        color: var(--cd-orange-80);
    }

    &:disabled {
        cursor: progress;
        opacity: 0.5;
    }

    &:focus-visible {
        border-radius: var(--theme-radius-sm);
        outline: 2px solid var(--theme-focus);
        outline-offset: 2px;
    }

    .material-icons {
        font-size: 1.2em;
    }
}

/* On the login: the action a step below the intro, a bit bigger */
.studio-login .studio-generate {
    margin-block-start: var(--theme-space-xl);
    font-size: var(--theme-font-size-lg);
}

/* The shortcut in the button: plain, quieter text */
.studio-shortcut {
    margin-inline-start: var(--theme-space-xs);
    font-family: inherit;
    font-size: 0.85em;
    font-weight: var(--theme-font-weight-regular);
    opacity: 0.7;
}

.studio-status {
    min-height: 1.5em;
    margin: 0;
    color: var(--theme-text-muted);
    text-align: center;

    &:empty {
        visibility: hidden;
    }
}

.studio-error {
    color: var(--theme-error-text);
}

/* While Claude draws: the row of the new asset, its variants as five pulsing tiles */

.studio-tile {
    aspect-ratio: 1;
    background: linear-gradient(135deg, var(--cd-orange-60), var(--cd-orange-40));
    border-radius: 22%;
    animation: studio-pulse 1.6s ease-in-out infinite;
}

.studio-pending {
    cursor: progress;
}

.studio-tile:nth-child(2) { animation-delay: 0.2s; }
.studio-tile:nth-child(3) { animation-delay: 0.4s; }
.studio-tile:nth-child(4) { animation-delay: 0.6s; }
.studio-tile:nth-child(5) { animation-delay: 0.8s; }

@keyframes studio-pulse {
    0%,
    100% {
        opacity: 0.25;
    }

    50% {
        opacity: 0.7;
    }
}

@media (prefers-reduced-motion: reduce) {
    .studio-tile {
        animation: none;
        opacity: 0.4;
    }
}

/* The recent assets: the first variant large, the others small below it */

/* The recent assets: a list, one asset per row (its description & meta next to all its variants) */

.studio-recent {
    display: flex;
    flex-direction: column;
    max-width: 50rem;
    margin: var(--theme-space) auto 0;
}

/* The hint of the empty list, centred below the form, gone with its first row (also the one drawn right now) */
.studio-empty {
    text-align: center;
}

.studio-recent:has(.studio-asset) + .studio-empty {
    display: none;
}

.studio-asset {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--theme-space-lg);
    align-items: center;
    padding: var(--theme-space);
    border-block-end: 1px solid var(--theme-border);
    color: inherit;
    text-decoration: none;
    transition: background-color var(--theme-transition);

    &:last-child {
        border-block-end: 0;
    }

    /* A soft background on hover: the row is the link */
    &:hover {
        background: color-mix(in srgb, var(--theme-surface) 60%, transparent);
    }

    @media (width < 48rem) {
        grid-template-columns: 1fr;
    }
}

.studio-asset-text {
    display: flex;
    flex-direction: column;
    gap: var(--theme-space-sm);
    min-width: 0;
}

/* The description as a quote, in normal weight & cut to two lines (all of it in the tooltip) */
.studio-asset-description {
    display: -webkit-box;
    overflow: hidden;
    font-weight: var(--theme-font-weight-regular);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

/* The variants as small tiles, rounded like the avatars of GitLab */
.studio-asset-variants {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 4rem));
    gap: var(--theme-space-sm);

    img {
        width: 100%;
        height: auto;
        border-radius: 22%;
    }
}

.studio-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--theme-space-xs);
    align-items: center;
    font-size: var(--theme-font-size-sm);

    .material-icons {
        font-size: 1.1em;
    }
}

/* An asset: its meta as chips, the crops of the preview & the variants */

.studio-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--theme-space-sm);
}

.studio-chip {
    display: inline-flex;
    gap: var(--theme-space-xs);
    align-items: center;
    padding: 0.2em 0.75em;
    font-size: var(--theme-font-size-sm);
    background: color-mix(in srgb, currentcolor 12%, transparent);
    border-radius: 0.9em;

    .material-icons {
        font-size: 1.1em;
    }
}

.studio-crop-shape {
    width: 1rem;
    height: 1rem;
    background: currentcolor;
}

.studio-crop-rounded {
    border-radius: 22%;
}

.studio-crop-circle {
    border-radius: 50%;
}

.studio-variant {
    h3 {
        margin: 0;
    }

    .studio-muted {
        margin: 0;
    }
}

.studio-preview {
    width: 100%;
    height: auto;
    transition: border-radius var(--theme-transition);
}

/* The preview: a hint on hover, a click shows it big (see .studio-zoom) */
.studio-variant .studio-preview {
    position: relative;
    cursor: zoom-in;
    transition: transform var(--theme-transition), box-shadow var(--theme-transition),
        border-radius var(--theme-transition);

    &:hover {
        z-index: 1;
        box-shadow: var(--theme-shadow);
        transform: scale(1.05);
    }
}

/* The crop chosen in the bar (see .studio-crop) */
.studio-asset-details:has(input[value="rounded"]:checked) .studio-preview {
    border-radius: 22%;
}

.studio-asset-details:has(input[value="circle"]:checked) .studio-preview {
    border-radius: 50%;
}

/* A variant, big, & right of it the small sizes (as they really look, with their size below each):
   on top of everything, a click anywhere (or Escape) closes it */
.studio-zoom {
    max-width: none;
    max-height: none;
    padding: 0;
    overflow: visible;
    border: 0;
    background: none;
    cursor: zoom-out;

    &::backdrop {
        background: color-mix(in srgb, var(--theme-background) 80%, transparent);
        backdrop-filter: blur(8px);
    }
}

.studio-zoom-content {
    display: flex;
    gap: var(--theme-space-xl);
    align-items: start;
}

.studio-zoom-big {
    display: block;
    width: min(70vmin, 44rem);
    height: auto;
    box-shadow: var(--theme-shadow);
}

.studio-zoom-sizes {
    display: flex;
    flex-direction: column;
    gap: var(--theme-space-lg);
    align-items: center;

    figure {
        display: flex;
        flex-direction: column;
        gap: var(--theme-space-xs);
        align-items: center;
        margin: 0;
    }

    figcaption {
        color: var(--theme-text);
        font-size: var(--theme-font-size-sm);
    }
}

/* On small screens below each other: the big one as wide as the screen allows, the sizes in a row */
@media (width < 48rem) {
    .studio-zoom {
        max-height: calc(100dvh - 2rem);
        overflow: auto;
    }

    .studio-zoom-content {
        flex-direction: column;
        align-items: center;
    }

    .studio-zoom-big {
        width: min(90vw, 60dvh);
    }

    .studio-zoom-sizes {
        flex-flow: row wrap;
        align-items: end;
        justify-content: center;
    }
}

/* The downloads as one block, the width of the card: SVG & ZIP side by side, the PNG sizes below */
.studio-variant .studio-downloads {
    display: grid;
    flex-grow: 0;  /* Not like the other paragraphs of a card (.card p): the idea above takes the slack */
    grid-template-columns: 1fr 1fr;
    gap: var(--theme-space-sm);
    align-content: end;
    width: 100%;

    .download {
        justify-content: center;
    }

    /* The PNG sizes on one line, tighter than elsewhere (a narrow card wraps to the next row instead) */
    .download:has(a) {
        display: flex;
        flex-wrap: nowrap;
        grid-column: 1 / -1;

        > * {
            flex: 1;
            padding-inline: 0.3em;
            text-align: center;
        }

        /* More room at the round ends */
        > :first-child {
            padding-inline-start: 0.6em;
        }

        > :last-child {
            padding-inline-end: 0.6em;
        }
    }
}

.studio-prompt {
    margin: var(--theme-space) 0 0;
    overflow-x: auto;
    font-size: var(--theme-font-size-sm);
    white-space: pre-wrap;
}

/* The modal of the MCP server (opened by the link in the header) */

.studio-mcp {
    width: min(100% - 2rem, 60rem);

    .modal-body > p {
        margin-block: 0 var(--theme-space);
    }

    h3 {
        margin-block: var(--theme-space-lg) var(--theme-space-sm);
        color: var(--theme-text-muted);
        font-size: var(--theme-font-size-sm);
        font-weight: var(--theme-font-weight-semibold);
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    dl {
        margin: 0;
    }

    dt {
        font-weight: var(--theme-font-weight-medium);
    }

    dd {
        margin: 0 0 var(--theme-space-sm);
        color: var(--theme-text-muted);
    }

    dd ul {
        margin: 0;
        padding-inline-start: var(--theme-space-lg);
    }
}

/* A command or URL to copy (the copy button comes from site/script.js) */
.studio-snippet {
    padding: 0;
    overflow: hidden;
}

.studio-tools dt code {
    font-weight: var(--theme-font-weight-semibold);
}

/* An asset in the modal of the home page: wide enough for all variants in a row */

.studio-asset-modal {
    width: min(100% - 2rem, 110rem);

    /* The tags right under the title: no line between them, little space */
    .modal-header {
        gap: var(--theme-space-sm);
        padding-block-end: 0;
        border-block-end: 0;
    }

    .modal-body {
        padding-block-start: var(--theme-space);
    }

    .studio-variants {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
    }
}

.studio-asset-title {
    display: -webkit-box;
    flex: 1;
    margin: 0;
    overflow: hidden;
    font-weight: var(--theme-font-weight-regular);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.studio-asset-details {
    display: flex;
    flex-direction: column;
    gap: var(--theme-space);

    .studio-chips,
    .actions {
        margin: 0;
    }
}

/* The prompt of an asset, in a modal on top of the asset's */
.studio-prompt-modal {
    width: min(100% - 2rem, 50rem);
}

/* Try again & the prompt left, the tags right (below each other when there's no room) */
.studio-asset-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--theme-space-sm) var(--theme-space-lg);
    align-items: center;
    justify-content: space-between;

    .studio-chips {
        justify-content: end;
        margin: 0;
    }

    /* On small screens below each other: all of it centred */
    @media (width < 48rem) {
        row-gap: var(--theme-space);
        justify-content: center;

        .studio-pills,
        .studio-chips {
            justify-content: center;
        }
    }
}

/* Named pills like the PNG downloads: a label, then its actions (orange on hover) */
.studio-pills {
    display: flex;
    flex-wrap: wrap;
    gap: var(--theme-space-sm);
    align-items: center;
}

.studio-pill {
    display: inline-flex;
    align-items: stretch;
    overflow: hidden;
    border-radius: 0.9em;
    background: color-mix(in srgb, currentcolor 12%, transparent);
    font-size: var(--theme-font-size-sm);
    line-height: 1.8;

    > :not(.studio-pill-label, template) {
        display: inline-grid;
        place-items: center;
        padding-inline: 0.55em;
        border: 0;
        border-inline-start: 1px solid color-mix(in srgb, currentcolor 20%, transparent);
        background: none;
        color: inherit;
        font: inherit;
        text-decoration: none;
        cursor: pointer;
        transition: background-color var(--theme-transition), color var(--theme-transition);
    }

    > :not(.studio-pill-label, template):last-child {
        padding-inline-end: 0.75em;
    }

    > :not(.studio-pill-label, template):hover {
        background: var(--theme-primary);
        color: var(--theme-primary-contrast);
    }

    .material-icons {
        font-size: 1.15em;
    }
}

.studio-pill-label {
    display: inline-flex;
    align-items: center;
    padding-inline: 0.75em 0.5em;
    font-weight: var(--theme-font-weight-semibold);
}

/* A crop as its shape (the radio stays, invisible): orange when chosen */
.studio-crop {
    input {
        position: absolute;
        opacity: 0;
        pointer-events: none;
    }

    &:has(input:checked) {
        color: var(--cd-orange-70);
    }

    &:has(input:focus-visible) {
        outline: 2px solid var(--theme-focus);
        outline-offset: -2px;
    }
}

.studio-pill .studio-crop-shape {
    width: 0.85em;
    height: 0.85em;
}
