/* =====================================================================
   A bouquet for her - styles for both pages
   ===================================================================== */
@font-face { font-family: 'Playfair Display'; font-style: italic; font-weight: 500 700; font-display: swap; src: url(../fonts/playfair-italic.woff2) format('woff2'); }
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 400 800; font-display: swap; src: url(../fonts/nunito.woff2) format('woff2'); }
@font-face { font-family: 'Scheherazade New'; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/scheherazade-arabic.woff2) format('woff2'); }
@font-face { font-family: 'Caveat'; font-style: normal; font-weight: 500 700; font-display: swap; src: url(../fonts/caveat.woff2) format('woff2'); }

:root {
  --ink: #4a2a3a;
  --muted: #8b6676;
  --rose: #e0527f;
  --rose-deep: #c93a6b;
  --blush: #fde7ea;
  --cream: #fff8f2;
  --card: rgba(255, 255, 255, .72);
  --line: rgba(201, 58, 107, .16);
  --shadow: 0 24px 60px rgba(176, 72, 108, .18);
  --serif: 'Playfair Display', 'Georgia', serif;
  --sans: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --hand: 'Caveat', 'Segoe Print', 'Bradley Hand', cursive;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100svh; color: var(--ink); font-family: var(--sans); line-height: 1.5;
  background:
    radial-gradient(1100px 700px at 22% 18%, #fffaf6 0%, rgba(255, 250, 246, 0) 60%),
    radial-gradient(900px 700px at 90% 90%, #f9d3e0 0%, rgba(249, 211, 224, 0) 62%),
    linear-gradient(160deg, #fff3ee 0%, #fde4e8 55%, #f7d6e6 100%);
  background-color: #fde7ea;
  overflow-x: hidden;
}
body.leaving { opacity: 0; transition: opacity .55s ease; }

/* ---------- drifting petals ---------- */
.petals { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.petals i {
  position: absolute; top: -8vh; left: var(--x); width: var(--s); height: calc(var(--s) * 1.3);
  background: linear-gradient(140deg, var(--c1), var(--c2)); opacity: .0;
  border-radius: 100% 0 100% 0; will-change: transform, opacity;
  animation: drift var(--t) linear var(--d) infinite;
}
@keyframes drift {
  0%   { transform: translate3d(0, 0, 0) rotate(0); opacity: 0; }
  8%   { opacity: .75; }
  50%  { transform: translate3d(calc(var(--sw) * 1px), 55vh, 0) rotate(200deg); }
  92%  { opacity: .6; }
  100% { transform: translate3d(calc(var(--sw) * -.6px), 112vh, 0) rotate(420deg); opacity: 0; }
}

/* ---------- layout ---------- */
.stage {
  position: relative; z-index: 1; width: 100%; max-width: 1260px; margin: 0 auto; min-height: 100svh;
  padding: 28px clamp(16px, 4.5vw, 64px); display: grid; align-content: center; justify-content: stretch;
  column-gap: clamp(20px, 4vw, 64px);
  grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr);
  grid-template-areas: "visual head" "visual picker";
}
.head { grid-area: head; align-self: end; padding-bottom: 14px; }
.visual { grid-area: visual; align-self: center; display: flex; justify-content: center; }
.picker, .letter-col { grid-area: picker; align-self: start; }

.eyebrow { margin: 0 0 8px; font-weight: 800; font-size: clamp(.92rem, 1.5vw, 1.05rem); line-height: 1.4; letter-spacing: .01em; color: var(--rose-deep); }
.title { margin: 0; font-family: var(--serif); font-style: italic; font-weight: 600; font-size: clamp(2rem, 4.6vw, 3.4rem); line-height: 1.08; }
.subtitle { margin: 12px 0 0; color: var(--muted); font-size: 1.04rem; max-width: 34em; }

/* ---------- the bouquet ---------- */
.bouquet-wrap { position: relative; width: min(100%, calc(84svh * 600 / 730)); aspect-ratio: 600 / 730; }
.bouquet-wrap::before {
  content: ''; position: absolute; inset: 2% -6% 18% -6%; border-radius: 50%; z-index: 0;
  background: radial-gradient(closest-side, rgba(255, 255, 255, .95), rgba(255, 255, 255, .55) 55%, rgba(255, 255, 255, 0) 100%);
}
.bouquet-wrap svg { position: relative; z-index: 1; width: 100%; height: 100%; display: block; overflow: visible; }

/* ---------- picker ---------- */
.card { background: rgba(255, 255, 255, .84); border: 1px solid rgba(255, 255, 255, .8); border-radius: 28px; box-shadow: var(--shadow); padding: clamp(16px, 2.4vw, 26px); }
.label { margin: 0 0 12px; font-size: .95rem; font-weight: 800; letter-spacing: .02em; }
.chips { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.chip {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 8px;
  border: 1.5px solid transparent; border-radius: 18px; background: rgba(255, 255, 255, .55); cursor: pointer;
  font: inherit; color: var(--ink); transition: transform .18s ease, background .2s, border-color .2s, box-shadow .2s;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover { transform: translateY(-2px); background: #fff; }
.chip:focus-visible { outline: 3px solid rgba(224, 82, 127, .45); outline-offset: 2px; }
.chip .icon { width: clamp(38px, 5.4vw, 54px); height: clamp(38px, 5.4vw, 54px); display: block; opacity: .85; transition: opacity .2s, transform .25s; }
.chip .nm { font-size: clamp(.68rem, 1.3vw, .8rem); font-weight: 700; line-height: 1.1; }
.chip[aria-pressed="true"] { background: #fff; border-color: var(--rose); box-shadow: 0 8px 20px rgba(201, 58, 107, .16); }
.chip[aria-pressed="true"] .icon { opacity: 1; transform: scale(1.06); }
.chip.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }

.mix { margin-top: 16px; }
.bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: rgba(139, 102, 118, .12); gap: 2px; }
.bar i { display: block; height: 100%; flex: 1 1 0; background: var(--c); transition: flex .4s ease; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 10px 0 0; padding: 0; list-style: none; font-size: .85rem; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend b { color: var(--ink); font-weight: 800; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.count { margin: 8px 0 0; font-size: .85rem; color: var(--muted); }
.hint { min-height: 1.3em; margin: 6px 0 0; font-size: .82rem; font-weight: 700; color: var(--rose-deep); opacity: 0; transition: opacity .25s; }
.hint.show { opacity: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; border: 0; cursor: pointer; font: inherit; font-weight: 800;
  border-radius: 999px; padding: 15px 30px; color: #fff; font-size: 1.05rem; text-decoration: none;
  background: linear-gradient(135deg, #f0709a, #d93f74); box-shadow: 0 14px 30px rgba(217, 63, 116, .38), inset 0 1px 0 rgba(255, 255, 255, .45);
  transition: transform .18s ease, box-shadow .2s ease, filter .2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 18px 36px rgba(217, 63, 116, .45), inset 0 1px 0 rgba(255, 255, 255, .45); }
.btn:active { transform: translateY(0) scale(.98); }
.btn:focus-visible { outline: 3px solid rgba(224, 82, 127, .5); outline-offset: 3px; }
.btn[disabled] { opacity: .7; pointer-events: none; }
.btn svg { width: 20px; height: 20px; }
.btn.ghost { background: rgba(255, 255, 255, .75); color: var(--rose-deep); box-shadow: 0 6px 16px rgba(176, 72, 108, .14); padding: 12px 22px; font-size: .95rem; }
.save-row { margin-top: 16px; }
.save-row .btn { width: 100%; }

/* ---------- the saved page: the letter ---------- */
.letter {
  position: relative; background: #fffaf2; border-radius: 6px 22px 22px 22px; padding: clamp(20px, 3vw, 34px) clamp(22px, 3.4vw, 40px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .02), 0 24px 56px rgba(150, 70, 96, .2); transform: rotate(-.7deg);
  background-image: repeating-linear-gradient(transparent 0 35px, rgba(224, 82, 127, .09) 35px 36px);
  opacity: 0; animation: letterIn .9s ease 1.6s forwards;
}
.letter::before { content: ''; position: absolute; top: -14px; left: 50%; width: 110px; height: 26px; margin-left: -55px; background: rgba(240, 168, 190, .55); transform: rotate(-2deg); border-radius: 3px; }
@keyframes letterIn { from { opacity: 0; transform: translateY(18px) rotate(-.7deg); } to { opacity: 1; transform: rotate(-.7deg); } }
.letter p { margin: 0 0 14px; font-family: var(--hand); font-size: clamp(1.4rem, 2.5vw, 1.75rem); line-height: 1.28; font-weight: 500; }
.letter .greet { font-size: clamp(1.7rem, 3vw, 2.2rem); font-weight: 700; color: var(--rose-deep); }
.letter .closing { font-weight: 700; font-size: clamp(1.7rem, 3vw, 2.1rem); margin-top: 18px; }
.letter .sign { margin: 0; color: var(--rose-deep); }
.w { opacity: 0; display: inline-block; white-space: pre; animation: wordIn .8s ease forwards; animation-delay: calc(2.1s + var(--n) * 62ms); }
@keyframes wordIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* ---------- the "save as picture" window ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(74, 42, 58, .68); animation: fadeIn .25s ease; }
.sheet[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }
.sheet-card { display: flex; flex-direction: column; align-items: center; gap: 12px; max-height: 100%; max-width: 100%; padding: 14px; border-radius: 26px; background: #fff7f9; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); animation: pop .35s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
.sheet-card img { display: block; max-width: 100%; max-height: calc(100svh - 190px); width: auto; height: auto; border-radius: 16px; box-shadow: 0 8px 28px rgba(150, 70, 96, .25); -webkit-touch-callout: default; }
.sheet-hint { margin: 0; font-size: .82rem; color: var(--muted); text-align: center; }
.sheet-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.sheet-actions .btn { padding: 12px 24px; font-size: .98rem; }

/* ---------- the verse card ---------- */
.verse {
  position: relative; margin-top: 26px; padding: 22px clamp(18px, 3vw, 34px) 20px; text-align: center; border-radius: 26px;
  background: radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, .95), rgba(255, 238, 243, .78));
  border: 1px solid rgba(200, 150, 80, .38); box-shadow: 0 0 0 5px rgba(255, 255, 255, .45), 0 20px 46px rgba(176, 72, 108, .16);
  opacity: 0; animation: letterIn 1.1s ease var(--verse-delay, 6s) forwards;
}
.verse[hidden] { display: none; }
.verse .orn-row { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 4px; }
.verse .orn-row span { flex: 1; max-width: 90px; height: 1px; background: linear-gradient(90deg, transparent, rgba(200, 150, 80, .7)); }
.verse .orn-row span:last-child { transform: scaleX(-1); }
.verse .orn { width: 34px; height: 34px; fill: none; stroke: #c99a4b; stroke-width: 1.4; animation: spinSlow 24s linear infinite; }
.verse .orn circle { fill: #e0527f; stroke: none; }
@keyframes spinSlow { to { transform: rotate(360deg); } }
.verse .ar {
  margin: 8px 0 6px; font-family: 'Scheherazade New', 'Noto Naskh Arabic', 'Traditional Arabic', serif; font-size: clamp(2.3rem, 5.2vw, 3.4rem);
  line-height: 2; font-weight: 400; color: #6e2a4b; text-shadow: 0 2px 18px rgba(224, 82, 127, .28);
  background: linear-gradient(100deg, #7a2f52 0%, #c0396b 50%, #b0803a 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.verse .tr { margin: 0; font-family: var(--serif); font-style: italic; font-size: clamp(1.05rem, 2vw, 1.25rem); color: var(--rose-deep); }
.verse .en { margin: 6px 0 0; font-size: clamp(.98rem, 1.8vw, 1.1rem); color: var(--ink); }
.verse .ref { margin: 10px 0 0; font-size: .74rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: #b0803a; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; opacity: 0; animation: letterIn .8s ease forwards; animation-delay: var(--actions-delay, 8s); }
.letter-col { grid-area: picker; }

/* =====================================================================
   BOUQUET ANIMATION (all driven from the classes bouquet.js sets)
   ===================================================================== */
/* the gentle sway is done on the whole <svg> (one GPU layer), not on thousands of SVG shapes */
.bouquet-wrap svg { transform-origin: 50% 100%; will-change: transform; animation: sway 7.5s ease-in-out infinite alternate; }
@keyframes sway { from { transform: rotate(-1deg); } to { transform: rotate(1.1deg); } }

/* paper + ribbon rise from the tip */
.intro-wrap .wrap-grow { transform-origin: 300px 758px; animation: wrapGrow .95s cubic-bezier(.2, 1.1, .3, 1) both; }
@keyframes wrapGrow { from { transform: scale(.15, .05); opacity: 0; } 35% { opacity: 1; } to { transform: none; opacity: 1; } }
.intro-wrap .bow { animation: bowPop .7s cubic-bezier(.2, 1.5, .4, 1) 2.2s both; }
@keyframes bowPop { from { transform: scale(0) rotate(-20deg); } to { transform: none; } }
.intro-wrap .gleaf { animation: leafPop .8s cubic-bezier(.2, 1.2, .4, 1) calc(.35s + var(--i) * .07s) both; }

/* a flower growing in: stem draws, leaves pop, head blooms, petals open */
.anim-in .stem { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: stemGrow .8s cubic-bezier(.3, .7, .3, 1) var(--d, 0s) forwards; }
@keyframes stemGrow { to { stroke-dashoffset: 0; } }
.anim-in .leaf { animation: leafPop .6s cubic-bezier(.2, 1.3, .4, 1) calc(var(--d, 0s) + .4s) both; }
@keyframes leafPop { from { transform: scale(0); } to { transform: none; } }
.anim-in .bloom { animation: bloomIn 1s cubic-bezier(.2, 1.2, .35, 1) calc(var(--d, 0s) + .55s) both; }
@keyframes bloomIn { from { transform: scale(0) rotate(-35deg); } 55% { transform: scale(1.08) rotate(4deg); } to { transform: none; } }
.anim-in .p { animation: petalOpen .85s cubic-bezier(.2, .9, .3, 1.15) calc(var(--d, 0s) + .6s + var(--k, 0) * 24ms) both; }
@keyframes petalOpen { from { transform: scale(.15) rotate(-24deg); opacity: 0; } 35% { opacity: 1; } to { transform: none; opacity: 1; } }

/* a flower leaving (when you change the mix) */
.out .stem { stroke-dasharray: var(--len); animation: stemOut .3s ease-in var(--d, 0s) forwards; }
@keyframes stemOut { to { stroke-dashoffset: var(--len); } }
.out .bloom, .out .leaf { animation: bloomOut .3s ease-in var(--d, 0s) forwards; }
@keyframes bloomOut { to { transform: scale(0) rotate(25deg); } }

.spark { opacity: 0; animation: spark 1.5s ease-out both; }
@keyframes spark {
  0%   { transform: translate(var(--x), var(--y)) scale(0); opacity: 0; }
  25%  { opacity: 1; transform: translate(var(--x), var(--y)) scale(var(--s)); }
  100% { transform: translate(calc(var(--x) + var(--dx)), calc(var(--y) + var(--dy))) scale(0) rotate(90deg); opacity: 0; }
}

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .stage { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "visual" "picker"; row-gap: 6px; padding-top: 20px; padding-bottom: 28px; min-height: 0; }
  .head { padding-bottom: 0; text-align: center; }
  .subtitle { margin-left: auto; margin-right: auto; }
  .bouquet-wrap { width: min(100%, 440px, calc(62svh * 600 / 730)); }
  /* the Save button stays reachable while she scrolls, on a soft fade so nothing shows through it */
  .save-row {
    position: sticky; bottom: 0; z-index: 5; margin: 14px calc(-1 * clamp(16px, 2.4vw, 26px)) calc(-1 * clamp(16px, 2.4vw, 26px));
    padding: 14px clamp(16px, 2.4vw, 26px) calc(14px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, rgba(255, 247, 249, .97) 72%, rgba(255, 247, 249, 0)); border-radius: 0 0 28px 28px;
  }
  .actions { justify-content: center; }
}
@media (max-width: 420px) {
  .chips { gap: 6px; }
  .btn { padding: 14px 22px; }
}
@media (max-width: 370px) {
  .chips { gap: 4px; }
  .chip { padding-inline: 0; border-radius: 14px; }
  .chip .nm { font-size: .6rem; letter-spacing: -.02em; }
  .card { padding: 14px; border-radius: 22px; }
  .save-row { margin-inline: -14px; padding-inline: 14px; margin-bottom: -14px; }
  .title { font-size: 1.85rem; }
}
/* short, wide screens (phones on their side): keep the bouquet from being tiny */
@media (max-height: 520px) and (min-width: 600px) {
  .bouquet-wrap { width: min(100%, 300px); }
}

@media (prefers-reduced-motion: reduce) {
  .bouquet-wrap svg, .petals i { animation: none; }
  .petals { display: none; }
  .letter, .w, .actions { animation-duration: .01s; animation-delay: 0s; }
  .w { opacity: 1; }
}
