/* ==========================================================================
   Messages wall: dusk sky, cottage, floating notes, stationery form.
   ========================================================================== */

.page-messages {
  background: var(--cream);
}

/* ── The scene ────────────────────────────────────────────────────────────── */

.scene {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 560px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--dusk-top) 0%, var(--dusk-mid) 58%, var(--dusk-low) 100%);
  color: #fff;
  isolation: isolate;
}

.scene__sky,
.scene__stars,
.scene__snow {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scene__stars,
.scene__snow {
  width: 100%;
  height: 100%;
}

.scene__snow {
  z-index: 4;
}

.aurora {
  position: absolute;
  inset: -10% -25% 45%;
  background:
    radial-gradient(40% 32% at 28% 46%, rgb(124 232 196 / 0.32), transparent 70%),
    radial-gradient(34% 26% at 62% 32%, rgb(170 146 255 / 0.28), transparent 70%),
    radial-gradient(30% 22% at 46% 60%, rgb(255 176 206 / 0.18), transparent 70%);
  filter: blur(34px);
  opacity: 0.85;
  animation: aurora 38s ease-in-out infinite alternate;
}

@keyframes aurora {
  from {
    transform: translateX(-5%) skewX(-8deg);
    opacity: 0.6;
  }
  to {
    transform: translateX(5%) skewX(8deg);
    opacity: 0.95;
  }
}

.moon {
  position: absolute;
  top: clamp(84px, 13vh, 130px);
  right: clamp(26px, 9vw, 140px);
  width: clamp(44px, 6vw, 70px);
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: calc(clamp(44px, 6vw, 70px) * 0.22) calc(clamp(44px, 6vw, 70px) * -0.1) 0 0 #F8E3A6;
  filter: drop-shadow(0 0 18px rgb(248 227 166 / 0.55));
}

@media (max-width: 700px) {
  .moon {
    top: 70px;
    right: 22px;
    width: 30px;
    box-shadow: 7px -3px 0 0 #F8E3A6;
  }
}

/* ── Hero over the sky ────────────────────────────────────────────────────── */

.sky-hero {
  position: relative;
  z-index: 3;
  padding: calc(62px + clamp(6px, 2vh, 22px)) var(--gutter) 0;
  text-align: center;
}

.sky-hero .kicker {
  color: #F9C9D4;
  font-size: clamp(21px, 2.6vw, 26px);
}

.sky-hero .hero__title {
  color: #FFF8EC;
  font-size: clamp(34px, 5.2vw, 58px);
  text-shadow: 0 0 30px rgb(255 230 190 / 0.35);
}

.sky-hero .hero__title em {
  color: #FCE7A8;
}

.sky-count {
  margin: 12px 0 0;
  color: #FCE7A8;
  font: 700 22px/1 var(--font-hand);
}

/* Phones: a slightly more compact hero and landscape leave room for two lanes of notes */
@media (max-width: 640px) {
  .sky-hero .hero__title {
    font-size: 32px;
  }
  .sky-hero__actions .btn {
    min-height: 44px;
    padding: 0 18px;
  }
  .sky-count {
    margin-top: 8px;
    font-size: 20px;
  }
  .landscape {
    height: clamp(150px, 21svh, 190px) !important;
  }
}

.sky-hero__sub {
  margin: 6px 0 0;
  color: rgb(255 255 255 / 0.86);
  font-weight: 600;
  font-size: clamp(15px, 1.9vw, 18px);
}

@media (max-width: 560px) {
  .sky-hero__dot {
    display: none;
  }
  .sky-hero__sub span[data-config],
  .sky-hero__sub > span:not(.sky-hero__dot) {
    display: block;
  }
}

.sky-hero__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: clamp(12px, 2.4vh, 20px);
}

.btn--glow {
  --btn-bg: #FCE7A8;
  --btn-fg: var(--ink);
  box-shadow: 0 0 0 6px rgb(252 231 168 / 0.16), 0 8px 30px rgb(252 231 168 / 0.45);
}

.btn--glow:hover {
  box-shadow: 0 0 0 8px rgb(252 231 168 / 0.2), 0 10px 36px rgb(252 231 168 / 0.6);
}

.btn--glass {
  --btn-bg: rgb(255 255 255 / 0.12);
  --btn-fg: #fff;
  box-shadow: inset 0 0 0 1.5px rgb(255 255 255 / 0.32);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.btn--glass:hover {
  --btn-bg: rgb(255 255 255 / 0.2);
}

/* ── Landscape + cottage ──────────────────────────────────────────────────── */

.landscape {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  width: 100%;
  height: clamp(170px, 28svh, 280px);
  overflow: visible; /* let chimney smoke drift above the drawing */
  pointer-events: none;
}

.smoke .puff {
  fill: rgb(236 238 250 / 0.6);
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: puff 7s ease-out infinite;
}

.smoke .puff:nth-child(2) {
  animation-delay: 1.75s;
}

.smoke .puff:nth-child(3) {
  animation-delay: 3.5s;
}

.smoke .puff:nth-child(4) {
  animation-delay: 5.25s;
}

@keyframes puff {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.35);
  }
  15% {
    opacity: 0.75;
  }
  100% {
    opacity: 0;
    transform: translate(34px, -120px) scale(2.6);
  }
}

.smoke .puff--burst {
  animation: puff 2.6s ease-out both;
}

.window-glow {
  animation: flicker 3.6s ease-in-out infinite alternate;
}

.advent-star {
  filter: drop-shadow(0 0 3px #FFC46B);
}

@keyframes flicker {
  0% {
    opacity: 0.7;
  }
  45% {
    opacity: 1;
  }
  60% {
    opacity: 0.85;
  }
  100% {
    opacity: 1;
  }
}

.scene.is-paused .aurora,
.scene.is-paused .puff,
.scene.is-paused .window-glow,
.scene.is-paused .note.is-new .note__paper {
  animation-play-state: paused;
}

/* ── Controls ─────────────────────────────────────────────────────────────── */

.round-btn {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(31 38 80 / 0.55);
  color: #fff;
  cursor: pointer;
  box-shadow: inset 0 0 0 1.5px rgb(255 255 255 / 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.round-btn svg {
  width: 20px;
  height: 20px;
}

.scene__pause {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 8;
}

.scene__pause .icon-play,
.scene__pause[aria-pressed='true'] .icon-pause {
  display: none;
}

.scene__pause[aria-pressed='true'] .icon-play {
  display: block;
}

.scene__hint {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(26px, calc(env(safe-area-inset-bottom) + 10px));
  z-index: 8;
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgb(31 38 80 / 0.45);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.hint--touch {
  display: none;
}

@media (hover: none) {
  .hint--hover {
    display: none;
  }
  .hint--touch {
    display: inline;
  }
}

@media (max-width: 640px) {
  .scene__hint {
    display: none;
  }
}

.sky-empty {
  position: absolute;
  left: 50%;
  top: 52%;
  z-index: 5;
  width: min(420px, calc(100% - 40px));
  margin: 0;
  padding: 18px 22px;
  border-radius: 24px;
  background: rgb(255 255 255 / 0.1);
  color: #fff;
  font: 400 24px/1.3 var(--font-note);
  text-align: center;
  transform: translate(-50%, -50%);
  box-shadow: inset 0 0 0 1.5px rgb(255 255 255 / 0.22);
}

/* ── Notes (shared by floating, opened and listed notes) ──────────────────── */

.note-layer {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 5;
  pointer-events: none;
}

.note {
  --note-w: 232px;
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: var(--note-w);
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  pointer-events: auto;
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 640px) {
  .note {
    --note-w: 178px;
  }
}

.note:focus-visible {
  outline: none;
}

.note:focus-visible .note__paper {
  outline: 3px solid #fff;
  outline-offset: 5px;
}

.note__paper {
  position: relative;
  display: block;
  padding: 16px 16px 12px;
  border-radius: 20px;
  background: var(--paper-color);
  isolation: isolate;
  filter: drop-shadow(0 10px 18px rgb(18 14 52 / 0.35));
  animation: note-in 0.9s ease both;
}

@keyframes note-in {
  from {
    opacity: 0;
  }
}

/* Paper lantern: warm inner glow, colored caps (= note type), little tassel */
.note--lantern .note__paper {
  margin: 8px 0 10px;
  border-radius: 30px / 24px;
  background:
    repeating-linear-gradient(90deg, transparent 0 27px, rgb(120 80 40 / 0.05) 27px 28px),
    radial-gradient(110% 85% at 50% 42%, rgb(255 251 236 / 0.95) 0%, rgb(255 251 236 / 0) 68%),
    var(--paper-color);
  filter: drop-shadow(0 0 22px rgb(255 214 150 / 0.38)) drop-shadow(0 10px 16px rgb(18 14 52 / 0.32));
}

.note--lantern .note__paper::before,
.note--lantern .note__paper::after {
  content: '';
  position: absolute;
  left: 50%;
  border-radius: 6px;
  background: var(--type-color);
  transform: translateX(-50%);
}

.note--lantern .note__paper::before {
  top: -7px;
  width: 44%;
  height: 11px;
}

.note--lantern .note__paper::after {
  bottom: -6px;
  width: 30%;
  height: 9px;
  opacity: 0.85;
}

/* Cloud: puffy bumps on top */
.note--cloud .note__paper {
  margin-top: 22px;
  border-radius: 40px;
  background:
    radial-gradient(90% 70% at 30% 20%, rgb(255 255 255 / 0.65), rgb(255 255 255 / 0) 70%),
    var(--paper-color);
}

.note--cloud .note__paper::before,
.note--cloud .note__paper::after {
  content: '';
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  background: var(--paper-color);
}

.note--cloud .note__paper::before {
  top: -26px;
  left: 16%;
  width: 72px;
  height: 72px;
}

.note--cloud .note__paper::after {
  top: -18px;
  left: 50%;
  width: 56px;
  height: 56px;
}

.note__type {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 6px;
  border-radius: 999px;
  background: var(--type-color);
  color: #fff;
  font: 800 11px/1.2 var(--font-ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.note__type svg {
  width: 14px;
  height: 14px;
}

.note__text {
  display: -webkit-box;
  margin: 8px 0 4px;
  overflow: hidden;
  font: 400 20px/1.2 var(--font-note);
  white-space: pre-line;
  overflow-wrap: anywhere;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.note__author {
  display: block;
  overflow: hidden;
  color: var(--ink-soft);
  font: 700 22px/1.1 var(--font-hand);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note__sticker {
  position: absolute;
  top: -14px;
  right: -12px;
  width: 42px;
  height: 42px;
  transform: rotate(12deg);
  filter: drop-shadow(0 2px 2px rgb(0 0 0 / 0.18));
}

.note__sticker svg {
  width: 100%;
  height: 100%;
}

@media (max-width: 640px) {
  .note__paper {
    padding: 14px 13px 10px;
  }
  .note__text {
    font-size: 18px;
  }
  .note__author {
    font-size: 19px;
  }
  .note__sticker {
    width: 34px;
    height: 34px;
  }
}

.note.is-source {
  opacity: 0;
  transition: opacity 0.2s;
}

.note.is-leaving {
  opacity: 0;
  transition: opacity 0.7s;
}

.note.is-new .note__paper {
  animation: note-in 0.6s ease both, new-glow 2.6s ease-in-out 0.6s 3;
}

@keyframes new-glow {
  50% {
    filter: drop-shadow(0 0 34px rgb(255 226 160 / 0.95)) drop-shadow(0 10px 16px rgb(18 14 52 / 0.32));
  }
}

.sparkle {
  position: absolute;
  z-index: 6;
  width: 10px;
  height: 10px;
  pointer-events: none;
  background: radial-gradient(circle, #FFF6D6 0 30%, rgb(255 230 160 / 0) 70%);
  animation: sparkle 1s ease-out forwards;
}

@keyframes sparkle {
  to {
    opacity: 0;
    transform: translateY(26px) scale(0.3);
  }
}

/* ── Opened note ──────────────────────────────────────────────────────────── */

.note-open {
  position: absolute;
  z-index: 30;
  width: min(380px, calc(100% - 32px));
  transform-origin: var(--ox, 50%) var(--oy, 50%);
  animation: open-in 0.38s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
}

.note-open.is-closing {
  animation: open-out 0.2s ease-in both;
}

@keyframes open-in {
  from {
    opacity: 0;
    transform: scale(0.62) rotate(var(--tilt, 0deg));
  }
}

@keyframes open-out {
  to {
    opacity: 0;
    transform: scale(0.8);
  }
}

.note--open {
  position: relative;
  width: 100%;
  cursor: default;
}

.note--open .note__paper {
  padding: 24px 24px 18px;
  animation: none;
}

.note--open .note__text {
  display: block;
  max-height: min(42svh, 330px);
  margin: 12px 0 10px;
  padding-right: 4px;
  overflow-y: auto;
  font-size: 24px;
  line-height: 1.25;
  -webkit-line-clamp: unset;
}

.note--open .note__author {
  font-size: 28px;
  white-space: normal;
}

.note--open .note__sticker {
  top: -18px;
  right: -14px;
  width: 58px;
  height: 58px;
}

.note__date {
  display: block;
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

.note__close {
  position: absolute;
  top: 10px;
  right: 40px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.55);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.note__close:hover {
  background: #fff;
}

/* ── All notes (list below the sky; also the calm, reduced-motion view) ───── */

.all-notes {
  padding: clamp(36px, 6vw, 64px) 0 20px;
  background: var(--grain), linear-gradient(180deg, #F6F7FC 0%, var(--cream) 340px);
  color: var(--ink);
}

.all-notes:focus {
  outline: none;
}

.all-notes .section__head {
  margin-bottom: 16px;
}

.notes-status {
  margin: 14px 0 22px;
  color: var(--ink-soft);
  font-weight: 600;
}

.notes-grid {
  columns: 270px;
  column-gap: 26px;
}

.notes-grid .note {
  position: relative;
  width: 100%;
  margin: 0 0 30px;
  break-inside: avoid;
  cursor: default;
  transform: rotate(var(--tilt, 0deg));
  will-change: auto;
}

.notes-grid .note__text {
  display: block;
  -webkit-line-clamp: unset;
}

.notes-grid .note--cloud .note__paper {
  margin-top: 26px;
}

/* ── Stationery form ──────────────────────────────────────────────────────── */

.stationery {
  width: min(640px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  background:
    radial-gradient(120% 60% at 0% 0%, rgb(249 217 223 / 0.35), transparent 60%),
    radial-gradient(100% 50% at 100% 100%, rgb(213 229 245 / 0.45), transparent 60%),
    #FFFDF7;
}

.stationery__form {
  position: relative;
  padding: 36px clamp(16px, 4vw, 34px) 22px;
}

.stationery__tape {
  position: absolute;
  top: 2px;
  left: 50%;
  width: 132px;
  height: 24px;
  background: repeating-linear-gradient(45deg, rgb(244 199 207 / 0.85) 0 8px, rgb(249 221 226 / 0.85) 8px 16px);
  transform: translateX(-50%) rotate(-2deg);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}

.stationery__title {
  margin: 0 40px 2px 0;
  font: 700 clamp(30px, 6vw, 38px)/1.05 var(--font-hand);
}

.stationery__lead {
  color: var(--ink-soft);
  font-size: 15px;
}

.kinds,
.picker {
  min-width: 0;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
}

.kinds legend,
.picker legend {
  margin-bottom: 8px;
  padding: 0;
}

.kinds__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 480px) {
  .kinds__grid {
    grid-template-columns: 1fr;
  }
}

.kind {
  position: relative;
  display: block;
  cursor: pointer;
}

.kind input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.kind__box {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 2px 8px;
  height: 100%;
  padding: 10px 12px;
  border-radius: 16px;
  background: #fff;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--type-color) 30%, transparent);
  transition: background-color 0.2s, box-shadow 0.2s;
}

.kind__icon {
  display: grid;
  place-items: center;
  grid-row: span 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--type-color) 14%, #fff);
  color: var(--type-color);
}

.kind__icon svg {
  width: 18px;
  height: 18px;
}

.kind__label {
  font-weight: 800;
  font-size: 15px;
  line-height: 1.2;
}

.kind__hint {
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.25;
}

.kind input:checked + .kind__box {
  background: color-mix(in srgb, var(--type-color) 12%, #fff);
  box-shadow: inset 0 0 0 2.5px var(--type-color);
}

.kind input:checked + .kind__box .kind__icon {
  background: var(--type-color);
  color: #fff;
}

.kind input:focus-visible + .kind__box {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* The writing area looks like a lined note card in the chosen paper color */
.letter {
  position: relative;
  border-radius: 18px;
  background-color: var(--paper-color, #FBEBB8);
  box-shadow: inset 0 0 0 1.5px rgb(59 52 66 / 0.08);
  transition: background-color 0.3s, box-shadow 0.2s;
}

.letter:focus-within {
  box-shadow: inset 0 0 0 1.5px rgb(59 52 66 / 0.1), 0 0 0 4px color-mix(in srgb, var(--sky-deep) 22%, transparent);
}

.letter textarea {
  display: block;
  min-height: 210px;
  padding: 14px 56px 34px 54px;
  border: 0;
  border-radius: 18px;
  background-color: transparent;
  background-image:
    linear-gradient(90deg, transparent 40px, rgb(200 90 110 / 0.35) 40px, rgb(200 90 110 / 0.35) 41.5px, transparent 41.5px),
    repeating-linear-gradient(180deg, transparent 0 33px, rgb(70 80 140 / 0.16) 33px 34px);
  background-position: 0 0, 0 14px;
  background-attachment: local;
  font: 400 22px/34px var(--font-note);
  resize: vertical;
}

.letter textarea:focus {
  border: 0;
  box-shadow: none;
}

.letter__sticker {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  height: 44px;
  transform: rotate(10deg);
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgb(0 0 0 / 0.15));
}

.letter__sticker svg {
  width: 100%;
  height: 100%;
}

.letter__count {
  position: absolute;
  right: 16px;
  bottom: 8px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.letter__count.is-near {
  color: #A3322A;
}

.signature {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px 10px;
  margin: 12px 0 16px;
}

.signature__label {
  color: var(--ink-soft);
  font: 700 26px/1 var(--font-hand);
}

.signature input {
  width: min(280px, 100%);
  min-height: 46px;
  padding: 4px 6px;
  border: 0;
  border-bottom: 2px dashed rgb(59 52 66 / 0.3);
  border-radius: 0;
  background: transparent;
  font: 700 30px/1 var(--font-hand);
}

.signature input:focus {
  border-bottom-color: var(--sky-deep);
  box-shadow: none;
}

.pickers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 28px;
}

.swatches,
.sticker-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.swatch {
  width: 38px;
  height: 38px;
  margin: 3px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1.5px rgb(0 0 0 / 0.12);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: transform 0.15s, box-shadow 0.15s;
}

.swatch:checked {
  box-shadow: inset 0 0 0 1.5px rgb(0 0 0 / 0.12), 0 0 0 3px #fff, 0 0 0 5.5px var(--ink);
  transform: scale(1.06);
}

.swatch:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 5px;
}

.sticker-opt {
  position: relative;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
}

.sticker-opt input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 14px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: background-color 0.15s, box-shadow 0.15s;
}

.sticker-opt input:hover {
  background: var(--cream);
}

.sticker-opt input:checked {
  background: var(--butter);
  box-shadow: inset 0 0 0 2px var(--ink);
}

.sticker-opt input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.sticker-opt svg {
  position: relative;
  width: 38px;
  height: 38px;
  pointer-events: none;
}

.turnstile:not(:empty) {
  margin: 4px 0 10px;
}

/* ── Calm mode (prefers-reduced-motion) ───────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .aurora {
    animation: none;
  }
  .scene__pause {
    display: none;
  }
}
