/* ===========================
   文章列表區域樣式
   =========================== */

#article-list-section {
  margin-bottom: 50px;
}

#article-list-section h2 {
  font-size: 2rem;
  font-weight: bold;
  color: #333;
  margin-bottom: 16px;
}

/* ===========================
   文章卡片樣式
   =========================== */

.article-card {
  border: 2px solid #ddd;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  background-color: #fff;
  transition: all 0.3s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  min-height: 120px;
}

/* 無障礙：焦點狀態必須清晰可見 */
.article-card:hover,
.article-card:focus-within {
  border-color: #0066cc;
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.2);
  background-color: #f8f9fa;
}

/* 文章標題連結 */
.article-title-link {
  color: #0066cc;
  text-decoration: none;
  font-size: 1.25rem;
  font-weight: bold;
  display: block;
  margin-bottom: 10px;
  transition: color 0.2s ease;
  line-height: 1.4;
}

/* 焦點狀態 */
.article-title-link:focus {
  outline: 3px solid #0066cc;
  outline-offset: 2px;
  text-decoration: underline;
  transform: none;
}

.article-title-link:hover {
  color: #0047ab;
  text-decoration: underline;
  transform: none;
}

/* 文章日期時間 */
.article-datetime {
  color: #666;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  margin-top: auto;
}

.article-datetime i {
  margin-right: 8px;
  color: #0066cc;
}

/* ===========================
   載入和錯誤狀態
   =========================== */

#article-loading {
  padding: 40px 20px;
  text-align: center;
  color: #666;
  font-size: 1.1rem;
}

/* 旋轉載入動畫 */
.article-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid #f0f0f0;
  border-top: 3px solid #0066cc;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 12px;
  vertical-align: middle;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* 錯誤訊息 */
#article-error {
  margin: 20px 0;
  padding: 15px 20px;
  background-color: #fee;
  border: 2px solid #c33;
  border-radius: 8px;
  color: #c33;
  font-size: 1rem;
}

#article-error strong {
  color: #c33;
}

#retry-button {
  margin-top: 10px;
  background-color: #c33;
  border-color: #c33;
  color: white;
  font-weight: bold;
}

#retry-button:hover,
#retry-button:focus {
  background-color: #a22;
  border-color: #a22;
}

/* ===========================
   分頁樣式
   =========================== */

#article-pagination {
  margin-top: 40px;
  margin-bottom: 40px;
}

.pagination {
  margin: 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px;
}

.pagination .page-link {
  color: #0066cc;
  background-color: #fff;
  border: 2px solid #ddd;
  padding: 8px 12px;
  margin: 0;
  border-radius: 4px;
  font-weight: 500;
  transition: all 0.2s ease;
  min-width: 44px;
  text-align: center;
}

/* 鍵盤焦點 */
.pagination .page-link:focus {
  outline: 3px solid #0066cc;
  outline-offset: 2px;
}

.pagination .page-link:hover:not(.disabled) {
  background-color: #f0f5ff;
  border-color: #0066cc;
  color: #0047ab;
}

/* 當前頁面 */
.pagination .page-item.active .page-link {
  background-color: #0066cc;
  border-color: #0066cc;
  color: #fff;
  font-weight: bold;
}

/* 禁用狀態 */
.pagination .page-item.disabled .page-link {
  color: #999;
  border-color: #ddd;
  background-color: #f5f5f5;
  cursor: not-allowed;
}

/* ===========================
   文章詳細內容視圖
   =========================== */

#article-detail-view {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

#back-to-list-btn {
  background-color: #0066cc;
  border-color: #0066cc;
  color: white;
  font-weight: bold;
  padding: 10px 20px;
  border-radius: 6px;
  transition: all 0.2s ease;
  margin-bottom: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#back-to-list-btn:hover,
#back-to-list-btn:focus {
  background-color: #0047ab;
  border-color: #0047ab;
}

#back-to-list-btn:focus {
  outline: 3px solid #0066cc;
  outline-offset: 2px;
}

/* 文章詳細容器 */
#article-detail-container {
  background-color: #fff;
  padding: 30px;
  border-radius: 8px;
  border: 2px solid #ddd;
}

.article-detail-title {
  color: #333;
  font-size: 2rem;
  margin-bottom: 15px;
  font-weight: bold;
  line-height: 1.4;
}

.article-detail-datetime {
  color: #666;
  font-size: 0.95rem;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 2px solid #eee;
  display: flex;
  align-items: center;
  gap: 8px;
}

.article-detail-datetime i {
  color: #0066cc;
}

.article-detail-content {
  line-height: 1.8;
  color: #444;
  font-size: 1rem;
}

/* 內容中的文本元素 */
.article-detail-content h1,
.article-detail-content h2,
.article-detail-content h3,
.article-detail-content h4,
.article-detail-content h5,
.article-detail-content h6 {
  margin-top: 20px;
  margin-bottom: 15px;
  color: #333;
  font-weight: bold;
}

.article-detail-content p {
  margin-bottom: 15px;
}

.article-detail-content ul,
.article-detail-content ol {
  margin-bottom: 15px;
  margin-left: 30px;
}

.article-detail-content li {
  margin-bottom: 8px;
}

/* 內容中的圖片 */
.article-detail-content img {
  max-width: 100%;
  height: auto;
  margin: 20px 0;
  border-radius: 6px;
  border: 1px solid #ddd;
  display: block;
}

.article-detail-content img.editor-image {
  max-width: 100%;
}

/* 內容中的連結 */
.article-detail-content a {
  color: #0066cc;
  text-decoration: underline;
  transition: color 0.2s ease;
}

.article-detail-content a:hover,
.article-detail-content a:focus {
  color: #0047ab;
}

.article-detail-content a:focus {
  outline: 3px solid #0066cc;
  outline-offset: 2px;
}

/* ===========================
   自動連結
   =========================== */

/* 自動生成的連結 - 防止長URL破壞版面 */
.article-detail-content a.auto-link {
  word-break: break-all;
}

/* 響應式設計 - 小螢幕 */
@media (max-width: 576px) {
  .article-detail-content a.auto-link {
    font-size: 0.9rem;
    word-break: break-word;
  }
}

/* ===========================
   無障礙：螢幕閱讀器提示
   =========================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ===========================
   響應式設計
   =========================== */

@media (max-width: 768px) {
  #article-list-section h2 {
    font-size: 1.5rem;
    margin-bottom: 15px;
  }

  .article-card {
    padding: 15px;
    margin-bottom: 15px;
  }

  .article-title-link {
    font-size: 1.1rem;
  }

  .article-detail-title {
    font-size: 1.5rem;
  }

  #article-detail-container {
    padding: 20px;
  }

  .pagination .page-link {
    padding: 6px 10px;
    font-size: 0.9rem;
  }

  #back-to-list-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 576px) {
  #article-list-section h2 {
    font-size: 1.3rem;
  }

  .article-card {
    padding: 12px;
  }

  .article-title-link {
    font-size: 1rem;
  }

  .article-detail-title {
    font-size: 1.25rem;
  }

  #article-detail-container {
    padding: 15px;
  }

  .article-detail-content {
    font-size: 0.95rem;
  }

  .pagination {
    gap: 3px;
  }

  .pagination .page-link {
    padding: 5px 8px;
    font-size: 0.85rem;
    min-width: 36px;
  }
}

/* ===========================
   無障礙：高對比度模式支援
   =========================== */

@media (prefers-contrast: more) {
  .article-card {
    border-width: 3px;
  }

  .article-title-link {
    font-weight: 900;
  }

  .pagination .page-link {
    border-width: 3px;
  }
}

/* ===========================
   無障礙：減少動畫支援
   =========================== */

@media (prefers-reduced-motion: reduce) {
  .article-card,
  .article-title-link,
  .pagination .page-link,
  #back-to-list-btn {
    transition: none;
  }

  .article-spinner {
    animation: none;
    border: 3px solid #0066cc;
  }

  #article-detail-view {
    animation: none;
  }
}
