/* =========================================================
   login_gate.css — 登入／註冊閘口表面風格
   Prefs key: localStorage "ui_surface" = "flat" | "glass" (default: glass)
   DOM hook:  html[data-ui-surface="flat"|"glass"]  (+ optional body.ui-flat / body.ui-glass)
   Settings toggle / glass-panel 全域切換：teammate 認領，此檔只消費 hook。
   ========================================================= */

:root {
  /* Flat B&W tokens（高級黑白平面） */
  --ui-flat-bg: #fafafa;
  --ui-flat-fg: #111;
  --ui-flat-muted: #666;
  --ui-flat-hint: #888;
  --ui-flat-placeholder: #999;
  --ui-flat-border: #111;
  --ui-flat-border-soft: #ccc;
  --ui-flat-border-hair: #e5e5e5;
  --ui-flat-input-bg: #fff;
  --ui-flat-hover: #f0f0f0;
  --ui-flat-radius: 8px;
  --ui-flat-radius-sm: 6px;
  --ui-flat-overlay: rgba(0, 0, 0, 0.42);
}

/* ---------- shared layout (both surfaces) ---------- */
#login-gate.login-gate-wrapper {
  width: min(92vw, 360px);
  max-width: 360px;
  top: 12px !important;
  max-height: calc(100dvh - 24px) !important;
  overflow-y: auto !important;
}

.login-google-slot {
  width: 100%;
  min-height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.login-google-slot .g_id_signin {
  display: flex;
  justify-content: center;
}

body:has(#login-gate.active-view) .system-controls {
  display: none !important;
}

@keyframes registerPulse {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: none; }
}

/* =========================================================
   FLAT — only when data-ui-surface="flat" (default is glass)
   ========================================================= */
html[data-ui-surface="flat"] #login-gate.login-gate-wrapper,
body.ui-flat #login-gate.login-gate-wrapper {
  gap: 10px;
  padding: 28px 24px 22px !important;
  background: var(--ui-flat-bg) !important;
  color: var(--ui-flat-fg) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: 1px solid var(--ui-flat-border) !important;
  border-radius: var(--ui-flat-radius) !important;
  box-shadow: none !important;
}

html[data-ui-surface="flat"] #login-gate.login-gate-wrapper::before,
body.ui-flat #login-gate.login-gate-wrapper::before {
  display: none !important;
  content: none !important;
}

html[data-ui-surface="flat"] #login-gate #lan-gate-title,
body.ui-flat #login-gate #lan-gate-title {
  margin: 4px 0 0;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: 0.12em;
  font-weight: 600;
  color: var(--ui-flat-fg) !important;
}

html[data-ui-surface="flat"] .login-gate-tagline,
body.ui-flat .login-gate-tagline {
  margin: 0 0 8px;
  color: var(--ui-flat-muted) !important;
  font-size: 11px;
  letter-spacing: 0.06em;
  font-weight: 400;
}

html[data-ui-surface="flat"] .login-gate-hint,
body.ui-flat .login-gate-hint {
  margin: 0 0 4px;
  color: var(--ui-flat-hint) !important;
  font-size: 11px;
  line-height: 1.55;
  letter-spacing: 0.02em;
}

html[data-ui-surface="flat"] #login-gate #gate-user,
html[data-ui-surface="flat"] #login-gate #gate-pwd,
body.ui-flat #login-gate #gate-user,
body.ui-flat #login-gate #gate-pwd {
  width: 100%;
  margin: 0 !important;
  padding: 11px 12px !important;
  box-sizing: border-box;
  background: var(--ui-flat-input-bg) !important;
  color: var(--ui-flat-fg) !important;
  border: 1px solid var(--ui-flat-border-soft) !important;
  border-radius: var(--ui-flat-radius-sm) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  font-size: 14px;
  outline: none;
}

html[data-ui-surface="flat"] #login-gate #gate-user:focus,
html[data-ui-surface="flat"] #login-gate #gate-pwd:focus,
body.ui-flat #login-gate #gate-user:focus,
body.ui-flat #login-gate #gate-pwd:focus {
  border-color: var(--ui-flat-border) !important;
}

html[data-ui-surface="flat"] #login-gate #gate-user::placeholder,
html[data-ui-surface="flat"] #login-gate #gate-pwd::placeholder,
body.ui-flat #login-gate #gate-user::placeholder,
body.ui-flat #login-gate #gate-pwd::placeholder {
  color: var(--ui-flat-placeholder) !important;
}

html[data-ui-surface="flat"] .btn-login-secondary,
html[data-ui-surface="flat"] #login-gate #lan-gate-loginbtn,
body.ui-flat .btn-login-secondary,
body.ui-flat #login-gate #lan-gate-loginbtn {
  width: 100%;
  margin: 2px 0 0 !important;
  padding: 11px 16px !important;
  background: var(--ui-flat-bg) !important;
  color: var(--ui-flat-fg) !important;
  border: 1px solid var(--ui-flat-border) !important;
  box-shadow: none !important;
  height: auto !important;
  border-radius: var(--ui-flat-radius-sm) !important;
  font-weight: 500 !important;
  font-size: 13px !important;
  letter-spacing: 0.04em;
}

html[data-ui-surface="flat"] .btn-login-secondary:hover,
html[data-ui-surface="flat"] #login-gate #lan-gate-loginbtn:hover,
body.ui-flat .btn-login-secondary:hover,
body.ui-flat #login-gate #lan-gate-loginbtn:hover {
  background: var(--ui-flat-hover) !important;
  filter: none;
}

html[data-ui-surface="flat"] .btn-register-cta,
html[data-ui-surface="flat"] #login-gate #btn-show-register,
body.ui-flat .btn-register-cta,
body.ui-flat #login-gate #btn-show-register {
  width: 100% !important;
  margin: 6px 0 0 !important;
  padding: 12px 16px !important;
  background: var(--ui-flat-fg) !important;
  color: #fff !important;
  border: 1px solid var(--ui-flat-border) !important;
  box-shadow: none !important;
  animation: none;
  font-size: 14px !important;
  font-weight: 600 !important;
  letter-spacing: 0.06em;
  height: auto !important;
  border-radius: var(--ui-flat-radius-sm) !important;
}

html[data-ui-surface="flat"] .btn-register-cta:hover,
html[data-ui-surface="flat"] #login-gate #btn-show-register:hover,
body.ui-flat .btn-register-cta:hover,
body.ui-flat #login-gate #btn-show-register:hover {
  filter: none;
  background: #000 !important;
}

html[data-ui-surface="flat"] .login-divider,
body.ui-flat .login-divider {
  text-align: center;
  color: var(--ui-flat-hint) !important;
  margin: 10px 0 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
}

html[data-ui-surface="flat"] .login-oauth-stack,
body.ui-flat .login-oauth-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  background: transparent;
  padding: 12px 0 0;
  border-radius: 0;
  border: none;
  border-top: 1px solid var(--ui-flat-border-hair);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}

html[data-ui-surface="flat"] .login-oauth-stack > .btn,
body.ui-flat .login-oauth-stack > .btn {
  width: 100% !important;
  margin: 0 !important;
  min-height: 40px;
  border-radius: var(--ui-flat-radius-sm) !important;
  box-shadow: none !important;
}

html[data-ui-surface="flat"] #login-gate .login-oauth-stack > .btn[onclick*="discord"],
html[data-ui-surface="flat"] #login-gate .login-oauth-stack > .btn[onclick*="microsoft"],
body.ui-flat #login-gate .login-oauth-stack > .btn[onclick*="discord"],
body.ui-flat #login-gate .login-oauth-stack > .btn[onclick*="microsoft"] {
  background: var(--ui-flat-bg) !important;
  color: var(--ui-flat-fg) !important;
  border: 1px solid var(--ui-flat-border) !important;
  font-weight: 500 !important;
}

html[data-ui-surface="flat"] #login-gate .login-oauth-stack > .btn[onclick*="discord"] svg,
html[data-ui-surface="flat"] #login-gate .login-oauth-stack > .btn[onclick*="microsoft"] svg,
body.ui-flat #login-gate .login-oauth-stack > .btn[onclick*="discord"] svg,
body.ui-flat #login-gate .login-oauth-stack > .btn[onclick*="microsoft"] svg {
  fill: var(--ui-flat-fg) !important;
}

html[data-ui-surface="flat"] #login-gate .login-oauth-stack > .btn[onclick*="discord"]:hover,
html[data-ui-surface="flat"] #login-gate .login-oauth-stack > .btn[onclick*="microsoft"]:hover,
body.ui-flat #login-gate .login-oauth-stack > .btn[onclick*="discord"]:hover,
body.ui-flat #login-gate .login-oauth-stack > .btn[onclick*="microsoft"]:hover {
  background: var(--ui-flat-hover) !important;
}

/* Register modal — flat (same tokens as login) */
html[data-ui-surface="flat"] #register-modal.modal-overlay,
body.ui-flat #register-modal.modal-overlay {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: var(--ui-flat-overlay) !important;
}

html[data-ui-surface="flat"] #register-modal .modal-window,
body.ui-flat #register-modal .modal-window {
  width: min(92vw, 360px) !important;
  max-width: 360px !important;
  padding: 28px 24px 22px !important;
  background: var(--ui-flat-bg) !important;
  color: var(--ui-flat-fg) !important;
  border: 1px solid var(--ui-flat-border) !important;
  border-radius: var(--ui-flat-radius) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  overflow: visible;
}

html[data-ui-surface="flat"] #register-modal .modal-window::before,
body.ui-flat #register-modal .modal-window::before {
  display: none !important;
  content: none !important;
}

html[data-ui-surface="flat"] #register-modal .modal-window h3,
body.ui-flat #register-modal .modal-window h3 {
  margin: 4px 0 14px;
  padding-right: 28px;
  font-size: 17px;
  line-height: 1.35;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--ui-flat-fg) !important;
  text-align: left;
}

html[data-ui-surface="flat"] #register-modal .modal-window input,
html[data-ui-surface="flat"] #register-modal #reg-user,
html[data-ui-surface="flat"] #register-modal #reg-pwd,
body.ui-flat #register-modal .modal-window input,
body.ui-flat #register-modal #reg-user,
body.ui-flat #register-modal #reg-pwd {
  width: 100%;
  margin: 0 0 10px !important;
  padding: 11px 12px !important;
  box-sizing: border-box;
  background: var(--ui-flat-input-bg) !important;
  color: var(--ui-flat-fg) !important;
  border: 1px solid var(--ui-flat-border-soft) !important;
  border-radius: var(--ui-flat-radius-sm) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  font-size: 14px;
  font-weight: 400;
  text-align: left;
  outline: none;
}

html[data-ui-surface="flat"] #register-modal .modal-window input:focus,
html[data-ui-surface="flat"] #register-modal #reg-user:focus,
html[data-ui-surface="flat"] #register-modal #reg-pwd:focus,
body.ui-flat #register-modal .modal-window input:focus,
body.ui-flat #register-modal #reg-user:focus,
body.ui-flat #register-modal #reg-pwd:focus {
  border-color: var(--ui-flat-border) !important;
  background: var(--ui-flat-input-bg) !important;
  box-shadow: none !important;
}

html[data-ui-surface="flat"] #register-modal .modal-window input::placeholder,
html[data-ui-surface="flat"] #register-modal #reg-user::placeholder,
html[data-ui-surface="flat"] #register-modal #reg-pwd::placeholder,
body.ui-flat #register-modal .modal-window input::placeholder,
body.ui-flat #register-modal #reg-user::placeholder,
body.ui-flat #register-modal #reg-pwd::placeholder {
  color: var(--ui-flat-placeholder) !important;
}

html[data-ui-surface="flat"] #register-modal .close-btn,
body.ui-flat #register-modal .close-btn {
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  font-size: 20px;
  line-height: 30px;
  color: var(--ui-flat-muted) !important;
  border: 1px solid transparent;
  border-radius: var(--ui-flat-radius-sm);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  transform: none !important;
}

html[data-ui-surface="flat"] #register-modal .close-btn:hover,
body.ui-flat #register-modal .close-btn:hover {
  color: var(--ui-flat-fg) !important;
  background: var(--ui-flat-hover) !important;
  border-color: var(--ui-flat-border-soft);
  transform: none !important;
}

html[data-ui-surface="flat"] #register-modal #btn-do-register,
html[data-ui-surface="flat"] #register-modal .modal-window > .btn,
body.ui-flat #register-modal #btn-do-register,
body.ui-flat #register-modal .modal-window > .btn {
  width: 100% !important;
  margin: 6px 0 0 !important;
  padding: 12px 16px !important;
  background: var(--ui-flat-fg) !important;
  color: #fff !important;
  border: 1px solid var(--ui-flat-border) !important;
  border-radius: var(--ui-flat-radius-sm) !important;
  box-shadow: none !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  letter-spacing: 0.06em;
  height: auto !important;
}

html[data-ui-surface="flat"] #register-modal #btn-do-register:hover,
html[data-ui-surface="flat"] #register-modal .modal-window > .btn:hover,
body.ui-flat #register-modal #btn-do-register:hover,
body.ui-flat #register-modal .modal-window > .btn:hover {
  background: #000 !important;
  filter: none;
}

html[data-ui-surface="flat"] body.no-glass #login-gate.login-gate-wrapper,
html[data-ui-surface="flat"] body.no-glass .privacy-modal,
html[data-ui-surface="flat"] body.no-glass #register-modal .modal-window,
body.ui-flat.no-glass #login-gate.login-gate-wrapper,
body.ui-flat.no-glass .privacy-modal,
body.ui-flat.no-glass #register-modal .modal-window {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: var(--ui-flat-bg) !important;
}

/* =========================================================
   GLASS — html[data-ui-surface="glass"] / body.ui-glass
   ========================================================= */
html[data-ui-surface="glass"] #login-gate.login-gate-wrapper,
body.ui-glass #login-gate.login-gate-wrapper {
  gap: 8px;
  padding: 18px 16px 16px !important;
  background: rgba(255, 255, 255, 0.13) !important;
  color: inherit !important;
  backdrop-filter: blur(28px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(32px) saturate(180%) !important;
  border: 1px solid rgba(255, 255, 255, 0.22) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.4) !important;
  border-radius: 24px !important;
  box-shadow:
    0 12px 36px rgba(0, 0, 0, 0.28),
    inset 0 1px 1px rgba(255, 255, 255, 0.25),
    inset 0 -3px 8px rgba(0, 0, 0, 0.35) !important;
}

html[data-ui-surface="glass"] #login-gate #lan-gate-title,
body.ui-glass #login-gate #lan-gate-title {
  margin: 2px 0 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: normal;
  font-weight: 700;
  color: inherit !important;
}

html[data-ui-surface="glass"] .login-gate-tagline,
body.ui-glass .login-gate-tagline {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.03em;
  font-weight: 400;
}

html[data-ui-surface="glass"] .login-gate-hint,
body.ui-glass .login-gate-hint {
  margin: 0 0 4px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

html[data-ui-surface="glass"] #login-gate #gate-user,
html[data-ui-surface="glass"] #login-gate #gate-pwd,
body.ui-glass #login-gate #gate-user,
body.ui-glass #login-gate #gate-pwd {
  width: 100%;
  margin: 0 !important;
  padding: 10px 12px !important;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.08) !important;
  color: var(--text-main) !important;
  border: 1px solid rgba(255, 255, 255, 0.22) !important;
  border-radius: 14px !important;
  box-shadow: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

html[data-ui-surface="glass"] .btn-login-secondary,
html[data-ui-surface="glass"] #login-gate #lan-gate-loginbtn,
body.ui-glass .btn-login-secondary,
body.ui-glass #login-gate #lan-gate-loginbtn {
  width: 100%;
  margin: 2px 0 0 !important;
  padding: 10px 16px !important;
  background: rgba(255, 255, 255, 0.12) !important;
  color: var(--text-main) !important;
  border: 1px solid rgba(255, 255, 255, 0.22) !important;
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.25),
    inset 0 -2px 4px rgba(0, 0, 0, 0.12) !important;
  height: auto !important;
  border-radius: 16px !important;
  font-weight: 600 !important;
  font-size: 14px !important;
}

html[data-ui-surface="glass"] .btn-register-cta,
html[data-ui-surface="glass"] #login-gate #btn-show-register,
body.ui-glass .btn-register-cta,
body.ui-glass #login-gate #btn-show-register {
  width: 100% !important;
  margin: 4px 0 0 !important;
  padding: 12px 16px !important;
  background: rgba(10, 132, 255, 0.88) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.28) !important;
  box-shadow:
    0 6px 18px rgba(10, 132, 255, 0.22),
    inset 0 1px 1px rgba(255, 255, 255, 0.28) !important;
  animation: none;
  font-size: 16px !important;
  font-weight: 700 !important;
  height: auto !important;
  border-radius: 16px !important;
  letter-spacing: normal;
}

html[data-ui-surface="glass"] .btn-register-cta:hover,
html[data-ui-surface="glass"] #login-gate #btn-show-register:hover,
body.ui-glass .btn-register-cta:hover,
body.ui-glass #login-gate #btn-show-register:hover {
  filter: brightness(1.05);
  background: rgba(10, 132, 255, 0.96) !important;
}

html[data-ui-surface="glass"] .login-divider,
body.ui-glass .login-divider {
  text-align: center;
  color: var(--text-muted);
  margin: 8px 0 2px;
  font-size: 11px;
  letter-spacing: normal;
}

html[data-ui-surface="glass"] .login-oauth-stack,
body.ui-glass .login-oauth-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  background: rgba(255, 255, 255, 0.06);
  padding: 10px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.18);
}

html[data-ui-surface="glass"] .login-oauth-stack > .btn,
body.ui-glass .login-oauth-stack > .btn {
  width: 100% !important;
  margin: 0 !important;
  min-height: 40px;
  border-radius: 12px !important;
}

html[data-ui-surface="glass"] body.no-glass #login-gate.login-gate-wrapper,
html[data-ui-surface="glass"] body.no-glass .privacy-modal,
body.ui-glass.no-glass #login-gate.login-gate-wrapper,
body.ui-glass.no-glass .privacy-modal {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: #1c1c1e !important;
}

/* glass-panel 全域 flat 覆寫由 teammate 認領；此處僅閘口／註冊。 */
