/*
 * The maker family (TOOLS-PLAN 3.2 "Maker", site/pages/free-tools/maker.php, assets/js/ft/maker.js), after ft-base.css
 * and ft-calc.css (fields, error lines). Tokens only.
 *
 *   .ft-maker > .ft-maker__controls (.ft-maker__head, .ft-maker__group > .ft-field…, .ft-linkpanel after the link
 *             generator's first group, .ft-image, .ft-adjust, .ft-maker__save)
 *             + .ft-maker__side (.ft-maker__preview > .ft-maker__piece > canvas, .ft-maker__rail)
 *   .ft-zoom   the enlarged preview on a phone          .ft-mbar   the phone's bottom bar with the main download
 * Desktop (960 px and wider): controls 7/12, the preview and files 5/12, sticky under the header. Phone: a small preview
 * first, then the controls, then the files (the link generator: the controls with the link under its field, then the preview and files). The preview box takes
 * its shape from --ft-aspect before anything is drawn, so nothing moves when it paints. The paper stays white in dark
 * mode. Targets 44 px or more, fields 16 px.
 */
.ft-maker {
    display: grid;
    gap: var(--sp-5);
    align-items: start;
}

.ft-maker__side {
    display: contents;
}

.ft-maker__preview { order: 1; }
.ft-maker__controls { order: 2; }
.ft-maker__rail { order: 4; }

.ft-maker--link .ft-maker__controls { order: 1; }
.ft-maker--link .ft-maker__preview { order: 3; }

@media (min-width: 960px) {
    .ft-maker {
        grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
        gap: var(--sp-8);
    }

    .ft-maker .ft-maker__controls { order: 0; }

    .ft-maker__side {
        order: 1;
        position: sticky;
        top: 96px;
        display: grid;
        gap: var(--sp-4);
    }
}

.ft-maker__controls,
.ft-maker__rail {
    display: grid;
    gap: var(--sp-4);
    padding: var(--sp-4);
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
}

@media (min-width: 640px) {
    .ft-maker__controls { padding: var(--sp-6); }
}

.ft-maker__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2) var(--sp-4);
}

.ft-maker__title {
    margin: 0;
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
    color: var(--c-ink);
}

.ft-maker__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
}

.ft-maker .btn {
    min-height: 44px;
}

.ft-maker__note {
    margin: 0;
    font-size: var(--fs-sm);
    color: var(--c-text-2);
}

.ft-maker__group {
    display: grid;
    gap: var(--sp-4);
    min-width: 0;
    margin: 0;
    padding: var(--sp-4) 0 0;
    border: 0;
    border-top: 1px solid var(--c-line);
}

.ft-maker__legend {
    float: left;
    width: 100%;
    margin-bottom: var(--sp-1);
    padding: 0;
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    color: var(--c-ink);
}

.ft-maker__group > .ft-maker__legend + * {
    clear: both;
}

.ft-field .textarea {
    min-height: 44px;
    font-size: 1rem;
}

.ft-field .textarea[aria-invalid="true"],
.ft-field .ft-color[aria-invalid="true"] {
    border-color: var(--c-danger);
}

.ft-color {
    width: 88px;
    min-height: 44px;
    padding: 4px;
    background: var(--c-surface);
    border: 1px solid var(--c-line-strong);
    border-radius: var(--r-md);
    cursor: pointer;
}

.ft-field--check .check {
    align-items: center;
    min-height: 44px;
    font-size: 1rem;
}

.ft-field--check .check input {
    width: 20px;
    height: 20px;
}

/* ---- a picture: Choose / Replace, its state, Remove */
.ft-image {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2) var(--sp-3);
}

.ft-image__pick {
    position: relative;
    cursor: pointer;
}

.ft-image__file {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.ft-image__pick:focus-within {
    box-shadow: var(--focus-ring);
}

.ft-adjust {
    margin-top: var(--sp-2);
    font-size: var(--fs-sm);
}

.ft-adjust summary {
    display: flex;
    align-items: center;
    min-height: 44px;
    color: var(--c-brand-ink);
    cursor: pointer;
}

.ft-adjust__row {
    display: grid;
    grid-template-columns: 8.5rem minmax(0, 1fr);
    align-items: center;
    gap: var(--sp-3);
    min-height: 44px;
    color: var(--c-text-2);
}

.ft-adjust__row input {
    width: 100%;
    min-height: 32px;
    accent-color: var(--c-brand);
}

.ft-maker__save {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2) var(--sp-4);
    padding-top: var(--sp-4);
    border-top: 1px solid var(--c-line);
}

.ft-maker__save .check {
    align-items: center;
    min-height: 44px;
}

.ft-maker__saved {
    font-size: var(--fs-sm);
    color: var(--c-text-2);
}

.ft-linkbtn {
    min-height: 44px;
    padding: 0;
    font: inherit;
    font-size: var(--fs-sm);
    color: var(--c-brand-ink);
    text-decoration: underline;
    background: none;
    border: 0;
    cursor: pointer;
}

.ft-linkbtn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* ---- the preview: white paper at the piece's shape, in both themes */
.ft-maker__preview {
    position: relative;
    display: grid;
    grid-template-columns: repeat(var(--ft-pieces, 1), minmax(0, 1fr));
    gap: var(--sp-3);
    justify-items: center;
    padding: var(--sp-4);
    background: var(--c-surface-2);
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
}

.ft-maker--pair .ft-maker__preview {
    --ft-pieces: 2;
}

.ft-maker__piece {
    width: 100%;
    margin: 0;
    text-align: center;
}

.ft-maker__canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: var(--ft-aspect, 1);
    margin-inline: auto;
    background: #fff;
    box-shadow: var(--sh-md);
    touch-action: pinch-zoom;
}

.ft-maker--photo .ft-maker__canvas {
    cursor: grab;
    touch-action: none;
}

.ft-maker__cap {
    margin-top: var(--sp-2);
    font-size: var(--fs-xs);
    color: var(--c-text-2);
}

/* on a phone the preview is small (tap to enlarge): tall pieces are held to 42% of the screen's height */
@media (max-width: 959px) {
    .ft-maker__canvas {
        max-height: 42vh;
        width: auto;
        max-width: 100%;
    }

    .ft-maker__enlarge {
        position: absolute;
        inset: 0;
        width: 100%;
        background: transparent;
        border: 0;
        border-radius: var(--r-lg);
        color: transparent;
        cursor: zoom-in;
    }

    /* the photo maker's preview is dragged to move a photo, so nothing may lie over it */
    .ft-maker--photo .ft-maker__enlarge { display: none !important; }

    .ft-maker__enlarge:focus-visible {
        outline: none;
        box-shadow: var(--focus-ring);
    }
}

@media (min-width: 960px) {
    .ft-maker__enlarge { display: none !important; }
    .ft-maker--pair .ft-maker__canvas { max-height: 70vh; width: auto; max-width: 100%; }
}

/* ---- the files */
.ft-maker__rail {
    gap: var(--sp-2);
}

.ft-maker__out {
    width: 100%;
    justify-content: center;
}

.ft-maker__status {
    min-height: 1.5em;
    margin: var(--sp-1) 0 0;
    font-size: var(--fs-sm);
    color: var(--c-text-2);
    overflow-wrap: anywhere;
}

.ft-maker__status:empty {
    min-height: 0;
}

/* ---- the review link panel, a group of the controls right under the link field */
.ft-linkpanel {
    display: grid;
    gap: var(--sp-3);
    padding-top: var(--sp-4);
    border-top: 1px solid var(--c-line);
}

.ft-linkpanel__msgactions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--sp-1);
}

.ft-linkpanel__link {
    margin: 0;
    padding: var(--sp-3);
    font-size: var(--fs-sm);
    background: var(--c-surface-2);
    border-radius: var(--r-md);
    overflow-wrap: anywhere;
}

.ft-linkpanel__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
}

.ft-linkpanel__msg {
    padding-top: var(--sp-3);
    border-top: 1px solid var(--c-line);
}

.ft-linkpanel__msghead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
}

.ft-linkpanel__msghead .ft-h3 {
    margin: 0;
}

.ft-linkpanel__text {
    margin: var(--sp-2) 0 0;
    font-size: var(--fs-sm);
    color: var(--c-text);
    white-space: pre-line;
    overflow-wrap: anywhere;
}

/* ---- the enlarged preview */
.ft-zoom {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom, 0px));
    background: var(--c-surface-2);
}

.ft-zoom[hidden] {
    display: none;
}

.ft-zoom__close {
    justify-self: end;
}

.ft-zoom__host {
    display: flex;
    gap: var(--sp-3);
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow: auto;
}

.ft-zoom__host img {
    max-width: 100%;
    max-height: 100%;
    background: #fff;
    box-shadow: var(--sh-md);
}

html.ft-zoomed {
    overflow: hidden;
}

/* ---- the phone's bottom bar */
.ft-mbar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: var(--z-sticky);
    padding: var(--sp-2) var(--sp-4) calc(var(--sp-2) + env(safe-area-inset-bottom, 0px));
    background: var(--c-surface);
    border-top: 1px solid var(--c-line-strong);
    box-shadow: var(--sh-md);
}

.ft-mbar__btn {
    width: 100%;
    min-height: 48px;
    justify-content: center;
}

@media (min-width: 960px) {
    .ft-mbar { display: none !important; }
}

/* ---- the worked example and file sizes */
.ft-maker__tablewrap {
    overflow-x: auto;
}

.ft-maker__table td {
    overflow-wrap: anywhere;
}

@media print {
    .ft-maker__controls,
    .ft-maker__rail,
    .ft-linkpanel__actions,
    .ft-linkpanel__msg,
    .ft-maker__enlarge,
    .ft-zoom,
    .ft-mbar {
        display: none !important;
    }

    .ft-maker,
    .ft-maker__side {
        display: block;
    }

    .ft-maker__preview {
        background: none;
        border: 0;
    }

    .ft-maker__canvas {
        max-height: none;
        box-shadow: none;
        border: 1px solid #999;
    }
}
