/**
 * ============================================================================
 * Project Noyan - Pixar Design System & Visual Softness Kit (v1.0.0)
 * ============================================================================
 * Organization: Vida Pendar Pars
 * Theoretical Basis: Cognitive Neuroscience, Ergonomics & Pixar Visual Aesthetics
 * Target Audience: Early Childhood & Elementary (Grades 1-4)
 * Architecture: Pure CSS3, GPU-Accelerated, RTL-First, Zero External Bloat
 * ============================================================================
 */

/* ----------------------------------------------------------------------------
 * 1. DESIGN TOKENS & SYSTEM VARIABLES (متغیرهای سراسری سیستم طراحی)
 * ------------------------------------------------------------------------- */
:root {
  /* --- A. Organic Backgrounds (پالت پس‌زمینه ارگانیک و لطیف) --- */
  --noyan-bg-base: #FAF7F0;        /* کرم استخوانی بسیار لطیف و گرم (جایگزین سفید مطلق) */
  --noyan-bg-subtle: #F3ECE1;      /* پس‌زمینه لایه‌های دوم و فیلدهای ورودی */
  --noyan-bg-card: rgba(255, 255, 255, 0.88); /* شیشه شیری نرم با بلور */
  --noyan-bg-card-solid: #FFFFFF;
  --noyan-bg-overlay: rgba(45, 36, 30, 0.45);

  /* --- B. Text & Neutral Colors (کنتراست نرم، بدون رنگ مشکی خالص خشن) --- */
  --noyan-text-title: #2B2118;     /* قهوه‌ای شکلاتی پررنگ و عمیق برای تیترها */
  --noyan-text-body: #4A3B32;      /* رنگ ارگانیک متن‌ها با بیشترین آرامش بصری */
  --noyan-text-muted: #826F63;     /* رنگ راهنما و برچسب‌های فرعی */
  --noyan-text-on-accent: #FFFFFF;

  /* --- C. Pixar Thematic Accents (پالت رنگی گرم و اسباب‌بازی‌مانند نویان) --- */
  /* ۱. تم پوپی (نارنجی هلویی پرانرژی و مهربان) */
  --noyan-peach-main: #FF8A50;
  --noyan-peach-shadow: #D96024;
  --noyan-peach-light: #FFEADF;
  --noyan-peach-gradient: linear-gradient(180deg, #FFA070 0%, #FF8A50 100%);

  /* ۲. تم پیروزی و پیشرفت (سبز نعنایی-پسته‌ای آرامش‌بخش) */
  --noyan-mint-main: #2EC4B6;
  --noyan-mint-shadow: #199489;
  --noyan-mint-light: #E0F8F5;
  --noyan-mint-gradient: linear-gradient(180deg, #44D7C9 0%, #2EC4B6 100%);

  /* ۳. تم دانایی و جادو (بنفش یاسی پیکساری) */
  --noyan-lilac-main: #845EC2;
  --noyan-lilac-shadow: #5C3A96;
  --noyan-lilac-light: #F2ECFA;
  --noyan-lilac-gradient: linear-gradient(180deg, #9C79D8 0%, #845EC2 100%);

  /* ۴. تم پاداش و بلوط‌ها (خردلی-عسلی درخشان و طلایی) */
  --noyan-gold-main: #FFB830;
  --noyan-gold-shadow: #C68612;
  --noyan-gold-light: #FFF5DD;
  --noyan-gold-gradient: linear-gradient(180deg, #FFC85C 0%, #FFB830 100%);

  /* ۵. تم شادی و محبت (مرجانی-توت‌فرنگی) */
  --noyan-coral-main: #FF6B8B;
  --noyan-coral-shadow: #D44163;
  --noyan-coral-light: #FFEBF0;
  --noyan-coral-gradient: linear-gradient(180deg, #FF85A0 0%, #FF6B8B 100%);

  /* ۶. تم آسمان و کاوش (آبی ابری نویان) */
  --noyan-sky-main: #4D96FF;
  --noyan-sky-shadow: #216FE0;
  --noyan-sky-light: #EBF4FF;
  --noyan-sky-gradient: linear-gradient(180deg, #6FAAFF 0%, #4D96FF 100%);

  /* --- D. Soft Tactile Toy Shadows (سایه‌های مخملی و فیزیک سه‌بعدی) --- */
  --shadow-card: 0 16px 32px -8px rgba(74, 52, 36, 0.08), 0 4px 12px rgba(74, 52, 36, 0.04);
  --shadow-floating: 0 24px 48px -10px rgba(74, 52, 36, 0.16);
  --shadow-soft-inset: inset 0 2px 4px rgba(255, 255, 255, 0.6), inset 0 -2px 4px rgba(0, 0, 0, 0.08);

  /* سایه‌های کلیدهای اسباب‌بازی (برآمدگی فیزیکی ۴ تا ۶ پیکسل) */
  --shadow-btn-peach: 0 6px 0 var(--noyan-peach-shadow), 0 12px 20px rgba(217, 96, 36, 0.28);
  --shadow-btn-peach-active: 0 2px 0 var(--noyan-peach-shadow), 0 4px 8px rgba(217, 96, 36, 0.2);

  --shadow-btn-mint: 0 6px 0 var(--noyan-mint-shadow), 0 12px 20px rgba(25, 148, 137, 0.28);
  --shadow-btn-mint-active: 0 2px 0 var(--noyan-mint-shadow), 0 4px 8px rgba(25, 148, 137, 0.2);

  --shadow-btn-lilac: 0 6px 0 var(--noyan-lilac-shadow), 0 12px 20px rgba(92, 58, 150, 0.28);
  --shadow-btn-lilac-active: 0 2px 0 var(--noyan-lilac-shadow), 0 4px 8px rgba(92, 58, 150, 0.2);

  --shadow-btn-gold: 0 6px 0 var(--noyan-gold-shadow), 0 12px 20px rgba(198, 134, 18, 0.28);
  --shadow-btn-gold-active: 0 2px 0 var(--noyan-gold-shadow), 0 4px 8px rgba(198, 134, 18, 0.2);

  --shadow-btn-sky: 0 6px 0 var(--noyan-sky-shadow), 0 12px 20px rgba(33, 111, 224, 0.28);
  --shadow-btn-sky-active: 0 2px 0 var(--noyan-sky-shadow), 0 4px 8px rgba(33, 111, 224, 0.2);

  /* --- E. Ergonomic Radii & Touch Dimensions (انحناهای مخملی و ابعاد ارگونومیک) --- */
  --radius-sm: 18px;
  --radius-btn: 26px;
  --radius-bubble: 28px;
  --radius-card: 32px;
  --radius-hero: 40px;
  --radius-full: 9999px;

  /* استاندارد حرکتی فیتس (Fitts's Law) برای دست کودکان */
  --touch-min-size: 56px;
  --touch-ideal-size: 64px;
  --touch-safe-gap: 14px;

  /* --- F. Organic Spring Curves (منحنی‌های ارتجاعی فنری پیکساری) --- */
  --ease-spring-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-spring-smooth: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring-snap: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --speed-touch: 0.16s;
  --speed-normal: 0.35s;

  /* --- G. Typography Tokens (تایپوگرافی خوانا، صمیمی و کودک‌محور) --- */
  --font-family-kids: "Vazirmatn RD", "Shabnam", "Vazirmatn", "IRANSans", system-ui, -apple-system, sans-serif;
  --line-height-kids: 1.85; /* فاصله خطوط استاندارد برای سهولت روانخوانی کودکان پایه ابتدایی */
  --letter-spacing-kids: 0.015em;
}

/* ----------------------------------------------------------------------------
 * 2. GLOBAL RESET & ERGONOMIC FOUNDATION
 * ------------------------------------------------------------------------- */
html {
  box-sizing: border-box;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--font-family-kids);
  font-size: 16px;
  line-height: var(--line-height-kids);
  letter-spacing: var(--letter-spacing-kids);
  direction: rtl;
  text-align: right;
  background-color: var(--noyan-bg-base);
  color: var(--noyan-text-body);
}

*, *::before, *::after {
  box-sizing: inherit;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  min-height: 100vh;
  background-color: var(--noyan-bg-base);
  background-image: 
    radial-gradient(circle at 12% 18%, rgba(255, 138, 80, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 88% 25%, rgba(46, 196, 182, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 50% 85%, rgba(132, 94, 194, 0.06) 0%, transparent 50%);
  background-attachment: fixed;
  overflow-x: hidden;
  font-size: 1.05rem;
  color: var(--noyan-text-body);
}

/* ----------------------------------------------------------------------------
 * 3. CORE UI COMPONENTS (مولفه‌های اصلی رابط کاربری نویان)
 * ------------------------------------------------------------------------- */

/* --- A. Cards (کارت‌های ارگانیک شناور) --- */
.noyan-card {
  background: var(--noyan-bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: var(--radius-card);
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-card);
  padding: 24px;
  position: relative;
  transition: transform var(--speed-normal) var(--ease-spring-smooth), 
              box-shadow var(--speed-normal) var(--ease-spring-smooth);
  will-change: transform, box-shadow;
}

.noyan-card.interactive:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-floating);
}

.noyan-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.noyan-card-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--noyan-text-title);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --- B. Buttons (دکمه‌های اسباب‌بازی ژله‌ای و سه‌بعدی) --- */
.noyan-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: var(--touch-ideal-size);
  min-width: 140px;
  padding: 12px 28px;
  border-radius: var(--radius-btn);
  border: none;
  outline: none;
  cursor: pointer;
  font-family: var(--font-family-kids);
  font-size: 1.15rem;
  font-weight: 800;
  text-decoration: none;
  position: relative;
  transform: translateY(0);
  transition: transform var(--speed-touch) var(--ease-spring-snap), 
              box-shadow var(--speed-touch) var(--ease-spring-snap),
              filter var(--speed-touch) ease;
  will-change: transform, box-shadow;
  touch-action: manipulation;
}

/* افکت لایه درخشان روی سر دکمه (Highlight Sheen) */
.noyan-btn::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 12px;
  right: 12px;
  height: 38%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 100%);
  border-radius: var(--radius-btn) var(--radius-btn) 12px 12px;
  pointer-events: none;
}

/* فیزیک فشرده‌شدن کلید مکانیکی اسباب‌بازی در زمان تاچ */
.noyan-btn:active,
.noyan-btn.is-pressed {
  transform: translateY(4px) scale(0.985);
}

/* گونه ۱: تم اصلی پوپی (Popy Peach) */
.noyan-btn-primary {
  background: var(--noyan-peach-gradient);
  color: var(--noyan-text-on-accent);
  box-shadow: var(--shadow-btn-peach);
}
.noyan-btn-primary:active,
.noyan-btn-primary.is-pressed {
  box-shadow: var(--shadow-btn-peach-active);
}

/* گونه ۲: تم پیروزی و درست (Mint Success) */
.noyan-btn-success {
  background: var(--noyan-mint-gradient);
  color: var(--noyan-text-on-accent);
  box-shadow: var(--shadow-btn-mint);
}
.noyan-btn-success:active,
.noyan-btn-success.is-pressed {
  box-shadow: var(--shadow-btn-mint-active);
}

/* گونه ۳: تم معما و تفکر (Lilac Wisdom) */
.noyan-btn-secondary {
  background: var(--noyan-lilac-gradient);
  color: var(--noyan-text-on-accent);
  box-shadow: var(--shadow-btn-lilac);
}
.noyan-btn-secondary:active,
.noyan-btn-secondary.is-pressed {
  box-shadow: var(--shadow-btn-lilac-active);
}

/* گونه ۴: تم طلا و جایزه (Honey Gold) */
.noyan-btn-gold {
  background: var(--noyan-gold-gradient);
  color: #5A3C00;
  box-shadow: var(--shadow-btn-gold);
}
.noyan-btn-gold:active,
.noyan-btn-gold.is-pressed {
  box-shadow: var(--shadow-btn-gold-active);
}

/* گونه ۵: تم آسمان و پرواز (Sky Explorer) */
.noyan-btn-sky {
  background: var(--noyan-sky-gradient);
  color: var(--noyan-text-on-accent);
  box-shadow: var(--shadow-btn-sky);
}
.noyan-btn-sky:active,
.noyan-btn-sky.is-pressed {
  box-shadow: var(--shadow-btn-sky-active);
}

/* دکمه دایره‌ای آیکون دار (برای برگشت، صوت، راهنما و ...) */
.noyan-btn-icon {
  width: var(--touch-ideal-size);
  height: var(--touch-ideal-size);
  min-width: var(--touch-ideal-size);
  min-height: var(--touch-ideal-size);
  padding: 0;
  border-radius: var(--radius-full);
}
.noyan-btn-icon::after {
  border-radius: var(--radius-full);
}

/* --- C. Badges (کپسول‌های معلق و نرم اطلاعاتی) --- */
.noyan-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: var(--radius-badge);
  font-size: 0.95rem;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(74, 52, 36, 0.06);
  border: 1.5px solid rgba(255, 255, 255, 0.8);
}

.noyan-badge-acorn {
  background-color: var(--noyan-gold-light);
  color: #7A4F00;
  border-color: rgba(255, 184, 48, 0.4);
}

.noyan-badge-star {
  background-color: var(--noyan-peach-light);
  color: var(--noyan-peach-shadow);
  border-color: rgba(255, 138, 80, 0.35);
}

.noyan-badge-level {
  background-color: var(--noyan-mint-light);
  color: var(--noyan-mint-shadow);
  border-color: rgba(46, 196, 182, 0.35);
}

.noyan-badge-wisdom {
  background-color: var(--noyan-lilac-light);
  color: var(--noyan-lilac-shadow);
  border-color: rgba(132, 94, 194, 0.35);
}

/* --- D. HUD Floating Bar (نوار سربرگ شناور بازی و کودک) --- */
.noyan-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--noyan-bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-hud);
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
  gap: 16px;
}

.noyan-hud-child {
  display: flex;
  align-items: center;
  gap: 12px;
}

.noyan-hud-avatar-frame {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  border: 3px solid var(--noyan-peach-main);
  box-shadow: 0 4px 8px rgba(217, 96, 36, 0.25);
  overflow: hidden;
  background: #FFF;
  flex-shrink: 0;
}

.noyan-hud-avatar-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.noyan-hud-stats {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --- E. Avatar Speech Bubble (حباب گفتگوی اختصاصی پوپی) --- */
.noyan-avatar-bubble {
  position: relative;
  background: #FFFFFF;
  border-radius: var(--radius-bubble);
  padding: 22px 26px;
  border: 3px solid var(--noyan-peach-light);
  box-shadow: 0 16px 30px -6px rgba(217, 96, 36, 0.12), 0 4px 10px rgba(0, 0, 0, 0.04);
  font-size: 1.18rem;
  font-weight: 700;
  line-height: var(--line-height-kids);
  color: var(--noyan-text-title);
  margin-right: 20px;
  animation: noyanFloat 4s ease-in-out infinite;
}

/* دم متصل حباب به آواتار پوپی (RTL Tail) */
.noyan-avatar-bubble::before {
  content: "";
  position: absolute;
  top: 32px;
  right: -16px;
  width: 0;
  height: 0;
  border-top: 14px solid transparent;
  border-bottom: 14px solid transparent;
  border-left: 18px solid var(--noyan-peach-light);
}

.noyan-avatar-bubble::after {
  content: "";
  position: absolute;
  top: 35px;
  right: -11px;
  width: 0;
  height: 0;
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  border-left: 14px solid #FFFFFF;
}

/* برچسب نام مهربان گوینده */
.noyan-bubble-speaker {
  font-size: 0.92rem;
  font-weight: 900;
  color: var(--noyan-peach-shadow);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ----------------------------------------------------------------------------
 * 4. KEYFRAME ANIMATION LIBRARY (کتابخانه انیمیشن‌های ارگانیک و فنری)
 * ------------------------------------------------------------------------- */

/* شناوری ارگانیک و آرام (Organic Floating) */
@keyframes noyanFloat {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-8px) rotate(0.8deg);
  }
}

.anim-float {
  animation: noyanFloat 3.8s ease-in-out infinite;
  will-change: transform;
}

/* جهش فنری و شاد در زمان کشف و پیروزی (Joyous Spring Bounce) */
@keyframes noyanBounce {
  0% {
    transform: scale(0.85);
  }
  40% {
    transform: scale(1.12);
  }
  70% {
    transform: scale(0.96);
  }
  100% {
    transform: scale(1);
  }
}

.anim-bounce {
  animation: noyanBounce 0.65s var(--ease-spring-bounce) forwards;
  will-change: transform;
}

/* لرزش افقی ملایم و مهربان هنگام تلاش دوباره (بدون ایجاد استرس و حس شکست) */
@keyframes noyanSoftShake {
  0%, 100% {
    transform: translateX(0);
  }
  20%, 60% {
    transform: translateX(-6px) rotate(-1deg);
  }
  40%, 80% {
    transform: translateX(6px) rotate(1deg);
  }
}

.anim-soft-shake {
  animation: noyanSoftShake 0.45s ease-in-out;
  will-change: transform;
}

/* ضربان ملایم نوری برای جلب توجه چشم کودک به دکمه اقدام اصلی */
@keyframes noyanPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: var(--shadow-btn-peach);
  }
  50% {
    transform: scale(1.035);
    box-shadow: 0 8px 0 var(--noyan-peach-shadow), 0 16px 28px rgba(255, 138, 80, 0.48);
  }
}

.anim-pulse {
  animation: noyanPulse 2.4s ease-in-out infinite;
  will-change: transform, box-shadow;
}

/* ستاره‌های جشن پیروزی (Twinkle) */
@keyframes noyanTwinkle {
  0%, 100% {
    transform: scale(1) rotate(0deg);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.25) rotate(15deg);
    opacity: 1;
    filter: drop-shadow(0 0 12px rgba(255, 184, 48, 0.8));
  }
}

.anim-twinkle {
  animation: noyanTwinkle 1.8s ease-in-out infinite;
  display: inline-block;
  will-change: transform, filter;
}

/* رعایت نیازهای دسترسی‌پذیری و کاهش انیمیشن در صورت تنظیم سیستم */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================================
 * 12-POINT COGNITIVE STABILITY & ERGONOMIC ENHANCEMENTS (HOTFIX RELEASE)
 * ============================================================================ */

/* 1. ایزولاسیون کامل رویدادهای لمسی و جلوگیری از تداخل سوایپ اندروید/آیپد (Point 3) */
.draggable,
.card-draggable,
.food-item,
.bubble,
.command-card,
.block-item,
.drag-target,
.inventory-drag-item,
[data-draggable="true"],
.btn-hold-to-buy {
  touch-action: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none !important;
}

/* 2. بهینه‌سازی گرافیکی مدال پیروزی و ذرات سخت‌افزاری GPU (Point 5) */
.victory-modal-overlay,
.noyan-modal-overlay,
.hub-modal-overlay {
  background: rgba(0, 0, 0, 0.45) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.confetti-particle {
  position: absolute;
  width: 12px;
  height: 12px;
  will-change: transform;
  transform: translate3d(0, 0, 0);
  pointer-events: none;
}

/* 3. داربست‌های شناختی انطباقی ZPD در زمان بروز ۲ خطای متوالی (Point 6) */
.zpd-scaffold-dim {
  opacity: 0.35 !important;
  filter: grayscale(40%) !important;
  pointer-events: none !important;
  transition: opacity 0.45s ease-in-out, filter 0.45s !important;
}

.zpd-scaffold-highlight {
  animation: noyanPulse 2s infinite !important;
  border: 3.5px solid var(--noyan-peach-main) !important;
  box-shadow: 0 0 24px rgba(255, 138, 80, 0.65) !important;
  transform: scale(1.04) !important;
  transition: all 0.35s ease-in-out !important;
  z-index: 25 !important;
}

/* 4. دکمه خرید دو مرحله‌ای لمسی با نگه داشتن ۱.۵ ثانیه‌ای (Point 7) */
.btn-hold-to-buy {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-btn);
  cursor: pointer;
}

.btn-hold-to-buy .hold-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: rgba(255, 255, 255, 0.38);
  pointer-events: none;
  transition: width 0.04s linear;
  z-index: 1;
}

.btn-hold-to-buy .btn-hold-text {
  position: relative;
  z-index: 2;
  font-weight: 800;
  pointer-events: none;
}

/* 5. کشوی تخصیص ۳ قلک هوشمند مالی نویان (خرج / پس‌انداز / بخشش) (Point 9) */
.three-jars-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #FFFFFF;
  border-radius: 32px 32px 0 0;
  padding: 24px;
  box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.18);
  z-index: 1000;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  direction: rtl;
  max-width: 600px;
  margin: 0 auto;
}

.three-jars-drawer.active {
  transform: translateY(0);
}

.three-jars-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 18px 0;
}

.jar-slider-row {
  background: #F8FAFC;
  border: 2px solid #E2E8F0;
  border-radius: 20px;
  padding: 12px 16px;
}

/* 6. محافظت ملاتونین و پایش ریتم شبانه‌روزی (Circadian Vision Warmth) (Point 12) */
html.circadian-night,
body.circadian-night {
  filter: sepia(18%) hue-rotate(-10deg) brightness(97%) !important;
  transition: filter 1.5s cubic-bezier(0.4, 0, 0.2, 1) !important;
}
