/* Greeting card viewport fit. Loaded last so the card never needs a scrollbar. */

#messageBox {
    align-items: center !important;
    overflow: hidden !important;
}

#messageContent {
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    height: min(660px, calc(100dvh - 1.5rem)) !important;
    min-height: 0 !important;
    max-height: calc(100dvh - 1.5rem) !important;
    padding: clamp(1.15rem, 3dvh, 2.25rem) clamp(1.2rem, 3vw, 2.7rem);
    overflow: hidden !important;
    row-gap: clamp(0.35rem, 1.2dvh, 0.7rem);
}

#typedText {
    min-height: 0 !important;
    max-height: none !important;
    padding: clamp(0.65rem, 1.5dvh, 1rem) 1rem;
    overflow: visible !important;
    font-size: clamp(0.78rem, 1.6dvh, 0.96rem);
    line-height: 1.45;
}

.profile-photo {
    width: clamp(170px, 27dvh, 250px);
    height: clamp(205px, 34dvh, 305px);
}

.gift-gif-container {
    width: clamp(68px, 11dvh, 104px);
}

#title,
.neonTitle {
    font-size: clamp(2rem, 5.5dvh, 3.8rem) !important;
}

@media (max-width: 767px) {
    #messageBox {
        padding: 0.45rem;
    }

    #messageContent {
        display: grid !important;
        grid-template-columns: minmax(84px, 110px) minmax(0, 1fr) minmax(72px, 88px);
        grid-template-rows: auto auto auto minmax(0, 1fr) auto;
        gap: 0.36rem 0.42rem;
        width: 100%;
        height: min(650px, calc(100dvh - 0.9rem)) !important;
        max-height: calc(100dvh - 0.9rem) !important;
        margin: auto;
        padding: clamp(0.65rem, 2dvh, 0.9rem);
        overflow: hidden !important;
    }

    #title,
    .neonTitle {
        grid-column: 1 / -1;
        grid-row: 1;
        align-self: center;
        order: initial;
        margin: 0;
        font-size: clamp(1.55rem, 7vw, 2.25rem) !important;
        text-align: center;
    }

    .profile-container {
        grid-column: 1;
        grid-row: 2 / span 2;
        align-self: center;
        order: initial;
        margin: 0;
    }

    .profile-photo {
        width: clamp(90px, 27vw, 118px);
        height: clamp(108px, 32vw, 142px);
    }

    .name-under-photo {
        grid-column: 2;
        grid-row: 2;
        align-self: end;
        order: initial;
        margin: 0;
        font-size: clamp(1.02rem, 4.3vw, 1.22rem);
        text-align: left;
    }

    #timeWrapper {
        grid-column: 2;
        grid-row: 3;
        align-self: center;
        align-items: flex-start;
        order: initial;
        min-width: 0;
        width: 100%;
        margin: 0;
    }

    .birth-date,
    .birth-age {
        width: 100%;
        padding: 0;
        font-size: clamp(0.68rem, 2.7vw, 0.82rem) !important;
        line-height: 1.32;
        text-align: left;
    }

    .current-date {
        display: none;
    }

    .gift-gif-container {
        grid-column: 3;
        grid-row: 2 / span 2;
        align-self: center;
        justify-self: end;
        order: initial;
        width: clamp(70px, 19vw, 84px);
        margin: 0;
        padding: 4px;
        border-width: 2px;
        border-radius: 14px;
        background: #fff;
        box-shadow: 0 8px 0 rgba(95,118,179,0.34), 0 12px 20px rgba(5,9,31,0.2);
    }

    .gift-gif {
        border-radius: 8px;
    }

    .gift-gif-container figcaption {
        display: none;
    }

    #typedText {
        grid-column: 1 / -1;
        grid-row: 4;
        align-self: stretch;
        order: initial;
        min-height: 0 !important;
        margin: 0;
        padding: clamp(0.48rem, 1.5dvh, 0.7rem) 0.7rem;
        overflow: visible !important;
        font-size: clamp(0.78rem, 3vw, 0.95rem);
        line-height: 1.45;
    }

    #heartWrap {
        grid-column: 1;
        grid-row: 5;
        align-self: center;
        justify-self: center;
        order: initial;
        margin: 0;
    }

    .bigHeart {
        font-size: 1.45rem !important;
    }

    #messageContent > .btnRow {
        grid-column: 2;
        grid-row: 5;
        align-self: center;
        justify-content: flex-end;
        order: initial;
        width: 100%;
        margin: 0 !important;
        padding: 0;
    }

    #giftBtn {
        min-width: 0;
        min-height: 38px;
        padding: 0.48rem 0.8rem;
        font-size: clamp(0.7rem, 3.1vw, 0.86rem);
    }
}

@media (max-width: 767px) and (max-height: 620px) {
    #messageContent {
        gap: 0.22rem 0.55rem;
        padding: 0.55rem;
    }

    .gift-gif-container,
    #heartWrap {
        display: none !important;
    }

    #messageContent > .btnRow {
        grid-column: 1 / -1;
        justify-content: center;
    }

    #typedText {
        font-size: clamp(0.65rem, 2.4vw, 0.76rem);
        line-height: 1.3;
        min-height: 6.6em !important;
    }
}

@media (min-width: 768px) and (max-height: 620px) {
    #messageContent {
        height: calc(100dvh - 1rem) !important;
        max-height: calc(100dvh - 1rem) !important;
        padding-top: 0.8rem;
        padding-bottom: 0.8rem;
    }

    .profile-photo {
        width: 150px;
        height: 180px;
    }

    .gift-gif-container,
    #heartWrap {
        display: none !important;
    }

    #typedText {
        font-size: 0.74rem;
        line-height: 1.32;
    }
}
