/* ============================================
   YiQiDao — Fox Fairy Worship: Shared Styles
   Deity Detail Pages
   ============================================ */

/* --- Custom Properties --- */
:root {
  --ink-black: #1a1a1a;
  --cinnabar: #c9372c;
  --cinnabar-dark: #a82e25;
  --gold: #d4af37;
  --gold-light: #e8d48b;
  --indigo: #2c3e50;
  --indigo-deep: #1a2a3a;
  --rice-paper: #f5f0e8;
  --rice-paper-dark: #e8e0d0;
  --mist: #d5cec3;
  --font-display: 'Cinzel', 'Georgia', serif;
  --font-body: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  --font-chinese: 'Ma Shan Zheng', 'KaiTi', cursive;
  --max-w: 1200px;
  --content-w: 780px;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --radius: 8px;
  --radius-lg: 16px;
  --transition: 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink-black);
  background: var(--rice-paper);
  line-height: 1.8;
  font-size: 17px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }

/* --- Texture --- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg width='200' height='200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  opacity: 0.4;
}

.container { max-width: var(--max-w); margin: 0 auto; padding: 0 var(--gutter); }

/* --- Navigation --- */
.site-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: rgba(26,26,26,0.92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(212,175,55,0.15);
  transition: var(--transition);
}
.nav-inner {
  max-width: var(--max-w); margin: 0 auto; padding: 0 var(--gutter);
  display: flex; align-items: center; justify-content: space-between; height: 64px;
}
.nav-logo {
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 700;
  color: #fff; letter-spacing: 0.05em; display: flex; align-items: center; gap: 0.5rem;
}
.nav-logo .cn { font-family: var(--font-chinese); font-size: 1.1rem; color: var(--gold); font-weight: 400; }
.nav-links { display: flex; gap: 2rem; list-style: none; }
.nav-links a {
  color: rgba(255,255,255,0.7); font-size: 0.875rem; font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase; transition: color 0.2s;
  position: relative;
}
.nav-links a::after {
  content: ''; position: absolute; bottom: -4px; left: 0; width: 0; height: 2px;
  background: var(--cinnabar); transition: width var(--transition);
}
.nav-links a:hover { color: #fff; }
.nav-links a:hover::after { width: 100%; }
.nav-links a.active { color: var(--gold); }
.nav-links a.active::after { width: 100%; background: var(--gold); }
.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 8px; }
.nav-toggle span { display: block; width: 24px; height: 2px; background: #fff; margin: 5px 0; transition: var(--transition); }

@media (max-width: 768px) {
  .nav-toggle { display: block; }
  .nav-links {
    position: fixed; inset: 0; background: rgba(26,26,26,0.97);
    flex-direction: column; align-items: center; justify-content: center;
    gap: 2.5rem; transform: translateX(100%); transition: transform var(--transition);
  }
  .nav-links.open { transform: translateX(0); }
  .nav-links a { font-size: 1.25rem; }
}

/* --- Breadcrumb --- */
.breadcrumb {
  padding-top: 80px; padding-bottom: 1rem;
  font-size: 0.8rem; color: rgba(26,26,26,0.45); letter-spacing: 0.03em;
}
.breadcrumb a { color: rgba(26,26,26,0.55); transition: color 0.2s; }
.breadcrumb a:hover { color: var(--cinnabar); }
.breadcrumb .sep { margin: 0 0.5rem; opacity: 0.4; }

/* --- Article Header --- */
.article-header {
  padding: 1rem 0 3rem; border-bottom: 1px solid var(--mist);
}
.article-header .eyebrow {
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.25em;
  text-transform: uppercase; color: var(--cinnabar); margin-bottom: 1rem;
  display: flex; align-items: center; gap: 0.75rem;
}
.article-header .eyebrow::before {
  content: ''; width: 30px; height: 2px; background: var(--cinnabar); opacity: 0.5;
}
.article-header h1 {
  font-family: var(--font-display); font-size: clamp(2rem, 4.5vw, 3.2rem);
  font-weight: 700; line-height: 1.15; margin-bottom: 0.5rem;
}
.article-header .cn-title {
  font-family: var(--font-chinese); font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  color: var(--gold); opacity: 0.7; margin-bottom: 1rem;
}
.article-header .subtitle {
  font-size: 1.1rem; color: rgba(26,26,26,0.55); line-height: 1.7;
  max-width: 650px;
}

/* --- Hero Image --- */
.article-hero {
  margin: 2rem 0 3rem; border-radius: var(--radius-lg); overflow: hidden;
  position: relative; aspect-ratio: 21/9; min-height: 280px;
  background: linear-gradient(135deg, var(--ink-black) 0%, var(--indigo-deep) 100%);
  display: flex; align-items: center; justify-content: center;
}
.article-hero .hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(26,26,26,0.6) 0%, transparent 50%);
}
.article-hero .hero-icon {
  font-size: clamp(5rem, 12vw, 10rem); opacity: 0.15; filter: grayscale(0.3);
}
.article-hero .hero-caption {
  position: absolute; bottom: 1.5rem; left: 1.5rem; right: 1.5rem;
  font-size: 0.8rem; color: rgba(255,255,255,0.5); font-style: italic;
}

/* --- Article Layout --- */
.article-layout {
  display: grid; grid-template-columns: 1fr 280px; gap: 3rem;
  padding: 3rem 0 5rem;
}
@media (max-width: 900px) {
  .article-layout { grid-template-columns: 1fr; }
}

/* --- Main Content --- */
.article-main { max-width: var(--content-w); }
.article-main h2 {
  font-family: var(--font-display); font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700; margin: 3rem 0 1.25rem; padding-top: 1rem;
  border-top: 1px solid var(--mist); color: var(--ink-black);
}
.article-main h2:first-of-type { border-top: none; margin-top: 0; }
.article-main h3 {
  font-family: var(--font-display); font-size: 1.2rem; font-weight: 600;
  margin: 2rem 0 0.75rem; color: var(--ink-black);
}
.article-main p { margin-bottom: 1.25rem; color: rgba(26,26,26,0.75); }
.article-main blockquote {
  border-left: 3px solid var(--gold); padding: 1rem 1.5rem; margin: 2rem 0;
  background: rgba(212,175,55,0.04); border-radius: 0 var(--radius) var(--radius) 0;
}
.article-main blockquote p {
  font-style: italic; color: rgba(26,26,26,0.6); margin-bottom: 0.5rem;
}
.article-main blockquote cite {
  font-size: 0.85rem; color: var(--cinnabar); font-style: normal; font-weight: 600;
}
.article-main ul, .article-main ol { margin: 1rem 0 1.5rem 1.5rem; color: rgba(26,26,26,0.7); }
.article-main li { margin-bottom: 0.5rem; }
.article-main .cn-inline {
  font-family: var(--font-chinese); color: var(--cinnabar); opacity: 0.8;
}
.article-main .pinyin {
  font-style: italic; color: rgba(26,26,26,0.45); font-size: 0.9em;
}
.article-main .internal-link {
  color: var(--cinnabar); font-weight: 500; border-bottom: 1px solid rgba(201,55,44,0.2);
  transition: border-color 0.2s;
}
.article-main .internal-link:hover { border-bottom-color: var(--cinnabar); }

/* --- Quick Facts Sidebar --- */
.sidebar { position: sticky; top: 80px; align-self: start; }
@media (max-width: 900px) { .sidebar { position: static; } }

.quick-facts {
  background: #fff; border: 1px solid var(--mist); border-radius: var(--radius-lg);
  padding: 1.75rem; margin-bottom: 2rem;
}
.quick-facts h4 {
  font-family: var(--font-display); font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--cinnabar);
  margin-bottom: 1.25rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--mist);
}
.quick-facts .fact-row {
  display: flex; flex-direction: column; gap: 0.15rem;
  padding: 0.6rem 0; border-bottom: 1px solid rgba(213,206,195,0.4);
}
.quick-facts .fact-row:last-child { border-bottom: none; }
.quick-facts .fact-label {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: rgba(26,26,26,0.4);
}
.quick-facts .fact-value { font-size: 0.9rem; color: var(--ink-black); font-weight: 500; }
.quick-facts .fact-value .cn { font-family: var(--font-chinese); color: var(--gold); opacity: 0.8; }

/* --- Related Deities Sidebar --- */
.related-box {
  background: var(--ink-black); border-radius: var(--radius-lg); padding: 1.75rem;
}
.related-box h4 {
  font-family: var(--font-display); font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold);
  margin-bottom: 1.25rem; padding-bottom: 0.75rem; border-bottom: 1px solid rgba(212,175,55,0.15);
}
.related-box a {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.06); transition: var(--transition);
}
.related-box a:last-child { border-bottom: none; }
.related-box a:hover { padding-left: 0.5rem; }
.related-box .rel-icon { font-size: 1.5rem; flex-shrink: 0; }
.related-box .rel-info { flex: 1; }
.related-box .rel-name { font-size: 0.9rem; font-weight: 600; color: #fff; }
.related-box .rel-cn { font-family: var(--font-chinese); font-size: 0.8rem; color: var(--gold); opacity: 0.6; }
.related-box .rel-arrow { color: var(--cinnabar); font-size: 0.8rem; opacity: 0; transition: opacity 0.2s; }
.related-box a:hover .rel-arrow { opacity: 1; }

/* --- Citations --- */
.citations {
  margin-top: 3rem; padding-top: 2rem; border-top: 2px solid var(--mist);
}
.citations h3 {
  font-family: var(--font-display); font-size: 1.1rem; font-weight: 600;
  margin-bottom: 1rem;
}
.citations ol { margin-left: 1.25rem; font-size: 0.85rem; color: rgba(26,26,26,0.55); }
.citations li { margin-bottom: 0.5rem; line-height: 1.6; }
.citations .cite-title { font-style: italic; }
.citations .cite-link { color: var(--cinnabar); border-bottom: 1px solid rgba(201,55,44,0.2); }

/* --- Page FAQ --- */
.page-faq {
  margin-top: 3rem; padding: 2rem; background: #fff;
  border: 1px solid var(--mist); border-radius: var(--radius-lg);
}
.page-faq h3 {
  font-family: var(--font-display); font-size: 1.1rem; font-weight: 600;
  margin-bottom: 1.5rem;
}
.faq-item { border-bottom: 1px solid rgba(213,206,195,0.5); }
.faq-item:last-child { border-bottom: none; }
.faq-q {
  width: 100%; background: none; border: none; padding: 1rem 0;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  cursor: pointer; text-align: left; font-family: var(--font-body);
  font-size: 0.95rem; font-weight: 600; color: var(--ink-black);
}
.faq-q .icon {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--rice-paper); display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.faq-q .icon svg { width: 10px; height: 10px; stroke: var(--cinnabar); transition: transform 0.3s; }
.faq-item.open .faq-q .icon { background: var(--cinnabar); }
.faq-item.open .faq-q .icon svg { stroke: #fff; transform: rotate(180deg); }
.faq-a { max-height: 0; overflow: hidden; transition: max-height 0.4s ease; }
.faq-item.open .faq-a { max-height: 250px; }
.faq-a-inner { padding: 0 0 1rem; font-size: 0.9rem; color: rgba(26,26,26,0.6); line-height: 1.8; }

/* --- Cloud Divider --- */
.cloud-divider {
  width: 100%; height: 40px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 40'%3E%3Cpath d='M0 20 Q150 0 300 20 Q450 40 600 20 Q750 0 900 20 Q1050 40 1200 20' fill='none' stroke='%23d4af37' stroke-width='0.5' opacity='0.3'/%3E%3C/svg%3E") repeat-x center;
  opacity: 0.6;
}

/* --- CTA Section --- */
.cta-section {
  background: linear-gradient(135deg, var(--ink-black) 0%, var(--indigo-deep) 100%);
  text-align: center; padding: 5rem 0; position: relative; overflow: hidden;
}
.cta-section::before {
  content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
  background: radial-gradient(ellipse 30% 30% at 50% 50%, rgba(201,55,44,0.08) 0%, transparent 70%);
}
.cta-content { position: relative; z-index: 1; max-width: 600px; margin: 0 auto; }
.cta-content h2 {
  font-family: var(--font-display); font-size: clamp(1.8rem, 3.5vw, 2.5rem);
  color: #fff; margin-bottom: 1rem;
}
.cta-content p { color: rgba(255,255,255,0.5); margin-bottom: 2rem; font-size: 1.05rem; }
.cta-buttons { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.btn-primary {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.875rem 2rem;
  background: var(--cinnabar); color: #fff; font-family: var(--font-display);
  font-size: 0.85rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  border: none; border-radius: var(--radius); cursor: pointer; transition: var(--transition);
}
.btn-primary:hover { background: var(--cinnabar-dark); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(201,55,44,0.25); }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.875rem 2rem;
  background: transparent; color: rgba(255,255,255,0.7); font-family: var(--font-display);
  font-size: 0.85rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  border: 1px solid rgba(212,175,55,0.3); border-radius: var(--radius); cursor: pointer;
  transition: var(--transition);
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }

/* --- Footer --- */
.site-footer {
  background: var(--ink-black); padding: 3rem 0 1.5rem;
  border-top: 1px solid rgba(212,175,55,0.1);
}
.footer-grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 2rem; margin-bottom: 2.5rem;
}
.footer-brand .logo { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; color: #fff; margin-bottom: 0.75rem; }
.footer-brand p { font-size: 0.85rem; color: rgba(255,255,255,0.4); line-height: 1.7; max-width: 280px; }
.footer-col h4 {
  font-family: var(--font-display); font-size: 0.8rem; font-weight: 600;
  letter-spacing: 0.15em; text-transform: uppercase; color: var(--gold); margin-bottom: 1rem;
}
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 0.5rem; }
.footer-col a { font-size: 0.85rem; color: rgba(255,255,255,0.4); transition: color 0.2s; }
.footer-col a:hover { color: #fff; }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.06); padding-top: 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.75rem; color: rgba(255,255,255,0.3);
}
@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-bottom { flex-direction: column; gap: 0.75rem; text-align: center; }
}
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }

/* --- Scroll Reveal --- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.visible { opacity: 1; transform: translateY(0); }

/* --- Print --- */
@media print {
  .site-nav, .cta-section, .site-footer, .related-box, .sidebar { display: none; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .article-layout { grid-template-columns: 1fr; }
}
