@import "github-markdown-css/github-markdown.css";

// ===== 阅读进度条 =====
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
  z-index: 201;
  transition: width 0.15s linear;
  border-radius: 0 4px 4px 0;
}

// ===== 顶部导航栏 =====
.book_header_div {
  width: 100%;
  height: 88px;
}

.book_header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 88px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;

  .book_header_left {
    width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a1a2e;
    cursor: pointer;
  }

  .book_header_middle {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 600;
    color: #1a1a2e;
    letter-spacing: 2px;
  }

  .book_header_right {
    width: 72px;
    height: 72px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4facfe;
    cursor: pointer;
    margin-right: 10px;
    background: #f0f7ff;
    border-radius: 50%;
    transition: all 0.2s ease;

    &:active {
      background: #dceeff;
      transform: scale(0.96);
    }

    &.active {
      background: #4facfe;
      color: #fff;
    }

    .pc-only {
      display: none;
    }
  }
}

// ===== 段落渐入动画 =====
@keyframes chunkAppear {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chunk-enter {
  animation: chunkAppear 0.5s ease-out both;
}

// ===== 骨架屏占位 =====
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.chunk-placeholder {
  background: linear-gradient(90deg, #f6f7f8 25%, #edeef1 37%, #f6f7f8 63%);
  background-size: 400% 100%;
  animation: shimmer 1.8s ease infinite;
  border-radius: 12px;
  margin: 24px 0;
}

// ===== 加载状态 =====
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

// ===== 回到顶部 =====
.back-to-top {
  position: fixed;
  bottom: 120px;
  right: 30px;
  width: 80px;
  height: 80px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  z-index: 50;
  animation: fadeInUp 0.3s ease;
  color: #4facfe;
  transition: transform 0.2s ease, box-shadow 0.2s ease;

  &:active {
    transform: scale(0.9);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  }
}

// ===== 内容区域 =====
.Book {
  padding: 30px;
  max-width: 100%;

  .markdown-loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 500px;
    gap: 28px;

    .loading-spinner {
      width: 56px;
      height: 56px;
      border: 5px solid #f0f0f0;
      border-top-color: #4facfe;
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
    }

    .loading-text {
      color: #8c8c8c;
      font-size: 28px;
      letter-spacing: 2px;
    }
  }

  .markdown-body {
    font-size: 32px !important;
    line-height: 1.85 !important;
    color: #2c3e50 !important;
    word-wrap: break-word;
    overflow-wrap: break-word;

    h1 {
      font-size: 48px !important;
      font-weight: 800;
      color: #1a1a2e;
      margin: 56px 0 20px;
      padding-bottom: 0;
      border-bottom: none;
      line-height: 1.3;

      &::after {
        content: '';
        display: block;
        width: 80px;
        height: 6px;
        background: linear-gradient(90deg, #4facfe, #00f2fe);
        border-radius: 3px;
        margin-top: 16px;
      }
    }

    h2 {
      font-size: 42px !important;
      font-weight: 700;
      color: #2c3e50;
      margin: 44px 0 18px;
      padding-bottom: 12px;
      border-bottom: 1px solid #f0f0f0;
      line-height: 1.3;
    }

    h3 {
      font-size: 36px !important;
      font-weight: 600;
      color: #34495e;
      margin: 36px 0 14px;
    }

    h4, h5, h6 {
      font-size: 32px !important;
      font-weight: 600;
      color: #4a5568;
      margin: 28px 0 12px;
    }

    p {
      font-size: 32px !important;
      margin-bottom: 20px;
      line-height: 1.9;
    }

    blockquote {
      position: relative;
      margin: 28px 0;
      padding: 20px 24px 20px 30px;
      border-left: none;
      background: linear-gradient(135deg, #f8fbff 0%, #f0f7ff 100%);
      border-radius: 0 12px 12px 0;
      color: #4a5568;

      &::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 6px;
        background: linear-gradient(180deg, #4facfe, #00f2fe);
        border-radius: 3px;
      }

      p {
        margin-bottom: 8px;
        &:last-child { margin-bottom: 0; }
      }
    }

    pre {
      position: relative;
      margin: 28px 0;
      padding: 28px 24px 24px;
      background: #1e1e2e;
      border-radius: 12px;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;

      &::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 4px;
        background: linear-gradient(90deg, #4facfe, #00f2fe);
        border-radius: 12px 12px 0 0;
      }

      code {
        font-family: "SF Mono", "Fira Code", Menlo, Monaco, Consolas, monospace;
        font-size: 26px !important;
        line-height: 1.6;
        color: #e2e8f0;
        background: none !important;
        padding: 0;
        border-radius: 0;
        white-space: pre;
        word-break: normal;
        word-wrap: normal;
      }
    }

    code {
      font-family: "SF Mono", "Fira Code", Menlo, Monaco, Consolas, monospace;
      font-size: 28px !important;
      padding: 4px 10px;
      background: #f1f5f9;
      color: #e53e3e;
      border-radius: 6px;
      word-break: break-word;
    }

    li {
      font-size: 32px !important;
    }

    ul, ol {
      margin: 16px 0;
      padding-left: 40px;

      li {
        margin-bottom: 10px;
        line-height: 1.85;
        > p {
          margin-top: 0;
          margin-bottom: 8px;
        }
      }
    }

    ul li { list-style-type: disc; }
    ol li { list-style-type: decimal; }

    table {
      width: 100%;
      margin: 28px 0;
      border-collapse: collapse;
      border-spacing: 0;
      display: block;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      border-radius: 8px;

      th {
        background: linear-gradient(135deg, #f8fafc, #edf2f7);
        font-weight: 600;
        padding: 16px 20px;
        text-align: left;
        border: 1px solid #e2e8f0;
        white-space: nowrap;
        font-size: 28px !important;
      }

      td {
        padding: 14px 20px;
        border: 1px solid #e2e8f0;
        font-size: 28px !important;
      }

      tr:nth-child(even) { background: #f8fafc; }
      tr { transition: background 0.15s ease; }
    }

    hr {
      margin: 48px 0;
      border: none;
      height: 2px;
      background: linear-gradient(90deg, transparent, #e2e8f0, transparent);
    }

    img {
      display: block;
      margin: 28px auto;
      max-width: 100%;
      height: auto;
      border-radius: 8px;
      opacity: 0;
      transform: translateY(10px);
      transition: opacity 0.6s ease, transform 0.6s ease, box-shadow 0.3s ease;

      &.loaded {
        opacity: 1;
        transform: translateY(0);
      }
    }

    a {
      color: #4facfe;
      text-decoration: none;
      font-size: inherit !important;
      border-bottom: 1px solid transparent;
      transition: border-color 0.2s, color 0.2s;

      &:hover {
        color: #2b8de3;
        border-bottom-color: #4facfe;
      }
    }

    strong {
      font-weight: 700;
      color: #1a1a2e;
      font-size: inherit !important;
    }

    em {
      font-style: italic;
      color: #4a5568;
    }

    details {
      margin: 16px 0;
      padding: 16px;
      background: #f8fafc;
      border-radius: 8px;
      border: 1px solid #e2e8f0;
      transition: background 0.2s;

      &[open] {
        background: #fff;
      }

      summary {
        cursor: pointer;
        font-weight: 600;
        color: #2c3e50;
      }
    }
  }

  // 二维码区域
  .qrcode-section {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    margin: 40px 0;
  }

  // 抽屉目录
  .book_AtDrawer {
    .at-drawer__content {
      background: #fff;
      padding-top: 88px;
      box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);

      .at-list {
        .at-list__item {
          font-size: 30px;
          padding: 20px 24px;
          border-bottom: 1px solid #f5f5f5;
          color: #2c3e50;
          transition: background 0.15s;

          &:active {
            background: #f0f7ff;
          }

          .at-list__item-container {
            .at-list__item-content__info-title {
              font-size: 30px;
              line-height: 1.5;
              color: #2c3e50;
            }
          }
        }
      }
    }

    .at-drawer__mask {
      background: rgba(0, 0, 0, 0.35);
      backdrop-filter: blur(2px);
    }
  }

  // 支付按钮
  .joinSalon {
    margin-top: 40px;
    margin-bottom: 40px;
    border-radius: 12px;
    font-size: 30px;
    font-weight: 600;
  }
}

/* stylelint-disable */
// ===== Tablet/Desktop: 768px+ =====
@media (min-width: 768PX) {
  .reading-progress {
    height: 3PX;
  }

  .back-to-top {
    width: 44PX;
    height: 44PX;
    bottom: 40PX;
    right: 40PX;
    box-shadow: 0 2PX 12PX rgba(0, 0, 0, 0.1);

    &:hover {
      transform: translateY(-2PX);
      box-shadow: 0 4PX 16PX rgba(0, 0, 0, 0.15);
    }
  }

  .book_header {
    height: 56PX;

    .book_header_middle {
      font-size: 18PX;
    }

    .book_header_right {
      width: auto;
      height: 34PX;
      padding: 0 14PX;
      margin-right: 16PX;
      gap: 5PX;
      border-radius: 17PX;
      font-size: 13PX;

      &:hover {
        background: #dceeff;
      }

      .pc-only {
        display: inline;
        font-size: 13PX;
        font-weight: 500;
      }
    }
  }

  .book_header_div {
    height: 56PX;
  }

  .Book {
    padding: 30PX 60PX;

    .markdown-loading {
      .loading-spinner {
        width: 36PX;
        height: 36PX;
        border-width: 3PX;
      }
      .loading-text {
        font-size: 15PX;
      }
    }

    .book_AtDrawer .at-drawer__content {
      padding-top: 56PX;
      width: 300PX;

      .at-list .at-list__item {
        font-size: 21PX;
        padding: 14PX 18PX;

        .at-list__item-container .at-list__item-content__info-title {
          font-size: 21PX;
        }

        .at-list__item-extra__icon-arrow {
          font-size: 12PX !important;
        }

        &:hover {
          background: #f0f7ff;
        }
      }
    }

    .markdown-body {
      font-size: 16PX !important;
      line-height: 1.8 !important;
      max-width: 800PX;
      margin: 0 auto;

      h1 {
        font-size: 28PX !important;
        margin: 36PX 0 14PX;

        &::after {
          width: 50PX;
          height: 3PX;
          margin-top: 10PX;
          border-radius: 2PX;
        }
      }

      h2 {
        font-size: 23PX !important;
        margin: 28PX 0 12PX;
        padding-bottom: 8PX;
      }

      h3 {
        font-size: 19PX !important;
        margin: 22PX 0 10PX;
      }

      h4, h5, h6 {
        font-size: 16PX !important;
      }

      p {
        font-size: 16PX !important;
        margin-bottom: 14PX;
      }

      li {
        font-size: 16PX !important;
      }

      pre {
        padding: 22PX 18PX 18PX;
        border-radius: 8PX;
        margin: 20PX 0;

        &::before {
          height: 3PX;
          border-radius: 8PX 8PX 0 0;
        }

        code {
          font-size: 14PX !important;
        }
      }

      code {
        font-size: 14PX !important;
        padding: 2PX 6PX;
        border-radius: 4PX;
      }

      table th, table td {
        font-size: 14PX !important;
        padding: 8PX 12PX;
      }

      blockquote {
        padding: 14PX 18PX 14PX 22PX;
        margin: 18PX 0;
        border-radius: 0 8PX 8PX 0;

        &::before {
          width: 4PX;
          border-radius: 2PX;
        }
      }

      ul, ol { padding-left: 24PX; }
      img { border-radius: 8PX; margin: 20PX auto; }
      hr { margin: 28PX 0; }

      a { font-size: inherit !important; }
      strong { font-size: inherit !important; }
    }

    .joinSalon {
      max-width: 360PX;
      margin-left: auto;
      margin-right: auto;
      display: block;
      font-size: 16PX;
      border-radius: 8PX;
    }
  }
}

// ===== Desktop: 1024px+ =====
@media (min-width: 1024PX) {
  .Book {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30PX 80PX;

    .markdown-body {
      width: 720PX;
      font-size: 17PX !important;
      line-height: 1.85 !important;

      h1 { font-size: 30PX !important; }
      h2 { font-size: 25PX !important; }
      h3 { font-size: 20PX !important; }
      p { font-size: 17PX !important; }
      li { font-size: 17PX !important; }

      pre {
        padding: 22PX 22PX 18PX;
        code { font-size: 14PX !important; }
      }

      img {
        border-radius: 10PX;
        max-width: 90%;

        &.loaded:hover {
          box-shadow: 0 8PX 30PX rgba(0, 0, 0, 0.12);
          transform: translateY(-2PX);
        }
      }
    }

    .joinSalon {
      max-width: 280PX;
      font-size: 15PX;
    }
  }
}

// ===== Large Desktop: 1536px+ =====
@media (min-width: 1536PX) {
  .Book {
    .markdown-body {
      width: 780PX;
      font-size: 18PX !important;

      h1 { font-size: 32PX !important; }
      h2 { font-size: 26PX !important; }
      h3 { font-size: 22PX !important; }
      p { font-size: 18PX !important; }
      li { font-size: 18PX !important; }
      pre code { font-size: 15PX !important; }
    }

    .joinSalon {
      display: none;
    }
  }
}
/* stylelint-enable */
