/* 霍长卿的农场：夏目友人帐水彩风 —— 低饱和抹茶绿、青灰山雾、日式木屋 */
.farm {
  --sky-1: #9fc3d8;
  --sky-2: #c5dde6;
  --sky-3: #f2ecd7;
  --cloud: #fdfbf3;
  --cloud-shade: #dfe4dc;
  --sun: #f5d98a;
  --moon: #f7f0d8;
  --mtn-far: #a9c4bd;
  --mtn-mid: #8fb09c;
  --hill-back: #a3bd8a;
  --hill-main: #8fae76;
  --hill-front: #7c9c66;
  --pond-1: #8fbccb;
  --pond-2: #6798ad;
  --pond-edge: #d8cfab;
  --canopy: #86a86e;
  --canopy-dark: #6f925c;
  --canopy-hl: #c2d8ae;
  --sakura: #f0d3de;
  --sakura-dark: #e3bccb;
  --pine: #6f9270;
  --trunk: #8a7058;
  --grass-deep: #6a8a58;
  --roof: #7d8a99;
  --roof-shade: #66727f;
  --wall: #f5efe0;
  --window: #f2d894;
  --window-line: #d8bc7e;
  --eave: #8a7a62;
  --door: #9c7a56;
  --smoke: #ffffff;
  --fence: #e8e2d0;
  --pole: #8a8578;
  --wool: #f5f2e8;
  --hen: #f5efe2;
  --hen-wing: #e0d5bc;
  --cow: #f2efe6;
  --duck: #f0d896;
  --beak: #d8a05e;
  --comb: #d88a70;
  --blush: #e8b4a8;
  --petal: #e8c8d4;
  --core: #f0d08a;
  --fruit: #e0a890;
  --reed-head: #a08a68;
  --tint: transparent;
  --star-opacity: 0;
  --sun-opacity: 1;
  --moon-opacity: 0;
  --snow-opacity: 0;
  --window-glow: 0;

  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 520px;
  overflow: hidden;
  background: var(--sky-2);
  isolation: isolate;
}

.farm[data-weather="cloudy"] {
  --sky-1: #b9c8cd;
  --sky-2: #d2dcda;
  --sky-3: #e9e8d8;
  --sun-opacity: .28;
  --cloud: #f2f3ee;
  --cloud-shade: #d8ddd8;
  --hill-back: #93aa7e;
  --hill-main: #7e9a6a;
  --hill-front: #6d8a5b;
  --canopy: #789864;
  --canopy-dark: #648455;
  --canopy-hl: #adc498;
  --wool: #eeebdf;
  --hen: #eae2d0;
  --hen-wing: #d6caae;
  --cow: #e9e5d8;
  --duck: #e2c684;
  --fence: #ddd8c6;
  --pole: #7e7a6e;
  --petal: #d4b4c0;
  --window-glow: .3;
}

.farm[data-weather="rain"] {
  --sky-1: #8ba4b0;
  --sky-2: #a9c0c6;
  --sky-3: #ccd8d0;
  --sun-opacity: 0;
  --cloud: #dde4e1;
  --cloud-shade: #c3ceca;
  --mtn-far: #93a8a2;
  --mtn-mid: #7f978b;
  --hill-back: #7c9c6e;
  --hill-main: #6a8c5c;
  --hill-front: #5b7c4f;
  --pond-1: #739aae;
  --pond-2: #55808f;
  --pond-edge: #c2b894;
  --canopy: #688a5c;
  --canopy-dark: #587650;
  --canopy-hl: #94b184;
  --grass-deep: #567648;
  --wool: #e0e2da;
  --hen: #d8d2c0;
  --hen-wing: #c5bba4;
  --cow: #d8dcd4;
  --duck: #d0b266;
  --fence: #cdd0c2;
  --pole: #6e6e64;
  --petal: #c0a0ae;
  --reed-head: #857454;
  --tint: rgba(70, 92, 104, .16);
  --window-glow: .55;
}

.farm[data-weather="snow"] {
  --sky-1: #c4d2dd;
  --sky-2: #dde6ec;
  --sky-3: #f2f4f0;
  --sun-opacity: .25;
  --cloud: #fbfcfe;
  --cloud-shade: #e0e8ef;
  --mtn-far: #cdd8dc;
  --mtn-mid: #bdccd0;
  --hill-back: #dde6de;
  --hill-main: #d0ded0;
  --hill-front: #c3d4c4;
  --canopy: #7a9a72;
  --canopy-dark: #688660;
  --canopy-hl: #b2ccb0;
  --sakura: #ecdce4;
  --sakura-dark: #d8c4ce;
  --pine: #68846a;
  --pond-1: #a4c0d2;
  --pond-2: #84a8be;
  --pond-edge: #ddd6bc;
  --wool: #ffffff;
  --hen: #fbf8ef;
  --hen-wing: #e6e0ce;
  --cow: #f9f9f3;
  --duck: #ecd49a;
  --fence: #f2f4ee;
  --pole: #9a9a90;
  --petal: #e2ccda;
  --snow-opacity: 1;
  --window-glow: .5;
}

.farm[data-weather="night"] {
  --sky-1: #22354a;
  --sky-2: #2f4758;
  --sky-3: #435c66;
  --cloud: #92a4b2;
  --cloud-shade: #75879a;
  --moon: #f7f0d8;
  --mtn-far: #33474e;
  --mtn-mid: #2d4044;
  --hill-back: #2d453c;
  --hill-main: #283d35;
  --hill-front: #203329;
  --pond-1: #2f5258;
  --pond-2: #223e46;
  --pond-edge: #45443a;
  --canopy: #2c463a;
  --canopy-dark: #253b31;
  --canopy-hl: #3a5c4c;
  --sakura: #b6a8b0;
  --sakura-dark: #9c8e98;
  --pine: #33483a;
  --trunk: #55432f;
  --grass-deep: #27422f;
  --roof: #4e5a66;
  --roof-shade: #414c56;
  --wall: #c9bda2;
  --window: #f5d98a;
  --window-line: #c8a868;
  --eave: #6e6250;
  --door: #6a5238;
  --smoke: #c8d2dc;
  --fence: #6e7484;
  --pole: #565860;
  --wool: #b2bec8;
  --hen: #c2ccd4;
  --hen-wing: #a6b2c0;
  --cow: #b6c2cc;
  --duck: #c2a452;
  --beak: #bd8f50;
  --comb: #b26a62;
  --blush: #ab8688;
  --petal: #a8869a;
  --core: #c2a452;
  --fruit: #9a5a52;
  --reed-head: #454038;
  --tint: rgba(12, 24, 40, .28);
  --star-opacity: 1;
  --sun-opacity: 0;
  --moon-opacity: 1;
  --window-glow: 1;
}

.scene-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.scene {
  width: 100%;
  height: 100%;
  display: block;
  transform: scale(1.02);
}

.layer {
  transform: translate3d(calc(var(--px, 0px) * var(--depth, 1)), calc(var(--py, 0px) * var(--depth, 1)), 0);
  transition: transform .28s ease-out;
}

/* ---------- 天空元素 ---------- */
.stars { fill: #fff; opacity: var(--star-opacity); transition: opacity 1.2s ease; }
.stars circle { animation: twinkle 4s ease-in-out infinite; }
.stars circle:nth-child(3n) { animation-delay: 1.2s; }
.stars circle:nth-child(3n + 1) { animation-delay: 2.4s; }

.sun { fill: url(#sunCore); opacity: var(--sun-opacity); transition: opacity 1s ease; }
.sun-halo { opacity: var(--sun-opacity); transition: opacity 1s ease; }
.sun-face path {
  fill: none;
  stroke: #f0a83c;
  stroke-width: 4.5;
  stroke-linecap: round;
  opacity: var(--sun-opacity);
  transition: opacity 1s ease;
}
.moon { opacity: var(--moon-opacity); transition: opacity 1s ease; }
.moon-crater { fill: rgba(120, 108, 78, .22); }
.moon-star { fill: #fff3c2; animation: twinkle 3.2s ease-in-out infinite; }

.cloud { fill: var(--cloud); opacity: .95; }
.cloud.c1 { animation: drift 52s linear infinite; }
.cloud.c2 { animation: drift 72s linear infinite reverse; }
.cloud.c3 { animation: drift 90s linear infinite; }
.cloud-hl { fill: #ffffff; }
.cloud-shade { fill: var(--cloud-shade); opacity: .8; }

/* ---------- 地形 ---------- */
.mtn-far { fill: var(--mtn-far); opacity: .85; transition: fill 1s ease; }
.mtn-mid { fill: var(--mtn-mid); opacity: .9; transition: fill 1s ease; }
.mtn-snow { fill: #fff; opacity: .9; transition: opacity 1.2s ease; }
.hill-back { fill: var(--hill-back); transition: fill 1s ease; }
.hill-main { fill: var(--hill-main); transition: fill 1s ease; }
.hill-front { fill: var(--hill-front); transition: fill 1s ease; }
.snowcap-ground {
  fill: #fff;
  opacity: var(--snow-opacity);
  transition: opacity 1.4s ease;
}

/* ---------- 池塘 ---------- */
.sp-reed {
  transform-box: fill-box;
  transform-origin: bottom center;
  animation: sway 5.5s ease-in-out infinite;
}
.sp-reed2 { animation-delay: -2.2s; }

.ripples ellipse {
  fill: none;
  stroke: rgba(255, 255, 255, .7);
  stroke-width: 2;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}
.farm[data-weather="rain"] .ripples ellipse { animation: ripple 2.6s ease-out infinite; }
.farm[data-weather="rain"] .ripples ellipse:nth-child(2) { animation-delay: .9s; }
.farm[data-weather="rain"] .ripples ellipse:nth-child(3) { animation-delay: 1.7s; }

.sp-goldfish { animation: pond-drift 11s ease-in-out infinite; }
.sp-fish { animation: pond-drift 13s ease-in-out infinite reverse; }
.sp-fish2 { animation-duration: 15s; animation-delay: -6s; }
.sp-shrimp { animation: pond-drift 9s ease-in-out infinite; }

/* ---------- 房子（AI 贴图） ---------- */
.sp-house, .sp-pond, .sp-sakura, .sp-pine {
  transform-box: fill-box;
  transform-origin: bottom center;
}
.sp-sakura { animation: sway 7s ease-in-out infinite; }
.sp-pine { animation: sway 9s ease-in-out infinite; }

/* 夜间窗光 */
.win-glow {
  fill: #ffd578;
  opacity: calc(var(--window-glow) * .5);
  filter: blur(7px);
  transition: opacity 1s ease;
  pointer-events: none;
}

.door-click { cursor: pointer; outline: none; }

.shelter-roof { fill: var(--roof-shade); opacity: .95; }
.shelter-post { fill: var(--trunk); }

/* ---------- 植物与栅栏 ---------- */
.petal-fall {
  fill: var(--sakura);
  opacity: .85;
  animation: petalfall 7s linear infinite;
}
.petal-fall.pf2 { animation-delay: -3.4s; }

@keyframes petalfall {
  0%   { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  12%  { opacity: .85; }
  55%  { transform: translate(46px, 96px) rotate(160deg); }
  100% { transform: translate(84px, 190px) rotate(320deg); opacity: 0; }
}

.pole { fill: var(--pole); transition: fill 1s ease; }
.wire {
  fill: none;
  stroke: var(--pole);
  stroke-width: 2.2;
  opacity: .5;
}

.kasa path {
  fill: none;
  stroke: var(--grass-deep);
  stroke-width: 3;
  stroke-linecap: round;
  transform-box: fill-box;
  transform-origin: bottom center;
  animation: sway 6s ease-in-out infinite;
}

.fence rect, .fence circle { fill: var(--fence); transition: fill 1s ease; }
.bush ellipse { fill: var(--canopy-dark); transition: fill 1s ease; }
.bush-hl { fill: var(--canopy-hl); opacity: .7; transition: fill 1s ease; }

.bloom .petal { fill: var(--petal); transition: fill 1s ease; }
.bloom .core { fill: var(--core); transition: fill 1s ease; }

.tuft {
  fill: var(--grass-deep);
  transform-box: fill-box;
  transform-origin: bottom center;
  animation: sway 4.5s ease-in-out infinite;
}
.tuft:nth-child(2n) { animation-delay: -1.4s; }
.tuft:nth-child(3n) { animation-delay: -3s; }

/* ---------- 场景整图（水墨淡彩） ---------- */
.scene-img { transition: filter 1s ease; }
.farm[data-weather="cloudy"] .scene-img { filter: saturate(.8) brightness(.88) contrast(.97); }
.farm[data-weather="rain"] .scene-img { filter: saturate(.7) brightness(.8) contrast(.95) hue-rotate(-5deg); }
.farm[data-weather="snow"] .scene-img { filter: saturate(.6) brightness(.93) contrast(.97); }
.farm[data-weather="night"] .scene-img { filter: brightness(.4) saturate(.55) contrast(1.06) hue-rotate(12deg); }

/* 夜间窗光 */
.win-glows {
  opacity: calc(var(--window-glow) * .6);
  transition: opacity 1s ease;
  pointer-events: none;
}

/* 飘落花瓣 */
.pf {
  fill: #f2cdd8;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: petal-drift 12s linear infinite;
}
.pf2 { animation-duration: 15s; animation-delay: -4s; }
.pf3 { animation-duration: 10s; animation-delay: -7s; }
.pf4 { animation-duration: 17s; animation-delay: -2s; }
.pf5 { animation-duration: 13s; animation-delay: -9s; }

@keyframes petal-drift {
  0%   { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  8%   { opacity: .85; }
  80%  { opacity: .6; }
  100% { transform: translate(-90px, 260px) rotate(160deg); opacity: 0; }
}

/* ---------- 蝴蝶 ---------- */
.butterfly { animation: flutter 11s ease-in-out infinite; }
.butterfly.bf2 { animation-duration: 14s; animation-delay: -5s; }
.butterfly .wing-l, .butterfly .wing-r { fill: var(--petal); opacity: .85; transition: fill 1s ease; }
.butterfly .bf-body { fill: #7a5c48; }

@keyframes flutter {
  0%   { transform: translate(0, 0) rotate(0deg); }
  25%  { transform: translate(60px, -26px) rotate(6deg); }
  50%  { transform: translate(120px, 6px) rotate(-4deg); }
  75%  { transform: translate(60px, 34px) rotate(4deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

/* ---------- 天气效果 ---------- */
.weather-tint {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: var(--tint);
  transition: background 1s ease;
  z-index: 4;
}

#weather-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  display: none;
}

.farm[data-weather="rain"] #weather-canvas,
.farm[data-weather="snow"] #weather-canvas { display: block; }

/* ---------- 天气切换 ---------- */
.weather-bar {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 20;
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 253, 247, .74);
  border: 1px solid rgba(255, 255, 255, .5);
  box-shadow: 0 8px 22px rgba(40, 50, 40, .12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.weather-bar button {
  border: none;
  background: transparent;
  color: #5b5347;
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s, color .18s;
}

.weather-bar button:hover { background: rgba(111, 156, 98, .14); }
.weather-bar button.on { background: #6f9c62; color: #fff; }

.farm-hint {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 15;
  margin: 0;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(255, 253, 247, .7);
  border: 1px solid rgba(255, 255, 255, .55);
  font-size: 12.5px;
  letter-spacing: .06em;
  color: #5b5347;
  animation: breathe 3.4s ease-in-out infinite;
  transition: opacity .3s;
  pointer-events: none;
  white-space: nowrap;
}

.farm-hint.hidden { opacity: 0; }

/* ---------- 房门面板 ---------- */
.door-layer {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(38, 34, 27, .22);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.door-layer[hidden] { display: none; }

.door-card {
  width: min(400px, 100%);
  padding: 26px 24px 20px;
  border-radius: 26px;
  background: var(--card, #fffdf7);
  border: 1px solid #ece2cf;
  box-shadow: 0 26px 60px rgba(40, 32, 20, .3);
  text-align: center;
  animation: card-in .32s cubic-bezier(.18, .89, .32, 1.12);
}

.door-card h2 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: .02em;
}

.door-sub {
  margin: 0 0 18px;
  font-size: 13px;
  color: #8b8070;
}

.door-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border-radius: 16px;
  background: #faf5e8;
  border: 1px solid transparent;
  text-decoration: none;
  color: #3b332a;
  text-align: left;
  transition: transform .18s, border-color .18s, background .18s;
}

.door-link:hover {
  transform: translateY(-2px);
  border-color: #cfe4c4;
  background: #f4f8ee;
}

.dl-icon {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #e8f1df;
  color: #557a4c;
}

.dl-icon svg { width: 21px; height: 21px; }

.dl-text { display: grid; }
.dl-text b { font-size: 15px; font-weight: 600; }
.dl-text small { font-size: 12px; color: #8b8070; }

.door-close {
  margin-top: 8px;
  border: none;
  background: transparent;
  color: #8b8070;
  font-family: inherit;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.door-close:hover { background: #f2ece0; color: #3b332a; }

/* ---------- 手机端入口卡片（桌面由门面板提供入口，默认隐藏） ---------- */
.farm-links { display: none; }

/* ---------- 动画 ---------- */
@keyframes drift {
  from { transform: translateX(-40px); }
  50% { transform: translateX(40px); }
  to { transform: translateX(-40px); }
}

@keyframes twinkle {
  0%, 100% { opacity: .35; }
  50% { opacity: 1; }
}

@keyframes sway {
  0%, 100% { transform: rotate(-2.5deg); }
  50% { transform: rotate(2.5deg); }
}

@keyframes ripple {
  0% { transform: scale(.4); opacity: .9; }
  100% { transform: scale(1.6); opacity: 0; }
}

@keyframes pond-drift {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(24px, 4px); }
}

@keyframes breathe {
  0%, 100% { opacity: .78; }
  50% { opacity: 1; }
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(16px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 640px) {
  .farm-hint { bottom: 66px; font-size: 12px; }
}

/* ---------- 竖屏 / 小屏：场景按原比例完整展示，入口改用卡片 ---------- */
@media (max-width: 960px) {
  .page-home {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100svh;
  }

  .page-home .page-main { flex: 1 0 auto; }

  .farm {
    height: auto;
    min-height: 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: calc(76px + env(safe-area-inset-top)) 14px calc(24px + env(safe-area-inset-bottom));
    background: var(--paper, #faf6ec);
  }

  .scene-wrap {
    position: relative;
    inset: auto;
    flex: none;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 16px;
    border: 1px solid rgba(232, 223, 205, .9);
    box-shadow: 0 12px 30px rgba(95, 80, 55, .14);
  }

  /* 容器已是 16:9，slice 不再裁切画面 */
  .scene { transform: none; }

  .weather-bar { position: static; align-self: center; }
  .farm-hint { display: none; }

  .farm-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .farm-link {
    display: grid;
    gap: 3px;
    padding: 13px 15px;
    border-radius: 14px;
    background: var(--card, #fffdf7);
    border: 1px solid var(--line, #e8dfcd);
    box-shadow: 0 4px 14px rgba(95, 80, 55, .06);
    text-decoration: none;
    color: #3b332a;
    text-align: left;
  }

  .farm-link:active { background: #f4f8ee; border-color: var(--accent-soft, #cfe4c4); }
  .farm-link b { font-size: 15px; font-weight: 600; }
  .farm-link small { font-size: 11.5px; line-height: 1.5; color: #8b8070; }
  .farm-link.wide { grid-column: 1 / -1; text-align: center; }

  /* 手机端页脚回到常规流，备案号保持可见 */
  .page-home .sitefoot {
    display: block;
    position: static;
    mix-blend-mode: normal;
    color: var(--ink-2, #7b7062);
    font-size: 12px;
    padding: 0 0 calc(12px + env(safe-area-inset-bottom));
    text-align: center;
  }
  .page-home .sitefoot span:first-child,
  .page-home .sitefoot .sep { display: inline; }
}

/* ---------- 手机横屏：回归整屏场景，从小屋门进入 ---------- */
@media (max-width: 960px) and (orientation: landscape) and (max-height: 540px) {
  .page-home { display: block; min-height: 0; }

  .page-home .page-main { flex: none; }

  .farm {
    height: 100vh;
    height: 100svh;
    padding: 0;
    display: block;
    overflow: hidden;
  }

  .scene-wrap {
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    aspect-ratio: auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .weather-bar { position: absolute; left: 12px; bottom: 12px; }
  .farm-links { display: none; }
  .farm-hint { display: block; bottom: 20px; }

  .page-home .sitefoot {
    position: fixed;
    right: 14px;
    bottom: 10px;
    padding: 0;
    text-align: right;
    color: rgba(59, 51, 42, .55);
  }
  .page-home .sitefoot span:first-child,
  .page-home .sitefoot .sep { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cloud, .stars circle, .tuft, .sp-reed, .sp-goldfish, .sp-fish, .sp-shrimp,
  .sp-duck, .sp-cat, .sp-hen, .sp-chick, .sp-sakura, .sp-pine,
  .farm-hint, .butterfly, .moon-star { animation: none !important; }
}
