:root {
  color-scheme: light;
  --gold: #d4a34d;
  --gold-bright: #fff0b5;
  --jade: #7dc8b5;
  --jade-deep: #1f7169;
  --ink: #31534d;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: #fff8d9;
  background: #b8dfe2;
  font-family: "Noto Serif SC", "Source Han Serif SC", "SimSun", "STSong", serif;
}

a,
button,
textarea {
  font: inherit;
}

button,
textarea {
  letter-spacing: 0;
}

.heart-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.heart-stage {
  position: relative;
  width: min(100vw, 150vh);
  min-height: min(100vh, 66.666vw);
  aspect-ratio: 3 / 2;
  overflow: hidden;
  isolation: isolate;
  background: #c8e5e4;
  box-shadow: 0 24px 82px rgba(31, 72, 76, 0.34);
}

.heart-bg {
  position: absolute;
  inset: 0;
  z-index: -6;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}

.top-veil,
.sun-haze,
.pond-mist,
.water-glints {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.top-veil {
  z-index: -2;
  background: linear-gradient(180deg, rgba(15, 43, 61, 0.7) 0%, rgba(25, 68, 76, 0.22) 8.5%, transparent 17%);
}

.sun-haze {
  z-index: -1;
  opacity: 0.42;
  background: radial-gradient(circle at 28% 18%, rgba(255, 247, 211, 0.66), transparent 30%);
  mix-blend-mode: screen;
}

.pond-mist {
  left: -30%;
  width: 165%;
  height: 16%;
  z-index: 16;
  opacity: 0.14;
  filter: blur(18px);
  mix-blend-mode: screen;
  background:
    radial-gradient(ellipse at 14% 50%, rgba(255, 255, 255, 0.68), transparent 39%),
    radial-gradient(ellipse at 43% 54%, rgba(228, 251, 249, 0.55), transparent 42%),
    radial-gradient(ellipse at 74% 48%, rgba(255, 247, 215, 0.42), transparent 41%),
    radial-gradient(ellipse at 95% 52%, rgba(255, 255, 255, 0.58), transparent 38%);
}

.mist-a {
  top: 49%;
  animation: mist-drift 92s linear infinite;
}

.mist-b {
  top: 76%;
  opacity: 0.08;
  animation: mist-drift 126s linear infinite reverse;
}

.water-glints {
  z-index: 4;
  opacity: 0.42;
  background:
    radial-gradient(circle at 18% 76%, rgba(255, 240, 165, 0.9) 0 1px, transparent 2px),
    radial-gradient(circle at 42% 83%, rgba(255, 255, 225, 0.82) 0 1px, transparent 2px),
    radial-gradient(circle at 59% 68%, rgba(255, 230, 147, 0.78) 0 1px, transparent 2px),
    radial-gradient(circle at 71% 87%, rgba(255, 255, 230, 0.74) 0 1px, transparent 2px);
  animation: glint-breathe 4.8s ease-in-out infinite alternate;
}

.site-header {
  position: relative;
  z-index: 30;
  height: 8%;
  min-height: 66px;
}

.brand {
  position: absolute;
  left: 2.2%;
  top: 18%;
  width: 12.5%;
  min-width: 150px;
  line-height: 0;
}

.brand img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 4px 10px rgba(8, 28, 36, 0.42));
}

.primary-nav {
  position: absolute;
  left: 22.2%;
  top: 17%;
  width: 52%;
  display: flex;
  justify-content: space-between;
  gap: 1.2vw;
}

.utility-nav {
  position: absolute;
  right: 2.4%;
  top: 17%;
  display: flex;
  gap: 1.2vw;
}

.nav-link,
.utility-link {
  position: relative;
  color: rgba(255, 235, 182, 0.92);
  text-decoration: none;
  text-shadow: 0 2px 9px rgba(3, 25, 35, 0.72);
  transition: color 220ms ease, text-shadow 220ms ease;
}

.nav-link {
  padding: 0.3rem 0.18rem 0.68rem;
  font-size: clamp(0.95rem, 1.28vw, 1.28rem);
  white-space: nowrap;
}

.utility-link {
  display: inline-flex;
  align-items: center;
  gap: 0.36rem;
  padding: 0.3rem 0.1rem;
  font-size: clamp(0.82rem, 1vw, 1rem);
}

.utility-icon {
  width: 1.32em;
  height: 1.32em;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255, 230, 159, 0.64);
  border-radius: 999px;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0.28rem;
  width: 0;
  height: 1px;
  transform: translateX(-50%);
  opacity: 0;
  background: linear-gradient(90deg, transparent, var(--gold-bright), transparent);
  box-shadow: 0 0 12px rgba(255, 239, 180, 0.9);
  transition: width 220ms ease, opacity 220ms ease;
}

.nav-link:hover,
.nav-link:focus-visible,
.nav-link.is-active,
.utility-link:hover,
.utility-link:focus-visible {
  color: #fff4c8;
  text-shadow: 0 0 11px rgba(255, 235, 171, 0.9), 0 2px 12px rgba(4, 29, 38, 0.68);
}

.nav-link:hover::after,
.nav-link:focus-visible::after {
  width: 86%;
  opacity: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wish-ritual {
  position: absolute;
  inset: 0;
  z-index: 14;
  pointer-events: none;
  opacity: 1;
  visibility: visible;
  transition: opacity 420ms ease, visibility 420ms ease;
}

.is-post-wish .wish-ritual {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.jade-slip {
  position: absolute;
  left: 50%;
  top: 13.5%;
  width: 30%;
  max-height: 78%;
  aspect-ratio: 656 / 1077;
  padding: 0;
  color: var(--ink);
  transform: translateX(-50%);
  pointer-events: auto;
  transition: opacity 450ms ease, transform 650ms ease, filter 650ms ease;
}

.jade-slip-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.9;
  filter:
    drop-shadow(0 20px 28px rgba(31, 84, 78, 0.2))
    drop-shadow(0 0 18px rgba(255, 241, 184, 0.28));
  pointer-events: none;
  user-select: none;
}

.wish-heading {
  position: absolute;
  left: 13%;
  right: 13%;
  top: 20.5%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 0;
}

.wish-heading h2 {
  margin: 0;
  color: #315f57;
  font-size: clamp(1.48rem, 2.05vw, 2.05rem);
  font-weight: 500;
  text-shadow: 0 1px rgba(255, 255, 255, 0.7);
}

.wish-seal {
  width: 2rem;
  height: 2rem;
  display: inline-grid;
  place-items: center;
  color: #fff0b7;
  border: 1px solid rgba(255, 227, 144, 0.86);
  border-radius: 50%;
  background: linear-gradient(145deg, #c56d43, #9b4c35);
  box-shadow: 0 3px 8px rgba(105, 64, 38, 0.22);
  font-size: 0.92rem;
}

#wish-form {
  position: absolute;
  left: 13%;
  right: 13%;
  top: 28%;
  bottom: 12.5%;
  z-index: 2;
  display: flex;
  flex-direction: column;
}

#wish-form label {
  display: block;
  margin-bottom: 0.4rem;
  color: #4e7269;
  font-size: 0.92rem;
}

#wish-message {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  resize: none;
  padding: 0.75rem 0.85rem;
  color: #304f49;
  border: 0;
  border-top: 1px solid rgba(64, 126, 110, 0.24);
  border-bottom: 1px solid rgba(164, 120, 43, 0.36);
  border-radius: 0;
  outline: none;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(1.8rem - 1px),
      rgba(68, 124, 108, 0.13) calc(1.8rem - 1px),
      rgba(68, 124, 108, 0.13) 1.8rem
    ),
    rgba(244, 255, 241, 0.22);
  background-position: 0 12px;
  line-height: 1.8rem;
  transition: background-color 200ms ease, box-shadow 200ms ease;
}

#wish-message::placeholder {
  color: rgba(45, 87, 78, 0.52);
}

#wish-message:focus {
  background-color: rgba(246, 255, 238, 0.36);
  box-shadow: inset 0 0 18px rgba(255, 251, 206, 0.28);
}

.wish-actions {
  min-height: 2.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-top: 0.72rem;
  padding: 0 1.35rem;
}

#character-count {
  color: rgba(43, 82, 75, 0.62);
  font-size: 0.78rem;
  white-space: nowrap;
}

.wish-button {
  position: relative;
  min-width: 8.6rem;
  min-height: 2.45rem;
  padding: 0.5rem 1.05rem;
  overflow: hidden;
  color: #624018;
  border: 1px solid rgba(166, 107, 28, 0.78);
  border-radius: 4px;
  background: linear-gradient(180deg, #fff2b7, #e4b452 58%, #c58731);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.82), 0 6px 14px rgba(73, 100, 69, 0.2);
  cursor: pointer;
  transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease;
}

.wish-button:hover,
.wish-button:focus-visible {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.88), 0 9px 20px rgba(74, 101, 70, 0.27), 0 0 17px rgba(255, 232, 150, 0.68);
}

.wish-button:focus-visible {
  outline: 2px solid rgba(255, 243, 188, 0.95);
  outline-offset: 3px;
}

.wish-button:disabled {
  cursor: default;
  filter: saturate(0.75);
}

.post-wish-clouds {
  position: absolute;
  inset: 0;
  z-index: 15;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 700ms ease, visibility 700ms ease;
}

.is-post-wish .post-wish-clouds {
  opacity: 1;
  visibility: visible;
}

.post-cloud {
  position: absolute;
  left: -44%;
  top: var(--cloud-top);
  width: var(--cloud-width);
  height: auto;
  opacity: var(--cloud-opacity);
  filter:
    blur(var(--cloud-blur))
    brightness(1.03)
    contrast(1.08)
    drop-shadow(0 8px 13px rgba(92, 132, 146, 0.2));
  animation: post-cloud-pass var(--cloud-duration) linear infinite;
  animation-delay: var(--cloud-delay);
  animation-play-state: paused;
  will-change: transform;
}

.is-post-wish .post-cloud {
  animation-play-state: running;
}

.post-cloud-a {
  --cloud-top: 25%;
  --cloud-width: 38%;
  --cloud-opacity: 0.52;
  --cloud-blur: 0.6px;
  --cloud-duration: 72s;
  --cloud-delay: -18s;
}

.post-cloud-b {
  --cloud-top: 43%;
  --cloud-width: 47%;
  --cloud-opacity: 0.38;
  --cloud-blur: 1px;
  --cloud-duration: 92s;
  --cloud-delay: -63s;
}

.post-cloud-c {
  --cloud-top: 60%;
  --cloud-width: 34%;
  --cloud-opacity: 0.46;
  --cloud-blur: 0.5px;
  --cloud-duration: 80s;
  --cloud-delay: -43s;
}

.post-cloud-d {
  --cloud-top: 71%;
  --cloud-width: 42%;
  --cloud-opacity: 0.34;
  --cloud-blur: 1.2px;
  --cloud-duration: 104s;
  --cloud-delay: -84s;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 3.2%;
  z-index: 40;
  min-width: 14rem;
  margin: 0;
  padding: 0.58rem 1.15rem;
  color: #fff3c1;
  text-align: center;
  border: 1px solid rgba(255, 226, 146, 0.55);
  border-radius: 4px;
  opacity: 0;
  transform: translate(-50%, 8px);
  background: rgba(23, 78, 75, 0.82);
  box-shadow: 0 8px 24px rgba(18, 66, 70, 0.26), 0 0 16px rgba(255, 235, 170, 0.25);
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  backdrop-filter: blur(8px);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes mist-drift {
  from { transform: translateX(-7%); }
  to { transform: translateX(18%); }
}

@keyframes glint-breathe {
  from { opacity: 0.24; }
  to { opacity: 0.58; }
}

@keyframes post-cloud-pass {
  from { transform: translateX(-12vw); }
  to { transform: translateX(160vw); }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .heart-page {
    display: block;
  }

  .heart-stage {
    width: 100%;
    min-height: 100svh;
    aspect-ratio: auto;
  }

  .heart-bg {
    object-position: 52% center;
  }

  .site-header {
    min-height: 126px;
  }

  .brand {
    left: 3.5%;
    top: 10px;
    width: 158px;
    min-width: 0;
  }

  .utility-nav {
    right: 3.5%;
    top: 12px;
  }

  .utility-link {
    font-size: 0.72rem;
  }

  .utility-link span:last-child {
    display: none;
  }

  .primary-nav {
    left: 3.5%;
    right: 3.5%;
    top: 73px;
    width: auto;
    justify-content: flex-start;
    gap: 0.65rem;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .primary-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-link {
    flex: 0 0 auto;
    padding-inline: 0.08rem;
    font-size: 0.8rem;
  }

  .jade-slip {
    top: 17%;
    width: 84%;
    max-height: 76%;
  }

  .wish-heading h2 {
    font-size: 1.55rem;
  }

  #wish-message {
    min-height: 150px;
  }

  .post-cloud-a,
  .post-cloud-c {
    --cloud-width: 68%;
  }

  .post-cloud-b,
  .post-cloud-d {
    --cloud-width: 76%;
  }

  .post-cloud-a { --cloud-opacity: 0.62; }
  .post-cloud-b { --cloud-opacity: 0.5; }
  .post-cloud-c { --cloud-opacity: 0.58; }
  .post-cloud-d { --cloud-opacity: 0.46; }

  .toast {
    bottom: 4%;
    min-width: 12rem;
    max-width: 86%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .post-cloud {
    left: 8%;
    animation: none !important;
  }

  .post-cloud-b {
    left: 52%;
  }

  .post-cloud-c {
    left: 24%;
  }

  .post-cloud-d {
    left: 62%;
  }
}
