/* =========================================================
   Component: Blog Sign-up Box (blog-sign-box)
   ---------------------------------------------------------
   - 抽出元: yoyipapa-web-bkc
     packages/next/src/app/[locale]/(blog)/blog/[id]/BlogSignBox.tsx
     packages/next/src/app/[locale]/(blog)/blog/[id]/BlogContent.tsx
   - 用途: 博客详情页右侧 sticky 手机号/邮箱注册版块
   - 依赖 JS: js/blog-sign-box.js (手机号校验 + check-user API + 埋点)
    - 使用方式(桌面右侧 sticky 侧栏):
        1) <link rel="stylesheet" href="css/blog-sign-box.css">
        2) <script src="js/blog-sign-box.js"></script>  (建议放 body 末尾)
        3) 放置挂载点: <div class="blog-sign-sticky" data-bsb-mount></div>
        JS 会从缓存模板生成 .blog-sign-box，调用页不再复制组件内部结构。
        移动端直接使用 <div data-bsb-mount></div> 即可自动全宽。
   - 此组件已针对 Konkatsu 站点设计，可使用 CSS 自定义变量覆盖颜色：
     --bsb-title-color:    标题文字颜色   (默认 #da1c1c)
     --bsb-subtitle-color: 副标题文字颜色 (默认 #da1c1c)
     --bsb-gold-gradient:  金色渐变背景   (默认原 React gradient)
   - 组件输入框使用 Konkatsu 站点的 --color-border, --radius-md, --font-jp 变量，
     以保持与站点其余表单的视觉一致性。
   ========================================================= */

.blog-sign-box {
  display: block;
  width: 377px;
  max-width: 100%;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 22px 66px 0 rgba(0, 0, 0, 0.1);
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    'Hiragino Sans', sans-serif;
  --bsb-title-color: #da1c1c;
  --bsb-subtitle-color: #da1c1c;
}

/* 页面只保留该挂载点；内部组件由 js/blog-sign-box.js 创建。 */
[data-bsb-mount] {
  display: block;
  width: 377px;
  max-width: 100%;
}

/* 以下变量可在页面层通过 :root { --bsb-title-color: ... } 进行覆盖 */

/* ---- 桌面右侧 sticky 容器 ---- */
.blog-sign-sticky {
  position: sticky;
  top: 80px;
  z-index: 10;
}

/* ---- Header ---- */
.bsb-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 20px 0;
}

.bsb-title {
  margin: 0;
  text-align: center;
  color: var(--bsb-title-color, #da1c1c);
  font-size: 32px;
  line-height: 1.4;
  font-weight: 600;
}

.bsb-subtitle {
  margin: 0;
  text-align: center;
  color: var(--bsb-subtitle-color, #da1c1c);
  font-size: 24px;
  line-height: 1.4;
  font-weight: 600;
}

/* ---- Body ---- */
.bsb-body {
  padding: 10px 24px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bsb-tip {
  margin: 0;
  text-align: center;
  color: rgba(0, 0, 0, 0.8);
  font-size: 16px;
  line-height: 22px;
  font-weight: 400;
}

/* ---- 手机号表单 ---- */
.bsb-form {
  width: 100%;
  margin: 26px 0 24px;
}

.bsb-field-title {
  margin: 0 0 8px;
  text-align: left;
  color: rgba(0, 0, 0, 0.6);
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
}

.bsb-phone-row {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

/* 国家码下拉框 - 使用 Konkatsu 站点输入框样式 */
.bsb-area {
  min-width: 98px;
  height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--color-border, #e8e0d8);
  border-radius: var(--radius-md, 8px);
  background: #fff;
  color: rgba(0, 0, 0, 0.8);
  font-family: var(--font-jp, "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif);
  font-size: 14px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

/* 手机号输入框 - 使用 Konkatsu 站点输入框样式 */
.bsb-phone {
  width: 100%;
  height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--color-border, #e8e0d8);
  border-radius: var(--radius-md, 8px);
  background: #fff;
  color: rgba(0, 0, 0, 0.8);
  font-family: var(--font-jp, "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif);
  font-size: 14px;
  outline: 0;
}

.bsb-phone:focus,
.bsb-area:focus {
  border-color: var(--color-primary, #f08080);
  box-shadow: 0 0 0 3px rgba(240, 128, 128, 0.1);
}

/* ---- 校验错误 ---- */
.bsb-form.is-invalid .bsb-phone,
.bsb-form.is-invalid .bsb-area {
  border-color: #e03636;
  box-shadow: 0 0 0 3px rgba(224, 54, 54, 0.12);
}

.bsb-error {
  min-height: 0;
  margin: 6px 2px 0 2px;
  padding: 0;
  text-align: left;
  font-size: 12px;
  line-height: 18px;
  color: #e03636;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.bsb-error.show {
  opacity: 1;
  transform: translateY(0);
}

/* ---- 金色按钮 ---- */
.bsb-gold-gradient {
  background: var(--bsb-gold-gradient, linear-gradient(
    154deg,
    rgba(176, 117, 21, 1),
    rgba(244, 221, 137, 1),
    rgba(255, 255, 215, 1),
    rgba(240, 218, 137, 1),
    rgba(176, 117, 21, 1),
    rgba(244, 221, 137, 1),
    rgba(255, 255, 215, 1),
    rgba(240, 218, 137, 1),
    rgba(176, 117, 21, 1)
  ));
  background-size: 300% 300%;
  animation: bsb-gradient-move 10s ease infinite;
}

@keyframes bsb-gradient-move {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.bsb-btn-primary {
  display: inline-block;
  width: 100%;
  margin: 0 0 18px;
  padding: 2px;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
}

.bsb-btn-primary:active {
  opacity: 0.5;
  transform: scale(0.98);
}

/* 预填手机号后可选展示徽标 */
.bsb-btn-primary.is-loading {
  pointer-events: none;
  opacity: 0.6;
}

.bsb-btn-primary-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border-radius: 30px;
  background: linear-gradient(270deg, #bd0202 0%, #ff3838 100%);
}

.bsb-btn-primary-text {
  background: var(--bsb-gold-gradient, linear-gradient(
    154deg,
    rgba(176, 117, 21, 1),
    rgba(244, 221, 137, 1),
    rgba(255, 255, 215, 1),
    rgba(240, 218, 137, 1),
    rgba(176, 117, 21, 1),
    rgba(244, 221, 137, 1),
    rgba(255, 255, 215, 1),
    rgba(240, 218, 137, 1),
    rgba(176, 117, 21, 1)
  ));
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: bsb-gradient-move 10s ease infinite;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
}

/* ---- 18歳未満注意 ---- */
.bsb-warning {
  width: 100%;
  margin: 0 0 10px;
  padding: 12px 0 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  text-align: center;
  color: rgba(0, 0, 0, 0.6);
  font-size: 14px;
  line-height: 20px;
}

/* ---- 邮箱注册按钮 ---- */
.bsb-email-wrap {
  width: 100%;
  margin: 0 0 24px;
}

.bsb-btn-email {
  display: block;
  width: 100%;
  height: 44px;
  border-radius: 30px;
  text-align: center;
  line-height: 44px;
  font-size: 20px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.1);
  color: #000;
  text-decoration: none;
  transition: background 0.2s;
}

.bsb-btn-email:hover {
  background: rgba(0, 0, 0, 0.16);
}

/* ---- App 下载 ---- */
.bsb-tip2 {
  width: 100%;
  margin: 0;
  text-align: center;
  font-size: 16px;
  line-height: 22px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.8);
}

.bsb-store-badges {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.bsb-badge-link {
  display: block;
  line-height: 0;
}

.bsb-badge {
  display: block;
  width: auto;
  height: 44px;
  max-width: 160px;
}

/* ---- 移动端 (767px 及以下) ---- */
@media (max-width: 767px) {
  [data-bsb-mount] {
    width: 100%;
  }

  .blog-sign-box {
    width: 100%;
  }

  .bsb-header {
    padding: 17px 16px 16px;
  }

  .bsb-title {
    font-size: 22px;
  }

  .bsb-subtitle {
    font-size: 20px;
  }

  .bsb-body {
    padding: 0 20px 30px;
  }

  .bsb-tip {
    font-size: 14px;
    line-height: 20px;
  }

  .bsb-form {
    margin: 22px 0 14px;
  }

  .bsb-btn-primary {
    margin-bottom: 0;
  }

  .bsb-warning {
    padding-bottom: 18px;
  }

  .bsb-tip2 {
    font-size: 12px;
  }
}
