/* --- Replace buttons in style.css --- */
const fs = require('fs');

let css = fs.readFileSync('style.css', 'utf8');

// remove everything from /* 6. Buttons */ to the end
const btnIndex = css.indexOf('/* 6. Buttons */');
if (btnIndex !== -1) {
    css = css.substring(0, btnIndex);
}

const newBtns = `/* 6. Buttons */
.tj-primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  font-weight: 600;
  color: #ffffff;
  background-color: var(--color-secondary);
  padding: 5.5px;
  border-radius: 50px;
  position: relative;
  z-index: 1;
  font-family: var(--font-heading);
  text-decoration: none;
  border: none;
}

.tj-primary-btn .btn_inner {
  position: relative;
  z-index: 1;
  padding: 12px 18px 12px 50px;
  width: 100%;
  text-align: center;
}

.tj-primary-btn .btn_inner::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 0;
  left: 0;
  width: 40px;
  height: 100%;
  background-color: var(--color-primary);
  border-radius: 50px;
  transition: all 0.3s ease-in-out 0s;
}

.tj-primary-btn .btn_inner .btn_icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  left: 0;
  top: 0;
  min-width: 40px;
  height: 100%;
  z-index: 2;
  font-size: 20px;
  color: #ffffff;
}

.tj-primary-btn .btn_inner .btn_icon > span {
  overflow: hidden;
  position: relative;
  display: inline-flex;
  width: 20px;
  height: 20px;
  align-items: center;
}

.tj-primary-btn .btn_inner .btn_icon > span i {
  display: inline-block;
  width: 20px;
  height: 20px;
  background-color: currentColor;
  -webkit-mask-image: url('assets/img/btn-arrow.svg');
  mask-image: url('assets/img/btn-arrow.svg');
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  transition: transform 0.4s ease-in-out 0s;
}

.tj-primary-btn .btn_inner .btn_icon > span i:last-child {
  position: absolute;
  transform: translateX(-150%);
}

.tj-primary-btn .btn_inner .btn_text {
  display: inline-flex;
  overflow: hidden;
  color: #ffffff;
  text-shadow: 0 23px 0 currentColor;
}

.tj-primary-btn .btn_inner .btn_text > span {
  display: flex;
  align-items: center;
  backface-visibility: hidden;
  transform: translateY(0);
  transition: 0.5s;
}

/* Light variant (for dark backgrounds) */
.tj-primary-btn.header_btn {
  background-color: var(--color-bg);
  padding: 4.5px;
}

.tj-primary-btn.header_btn .btn_inner .btn_text {
  color: var(--color-secondary);
}

/* Hover Effects */
.tj-primary-btn:hover .btn_inner::before {
  width: 100%;
}

.tj-primary-btn:hover .btn_inner .btn_icon i:first-child {
  transform: translateX(150%);
}

.tj-primary-btn:hover .btn_inner .btn_icon i:last-child {
  transform: translateX(0);
}

.tj-primary-btn:hover .btn_inner .btn_text {
  color: #ffffff;
}

.tj-primary-btn:hover .btn_inner .btn_text > span {
  transform: translateY(-23px);
}
`;

fs.writeFileSync('style.css', css + newBtns);
console.log('Updated style.css');
