/* ===========================
   DuoDuoYu — Design System
   =========================== */

@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;600;700&family=Noto+Sans+SC:wght@400;500;700&family=Noto+Sans+KR:wght@400;500;700&family=Noto+Sans+JP:wght@400;500;700&display=swap');

/* --- CSS Variables --- */
:root {
  /* Colors */
  --color-primary: #FF8C42;
  --color-primary-dark: #e67a30;
  --color-primary-light: #FFB480;
  --color-secondary: #4ECDC4;
  --color-secondary-dark: #3ab5ac;
  --color-accent: #FF6B6B;
  --color-bg: #FFF8F0;
  --color-bg-card: #FFFFFF;
  --color-text: #2D3436;
  --color-text-muted: #636e72;
  --color-border: #F0E8DC;
  --color-success: #55efc4;

  /* Typography */
  --font-display: 'Fredoka One', cursive;
  --font-body-en: 'Nunito', sans-serif;
  --font-body-zh: 'Noto Sans SC', sans-serif;
  --font-body-ko: 'Noto Sans KR', sans-serif;
  --font-body-ja: 'Noto Sans JP', sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 64px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.16);

  /* Transitions */
  --transition: 0.2s ease;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

/* Per-language font application */
:lang(zh) { font-family: var(--font-body-zh), sans-serif; }
:lang(ko) { font-family: var(--font-body-ko), sans-serif; }
:lang(ja) { font-family: var(--font-body-ja), sans-serif; }
:lang(id), :lang(vi), :lang(en) { font-family: var(--font-body-en), sans-serif; }

body {
  font-family: var(--font-body-zh), var(--font-body-en), sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100dvh;
}

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
ul { list-style: none; }

/* --- Typography --- */
h1, h2, h3 { font-family: var(--font-display), var(--font-body-en); line-height: 1.2; }
.zh h1, .zh h2, .zh h3 { font-family: var(--font-body-zh); font-weight: 700; }

/* --- Layout --- */
.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 var(--space-md); }
.section { padding: var(--space-xl) 0; }

/* --- Header --- */
.site-header {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  background: rgba(255,248,240,0.92);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.logo {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.logo span { color: var(--color-secondary); }

.header-actions { display: flex; align-items: center; gap: var(--space-sm); }

.lang-switch {
  display: flex;
  gap: 2px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  padding: 3px;
}
.lang-switch button {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  transition: var(--transition);
}
.lang-switch button.active {
  background: white;
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 1rem;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--color-primary);
  color: white;
}
.btn-primary:hover { background: var(--color-primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary {
  background: var(--color-secondary);
  color: white;
}
.btn-secondary:hover { background: var(--color-secondary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}
.btn-outline:hover { background: var(--color-primary); color: white; }
.btn-sm { padding: 8px 16px; font-size: 0.875rem; }

/* --- Story Card --- */
.story-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.story-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.story-card:active { transform: translateY(-2px); }

.story-card-cover {
  aspect-ratio: 4/3;
  background: linear-gradient(135deg, #FFD3A5, #FFA07A);
  overflow: hidden;
  position: relative;
}
.story-card-cover img { width: 100%; height: 100%; object-fit: cover; }
.story-card-cover .placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.story-card-body { padding: var(--space-md); flex: 1; display: flex; flex-direction: column; gap: var(--space-xs); }
.story-card-title { font-family: var(--font-display); font-size: 1rem; color: var(--color-text); }
.story-card-title-zh { font-family: var(--font-body-zh); font-weight: 700; font-size: 0.9rem; color: var(--color-text-muted); }
.story-card-meta { display: flex; gap: var(--space-sm); margin-top: auto; padding-top: var(--space-sm); }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--color-border);
  color: var(--color-text-muted);
}
.tag-age { background: #FFF0E0; color: var(--color-primary); }
.tag-audio { background: #E0F8F6; color: var(--color-secondary-dark); }

/* --- Story Grid --- */
.story-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}
@media (min-width: 600px) { .story-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .story-grid { grid-template-columns: repeat(4, 1fr); } }

/* --- Footer --- */
.site-footer {
  background: var(--color-text);
  color: #b2bec3;
  padding: var(--space-xl) 0 var(--space-lg);
  margin-top: var(--space-2xl);
}
.footer-inner { display: flex; flex-direction: column; gap: var(--space-md); }
.footer-brand { font-family: var(--font-display); font-size: 1.25rem; color: white; }
.footer-links { display: flex; flex-wrap: wrap; gap: var(--space-md); }
.footer-links a { color: #b2bec3; font-size: 0.875rem; transition: var(--transition); }
.footer-links a:hover { color: white; }
.footer-copy { font-size: 0.8rem; }

/* --- PWA Install Banner --- */
.pwa-banner {
  display: none;
  position: fixed;
  bottom: var(--space-md);
  left: var(--space-md);
  right: var(--space-md);
  background: white;
  border-radius: var(--radius-md);
  padding: var(--space-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  align-items: center;
  gap: var(--space-md);
  animation: slideUp 0.3s ease;
}
.pwa-banner.show { display: flex; }
.pwa-banner-icon { font-size: 2rem; }
.pwa-banner-text { flex: 1; }
.pwa-banner-text strong { display: block; font-size: 0.95rem; }
.pwa-banner-text span { font-size: 0.8rem; color: var(--color-text-muted); }
.pwa-banner-close { color: var(--color-text-muted); font-size: 1.2rem; padding: var(--space-sm); }

/* --- Loading State --- */
.skeleton {
  background: linear-gradient(90deg, #f0e8dc 25%, #ffe9d0 50%, #f0e8dc 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- Utility --- */
.text-center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
