/* ============================================================
   Secret Block Plugin
   ============================================================ */

/* ── 外层容器 ── */
.secret-block {
  margin: 1rem 0;
  border: 1px solid #e9ecef;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  transition: border-color 0.2s;
  position: relative;
}

.secret-block:focus-within {
  border-color: #ffcc22;
}

.secret-block-num {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 10px;
  font-size: 0.72em;
  line-height: 1;
  color: currentColor;
  opacity: 0.35;
  pointer-events: none;
  user-select: none;
}

/* ── 解锁后：移除容器样式 ── */
.secret-block.is-unlocked {
  border: none;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  margin: 1rem 0;
}

.secret-block.is-unlocked .secret-block-num {
  display: none; /* 解锁后隐藏编号 */
}

/* ── 锁定区域 ── */
.secret-block-lock {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
  background: linear-gradient(160deg, #f8f9fa 0%, #f8f9fa 100%);
  cursor: default;
}

/* ── 锁图标 ── */
.secret-block-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ffcc22;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  transition: background 0.2s;
}

.secret-block-icon svg {
  width: 18px;
  height: 18px;
}

/* ── 提示文字（未激活时显示） ── */
.secret-block-hint {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 300;
  color: #ffcc22;
  cursor: pointer;
  user-select: none;
  letter-spacing: -0.01em;
  transition: color 0.18s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 33px;
}

.secret-block-hint:hover {
  color: #0077be;
}

/* ── 输入行 ── */
.secret-block-input-row {
  display: none;
  gap: 0.5rem;
  flex: 1;
  max-width: 230px;
  pointer-events: none;
}

.secret-block-input-row.is-active {
  display: flex;
  opacity: 1;
  pointer-events: auto;
  animation: input-row-in 0.22s ease both;
}

.secret-block-input-row.is-hiding {
  pointer-events: none;
  animation: input-row-out 0.2s ease both;
}

@keyframes input-row-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes input-row-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* ── 密码输入框 ── */
.secret-pwd-input {
  flex: 1;
  min-width: 0;
  height: 33px;
  box-sizing: border-box;
  padding: 0 0.8rem 0 0;
  border: none;
  border-bottom: 1px solid #c8eef1;
  border-radius: 0;
  font-size: 1rem;
  background: transparent;
  color: #1f2937;
  outline: none;
  transition: border-color 0.18s;
}

.secret-pwd-input::placeholder {
  color: #b5cdd0;
}

.secret-pwd-input:focus {
  border-bottom-color: #ffcc22;
  outline: none;
}

/* ── 解锁 SVG 图标 ── */
.secret-unlock-btn {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: #ffcc22;
  cursor: pointer;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  transition:
    color 0.18s,
    transform 0.1s;
}

.secret-unlock-btn:hover {
  color: #0077be;
}

.secret-unlock-btn:active {
  transform: scale(0.9);
}

.secret-block-error {
  flex: 1;
  margin: 0;
  font-size: 1.1rem;
  font-weight: 300;
  color: #ffcc22;
  letter-spacing: -0.01em;
  line-height: 33px;
}

@keyframes secret-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

/* ── 解锁后内容区域 ── */
.secret-block-content {
  display: none;
}

.secret-block-content.is-revealed {
  display: block;
  animation: secret-reveal 0.28s ease;
}

@keyframes secret-reveal {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.secret-block-content > :first-child,
.secret-block-content > pre:first-child,
.secret-block-content > .itxgo-code-block:first-child {
  margin-top: 0;
}

.secret-block-content > :last-child,
.secret-block-content > pre:last-child,
.secret-block-content > .itxgo-code-block:last-child {
  margin-bottom: 0;
}

/* ── 密码块 深色模式 ── */
@media (prefers-color-scheme: dark) {
  /* 外层容器 */
  :root:not([data-theme="light"]) .secret-block {
    border-color: var(--color-border);
    background: var(--color-bg-card);
  }

  /* 锁定区域背景 */
  :root:not([data-theme="light"]) .secret-block-lock {
    background: linear-gradient(
      160deg,
      var(--color-bg-light) 0%,
      var(--color-bg-light) 100%
    );
  }

  /* 提示文字 hover */
  :root:not([data-theme="light"]) .secret-block-hint:hover {
    color: var(--color-accent-hover);
  }

  /* 密码输入框 */
  :root:not([data-theme="light"]) .secret-pwd-input {
    border-bottom-color: var(--color-border-light);
    color: var(--color-text-primary);
  }

  :root:not([data-theme="light"]) .secret-pwd-input::placeholder {
    color: var(--color-text-tertiary);
  }

  /* 解锁按钮 hover */
  :root:not([data-theme="light"]) .secret-unlock-btn:hover {
    color: var(--color-accent-hover);
  }
}

[data-theme="dark"] .secret-block,
.dark-mode .secret-block {
  border-color: var(--color-border);
  background: var(--color-bg-card);
}

[data-theme="dark"] .secret-block-lock,
.dark-mode .secret-block-lock {
  background: linear-gradient(
    160deg,
    var(--color-bg-light) 0%,
    var(--color-bg-light) 100%
  );
}

[data-theme="dark"] .secret-block-hint:hover,
.dark-mode .secret-block-hint:hover {
  color: var(--color-accent-hover);
}

[data-theme="dark"] .secret-pwd-input,
.dark-mode .secret-pwd-input {
  border-bottom-color: var(--color-border-light);
  color: var(--color-text-primary);
}

[data-theme="dark"] .secret-pwd-input::placeholder,
.dark-mode .secret-pwd-input::placeholder {
  color: var(--color-text-tertiary);
}

[data-theme="dark"] .secret-unlock-btn:hover,
.dark-mode .secret-unlock-btn:hover {
  color: var(--color-accent-hover);
}

/* ── 移动端适配 ── */
@media (max-width: 480px) {
  .secret-block-lock {
    padding: 0.75rem 1rem;
  }

  .secret-block-hint,
  .secret-block-error {
    font-size: 1.1rem;
    line-height: 33px;
  }

  .secret-block-input-row.is-active {
    max-width: 100%;
  }
}
