@font-face {
  font-family: 'Amatica SC';
  src: url('assets/fonts/AmaticaSC-Regular.ttf') format('truetype');
  font-weight: 400; font-style: normal; font-display: swap;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-height: 100%; }
body { background: #faf7f0; color: #25211e; }
button { font: inherit; }
.room { position: relative; height: 100svh; min-height: 320px; overflow: hidden; isolation: isolate; }
.scene {
  position: absolute; left: 50%; top: 50%;
  width: max(100vw, 176.4831svh); aspect-ratio: 1666 / 944;
  transform: translate(-50%, -50%);
}
.scene-background { display: block; width: 100%; height: 100%; user-select: none; pointer-events: none; }
.wordmark {
  position: absolute; z-index: 2; left: 8%; top: 32.5%;
  display: flex; flex-direction: column; gap: 1.32vw; margin: 0;
  font-family: 'Amatica SC', 'Arial Narrow', sans-serif;
  font-size: clamp(48px, 5.7vw, 132px); font-weight: 400; line-height: 1.05; letter-spacing: .035em;
}
.wordmark span { display: block; }
.keepsake {
  position: absolute; z-index: 3; margin: 0; padding: 0; border: 0; border-radius: 8px;
  background: none; appearance: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
  outline: none; touch-action: manipulation; overflow: visible;
  /* A stationary hit area prevents a lifted object from losing hover. */
}
.keepsake--pink { left: 41%; top: 73.19915%; width: 6.30252%; height: 9.32203%; }
.keepsake--history { left: 32.5%; top: 75.42373%; width: 6.30252%; height: 5.99194%; }
.keepsake--blue { left: 47.4%; top: 73.83475%; width: 6.30252%; height: 8.47458%; }
.keepsake--letter { left: 55.4%; top: 73.19915%; width: 14.64586%; height: 9.53390%; }
.keepsake:focus-visible { outline: 1px dashed #937960; outline-offset: 7px; }
.keepsake.is-awake { z-index: 5; }
.object-body, .object-shadow { position: absolute; inset: 0; display: block; pointer-events: none; }
.object-body { transform-origin: 50% 65%; backface-visibility: hidden; }
.object-body img, .object-shadow img { display: block; width: 100%; height: 100%; user-select: none; }
.object-shadow { opacity: .045; filter: brightness(0) blur(1px); transform: translate(1px, 1px); }
.keepsake.is-awake .object-body { will-change: transform; }
.hint {
  position: absolute; left: 50%; bottom: calc(100% + 17px);
  display: block; padding: 7px 11px 8px;
  color: #6c5848; background: rgba(255, 252, 246, .92);
  border: 1px solid rgba(158, 127, 96, .16); border-radius: 5px 8px 6px 9px;
  box-shadow: 0 3px 12px rgba(100, 72, 46, .045);
  font: 400 clamp(12px, 1vw, 16px)/1.5 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  letter-spacing: .13em; white-space: nowrap;
  opacity: 0; visibility: hidden; transform: translate(-50%, 5px);
  transition: opacity 220ms ease, transform 320ms ease, visibility 220ms;
  pointer-events: none;
}
.keepsake.is-active .hint { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 110ms; }
@media (max-aspect-ratio: 1/1) {
  .room { background: url('assets/city-scene-clean.png') left top / auto 250svh; }
  .scene { width: min(208vw, 140svh); top: 62%; mask-image: linear-gradient(transparent, #000 9%, #000 91%, transparent); }
  .wordmark { left: 12%; top: 9%; font-size: clamp(44px, 10vw, 64px); gap: 2vw; }
  .hint { font-size: 13px; bottom: calc(100% + 14px); }
}
@media (prefers-reduced-motion: reduce) { .hint { transition: opacity 120ms; } }

/* Clouds are separate original-art cutouts; clip them behind the window and roofs. */
.cloud-layer { position: absolute; inset: 0; pointer-events: none; clip-path: polygon(37.815% 18.114%, 62.785% 18.114%, 58.703% 22.669%, 58.643% 31.886%, 54.922% 36.441%, 54.922% 39.619%, 41.056% 39.619%, 40.456% 36.653%, 39.916% 34.852%, 39.976% 33.051%, 39.016% 31.992%, 37.815% 31.992%); }
.cloud { position: absolute; display: block; user-select: none; will-change: transform; }
.cloud--left { left: 39.25570%; top: 31.14407%; width: 6.96279%; height: 4.13136%; }
.cloud--small { left: 46.09844%; top: 34.63983%; width: 5.34214%; height: 2.86017%; }
.cloud--high { left: 51.32053%; top: 27.01271%; width: 6.54262%; height: 4.66102%; }
.cloud--left { animation: cloud-left 48s linear -12s infinite; }
.cloud--small { animation: cloud-small 57s linear -23s infinite; }
.cloud--high { animation: cloud-high 43s linear -28s infinite; }
/* Travel continuously across the sky; wrap only when fully behind its boundaries. */
@keyframes cloud-left { from { transform: translate(-120%, 0); } to { transform: translate(310%, 0); } }
@keyframes cloud-small { from { transform: translate(-240%, 0); } to { transform: translate(270%, 0); } }
@keyframes cloud-high { from { transform: translate(-300%, 0); } to { transform: translate(140%, 0); } }
@media (prefers-reduced-motion: reduce) { .cloud { animation: none; will-change: auto; } }

/* ===== 信纸面板（右 1/3）与折叠飞出动效 ===== */
.desk {
  position: absolute; z-index: 8; right: 4.5vw; top: 50%;
  width: min(24vw, 380px); min-width: 300px;
  transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.desk[hidden] { display: none; }
.desk.is-entering { animation: desk-in 480ms cubic-bezier(.22,.9,.3,1) both; }
@keyframes desk-in {
  from { opacity: 0; transform: translateY(-50%) translateX(26px) rotate(1.2deg); }
  to { opacity: 1; transform: translateY(-50%) translateX(0) rotate(0); }
}
.paper-stage { perspective: 1100px; width: 100%; }
.paper {
  position: relative; width: 100%; aspect-ratio: 5 / 6.4;
  transform-style: preserve-3d;
  transform: rotate(-.5deg);
  transition: transform 620ms ease-in, opacity 520ms ease-in;
  filter: drop-shadow(0 10px 18px rgba(96, 70, 44, .14));
}
.paper-half { position: absolute; left: 0; width: 100%; height: 50%; transform-style: preserve-3d; }
.paper-half--top { top: 0; transform-origin: 50% 100%; transition: transform 700ms cubic-bezier(.55,.06,.35,1); }
.paper-half--bottom { top: 50%; transform-origin: 50% 0; transition: transform 750ms cubic-bezier(.55,.06,.35,1); }
.paper-face {
  position: absolute; inset: 0; overflow: hidden;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: #fdfaf2;
  border: 1.5px solid rgba(146, 116, 84, .55);
}
.paper-half--top .paper-face { border-radius: 3px 7px 2px 5px / 5px 3px 0 0; border-bottom-style: dashed; border-bottom-color: rgba(146,116,84,.3); }
.paper-half--bottom .paper-face { border-radius: 0 0 4px 6px / 0 0 5px 3px; border-top: 0; }
.paper-face--back {
  transform: rotateX(180deg);
  background:
    linear-gradient(rgba(120, 92, 62, .05), rgba(120, 92, 62, .11)),
    #f7f1e3;
  border-bottom-style: solid;
}
/* 翻面后成为可见面，需恢复完整描边（正反两面翻转相抵，其 top 边即在视觉顶部） */
.paper-half--bottom .paper-face--back {
  border-top: 1.5px solid rgba(146, 116, 84, .55);
  border-radius: 3px 5px 4px 6px / 4px 3px 5px 3px;
}
.paper-sheet {
  position: absolute; left: 0; width: 100%; height: 200%; padding: 26px 24px;
  background: repeating-linear-gradient(to bottom, transparent 0 31px, rgba(150, 120, 90, .30) 31px 32px);
  background-position: 0 26px;
}
.paper-half--bottom .paper-sheet { top: -100%; }
.paper-text {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font: 400 clamp(15px, 1.1vw, 18px)/32px 'Xingkai SC', 'STXingkai', 'Xingkai', 'Kaiti SC', 'STKaiti', 'Songti SC', serif;
  color: #5d4936; letter-spacing: .08em;
}
.paper-input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 26px 24px;
  border: 1.5px solid rgba(146, 116, 84, .55); border-radius: 3px 7px 4px 6px / 5px 3px 6px 4px;
  background: repeating-linear-gradient(to bottom, transparent 0 31px, rgba(150, 120, 90, .30) 31px 32px), #fdfaf2;
  background-position: 0 26px, 0 0;
  font: 400 clamp(15px, 1.1vw, 18px)/32px 'Xingkai SC', 'STXingkai', 'Xingkai', 'Kaiti SC', 'STKaiti', 'Songti SC', serif;
  color: #5d4936; letter-spacing: .08em; resize: none; outline: none;
  caret-color: #8a6a48;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.paper-input::placeholder { color: rgba(140, 112, 82, .55); }
.paper-input:focus { border-color: rgba(146, 116, 84, .8); box-shadow: 0 0 0 3px rgba(160, 128, 92, .10); }
.paper.is-folding .paper-input { display: none; }
.desk.is-folding .fold-button { opacity: 0; pointer-events: none; }

/* 我的回信 / 别人的烦恼：同一张信纸，只读或上半读+下半回 */
.paper-read, .paper-share {
  position: absolute; inset: 0; overflow: hidden;
  border: 1.5px solid rgba(146, 116, 84, .55); border-radius: 3px 7px 4px 6px / 5px 3px 6px 4px;
  background: repeating-linear-gradient(to bottom, transparent 0 31px, rgba(150, 120, 90, .30) 31px 32px), #fdfaf2;
  background-position: 0 26px, 0 0;
}
.paper-read[hidden], .paper-share[hidden] { display: none; }
.letter-date {
  margin: 0 0 6px; text-align: right; color: rgba(93, 73, 54, .82);
  font: 400 clamp(13px, .95vw, 15px)/32px 'Xingkai SC', 'STXingkai', 'Xingkai', 'Kaiti SC', 'STKaiti', 'Songti SC', serif;
  letter-spacing: .08em;
}
.letter-body {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font: 400 clamp(15px, 1.1vw, 18px)/32px 'Xingkai SC', 'STXingkai', 'Xingkai', 'Kaiti SC', 'STKaiti', 'Songti SC', serif;
  color: #5d4936; letter-spacing: .08em;
}
.letter-reply {
  margin: 14px 0 0; padding-top: 6px; border-top: 1px dashed rgba(146, 116, 84, .45);
  font: 400 clamp(15px, 1.1vw, 18px)/32px 'Xingkai SC', 'STXingkai', 'Xingkai', 'Kaiti SC', 'STKaiti', 'Songti SC', serif;
  color: #5d4936; letter-spacing: .08em;
}
.letter-reply-label { color: rgba(93, 73, 54, .62); }
.paper-read { padding: 26px 24px; }
.paper-share { display: flex; flex-direction: column; }
.share-top { padding: 26px 24px 0; flex: 0 0 auto; }
.share-input {
  flex: 1; margin: 14px 0 0; padding: 6px 24px 16px;
  border: 0; border-top: 1px dashed rgba(146, 116, 84, .45);
  background: none; resize: none; outline: none;
  font: 400 clamp(15px, 1.1vw, 18px)/32px 'Xingkai SC', 'STXingkai', 'Xingkai', 'Kaiti SC', 'STKaiti', 'Songti SC', serif;
  color: #5d4936; letter-spacing: .08em; caret-color: #8a6a48;
}
.share-input::placeholder { color: rgba(140, 112, 82, .55); }
.paper.is-fold-1 .paper-half--bottom { transform: rotateX(-179.5deg); z-index: 2; }
.paper.is-vanish { transform: rotate(-10deg) translateY(19%) scale(.16); opacity: 0; }
.fold-button {
  font: 400 clamp(13px, .95vw, 16px)/1 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  letter-spacing: .18em; color: #6c5848; cursor: pointer;
  background: none; border: 0; padding: 10px 6px 12px;
  transition: color 180ms ease, transform 180ms ease, opacity 200ms ease;
}
.fold-button:hover:not(:disabled) { color: #4a3a2c; transform: translateY(-2px); }
.fold-button:disabled { opacity: .38; cursor: default; }

/* 飞行中的纸飞机 */
.flight-plane {
  position: fixed; z-index: 9; left: 0; top: 0; width: 118px;
  pointer-events: none; opacity: 0; will-change: transform;
  filter: drop-shadow(3px 7px 6px rgba(96, 70, 44, .18));
}
.flight-plane img { display: block; width: 100%; user-select: none; }

/* 窗户右下角的呼吸投放区：只有弥散阴影 */
.launch-zone {
  position: absolute; z-index: 6;
  left: 62.5%; top: 61.5%;
  width: 9%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
  animation: zone-breathe 2.8s ease-in-out infinite;
}
.launch-zone[hidden] { display: none; }
.launch-zone::before {
  content: ''; position: absolute; inset: -22%; z-index: -1; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(122, 94, 66, .30), rgba(122, 94, 66, .12) 55%, transparent 76%);
  filter: blur(8px);
}
.zone-text {
  width: max-content;
  text-align: center;
  transition: opacity 200ms ease;
  color: #55422f;
  text-shadow: 0 0 3px rgba(255, 253, 247, .95), 0 0 7px rgba(255, 253, 247, .85), 0 0 12px rgba(255, 253, 247, .7), 0 1px 2px rgba(255, 253, 247, .9);
  font: 400 clamp(11px, .85vw, 14px)/1.6 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  letter-spacing: .1em;
}
.launch-zone.is-armed::before {
  background: radial-gradient(closest-side, rgba(122, 94, 66, .42), rgba(122, 94, 66, .17) 55%, transparent 76%);
}
.launch-zone.is-armed .zone-text { opacity: 0; }
.launch-zone.is-done { transition: opacity 450ms ease; opacity: 0; animation-play-state: paused; }
@keyframes zone-breathe {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: .75; }
  50% { transform: translate(-50%, -50%) scale(1.09); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .launch-zone { animation: none; }
}

@media (prefers-reduced-motion: reduce) {
  .desk.is-entering { animation: none; }
  .paper, .paper-half--top, .paper-half--bottom { transition-duration: 120ms; }
}

/* A quiet stack of paper, beside the window, for demo memories. */
.history-panel {
  position: absolute; z-index: 8; right: 4.5vw; top: 50%;
  width: min(24vw, 380px); min-width: 300px; max-height: 78svh;
  transform: translateY(-50%); padding: 25px 24px 20px;
  display: flex; flex-direction: column;
  color: #65513e; background: #faf7ef url('assets/city-scene-clean.png') left top / 1666px 944px;
  border: 1px solid #aa9277; border-radius: 3px 7px 4px 6px / 5px 3px 6px 4px;
  box-shadow: 3px 4px 0 -1px #f3edde, 3px 4px 0 0 #c5b29b, 0 12px 24px #60462c14;
  font: 400 13px/1.8 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  animation: desk-in 480ms cubic-bezier(.22,.9,.3,1) both;
}
.history-panel[hidden] { display: none; }
.history-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.history-eyebrow { margin: 0 0 5px; font-size: 11px; letter-spacing: .15em; color: #9a8670; }
.history-header h2 { margin: 0; font-size: 22px; font-weight: 400; letter-spacing: .15em; }
.history-close { border: 0; background: none; padding: 0 4px; font-size: 25px; line-height: 1.2; color: #9b846e; cursor: pointer; }
.history-close:hover { color: #604a37; }
.history-close:focus-visible { outline: 1px dashed #937960; outline-offset: 3px; }
.history-list { list-style: none; padding: 0; margin: 17px 0 20px; overflow-y: auto; min-height: 0; }
.history-list li { padding: 12px 0; border-bottom: 1px solid #aa92772e; }
.history-meta { display: flex; gap: 12px; align-items: center; color: #98816b; font-size: 11px; }
.history-meta time { font-variant-numeric: tabular-nums; letter-spacing: .08em; }
.history-meta span { color: #8c9280; }
.history-list p { margin: 4px 0 0; }
.history-summary {
  flex-shrink: 0; padding: 15px 14px 10px;
  background: rgba(176, 187, 157, .16);
  border: 1px solid rgba(131, 146, 113, .24);
  border-radius: 4px 9px 5px 7px / 7px 4px 8px 5px;
  color: #62684f;
}
.history-summary-title {
  margin: 0 0 10px; font-size: 14px; font-weight: 500; letter-spacing: .12em;
  color: #6c785b;
}
.history-summary p { margin: 4px 0; font-size: 12px; }
.history-summary .history-stats {
  display: flex; justify-content: space-between; gap: 8px;
  margin: 0 0 11px; padding-bottom: 9px;
  border-bottom: 1px solid rgba(131, 146, 113, .22);
  color: #7a836b; font-size: 11px;
}
.history-summary small { display: block; margin-top: 12px; color: #b1a28e; font-size: 10px; text-align: right; }
@media (prefers-reduced-motion: reduce) { .history-panel { animation: none; } }

.credit {
  position: absolute; z-index: 8; right: 12px; bottom: 9px; margin: 0;
  font: 400 10.5px/1.4 Helvetica, 'Helvetica Neue', Arial, sans-serif;
  color: rgba(110, 105, 98, .5); letter-spacing: .03em;
}
