/* 測試環境登入頁：像素城市背景＋現代登入卡。選擇器一律 lc- 開頭，不與站內既有樣式互相覆蓋。 */

:root {
  --lc-bg: #07050e;
  --lc-ink: #f1edff;
  --lc-ink-2: #b3a8d6;
  --lc-ink-3: #8379a8;
  --lc-line: rgba(160, 135, 235, 0.22);
  --lc-card-bg: rgba(12, 8, 22, 0.74);
  --lc-input-bg: rgba(255, 255, 255, 0.035);
  --lc-accent: #6a50c8;
  --lc-accent-hover: #7860d6;
  --lc-focus: rgba(146, 116, 240, 0.3);
  --lc-card-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  --lc-panel-shade-night: radial-gradient(ellipse 30% 55% at 50% 50%, rgba(7, 5, 14, 0.55) 0%, rgba(7, 5, 14, 0.35) 55%, rgba(7, 5, 14, 0) 100%);
  --lc-panel-shade-day: linear-gradient(90deg, rgba(240, 236, 255, 0) 0%, rgba(240, 236, 255, 0.3) 35%, rgba(240, 236, 255, 0.42) 100%);
  --lc-tdur: 3s; /* 日夜交接時間，LabCity.js 也讀這個值 */
  --lc-badge-ink: #c9b9ff;
  --lc-badge-bg: rgba(120, 92, 210, 0.12);
  --lc-badge-line: rgba(180, 155, 255, 0.28);
  --lc-badge-dot: #b49cff;
  --lc-autofill: #19122c;

  /* tooltip 日夜都維持深色 */
  --lc-tip-bg: #100a1d;
  --lc-tip-line: #4a3b7c;
  --lc-tip-ink: #f1edff;
  --lc-tip-ink-2: #b3a8d6;
  --lc-tip-ink-3: #8379a8;
  --lc-alert: #cf6aa5;

  /* 場景裡會變化的狀態色 */
  --lc-win-off: #120b20;
  --lc-win-warm: #ead2a2;
  --lc-win-lilac: #d6c9fb;
  --lc-win-dim: #8a78c2;
  --lc-alert-lo: #3a1733;
  --lc-alert-hi: #a9548a;
  --lc-alert-still: #a24d82;
  --lc-node-lo: #4a3a78;
  --lc-node-hi: #cdbcff;
  --lc-lamp-on: #f3dfbd;
  --lc-lamp-on-hover: #fff4df;
  --lc-lamp-off: #4a3e66;
  --lc-lamp-off-hover: #5d5080;
  --lc-pipe-hi: #171127;
  --lc-pipe-body: #120d1f;
  --lc-pipe-lo: #0e0a18;
  --lc-pipe-hi-on: #5a64b0;
  --lc-pipe-body-on: #343a7c;
  --lc-pipe-lo-on: #24295a;

  --lc-font: "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --lc-mono: "Cascadia Mono", Consolas, "Courier New", ui-monospace, monospace;
}

/* 日間模式：由 LabTheme.js／LabCity.js 在 <html> 設 data-lc-theme="day"。
   只有城市變亮；登入卡與按鈕維持深色，因為兩個 logo 都是白字 */
:root[data-lc-theme="day"] {
  --lc-bg: #8a97dc;
  --lc-card-bg: rgba(16, 11, 30, 0.88); /* 亮背景上透明度要低一點，才不會透成灰紫 */
  --lc-card-shadow: 0 24px 64px rgba(40, 25, 90, 0.35);
}

/* 白天城市的狀態色掛在那份 SVG 上：日夜交接時兩份城市同時在畫面上，各用各的 */
.lc-city--day {
  --lc-win-off: #4c4285;
  --lc-win-warm: #c9d0f7;
  --lc-win-lilac: #b8bff2;
  --lc-win-dim: #8f88cc;
  --lc-alert-lo: #6e3a72;
  --lc-alert-hi: #d65fa0;
  --lc-alert-still: #b8558c;
  --lc-node-lo: #5f509a;
  --lc-node-hi: #ffffff;
  --lc-lamp-on: #fff3d6;
  --lc-lamp-on-hover: #ffffff;
  --lc-lamp-off: #7d70b0;
  --lc-lamp-off-hover: #9083c2;
  --lc-pipe-hi: #4a4170;
  --lc-pipe-body: #443b68;
  --lc-pipe-lo: #3d345f;
  --lc-pipe-hi-on: #a3b2ff;
  --lc-pipe-body-on: #6c7ae0;
  --lc-pipe-lo-on: #515eb8;
}

.lc-page {
  margin: 0;
  min-height: 100vh;
  background: var(--lc-bg);
  color: var(--lc-ink);
  font-family: var(--lc-font);
  overflow-x: hidden;
}

.lc-page *,
.lc-page *::before,
.lc-page *::after {
  box-sizing: border-box;
}

/* ===== 像素城市 ===== */

.lc-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.lc-city--day .lc-layer--stars {
  display: none;
}

/* 日夜交接：新城市疊在上面分段淡入；舊的日月落下、新的升起，星星跟著淡入淡出 */
.lc-city.is-leaving {
  pointer-events: none;
}

.lc-city.is-entering {
  animation: lc-dissolve var(--lc-tdur) steps(8, end) both;
}

.lc-city.is-leaving .lc-moon,
.lc-city.is-leaving .lc-sun {
  animation: lc-sink var(--lc-tdur) steps(80, end) forwards;
}

.lc-city.is-entering .lc-moon,
.lc-city.is-entering .lc-sun {
  animation: lc-rise-up var(--lc-tdur) steps(80, end) both;
}

.lc-city.is-entering .lc-layer--stars {
  animation: lc-dissolve var(--lc-tdur) steps(6, end) both;
}

.lc-city.is-leaving .lc-layer--stars {
  animation: lc-vanish calc(var(--lc-tdur) * 0.6) steps(6, end) forwards;
}

/* ===== 右上角日／夜切換 ===== */

/* 跟登入卡同一套半透明底，看起來是介面按鈕而不是天上的東西 */
.lc-theme {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--lc-ink-2);
  background: var(--lc-card-bg);
  border: 1px solid var(--lc-line);
  border-radius: 50%;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.lc-theme:hover {
  color: var(--lc-ink);
  border-color: rgba(170, 145, 245, 0.5);
}

.lc-theme:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--lc-focus);
}

.lc-theme svg {
  width: 22px;
  height: 22px;
}

/* 夜景顯示太陽（按了變白天），白天顯示月亮 */
.lc-theme__moon { display: none; }
:root[data-lc-theme="day"] .lc-theme__sun { display: none; }
:root[data-lc-theme="day"] .lc-theme__moon { display: block; }

.lc-city {
  position: absolute;
  left: 0;
  bottom: 0;
  display: block;
  shape-rendering: crispEdges;
}

.lc-star.is-twinkle {
  animation: lc-twinkle var(--lc-dur, 6s) steps(3, end) var(--lc-delay, 0s) infinite alternate;
}

.lc-win {
  fill: var(--lc-win-off);
  transition: fill 1.2s steps(4, end);
}

.lc-win.is-on.tone-warm { fill: var(--lc-win-warm); }
.lc-win.is-on.tone-lilac { fill: var(--lc-win-lilac); }
.lc-win.is-on.tone-dim { fill: var(--lc-win-dim); }

.lc-win--alert {
  fill: var(--lc-alert-lo);
  animation: lc-alert 5s steps(10, end) infinite;
}

.lc-node {
  fill: var(--lc-node-lo);
  animation: lc-node 7s steps(1, end) var(--lc-delay, 0s) infinite;
}

.lc-bldg {
  transition: filter 0.35s ease;
}

.lc-bldg:hover {
  filter: brightness(1.22);
}

.lc-lamp__head {
  fill: var(--lc-lamp-on);
  transition: fill 0.4s ease;
}

.lc-lamp__glow {
  opacity: 0.18;
  transition: opacity 0.4s ease;
}

.lc-lamp:hover .lc-lamp__head { fill: var(--lc-lamp-on-hover); }
.lc-lamp:hover .lc-lamp__glow { opacity: 0.38; }

/* 彩蛋：點路燈開關（關燈規則要排在 hover 之後才蓋得過） */
.lc-lamp .lc-hit { cursor: pointer; }
.lc-lamp.is-off .lc-lamp__head { fill: var(--lc-lamp-off); }
.lc-lamp.is-off .lc-lamp__glow { opacity: 0; }
.lc-lamp.is-off:hover .lc-lamp__head { fill: var(--lc-lamp-off-hover); }

/* 只閃燈頭；光圈靠自己的 transition 淡入 */
.lc-lamp.is-flicker .lc-lamp__head {
  animation: lc-flicker 0.6s steps(1, end);
}

/* 彩蛋：地下水管，平常幾乎融入土色 */
.lc-pipe__hi { fill: var(--lc-pipe-hi); }
.lc-pipe__body { fill: var(--lc-pipe-body); }
.lc-pipe__lo { fill: var(--lc-pipe-lo); }

.lc-pipe__hi,
.lc-pipe__body,
.lc-pipe__lo {
  transition: fill 0.5s ease;
}

.lc-pipe:hover .lc-pipe__hi { fill: var(--lc-pipe-hi-on); }
.lc-pipe:hover .lc-pipe__body { fill: var(--lc-pipe-body-on); }
.lc-pipe:hover .lc-pipe__lo { fill: var(--lc-pipe-lo-on); }

.lc-pipe__flow {
  opacity: 0;
  transition: opacity 0.4s ease;
  animation: lc-flow 1.2s steps(10, end) infinite paused;
}

.lc-pipe:hover .lc-pipe__flow {
  opacity: 1;
  animation-play-state: running;
}

/* 彩蛋：路人，走路時兩格輪流顯示 */
.lc-walker { visibility: hidden; }
.lc-walker.is-walking { visibility: visible; }
.lc-walker__f2 { opacity: 0; }
.lc-walker.is-walking .lc-walker__f1 { animation: lc-frame 0.5s steps(1, end) infinite; }
.lc-walker.is-walking .lc-walker__f2 { animation: lc-frame 0.5s steps(1, end) -0.25s infinite; }

/* 只負責接 hover／click 的透明感應區 */
.lc-hit {
  fill: none;
  pointer-events: all;
}

@keyframes lc-dissolve {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes lc-vanish {
  to { opacity: 0; }
}

@keyframes lc-sink {
  to { transform: translateY(80px); }
}

@keyframes lc-rise-up {
  from { transform: translateY(80px); }
  to { transform: none; }
}

@keyframes lc-twinkle {
  from { opacity: 1; }
  to { opacity: 0.3; }
}

@keyframes lc-alert {
  0%, 100% { fill: var(--lc-alert-lo); }
  50% { fill: var(--lc-alert-hi); }
}

@keyframes lc-node {
  0%, 86% { fill: var(--lc-node-lo); }
  88%, 94% { fill: var(--lc-node-hi); }
}

@keyframes lc-drift {
  from { transform: translateX(var(--lc-from)); }
  to { transform: translateX(var(--lc-to)); }
}

@keyframes lc-flicker {
  0%, 34% { opacity: 1; }
  17%, 50% { opacity: 0.15; }
}

@keyframes lc-flow {
  from { transform: translateX(0); }
  to { transform: translateX(10px); }
}

@keyframes lc-frame {
  0% { opacity: 1; }
  50% { opacity: 0; }
}

/* ===== Tooltip（像素風：硬邊框＋硬陰影） ===== */

.lc-tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 3;
  min-width: 168px;
  padding: 10px 12px 11px;
  font: 12px/1.4 var(--lc-mono);
  color: var(--lc-tip-ink);
  background: var(--lc-tip-bg);
  border: 2px solid var(--lc-tip-line);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.55);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(3px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}

.lc-tip.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

.lc-tip__head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lc-tip-ink-3);
}

.lc-tip__dot {
  width: 6px;
  height: 6px;
  background: #9d86f0;
}

.lc-tip__rows {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 18px;
  row-gap: 3px;
  margin: 0;
}

.lc-tip__rows dt { color: var(--lc-tip-ink-2); }

.lc-tip__rows dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.lc-tip__unit { color: var(--lc-tip-ink-3); }

.lc-tip--alert { border-color: #74386a; }
.lc-tip--alert .lc-tip__dot { background: var(--lc-alert); }
.lc-tip__alert { color: #efc7df; }

.lc-tip--water { border-color: #3d4a8a; }
.lc-tip--water .lc-tip__dot { background: #8fa2ff; }

.lc-tip__delta {
  margin-top: 2px;
  font-size: 18px;
  color: var(--lc-alert);
}

.lc-tip__spark {
  display: block;
  width: 96px;
  height: 24px;
  margin-top: 6px;
}

.lc-tip__foot {
  margin-top: 4px;
  font-size: 10.5px;
  color: var(--lc-tip-ink-3);
}

/* ===== 登入區 ===== */

.lc-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  pointer-events: none;
}

.lc-panel > * {
  pointer-events: auto;
}

/* 卡片周圍壓暗（白天改成淡霧），讓登入卡成為焦點；日夜兩層疊著，交接時一起分段淡換 */
.lc-panel::before,
.lc-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  transition: opacity var(--lc-tdur) steps(8, end);
}

.lc-panel::before { background: var(--lc-panel-shade-night); }
.lc-panel::after { background: var(--lc-panel-shade-day); opacity: 0; }
:root[data-lc-theme="day"] .lc-panel::before { opacity: 0; }
:root[data-lc-theme="day"] .lc-panel::after { opacity: 1; }

.lc-card {
  width: 100%;
  max-width: 400px;
  padding: 36px 32px 28px;
  background: var(--lc-card-bg);
  border: 1px solid var(--lc-line);
  border-radius: 14px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: var(--lc-card-shadow);
  animation: lc-rise 0.6s ease-out both;
  transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

@keyframes lc-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.lc-badge {
  display: inline-flex;
  margin-bottom: 20px;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  font: 600 10.5px/1 var(--lc-font);
  letter-spacing: 0.12em;
  color: var(--lc-badge-ink);
  background: var(--lc-badge-bg);
  border: 1px solid var(--lc-badge-line);
  border-radius: 999px;
}

.lc-badge__dot {
  width: 6px;
  height: 6px;
  background: var(--lc-badge-dot);
}

.lc-card__logo {
  display: block;
  width: 104px;
  height: auto;
  aspect-ratio: 251.57 / 163.46;
  margin-bottom: 22px;
}

.lc-card__title {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.lc-card__sub {
  margin: 0 0 26px;
  font-size: 14px;
  color: var(--lc-ink-2);
}

.lc-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 給 validationEngine 的提示框當定位層：卡片的 backdrop-filter 會讓 jQuery 算出的位置偏到卡片底部 */
.lc-field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.lc-field__label {
  font-size: 13px;
  color: var(--lc-ink-2);
}

.lc-field__wrap {
  position: relative;
}

.lc-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font: 15px var(--lc-font);
  color: var(--lc-ink);
  background: var(--lc-input-bg);
  border: 1px solid var(--lc-line);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.lc-input:hover {
  border-color: rgba(170, 145, 245, 0.38);
}

.lc-input:focus {
  border-color: #9a80f0;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 3px var(--lc-focus);
}

/* 瀏覽器自動填入時維持卡片底色 */
.lc-input:-webkit-autofill {
  -webkit-text-fill-color: var(--lc-ink);
  box-shadow: 0 0 0 100px var(--lc-autofill) inset;
  caret-color: var(--lc-ink);
}

.lc-input--pw {
  padding-right: 46px;
}

.lc-eye {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--lc-ink-3);
  cursor: pointer;
  transform: translateY(-50%);
}

.lc-eye:hover {
  color: var(--lc-ink);
  background: rgba(255, 255, 255, 0.05);
}

.lc-eye:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--lc-focus);
}

.lc-eye svg {
  width: 18px;
  height: 18px;
}

/* Login.js 只切換 input 的 type，圖示跟著 type 換 */
.lc-eye__on { display: none; }
.lc-input[type="text"] + .lc-eye .lc-eye__on { display: block; }
.lc-input[type="text"] + .lc-eye .lc-eye__off { display: none; }

.lc-btn {
  height: 46px;
  margin-top: 6px;
  border: 0;
  border-radius: 10px;
  font: 600 15px var(--lc-font);
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--lc-accent);
  box-shadow: 0 6px 18px rgba(80, 55, 170, 0.35);
  cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s, transform 0.1s;
}

.lc-btn:hover {
  background: var(--lc-accent-hover);
}

.lc-btn:active {
  transform: translateY(1px);
}

.lc-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--lc-focus), 0 6px 18px rgba(80, 55, 170, 0.35);
}

/* 首頁：登入／註冊兩顆按鈕 */
.lc-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lc-actions .lc-btn {
  margin-top: 0;
}

.lc-btn--ghost {
  color: var(--lc-ink);
  background: transparent;
  border: 1px solid rgba(170, 145, 245, 0.45);
  box-shadow: none;
}

.lc-btn--ghost:hover {
  background: rgba(140, 110, 240, 0.12);
  border-color: #9a80f0;
}

.lc-btn--ghost:focus-visible {
  box-shadow: 0 0 0 3px var(--lc-focus);
}

.lc-form__note {
  margin: 0;
  font-size: 12.5px;
  text-align: center;
  color: var(--lc-ink-3);
}

.lc-actions + .lc-form__note {
  margin-top: 12px;
}

.lc-form__note:empty {
  display: none;
}

.lc-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.lc-links a {
  color: var(--lc-ink-2);
  text-decoration: none;
}

.lc-links a:hover {
  color: var(--lc-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* 卡片底部的公司 logo */
.lc-card__foot {
  display: flex;
  justify-content: center;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--lc-line);
}

.lc-dae {
  width: auto;
  height: 30px;
  opacity: 0.55;
}

/* ===== Responsive ===== */

@media (max-width: 1199px) {
  .lc-city .is-extra { display: none; }
}

@media (max-width: 767px) {
  .lc-city .lc-layer--mid,
  .lc-city .lc-layer--main,
  .lc-city .lc-layer--props,
  .lc-city .lc-layer--underground,
  .lc-city .lc-layer--walker,
  .lc-city .lc-cloud--near,
  .lc-city .is-sparse {
    display: none;
  }

  .lc-panel {
    --lc-panel-shade-night: rgba(7, 5, 14, 0.35);
    --lc-panel-shade-day: rgba(240, 236, 255, 0.3);
    width: 100%;
    margin: 0;
    padding: 32px 16px;
  }

  .lc-card {
    padding: 30px 22px 24px;
  }

  .lc-card__logo {
    width: 88px;
  }

  .lc-tip {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lc-star.is-twinkle,
  .lc-node,
  .lc-card {
    animation: none;
  }

  .lc-win--alert {
    animation: none;
    fill: var(--lc-alert-still);
  }

  .lc-pipe__flow,
  .lc-lamp.is-flicker .lc-lamp__head {
    animation: none;
  }

  .lc-win,
  .lc-bldg,
  .lc-tip,
  .lc-panel::before,
  .lc-panel::after,
  .lc-lamp__head,
  .lc-lamp__glow {
    transition: none;
  }
}
