/* HanziGrammar — Authentic VisionOS Glassmorphism & Spatial Light System */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400..800;1,400..800&family=Noto+Sans+SC:wght@400;500;700;900&family=Noto+Sans+Thai:wght@400;500;600;700;800&display=swap');

:root {
  --spring-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --bounce-ease: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Plus Jakarta Sans', 'Noto Sans Thai', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: #e2e8f0;
  background-image: 
    radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.35) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.35) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(244, 114, 182, 0.25) 0px, transparent 60%),
    radial-gradient(at 85% 95%, rgba(59, 130, 246, 0.3) 0px, transparent 50%),
    radial-gradient(at 10% 95%, rgba(16, 185, 129, 0.28) 0px, transparent 50%);
  background-attachment: fixed;
  background-size: cover;
  color: #0f172a;
  min-height: 100vh;
}

/* Authentic VisionOS Colorful Ambient Light Beams */
.ambient-glow-1 {
  position: fixed;
  top: -100px;
  left: 5%;
  width: 650px;
  height: 650px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.5) 0%, rgba(99, 102, 241, 0.35) 45%, transparent 70%);
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
  animation: floatBeam1 12s infinite alternate ease-in-out;
}

.ambient-glow-2 {
  position: fixed;
  bottom: -100px;
  right: 5%;
  width: 750px;
  height: 750px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.45) 0%, rgba(244, 63, 94, 0.3) 45%, transparent 70%);
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
  animation: floatBeam2 16s infinite alternate ease-in-out;
}

.ambient-glow-3 {
  position: fixed;
  top: 40%;
  left: 35%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(20, 184, 166, 0.35) 0%, rgba(59, 130, 246, 0.2) 50%, transparent 70%);
  border-radius: 50%;
  filter: blur(85px);
  pointer-events: none;
  z-index: 0;
  animation: floatBeam3 14s infinite alternate ease-in-out;
}

@keyframes floatBeam1 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, 40px) scale(1.12); }
  100% { transform: translate(-30px, -20px) scale(0.95); }
}

@keyframes floatBeam2 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-50px, -60px) scale(1.1); }
  100% { transform: translate(40px, 30px) scale(0.9); }
}

@keyframes floatBeam3 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, -40px) scale(1.15); }
  100% { transform: translate(-40px, 20px) scale(0.92); }
}

/* VisionOS Ultra-Translucent Frosted Glass Panels */
.glass-island {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(40px) saturate(190%);
  -webkit-backdrop-filter: blur(40px) saturate(190%);
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.12), inset 0 1px 2px rgba(255, 255, 255, 0.95);
}

.glass-card {
  background: rgba(255, 255, 255, 0.52);
  backdrop-filter: blur(40px) saturate(190%);
  -webkit-backdrop-filter: blur(40px) saturate(190%);
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 25px 55px -12px rgba(15, 23, 42, 0.14), inset 0 1px 2px rgba(255, 255, 255, 0.95);
}

.glass-inner {
  background: rgba(255, 255, 255, 0.38);
  backdrop-filter: blur(25px) saturate(160%);
  -webkit-backdrop-filter: blur(25px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.8);
}

.glass-modal {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(50px) saturate(200%);
  -webkit-backdrop-filter: blur(50px) saturate(200%);
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 35px 70px -15px rgba(15, 23, 42, 0.25), inset 0 2px 4px rgba(255, 255, 255, 0.95);
}

/* Ruby Typography & Annotations */
ruby {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: bottom;
}

rt {
  font-size: 0.54em;
  line-height: 1.2;
  text-align: center;
  font-weight: 700;
  user-select: all;
  letter-spacing: -0.01em;
}

/* Token Spring Physics Card (VisionOS Glass Gem) */
.token-card {
  transition: transform 0.3s var(--bounce-ease), box-shadow 0.3s var(--spring-ease), border-color 0.2s ease, background 0.2s ease;
  will-change: transform, box-shadow;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 20px -3px rgba(15, 23, 42, 0.08), inset 0 1px 2px rgba(255, 255, 255, 0.9);
}

.token-card:hover {
  transform: translateY(-6px) scale(1.06);
  z-index: 30;
}

.token-card:active {
  transform: translateY(0px) scale(0.97);
}

/* Syntax Color Roles (Vivid Translucent Glass Colors) */
.role-subject {
  background: rgba(224, 242, 254, 0.65);
  color: #0284c7;
  border: 1.5px solid rgba(56, 189, 248, 0.85);
}
.role-subject:hover {
  background: rgba(186, 230, 253, 0.85);
  border-color: #0284c7;
  box-shadow: 0 16px 35px -4px rgba(2, 132, 199, 0.5), inset 0 1px 2px #fff;
}

.role-predicate {
  background: rgba(209, 250, 229, 0.65);
  color: #059669;
  border: 1.5px solid rgba(52, 211, 153, 0.85);
}
.role-predicate:hover {
  background: rgba(167, 243, 208, 0.85);
  border-color: #059669;
  box-shadow: 0 16px 35px -4px rgba(5, 150, 105, 0.5), inset 0 1px 2px #fff;
}

.role-object {
  background: rgba(254, 243, 199, 0.65);
  color: #d97706;
  border: 1.5px solid rgba(251, 191, 36, 0.85);
}
.role-object:hover {
  background: rgba(253, 230, 138, 0.85);
  border-color: #d97706;
  box-shadow: 0 16px 35px -4px rgba(217, 119, 6, 0.5), inset 0 1px 2px #fff;
}

.role-attributive {
  background: rgba(254, 252, 232, 0.65);
  color: #ca8a04;
  border: 1.5px solid rgba(250, 204, 21, 0.85);
}
.role-attributive:hover {
  background: rgba(254, 240, 138, 0.85);
  border-color: #ca8a04;
  box-shadow: 0 16px 35px -4px rgba(202, 138, 4, 0.5), inset 0 1px 2px #fff;
}

.role-adverbial {
  background: rgba(238, 242, 255, 0.65);
  color: #4f46e5;
  border: 1.5px solid rgba(129, 140, 248, 0.85);
}
.role-adverbial:hover {
  background: rgba(224, 231, 255, 0.85);
  border-color: #4f46e5;
  box-shadow: 0 16px 35px -4px rgba(79, 70, 229, 0.5), inset 0 1px 2px #fff;
}

.role-complement {
  background: rgba(240, 253, 250, 0.65);
  color: #0d9488;
  border: 1.5px solid rgba(45, 212, 191, 0.85);
}
.role-complement:hover {
  background: rgba(204, 251, 241, 0.85);
  border-color: #0d9488;
  box-shadow: 0 16px 35px -4px rgba(13, 148, 136, 0.5), inset 0 1px 2px #fff;
}

.role-grammar-marker {
  background: rgba(250, 245, 255, 0.65);
  color: #9333ea;
  border: 1.5px solid rgba(192, 132, 252, 0.85);
}
.role-grammar-marker:hover {
  background: rgba(243, 232, 255, 0.85);
  border-color: #9333ea;
  box-shadow: 0 16px 35px -4px rgba(147, 51, 234, 0.5), inset 0 1px 2px #fff;
}

.role-time-location {
  background: rgba(255, 241, 242, 0.65);
  color: #e11d48;
  border: 1.5px solid rgba(251, 113, 133, 0.85);
}
.role-time-location:hover {
  background: rgba(255, 228, 230, 0.85);
  border-color: #e11d48;
  box-shadow: 0 16px 35px -4px rgba(225, 29, 72, 0.5), inset 0 1px 2px #fff;
}

/* Hanzi Single Character Hover Ripple */
.hanzi-char {
  cursor: pointer;
  transition: transform 0.25s var(--bounce-ease), color 0.15s ease;
  display: inline-block;
}
.hanzi-char:hover {
  transform: translateY(-3px) scale(1.15);
  color: #2563eb;
}

/* Animations: Staggered Cascade Entrance */
@keyframes springPop {
  0% {
    opacity: 0;
    transform: translateY(22px) scale(0.9);
  }
  70% {
    transform: translateY(-4px) scale(1.03);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.animate-spring-pop {
  animation: springPop 0.5s var(--bounce-ease) forwards;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.animate-fade-scale {
  animation: fadeInScale 0.45s var(--spring-ease) forwards;
}

/* Shimmer Loading Wave */
@keyframes shimmerWave {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton-shimmer {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.2) 25%, rgba(255, 255, 255, 0.65) 50%, rgba(255, 255, 255, 0.2) 75%);
  background-size: 200% 100%;
  animation: shimmerWave 1.5s infinite ease-in-out;
}

/* Interactive Action Buttons */
.btn-primary {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.95), rgba(79, 70, 229, 0.95));
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 25px -4px rgba(37, 99, 235, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.4);
  transition: all 0.25s var(--spring-ease);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #4338ca);
  box-shadow: 0 16px 32px -4px rgba(37, 99, 235, 0.55), inset 0 1px 2px rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}
.btn-primary:active {
  transform: translateY(0px) scale(0.97);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 14px -2px rgba(15, 23, 42, 0.06), inset 0 1px 1px #fff;
  transition: all 0.2s var(--spring-ease);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.8);
  border-color: #ffffff;
  transform: translateY(-1.5px);
  box-shadow: 0 8px 20px -3px rgba(15, 23, 42, 0.1), inset 0 1px 1px #fff;
}
.btn-secondary:active {
  transform: translateY(0) scale(0.98);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.5);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.8);
}
