@import url('https://fonts.googleapis.com/css2?family=Bagel+Fat+One&family=Nunito:wght@500;700;800&display=swap');

:root {
    --cream: #fff6ee;
    --blush: #ffd6de;
    --peach: #ffc4a3;
    --berry: #ff4f7b;
    --berry-deep: #d92a5c;
    --wine: #6d1b3a;
    --ink: #4a2233;
    --mint: #2f9e77;
    --shadow: 109 27 58;
    --display: 'Bagel Fat One', 'Trebuchet MS', sans-serif;
    --body: 'Nunito', 'Trebuchet MS', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
    margin: 0;
    min-height: 100%;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: var(--body);
    font-weight: 500;
    color: var(--ink);
    background:
        radial-gradient(60rem 40rem at 12% -10%, #fff1c9 0%, transparent 60%),
        radial-gradient(50rem 36rem at 105% 20%, #ffb7c9 0%, transparent 62%),
        radial-gradient(46rem 40rem at 30% 115%, var(--peach) 0%, transparent 60%),
        var(--blush);
    background-attachment: fixed;
    overflow-x: hidden;
}

/* drifting hearts behind everything */
.sky { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.sky span {
    position: absolute;
    bottom: -3rem;
    opacity: 0;
    animation: drift linear infinite;
    will-change: transform;
}
@keyframes drift {
    0% { transform: translate3d(0, 0, 0) rotate(-12deg); opacity: 0; }
    12% { opacity: var(--o, .5); }
    88% { opacity: var(--o, .5); }
    100% { transform: translate3d(var(--sway, 2rem), -112vh, 0) rotate(14deg); opacity: 0; }
}

main {
    position: relative;
    z-index: 1;
    flex: 1;
    width: 100%;
    display: grid;
    place-items: center;
    padding: clamp(2.25rem, 6vw, 3.5rem) 1rem 1rem;
}

/* the valentine card */
.card {
    position: relative;
    width: min(100%, 27rem);
    padding: clamp(1.5rem, 5vw, 2.25rem);
    text-align: center;
    background: var(--cream);
    border-radius: 2rem;
    box-shadow:
        0 1px 0 #fff inset,
        0 1.5rem 3rem -1rem rgb(var(--shadow) / .35),
        0 .4rem 0 #f3c3cf;
    transform: rotate(-1.2deg);
    animation: pop .7s cubic-bezier(.2, 1.4, .4, 1) both;
}
.card::before { /* stitched edge */
    content: '';
    position: absolute;
    inset: .6rem;
    border: 2px dashed #f6b9c8;
    border-radius: 1.5rem;
    pointer-events: none;
}
.card > * { position: relative; }
@keyframes pop {
    from { transform: rotate(-6deg) scale(.86) translateY(1.5rem); opacity: 0; }
    to { transform: rotate(-1.2deg) scale(1) translateY(0); opacity: 1; }
}

.card > .stamp {
    position: absolute;
    top: -1.4rem;
    right: 1.4rem;
    width: 3.6rem;
    height: 3.6rem;
    display: grid;
    place-items: center;
    font-size: 1.7rem;
    background: var(--berry);
    border-radius: 50%;
    box-shadow: 0 .35rem 0 var(--berry-deep), 0 .8rem 1.2rem -.4rem rgb(var(--shadow) / .5);
    transform: rotate(12deg);
    animation: beat 1.6s ease-in-out infinite;
}
@keyframes beat {
    0%, 100% { transform: rotate(12deg) scale(1); }
    12% { transform: rotate(12deg) scale(1.12); }
    24% { transform: rotate(12deg) scale(1); }
    36% { transform: rotate(12deg) scale(1.08); }
}

.gif {
    width: 9.5rem;
    height: 9.5rem;
    margin: 0 auto 1rem;
    border-radius: 1.5rem;
    overflow: hidden;
    background: var(--blush);
    box-shadow: 0 0 0 .3rem #fff, 0 .6rem 1.2rem -.4rem rgb(var(--shadow) / .4);
    transform: rotate(2.5deg);
}
.gif img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif.emoji { display: grid; place-items: center; font-size: 5.5rem; line-height: 1; animation: sob 2.4s ease-in-out infinite; }
@keyframes sob {
    0%, 100% { transform: rotate(2.5deg) translateY(0); }
    50% { transform: rotate(-2deg) translateY(.3rem); }
}

h1 {
    margin: 0 0 .5rem;
    font-family: var(--display);
    font-weight: 400;
    font-size: clamp(1.8rem, 7.5vw, 2.5rem);
    line-height: 1.08;
    color: var(--berry);
    text-wrap: balance;
    overflow-wrap: anywhere;
}
h1 em { font-style: normal; color: var(--wine); }

.lede { margin: 0 0 1.25rem; font-size: 1.05rem; text-wrap: pretty; }
.from { margin: .25rem 0 1rem; font-weight: 800; color: var(--wine); }

.note {
    margin: 0 0 1.25rem;
    padding: .9rem 1rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--wine);
    background: #ffe9ee;
    border-radius: 1rem;
    overflow-wrap: anywhere;
}
.note::before { content: '“'; }
.note::after { content: '”'; }

/* form */
form { display: grid; gap: .9rem; text-align: left; }
.field { display: grid; gap: .3rem; }
.field label { font-weight: 800; font-size: .95rem; color: var(--wine); }
.field small { font-weight: 500; opacity: .7; }
input[type="text"], textarea {
    width: 100%;
    padding: .8rem 1rem;
    font: inherit;
    font-weight: 700;
    color: var(--ink);
    background: #fff;
    border: 2px solid #f6c6d2;
    border-radius: 1rem;
    transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 4.5rem; }
input[type="text"]::placeholder, textarea::placeholder { color: #d9a9b6; font-weight: 500; }
input[type="text"]:focus, textarea:focus {
    outline: none;
    border-color: var(--berry);
    box-shadow: 0 0 0 .25rem rgb(255 79 123 / .2);
}

.toggle { display: flex; align-items: center; gap: .75rem; cursor: pointer; font-weight: 700; }
.toggle input { position: absolute; opacity: 0; }
.toggle .track {
    flex: none;
    width: 3rem;
    height: 1.75rem;
    padding: .2rem;
    background: #f1c5cf;
    border-radius: 2rem;
    transition: background .2s;
}
.toggle .track::after {
    content: '';
    display: block;
    width: 1.35rem;
    height: 1.35rem;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 .1rem .25rem rgb(var(--shadow) / .3);
    transition: transform .2s cubic-bezier(.3, 1.6, .5, 1);
}
.toggle input:checked + .track { background: var(--berry); }
.toggle input:checked + .track::after { transform: translateX(1.25rem); }
.toggle input:focus-visible + .track { box-shadow: 0 0 0 .25rem rgb(255 79 123 / .3); }

/* buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .85rem 1.4rem;
    font: inherit;
    font-weight: 800;
    font-size: 1.05rem;
    color: #fff;
    text-decoration: none;
    background: var(--berry);
    border: 0;
    border-radius: 1rem;
    box-shadow: 0 .3rem 0 var(--berry-deep);
    cursor: pointer;
    white-space: nowrap;
    transition: transform .12s, box-shadow .12s, background .15s;
    -webkit-tap-highlight-color: transparent;
}
.btn[hidden] { display: none; }
.btn:hover { background: #ff3f70; }
.btn:active { transform: translateY(.2rem); box-shadow: 0 .1rem 0 var(--berry-deep); }
.btn:focus-visible { outline: .2rem solid var(--wine); outline-offset: .15rem; }
.btn.ghost { color: var(--wine); background: #fff; box-shadow: 0 .3rem 0 #f1c5cf; }
.btn.ghost:hover { background: #fff0f3; }
.btn.ghost:active { box-shadow: 0 .1rem 0 #f1c5cf; }
.btn.done { background: var(--mint); box-shadow: 0 .3rem 0 #227a5b; }
.btn.wide { width: 100%; }

/* share result */
.result { display: grid; gap: .75rem; margin-top: 1.25rem; animation: pop-in .4s cubic-bezier(.2, 1.4, .4, 1) both; }
.result[hidden] { display: none; }
@keyframes pop-in { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.linkbox {
    padding: .75rem 1rem;
    font-size: .9rem;
    font-weight: 700;
    text-align: left;
    color: var(--wine);
    background: #fff;
    border: 2px dashed #f6b9c8;
    border-radius: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: all;
}
.row { display: flex; flex-wrap: wrap; gap: .6rem; }
.row .btn { flex: 1 1 7rem; }

/* ask page */
.answers {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    min-height: 4.5rem;
    margin-top: .5rem;
}
.answers .btn { flex: none; }
#yesButton { position: relative; z-index: 1; transition: transform .35s cubic-bezier(.3, 1.6, .5, 1), background .15s; }
#noButton {
    position: relative;
    z-index: 2;
    transition: transform .3s cubic-bezier(.3, 1.4, .5, 1), opacity .3s;
}
#noButton.gone { opacity: 0; pointer-events: none; }
.hint { min-height: 1.4em; margin: .9rem 0 0; font-weight: 700; color: var(--wine); }

/* the no page: same card, at night, in the rain */
body.sad {
    --cream: #262936;
    --blush: #1c1e29;
    --berry: #8d93ab;
    --berry-deep: #14151d;
    --wine: #c3c7d6;
    --ink: #9498ab;
    --shadow: 0 0 0;
    background:
        radial-gradient(50rem 30rem at 50% -20%, #2f3447 0%, transparent 65%),
        linear-gradient(#161821, #0e0f15);
    background-attachment: fixed;
}
body.sad main { filter: saturate(.35); }
body.sad .card {
    box-shadow: 0 1px 0 #343849 inset, 0 2rem 4rem -1rem rgb(0 0 0 / .8), 0 .4rem 0 #14151d;
    transform: rotate(2.2deg);
    animation: sink 2.4s cubic-bezier(.3, 0, .2, 1) both, sway 9s ease-in-out 2.4s infinite;
}
@keyframes sink {
    from { transform: rotate(-1.2deg) translateY(-2rem); opacity: 0; }
    to { transform: rotate(2.2deg) translateY(0); opacity: 1; }
}
@keyframes sway {
    0%, 100% { transform: rotate(2.2deg) translateY(0); }
    50% { transform: rotate(1.4deg) translateY(.5rem); }
}
body.sad .card::before { border-color: #3a3e50; }
body.sad .card > .stamp { /* no heartbeat */
    background: #3a3e50;
    box-shadow: 0 .35rem 0 #14151d;
    animation: none;
    transform: rotate(28deg) translateY(.4rem);
}
body.sad .gif { background: #1c1e29; box-shadow: 0 0 0 .3rem #343849, 0 .6rem 1.2rem -.4rem #000; }
body.sad h1 { color: var(--wine); }
body.sad h1 em { color: var(--berry); }
body.sad .lede { min-height: 3.2em; margin-bottom: .75rem; transition: opacity .8s; }
body.sad .lede.fading { opacity: 0; }
body.sad .btn.ghost { color: #7d8196; background: transparent; border: 1px solid #3a3e50; box-shadow: none; font-size: .9rem; font-weight: 700; }
body.sad .btn.ghost:hover { color: var(--wine); background: #2d3040; }
body.sad footer { color: #5d6174; }

.since { margin: 0 0 1.25rem; font-size: .85rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #6d7186; }
.since b { font-variant-numeric: tabular-nums; color: var(--wine); }

.rain { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.rain span {
    position: absolute;
    top: -20vh;
    width: 1px;
    height: 14vh;
    background: linear-gradient(transparent, rgb(170 180 210 / .35));
    animation: pour linear infinite;
    will-change: transform;
}
@keyframes pour {
    to { transform: translate3d(-6vh, 130vh, 0); }
}

.confetti { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 2; }
.confetti span {
    position: absolute;
    top: -3rem;
    animation: fall linear forwards;
    will-change: transform;
}
@keyframes fall {
    to { transform: translate3d(var(--sway, 0), 112vh, 0) rotate(var(--spin, 360deg)); }
}

footer {
    position: relative;
    z-index: 1;
    padding: 1rem 1rem 1.25rem;
    font-size: .9rem;
    font-weight: 700;
    text-align: center;
    color: var(--wine);
}
footer a { color: inherit; text-underline-offset: .2em; }
footer a:hover { color: var(--berry); }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    .sky, .confetti, .rain { display: none; }
}
