/*
 * The free letter studio.
 *
 * Loaded only on /letter-from-santa/. Two columns on desktop — controls on the
 * left, the A4 sheet on the right — collapsing to sheet-under-controls on
 * mobile. The sheet keeps its 1:√2 ratio at every width so the preview is
 * honest about what comes out of the printer.
 */

.letter-studio {
    display: grid;
    grid-template-columns: minmax(0, 22rem) minmax(0, 1fr);
    gap: clamp(1.5rem, 4vw, 3rem);
    align-items: start;
    margin: clamp(2rem, 5vw, 3.5rem) 0;
}

@media (max-width: 860px) {
    .letter-studio {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Sheet first on mobile: it is the thing worth seeing. */
    .letter-preview {
        order: -1;
    }
}

/* ---------------------------------------------------------------- controls */

.letter-controls {
    display: grid;
    gap: 1rem;
}

.letter-controls .field {
    display: grid;
    gap: 0.4rem;
}

.letter-controls label {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--v2-gold-bright, #f2d69a);
}

.letter-controls input {
    width: 100%;
    min-height: 3rem;
    padding: 0.7rem 0.9rem;
    font-family: inherit;
    font-size: 1rem;
    color: var(--color-white, #fff);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.letter-controls input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.letter-controls input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--v2-gold, #d8ab5c);
}

.letter-controls input:focus-visible {
    outline: 2px solid var(--v2-gold-bright, #f2d69a);
    outline-offset: 2px;
}

/* ----------------------------------------------------------------- actions */

.letter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.letter-actions .button {
    flex: 1 1 auto;
    justify-content: center;
}

.letter-note {
    margin-top: 0.9rem;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.5;
}

/* ------------------------------------------------------------------- sheet */

.letter-preview {
    /* The gold frame reads as a mount around the paper rather than a border on it. */
    padding: clamp(0.5rem, 1.5vw, 1rem);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(216, 171, 92, 0.28);
    border-radius: 12px;
}

.letter__canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 210 / 297;
    background: #fff;
    border-radius: 3px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

/* --------------------------------------------------------------- fallback */

/* Only ever seen with JS off — the studio replaces it otherwise. */
.letter-fallback {
    margin: 1.5rem 0 0;
    padding: 1.5rem clamp(1rem, 3vw, 2rem);
    background: rgba(255, 255, 255, 0.04);
    border-left: 3px solid var(--v2-gold, #d8ab5c);
    border-radius: 0 10px 10px 0;
}

.letter-fallback p + p {
    margin-top: 0.9rem;
}

/* ------------------------------------------------------------------- print */

.sv-print-sheet {
    display: none;
}

@media print {
    /* Everything except the rendered sheet is display:none — see svPrintCanvas.
     * visibility:hidden would keep the layout boxes and eject a blank page. */
    body.sv-printing > *:not(.sv-print-sheet) {
        display: none !important;
    }

    body.sv-printing {
        background: #fff;
    }

    .sv-print-sheet {
        display: block;
    }

    .sv-print-sheet img {
        display: block;
        width: 210mm;
        max-width: 100%;
    }

    @page {
        size: A4 portrait;
        margin: 0;
    }
}
