/* ============================================
   Chinese New Year 春節 — Advocacy Website
   v2: Elegant Light Theme
   Palette inspired by watercolor florals —
   sage-cream, rose, crimson, warm brown, olive
   ============================================ */

/* --- Variables --- */
:root {
  /* Backgrounds — warm sage-cream paper */
  --bg-page: #E9E5DA;
  --bg-surface: #F0EDE5;
  --bg-card: #F7F5F0;
  --bg-card-hover: #FDFCFA;
  --bg-white: #FFFFFF;

  /* Rose / Crimson range (from flower petals) */
  --rose: #C4626A;
  --rose-soft: #D98A90;
  --rose-pale: #EBBFC2;
  --rose-deep: #A84858;
  --rose-muted: #B07078;
  --rose-bg: rgba(196, 98, 106, 0.06);
  --rose-bg-strong: rgba(196, 98, 106, 0.10);

  /* Brown range (branch, monkey — warm naturals) */
  --brown: #7A5C42;
  --brown-dark: #4A3530;
  --brown-light: #9E8468;
  --brown-pale: #BBA98E;

  /* Sage / Olive green (leaves) */
  --sage: #7E8E62;
  --sage-muted: #96A47A;
  --sage-bg: rgba(126, 142, 98, 0.07);
  --sage-border: rgba(126, 142, 98, 0.18);

  /* Gold-brown warmth */
  --gold: #B89650;
  --gold-light: #D1AF6A;
  --gold-dim: #9A7E3E;

  /* Text */
  --text-primary: #3D302B;
  --text-secondary: #6B5A50;
  --text-muted: #9A8C80;

  /* Archive panel accents */
  --accent-green: #5C7A42;
  --accent-green-bg: rgba(92, 122, 66, 0.05);
  --accent-red: #B04A4A;
  --accent-red-bg: rgba(176, 74, 74, 0.04);

  /* Borders & Shadows */
  --border: rgba(74, 53, 48, 0.08);
  --border-hover: rgba(196, 98, 106, 0.20);
  --shadow-sm: 0 1px 3px rgba(74, 53, 48, 0.05), 0 1px 2px rgba(74, 53, 48, 0.03);
  --shadow-md: 0 4px 20px rgba(74, 53, 48, 0.06), 0 2px 8px rgba(74, 53, 48, 0.04);
  --shadow-lg: 0 12px 40px rgba(74, 53, 48, 0.08), 0 4px 12px rgba(74, 53, 48, 0.04);

  /* Radii */
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Transitions */
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Soft warm ambient tints */
  background-image:
    radial-gradient(ellipse at 15% 0%,  rgba(196, 98, 106, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 100%, rgba(126, 142, 98, 0.03) 0%, transparent 50%);
  background-attachment: fixed;
}

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: 'DM Serif Display', 'Noto Serif TC', 'Georgia', serif;
  line-height: 1.3;
}

.chinese, [lang="zh"], .article-content h2:lang(zh) {
  font-family: 'Noto Serif TC', 'Georgia', serif;
}

a {
  color: var(--rose);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--rose-deep);
}

/* Animated underline for inline article links */
.article-content a {
  background-image: linear-gradient(var(--rose-soft), var(--rose-soft));
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.3s ease, color var(--transition);
}

.article-content a:hover {
  background-size: 100% 1px;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-page);
}

::-webkit-scrollbar-thumb {
  background: var(--brown-pale);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--rose-soft);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--brown-pale) var(--bg-page);
}

/* ============================================
   Keyframe Animations
   ============================================ */

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

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

/* Gentle color shift for the header accent stripe */
@keyframes accentShift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

/* Separator glow */
@keyframes separatorShimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

/* ============================================
   Header — Watercolor background image
   ============================================ */
.site-header {
  background: var(--bg-surface);
  padding: 3.5rem 2rem 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Watercolor header background */
.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background: url('header-bg.jpg') center center / cover no-repeat;
  pointer-events: none;
}

/* Bottom accent — animated gradient stripe */
.site-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 5;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--rose-pale),
    var(--rose),
    var(--gold-light),
    var(--rose-soft),
    var(--rose-pale)
  );
  background-size: 200% 100%;
  animation: accentShift 8s ease-in-out infinite;
}

/* Frosted text backdrop — feathered edges, see-through */
.header-text {
  position: relative;
  z-index: 2;
  display: inline-block;
  max-width: 720px;
  padding: 2rem 3rem 1.75rem;
}

/* The frosted layer: sits behind text, masked for soft fade-out */
.header-text::before {
  content: '';
  position: absolute;
  /* Extend well beyond text so the fade happens outside the reading area */
  inset: -2.5rem -4rem;
  z-index: -1;
  background: rgba(244, 241, 235, 0.48);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  /* Feathered edge: fully opaque at centre, seamless fade to transparent */
  -webkit-mask-image: radial-gradient(ellipse 52% 58% at 50% 48%, rgba(0,0,0,1) 30%, rgba(0,0,0,0) 100%);
  mask-image: radial-gradient(ellipse 52% 58% at 50% 48%, rgba(0,0,0,1) 30%, rgba(0,0,0,0) 100%);
}

.site-header h1 {
  font-family: 'DM Serif Display', 'Noto Serif TC', 'Georgia', serif;
  font-size: 2.5rem;
  font-weight: 400;
  color: var(--rose-deep);
  margin-bottom: 0.85rem;
  letter-spacing: 0.01em;
  animation: slideUp 0.6s ease-out both;
}

.site-header h1 .chinese {
  font-family: 'Noto Serif TC', serif;
  font-weight: 600;
  margin-left: 0.25em;
  color: var(--rose);
}

.site-header .subtitle {
  font-size: 0.93rem;
  color: var(--text-secondary);
  max-width: 660px;
  margin: 0 auto;
  line-height: 1.75;
  animation: slideUp 0.6s 0.12s ease-out both;
}

.site-header .subtitle strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* ============================================
   Tab Bar — Frosted glass on sage
   ============================================ */
.tab-bar {
  display: flex;
  justify-content: center;
  gap: 0;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.tab-btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  padding: 1rem 2rem;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tab-btn:hover {
  color: var(--text-secondary);
  background: rgba(196, 98, 106, 0.04);
}

.tab-btn.active {
  color: var(--rose-deep);
  border-bottom-color: var(--rose);
}

/* ============================================
   Tab Content
   ============================================ */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.35s ease-out;
}

/* ============================================
   Tab 1: Archive Panels
   ============================================ */
.archive-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  height: calc(100vh - 160px);
  min-height: 500px;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-correct {
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, var(--accent-green-bg), var(--bg-page) 320px);
}

.panel-problematic {
  background: linear-gradient(180deg, var(--accent-red-bg), var(--bg-page) 320px);
}

.panel-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: rgba(240, 237, 229, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.panel-header h2 {
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.panel-correct .panel-header h2 {
  color: var(--accent-green);
}

.panel-problematic .panel-header h2 {
  color: var(--accent-red);
}

.card-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  columns: 1;
  column-gap: 0.75rem;
}

/* Scrollbar: subtle by default, visible on hover */
.card-list::-webkit-scrollbar {
  width: 6px;
}

.card-list::-webkit-scrollbar-track {
  background: transparent;
}

.card-list::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
  transition: background 0.3s ease;
}

.card-list:hover::-webkit-scrollbar-thumb {
  background: var(--brown-pale);
}

.card-list:hover::-webkit-scrollbar-thumb:hover {
  background: var(--rose-soft);
}

/* Firefox */
.card-list {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 0.3s ease;
}

.card-list:hover {
  scrollbar-color: var(--brown-pale) transparent;
}

/* ============================================
   Cards
   ============================================ */
.card {
  display: inline-block;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition-slow);
  text-decoration: none;
  color: var(--text-primary);
  break-inside: avoid;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.card-screenshot {
  position: relative;
  width: 100%;
  background: var(--bg-surface);
  overflow: hidden;
}

.card-screenshot img {
  width: 100%;
  height: auto;
  display: block;
}

.card-screenshot .card-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Noto Serif TC', serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--rose-pale);
  opacity: 0;
  transition: opacity var(--transition);
  user-select: none;
}

.card-screenshot.no-image img {
  display: none;
}

.card-screenshot.no-image {
  aspect-ratio: 3 / 1;
}

.card-screenshot.no-image .card-placeholder {
  opacity: 0.5;
}

.card-info {
  padding: 0.8rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.card-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  transition: color var(--transition);
}

.card:hover .card-name {
  color: var(--rose-deep);
}

.card-note {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 0.1rem;
}

/* ============================================
   Tab 2: Article
   ============================================ */
.article-container {
  max-width: 760px;
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
  position: relative;
}

/* Language Toggle — Pill style */
.lang-toggle {
  float: right;
  position: relative;
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 50px;
  overflow: hidden;
  z-index: 10;
  margin-left: 1rem;
  margin-top: 0.25rem;
  box-shadow: var(--shadow-sm);
  background: var(--bg-surface);
}

.lang-btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.02em;
}

.lang-btn:first-child {
  border-right: 1px solid var(--border);
}

.lang-btn:hover {
  color: var(--text-secondary);
}

.lang-btn.active {
  background: var(--rose);
  color: #FFFFFF;
  border-radius: 50px;
  box-shadow: 0 2px 8px rgba(196, 98, 106, 0.25);
}

/* Article Content */
.article-content {
  animation: fadeIn 0.4s ease-out;
}

/* Section headings — gradient underline accent */
.article-content h2 {
  font-size: 1.55rem;
  margin: 3rem 0 1.2rem;
  padding-bottom: 0.6rem;
  color: var(--brown-dark);
  position: relative;
}

.article-content h2::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 50px;
  height: 3px;
  background: linear-gradient(90deg, var(--rose), var(--rose-pale));
  border-radius: 2px;
  transition: width var(--transition-slow);
}

.article-content h2:hover::after {
  width: 90px;
}

.article-content h2:first-child {
  margin-top: 0;
}

/* Subheading with a subtle left accent */
.article-content h3 {
  font-family: 'DM Serif Display', 'Noto Serif TC', 'Georgia', serif;
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--rose-deep);
  margin: 2.2rem 0 0.75rem;
  position: relative;
  padding-left: 0.85rem;
}

.article-content h3::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.15em;
  bottom: 0.15em;
  width: 3px;
  background: linear-gradient(180deg, var(--rose-soft), var(--gold-light));
  border-radius: 2px;
}

.article-content p {
  margin-bottom: 1.1rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.85;
}

.article-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.article-content em {
  color: var(--rose);
  font-style: italic;
}

.article-content ul, .article-content ol {
  margin: 0.75rem 0 1.25rem 1.5rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.article-content li {
  margin-bottom: 0.5rem;
  line-height: 1.7;
}

.article-content li::marker {
  color: var(--rose-soft);
}

/* Blockquote — rose-to-gold gradient border */
.article-content blockquote {
  border-left: 3px solid transparent;
  border-image: linear-gradient(180deg, var(--rose), var(--gold-light)) 1;
  margin: 1.75rem 0;
  padding: 1.25rem 1.5rem;
  background: var(--rose-bg);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.95rem;
  line-height: 1.8;
}

.article-content blockquote p {
  margin-bottom: 0.4rem;
  color: var(--text-primary);
}

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

.highlight-box {
  background: var(--rose-bg);
  border: 1px solid rgba(196, 98, 106, 0.12);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
}

.highlight-box p {
  margin-bottom: 0.5rem;
}

.highlight-box p:last-child {
  margin-bottom: 0;
}

/* Call to Action */
.call-to-action {
  margin-top: 3rem;
  padding: 2rem;
  background: linear-gradient(135deg,
    var(--rose-bg) 0%,
    rgba(184, 150, 80, 0.04) 50%,
    var(--sage-bg) 100%
  );
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.call-to-action::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--rose-pale) 0%, transparent 60%);
  opacity: 0.2;
  border-radius: var(--radius-xl) 0 0 0;
}

.call-to-action h3 {
  margin-top: 0;
  color: var(--brown-dark);
  position: relative;
}

/* Separator — animated shimmer */
.separator {
  text-align: center;
  margin: 3rem 0;
  font-size: 1.1rem;
  letter-spacing: 0.5em;
  background: linear-gradient(90deg,
    var(--brown-pale),
    var(--rose-soft),
    var(--gold-light),
    var(--rose-soft),
    var(--brown-pale)
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: separatorShimmer 5s linear infinite;
}

/* Article Figures */
.article-figure {
  margin: 1.75rem 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: var(--bg-card);
  transition: box-shadow var(--transition-slow), transform var(--transition-slow);
}

.article-figure:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.article-figure img {
  width: 100%;
  height: auto;
  display: block;
}

.article-figure figcaption {
  padding: 0.65rem 0.85rem;
  font-size: 0.83rem;
  color: var(--text-muted);
  text-align: center;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}

/* Figure Gallery */
.figure-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin: 1.75rem 0;
}

.figure-gallery .article-figure {
  margin: 0;
}

.figure-gallery .article-figure img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

@media (max-width: 560px) {
  .figure-gallery {
    grid-template-columns: 1fr;
  }
}

/* Credits */
.article-credits {
  margin-top: 3rem;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  background: var(--sage-bg);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.article-credits h3 {
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
  color: var(--brown);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
}

/* ============================================
   Footer
   ============================================ */
.site-footer {
  text-align: center;
  padding: 2.5rem 2rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  background: linear-gradient(180deg, var(--bg-page), #DDD9CE);
  position: relative;
}

.site-footer::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--rose-soft), transparent);
}

.site-footer a {
  color: var(--rose);
  font-weight: 500;
}

.site-footer a:hover {
  color: var(--rose-deep);
}

/* ============================================
   Focus States (Accessibility)
   ============================================ */
.tab-btn:focus-visible,
.lang-btn:focus-visible,
.card:focus-visible {
  outline: 2px solid var(--rose);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================
   Selection Color
   ============================================ */
::selection {
  background: rgba(196, 98, 106, 0.16);
  color: var(--text-primary);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  .site-header {
    padding: 2rem 0.75rem 1.75rem;
  }

  .header-text {
    padding: 1.25rem 1.25rem 1rem;
    max-width: 100%;
  }

  .header-text::before {
    inset: -1.5rem -1.5rem;
    background: rgba(244, 241, 235, 0.58);
    -webkit-mask-image: radial-gradient(ellipse 54% 58% at 50% 48%, rgba(0,0,0,1) 35%, rgba(0,0,0,0) 100%);
    mask-image: radial-gradient(ellipse 54% 58% at 50% 48%, rgba(0,0,0,1) 35%, rgba(0,0,0,0) 100%);
  }

  .site-header h1 {
    font-size: 1.7rem;
  }

  .site-header .subtitle {
    font-size: 0.85rem;
  }

  .tab-btn {
    font-size: 0.78rem;
    padding: 0.85rem 1.25rem;
  }

  .archive-panels {
    grid-template-columns: 1fr;
    height: auto;
    min-height: auto;
  }

  .panel-correct {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .card-list {
    max-height: none;
    columns: 1;
  }

  .article-container {
    padding: 2rem 1.25rem 3rem;
  }

  .lang-toggle {
    float: none;
    display: inline-flex;
    margin-bottom: 1rem;
    margin-left: 0;
  }

  .article-content h2 {
    font-size: 1.3rem;
  }

  .article-content h3 {
    padding-left: 0.7rem;
  }

  .call-to-action {
    padding: 1.5rem;
    border-radius: var(--radius-lg);
  }
}

@media (max-width: 480px) {
  .site-header h1 {
    font-size: 1.4rem;
  }
}

/* ============================================
   Reduced Motion (Accessibility)
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
