/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: "Noto Serif SC", "STSong", "Songti SC", Georgia, serif;
  color: #3e2723;
  min-height: 100vh;
  background: #c8b898;
  position: relative;
}

/* 千里江山图风格山水画背景 */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url('https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1920&q=80');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  opacity: 0.12;
  z-index: 0;
  pointer-events: none;
}

/* 叠加一层柔和的渐变，让背景更淡雅 */
body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(210, 190, 160, 0.4) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(190, 170, 140, 0.3) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(200, 180, 150, 0.4) 0%, transparent 50%);
  z-index: 0;
  pointer-events: none;
}



/* ===== Page Layout ===== */
.page-wrapper {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 1rem 2rem;
}

/* ===== Header ===== */
.site-header {
  text-align: center;
  margin-bottom: 2rem;
}

.site-title {
  font-size: 2rem;
  font-weight: 700;
  color: #3e2723;
  letter-spacing: 0.5em;
  margin-bottom: 0.4rem;
  text-shadow: 1px 1px 2px rgba(62, 39, 35, 0.1);
}

.site-subtitle {
  font-size: 0.9rem;
  color: #795548;
  letter-spacing: 0.3em;
  font-weight: 400;
}

/* ===== Poetry Card ===== */
.poetry-card {
  width: 100%;
  max-width: 680px;
  background: #f5e6c8;
  background-image:
    linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 40%),
    linear-gradient(225deg, rgba(0,0,0,0.03) 0%, transparent 40%);
  border: 1px solid #d4c0a0;
  border-radius: 4px;
  padding: 2.5rem 2rem;
  position: relative;
  box-shadow:
    0 2px 8px rgba(62, 39, 35, 0.1),
    0 8px 24px rgba(62, 39, 35, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -1px 0 rgba(0, 0, 0, 0.05);
  transform: rotate(-0.3deg);
  min-height: 300px;
}

/* Subtle texture on card */
.poetry-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(139, 119, 90, 0.02) 3px,
      rgba(139, 119, 90, 0.02) 4px
    );
  border-radius: 4px;
  pointer-events: none;
}

/* Edge stain effect */
.poetry-card::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 4px;
  box-shadow:
    inset 0 0 30px rgba(160, 130, 90, 0.15),
    inset 0 0 60px rgba(160, 130, 90, 0.05);
  pointer-events: none;
}

/* ===== Loading State ===== */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 0;
}

.loading-brush {
  width: 40px;
  height: 40px;
  border: 3px solid #d4c0a0;
  border-top-color: #795548;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1.2rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 1rem;
  color: #8d6e63;
  letter-spacing: 0.2em;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ===== Error State ===== */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 0;
}

.error-text {
  font-size: 1rem;
  color: #8d6e63;
  letter-spacing: 0.15em;
  margin-bottom: 1.5rem;
}

/* ===== Poetry Category Tag ===== */
.poetry-category {
  text-align: center;
  margin-bottom: 1.2rem;
}

.category-tag {
  display: inline-block;
  padding: 0.35rem 1.2rem;
  font-size: 0.8rem;
  letter-spacing: 0.25em;
  color: #8b0000;
  background: linear-gradient(135deg, rgba(245, 230, 200, 0.9) 0%, rgba(232, 216, 184, 0.9) 100%);
  border: 1px solid #c4a882;
  border-radius: 3px;
  position: relative;
  font-weight: 500;
}

.category-tag::before,
.category-tag::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  background: #b08d6e;
  transform: rotate(45deg);
  top: 50%;
  margin-top: -3px;
}

.category-tag::before {
  left: 8px;
}

.category-tag::after {
  right: 8px;
}

/* Category-specific colors */
.category-tag.tang {
  color: #8b0000;
  border-color: #c4a882;
}

.category-tag.song {
  color: #2e5266;
  border-color: #7a9ca8;
}

.category-tag.yuan {
  color: #4a6741;
  border-color: #8fa888;
}

.category-tag.shi {
  color: #6b4c35;
  border-color: #a89080;
}

.category-tag.ci {
  color: #5d4e6d;
  border-color: #9b8da8;
}

.category-tag.qu {
  color: #7d5a4a;
  border-color: #b59888;
}

/* ===== Poetry Meta ===== */
.poetry-meta {
  text-align: center;
  margin-bottom: 1.5rem;
}

.poetry-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: #3e2723;
  letter-spacing: 0.15em;
  margin-bottom: 0.3rem;
}

.poetry-title-pinyin {
  font-size: 0.75rem;
  color: #8d6e63;
  letter-spacing: 0.1em;
  margin-bottom: 0.8rem;
  font-weight: 400;
}

.poetry-title-pinyin ruby {
  ruby-align: center;
}

.poetry-title-pinyin rt {
  font-size: 0.55em;
  color: #a08b6e;
  font-weight: 400;
}

.poetry-author {
  font-size: 0.95rem;
  color: #6d4c41;
  letter-spacing: 0.2em;
  font-weight: 400;
  margin-bottom: 0.2rem;
}

.poetry-author-pinyin {
  font-size: 0.7rem;
  color: #8d6e63;
  letter-spacing: 0.1em;
  font-weight: 400;
}

.poetry-author-pinyin ruby {
  ruby-align: center;
}

.poetry-author-pinyin rt {
  font-size: 0.55em;
  color: #a08b6e;
  font-weight: 400;
}

/* ===== Poetry Lines ===== */
.poetry-lines {
  text-align: center;
  margin-bottom: 1.8rem;
  padding: 0 1rem;
}

.poetry-lines .line {
  font-size: 1.2rem;
  line-height: 2.6;
  color: #3e2723;
  letter-spacing: 0.2em;
  text-shadow: 0 1px 1px rgba(62, 39, 35, 0.05);
}

/* Pinyin ruby annotations */
.poetry-lines ruby {
  ruby-align: center;
}

.poetry-lines rt {
  font-size: 0.45em;
  color: #8d6e63;
  font-weight: 400;
  letter-spacing: 0;
  font-family: "Noto Serif SC", serif;
}

/* ===== Divider ===== */
.divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.5rem 0 1.8rem;
  position: relative;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, #c4a882, transparent);
}

.divider-diamond {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #b08d6e;
  transform: rotate(45deg);
  margin: 0 1rem;
  opacity: 0.6;
}

/* ===== Interpretation ===== */
.interpretation-section {
  margin-bottom: 2rem;
}

.interpretation-label {
  font-size: 1rem;
  font-weight: 600;
  color: #5d4037;
  letter-spacing: 0.4em;
  margin-bottom: 0.8rem;
  text-align: center;
}

.interpretation-text {
  font-size: 0.95rem;
  line-height: 1.9;
  color: #4e342e;
  text-indent: 2em;
  text-align: justify;
  letter-spacing: 0.05em;
}

/* ===== Author Introduction ===== */
.author-intro-section {
  margin-bottom: 2rem;
}

.author-intro-label {
  font-size: 1rem;
  font-weight: 600;
  color: #5d4037;
  letter-spacing: 0.4em;
  margin-bottom: 0.8rem;
  text-align: center;
}

.author-intro-text {
  font-size: 0.9rem;
  line-height: 1.9;
  color: #5d4037;
  text-indent: 2em;
  text-align: justify;
  letter-spacing: 0.05em;
}

/* ===== Button ===== */
.action-area {
  text-align: center;
  padding: 1rem 0;
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.refresh-btn {
  display: inline-block;
  padding: 0.6rem 2rem;
  font-family: "Noto Serif SC", serif;
  font-size: 0.95rem;
  color: #8b0000;
  background: transparent;
  border: 1.5px solid #8b0000;
  border-radius: 3px;
  letter-spacing: 0.3em;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.refresh-btn:hover {
  background: #8b0000;
  color: #f5e6c8;
  box-shadow: 0 2px 8px rgba(139, 0, 0, 0.2);
}

.refresh-btn:active {
  transform: scale(0.97);
}

.refresh-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: #a08b6e;
  color: #a08b6e;
}

.refresh-btn:disabled:hover {
  background: transparent;
  color: #a08b6e;
  box-shadow: none;
}

.refresh-btn.copied {
  background: #4a6741;
  border-color: #4a6741;
  color: #f5e6c8;
}

/* Like Button */
.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.5rem;
  letter-spacing: 0.1em;
}

.like-btn .like-icon {
  font-size: 1.1rem;
  transition: transform 0.2s ease;
}

.like-btn:hover .like-icon {
  transform: scale(1.2);
}

.like-btn.liked {
  background: #8b0000;
  color: #f5e6c8;
}

.like-btn.liked .like-icon {
  animation: heartBeat 0.5s ease;
}

@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.3); }
  50% { transform: scale(1); }
  75% { transform: scale(1.3); }
}

.like-count {
  font-size: 0.85rem;
  min-width: 1.5rem;
  text-align: center;
}

/* ===== Disclaimer Section ===== */
.disclaimer-section {
  margin-top: 2rem;
  padding: 0 1rem;
  max-width: 680px;
  width: 100%;
}

.disclaimer-content {
  background: rgba(245, 230, 200, 0.6);
  border: 1px solid #d4c0a0;
  border-radius: 4px;
  padding: 1.5rem;
  text-align: center;
}

.disclaimer-content h4 {
  font-size: 0.9rem;
  color: #5d4037;
  letter-spacing: 0.3em;
  margin-bottom: 1rem;
  font-weight: 600;
}

.disclaimer-content p {
  font-size: 0.75rem;
  color: #8d6e63;
  line-height: 1.8;
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
}

.disclaimer-content p:last-child {
  margin-bottom: 0;
}

/* ===== Footer ===== */
.site-footer {
  margin-top: 1.5rem;
  text-align: center;
}

.site-footer p {
  font-size: 0.8rem;
  color: #a08b6e;
  letter-spacing: 0.2em;
}

.site-footer .footer-links {
  margin-top: 0.5rem;
  font-size: 0.75rem;
}

.site-footer .footer-links a {
  color: #8d6e63;
  text-decoration: none;
  margin: 0 0.3rem;
}

.site-footer .footer-links a:hover {
  color: #5d4037;
  text-decoration: underline;
}

.site-footer .footer-links .separator {
  color: #c4a882;
  margin: 0 0.2rem;
}

.site-footer .beian {
  margin-top: 0.5rem;
  font-size: 0.75rem;
}

.site-footer .beian a {
  color: #8d6e63;
  text-decoration: none;
}

.site-footer .beian a:hover {
  color: #5d4037;
  text-decoration: underline;
}

/* ===== Utility ===== */
.hidden {
  display: none !important;
}

/* ===== Animations ===== */
.fade-in {
  animation: fadeInUp 0.6s ease-out forwards;
}

.fade-out {
  animation: fadeOut 0.3s ease-out forwards;
}

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

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .page-wrapper {
    padding: 1.5rem 0.8rem 1.5rem;
  }

  .site-title {
    font-size: 1.5rem;
    letter-spacing: 0.4em;
  }

  .site-subtitle {
    font-size: 0.8rem;
  }

  .poetry-card {
    padding: 1.8rem 1.2rem;
    transform: rotate(0deg);
  }

  .image-placeholder {
    height: 200px;
  }

  .poetry-image {
    max-height: 300px;
  }

  .poetry-title {
    font-size: 1.3rem;
  }

  .poetry-lines .line {
    font-size: 1.05rem;
    line-height: 2.4;
  }

  .interpretation-text {
    font-size: 0.88rem;
    line-height: 1.8;
  }

  .refresh-btn {
    padding: 0.55rem 1.6rem;
    font-size: 0.88rem;
  }
}

@media (max-width: 400px) {
  .site-title {
    font-size: 1.3rem;
    letter-spacing: 0.3em;
  }

  .poetry-card {
    padding: 1.5rem 1rem;
  }

  .poetry-title {
    font-size: 1.15rem;
  }

  .poetry-lines .line {
    font-size: 0.95rem;
  }
}
