/* =========================================================
   Bulut — a little rain cloud over a drooping tulip on a sunny
   sill; on the tap it blushes, bursts into hearts, the tulip
   blooms and a rainbow fills the window with light, over a tulip
   meadow after the rain. Apology letters (event "uzr").
   Built on shared/base.css; this sheet is the look.
   ========================================================= */

/* Bad Script's ‘ ’ stand far from their letters ("yomg ‘ir"): the same two
   glyphs with tighter sides (made for Kapalak, see its media/PROMPTS.md) */
@font-face {
  font-family: "Bulut Apos";
  src: url("/styles/bulut/media/apos.woff2") format("woff2");
  unicode-range: U+2018-2019;
  font-display: swap;
}

:root {
  --bg: #fdf6f7;
  --ink: #48303c;
  --ink-soft: #84697a;
  --accent: #e0789a;
  --accent-deep: #b2476e;
  --accent-soft: #fde4ec;
  --sky: #9fcbe8;
  --lilac: #c9a6e8;
  --butter: #ffd59a;
  --line: rgba(178, 71, 110, 0.14);
  --line-strong: rgba(178, 71, 110, 0.3);
  --surface: #fffafb;
  --on-accent: #fffafb;
  --shadow: 150 70 100;
  --glow: rgba(255, 250, 251, 0.95);
  --intro-bg: #f4eeee;

  --display: "Bulut Apos", "Bad Script", "Segoe Script", cursive;
  --body: "EB Garamond", Georgia, serif;
  --label: "Montserrat Alternates", "Trebuchet MS", sans-serif;

  --open-default: url("/styles/bulut/media/open-poster.jpg");
  --amb-poster: url("/styles/bulut/media/amb-poster.jpg");
  --close-poster: url("/styles/bulut/media/close-poster.jpg");
  --dissolve: 2s;
  --pulse: rgba(255, 255, 255, 0.95);
  --pulse-glow: rgba(240, 150, 185, 0.55);
  --glint: rgba(255, 200, 220, 0.95);

  --heart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 22'%3E%3Cpath d='M12 21.5C5 16.6 0 12.3 0 6.9 0 3 3 0 6.6 0 9 0 10.9 1.3 12 3.2 13.1 1.3 15 0 17.4 0 21 0 24 3 24 6.9c0 5.4-5 9.7-12 14.6Z'/%3E%3C/svg%3E");
  --drop: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 22'%3E%3Cpath d='M8 0C8 0 0 9.6 0 14a8 8 0 0 0 16 0C16 9.6 8 0 8 0Z'/%3E%3C/svg%3E");
}

body {
  font-variant-numeric: lining-nums;
  font-size: 19.5px;
  background:
    radial-gradient(ellipse 120% 40% at 0% 0%, rgba(159, 203, 232, 0.16), transparent 70%),
    radial-gradient(ellipse 120% 50% at 100% 30%, rgba(255, 213, 154, 0.14), transparent 70%),
    radial-gradient(ellipse 120% 50% at 0% 70%, rgba(201, 166, 232, 0.13), transparent 70%),
    var(--bg);
}

.label {
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0.24em;
}

/* ---------- Opening ---------- */

.intro__kicker {
  color: var(--accent-deep);
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.95), 0 0 3px rgba(255, 255, 255, 0.9);
}

.intro__to {
  font-size: clamp(44px, 13vw, 58px);
  color: var(--accent-deep);
  text-shadow: 0 0 18px rgba(255, 255, 255, 1), 0 0 6px rgba(255, 255, 255, 0.9);
}

.intro__hint {
  letter-spacing: 0.12em;
  background: rgba(255, 250, 251, 0.85);
  color: var(--accent-deep);
}

/* the cloud bobs a little while it waits */
.intro__video {
  animation: bob 4.6s ease-in-out infinite;
  transform-origin: 49% 34%;
}

/* paused, not stopped: no jump when the film starts */
body.is-opening .intro__video {
  animation-play-state: paused;
}

@keyframes bob {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.014);
  }
}

/* ---------- Hero ---------- */

.hero__veil {
  background:
    radial-gradient(ellipse 100% 26% at 50% 21%, rgba(255, 250, 251, 0.62), rgba(255, 250, 251, 0) 74%),
    linear-gradient(to bottom, rgba(253, 246, 247, 0) 84%, rgba(253, 246, 247, 0.8) 95%, var(--bg) 100%);
}

.hero__text {
  top: max(9%, calc(env(safe-area-inset-top) + 60px));
  padding: 0 20px;
}

.hero__kicker {
  margin: 0 0 6px;
  font-family: var(--label);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--accent-deep);
  text-shadow: 0 0 12px var(--glow), 0 0 4px var(--glow);
}

.names {
  margin: 0;
  font-weight: 400;
  line-height: 1;
}

.name {
  display: block;
  white-space: nowrap;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(76px, 24vw, 104px);
  line-height: 1.15;
  color: var(--accent-deep);
  text-shadow: 0 0 22px var(--glow), 0 0 8px var(--glow), 0 0 2px #fff;
}

/* a pill at the bottom of the meadow, where an invitation shows its date */
.hero__quote {
  position: absolute;
  left: 50%;
  bottom: max(98px, calc(env(safe-area-inset-bottom) + 86px));
  translate: -50% 0;
  width: max-content;
  max-width: calc(100% - 40px);
  margin: 0;
  padding: 10px 22px 11px;
  border-radius: 999px;
  background: rgba(255, 250, 251, 0.9);
  border: 1px solid var(--line-strong);
  font-style: italic;
  font-size: 18px;
  line-height: 1.3;
  text-align: center;
  color: var(--ink);
  box-shadow: 0 12px 26px -14px rgb(var(--shadow) / 0.7);
}

.cue {
  color: var(--accent-deep);
}

.hero.is-in .hero__kicker {
  animation: rise 1.8s var(--ease) 0.4s both;
}

/* her name falls in like raindrops, letter by letter (shared/joy.js splits it) */
.hero.is-in .name {
  animation: none;
  opacity: 1;
}

.hero .name .ch {
  opacity: 0;
}

.hero.is-in .name .ch {
  animation: drip 1.4s cubic-bezier(0.3, 1.3, 0.5, 1) calc(0.8s + var(--i) * 140ms) both;
}

.hero.is-in .hero__quote {
  animation: rise 1.8s var(--ease) 2.4s both;
}

.hero {
  --cue-d: 3.2s;
}

@keyframes drip {
  0% {
    opacity: 0;
    transform: translateY(-60px) scaleY(1.4) scaleX(0.7);
    filter: blur(5px);
  }
  50% {
    opacity: 1;
    transform: translateY(4px) scaleY(0.88) scaleX(1.1);
    filter: blur(0);
  }
  75% {
    transform: translateY(-2px) scaleY(1.04) scaleX(0.98);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Clouds drifting behind the page ---------- */

.drift {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity 3s var(--ease-soft);
}

body.is-open .drift {
  opacity: 1;
}

.page {
  z-index: 1;
}

.drift > i {
  position: absolute;
  left: 0;
  width: var(--w);
  aspect-ratio: 1.7;
  background: url("/styles/bulut/media/cloud-1.webp") center / contain no-repeat;
  opacity: 0.55;
  will-change: transform;
  animation: sail var(--d) linear var(--delay) infinite;
}

.drift > i:nth-child(1) { top: 14vh; --w: 150px; --d: 70s; --delay: -10s; }
.drift > i:nth-child(2) { top: 52vh; --w: 110px; --d: 90s; --delay: -55s; background-image: url("/styles/bulut/media/cloud-2.webp"); }
.drift > i:nth-child(3) { top: 80vh; --w: 130px; --d: 80s; --delay: -30s; }

@keyframes sail {
  from {
    transform: translateX(-180px);
  }
  50% {
    transform: translateX(calc(50vw - 75px)) translateY(-14px);
  }
  to {
    transform: translateX(calc(100vw + 40px));
  }
}

/* after a yes the clouds blush */
body.is-forgiven .drift > i {
  filter: saturate(1.8) hue-rotate(-12deg);
  transition: filter 2s;
}

/* ---------- Bursts (shared/joy.js) ---------- */

.joy-heart,
.joy-drop {
  width: 14px;
  height: 13px;
  background: var(--c, var(--accent));
  -webkit-mask: var(--heart) center / contain no-repeat;
  mask: var(--heart) center / contain no-repeat;
  filter: drop-shadow(0 2px 3px rgba(150, 70, 100, 0.25));
}

.joy-drop {
  width: 9px;
  height: 13px;
  background: linear-gradient(160deg, #fff, var(--sky));
  -webkit-mask-image: var(--drop);
  mask-image: var(--drop);
}

/* ---------- Sections ---------- */

.title {
  position: relative;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(40px, 12vw, 52px);
  line-height: 1.2;
  color: var(--accent-deep);
}

.divider {
  width: min(84%, 320px);
  margin-top: 10px;
}

.corner {
  width: min(42vw, 180px);
}

[data-reveal] {
  transform: translateY(26px) scale(0.97);
  filter: blur(3px);
  transition:
    opacity 1.3s var(--ease),
    transform 1.5s cubic-bezier(0.34, 1.4, 0.64, 1),
    filter 1.2s var(--ease);
}

[data-reveal].is-in {
  filter: none;
}

/* ---------- The letter: a sheet of paper, the words ink in ---------- */

.letter.section:has(> .corner) {
  padding-top: 130px;
}

.paper {
  position: relative;
  margin: 0 -4px;
  padding: 38px 26px 44px;
  text-align: left;
  border-radius: 6px;
  background: linear-gradient(170deg, #fffdf8, #fff6ee 60%, #fdeee8);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 22px 40px -22px rgb(var(--shadow) / 0.55),
    0 2px 6px -2px rgb(var(--shadow) / 0.25);
  rotate: -1deg;
}

/* a pressed tulip and ribbon in the corner of the sheet */
.paper::after {
  content: "";
  position: absolute;
  right: -18px;
  bottom: -26px;
  width: 120px;
  height: 120px;
  background: url("/styles/bulut/media/corner.webp") center / contain no-repeat;
  transform: rotate(160deg);
  opacity: 0.9;
  pointer-events: none;
}

/* the sheet arrives folded and opens out (bulut.js adds is-in: a tall,
   tilted sheet never reaches the shared reveal's threshold on a small phone) */
.paper {
  opacity: 0;
  transform: perspective(900px) rotateX(38deg) translateY(40px) scale(0.92);
  transform-origin: 50% 0;
  transition:
    opacity 1.2s var(--ease),
    transform 1.8s cubic-bezier(0.25, 1.2, 0.5, 1);
}

.paper.is-in {
  opacity: 1;
  transform: none;
}

.paper__greet {
  margin: 0 0 14px;
  font-family: var(--display);
  font-size: clamp(30px, 9vw, 36px);
  line-height: 1.2;
  color: var(--accent-deep);
}

.paper__text {
  margin: 0;
  white-space: pre-line;
  font-family: var(--display);
  font-size: 20.5px;
  line-height: 38px;
  color: #4a3550;
  /* ruled lines under each line of writing */
  background: repeating-linear-gradient(to bottom, transparent 0 33px, rgba(159, 203, 232, 0.4) 33px 34px, transparent 34px 38px);
}

.paper__sign {
  margin: 24px 0 0;
  text-align: right;
  font-family: var(--display);
  font-size: 24px;
  color: var(--accent-deep);
}

/* each word inks in after the one before */
.paper .w {
  opacity: 0;
  filter: blur(4px);
}

.paper.is-in .w {
  animation: ink 0.9s var(--ease) calc(0.7s + var(--i) * 38ms) both;
}

.paper .paper__sign,
.paper .paper__greet {
  opacity: 0;
}

.paper.is-in .paper__greet {
  animation: ink 1.2s var(--ease) 0.4s both;
}

.paper.is-in .paper__sign {
  animation: ink 1.4s var(--ease) calc(1s + var(--words, 60) * 38ms) both;
}

@keyframes ink {
  from {
    opacity: 0;
    filter: blur(4px);
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    filter: none;
    transform: none;
  }
}

/* ---------- Promises ---------- */

.detail {
  background: rgba(255, 250, 251, 0.92);
}

.detail__ico {
  background: #fff;
  border: 2px solid var(--accent);
  color: var(--accent-deep);
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s;
  transform: scale(0.4) rotate(-30deg);
}

.detail.is-in .detail__ico {
  transform: none;
}

.detail:nth-child(3n + 2) .detail__ico {
  border-color: #7fb7dc;
  color: #3f7aa3;
}

.detail:nth-child(3n + 3) .detail__ico {
  border-color: #b48ad8;
  color: #7a4fa3;
}

.detail__title {
  font-weight: 600;
}

/* a promise with no note sits level with its icon */
.detail:not(:has(.detail__text)) {
  align-items: center;
}

/* ---------- Buttons ---------- */

.btn {
  font-family: var(--label);
  font-weight: 600;
  letter-spacing: 0.1em;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s;
}

.btn:active {
  transform: scale(0.95);
}

.btn--solid {
  background: linear-gradient(135deg, #f19bb8, var(--accent-deep));
  box-shadow: 0 14px 26px -14px rgb(var(--shadow) / 0.9);
}

/* ---------- The question ---------- */

.ask {
  --tries: 0;
}

.ask__cloud {
  width: 130px;
  margin: 0 auto 4px;
}

.ask .head.is-in .ask__cloud {
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

/* the "Yoʻq" button runs about inside this box */
.ask__stage {
  position: relative;
  height: 230px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  padding-top: 14px;
}

.ask__yes {
  z-index: 2;
  min-width: 180px;
  scale: calc(1 + min(var(--tries), 5) * 0.08);
  transition: scale 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.25s;
  animation: beat 2.2s ease-in-out infinite;
}

@keyframes beat {
  0%,
  60%,
  100% {
    transform: scale(1);
  }
  20% {
    transform: scale(1.06);
  }
  40% {
    transform: scale(1.03);
  }
}

/* above "Ha": a finger that lands on both moves "Yoʻq", never says yes by accident */
.ask__no {
  z-index: 3;
  white-space: nowrap;
  background: var(--surface);
  scale: calc(1 - min(var(--tries), 4) * 0.08);
  transition:
    left 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
    top 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
    scale 0.4s,
    background 0.4s,
    color 0.4s;
}

.ask__no.is-loose {
  position: absolute;
}

/* it gave up: now it says yes as well */
.ask__no.is-yes-too {
  scale: 1;
  color: #fff;
  background: linear-gradient(135deg, #f7b6cb, var(--accent));
  border-color: transparent;
}

.ask__done {
  display: none;
}

.ask.is-yes .ask__stage {
  display: none;
}

.ask.is-yes .ask__done {
  display: block;
  animation: rise 1.4s var(--ease) both;
}

.ask.is-yes .ask__cloud {
  animation: hop 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) both, float 4s ease-in-out 0.9s infinite;
}

@keyframes hop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.3) rotate(-6deg);
  }
  100% {
    transform: scale(1.12);
  }
}

.ask__thanks {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: clamp(40px, 12vw, 50px);
  line-height: 1.2;
  color: var(--accent-deep);
}

.ask__text {
  margin: 0 auto 26px;
  max-width: 340px;
  font-style: italic;
  font-size: 20px;
}

/* hearts falling over the whole screen after a yes */
.heart-rain {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  overflow: hidden;
}

.heart-rain > i {
  position: absolute;
  top: -30px;
  width: calc(22px * var(--s));
  height: calc(20px * var(--s));
  background: var(--c);
  -webkit-mask: var(--heart) center / contain no-repeat;
  mask: var(--heart) center / contain no-repeat;
  animation: fall linear both;
}

@keyframes fall {
  0% {
    transform: translate(0, 0) rotate(-20deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  50% {
    transform: translate(18px, 55vh) rotate(15deg);
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translate(-10px, 110vh) rotate(-10deg);
    opacity: 0;
  }
}

/* ---------- Closing ---------- */

.closing__veil {
  background:
    linear-gradient(to bottom, var(--bg) 0%, rgba(253, 246, 247, 0.55) 7%, rgba(253, 246, 247, 0) 20%),
    radial-gradient(ellipse 90% 18% at 50% 19%, rgba(80, 30, 60, 0.38), transparent 76%),
    linear-gradient(to top, var(--bg) 0%, rgba(253, 246, 247, 0) 14%);
}

.closing__wait {
  font-family: var(--display);
  font-size: clamp(50px, 15vw, 66px);
  color: #fff7fa;
  text-shadow: 0 2px 18px rgba(80, 25, 55, 0.75);
}

.closing__names {
  font-family: var(--label);
  color: #ffe0e8;
  text-shadow: 0 1px 10px rgba(80, 25, 55, 0.85);
}

.footer__art {
  width: 120px;
}

.footer__sign {
  font-family: var(--display);
  font-size: 24px;
  color: var(--accent-deep);
}

/* ---------- Small and wide screens ---------- */

@media (max-width: 380px) {
  .hero__quote {
    font-size: 16.5px;
  }
}

@media (max-height: 700px) and (max-aspect-ratio: 3/4) {
  .hero__text {
    top: max(6%, calc(env(safe-area-inset-top) + 56px));
  }

  .name {
    font-size: clamp(64px, 20vw, 84px);
  }
}

@media (min-aspect-ratio: 3/4) {
  .name {
    font-size: min(104px, 10vh);
  }
}

@media (prefers-reduced-motion: reduce) {
  .drift,
  .heart-rain {
    display: none;
  }

  .hero.is-in .name .ch,
  .hero .name .ch,
  .paper .w,
  .paper .paper__sign,
  .paper .paper__greet {
    animation: none !important;
    opacity: 1;
    filter: none;
  }

  .intro__video,
  .ask__yes,
  .ask__cloud {
    animation: none !important;
  }

  .ask__no {
    transition: none;
  }

  [data-reveal],
  .paper {
    filter: none;
    transform: none;
  }

  .paper {
    opacity: 1;
  }
}
