/* 今日串门
   独立绘制的小院子，不引用外部资源。 */

:root {
  --ink: #3A3328;
  --ink-soft: #6A5E4E;
  --paper: #FFF8EE;
  --paper-2: #F3E6CF;
  --accent: #C56A3A;
  --accent-deep: #A5522A;
  --preview: #8A4B12;
  --preview-bg: #F3D7A0;
  --bar-h: 34px;
  --safe-top: env(safe-area-inset-top, 0px);
  font-family: "Noto Sans CJK SC", "Noto Sans SC", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #CDB99A;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

.app {
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  max-height: 100dvh;
  background: var(--paper);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 0 1px rgba(80, 50, 20, 0.08), 0 16px 40px rgba(80, 50, 20, 0.18);
  overflow: hidden;
}

.site-exit {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
  padding: calc(8px + var(--safe-top)) 16px 6px;
  text-align: left;
  background: transparent;
}
.site-exit a {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.site-exit a:hover,
.site-exit a:focus-visible {
  color: var(--ink);
  border-bottom-color: currentColor;
}
.legal {
  flex: 0 0 auto;
  margin: 0;
  padding: 6px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}
.legal a {
  color: inherit;
  text-decoration: none;
}
.legal a:hover,
.legal a:focus-visible {
  text-decoration: underline;
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* ---------- 门口 ---------- */

.gate-screen {
  background:
    linear-gradient(180deg, #B7D6EA 0%, #D5E6CE 48%, #E8D7B0 100%);
}

.gate-head {
  text-align: center;
  padding: 18px 24px 8px;
}

.gate-head h1,
.yard-head h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--ink);
}

.gate-copy,
.greeting {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.gate-art {
  flex: 1;
  min-height: 180px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.moon {
  width: min(56vw, 220px);
  height: min(56vw, 220px);
  border-radius: 50%;
  background: #E8D9BE;
  padding: 10px;
  box-shadow:
    0 0 0 4px #C8B48E,
    0 0 0 10px #E8D9BE,
    0 10px 24px rgba(80, 50, 20, 0.18);
  position: relative;
  z-index: 2;
}

.moon-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background:
    radial-gradient(circle at 40% 40%, #D6E6B8, #A8C47A 70%);
  position: relative;
}

.doors {
  position: absolute;
  inset: 0;
  perspective: 600px;
}

.door {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  background:
    linear-gradient(90deg, #B07A48, #C9925C 40%, #A06A3C);
  transition: transform 0.8s cubic-bezier(0.4, 0.05, 0.2, 1);
  transform-origin: left center;
}

.door::after {
  content: "";
  position: absolute;
  top: 46%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #E8C878;
  box-shadow: 0 0 0 2px #8A5A30;
}

.door-l { left: 0; border-right: 1px solid #8A5A30; }
.door-l::after { right: 10px; }
.door-r {
  right: 0;
  transform-origin: right center;
  border-left: 1px solid #8A5A30;
}
.door-r::after { left: 10px; }

.gate-screen.opening .door-l { transform: rotateY(-78deg); }
.gate-screen.opening .door-r { transform: rotateY(78deg); }

.gate-wall {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 42%;
  background: linear-gradient(180deg, #F7F1E6, #E8DCC8);
  clip-path: polygon(0 18%, 22% 18%, 22% 0, 78% 0, 78% 18%, 100% 18%, 100% 100%, 0 100%);
  /* clip leaves a notch; moon sits in the opening. kept simple: flat wall behind moon */
  clip-path: none;
  mask-image: radial-gradient(circle at 50% -10%, transparent 90px, #000 91px);
}

@media (min-width: 400px) {
  .gate-wall {
    mask-image: radial-gradient(circle at 50% -20%, transparent 110px, #000 111px);
  }
}

.enter-form {
  padding: 8px 24px calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.enter-form label {
  font-size: 13px;
  color: var(--ink-soft);
}

.optional { opacity: 0.7; }

.enter-form input {
  appearance: none;
  border: 1px solid #D2C0A0;
  background: #FFFDF8;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  outline: none;
}

.enter-form input:focus {
  border-color: #C56A3A;
  box-shadow: 0 0 0 3px rgba(197, 106, 58, 0.18);
}

.btn-enter,
.btn-water {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #FFF8EE;
  background: linear-gradient(180deg, #D47A48, #C56A3A);
  box-shadow: 0 4px 0 #A5522A;
  border-radius: 999px;
  padding: 14px 22px;
  font-size: 17px;
}

.btn-enter:active,
.btn-water:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #A5522A;
}

.btn-enter:focus-visible,
.btn-water:focus-visible {
  outline: 3px solid #E8C878;
  outline-offset: 2px;
}

/* ---------- 院子 ---------- */

.yard-screen {
  background: #B7D6EA;
}

.yard-head {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px 4px;
}

.yard-head h1 { font-size: 20px; letter-spacing: 0.14em; }

.greeting {
  margin: 0;
  font-size: 13px;
  text-align: right;
  flex: 1;
}

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: #A8D0EB;
}

.stage svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* idle motion */
.cloud.c1 { animation: drift 28s linear infinite; }
.cloud.c2 { animation: drift 36s linear infinite reverse; }

@keyframes drift {
  0% { transform: translateX(0); }
  50% { transform: translateX(14px); }
  100% { transform: translateX(0); }
}

.canopy {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: idleSway 5.5s ease-in-out infinite;
}
.canopy-left { animation-duration: 6.2s; animation-delay: -1s; }
.canopy-right { animation-duration: 5.2s; animation-delay: -2s; }
.canopy-top { animation-duration: 6.8s; }

@keyframes idleSway {
  0%, 100% { transform: rotate(-0.6deg); }
  50% { transform: rotate(0.8deg); }
}

.yard-screen.is-watering .canopy {
  animation: waterSway 0.45s ease-in-out 4;
}

@keyframes waterSway {
  0%, 100% { transform: rotate(-0.4deg); }
  25% { transform: rotate(3.4deg); }
  75% { transform: rotate(-3.2deg); }
}

.gold-cherry {
  transform-box: fill-box;
  transform-origin: top center;
}

/* watering FX hidden until active */
.water-fx { opacity: 0; pointer-events: none; }
.yard-screen.is-watering .water-fx { opacity: 1; }

.can-wrap {
  transform-origin: 20px 8px;
  transform-box: fill-box;
}

.yard-screen.is-watering .can-wrap {
  animation: canTip 1.6s ease-in-out;
}

@keyframes canTip {
  0% { transform: translate(40px, -20px) rotate(-8deg); opacity: 0; }
  18% { transform: translate(0, 0) rotate(-8deg); opacity: 1; }
  30%, 70% { transform: translate(0, 0) rotate(28deg); opacity: 1; }
  88% { transform: translate(16px, -8px) rotate(-6deg); opacity: 1; }
  100% { transform: translate(40px, -20px) rotate(-8deg); opacity: 0; }
}

.yard-screen.is-watering .jet {
  animation: jetPulse 0.6s ease-in-out infinite;
}

@keyframes jetPulse {
  0%, 100% { opacity: 0.15; stroke-width: 3; }
  50% { opacity: 0.85; stroke-width: 6; }
}

.yard-screen.is-watering .drop {
  animation: dropFall 0.65s linear infinite;
}

.drop.d2 { animation-delay: 0.08s; }
.drop.d3 { animation-delay: 0.16s; }
.drop.d4 { animation-delay: 0.04s; }
.drop.d5 { animation-delay: 0.22s; }
.drop.d6 { animation-delay: 0.12s; }
.drop.d7 { animation-delay: 0.2s; }
.drop.d8 { animation-delay: 0.28s; }

@keyframes dropFall {
  0% { opacity: 0; transform: translate(0, 0) scale(0.7); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translate(-70px, 70px) scale(1.15); }
}

.yard-screen.is-watering .sp {
  animation: burst 0.9s ease-out infinite;
}

.sp.s2 { animation-delay: 0.08s; }
.sp.s3 { animation-delay: 0.16s; }
.sp.s4 { animation-delay: 0.05s; }
.sp.s5 { animation-delay: 0.2s; }
.sp.s6 { animation-delay: 0.12s; }
.sp.s7 { animation-delay: 0.24s; }
.sp.s8 { animation-delay: 0.1s; }
.sp.s9 { animation-delay: 0.18s; }
.sp.s10 { animation-delay: 0.28s; }
.sp.s11 { animation-delay: 0.14s; --sx: -8px; --sy: -46px; }
.sp.s12 { animation-delay: 0.22s; --sx: 18px; --sy: -44px; }

@keyframes burst {
  0% { opacity: 0; transform: translate(0, 0) scale(0.4); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--sx, 12px), var(--sy, -28px)) scale(0.2); }
}

.sp.s1 { --sx: -16px; --sy: -36px; }
.sp.s2 { --sx: -28px; --sy: -18px; }
.sp.s3 { --sx: 22px; --sy: -30px; }
.sp.s4 { --sx: -36px; --sy: -8px; }
.sp.s5 { --sx: 30px; --sy: -20px; }
.sp.s6 { --sx: 4px; --sy: -42px; }
.sp.s7 { --sx: 10px; --sy: 16px; }
.sp.s8 { --sx: 26px; --sy: -40px; }
.sp.s9 { --sx: -40px; --sy: 8px; }
.sp.s10 { --sx: 36px; --sy: 10px; }

.yard-screen.is-watering .puddle {
  animation: puddle 1.6s ease-in-out;
}

@keyframes puddle {
  0%, 100% { opacity: 0; transform: scale(0.6); }
  40%, 60% { opacity: 0.35; transform: scale(1); }
}

/* fallen cherries */
.fallen {
  cursor: pointer;
  transform-box: fill-box;
  transform-origin: center;
}
.fallen:focus { outline: none; }
.fallen:focus-visible circle.hit {
  stroke: #C56A3A;
  stroke-width: 2;
  fill: transparent;
}
.fallen.bob {
  animation: bob 2.4s ease-in-out infinite;
}
.fallen:nth-child(2) { animation-delay: 0.3s; }
.fallen:nth-child(3) { animation-delay: 0.7s; }
.fallen:nth-child(4) { animation-delay: 1.1s; }
.fallen:nth-child(5) { animation-delay: 0.5s; }

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

.fallen.flying {
  animation: none;
  pointer-events: none;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.55s ease;
  transform: translate(var(--dx, 0px), var(--dy, 0px)) scale(0.45);
  opacity: 0.2;
}

/* basket fruit inside scenic basket */
.basket-cherry { }

/* ---------- 底部操作 ---------- */

.actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(255, 248, 238, 0), #FFF8EE 28%, #F3E6CF);
}

.btn-water {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
}

.btn-water:disabled {
  opacity: 0.65;
  cursor: default;
}

.can-icon { display: flex; color: #FFF8EE; }

.basket-ui {
  flex: 0 0 112px;
  background: #FFFDF8;
  border: 1px solid #D2C0A0;
  border-radius: 16px;
  padding: 8px 10px;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.basket-label {
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
}

.basket-dots {
  display: flex;
  gap: 4px;
  min-height: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.basket-dots .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFF6C4, #E8C230 58%, #C99612);
  box-shadow: inset -1px -1px 0 #B8860B;
}

.basket-dots .empty-hint {
  font-size: 12px;
  color: #A89880;
}

/* toast */
.toast {
  position: absolute;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(58, 51, 40, 0.9);
  color: #FFF8EE;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
  z-index: 30;
}

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

@media (prefers-reduced-motion: reduce) {
  .canopy, .cloud.c1, .cloud.c2, .fallen.bob {
    animation: none;
  }
  .door, .toast, .fallen.flying {
    transition: none;
  }
}

@media (min-width: 800px) {
  body { background: #C4B091; }
}
