/* home.css —— 双屏主页：3D 小人物互动 + 原有内容页 */

html,
body {
  min-height: 100%;
}

body {
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 18% 28%, rgba(204, 120, 92, 0.09), transparent 28%),
    radial-gradient(circle at 78% 62%, rgba(122, 142, 128, 0.10), transparent 32%);
  pointer-events: none;
}

.page-bg::after {
  background: rgba(250, 249, 245, 0.70);
}

.home-top {
  position: fixed;
  top: 18px;
  right: clamp(18px, 4vw, 48px);
  z-index: 40;
  pointer-events: none;
}

.signin-link {
  pointer-events: auto;
  text-decoration: none;
  border: 1px solid rgba(230, 227, 218, 0.86);
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
  box-shadow: 0 10px 28px rgba(80, 66, 48, 0.07);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.signin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: min(240px, calc(100vw - 36px));
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color .2s ease, border-color .2s ease, transform .2s ease;
}

.signin-link.is-user {
  padding-left: 18px;
  padding-right: 18px;
}

.signin-link:hover {
  color: var(--accent);
  border-color: rgba(204, 120, 92, 0.40);
  transform: translateY(-1px);
}

.user-card {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  display: grid;
  gap: 12px;
  width: min(282px, calc(100vw - 36px));
  padding: 16px;
  border: 1px solid rgba(230, 227, 218, 0.90);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 18px 46px rgba(80, 66, 48, 0.11);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity .18s ease, transform .18s ease;
}

.user-card.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.user-logout {
  width: 100%;
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: .92rem;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}

.user-logout:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.user-meta {
  display: grid;
  gap: 5px;
  padding: 2px 4px 0;
  color: var(--ink-soft);
  font-size: .82rem;
  overflow-wrap: anywhere;
}

.user-meta strong {
  color: var(--ink);
  font-size: .98rem;
  font-weight: 600;
}

.home-main {
  min-height: 200vh;
}

.home-screen {
  position: relative;
  min-height: 100vh;
  display: grid;
  align-items: center;
  scroll-margin-top: 0;
}

.home-ai-layout {
  min-height: 100vh;
  width: min(1040px, calc(100% - 48px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(360px, 500px);
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vw, 26px);
  padding: 74px 0 42px;
}

.character-anchor {
  min-height: min(48vh, 430px);
}

.character-stage {
  position: fixed;
  left: calc(50% - 420px);
  top: 51%;
  z-index: 20;
  width: clamp(190px, 17vw, 244px);
  height: clamp(270px, 36vh, 346px);
  min-width: 0;
  min-height: 0;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  transition:
    left .65s cubic-bezier(.2,.8,.2,1),
    top .65s cubic-bezier(.2,.8,.2,1),
    bottom .65s cubic-bezier(.2,.8,.2,1),
    width .65s cubic-bezier(.2,.8,.2,1),
    height .65s cubic-bezier(.2,.8,.2,1),
    transform .65s cubic-bezier(.2,.8,.2,1),
    opacity .3s ease;
}

.mlpf-character-area,
.mlpf-character-3d {
  width: 100%;
  height: 100%;
}

.mlpf-character-area {
  position: relative;
}

.mlpf-character-3d {
  cursor: pointer;
  touch-action: manipulation;
}

.mlpf-character-3d canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.mini-hint {
  position: absolute;
  left: 62%;
  top: 35%;
  transform: translate(8px, -50%);
  opacity: 0;
  pointer-events: none;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(230, 227, 218, 0.92);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink-soft);
  font-size: 0.86rem;
  box-shadow: 0 12px 26px rgba(80, 66, 48, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: opacity .2s ease, transform .2s ease;
  white-space: nowrap;
}

.interaction-panel {
  position: fixed;
  left: calc(50% - 345px);
  top: 41%;
  z-index: 21;
  width: min(540px, calc(100vw - 520px));
  min-width: 420px;
  display: block;
  opacity: 0;
  pointer-events: none;
  transition: opacity .24s ease, transform .45s cubic-bezier(.2,.8,.2,1);
}

.mlpf-bubble {
  position: relative;
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  min-width: 230px;
  min-height: 82px;
  padding: 18px 28px;
  border-radius: 999px / 66%;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(230, 227, 218, 0.88);
  box-shadow: 0 18px 46px rgba(80, 66, 48, 0.10);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--ink);
  font-family: "Noto Serif SC", serif;
  font-size: clamp(1.16rem, 1.8vw, 1.45rem);
  line-height: 1.58;
  letter-spacing: 0;
  transition:
    min-width .22s ease,
    max-width .22s ease,
    padding .22s ease,
    border-radius .22s ease;
  white-space: normal;
}

.mlpf-bubble::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 56%;
  width: 18px;
  height: 18px;
  background: inherit;
  border-left: 1px solid rgba(230, 227, 218, 0.88);
  border-bottom: 1px solid rgba(230, 227, 218, 0.88);
  transform: rotate(45deg);
}

.mlpf-bubble.is-short {
  min-width: 220px;
  max-width: min(360px, 100%);
  padding: 18px 30px;
}

.mlpf-bubble.is-medium {
  min-width: 330px;
  max-width: min(520px, 100%);
  padding: 20px 32px;
  border-radius: 44px / 58%;
}

.mlpf-bubble.is-long {
  min-width: 420px;
  max-width: min(660px, calc(100vw - 420px));
  padding: 22px 34px;
  border-radius: 38px;
}

.mlpf-bubble.is-long::before {
  top: 42%;
}

.mlpf-bubble.is-error {
  color: var(--accent-dark);
}

.mlpf-input {
  display: grid;
  grid-template-columns: 1fr 46px;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 999px;
  border: 1px solid rgba(230, 227, 218, 0.92);
  background: rgba(255, 255, 255, 0.70);
  box-shadow: 0 12px 32px rgba(80, 66, 48, 0.08);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.hero-form {
  position: fixed;
  left: calc(50% - 424px);
  top: calc(51% + 184px);
  z-index: 22;
  width: clamp(260px, 24vw, 360px);
  opacity: 0;
  pointer-events: none;
}

.explore-cue {
  position: fixed;
  left: 50%;
  top: 57%;
  z-index: 18;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: rgba(107, 104, 98, 0.66);
  font: inherit;
  font-size: clamp(1rem, 1.4vw, 1.22rem);
  letter-spacing: 0;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: color .2s ease, transform .2s ease, opacity .2s ease;
}

.explore-cue span {
  font-size: 1.28em;
  line-height: 1;
  transform: translateY(1px);
}

.explore-cue:hover {
  color: var(--accent);
  transform: translate(-50%, calc(-50% + 2px));
}

.mlpf-input input {
  width: 100%;
  min-width: 0;
  height: 44px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  padding: 0 14px;
  font: inherit;
  font-size: 0.98rem;
}

.mlpf-input input::placeholder {
  color: rgba(107, 104, 98, 0.66);
}

.mlpf-input button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease, opacity .2s ease;
}

.mlpf-input button:hover {
  background: var(--accent-dark);
  transform: translateX(1px);
}

.mlpf-input input:disabled,
.mlpf-input button:disabled {
  cursor: default;
  opacity: .62;
}

.page-dots {
  position: fixed;
  right: clamp(18px, 3vw, 38px);
  top: 50%;
  z-index: 35;
  display: grid;
  gap: 14px;
  transform: translateY(-50%);
}

.dot {
  width: 11px;
  height: 11px;
  border: 1px solid rgba(107, 104, 98, 0.46);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
}

.dot.is-active {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.16);
}

.second-screen {
  align-items: start;
  padding: clamp(112px, 13vh, 136px) 0 64px;
}

.second-content {
  width: min(1260px, calc(100% - 112px));
  margin: 0 auto;
}

.second-screen section.block {
  max-width: none;
  padding: 0;
}

.second-screen section.intro-block {
  padding-top: 0;
  padding-bottom: clamp(22px, 3.2vh, 34px);
}

.second-screen section.explore-block {
  padding-top: 0;
  padding-bottom: 24px;
}

.second-screen .cards {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(22px, 2.5vw, 34px);
}

.second-screen .card {
  min-height: clamp(210px, 23vh, 270px);
  padding: clamp(30px, 3.1vw, 42px);
  border-radius: 16px;
}

.second-screen .card .icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  font-size: 1.36rem;
  margin-bottom: 22px;
}

.second-screen .card h3 {
  font-size: clamp(1.28rem, 1.55vw, 1.62rem);
  margin-bottom: 12px;
}

.second-screen .card p {
  font-size: clamp(.92rem, 1vw, 1.02rem);
  line-height: 1.7;
}

.second-screen .card .tag {
  margin-top: 16px;
  padding: 4px 12px;
  font-size: .78rem;
}

.mini-chat {
  position: fixed;
  left: clamp(190px, 18vw, 270px);
  top: 50%;
  bottom: auto;
  z-index: 36;
  width: min(460px, calc(100vw - 310px));
  display: grid;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-46%) translateX(-16px);
  transition: opacity .24s ease, transform .24s ease;
}

.mini-close {
  position: absolute;
  right: -38px;
  top: 3px;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(230, 227, 218, 0.92);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(80, 66, 48, 0.08);
}

.mini-bubble {
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 14px 22px;
  border-radius: 999px / 70%;
  font-family: inherit;
  font-size: 0.96rem;
}

.mini-bubble::before {
  top: 50%;
}

.mini-bubble.is-medium,
.mini-bubble.is-long {
  border-radius: 28px;
}

.mini-form {
  grid-template-columns: 1fr 40px;
  max-width: 290px;
  background: rgba(255, 255, 255, 0.46);
  box-shadow: 0 10px 26px rgba(80, 66, 48, 0.06);
}

.mini-form input {
  height: 38px;
  font-size: 0.92rem;
}

.mini-form button {
  width: 38px;
  height: 38px;
}

body.is-second-screen .character-stage {
  left: -78px;
  top: 50%;
  bottom: auto;
  width: 170px;
  height: 240px;
  min-width: 0;
  min-height: 0;
  transform: translateY(-50%);
  opacity: .98;
  pointer-events: auto;
}

body.is-second-screen .explore-cue {
  opacity: 0;
  pointer-events: none;
}

body.is-second-screen .interaction-panel {
  opacity: 0;
  pointer-events: none;
}

body.is-second-screen .character-stage:hover {
  left: -42px;
}

body.is-second-screen .character-stage:hover .mini-hint {
  opacity: 1;
  transform: translate(2px, -50%);
}

body.is-mini-open .character-stage {
  left: clamp(24px, 5vw, 72px);
  top: 50%;
  bottom: auto;
  width: 176px;
  height: 248px;
  transform: translateY(-50%);
}

body.is-mini-open .character-stage:hover {
  left: clamp(24px, 5vw, 72px);
}

body.is-mini-open .mini-hint {
  opacity: 0;
}

body.is-mini-open .mini-chat {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-46%) translateX(0);
}

@media (max-width: 820px) {
  .home-top {
    top: 12px;
    right: 14px;
  }

  .home-ai-layout {
    width: min(560px, calc(100% - 32px));
    grid-template-columns: 1fr;
    align-content: center;
    gap: 8px;
    padding-top: 70px;
  }

  .character-anchor {
    height: min(38vh, 330px);
    min-height: 246px;
  }

  .character-stage {
    left: 50%;
    top: 29%;
    width: min(54vw, 220px);
    height: min(32vh, 286px);
    min-width: 0;
    min-height: 246px;
    transform: translate(-50%, -50%);
  }

  .interaction-panel {
    left: 50%;
    top: 48%;
    width: min(520px, calc(100vw - 32px));
    min-width: 0;
    transform: translate(-50%, -50%);
  }

  .hero-form {
    left: 50%;
    top: calc(29% + 154px);
    width: min(360px, calc(100vw - 32px));
    transform: translateX(-50%);
  }

  .explore-cue {
    top: 52%;
  }

  .mlpf-bubble {
    font-size: 1.22rem;
    min-width: 0;
    max-width: 100%;
  }

  .mlpf-bubble::before {
    left: 42px;
    top: -9px;
    border-left: 1px solid rgba(230, 227, 218, 0.88);
    border-top: 1px solid rgba(230, 227, 218, 0.88);
    border-bottom: 0;
  }

  .page-dots {
    right: 12px;
  }

  .second-content {
    width: min(560px, calc(100% - 32px));
    padding-bottom: 96px;
  }

  .second-screen .cards,
  .cards {
    gap: 18px;
    grid-template-columns: 1fr;
  }

  .second-screen .card,
  .card {
    padding: 26px 24px;
    min-height: 0;
  }

  body.is-second-screen .character-stage {
    left: -72px;
    top: 50%;
    bottom: auto;
    width: 138px;
    height: 194px;
    min-height: 0;
    transform: translateY(-50%);
  }

  body.is-second-screen .character-stage:hover {
    left: -50px;
  }

  body.is-mini-open .character-stage {
    left: 10px;
    top: 50%;
    bottom: auto;
    width: 112px;
    height: 160px;
    transform: translateY(-50%);
  }

  .mini-chat {
    left: 108px;
    top: 50%;
    bottom: auto;
    width: min(320px, calc(100vw - 126px));
    transform: translateY(-46%) translateX(-10px);
  }

  .mini-close {
    right: 2px;
    top: -42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}
