@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');

:root {
  --main-bg-color: #d2b48c;
  --nav-bg-color: #8b4513;
  --accent-color: #45a049;
  --text-color: #ffffff;
  --card-bg-color: #f0fff0;
  --font-size-base: 1rem;

  --body-bg: var(--main-bg-color);
  --body-text: #333;

  --nav-bg: var(--nav-bg-color);
  --nav-hover-bg: var(--accent-color);

  --hero-bg: #b8935f;
  --hero-border: #D2A679;
  --hero-text: #2c1810;
  --hero-strong: #b8860b;

  --img-shadow: rgba(0,0,0,0.2);
}

[data-theme="dark"] {
  --body-bg: #2a1810;
  --body-text: #e0e0e0;

  --nav-bg: #5a2d0f;
  --nav-hover-bg: #3a7a32;

  --hero-bg: #1f1208;
  --hero-border: #8b5a3c;
  --hero-text: #f2f1ed;
  --hero-strong: #FFD700;

  --img-shadow: rgba(0,0,0,0.5);
}

body {
  font-family: 'Roboto', Arial, sans-serif;
  background-color: var(--body-bg);
  color: var(--body-text);
  padding: 2%;
  font-size: var(--font-size-base);
  min-height: 100dvh;
}

nav ul {
  list-style: none;
  display: flex;
  justify-content: center;
  padding: 0;
  margin: 0;
  gap: 1rem;
  flex-wrap: wrap;
}

nav li {
  flex: 0 1 auto;
}

nav a {
  display: block;
  padding: 0.8em 1.5em;
  font-size: 1.2rem;
  background-color: var(--nav-bg);
  color: var(--text-color);
  text-decoration: none;
  border-radius: 0.5em;
  transition: background-color 0.3s, transform 0.3s;
}

nav a:hover {
  background-color: var(--nav-hover-bg);
  transform: scale(1.1);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--nav-bg-color) 50%, var(--accent-color) 50%);
}

nav:has(a:hover) {
  background-color: rgba(139, 69, 19, 0.1);
  border-radius: 1rem;
  padding: 0.5rem;
}

fieldset {
  border: 3px solid var(--nav-bg-color);
  border-radius: 8px;
  padding: 1rem;
  background-color: #fffaf0;
}

[data-theme="dark"] fieldset {
  border-color: #d2a679;
  background-color: #3d2817;
}

legend {
  color: var(--nav-bg-color);
  font-weight: bold;
}

[data-theme="dark"] legend {
  color: #d2a679;
}

hero-card {
  display: block;
  border: 2px solid var(--hero-border);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1rem auto;
  background-color: var(--hero-bg);
  color: var(--hero-text);
  font-family: 'Roboto', sans-serif;
  animation: fadeIn 1.5s ease-in-out;
  box-shadow: 0 4px 12px var(--img-shadow);
  max-width: 800px;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

hero-card:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 8px 24px rgba(210, 166, 121, 0.4);
  border-color: #FFD700;
}

/* Removed section hover effect to prevent layout shift */
/* 
section:has(hero-card:hover) {
  background-color: rgba(210, 180, 140, 0.05);
  border-radius: 1rem;
  padding: 1rem;
  transition: background-color 0.3s ease;
}

[data-theme="dark"] section:has(hero-card:hover) {
  background-color: rgba(42, 24, 16, 0.5);
}
*/

hero-card h2 {
  color: #000000;
  margin-bottom: 0.5rem;
}

[data-theme="dark"] hero-card h2 {
  color: #ffffff;
}

hero-card p {
  line-height: 1.5;
}

hero-card ul, hero-card ol {
  margin-left: 1.2rem;
  margin-bottom: 1rem;
}

hero-card li {
  margin-bottom: 0.5rem;
}

hero-card li strong {
  color: var(--hero-strong);
  background: rgba(255, 215, 0, 0.15);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  font-weight: 700;
  font-family: 'Georgia', serif;
}

[data-theme="dark"] hero-card li strong {
  background: rgba(255, 215, 0, 0.2);
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

hero-card img {
  display: block;
  width: 12.5%;
  height: auto;
  margin: 0 auto 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--img-shadow);
  object-fit: contain;
  transition: transform 0.3s ease;
}

hero-card:hover img {
  transform: scale(1.1);
}

.rta-image {
  display: block;
  width: 100%;
  height: auto;
  max-width: 600px;
  margin: 1rem auto;
  border-radius: 8px;
  box-shadow: 0 4px 10px var(--img-shadow);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== 新增的 Hero Card CustomElement 样式 ===== */

/* Hero Card 内部结构样式 */
hero-card .hero-card-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Picture 标签样式 */
hero-card picture {
  display: block;
  width: 12.5%;
  margin: 0 auto 1rem;
}

hero-card picture img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--img-shadow);
  object-fit: contain;
  transition: transform 0.3s ease;
  margin: 0;
}

hero-card:hover picture img {
  transform: scale(1.1);
}

/* Element 标签样式 */
hero-card .hero-element {
  background: rgba(139, 69, 19, 0.1);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border-left: 4px solid var(--hero-strong);
  margin-bottom: 1rem;
}

[data-theme="dark"] hero-card .hero-element {
  background: rgba(255, 215, 0, 0.1);
}

hero-card .hero-element strong {
  color: var(--hero-strong);
  font-weight: 700;
}

/* Learn More 按钮样式 */
hero-card .hero-links {
  margin-top: 1.5rem;
  text-align: center;
}

hero-card .read-more-btn {
  display: inline-block;
  padding: 0.8rem 1.5rem;
  background: linear-gradient(135deg, var(--nav-bg-color), var(--accent-color));
  color: var(--text-color);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

hero-card .read-more-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(69, 160, 73, 0.4);
  background: linear-gradient(135deg, var(--accent-color), var(--nav-bg-color));
}

[data-theme="dark"] hero-card .read-more-btn {
  background: linear-gradient(135deg, #5a2d0f, #3a7a32);
}

[data-theme="dark"] hero-card .read-more-btn:hover {
  background: linear-gradient(135deg, #3a7a32, #5a2d0f);
  box-shadow: 0 6px 16px rgba(255, 215, 0, 0.3);
}

/* ===== 响应式设计 ===== */

@media (max-width: 600px) {
  nav ul {
    flex-direction: column;
    align-items: center;
  }

  nav a {
    font-size: 1rem;
    padding: 0.7em 1em;
  }

  hero-card {
    margin: 0.5rem;
    padding: 1rem;
  }

  hero-card img,
  .rta-image {
    max-width: 100%;
    max-height: 200px;
  }
  
  hero-card picture {
    width: 25%;
  }
  
  hero-card .read-more-btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
  }
}

@media (min-width: 601px) and (max-width: 1024px) {
  nav ul {
    justify-content: space-around;
  }

  hero-card {
    max-width: 600px;
  }

  hero-card img,
  .rta-image {
    max-height: 250px;
  }
  
  hero-card picture {
    width: 18%;
  }
}

@media (min-width: 1025px) {
  hero-card {
    max-width: 800px;
  }

  hero-card img,
  .rta-image {
    max-height: 350px;
  }
}

/* ===== Theme Toggle Button ===== */

#theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  background-color: var(--button-bg);
  color: var(--button-text);
  border: 1px solid var(--button-border);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  font-size: 1rem;
  z-index: 999;
  box-shadow: var(--button-shadow);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}

#theme-toggle:hover {
  transform: translateY(-2px);
  background-color: var(--button-hover);
}

/* ===== View Transition Animations ===== */

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.4s;
}

::view-transition-old(root) {
  animation-name: fade-out;
}

::view-transition-new(root) {
  animation-name: fade-in;
}

@keyframes fade-out {
  to { opacity: 0; }
}

@keyframes fade-in {
  from { opacity: 0; }
}

/* ===== Data Loading Buttons ===== */

.data-controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin: 2rem 0;
  flex-wrap: wrap;
}

.data-btn {
  padding: 0.8rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--nav-bg-color), var(--accent-color));
  color: var(--text-color);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.data-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(69, 160, 73, 0.5);
  background: linear-gradient(135deg, var(--accent-color), var(--nav-bg-color));
}

.data-btn:active {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .data-btn {
  background: linear-gradient(135deg, #5a2d0f, #3a7a32);
}

[data-theme="dark"] .data-btn:hover {
  background: linear-gradient(135deg, #3a7a32, #5a2d0f);
  box-shadow: 0 6px 16px rgba(255, 215, 0, 0.3);
}

#hero-container,
#hero-container-dark {
  min-height: 100px;
  margin: 1rem 0;
}

.loading-message,
.error-message {
  text-align: center;
  font-size: 1.2rem;
  color: var(--body-text);
  padding: 2rem;
  font-style: italic;
}

.error-message {
  color: #d32f2f;
}

[data-theme="dark"] .error-message {
  color: #ff6b6b;
}