/* =====================================================================================================================
   Template detail page (/templates/<category>/<slug>): the template big on a stage, a compact side panel with the
   toolbar (Save image, the pencil, Undo, Redo, Randomize, Info), the title and the restyle studio (js/seo/template-studio.js), then related templates and the apps.
   ===================================================================================================================== */

.tpl-detail {
    --tpl-text: #0f172a;
    --tpl-muted: #5b6577;
    --tpl-line: rgba(15, 23, 42, 0.1);
    --tpl-surface: #ffffff;
    --tpl-soft: #f3f5fa;
    --tpl-accent: var(--landing-accent, #2563eb);
    --tpl-accent-deep: var(--landing-accent-deep, #1d4ed8);
    --tpl-radius: 22px;
    --tpl-stage-h: clamp(420px, calc(100vh - 150px), 860px);
    max-width: 1560px;
    padding-top: clamp(16px, 2.4vw, 28px);
    color: var(--tpl-text);
}

.dark .tpl-detail {
    --tpl-text: rgba(255, 255, 255, 0.94);
    --tpl-muted: rgba(255, 255, 255, 0.62);
    --tpl-line: rgba(255, 255, 255, 0.1);
    --tpl-surface: #161b26;
    --tpl-soft: #1d2331;
    --tpl-accent: #4f86f7;
    --tpl-accent-deep: #3b73ea;
}

.tpl-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(300px, 26vw, 370px);
    gap: clamp(18px, 2.2vw, 32px);
    align-items: start;
}

/* ---- Stage -------------------------------------------------------------------------------------------------------- */

.tpl-stage-col {
    min-width: 0;
}

/* The toolbar at the top of the side panel (Save image, the pencil, Undo, Redo, Randomize, Info): the apps' toolbar. */
.tpl-toolbar {
    margin: 0;
}

/* Every button of the panel draws its own face: no native (grey) button look in any browser. */
.tpl-detail button {
    -webkit-appearance: none;
    appearance: none;
}

.tpl-breadcrumbs {
    margin-top: clamp(36px, 5vw, 56px);
    padding-top: 18px;
    border-top: 1px solid var(--tpl-line);
}

    .tpl-breadcrumbs .seo-breadcrumb {
        margin: 0;
    }

.tpl-stage {
    position: relative;
    display: grid;
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
    place-items: center;
    height: var(--tpl-stage-h);
    padding: clamp(22px, 4vw, 64px);
    overflow: hidden;
    border: 1px solid var(--tpl-line);
    border-radius: calc(var(--tpl-radius) + 6px);
    background:
        radial-gradient(circle at 1px 1px, rgba(15, 23, 42, 0.07) 1px, transparent 0) 0 0 / 22px 22px,
        radial-gradient(120% 90% at 20% 0%, #eef3ff 0%, transparent 60%),
        radial-gradient(100% 80% at 100% 100%, #fbf1ea 0%, transparent 55%),
        #f6f7fb;
    isolation: isolate;
}

.dark .tpl-stage {
    background:
        radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.06) 1px, transparent 0) 0 0 / 22px 22px,
        radial-gradient(120% 90% at 20% 0%, rgba(79, 134, 247, 0.16) 0%, transparent 60%),
        radial-gradient(100% 80% at 100% 100%, rgba(232, 71, 107, 0.1) 0%, transparent 55%),
        #0e121b;
}

.tpl-stage-canvas,
.tpl-stage-fallback {
    grid-area: 1 / 1;
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 0 0 1px rgba(15, 23, 42, 0.06), 0 28px 60px -24px rgba(15, 23, 42, 0.38), 0 8px 18px -10px rgba(15, 23, 42, 0.18);
}

.tpl-stage-fallback {
    object-fit: contain;
    background: #fff;
}

.tpl-stage-fallback.is-pending,
.tpl-detail.is-ready .tpl-stage-fallback,
.tpl-detail.is-loading .tpl-stage-fallback[src*="/placeholders/"] {
    visibility: hidden;
}

.tpl-detail.is-ready .tpl-stage-fallback {
    position: absolute;
}

.tpl-stage-canvas {
    display: none;
}

.tpl-detail.is-ready .tpl-stage-canvas {
    display: block;
    /* backwards: once revealed the canvas keeps no transform of its own, so the stage zoom can scale it. */
    animation: tpl-reveal 420ms cubic-bezier(0.2, 0, 0, 1) backwards;
}

/* No inset top highlight on the checkerboard: through the transparent canvas it shows as a white line along the top. */
.tpl-stage[data-bg="checker"] .tpl-stage-canvas {
    background: repeating-conic-gradient(#e7eaf0 0 25%, #ffffff 0 50%) 0 0 / 22px 22px;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06), 0 28px 60px -24px rgba(15, 23, 42, 0.38), 0 8px 18px -10px rgba(15, 23, 42, 0.18);
}

.dark .tpl-stage[data-bg="checker"] .tpl-stage-canvas {
    background: repeating-conic-gradient(#262c3a 0 25%, #1b202b 0 50%) 0 0 / 22px 22px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 28px 60px -20px rgba(2, 6, 23, 0.6);
}

.tpl-stage[data-bg="dark"] .tpl-stage-canvas {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 28px 60px -20px rgba(2, 6, 23, 0.6);
}

@keyframes tpl-reveal {
    from {
        opacity: 0;
        transform: scale(0.97) translateY(6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.tpl-stage-loading {
    position: absolute;
    inset: 0;
    display: none;
    place-items: center;
    pointer-events: none;
}

.tpl-detail.is-loading .tpl-stage-loading {
    display: grid;
}

    .tpl-stage-loading::before {
        content: "";
        position: absolute;
        inset: 14%;
        border-radius: 18px;
        background: linear-gradient(100deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.75) 50%, rgba(255, 255, 255, 0) 70%) 0 0 / 220% 100%, rgba(15, 23, 42, 0.04);
        animation: tpl-shimmer 1.4s linear infinite;
    }

.dark .tpl-stage-loading::before {
    background: linear-gradient(100deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.07) 50%, rgba(255, 255, 255, 0) 70%) 0 0 / 220% 100%, rgba(255, 255, 255, 0.03);
}

    .tpl-stage-loading span {
        position: relative;
        width: 38px;
        height: 38px;
        border: 3px solid rgba(37, 99, 235, 0.18);
        border-top-color: var(--tpl-accent);
        border-radius: 50%;
        animation: tpl-spin 0.8s linear infinite;
    }

@keyframes tpl-shimmer {
    to {
        background-position: -220% 0, 0 0;
    }
}

@keyframes tpl-spin {
    to {
        transform: rotate(360deg);
    }
}

.tpl-stage-badge {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 2;
    padding: 7px 11px;
    border-radius: 999px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    box-shadow: 0 6px 16px rgba(217, 119, 6, 0.3);
}
/* Below the template: the category and Free / Premium chips, then the description. */
.tpl-about {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 78ch;
    margin: 14px 4px 0;
}

.tpl-stage-caption {
    margin: 0;
    color: var(--tpl-muted);
    font-size: 1rem;
    line-height: 1.6;
}

/* ---- Side panel --------------------------------------------------------------------------------------------------- */

/* The side panel is an app control panel (.filter-landing-controls .ak-app in controls.css and the app kit): flat, a
   thin rule on its left, the apps' labels, buttons and links. This only keeps it in view while the page scrolls. */
.tpl-side {
    position: sticky;
    top: 92px;
}

.tpl-detail .ak-btn[hidden] {
    display: none;
}

.tpl-intro {
    margin: 2px 0 0;
    color: var(--tpl-muted);
    font-size: 1rem;
    line-height: 1.6;
}

/* Open in Atom Builder / Molecule Builder: a plain button with an icon, framed like Reset. */
.tpl-detail .tpl-app-link {
    gap: 6px;
    border: 1px solid var(--tpl-line);
    border-radius: 999px;
    padding-inline: 14px;
    background: var(--tpl-surface);
    color: var(--tpl-text);
}

    .tpl-detail .tpl-app-link:hover {
        border-color: var(--tpl-accent);
        background: var(--tpl-surface);
        color: var(--tpl-accent);
    }

    .tpl-app-link svg {
        width: 16px;
        height: 16px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

/* The restyle controls: the looks across the panel, then each label left of its control, as in the apps. A label sits
   level with the first row of its control (Palette and Background wrap onto two rows). */
.tpl-studio {
    --tpl-row: 36px;
    --tpl-ring: rgba(15, 23, 42, 0.14);
    display: grid;
    grid-template-columns: minmax(84px, auto) minmax(0, 1fr);
    align-items: start;
    gap: 14px 12px;
    padding-top: 4px;
}

.dark .tpl-studio {
    --tpl-ring: rgba(255, 255, 255, 0.2);
}

    .tpl-studio > .tpl-seg {
        grid-column: 1 / -1;
        margin-bottom: 2px;
    }

    .tpl-studio .filter-landing-controls-label {
        display: flex;
        align-items: center;
        min-height: var(--tpl-row);
        margin: 0;
    }

/* Until the template is loaded the controls show but do not respond (they have nothing to work on yet). */
.tpl-detail:not(.is-ready) .tpl-studio > * {
    pointer-events: none;
}

.tpl-detail.is-unavailable .tpl-studio {
    display: none;
}

/* The sizes a template comes in (Post, Story, Facebook): tiles like the looks, each with the shape of its size. */
.tpl-sizes {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 16px;
}

    .tpl-sizes a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        min-width: 0;
        padding: 10px 2px 8px;
        border: 1.5px solid var(--tpl-line);
        border-radius: 14px;
        background: var(--tpl-soft);
        color: var(--tpl-muted);
        font-size: 0.78rem;
        font-weight: 700;
        line-height: 1.1;
        text-align: center;
        text-decoration: none;
        transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
    }

        .tpl-sizes a small {
            font-size: 0.68rem;
            font-weight: 600;
            opacity: 0.75;
        }

        .tpl-sizes a:hover {
            border-color: color-mix(in srgb, var(--tpl-accent) 40%, var(--tpl-line));
            color: var(--tpl-text);
        }

        .tpl-sizes a[aria-current="true"] {
            border-color: var(--tpl-accent);
            background: color-mix(in srgb, var(--tpl-accent) 9%, var(--tpl-surface));
            color: var(--tpl-accent-deep);
        }

.dark .tpl-sizes a[aria-current="true"] {
    color: #fff;
}

.tpl-size-shape {
    display: block;
    margin: 2px 0 4px;
    border: 2px solid currentColor;
    border-radius: 4px;
}

/* The four looks: quiet tiles on the panel's own surface, the icon shows the look; the chosen one in the accent. */
.tpl-seg {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

    .tpl-seg button {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 7px;
        min-width: 0;
        padding: 11px 2px 9px;
        border: 1.5px solid var(--tpl-line);
        border-radius: 14px;
        background: var(--tpl-soft);
        color: var(--tpl-muted);
        font: inherit;
        font-size: 0.74rem;
        font-weight: 700;
        line-height: 1.1;
        text-align: center;
        overflow-wrap: anywhere;
        cursor: pointer;
        transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background-color 160ms ease, color 160ms ease;
    }

        .tpl-seg button:hover {
            border-color: color-mix(in srgb, var(--tpl-accent) 40%, var(--tpl-line));
            color: var(--tpl-text);
            transform: translateY(-1px);
        }

        .tpl-seg button[aria-pressed="true"] {
            border-color: var(--tpl-accent);
            background: color-mix(in srgb, var(--tpl-accent) 9%, var(--tpl-surface));
            color: var(--tpl-accent-deep);
            box-shadow: 0 0 0 3px color-mix(in srgb, var(--tpl-accent) 16%, transparent);
        }

.dark .tpl-seg button[aria-pressed="true"] {
    color: #fff;
}

.tpl-seg button:focus-visible,
.tpl-bgs button:focus-visible,
.tpl-palette:focus-visible {
    outline: 2px solid var(--tpl-accent);
    outline-offset: 2px;
}

.tpl-look-icon {
    display: block;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    box-shadow: 0 3px 8px -3px rgba(15, 23, 42, 0.35);
    transition: transform 160ms ease;
}

.tpl-seg button:hover .tpl-look-icon,
.tpl-seg button[aria-pressed="true"] .tpl-look-icon {
    transform: scale(1.06);
}

.tpl-look-icon--color {
    background: conic-gradient(#f72585, #ffb703, #06d6a0, #4361ee, #7209b7, #f72585);
}

.tpl-look-icon--duotone {
    background: linear-gradient(135deg, #1b1464 0 50%, #ffd36e 50% 100%);
}

.tpl-look-icon--outline {
    border: 2.5px solid #0f172a;
    background: radial-gradient(circle, #fff 36%, #0f172a 37% 45%, #fff 46%);
}

.dark .tpl-look-icon--outline {
    border-color: #fff;
}

.tpl-look-icon--neon {
    background: radial-gradient(circle, transparent 40%, #ff2bd6 45%, #2bd9ff 56%, transparent 62%), #11131c;
    box-shadow: 0 0 10px rgba(255, 43, 214, 0.55);
}

.tpl-field {
    display: contents;
}

/* The template's own colours: click one to pick a new colour. A ring keeps a black or white colour visible on either
   theme. */
.tpl-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: var(--tpl-row);
}

.tpl-swatch {
    position: relative;
    width: var(--tpl-row);
    height: var(--tpl-row);
    border-radius: 50%;
    background: var(--swatch, #ccc);
    box-shadow: 0 0 0 1px var(--tpl-ring) inset, 0 2px 6px rgba(15, 23, 42, 0.12);
    cursor: pointer;
    transition: transform 140ms ease, box-shadow 140ms ease;
}

    .tpl-swatch:hover {
        transform: scale(1.08);
    }

    .tpl-swatch:focus-within {
        box-shadow: 0 0 0 1px var(--tpl-ring) inset, 0 0 0 2px var(--tpl-surface), 0 0 0 4px var(--tpl-accent);
    }

    .tpl-swatch input {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        padding: 0;
        border: 0;
        opacity: 0;
        cursor: pointer;
    }

/* Palettes: two rows of four, the one last applied ringed in the accent. */
.tpl-palettes {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding-top: 4px;
}

.tpl-palette {
    display: block;
    width: 100%;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background-color: #e2e8f0;
    box-shadow: 0 0 0 1px var(--tpl-ring) inset;
    cursor: pointer;
    transition: transform 140ms ease, box-shadow 140ms ease;
}

    .tpl-palette:hover {
        transform: translateY(-1px);
        box-shadow: 0 0 0 1px var(--tpl-ring) inset, 0 6px 14px -6px rgba(15, 23, 42, 0.45);
    }

    .tpl-palette[aria-pressed="true"] {
        box-shadow: 0 0 0 1px var(--tpl-ring) inset, 0 0 0 2px var(--tpl-surface), 0 0 0 4px var(--tpl-accent);
    }

/* Backgrounds: each button shows its own background. */
.tpl-bgs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

    .tpl-bgs button {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 0;
        height: var(--tpl-row);
        padding: 0 6px;
        border: 1.5px solid var(--tpl-ring);
        border-radius: 12px;
        color: #0f172a;
        font: inherit;
        font-size: 0.8rem;
        font-weight: 700;
        line-height: 1.1;
        text-align: center;
        cursor: pointer;
        transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
    }

        .tpl-bgs button[data-bg="light"] {
            background: #fff;
        }

        .tpl-bgs button[data-bg="dark"] {
            background: radial-gradient(circle at 50% 30%, #2a3145, #0a0c12);
            color: #fff;
        }

        .tpl-bgs button[data-bg="tint"] {
            background: linear-gradient(135deg, #fde2e4, #e0e7ff 55%, #dbeafe);
            color: #3730a3;
        }

        .tpl-bgs button[data-bg="checker"] {
            background: repeating-conic-gradient(#e2e8f0 0 25%, #fff 0 50%) 0 0 / 12px 12px;
        }

            .tpl-bgs button[data-bg="checker"] span {
                padding: 1px 6px;
                border-radius: 6px;
                background: rgba(255, 255, 255, 0.88);
            }

        .tpl-bgs button:hover {
            transform: translateY(-1px);
            box-shadow: 0 8px 18px -10px rgba(15, 23, 42, 0.45);
        }

        .tpl-bgs button[aria-pressed="true"] {
            border-color: var(--tpl-accent);
            box-shadow: 0 0 0 3px color-mix(in srgb, var(--tpl-accent) 22%, transparent);
        }

/* Edit this look (once the colours are changed) and Reset, under the controls, as the apps' action buttons. */
.tpl-studio-actions {
    grid-column: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 2px;
}

    .tpl-studio-actions .tpl-edit-look {
        flex: 1 1 auto;
    }

    .tpl-detail .tpl-studio-actions .ak-btn {
        min-height: 36px;
        border-radius: 999px;
    }

.tpl-detail .tpl-studio-actions .tpl-reset {
    gap: 6px;
    border: 1px solid var(--tpl-line);
    border-radius: 999px;
    padding-inline: 14px;
    background: var(--tpl-surface);
    color: var(--tpl-text);
}

    .tpl-detail .tpl-studio-actions .tpl-reset:hover:not(:disabled) {
        border-color: var(--tpl-accent);
        background: var(--tpl-surface);
        color: var(--tpl-accent);
    }

    .tpl-detail .tpl-studio-actions .tpl-reset:disabled {
        opacity: 0.45;
        cursor: default;
    }

    .tpl-reset svg {
        width: 15px;
        height: 15px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

/* "More ... templates": the apps' "More information" link (.filter-landing-more), like the breadcrumb. */
.tpl-more {
    margin: 0;
}

.tpl-side > .tpl-more {
    margin-top: 8px;
}

/* ---- Sections below ------------------------------------------------------------------------------------------------ */

.tpl-section {
    margin-top: clamp(40px, 6vw, 72px);
}

.tpl-section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px 24px;
    margin-bottom: 18px;
}

    .tpl-section-head h2 {
        margin: 0;
        color: var(--tpl-text);
        font-size: clamp(1.35rem, 2vw, 1.75rem);
    }

    .tpl-section-head p {
        margin: 6px 0 0;
        color: var(--tpl-muted);
    }

    .tpl-section-head .tpl-more {
        margin: 0;
    }

.tpl-related-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

    .tpl-related-grid .seo-template-card {
        border: 1px solid var(--tpl-line);
        background: var(--tpl-surface);
    }

        .tpl-related-grid .seo-template-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 18px 34px -18px rgba(15, 23, 42, 0.35);
        }

.tpl-explore {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: clamp(12px, 1.6vw, 18px);
}

.tpl-explore-card {
    --tpl-card-a: #3b82f6;
    --tpl-card-b: #6366f1;
    position: relative;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px;
    overflow: hidden;
    border: 1px solid var(--tpl-line);
    border-radius: 18px;
    background: var(--tpl-surface);
    color: var(--tpl-text);
    text-decoration: none;
    transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

    .tpl-explore-card::after {
        content: "";
        position: absolute;
        inset: auto -30% -70% auto;
        width: 60%;
        aspect-ratio: 1;
        border-radius: 50%;
        background: radial-gradient(circle, color-mix(in srgb, var(--tpl-card-a) 18%, transparent), transparent 70%);
        pointer-events: none;
        transition: transform 300ms ease;
    }

    .tpl-explore-card:hover {
        color: var(--tpl-text);
        border-color: color-mix(in srgb, var(--tpl-card-a) 45%, transparent);
        transform: translateY(-3px);
        box-shadow: 0 18px 34px -20px color-mix(in srgb, var(--tpl-card-b) 70%, transparent);
    }

        .tpl-explore-card:hover::after {
            transform: scale(1.4);
        }

.tpl-explore-card--apps {
    --tpl-card-a: #ec4899;
    --tpl-card-b: #8b5cf6;
}

.tpl-explore-card--effects {
    --tpl-card-a: #f59e0b;
    --tpl-card-b: #ef4444;
}

.tpl-explore-card--collages {
    --tpl-card-a: #10b981;
    --tpl-card-b: #0ea5e9;
}

.tpl-explore-card--ai {
    --tpl-card-a: #8b5cf6;
    --tpl-card-b: #06b6d4;
}

.tpl-explore-card--fractals {
    --tpl-card-a: #f43f5e;
    --tpl-card-b: #6366f1;
}

.tpl-explore-icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 15px;
    background: linear-gradient(135deg, var(--tpl-card-a), var(--tpl-card-b));
    color: #fff;
    box-shadow: 0 10px 20px -10px var(--tpl-card-b);
}

    .tpl-explore-icon svg {
        width: 26px;
        height: 26px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

.tpl-explore-text {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

    .tpl-explore-text strong {
        font-size: 1rem;
    }

    .tpl-explore-text span {
        color: var(--tpl-muted);
        font-size: 0.86rem;
        line-height: 1.45;
    }

.tpl-explore-arrow {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: var(--tpl-muted);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 180ms ease, stroke 180ms ease;
}

.tpl-explore-card:hover .tpl-explore-arrow {
    stroke: var(--tpl-card-a);
    transform: translateX(3px);
}

/* ---- Smaller screens ----------------------------------------------------------------------------------------------- */

@media (max-width: 1080px) {
    .tpl-related-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .tpl-layout {
        grid-template-columns: minmax(0, 1fr) 300px;
    }

    .tpl-seg button {
        font-size: 0.7rem;
    }

    /* The 300px panel: five colours still fit on one row. */
    .tpl-studio {
        --tpl-row: 32px;
        grid-template-columns: minmax(72px, auto) minmax(0, 1fr);
        column-gap: 10px;
    }

    .tpl-swatches {
        gap: 6px;
    }
}

@media (max-width: 960px) {
    .tpl-studio {
        --tpl-row: 36px;
        grid-template-columns: minmax(84px, auto) minmax(0, 1fr);
    }
}

@media (max-width: 960px) {
    .tpl-detail {
        --tpl-stage-h: min(78vw, 560px);
    }

    .tpl-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .tpl-side {
        position: static;
    }

    /* On a phone one column: the picture, the toolbar under it, the restyle controls right below the toolbar, then
       the category chips and the description. */
    .tpl-layout {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .tpl-related-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tpl-side,
    .tpl-stage-col {
        display: contents;
    }

    .tpl-stage {
        order: 1;
    }

    .tpl-toolbar {
        order: 2;
    }

    .tpl-cta {
        order: 3;
    }

    .tpl-studio {
        order: 4;
    }

    .tpl-about {
        order: 5;
        margin: 0 4px;
    }

    /* The related section right below starts with the same link. */
    .tpl-side > .tpl-more {
        display: none;
    }

    .tpl-stage {
        padding: 18px;
        border-radius: 20px;
    }
    .tpl-layout > *,
    .tpl-side > *,
    .tpl-stage-col > * {
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tpl-detail *,
    .tpl-detail *::before,
    .tpl-detail *::after {
        animation: none !important;
        transition: none !important;
    }
}
