/*
 * The letter to Ježíšek (Letter/default.latte): the form on the left, the sheet on the right (under each other on a phone), and the print styles that
 * leave nothing but the sheet on the paper.
 *
 * The sheet is sized in `cqw`, a hundredth of the width of its wrapper: whatever the width of the sheet is (the preview on a phone, a whole A4 on the
 * printer), the letter looks the same, only bigger or smaller. The wrapper is 210 mm wide in the print, so 1cqw = 2.1 mm there.
 */

.letter-page {
    display: grid;
    gap: 1.5rem;
    margin: 1rem 0 2rem;
}

@media (min-width: 992px) {
    .letter-page {
        grid-template-columns: minmax(0, 26rem) minmax(0, 1fr);
        align-items: start;
    }

    .letter-preview {
        position: sticky;
        top: 1rem;
    }
}

.letter-field {
    margin-bottom: .9rem;
}

.letter-field label,
.letter-person label,
.letter-designs legend {
    margin-bottom: .25rem;
    color: var(--brand);
    font-size: 1rem;
    font-weight: 700;
}

.letter-row {
    display: flex;
    gap: .75rem;
}

.letter-row .letter-field {
    flex: 1 1 auto;
}

.letter-row .letter-field-age {
    flex: 0 0 7.5rem;
}

.letter-person {
    margin-bottom: 1.1rem;
    padding: .8rem .9rem;
    border-radius: 12px;
    background: var(--yellow-light);
}

.letter-person-row {
    display: flex;
    gap: .5rem;
}

.letter-designs {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    margin: 0 0 1rem;
    padding: 0;
    border: 0;
}

.letter-designs legend {
    width: 100%;
    margin-bottom: 1rem;
}

.letter-design {
    margin: 0;
    cursor: pointer;
}

.letter-design input {
    position: absolute;
    opacity: 0;
}

.letter-design-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .3rem;
    padding: .4rem;
    border: 2px solid #d8d6cf;
    border-radius: 12px;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.letter-design input:focus-visible + .letter-design-card {
    outline: 3px solid #006aeb;
    outline-offset: 2px;
}

.letter-design input:checked + .letter-design-card {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(20, 50, 92, .2);
}

.letter-design-swatch {
    display: block;
    width: 3.6rem;
    height: 4.6rem;
    border: .35rem solid;
    border-radius: 4px;
}

.letter-design-card[data-design="vanocni"] .letter-design-swatch {
    border-color: #c0392b #1e7a4c #c0392b #1e7a4c;
    background: #fffdf5;
}

.letter-design-card[data-design="zimni"] .letter-design-swatch {
    border-color: #3b6ea5;
    background: linear-gradient(#f2f8ff, #dcebf8);
}

.letter-design-card[data-design="zlaty"] .letter-design-swatch {
    border-color: #c9a227;
    background: #fff9e6;
}

.letter-design-name {
    color: #333;
    font-size: .88rem;
    font-weight: 700;
}

.letter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.letter-text {
    max-width: 44rem;
}

/* ---- the sheet ---- */
.letter-wrap {
    container-type: inline-size;
    width: 100%;
    max-width: 38rem;
    margin: 0 auto;
}

.letter {
    position: relative;
    display: flex;
    flex-direction: column;
    aspect-ratio: 210 / 297;
    padding: 11cqw 12cqw 8cqw;
    overflow: hidden;
    background: #fffdf5;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
    color: #2b2b2b;
    font-family: 'Caveat', 'Segoe Print', 'Comic Sans MS', cursive;
    font-size: 3.7cqw;
    line-height: 1.25;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

/* the frame: drawn over the sheet, so every look has its own */
.letter::before {
    content: '';
    position: absolute;
    inset: 3cqw;
    pointer-events: none;
}

.letter[data-design="vanocni"]::before {
    border: 2.2cqw solid transparent;
    border-image: repeating-linear-gradient(45deg, #c0392b 0 2.2cqw, #fff 2.2cqw 4.4cqw, #1e7a4c 4.4cqw 6.6cqw, #fff 6.6cqw 8.8cqw) 1;
}

.letter[data-design="zimni"] {
    background:
        radial-gradient(circle, rgba(255, 255, 255, .95) 0 .45cqw, transparent .55cqw) 0 0 / 7cqw 7cqw,
        radial-gradient(circle, rgba(255, 255, 255, .8) 0 .3cqw, transparent .4cqw) 3.5cqw 3.5cqw / 7cqw 7cqw,
        linear-gradient(#eef6ff, #d6e8f8);
}

.letter[data-design="zimni"]::before {
    border: 1.6cqw double #3b6ea5;
    border-radius: 2cqw;
}

.letter[data-design="zlaty"] {
    background: radial-gradient(ellipse at 50% 0%, #fffbe9, #fff3cc);
}

.letter[data-design="zlaty"]::before {
    border: 1.4cqw double #c9a227;
    outline: .35cqw solid #c9a227;
    outline-offset: -3.4cqw;
}

.letter-ornaments {
    margin-bottom: 1.5cqw;
    font-size: 5cqw;
    letter-spacing: 1cqw;
    text-align: center;
}

.letter-hello {
    margin: 0 0 2cqw;
    color: #b3261e;
    font-family: var(--font-logo);
    font-size: 8.2cqw;
    font-weight: 400;
    line-height: 1.1;
    text-align: center;
}

.letter[data-design="zimni"] .letter-hello {
    color: #285d99;
}

.letter[data-design="zlaty"] .letter-hello {
    color: #8a6b00;
}

.letter-intro {
    margin: 0 0 2cqw;
    font-size: 4.2cqw;
}

.letter-intro b {
    font-weight: 700;
}

.letter-wishes {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0 0 2cqw;
    padding: 0;
    list-style: none;
    font-size: 4.3cqw;
    font-weight: 700;
    overflow: hidden;
}

.letter[data-density="dense"] .letter-wishes {
    font-size: 3.7cqw;
}

.letter[data-density="denser"] .letter-wishes {
    font-size: 3.2cqw;
    line-height: 1.15;
}

/* every wish on a ruled line, with a little heart in front */
.letter-wishes li {
    padding: .1em 0 .1em 1.5em;
    border-bottom: .25cqw dotted rgba(0, 0, 0, .35);
    background: none;
    position: relative;
}

.letter-wishes li::before {
    content: '♥';
    position: absolute;
    left: .15em;
    color: #e0245e;
}

.letter-wishes li.letter-wish-empty {
    border-bottom-color: rgba(0, 0, 0, .15);
    color: rgba(0, 0, 0, .35);
    font-weight: 400;
}

.letter-wishes li.letter-wish-empty::before {
    color: rgba(224, 36, 94, .3);
}

.letter-draw {
    display: flex;
    flex: 0 0 22%;
    align-items: center;
    justify-content: center;
    margin: 0 0 2cqw;
    border: .5cqw dashed rgba(0, 0, 0, .35);
    border-radius: 2cqw;
    color: rgba(0, 0, 0, .4);
    font-size: 3.4cqw;
}

.letter-draw[hidden],
.letter-promise[hidden],
.letter-signature[hidden] {
    display: none;
}

.letter-promise {
    margin: 0 0 1.5cqw;
    font-size: 3.6cqw;
    font-style: italic;
}

.letter-bye {
    margin: 0;
    font-size: 4cqw;
    text-align: center;
}

.letter-signature {
    margin: .5cqw 0 1.5cqw;
    font-size: 5.2cqw;
    font-weight: 700;
    text-align: right;
}

.letter-ornaments-bottom {
    margin: 1.5cqw 0 0;
}

.letter-brand {
    margin: 1cqw 0 0;
    color: rgba(0, 0, 0, .5);
    font-family: var(--font-body);
    font-size: 2.8cqw;
    text-align: center;
}

/* ---- the print: nothing but the sheet, on a whole A4 ---- */
@page {
    size: A4 portrait;
    margin: 0;
}

@media print {
    body {
        margin: 0 !important;
        padding: 0;
        max-width: none;
        background: #fff !important;
    }

    body > *:not(#content),
    #content > *:not(.letter-page),
    .letter-controls,
    .letter-text,
    .crumbs,
    #local-tape {
        display: none !important;
    }

    #content {
        padding: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        background: #fff;
    }

    .letter-page {
        display: block;
        margin: 0;
    }

    .letter-preview {
        position: static;
    }

    .letter-wrap {
        width: 210mm;
        max-width: none;
        margin: 0;
    }

    .letter {
        width: 210mm;
        height: 297mm;
        box-shadow: none;
        break-inside: avoid;
    }

    .letter-wish-empty {
        display: none;
    }
}
