/* layout.css — 页面布局、大海场景、波浪、响应式 */

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 顶部 */
.app-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 6px;
  color: #f8efd4;
  text-shadow: 0 2px 4px rgba(40, 30, 15, 0.5);
}

.app-title {
  margin: 0;
  font-size: clamp(22px, 4vw, 34px);
  letter-spacing: 6px;
  font-weight: 700;
}

.app-header .btn {
  letter-spacing: 1px;
  padding: 8px 14px;
  font-size: 14px;
}

/* 大海 */
.sea {
  position: relative;
  flex: 1;
  min-height: 360px;
  overflow: hidden;
  background: #0e3a5c;
}

/* 天空时间遮罩：根据现实时间变色（黎明/白天/黄昏/夜晚） */
.sky-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 2;
  transition: background 1.5s ease;
}

.sun {
  position: absolute;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffe8a3 0 38%, #f2c96a 70%, rgba(242, 201, 106, 0) 72%);
  box-shadow: 0 0 40px rgba(255, 225, 150, 0.55);
  z-index: 3;
  transition: top 1.5s ease, left 1.5s ease, opacity 1s ease;
}

/* 星星层 */
.stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transition: opacity 2s ease;
}

.stars.visible {
  opacity: 1;
}

.star {
  position: absolute;
  width: 3px;
  height: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
  animation: starTwinkle 2s ease-in-out infinite;
}

@keyframes starTwinkle {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

.moon {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f5f0e0 0%, #d8d0bc 60%, #b8b09a 100%);
  box-shadow: 0 0 30px rgba(220, 215, 195, 0.4);
  z-index: 3;
  transition: top 1.5s ease, left 1.5s ease, opacity 1s ease;
}

/* 视频背景 */
.sea-bg-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
}

/* ===== 动态大海 ===== */
.sea-dynamic {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

/* 远海波浪：两层不同速度缓缓流动 */
.dy-wave {
  position: absolute;
  left: -5%;
  width: 110%;
  height: 90px;
  background-image: url('../images/wave.svg');
  background-repeat: repeat-x;
  background-size: 600px 100%;
}

.dy-wave-1 {
  top: 50%;
  opacity: 0.6;
  animation: waveDrift 14s linear infinite;
}

.dy-wave-2 {
  top: 58%;
  opacity: 0.4;
  transform: scaleY(-1);
  animation: waveDrift 22s linear infinite reverse;
}

@keyframes waveDrift {
  from { background-position-x: 0; }
  to { background-position-x: -600px; }
}

/* 近岸浪花：周期性涨落拍打沙滩 */
.dy-surge {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10%;
  height: 50px;
  background: linear-gradient(180deg,
    rgba(255, 255, 255, 0.55) 0%,
    rgba(255, 255, 255, 0.25) 40%,
    rgba(255, 255, 255, 0) 100%);
  animation: surgePulse 4.5s ease-in-out infinite;
  transform-origin: bottom center;
}

@keyframes surgePulse {
  0%, 100% {
    transform: scaleY(0.5) translateY(12px);
    opacity: 0.35;
  }
  40% {
    transform: scaleY(1.3) translateY(-6px);
    opacity: 0.75;
  }
  60% {
    transform: scaleY(1.1) translateY(-3px);
    opacity: 0.65;
  }
}

/* 海面波光闪烁 */
.dy-sparkles {
  position: absolute;
  top: 48%;
  left: 0;
  right: 0;
  height: 30%;
  background-image:
    radial-gradient(circle at 15% 30%, rgba(255,255,255,0.4) 0%, transparent 2%),
    radial-gradient(circle at 35% 60%, rgba(255,255,255,0.3) 0%, transparent 1.5%),
    radial-gradient(circle at 55% 25%, rgba(255,255,255,0.35) 0%, transparent 2%),
    radial-gradient(circle at 75% 50%, rgba(255,255,255,0.25) 0%, transparent 1.5%),
    radial-gradient(circle at 88% 35%, rgba(255,255,255,0.3) 0%, transparent 2%),
    radial-gradient(circle at 25% 75%, rgba(255,255,255,0.2) 0%, transparent 1.5%),
    radial-gradient(circle at 65% 80%, rgba(255,255,255,0.25) 0%, transparent 2%),
    radial-gradient(circle at 45% 45%, rgba(255,255,255,0.3) 0%, transparent 1.5%);
  animation: sparkleTwinkle 3s ease-in-out infinite alternate;
}

@keyframes sparkleTwinkle {
  from { opacity: 0.4; }
  to { opacity: 0.9; }
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  filter: blur(1px);
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.cloud-1 {
  top: 10%;
  left: -10%;
  width: 120px;
  height: 34px;
  animation: drift 46s linear infinite;
}

.cloud-1::before { width: 46px; height: 46px; left: 18px; top: -22px; }
.cloud-1::after { width: 34px; height: 34px; right: 14px; top: -16px; }

.cloud-2 {
  top: 22%;
  left: -20%;
  width: 160px;
  height: 40px;
  opacity: 0.55;
  animation: drift 70s linear infinite;
  animation-delay: -30s;
}

.cloud-2::before { width: 60px; height: 60px; left: 24px; top: -28px; }
.cloud-2::after { width: 44px; height: 44px; right: 18px; top: -20px; }

@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(140vw); }
}

/* 波浪层 */
.wave {
  position: absolute;
  left: -10%;
  bottom: -6px;
  width: 120%;
  height: 110px;
  background-repeat: repeat-x;
  background-size: 240px 100%;
  opacity: 0.75;
  pointer-events: none;
}

.wave-1 {
  bottom: 8px;
  height: 130px;
  opacity: 0.5;
  animation: waveMove 11s linear infinite;
}

.wave-2 {
  bottom: -8px;
  height: 140px;
  opacity: 0.75;
  animation: waveMove 16s linear infinite;
}

.wave-3 {
  bottom: -22px;
  height: 150px;
  opacity: 0.9;
  animation: waveMove 22s linear infinite;
}

.wave-1 { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 60'%3E%3Cpath d='M0 35 C 30 20 60 50 90 35 C 120 20 150 50 180 35 C 210 20 240 50 240 35 L240 60 L0 60 Z' fill='%236eb6c6'/%3E%3C/svg%3E"); }
.wave-2 { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 60'%3E%3Cpath d='M0 35 C 40 50 80 20 120 35 C 160 50 200 20 240 35 L240 60 L0 60 Z' fill='%232c7e9d'/%3E%3C/svg%3E"); }
.wave-3 { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 60'%3E%3Cpath d='M0 38 C 35 22 70 52 110 38 C 150 24 190 52 240 38 L240 60 L0 60 Z' fill='%231c5c7d'/%3E%3C/svg%3E"); }

@keyframes waveMove {
  from { transform: translateX(0); }
  to { transform: translateX(-240px); }
}

/* 漂浮瓶区域 */
.bottles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.bottles > * {
  pointer-events: auto;
}

/* 底部主按钮 */
.actions {
  position: relative;
  z-index: 5;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(22, 93, 126, 0.85), rgba(18, 68, 92, 0.95));
  border-top: 2px solid rgba(255, 240, 200, 0.35);
}

.actions .btn {
  flex: 1 1 120px;
  max-width: 200px;
}

.sea-hint {
  position: absolute;
  left: 50%;
  bottom: 34%;
  transform: translateX(-50%);
  color: #eaf7f2;
  font-size: 15px;
  letter-spacing: 2px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  text-align: center;
}

.sea-hint.show {
  opacity: 1;
}

/* 抽屉面板 */
.drawer {
  width: min(92vw, 480px);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
  border-bottom: 1px solid #d8c392;
}

.drawer-header h2 { margin: 0; font-size: 20px; letter-spacing: 2px; }

.drawer-header .modal-close { position: static; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 18px;
}

/* 写瓶 / 确认纸张 */
.paper {
  width: min(92vw, 420px);
  padding: 24px 22px 20px;
}

.paper h2 { margin: 0 0 14px; font-size: 20px; letter-spacing: 3px; }

.paper textarea {
  width: 100%;
  min-height: 150px;
  padding: 12px;
  border: 1px solid #d3bd88;
  border-radius: 8px;
  background: rgba(255, 250, 230, 0.7);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.7;
}

.paper textarea:focus {
  outline: 2px solid var(--gold);
  background: #fff9e6;
}

.paper-foot,
.reply-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.paper-actions {
  display: flex;
  gap: 10px;
}

.confirm {
  width: min(90vw, 360px);
  padding: 24px 22px;
  text-align: center;
}

.confirm h2 { margin: 0 0 10px; }

.confirm p { margin: 0 0 18px; color: var(--ink-soft); line-height: 1.6; }

.confirm .paper-actions { justify-content: center; }

/* 移动端 */
@media (max-width: 640px) {
  .app-title { letter-spacing: 3px; }
  .actions { gap: 8px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .actions .btn { padding: 12px 10px; font-size: 15px; letter-spacing: 1px; }
  .sea { min-height: 300px; }
  .modal { padding: 12px; }
}
/* 大海内阴影与纸质晕染 */
.sea::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  box-shadow: inset 0 0 90px rgba(8, 36, 50, 0.55);
  background: linear-gradient(180deg, rgba(255, 247, 222, 0.12), rgba(255, 247, 222, 0) 22%, rgba(12, 44, 60, 0.16) 86%);
}

.sea-hint {
  z-index: 5;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(18, 48, 62, 0.35);
  color: #f3f0dc;
  letter-spacing: 2px;
}
/* ===== 太阳与白云美化 ===== */
.sun {
  width: 78px;
  height: 78px;
  background: radial-gradient(circle at 38% 30%, #fff7cf 0 14%, #ffe29a 36%, #f2c469 70%, rgba(242, 196, 105, 0) 72%);
  box-shadow: 0 0 34px 18px rgba(255, 225, 150, 0.45);
  opacity: 0.95;
}

.sun::before {
  content: "";
  position: absolute;
  inset: -18px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(255, 226, 150, 0.85) 0 5deg, transparent 5deg 16deg);
  -webkit-mask: radial-gradient(circle, transparent 0 40px, #000 41px 52px, transparent 53px);
  mask: radial-gradient(circle, transparent 0 40px, #000 41px 52px, transparent 53px);
  animation: sunSpin 46s linear infinite;
}

.sun::after {
  content: "";
  position: absolute;
  left: 24%;
  top: 18%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  filter: blur(1px);
}

@keyframes sunSpin {
  to { transform: rotate(360deg); }
}

.cloud {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(214, 233, 240, 0.72));
  box-shadow: 0 8px 16px rgba(40, 80, 100, 0.18), inset 0 -6px 10px rgba(140, 180, 200, 0.35);
  filter: blur(0.5px);
}

.cloud::before,
.cloud::after {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(214, 233, 240, 0.72));
  box-shadow: inset 0 -6px 10px rgba(140, 180, 200, 0.35);
}