/* ===== CSS Variables ===== */
:root {
  --paper: #F5F0E6;
  --ink-deep: #1A1A1A;
  --ink-thick: #333333;
  --ink-light: #666666;
  --stone: #2A5F8A;
  --cinnabar: #9E2A2B;
}

/* ===== Base Styles ===== */
body {
  background-color: var(--paper);
  color: var(--ink-thick);
  font-family: 'Noto Serif SC', serif;
  font-weight: 500;
  line-height: 1.7;
  font-size: 17px;
}
.dark body {
  background-color: #121212;
  color: var(--paper);
}

/* ===== Paper Texture — single fixed pseudo-element ===== */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  /* Paper grain texture */
  background-image: url("../images/paper-texture.png");
  background-repeat: repeat;
  background-size: 200px 200px;
  opacity: 0.06;
}
.dark body::before {
  opacity: 0.03;
}

/* ===== Ink-wash ambient — separate fixed layer ===== */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(26,26,26,0.018) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(42,95,138,0.012) 0%, transparent 40%),
    radial-gradient(ellipse at 50% 80%, rgba(26,26,26,0.015) 0%, transparent 45%);
}

/* ===== Loading Screen ===== */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}
#loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.loading-char {
  font-family: 'Ma Shan Zheng', cursive;
  font-size: clamp(3rem, 8vw, 6rem);
  color: var(--ink-deep);
  opacity: 0;
  transform: translateY(10px);
  animation: brushWrite 0.6s ease forwards;
}
.loading-char:nth-child(1) { animation-delay: 0.2s; }
.loading-char:nth-child(2) { animation-delay: 0.7s; }
.loading-char:nth-child(3) { animation-delay: 1.2s; }
@keyframes brushWrite {
  0% { opacity: 0; transform: translateY(10px) scaleY(0.5); }
  40% { opacity: 1; transform: translateY(-2px) scaleY(1.05); }
  100% { opacity: 1; transform: translateY(0) scaleY(1); }
}
.loading-ink-blot {
  position: absolute;
  width: 120%;
  height: 20px;
  bottom: -5px;
  left: -10%;
  background: radial-gradient(ellipse at center, rgba(26,26,26,0.06) 0%, transparent 70%);
  animation: inkBleed 0.4s ease forwards;
  animation-delay: 1.8s;
  opacity: 0;
}
@keyframes inkBleed {
  to { opacity: 1; height: 30px; }
}

/* ===== Navigation ===== */
.nav-link {
  position: relative;
  color: var(--ink-thick);
  font-weight: 600;
  font-size: 1.05rem;
  transition: color 0.4s ease;
  letter-spacing: 0.12em;
}
.nav-link:hover { color: var(--ink-deep); }
.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--stone), transparent);
  transition: width 0.4s ease;
  box-shadow: 0 0 6px rgba(42,95,138,0.3);
}
.nav-link:hover::after { width: 100%; }
.nav-link.active { color: var(--cinnabar); }
.nav-link.active::after { width: 100%; background: linear-gradient(90deg, var(--cinnabar), transparent); }

/* ===== Brush Divider ===== */
.brush-divider {
  position: relative;
  width: 200px;
  height: 3px;
  margin: 1.5rem auto;
  background: linear-gradient(90deg, transparent, var(--ink-deep) 20%, var(--ink-deep) 60%, transparent);
  opacity: 0.35;
}
.brush-divider::after {
  content: '';
  position: absolute;
  right: -5px;
  top: -1px;
  width: 12px;
  height: 5px;
  background: var(--stone);
  border-radius: 50%;
  opacity: 0.5;
  box-shadow: 0 0 8px rgba(42,95,138,0.3);
}

/* ===== Mountain Glow ===== */
.mountain-glow {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(42,95,138,0.08), transparent);
  pointer-events: none;
}

/* ===== Scroll Animations ===== */
.scroll-reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.scroll-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}
.scroll-reveal.ink-in {
  opacity: 0;
  filter: blur(2px);
  transform: translateY(20px);
  transition: opacity 1s ease, filter 1s ease, transform 1s ease;
}
.scroll-reveal.ink-in.revealed {
  opacity: 1;
  filter: blur(0);
  transform: translateY(0);
}

/* ===== Section lazy render ===== */
section {
  content-visibility: auto;
  contain-intrinsic-size: auto 600px;
}

/* ===== Product Cards ===== */
.product-card {
  background: rgba(245,240,230,0.6);
  border: 1px solid rgba(26,26,26,0.1);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  transition: border-color 0.5s ease, transform 0.5s ease, box-shadow 0.5s ease;
  position: relative;
  overflow: hidden;
  contain: layout style;
}
.product-card:hover {
  border-color: rgba(26,26,26,0.2);
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(42,95,138,0.06);
}
.product-card h3 {
  font-size: 1.35rem;
  font-weight: 700;
}
.product-card .slogan {
  font-size: 1rem;
  font-weight: 600;
}
.product-card .desc {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.9;
}
.product-card .seal-stamp {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--cinnabar);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Ma Shan Zheng', cursive;
  font-size: 12px;
  color: var(--cinnabar);
  opacity: 0;
  transform: rotate(-8deg) scale(0.8);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.product-card:hover .seal-stamp {
  opacity: 0.7;
  transform: rotate(-8deg) scale(1);
}

/* ===== Buttons ===== */
.btn-primary {
  background: var(--cinnabar);
  color: white;
  padding: 1rem 3rem;
  border-radius: 6px;
  font-family: 'Noto Serif SC', serif;
  font-weight: 600;
  letter-spacing: 0.15em;
  font-size: 1.05rem;
  transition: box-shadow 0.4s ease;
  position: relative;
  overflow: hidden;
}
.btn-primary:hover { box-shadow: 0 0 20px rgba(158,42,43,0.2); }

.btn-outline {
  background: transparent;
  color: var(--ink-deep);
  padding: 1rem 3rem;
  border: 1.5px solid var(--ink-deep);
  border-radius: 6px;
  font-family: 'Noto Serif SC', serif;
  font-weight: 600;
  letter-spacing: 0.15em;
  font-size: 1.05rem;
  transition: background 0.4s ease, border-color 0.4s ease;
}
.btn-outline:hover {
  background: rgba(26,26,26,0.06);
  border-color: var(--ink-light);
}

/* ===== Scroll Arrow ===== */
.scroll-arrow {
  animation: float 2.5s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(8px); opacity: 0.8; }
}

/* ===== Dark Mode ===== */
.dark .product-card {
  background: rgba(30,30,30,0.6);
  border-color: rgba(245,240,230,0.08);
}
.dark .product-card:hover {
  border-color: rgba(245,240,230,0.2);
  box-shadow: 0 8px 30px rgba(42,95,138,0.1);
}
.dark .btn-outline {
  color: var(--paper);
  border-color: var(--paper);
}
.dark .btn-outline:hover {
  background: rgba(245,240,230,0.06);
}

/* ===== Mobile Menu ===== */
.hamburger-line {
  width: 28px;
  height: 2px;
  background: var(--ink-deep);
  margin: 6px 0;
  transition: all 0.3s ease;
  border-radius: 2px;
}
.dark .hamburger-line { background: var(--paper); }
.hamburger-line:nth-child(1) { width: 24px; }
.hamburger-line:nth-child(2) { width: 28px; }
.hamburger-line:nth-child(3) { width: 20px; }
.mobile-menu-open .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
  width: 28px;
}
.mobile-menu-open .hamburger-line:nth-child(2) { opacity: 0; }
.mobile-menu-open .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
  width: 28px;
}

#mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(245,240,230,0.98);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s ease;
}
#mobile-menu.open { opacity: 1; visibility: visible; }
.dark #mobile-menu { background: rgba(18,18,18,0.98); }

/* ===== Ink Text Effects ===== */
.ink-text-deep {
  color: var(--ink-deep);
  text-shadow: 0 0 1px rgba(26,26,26,0.1);
}
.ink-text-stone {
  color: var(--stone);
  font-weight: 600;
  text-shadow: 0 0 8px rgba(42,95,138,0.1);
}

/* ===== Bamboo Shadow ===== */
.bamboo-shadow {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 120px;
  opacity: 0.06;
  pointer-events: none;
}
.bamboo-shadow.left {
  left: 0;
  background: linear-gradient(90deg, rgba(26,26,26,0.06) 0%, transparent 100%);
}
.bamboo-shadow.right {
  right: 0;
  background: linear-gradient(-90deg, rgba(26,26,26,0.06) 0%, transparent 100%);
}

/* ===== Selection ===== */
::selection {
  background: rgba(42,95,138,0.15);
  color: var(--ink-deep);
}

/* ===== Responsive Typography ===== */
@media (max-width: 767px) {
  body { font-size: 16px; }
  .hero-title { font-size: clamp(2.5rem, 12vw, 4rem) !important; }
  .hero-subtitle { font-size: clamp(0.95rem, 3vw, 1.3rem) !important; }
}

/* ===== Nav Shrink ===== */
nav.shrink {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}
nav.shrink .nav-logo {
  font-size: 1.25rem;
}

/* ===== Section Text ===== */
.philosophy-text {
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 2;
  color: var(--ink-thick);
}
@media (min-width: 768px) {
  .philosophy-text { font-size: 1.2rem; }
}
.dark .philosophy-text { color: rgba(245,240,230,0.85); }

.cta-text {
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 2;
}
@media (min-width: 768px) {
  .cta-text { font-size: 1.2rem; }
}

.footer-text {
  font-weight: 500;
  font-size: 0.95rem;
}

/* ===== Card Textures ===== */
.card-texture-ripple {
  position: absolute;
  inset: 0;
  opacity: 0.04;
  pointer-events: none;
  background: url("../images/texture-ripple.svg") center/contain no-repeat;
}
.card-texture-mountain {
  position: absolute;
  inset: 0;
  opacity: 0.04;
  pointer-events: none;
  background: url("../images/texture-mountain.svg") center/contain no-repeat;
}
.card-texture-wave {
  position: absolute;
  inset: 0;
  opacity: 0.04;
  pointer-events: none;
  background: url("../images/texture-wave.svg") center/contain no-repeat;
}
