/* Contact page: an interactive paper envelope, isolated from the other tools. */
.contact-page *,
.contact-page *::before,
.contact-page *::after {
    box-sizing: border-box;
}

.contact-page {
    overflow-x: hidden;
    color: #293846;
    background:
        radial-gradient(circle at 10% 18%, rgb(214 177 144 / 14%) 0 8rem, transparent 8.1rem),
        radial-gradient(circle at 92% 75%, rgb(103 133 151 / 10%) 0 11rem, transparent 11.1rem),
        #f7f1e8;
}

.contact-page main {
    width: min(90%, 1500px);
    max-width: 1500px;
    padding: 1.35rem 0 1.6rem;
}

.contact-page .page-intro {
    max-width: none;
    margin-bottom: 1rem;
}

.contact-page .page-intro .eyebrow {
    margin: 0 0 .1rem;
    color: #59636f;
    font-size: .82rem;
}

.contact-page .page-intro h1 {
    margin-bottom: .35rem;
    color: #253442;
    font-size: 2.35rem;
}

.contact-page .page-intro > p:last-child {
    margin: 0;
    color: #635a52;
    font-size: .9rem;
}

.contact-page .contact-layout {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr);
    align-items: stretch;
    gap: 1.1rem;
    transition: grid-template-columns .5s ease;
}

.contact-page .contact-layout:not(.is-open) {
    grid-template-columns: minmax(0, 1fr);
    justify-content: center;
}

.envelope-panel,
.contact-page .contact-form-card {
    min-width: 0;
    border: 1px solid #dfcfbf;
    border-radius: .55rem;
    box-shadow: 0 18px 42px rgb(82 59 41 / 10%);
}

.envelope-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.1rem 1.3rem 1rem;
    overflow: hidden;
    text-align: center;
    background:
        linear-gradient(90deg, transparent 49.8%, rgb(154 116 82 / 6%) 50%, transparent 50.2%),
        linear-gradient(#fffdf8, #f3e8da);
}

.contact-layout:not(.is-open) .envelope-panel {
    min-height: 490px;
    padding: 1.25rem 1.5rem 1rem;
    overflow: visible;
    border-color: transparent;
    box-shadow: none;
    background: transparent;
}

.envelope-kicker {
    margin: 0 0 .18rem;
    color: #a15f49;
    font-size: .69rem;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.envelope-panel h2 {
    margin: 0;
    color: #2f4150;
    font-size: clamp(1.4rem, 2.3vw, 1.9rem);
    letter-spacing: -.035em;
}

.envelope-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: .18rem .42rem;
    margin: .5rem 0 0;
    color: #756b62;
    font-size: .7rem;
    line-height: 1.35;
    white-space: nowrap;
}

.envelope-hint a {
    color: #3d5668;
    font-weight: 700;
    text-underline-offset: .15rem;
}

.email-label {
    color: #8b796b;
    font-size: .64rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.envelope-kicker,
.envelope-panel h2,
.envelope-hint {
    transition: opacity .2s ease, visibility .2s ease;
}

.contact-layout.is-open .envelope-kicker,
.contact-layout.is-open .envelope-panel > h2,
.contact-layout.is-open .envelope-hint {
    visibility: hidden;
    opacity: 0;
}

.envelope-ribbons {
    position: absolute;
    inset: 0;
    z-index: 8;
    pointer-events: none;
    transition: opacity .2s ease, visibility .2s ease;
}

.envelope-ribbon {
    position: absolute;
    padding: .38rem .85rem;
    color: #fffdf8;
    clip-path: polygon(7% 0, 100% 0, 93% 50%, 100% 100%, 7% 100%, 0 50%);
    box-shadow: 0 7px 16px rgb(83 57 39 / 16%);
    font-family: Georgia, serif;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .025em;
}

.envelope-ribbon--questions {
    top: 53%;
    left: 3%;
    background: #72899a;
    font-size: .8rem;
    transform: rotate(-7deg);
    --float-duration: 4.1s;
    --float-delay: -1.8s;
    --float-y: -8px;
}

.envelope-ribbon--ideas {
    top: 54%;
    right: 3%;
    background: #b38355;
    font-size: .72rem;
    transform: rotate(7deg);
    --float-duration: 5.2s;
    --float-delay: -3.2s;
    --float-y: -12px;
}

.envelope-ribbon--feedback {
    right: 10%;
    bottom: 10%;
    background: #a56560;
    font-size: .86rem;
    transform: rotate(-5deg);
    --float-duration: 4.7s;
    --float-delay: -2.3s;
    --float-y: -9px;
}

.contact-layout.is-open .envelope-ribbons {
    visibility: hidden;
    opacity: 0;
}

.envelope-ribbon--note {
    top: 10%;
    left: 3%;
    color: #fff8ef;
    background: #a56560;
    font-size: .88rem;
    transform: rotate(-9deg);
    --float-duration: 5.1s;
    --float-delay: -1.1s;
    --float-y: -10px;
}

.envelope-ribbon--open {
    top: 12%;
    right: 5%;
    color: #fffaf0;
    background: #72899a;
    font-size: .8rem;
    transform: rotate(4deg);
    --float-duration: 4.4s;
    --float-delay: -3.6s;
    --float-y: -11px;
}

.envelope-decor {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    transition: opacity .2s ease, visibility .2s ease;
}

.mini-envelope {
    position: absolute;
    display: block;
    width: 3.8rem;
    height: 2.55rem;
    background: #f1c19d;
    border: 2px solid #9f6347;
    border-radius: .3rem;
    box-shadow: 0 8px 14px rgb(92 57 39 / 15%);
}

.envelope-ribbon,
.mini-envelope {
    animation: float-contact-decor var(--float-duration, 4.6s) ease-in-out infinite;
    animation-delay: var(--float-delay, 0s);
}

.mini-envelope::before {
    position: absolute;
    inset: 0;
    content: "";
    background: #e6aa82;
    clip-path: polygon(0 0, 100% 0, 50% 62%);
}

.mini-envelope::after {
    position: absolute;
    right: 13%;
    bottom: 14%;
    left: 13%;
    height: 1px;
    content: "";
    background: #a86a4d;
    box-shadow: 0 -4px 0 rgb(168 106 77 / 45%);
}

.mini-envelope--one {
    top: 31%;
    left: 12%;
    transform: rotate(-9deg);
    --decor-size: 1.12;
    --float-duration: 4.3s;
    --float-delay: -1.5s;
    --float-y: -12px;
}

.mini-envelope--two {
    top: 32%;
    right: 7%;
    transform: rotate(8deg);
    --decor-size: .94;
    --float-duration: 5s;
    --float-delay: -3.1s;
    --float-y: -9px;
}

.mini-envelope--three {
    left: 5%;
    bottom: 10%;
    transform: rotate(-7deg);
    --decor-size: .82;
    --float-duration: 3.9s;
    --float-delay: -2.4s;
    --float-y: -10px;
}

@keyframes float-contact-decor {
    0%, 100% {
        translate: 0 0;
        scale: var(--decor-size, 1);
    }
    50% {
        translate: 0 var(--float-y, -10px);
        scale: calc(var(--decor-size, 1) * 1.08);
    }
}

.contact-layout.is-open .envelope-decor {
    visibility: hidden;
    opacity: 0;
}

.envelope-button {
    position: relative;
    z-index: 3;
    width: 100%;
    max-width: 430px;
    padding: 0;
    color: inherit;
    background: transparent;
    border: 0;
    border-radius: .5rem;
}

.contact-layout:not(.is-open) .envelope-button {
    max-width: min(580px, 56%);
}

.contact-layout.is-open .envelope-button {
    transform: translateY(2.5rem);
}

.envelope-button:hover {
    background: transparent;
}

.envelope {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 1.75 / 1;
    perspective: 1100px;
    filter: drop-shadow(0 14px 13px rgb(86 55 35 / 17%));
    transform: translateY(0) scale(.92);
    transform-origin: center bottom;
    transition: transform .3s ease;
}

.envelope-button:hover .envelope,
.envelope-button:focus-visible .envelope {
    transform: translateY(-3px) scale(.94);
}

.contact-layout:not(.is-open) .envelope {
    transform: scale(.98);
}

.contact-layout:not(.is-open) .envelope-button:hover .envelope,
.contact-layout:not(.is-open) .envelope-button:focus-visible .envelope {
    transform: translateY(-4px) scale(1);
}

.envelope-back {
    position: absolute;
    inset: 14% 3% 3%;
    z-index: 1;
    background: #d9a77d;
    border: 3px solid #965d3f;
    border-radius: 6px;
}

.envelope-letter {
    position: absolute;
    right: 11%;
    bottom: 9%;
    left: 11%;
    z-index: 2;
    height: 68%;
    padding: 1.1rem 1.2rem;
    color: #31485a;
    background:
        repeating-linear-gradient(180deg, transparent 0 31px, rgb(99 128 146 / 9%) 31px 32px),
        #fffdf7;
    border: 1px solid #d8c8b8;
    border-radius: 5px 5px 2px 2px;
    box-shadow: 0 -4px 15px rgb(77 50 33 / 8%);
    text-align: left;
    transition: transform .65s cubic-bezier(.22, .8, .24, 1), box-shadow .65s ease;
}

.letter-mark {
    display: block;
    margin-bottom: .2rem;
    color: #ae694f;
    font-size: .63rem;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.letter-title {
    display: block;
    margin-bottom: .8rem;
    font-family: Georgia, serif;
    font-size: clamp(1.2rem, 3vw, 1.75rem);
    font-style: italic;
    font-weight: 700;
}

.letter-line {
    display: block;
    width: 75%;
    height: 2px;
    margin-top: .55rem;
    background: #d7d9d5;
}

.letter-line-short {
    width: 48%;
}

.envelope-front-left,
.envelope-front-right,
.envelope-front-bottom {
    position: absolute;
    inset: 14% 3% 3%;
    z-index: 4;
    pointer-events: none;
    filter: drop-shadow(0 0 1.1px rgb(143 83 54 / 84%));
}

.envelope-front-left {
    background: linear-gradient(135deg, #efc7a4, #db9f75);
    clip-path: polygon(0 0, 51% 51%, 0 100%);
}

.envelope-front-right {
    background: linear-gradient(225deg, #edc19c, #d89a70);
    clip-path: polygon(100% 0, 49% 51%, 100% 100%);
}

.envelope-front-bottom {
    background: linear-gradient(0deg, #e5ad82, #f0c9a6);
    clip-path: polygon(0 100%, 50% 38%, 100% 100%);
    border-bottom: 3px solid #965d3f;
    border-radius: 0 0 6px 6px;
}

.envelope-flap {
    position: absolute;
    top: 14%;
    right: 3%;
    left: 3%;
    z-index: 6;
    height: 50%;
    background: linear-gradient(180deg, #f2caaa, #dfaa83);
    border-top: 3px solid #965d3f;
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    transform: rotateX(0deg);
    transform-origin: top center;
    transition: transform .55s cubic-bezier(.4, 0, .2, 1), z-index 0s linear .28s;
}

.envelope-flap::before,
.envelope-flap::after {
    position: absolute;
    top: 0;
    width: 58%;
    height: 3px;
    content: "";
    background: rgb(135 76 46 / 84%);
    box-shadow: 0 -2px 3px rgb(92 49 31 / 35%);
}

.envelope-flap::before {
    left: 0;
    transform: rotate(31deg);
    transform-origin: left center;
}

.envelope-flap::after {
    right: 0;
    transform: rotate(-31deg);
    transform-origin: right center;
}

.contact-layout.is-open .envelope-flap {
    z-index: 1;
    transform: rotateX(180deg);
}

.contact-layout.is-open .envelope-letter {
    transform: translateY(-47%);
    box-shadow: 0 -12px 22px rgb(77 50 33 / 14%);
}

.envelope-action {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    margin-top: -.1rem;
    padding: .45rem .75rem;
    color: #6c4335;
    background: #fffaf3;
    border: 1px solid #dfc8b4;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 750;
    transition: color .2s ease, background .2s ease;
}

.envelope-button:hover .envelope-action {
    color: #fff;
    background: #a85e49;
}

.envelope-action-icon {
    font-size: 1rem;
    transition: rotate .3s ease;
}

.contact-layout.is-open .envelope-action-icon {
    rotate: 135deg;
}

.envelope-address {
    margin-top: .6rem;
    font-style: normal;
    line-height: 1.35;
}

.envelope-address span {
    display: block;
    color: #8b796b;
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.envelope-address a {
    color: #3d5668;
    font-size: .79rem;
    font-weight: 700;
    text-underline-offset: .18rem;
}

.contact-page .contact-form-card {
    padding: 1.15rem 1.35rem 1rem;
    background: #fffdf9;
    border-color: #dfcfbf;
}

.contact-page .contact-form-card[hidden] {
    display: none;
}

@media (min-width: 901px) and (min-height: 721px) {
    .contact-layout.is-open > .envelope-panel,
    .contact-layout.is-open > .contact-form-card {
        min-height: 440px;
    }
}

.contact-page .contact-form-card.is-revealed {
    animation: reveal-letter-form .48s ease both;
}

@keyframes reveal-letter-form {
    from { opacity: 0; transform: translateX(22px); }
    to { opacity: 1; transform: translateX(0); }
}

.contact-page .contact-form-card h2 {
    margin: 0 0 .2rem;
    color: #2d4151;
    font-size: 1.45rem;
    letter-spacing: -.025em;
}

.form-intro {
    margin: 0 0 .65rem;
    color: #796e64;
    font-size: .75rem;
    line-height: 1.45;
}

.contact-page #contact-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .45rem .7rem;
}

.contact-page .form-group {
    min-width: 0;
    margin: 0;
}

.contact-page .form-group:nth-child(n + 3) {
    grid-column: 1 / -1;
}

.contact-page .form-group label {
    margin-bottom: .15rem;
    color: #465867;
    font-size: .72rem;
    font-weight: 700;
}

.contact-page #contact-form input,
.contact-page #contact-form textarea {
    width: 100%;
    padding: .5rem .65rem;
    color: #2d3e4b;
    background: #fffdfa;
    border: 1px solid #d9cbbb;
    border-radius: .32rem;
    font-size: .84rem;
    line-height: 1.3;
}

.contact-page #contact-form input {
    height: 2.25rem;
}

.contact-page #contact-form textarea {
    display: block;
    min-height: 4.7rem;
    max-height: 9rem;
    resize: vertical;
}

.contact-page #contact-form input:focus,
.contact-page #contact-form textarea:focus {
    background: #fff;
    border-color: #a86a52;
}

.contact-page #contact-form button {
    grid-column: 1 / -1;
    justify-self: start;
    min-width: 8.5rem;
    min-height: 2.25rem;
    padding: .45rem 1rem;
    color: #fff;
    background: #3e586c;
    border-radius: .32rem;
    font-size: .8rem;
    transition: background .2s ease, transform .2s ease;
}

.contact-page #contact-form button:hover {
    transform: translateY(-1px);
    background: #2e4658;
}

.contact-page .contact-note {
    margin: .55rem 0 0;
    padding-top: .45rem;
    color: #82766c;
    border-top: 1px solid #eadfd4;
    font-size: .68rem;
}

@media (min-width: 901px) and (max-height: 720px) {
    .contact-page main { padding-bottom: .65rem; }
    .contact-page .page-intro { margin-bottom: .65rem; }
    .envelope-panel { padding-top: .75rem; padding-bottom: .65rem; }
    .contact-layout:not(.is-open) .envelope-panel { min-height: calc(100vh - 260px); }
    .contact-layout.is-open .envelope { width: min(100%, 360px); }
    .contact-page .site-footer { padding-top: .75rem; padding-bottom: .75rem; }
}

@media (max-width: 900px) {
    .contact-page .contact-layout,
    .contact-page .contact-layout:not(.is-open) {
        grid-template-columns: 1fr;
    }

    .contact-page .contact-form-card {
        order: 2;
        width: 100%;
    }

    .envelope-panel { min-height: 420px; }
}

@media (max-width: 620px) {
    .contact-page main { width: min(92%, 1500px); }
    .contact-page .page-intro { margin-bottom: .8rem; }
    .envelope-panel { min-height: 350px; padding: .9rem .6rem .75rem; }
    .envelope-button { max-width: 360px; }
    .envelope { transform: scale(.9); }
    .envelope-button:hover .envelope,
    .envelope-button:focus-visible .envelope { transform: translateY(-2px) scale(.92); }

    .contact-layout.is-open .envelope-letter {
        transform: translateY(-30%);
    }

    .contact-layout:not(.is-open) .envelope-panel {
        min-height: 390px;
        padding-inline: .7rem;
        overflow: hidden;
    }

    .envelope-ribbon {
        padding: .3rem .58rem;
        font-size: .66rem;
    }

    .envelope-ribbon--note,
    .envelope-ribbon--open { display: none; }
    .envelope-ribbon--questions { top: 14%; left: 4%; }
    .envelope-ribbon--ideas { top: 14%; right: 4%; }
    .envelope-ribbon--feedback { display: none; }

    .contact-layout:not(.is-open) .envelope-button { max-width: 360px; }
    .mini-envelope--one { top: 1.5rem; left: calc(50% - 1.9rem); }
    .mini-envelope--two { top: auto; right: 4%; bottom: 1.5rem; }
    .mini-envelope--three { left: 4%; bottom: 1.5rem; }

    .envelope-hint { white-space: normal; }

    .contact-page .page-intro > p:last-child {
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

@media (max-width: 560px) {
    .contact-page main { padding-top: .8rem; }
    .contact-page #contact-form { grid-template-columns: 1fr; }
    .contact-page .form-group { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
    .envelope,
    .envelope-letter,
    .envelope-flap,
    .envelope-ribbons,
    .envelope-action-icon,
    .contact-page #contact-form button { transition: none; }
    .contact-page .contact-form-card.is-revealed,
    .envelope-ribbon,
    .mini-envelope { animation: none; }
    .mini-envelope { scale: var(--decor-size, 1); }
}
