/* ==========================================================================
   P1 登录/注册页 · 全屏家庭群像主画幅 + 左侧斜切深炭墨毛玻璃登录区
   材质系统：深炭墨磨砂烟熏玻璃 × 暖象牙棉纸字墨 × 微光发丝斜切刃口
   作用域严格限定在 #login-card，隐藏时零干扰已登录后的 #nest-main
   ========================================================================== */

#login-card[hidden] {
  display: none !important;
}

#login-card {
  --ink-canvas: #121419;
  --ink-btn-text: #15171c;
  --ivory: #f4efe6;
  --ivory-soft: rgba(244, 239, 230, 0.72);
  --ivory-muted: rgba(244, 239, 230, 0.42);
  --ivory-hairline: rgba(244, 239, 230, 0.22);
  --ivory-hairline-focus: rgba(244, 239, 230, 0.88);
  --ivory-btn: #efe9dd;
  --ivory-btn-hover: #f8f4ec;
  --error-coral: #e58a78;

  /* 本地时区双层静默光影变量（全局色温 + 右侧落地窗/顶灯局部柔光罩） */
  --art-filter: brightness(1.01) contrast(1.01) saturate(1.02);
  --time-tint: linear-gradient(135deg, rgba(255, 249, 240, 0.06) 0%, rgba(220, 236, 248, 0.04) 100%);
  --time-tint-opacity: 0.55;
  --window-light: radial-gradient(ellipse 46% 68% at 84% 34%, rgba(255, 248, 236, 0.08) 0%, transparent 72%);
  --window-light-opacity: 0.5;

  /* 左侧斜切暗幕几何（顶 368px / 底 432px，静默平移 -322px → 露顶 46px / 底 110px） */
  --curtain-width: 432px;
  --curtain-slant: 64px;
  --curtain-rest-shift: -322px;

  /* 手机端 visualViewport 软键盘避让 */
  --vv-keyboard-offset: 0px;

  --login-font-sans: "PingFang SC", "HarmonyOS Sans SC", "Noto Sans SC", "Microsoft YaHei UI", system-ui, -apple-system, sans-serif;

  position: fixed;
  inset: 0;
  z-index: 100;
  width: 100%;
  max-width: 100vw;
  height: 100dvh;
  overflow: hidden;
  overflow-x: hidden;
  background-color: var(--ink-canvas);
  color: var(--ivory);
  font-family: var(--login-font-sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 四个时段基准氛围（清晨微青金 / 午后通透 / 黄昏柔琥珀 / 深夜右窗入夜+室内暖顶光） */
#login-card[data-time-phase="dawn"] {
  --art-filter: brightness(1.01) contrast(0.98) saturate(1.04) hue-rotate(-4deg);
  --time-tint: linear-gradient(125deg, rgba(178, 224, 226, 0.16) 0%, rgba(248, 220, 178, 0.14) 55%, rgba(28, 40, 56, 0.14) 100%);
  --time-tint-opacity: 0.72;
  --window-light:
    radial-gradient(ellipse 48% 72% at 85% 32%, rgba(206, 236, 246, 0.16) 0%, transparent 70%),
    radial-gradient(ellipse 46% 42% at 44% 34%, rgba(255, 238, 210, 0.08) 0%, transparent 72%);
  --window-light-opacity: 0.76;
}

#login-card[data-time-phase="day"] {
  --art-filter: brightness(1.02) contrast(1.01) saturate(1.03);
  --time-tint: linear-gradient(135deg, rgba(255, 251, 244, 0.07) 0%, rgba(222, 236, 250, 0.04) 60%, rgba(22, 28, 38, 0.08) 100%);
  --time-tint-opacity: 0.52;
  --window-light: radial-gradient(ellipse 46% 68% at 84% 34%, rgba(255, 250, 240, 0.08) 0%, transparent 72%);
  --window-light-opacity: 0.45;
}

#login-card[data-time-phase="dusk"] {
  --art-filter: brightness(0.93) contrast(1.02) saturate(1.09) sepia(0.11) hue-rotate(-6deg);
  --time-tint: linear-gradient(130deg, rgba(238, 158, 96, 0.22) 0%, rgba(196, 114, 86, 0.12) 48%, rgba(26, 20, 34, 0.24) 100%);
  --time-tint-opacity: 0.78;
  --window-light:
    radial-gradient(ellipse 50% 76% at 84% 38%, rgba(248, 174, 102, 0.22) 0%, rgba(214, 126, 84, 0.08) 46%, transparent 76%),
    radial-gradient(ellipse 46% 44% at 44% 34%, rgba(255, 212, 152, 0.12) 0%, transparent 70%);
  --window-light-opacity: 0.84;
}

#login-card[data-time-phase="night"] {
  --art-filter: brightness(0.74) contrast(0.92) saturate(0.92) sepia(0.10);
  --time-tint: radial-gradient(circle at 52% 44%, rgba(246, 198, 134, 0.14) 0%, rgba(30, 40, 68, 0.24) 58%, rgba(12, 16, 26, 0.44) 100%);
  --time-tint-opacity: 0.84;
  --window-light:
    radial-gradient(ellipse 48% 82% at 86% 36%, rgba(14, 20, 38, 0.44) 0%, rgba(18, 25, 46, 0.20) 52%, transparent 78%),
    radial-gradient(ellipse 54% 46% at 44% 30%, rgba(255, 208, 142, 0.24) 0%, rgba(246, 186, 112, 0.09) 48%, transparent 76%);
  --window-light-opacity: 0.94;
}

#login-card button,
#login-card input {
  font: inherit;
  color: inherit;
}

#login-card button {
  cursor: pointer;
}

/* ==========================================================================
   1. 全屏主画面（100% × 100dvh 零杂物家庭群像 + 静默时区光影滤镜）
   ========================================================================== */

#login-card .home-stage {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

#login-card .stage-canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translate3d(0, 0, 0) scale(1);
  transform-origin: center center;
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

/* 桌面端左侧斜切暗幕展开联动推镜：将画面主体推入右侧安全区，营造推门入室电影运镜 */
@media (min-width: 769px) {
  #login-card[data-gate-open="true"] .stage-canvas {
    transform: translate3d(5.5%, 0, 0) scale(1.06);
  }
}

/* 图片加载前的温馨室内暖光兜底渐变 */
#login-card .stage-fallback {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 68% 58% at 58% 42%, rgba(242, 204, 152, 0.28) 0%, rgba(126, 98, 78, 0.16) 44%, rgba(20, 22, 28, 0.96) 100%),
    linear-gradient(160deg, #2b2420 0%, #1d1c22 54%, #121419 100%);
  filter: var(--art-filter);
  transition: filter 900ms ease;
}

#login-card .stage-artwork {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  transform: scale(1.012);
  filter: var(--art-filter);
  transition:
    opacity 680ms ease,
    transform 1000ms cubic-bezier(0.22, 1, 0.36, 1),
    filter 900ms ease;
  user-select: none;
  -webkit-user-drag: none;
}

#login-card .stage-artwork.is-loaded {
  opacity: 1;
  transform: scale(1);
}

#login-card .stage-time-tint {
  position: absolute;
  inset: 0;
  background: var(--time-tint);
  mix-blend-mode: soft-light;
  opacity: var(--time-tint-opacity);
  transition: opacity 900ms ease;
}

/* 第二层时区光罩：专控右侧落地窗入夜暗罩与客厅中上部暖黄顶光柔晕 */
#login-card .stage-window-light {
  position: absolute;
  inset: 0;
  background: var(--window-light);
  opacity: var(--window-light-opacity);
  transition: opacity 900ms ease;
}

/* 极轻四周暗角，让左侧斜切毛玻璃过渡更柔和 */
#login-card .stage-vignette {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(12, 14, 19, 0.30) 0%,
    rgba(12, 14, 19, 0.04) 22%,
    rgba(12, 14, 19, 0) 68%,
    rgba(12, 14, 19, 0.18) 100%
  );
}

/* ==========================================================================
   2. 左侧斜切深炭墨毛玻璃登录/注册区
   静默态：干干净净，仅左缘斜切暗影 + 一枚极轻几何门徽/细线，零文字
   展开态：鼠标移入丝滑向右扩开，垂直居中大留白，极致克制
   ========================================================================== */

#login-card .gate-backdrop {
  position: fixed;
  inset: 0;
  z-index: 16;
  background: rgba(10, 12, 16, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 340ms ease;
}

#login-card[data-gate-open="true"] .gate-backdrop {
  opacity: 1;
  pointer-events: auto;
}

#login-card .gate-curtain {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  width: var(--curtain-width);
  transform: translate3d(var(--curtain-rest-shift), 0, 0);
  transition: transform 460ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

#login-card[data-gate-open="true"] .gate-curtain {
  transform: translate3d(0, 0, 0);
}

#login-card .gate-surface {
  position: relative;
  width: 100%;
  height: 100%;
  clip-path: polygon(
    0 0,
    calc(100% - var(--curtain-slant)) 0,
    100% 100%,
    0 100%
  );
  background: linear-gradient(
    168deg,
    rgba(16, 18, 23, 0.74) 0%,
    rgba(14, 16, 21, 0.80) 54%,
    rgba(12, 14, 19, 0.86) 100%
  );
  backdrop-filter: blur(20px) saturate(1.08);
  -webkit-backdrop-filter: blur(20px) saturate(1.08);
  display: flex;
  align-items: center;
}

/* 斜切刃口微光发丝线 */
#login-card .gate-slash-edge {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

#login-card .gate-slash-stroke {
  stroke: rgba(244, 239, 230, 0.22);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  transition: stroke 320ms ease;
}

#login-card[data-gate-open="true"] .gate-slash-stroke {
  stroke: rgba(244, 239, 230, 0.36);
}

/* 静默态触发热区：仅一枚极轻几何细线门徽，绝无文字 */
#login-card .gate-silent-trigger {
  position: absolute;
  top: 0;
  right: 8px;
  bottom: 0;
  z-index: 5;
  width: 96px;
  border: 0;
  background: transparent;
  padding: 0 22px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 220ms ease;
}

#login-card .gate-silent-trigger:focus-visible {
  outline: 2px solid var(--ivory);
  outline-offset: -8px;
}

#login-card[data-gate-open="true"] .gate-silent-trigger {
  opacity: 0;
  pointer-events: none;
}

#login-card .silent-emblem {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  opacity: 0.72;
  transition: opacity 260ms ease, transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

#login-card .gate-silent-trigger:hover .silent-emblem {
  opacity: 1;
  transform: translate3d(2px, 0, 0);
}

#login-card .emblem-line {
  display: block;
  width: 1px;
  background: linear-gradient(180deg, transparent 0%, rgba(244, 239, 230, 0.52) 50%, transparent 100%);
}

#login-card .emblem-line-top {
  height: 44px;
}

#login-card .emblem-line-bottom {
  height: 44px;
}

#login-card .emblem-diamond {
  display: block;
  width: 6px;
  height: 6px;
  border: 1px solid rgba(244, 239, 230, 0.78);
  transform: rotate(45deg);
}

#login-card .sheet-handle {
  display: none;
}

/* ==========================================================================
   3. 展开态内部极简表单（垂直居中、大留白、双纯文字 Tab、无框底线输入、单枚按钮）
   ========================================================================== */

#login-card .gate-inner {
  position: relative;
  z-index: 4;
  width: 100%;
  padding: 48px 88px 48px 46px;
  opacity: 0;
  transform: translate3d(-14px, 0, 0);
  pointer-events: none;
  transition:
    opacity 280ms ease,
    transform 380ms cubic-bezier(0.22, 1, 0.36, 1);
}

#login-card[data-gate-open="true"] .gate-inner {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  pointer-events: auto;
  transition-delay: 90ms;
}

/* 双纯文字模式切换：登录 / 注册（零厚重灰框） */
#login-card .mode-tabs {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-bottom: 42px;
}

#login-card .mode-tab {
  position: relative;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 2px 10px;
  border: 0;
  background: transparent;
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 0.10em;
  color: var(--ivory-muted);
  transition: color 220ms ease;
}

#login-card .mode-tab:hover {
  color: var(--ivory-soft);
}

#login-card .mode-tab.is-active {
  color: var(--ivory);
  font-weight: 600;
}

#login-card .mode-tab::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 4px;
  width: 24px;
  height: 2px;
  border-radius: 1px;
  background-color: var(--ivory);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

#login-card .mode-tab.is-active::after {
  transform: scaleX(1);
}

#login-card .mode-tab:focus-visible {
  outline: 2px solid var(--ivory);
  outline-offset: 4px;
  border-radius: 2px;
}

/* 无框底线输入框组 */
#login-card .auth-form {
  display: flex;
  flex-direction: column;
}

#login-card .field-row {
  position: relative;
  margin-bottom: 24px;
}

#login-card .field-input {
  width: 100%;
  height: 44px;
  padding: 10px 2px;
  border: 0;
  border-bottom: 1px solid var(--ivory-hairline);
  border-radius: 0;
  background: transparent;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--ivory);
  outline: none;
  transition: border-color 220ms ease;
}

#login-card .field-input::placeholder {
  color: var(--ivory-muted);
  letter-spacing: 0.06em;
}

#login-card .field-input:focus {
  border-bottom-color: transparent;
}

#login-card .field-underline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1.5px;
  background-color: var(--ivory-hairline-focus);
  transform: scaleX(0);
  transform-origin: left center;
  pointer-events: none;
  transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

#login-card .field-input:focus + .field-underline {
  transform: scaleX(1);
}

/* 浏览器自动填充底色修正 */
#login-card .field-input:-webkit-autofill,
#login-card .field-input:-webkit-autofill:hover,
#login-card .field-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ivory);
  -webkit-box-shadow: 0 0 0 1000px rgba(15, 17, 22, 0.01) inset;
  transition: background-color 9999s ease-out 0s;
}

/* 注册态平滑展开确认密码 */
#login-card .field-confirm {
  max-height: 0;
  margin-bottom: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transition:
    max-height 300ms cubic-bezier(0.22, 1, 0.36, 1),
    margin-bottom 300ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 220ms ease;
}

#login-card .gate-curtain[data-mode="register"] .field-confirm {
  max-height: 52px;
  margin-bottom: 24px;
  opacity: 1;
  pointer-events: auto;
}

/* 静默反馈行（平时无内容、无占位噪音） */
#login-card .auth-feedback {
  margin: 0 0 22px;
  min-height: 20px;
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0.03em;
  color: var(--ivory-soft);
}

#login-card .auth-feedback.is-error {
  color: var(--error-coral);
}

/* 唯一主提交按钮：柔和暖象牙反色 + 深炭墨文字 */
#login-card .submit-btn {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 3px;
  background-color: var(--ivory-btn);
  color: var(--ink-btn-text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.14em;
  transition:
    background-color 200ms ease,
    opacity 160ms ease,
    transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

#login-card .submit-btn:hover {
  background-color: var(--ivory-btn-hover);
}

#login-card .submit-btn:active {
  transform: scale(0.985);
}

#login-card .submit-btn:disabled {
  opacity: 0.72;
  cursor: wait;
}

#login-card .submit-btn:focus-visible {
  outline: 2px solid var(--ivory);
  outline-offset: 3px;
}

/* 手机端拉耳在桌面端隐藏 */
#login-card .mobile-gate-ear {
  display: none;
}

/* ==========================================================================
   4. 移动端响应式（390×844 零横向溢出、热区 >= 44px、visualViewport 180ms 避软键盘）
   ========================================================================== */

@media (max-width: 768px) {
  #login-card .mobile-gate-ear {
    position: fixed;
    left: 0;
    bottom: max(112px, calc(env(safe-area-inset-bottom) + 88px));
    z-index: 15;
    width: 44px;
    height: 96px;
    padding: 0 8px 0 0;
    border: 0;
    background: linear-gradient(165deg, rgba(16, 18, 23, 0.74) 0%, rgba(12, 14, 19, 0.84) 100%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    clip-path: polygon(0 0, 74% 0, 100% 100%, 0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 220ms ease, transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  #login-card .mobile-gate-ear:active {
    transform: translate3d(2px, 0, 0);
  }

  #login-card[data-gate-open="true"] .mobile-gate-ear {
    opacity: 0;
    pointer-events: none;
  }

  #login-card .ear-emblem {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  #login-card .ear-emblem .emblem-line {
    height: 24px;
  }

  /* 手机端走底部半透毛玻璃 Sheet（避开左右系统侧滑手势） */
  #login-card .gate-curtain {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100vw;
    height: auto;
    transform: translate3d(0, 105%, 0);
    transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  #login-card[data-gate-open="true"] .gate-curtain {
    transform: translate3d(0, calc(-1 * var(--vv-keyboard-offset)), 0);
  }

  #login-card .gate-surface {
    clip-path: none;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    border-top: 1px solid rgba(244, 239, 230, 0.16);
    flex-direction: column;
    align-items: stretch;
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }

  #login-card .gate-slash-edge,
  #login-card .gate-silent-trigger {
    display: none;
  }

  #login-card .sheet-handle {
    display: block;
    width: 36px;
    height: 3px;
    margin: 12px auto 0;
    border-radius: 999px;
    background: rgba(244, 239, 230, 0.28);
  }

  #login-card .gate-inner {
    padding: 24px 28px 12px;
    transform: translate3d(0, 8px, 0);
  }

  #login-card[data-gate-open="true"] .gate-inner {
    transform: translate3d(0, 0, 0);
    transition-delay: 40ms;
  }

  #login-card .mode-tabs {
    margin-bottom: 28px;
  }

  #login-card .field-row {
    margin-bottom: 20px;
  }

  #login-card .gate-curtain[data-mode="register"] .field-confirm {
    margin-bottom: 20px;
  }

  #login-card .auth-feedback {
    margin-bottom: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #login-card .stage-canvas,
  #login-card .stage-artwork,
  #login-card .stage-fallback,
  #login-card .stage-time-tint,
  #login-card .stage-window-light,
  #login-card .gate-curtain,
  #login-card .gate-inner,
  #login-card .gate-backdrop,
  #login-card .field-confirm,
  #login-card .field-underline,
  #login-card .mode-tab::after,
  #login-card .submit-btn {
    transition-duration: 1ms;
  }
}
