.article-template > *:first-child:not(.article-template__hero-container) {
  margin-top: 5rem;
}

.article-template__hero-container {
  max-width: 130rem;
  margin: 0 auto;
}

@media screen and (min-width: 1320px) {
  .article-template__hero-container:first-child {
    margin-top: 5rem;
  }
}

.article-template__hero-medium {
  height: 15.6rem;
}

.article-template__hero-large {
  height: 19rem;
}

@media screen and (min-width: 750px) and (max-width: 989px) {
  .article-template__hero-medium {
    height: 34.9rem;
  }

  .article-template__hero-large {
    height: 42.3rem;
  }
}

@media screen and (min-width: 990px) {
  .article-template__hero-medium {
    height: 54.5rem;
  }

  .article-template__hero-large {
    height: 66rem;
  }
}

.article-template header {
  margin-top: 4.4rem;
  margin-bottom: 2rem;
  line-height: 0.8;
}

@media screen and (min-width: 750px) {
  .article-template header {
    margin-top: 5rem;
  }
}

.article-template__title {
  margin: 0;
}

.article-template__title:not(:only-child) {
  margin-bottom: 1rem;
}

.article-template__link {
  font-size: 1.8rem;
  display: flex;
  justify-content: center;
  align-items: center;
  text-decoration: none;
}

.article-template__link .icon-wrap {
  margin-right: 1rem;
  transform: rotate(180deg);
}

.article-template__content {
  margin-top: 3rem;
  margin-bottom: 3rem;
}

.article-template__social-sharing {
  margin-top: 3rem;
}

.article-template__social-sharing + header, .article-template__social-sharing + .article-template__content {
  margin-top: 1.5rem;
}

.article-template__comment-wrapper {
  margin-top: 5rem;
}

@media screen and (min-width: 750px) {
  .article-template__comment-wrapper {
    margin-top: 6rem;
  }
}

.article-template__comment-wrapper h2 {
  margin-top: 0;
}

.article-template__comments {
  margin-bottom: 5rem;
}

@media screen and (min-width: 750px) {
  .article-template__comments {
    margin-bottom: 7rem;
  }
}

.article-template__comments-fields {
  margin-bottom: 4rem;
}

.article-template__comments-comment {
  color: rgba(var(--color-foreground), 0.75);
  background-color: rgb(var(--color-background));
  margin-bottom: 1.5rem;
  padding: 2rem 2rem 1.5rem;
}

@media screen and (min-width: 750px) {
  .article-template__comments-comment {
    padding: 2rem 2.5rem;
  }
}

.article-template__comments-comment p {
  margin: 0 0 1rem;
}

.article-template__comment-fields > * {
  margin-bottom: 3rem;
}

@media screen and (min-width: 750px) {
  .article-template__comment-fields {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-column-gap: 4rem;
  }
}

.article-template__comment-warning {
  margin: 2rem 0 2.5rem;
}

@media screen and (min-width: 990px) {
  .article-template__comments .pagination-wrapper {
    margin: 5rem 0 8rem;
  }
}

/* Button - social share */

.share-button {
  display: block;
  position: relative;
}

.share-button details {
  width: fit-content;
}

.share-button__button {
  font-size: 1.4rem;
  display: flex;
  min-height: 2.4rem;
  align-items: center;
  color: rgba(var(--color-link), var(--alpha-link));
  margin-left: 0;
  padding-left: 0;
}

.share-button__button:hover,
details[open] > .share-button__button {
  color: rgb(var(--color-link));
}

details[open] > .share-button__fallback {
  animation: animateMenuOpen var(--duration-default) ease;
}

.share-button__button:hover {
  text-decoration: underline;
  text-underline-offset: 0.3rem;
}

.share-button__button,
.share-button__fallback button {
  cursor: pointer;
  background-color: transparent;
  border: none;
}

.share-button__button .icon-share {
  margin-right: 1rem;
}

.share-button__fallback {
  background: rgb(var(--color-background));
  display: flex;
  align-items: center;
  position: absolute;
  top: 3rem;
  left: 0.1rem;
  z-index: 6;
  width: 100%;
  min-width: 31rem;
  box-shadow: 0 0 0 0.1rem rgba(var(--color-foreground), 0.55);
  

}

.share-button__fallback button {
  width: 4.4rem;
  height: 4.4rem;
  padding: 0;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.share-button__fallback button:hover {
  color: rgba(var(--color-foreground), 0.75);
}

.share-button__fallback button:hover svg {
  transform: scale(1.07);
}

.share-button__close:not(.hidden) + .share-button__copy {
  display: none;
}

.share-button__close,
.share-button__copy {
  background-color: transparent;
  color: rgb(var(--color-foreground));
}

.share-button__fallback .field__input {
  box-shadow: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.share-button__fallback .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.share-button__message:not(:empty) {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  margin-top: 0;
  padding: 0.8rem 0 0.8rem 1.5rem;
}

.share-button__message:not(:empty):not(.hidden) ~ * {
  display: none;
}

/* arrow animation */

.animate-arrow .icon-wrap .icon-arrow{
  transform: translateX(-0.25rem);
  transition: transform var(--duration-short) ease;
}

.animate-arrow .icon-wrap .icon-arrow:hover{
  transform: translateX(-0.05rem);
}

/* ========================================================
   部落格文章頁面排版優化（解決圖片過大、內文過寬與留白問題）
   ======================================================== */

/* 1. 限制內文閱讀寬度，集中於畫面中央，提升易讀性 */
.article-template,
.article-content,
[itemprop="articleBody"] {
  max-width: 820px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 20px !important;
  padding-right: 20px !important;
}

/* 2. 優化頂部封面大圖：限制最大高度與圓角，避免全螢幕壓迫 */
.article-template__hero-container img,
[itemprop="image"] img {
  max-height: 420px !important;
  width: 100% !important;
  object-fit: cover !important;
  border-radius: 12px !important;
  margin-bottom: 24px !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06) !important;
}

/* 3. 調整文章標題 (H1) 與發布日期距離 */
article header h1,
[itemprop="headline"] {
  max-width: 820px !important;
  margin: 16px auto 12px auto !important;
  line-height: 1.35 !important;
  font-size: 26px !important;
  color: #1a202c !important;
}

article header span,
[itemprop="datePublished"] {
  display: block !important;
  max-width: 820px !important;
  margin: 0 auto 24px auto !important;
  color: #888888 !important;
}

/* 4. 優化內文字距、行高與段落呼吸感 */
[itemprop="articleBody"] p {
  font-size: 16px !important;
  line-height: 1.85 !important;
  margin-bottom: 20px !important;
  color: #334155 !important;
}

[itemprop="articleBody"] h2 {
  font-size: 21px !important;
  margin-top: 48px !important;
  margin-bottom: 18px !important;
  line-height: 1.4 !important;
  font-weight: 700 !important;
  color: #0f172a !important;
}

[itemprop="articleBody"] h3 {
  font-size: 17px !important;
  margin-top: 24px !important;
  margin-bottom: 12px !important;
  color: #1e293b !important;
}

/* ========================================================
   部落格全裝置響應式（RWD）排版優化
   ======================================================== */

/* 1. 全域容器自適應：手機全滿留邊距，大螢幕維持舒適寬度 */
.article-template,
.article-content,
[itemprop="articleBody"],
article header,
[itemprop="headline"] {
  width: 100% !important;
  max-width: 880px !important; /* 電腦版最大寬度，兼顧大器與閱讀舒適感 */
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: clamp(16px, 4vw, 32px) !important; /* 隨螢幕寬度彈性增減左右留白 */
  padding-right: clamp(16px, 4vw, 32px) !important;
  box-sizing: border-box !important;
}

/* 2. 封面大圖：依螢幕寬度比例彈性縮放，且「完整顯示不裁切」 */
.article-template__hero-container,
[itemprop="image"] {
  max-width: 880px !important;
  margin: 0 auto 24px auto !important;
  padding: 0 clamp(16px, 4vw, 32px) !important;
  box-sizing: border-box !important;
}

.article-template__hero-container img,
[itemprop="image"] img {
  width: 100% !important;
  height: auto !important; /* 依原本比例縮放，絕不裁切畫面 */
  max-height: 520px !important; /* 防止在 4K 超大螢幕上爆版 */
  object-fit: contain !important; /* 確保整張圖完整可見 */
  border-radius: 12px !important;
  display: block !important;
  margin: 0 auto !important;
}

/* 3. 標題字級隨螢幕自適應（手機小一點、電腦大一點） */
article header h1,
[itemprop="headline"] {
  font-size: clamp(20px, 3.5vw, 28px) !important;
  line-height: 1.4 !important;
  margin-top: 16px !important;
  margin-bottom: 12px !important;
  color: #1a202c !important;
  font-weight: 700 !important;
}

/* 4. 內文字級與行高自適應 */
[itemprop="articleBody"] p {
  font-size: clamp(15px, 1.8vw, 16.5px) !important;
  line-height: 1.85 !important;
  margin-bottom: 20px !important;
  color: #334155 !important;
}

[itemprop="articleBody"] h2 {
  font-size: clamp(18px, 2.5vw, 22px) !important;
  margin-top: 40px !important;
  margin-bottom: 16px !important;
  line-height: 1.4 !important;
  font-weight: 700 !important;
  color: #0f172a !important;
}

[itemprop="articleBody"] h3 {
  font-size: clamp(16px, 2vw, 18px) !important;
  margin-top: 24px !important;
  margin-bottom: 12px !important;
  color: #1e293b !important;
}

/* 5. 內文圖片與表格保護（防止手機破版） */
[itemprop="articleBody"] img {
  max-width: 100% !important;
  height: auto !important;
  border-radius: 8px !important;
  display: block !important;
  margin: 20px auto !important;
}

[itemprop="articleBody"] table {
  width: 100% !important;
  max-width: 100% !important;
}