/* ─── 21 Days Wonder V2 Shared Styles ─── */
/* ─── Editorial Luxury Design System ─── */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,500&family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,400;0,9..144,500;0,9..144,600;0,9..144,700;0,9..144,800;0,9..144,900;1,9..144,400&family=Manrope:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;600;700&family=Noto+Sans+TC:wght@300;400;500;600;700&family=Noto+Serif+SC:wght@400;500;600;700;800;900&family=Noto+Serif+TC:wght@400;500;600;700;800;900&family=Instrument+Serif:ital@0;1&display=swap');

/* ─── CSS Custom Properties ─── */
:root {
  --brand-cream: #FDFCF8;
  --brand-graphite: #2D2D2D;
  --brand-navy: #1B3A4B;
  --brand-glacier: #3A7CA5;
  --brand-maple: #C75C3A;
  --brand-maple-light: #F8E9E9;

  /* Shadows — multi-layer for depth */
  --shadow-sm: 0 2px 8px rgba(27, 58, 75, 0.04), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md: 0 8px 30px rgba(27, 58, 75, 0.06), 0 2px 6px rgba(0,0,0,0.03);
  --shadow-lg: 0 20px 60px rgba(27, 58, 75, 0.08), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-xl: 0 32px 80px rgba(27, 58, 75, 0.12), 0 8px 24px rgba(0,0,0,0.06);
  --shadow-glow: 0 0 40px rgba(58, 124, 165, 0.15);
  --shadow-glow-maple: 0 0 40px rgba(199, 92, 58, 0.15);
  --shadow-card-hover: 0 20px 50px rgba(27, 58, 75, 0.1), 0 4px 12px rgba(0,0,0,0.05);

  /* Animation */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-spring: cubic-bezier(0.22, 1.2, 0.36, 1);
  --duration-fast: 0.2s;
  --duration-normal: 0.4s;
  --duration-slow: 0.7s;
}

/* ─── Base ─── */
html {
  scroll-behavior: smooth;
}

::selection {
  background: linear-gradient(135deg, #3A7CA5, #C75C3A);
  color: white;
}

/* ─── Custom Scrollbar ─── */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--brand-cream);
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--brand-glacier), var(--brand-navy));
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--brand-navy);
}

/* ─── Global Grain Texture Overlay ─── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* ─── Language Switching ─── */
[data-lang] {
  display: none !important;
}
[data-lang].active {
  display: inline !important;
}
/* Block-level overrides */
div[data-lang].active,
p[data-lang].active,
section[data-lang].active,
article[data-lang].active,
h1[data-lang].active,
h2[data-lang].active,
h3[data-lang].active,
h4[data-lang].active,
li[data-lang].active,
label[data-lang].active,
span[data-lang].active.block-lang {
  display: block !important;
}
/* Flex overrides */
a[data-lang].active,
.nav-links a[data-lang].active {
  display: inline-flex !important;
}

/* Language toggle pill buttons */
.lang-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
}
.lang-toggle button {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #6B7280;
  transition: all 0.3s var(--ease-out-expo);
  cursor: pointer;
  border: none;
  background: transparent;
}
.lang-toggle button.active {
  background: white;
  color: var(--brand-navy);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}
.lang-toggle button:hover:not(.active) {
  color: var(--brand-graphite);
  transform: translateY(-1px);
}

/* ─── Font Switching by Language ─── */
body.lang-en {
  font-family: 'Lora', serif;
}
body.lang-cn {
  font-family: 'Manrope', 'Noto Sans SC', sans-serif;
}
body.lang-tw {
  font-family: 'Manrope', 'Noto Sans TC', sans-serif;
}

/* ─── Headings ─── */
h1, h2, h3, .font-display {
  font-family: 'Montserrat', 'Fraunces', 'Noto Serif SC', 'Noto Serif TC', sans-serif;
}
body.lang-en h1,
body.lang-en h2,
body.lang-en h3,
body.lang-en .font-display {
  font-family: 'Montserrat', sans-serif;
}
body.lang-cn h1,
body.lang-cn h2,
body.lang-cn h3,
body.lang-cn .font-display {
  font-family: 'Noto Serif SC', 'Fraunces', serif;
}
body.lang-tw h1,
body.lang-tw h2,
body.lang-tw h3,
body.lang-tw .font-display {
  font-family: 'Noto Serif TC', 'Fraunces', serif;
}

/* ─── Accent Serif for English decorative text ─── */
.font-accent {
  font-family: 'Instrument Serif', 'Fraunces', serif;
  font-style: italic;
}

/* ─── Brand "21" Number ─── */
.brand-number {
  font-family: 'Space Grotesk', 'Manrope', sans-serif;
}

/* ═══════════════════════════════════════════════════ */
/* ─── Advanced Scroll Animations ─── */
/* ═══════════════════════════════════════════════════ */

.reveal {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity var(--duration-slow) var(--ease-out-expo),
              transform var(--duration-slow) var(--ease-out-expo);
}
.reveal.animate-in {
  opacity: 1;
  transform: translateY(0);
}

/* Slide from left */
.reveal-left {
  opacity: 0;
  transform: translateX(-40px);
  transition: opacity var(--duration-slow) var(--ease-out-expo),
              transform var(--duration-slow) var(--ease-out-expo);
}
.reveal-left.animate-in {
  opacity: 1;
  transform: translateX(0);
}

/* Slide from right */
.reveal-right {
  opacity: 0;
  transform: translateX(40px);
  transition: opacity var(--duration-slow) var(--ease-out-expo),
              transform var(--duration-slow) var(--ease-out-expo);
}
.reveal-right.animate-in {
  opacity: 1;
  transform: translateX(0);
}

/* Scale up */
.reveal-scale {
  opacity: 0;
  transform: scale(0.92);
  transition: opacity var(--duration-slow) var(--ease-out-expo),
              transform var(--duration-slow) var(--ease-out-expo);
}
.reveal-scale.animate-in {
  opacity: 1;
  transform: scale(1);
}

/* Clip reveal (for text) */
.reveal-clip {
  clip-path: inset(0 100% 0 0);
  transition: clip-path 0.8s var(--ease-out-expo);
}
.reveal-clip.animate-in {
  clip-path: inset(0 0% 0 0);
}

/* ═══════════════════════════════════════════════════ */
/* ─── Keyframe Animations ─── */
/* ═══════════════════════════════════════════════════ */

@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  33% { transform: translateY(-8px) rotate(0.5deg); }
  66% { transform: translateY(4px) rotate(-0.3deg); }
}

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(58, 124, 165, 0.3); }
  50% { box-shadow: 0 0 20px 4px rgba(58, 124, 165, 0.15); }
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}

@keyframes gradient-flow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes glow-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

@keyframes border-glow {
  0%, 100% { border-color: rgba(58, 124, 165, 0.2); }
  50% { border-color: rgba(58, 124, 165, 0.5); }
}

@keyframes counter-glow {
  0% { text-shadow: none; }
  50% { text-shadow: 0 0 12px rgba(58, 124, 165, 0.3); }
  100% { text-shadow: none; }
}

/* ═══════════════════════════════════════════════════ */
/* ─── Premium Card System ─── */
/* ═══════════════════════════════════════════════════ */

.card-premium {
  background: white;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 20px;
  transition: transform 0.5s var(--ease-out-expo),
              box-shadow 0.5s var(--ease-out-expo),
              border-color 0.4s ease;
  will-change: transform;
}

.card-premium:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(58, 124, 165, 0.15);
}

/* 3D Tilt card effect */
.card-tilt {
  transform-style: preserve-3d;
  perspective: 1000px;
}
.card-tilt:hover {
  transform: perspective(1000px) rotateX(2deg) rotateY(-2deg) translateY(-4px);
  box-shadow: var(--shadow-xl);
}

/* Glow card — subtle border glow on hover */
.card-glow {
  position: relative;
  overflow: hidden;
}
.card-glow::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, transparent 40%, rgba(58, 124, 165, 0.3), transparent 60%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.card-glow:hover::before {
  opacity: 1;
}

/* ═══════════════════════════════════════════════════ */
/* ─── Premium Button Styles ─── */
/* ═══════════════════════════════════════════════════ */

.btn-primary {
  position: relative;
  overflow: hidden;
  transition: all 0.4s var(--ease-out-expo);
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent, rgba(255,255,255,0.1));
  background-size: 200% 200%;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.btn-primary:hover::after {
  opacity: 1;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(58, 124, 165, 0.3);
}

.btn-outline {
  position: relative;
  overflow: hidden;
  transition: all 0.4s var(--ease-out-expo);
}
.btn-outline::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--brand-navy);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.5s var(--ease-out-expo);
  z-index: 0;
  border-radius: inherit;
}
.btn-outline:hover::before {
  transform: scaleX(1);
  transform-origin: left;
}
.btn-outline:hover {
  color: white;
  border-color: var(--brand-navy);
  transform: translateY(-2px);
}
.btn-outline span {
  position: relative;
  z-index: 1;
}

/* CTA glow effect */
.btn-glow {
  position: relative;
}
.btn-glow::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--brand-glacier), var(--brand-maple));
  z-index: -1;
  opacity: 0;
  filter: blur(12px);
  transition: opacity 0.4s ease;
}
.btn-glow:hover::before {
  opacity: 0.6;
}

/* ═══════════════════════════════════════════════════ */
/* ─── Product Color Borders ─── */
/* ═══════════════════════════════════════════════════ */

.product-card-border {
  border-top: 3px solid transparent;
}

/* ─── Responsive ─── */
@media (max-width: 860px) {
  .lang-toggle button {
    padding: 5px 10px;
    font-size: 12px;
  }
}

@media (max-width: 620px) {
  .lang-toggle button {
    padding: 4px 8px;
    font-size: 11px;
  }
}

/* ─── Mobile Menu ─── */
#mobile-menu {
  transition: max-height 0.3s ease;
  overflow: hidden;
}

/* Hamburger animation */
.menu-icon {
  transition: transform 0.3s ease;
}
.menu-icon.open {
  transform: rotate(90deg);
}

/* ─── Image Lightbox ─── */
.img-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s var(--ease-out-expo), visibility 0.35s ease;
  cursor: zoom-out;
}
.img-lightbox.open {
  opacity: 1;
  visibility: visible;
}
.img-lightbox img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 16px;
  transform: scale(0.9);
  transition: transform 0.5s var(--ease-out-expo);
}
.img-lightbox.open img {
  transform: scale(1);
}
.img-lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.15);
  color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}
.img-lightbox-close:hover {
  background: rgba(255,255,255,0.2);
  transform: rotate(90deg);
}
[data-product-img], [data-about-img] {
  cursor: zoom-in;
}

/* ═══════════════════════════════════════════════════ */
/* ─── Decorative Elements ─── */
/* ═══════════════════════════════════════════════════ */

/* Geometric grid background pattern */
.bg-grid {
  background-image:
    linear-gradient(rgba(27, 58, 75, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(27, 58, 75, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
}

/* Dot grid background */
.bg-dots {
  background-image: radial-gradient(circle, rgba(27, 58, 75, 0.06) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* Radial glow for dark sections */
.radial-glow {
  position: relative;
}
.radial-glow::before {
  content: '';
  position: absolute;
  top: -50%;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 100%;
  background: radial-gradient(ellipse, rgba(58, 124, 165, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

/* Decorative quote mark */
.quote-decor::before {
  content: '\201C';
  font-family: 'Fraunces', serif;
  font-size: 4rem;
  line-height: 1;
  color: var(--brand-glacier);
  opacity: 0.2;
  position: absolute;
  top: 12px;
  left: 20px;
}

/* Animated gradient border */
.gradient-border-animated {
  background: linear-gradient(90deg, var(--brand-glacier), var(--brand-maple), var(--brand-glacier));
  background-size: 200% 100%;
  animation: gradient-flow 3s ease infinite;
}

/* Science card left accent */
.science-accent {
  position: relative;
  border-left: 3px solid transparent;
  background-clip: padding-box;
}
.science-accent::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--brand-glacier), var(--brand-navy));
  border-radius: 3px;
}

/* ═══════════════════════════════════════════════════ */
/* ─── Page Load Animation ─── */
/* ═══════════════════════════════════════════════════ */

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--brand-cream);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s var(--ease-out-expo), visibility 0.6s ease;
}
.page-loader.loaded {
  opacity: 0;
  visibility: hidden;
}
.page-loader .loader-number {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 80px;
  font-weight: 700;
  color: var(--brand-navy);
  animation: fade-in-up 0.8s var(--ease-out-expo) both;
}
