// ============================================================
// DEVELOPMENTAL MILESTONES DATA
// Sources: AAP Bright Futures, Nelson Textbook of Pediatrics
// THIS MODULE IS COMPLETELY SEPARATE FROM HPI
// ============================================================

// Static fallback data - used when database is empty
var MILESTONES_DATA_STATIC = {

  "Newborn / 1 month": {
    "Gross Motor": [
      "Moves arms and legs equally",
      "Lifts head briefly when on tummy (prone)",
      "Strong flexion posture (arms and legs tucked)",
      "Turns head side to side when lying on back"
    ],
    "Fine Motor": [
      "Hands mostly fisted",
      "Strong grasp reflex when palm is touched",
      "Brings hands near face"
    ],
    "Language": [
      "Cries to express needs",
      "Startles or quiets to sounds",
      "Makes brief throaty sounds"
    ],
    "Social/Emotional": [
      "Recognizes caregiver voice",
      "Briefly fixates on faces at close range (8-12 inches)",
      "Calms when held or hears familiar voice",
      "Shows brief alert periods"
    ],
    "Cognitive": [
      "Focuses on faces briefly",
      "Follows objects briefly to midline",
      "Prefers black and white or high-contrast patterns",
      "Responds to loud sounds (Moro reflex)"
    ]
  },

  "2 months": {
    "Gross Motor": [
      "Lifts head when prone (45 degrees)",
      "Holds head steady when held upright briefly",
      "Moves both arms and both legs",
      "Pushes up on tummy"
    ],
    "Fine Motor": [
      "Opens hands briefly",
      "Holds rattle if placed in hand briefly",
      "Brings hands to midline"
    ],
    "Language": [
      "Coos and makes gurgling sounds",
      "Makes sounds other than crying",
      "Turns head toward sounds"
    ],
    "Social/Emotional": [
      "Social smile (responsive to faces)",
      "Begins to self-soothe (hands to mouth)",
      "Tries to look at parent",
      "Calms when spoken to or picked up"
    ],
    "Cognitive": [
      "Pays attention to faces",
      "Begins to follow things with eyes",
      "Recognizes people at a distance"
    ]
  },

  "4 months": {
    "Gross Motor": [
      "Holds head steady unsupported",
      "Pushes up to elbows when on tummy",
      "May roll over tummy to back",
      "Pushes down on legs when feet on hard surface"
    ],
    "Fine Motor": [
      "Reaches for toys with one hand",
      "Uses hands and eyes together",
      "Grasps and shakes hand toys"
    ],
    "Language": [
      "Babbles with expression and copies sounds",
      "Cries differently for hunger pain and tiredness",
      "Makes vowel sounds ah eh oh"
    ],
    "Social/Emotional": [
      "Smiles spontaneously especially at people",
      "Likes to play and may cry when playing stops",
      "Copies movements and facial expressions"
    ],
    "Cognitive": [
      "Lets you know if happy or sad",
      "Follows moving things with eyes side to side",
      "Watches faces closely",
      "Recognizes familiar people at a distance"
    ]
  },

  "6 months": {
    "Gross Motor": [
      "Rolls over in both directions",
      "Begins to sit without support",
      "Supports weight on legs and might bounce",
      "Rocks back and forth on hands and knees"
    ],
    "Fine Motor": [
      "Reaches for and grasps objects",
      "Transfers objects hand to hand",
      "Raking grasp to pick up objects",
      "Brings things to mouth"
    ],
    "Language": [
      "Responds to own name",
      "Responds to sounds by making sounds",
      "Strings vowels together when babbling",
      "Begins consonant sounds m and b",
      "Makes sounds to show joy and displeasure"
    ],
    "Social/Emotional": [
      "Knows familiar faces and recognizes strangers",
      "Likes to play with others especially parents",
      "Responds to other peoples emotions",
      "Likes to look at self in mirror"
    ],
    "Cognitive": [
      "Looks around at things nearby",
      "Shows curiosity and tries to get things out of reach",
      "Begins to pass things from one hand to the other"
    ]
  },

  "9 months": {
    "Gross Motor": [
      "Stands holding on to support",
      "Can get into sitting position",
      "Sits without support",
      "Pulls to stand",
      "Crawls"
    ],
    "Fine Motor": [
      "Pincer grasp developing (thumb and index finger)",
      "Transfers objects smoothly between hands",
      "Picks up small objects like cereal pieces",
      "Bangs two objects together"
    ],
    "Language": [
      "Understands no",
      "Makes many different sounds like mamamama bababababa",
      "Copies sounds and gestures of others",
      "Uses fingers to point at things"
    ],
    "Social/Emotional": [
      "May be afraid of strangers (stranger anxiety)",
      "May be clingy with familiar adults (separation anxiety)",
      "Has favorite toys",
      "Plays peek-a-boo"
    ],
    "Cognitive": [
      "Watches the path of something as it falls",
      "Looks for hidden things (object permanence developing)",
      "Puts things in mouth to explore",
      "Moves things smoothly between hands"
    ]
  },

  "12 months": {
    "Gross Motor": [
      "Pulls up to stand",
      "Walks holding on to furniture (cruising)",
      "May take a few steps without holding on",
      "May stand alone"
    ],
    "Fine Motor": [
      "Neat pincer grasp (thumb and forefinger)",
      "Puts things in a container",
      "Takes things out of a container",
      "Lets go of things without help",
      "Pokes with index finger"
    ],
    "Language": [
      "Says mama and dada with meaning",
      "Responds to simple spoken requests",
      "Uses simple gestures like waving bye-bye",
      "Says one to two other words",
      "Tries to say words you say"
    ],
    "Social/Emotional": [
      "Is shy or nervous with strangers",
      "Cries when mom or dad leaves",
      "Has favorite things and people",
      "Shows fear in some situations",
      "Hands you a book to hear a story"
    ],
    "Cognitive": [
      "Explores things by shaking banging throwing",
      "Finds hidden things easily",
      "Looks at right picture when it is named",
      "Copies gestures",
      "Starts to use things correctly like drinking from cup"
    ]
  },

  "15 months": {
    "Gross Motor": [
      "Walks independently",
      "May walk up steps with help",
      "Stoops to pick up toy and stands back up"
    ],
    "Fine Motor": [
      "Stacks two blocks",
      "Scribbles with crayon",
      "Drinks from cup with some spilling",
      "Uses fingers to eat"
    ],
    "Language": [
      "Says three to five words",
      "Follows one-step commands without gestures",
      "Points to show something interesting",
      "Points to ask for something"
    ],
    "Social/Emotional": [
      "Copies other children while playing",
      "Shows affection to familiar people",
      "Claps when excited",
      "Shows you objects they like"
    ],
    "Cognitive": [
      "Tries to use things the right way (phone cup book)",
      "Stacks at least two small objects",
      "Follows one-step directions without gestures"
    ]
  },

  "18 months": {
    "Gross Motor": [
      "Walks well independently",
      "Runs stiffly",
      "Walks up steps with hand held",
      "Pulls toys while walking",
      "Climbs on and off furniture without help"
    ],
    "Fine Motor": [
      "Scribbles spontaneously",
      "Stacks three to four blocks",
      "Drinks from cup",
      "Eats with spoon (messy)",
      "Turns book pages two to three at a time"
    ],
    "Language": [
      "Says ten to twenty or more single words",
      "Says and shakes head no",
      "Points to show someone what they want",
      "Points to one body part when asked",
      "Follows one-step verbal commands without gestures"
    ],
    "Social/Emotional": [
      "Likes to hand things to others as play",
      "May have temper tantrums",
      "Shows affection to familiar people",
      "Plays simple pretend like feeding a doll",
      "May cling to caregivers in new situations"
    ],
    "Cognitive": [
      "Knows what ordinary things are for (phone brush spoon)",
      "Points to get attention of others",
      "Shows interest in doll by pretending to feed",
      "Points to one body part when asked",
      "Scribbles on own"
    ]
  },

  "24 months": {
    "Gross Motor": [
      "Kicks a ball",
      "Runs",
      "Walks up and down stairs holding on",
      "Stands on tiptoe",
      "Throws ball overhand",
      "Begins to jump with both feet"
    ],
    "Fine Motor": [
      "Stacks six or more blocks",
      "Turns book pages one at a time",
      "Turns door handles",
      "Copies a straight line",
      "Eats with spoon well"
    ],
    "Language": [
      "Points to things in book when asked",
      "Says sentences with two to four words",
      "Follows simple two-step instructions",
      "Knows names of familiar people and body parts",
      "Uses more than fifty words",
      "Strangers understand about half of speech"
    ],
    "Social/Emotional": [
      "Copies others especially adults and older children",
      "Gets excited with other children",
      "Shows increasing independence",
      "Plays mainly beside other children (parallel play)",
      "Shows defiant behavior"
    ],
    "Cognitive": [
      "Finds things hidden under two to three covers",
      "Begins to sort shapes and colors",
      "Plays simple make-believe",
      "Builds tower of four or more blocks",
      "Follows two-step instructions"
    ]
  },

  "30 months": {
    "Gross Motor": [
      "Jumps with both feet off the ground",
      "Walks up stairs alternating feet with rail",
      "Runs well without falling",
      "Kicks ball forward"
    ],
    "Fine Motor": [
      "Stacks eight or more blocks",
      "Copies a vertical line",
      "Turns pages one at a time",
      "Strings large beads"
    ],
    "Language": [
      "Uses two to three word phrases routinely",
      "Uses plurals (dogs cats)",
      "Knows at least one color",
      "Uses I me you",
      "Vocabulary over 200 words"
    ],
    "Social/Emotional": [
      "Plays alongside progressing to interactive play",
      "Shows concern for crying friend",
      "Shows wide range of emotions",
      "Takes turns in games with help"
    ],
    "Cognitive": [
      "Plays make-believe with dolls animals people",
      "Does puzzles with three to four pieces",
      "Understands concept of two",
      "Copies a circle by age 3"
    ]
  },

  "36 months": {
    "Gross Motor": [
      "Climbs well",
      "Runs easily",
      "Pedals a tricycle",
      "Walks up and down stairs one foot per step",
      "Jumps forward"
    ],
    "Fine Motor": [
      "Copies a circle",
      "Builds towers of more than nine blocks",
      "Turns rotating handles like doorknobs",
      "Uses scissors to snip"
    ],
    "Language": [
      "Carries on conversation using two to three sentences",
      "Names most familiar things",
      "Understands in on under",
      "Says first name age and sex",
      "Talks well enough for strangers to understand most of the time",
      "Follows two to three step instructions"
    ],
    "Social/Emotional": [
      "Copies adults and friends",
      "Takes turns in games",
      "Shows affection for friends without prompting",
      "Understands mine and his or hers",
      "Separates easily from parents"
    ],
    "Cognitive": [
      "Works toys with buttons levers and moving parts",
      "Plays make-believe with dolls animals people",
      "Does puzzles with three to four pieces",
      "Understands what two means",
      "Copies a circle with pencil or crayon"
    ]
  },

  "48 months": {
    "Gross Motor": [
      "Hops on one foot",
      "Catches a bounced ball most of the time",
      "Walks up and down stairs without support",
      "Kicks ball forward with force",
      "Stands on one foot for two or more seconds"
    ],
    "Fine Motor": [
      "Draws a person with two to four body parts",
      "Copies a cross shape",
      "Uses scissors to cut along a line",
      "Prints some capital letters",
      "Stacks ten or more blocks"
    ],
    "Language": [
      "Knows some basic rules of grammar like he and she",
      "Sings a song or says a poem from memory",
      "Tells stories",
      "Says first and last name",
      "Understands same and different",
      "Uses sentences with four or more words",
      "Speech is fully intelligible to strangers"
    ],
    "Social/Emotional": [
      "Enjoys doing new things",
      "Plays mom and dad (role playing)",
      "Is creative with make-believe play",
      "Would rather play with others than alone",
      "Cooperates with other children"
    ],
    "Cognitive": [
      "Names some colors and numbers",
      "Understands the idea of counting",
      "Starts to understand time concepts",
      "Remembers parts of a story",
      "Understands same and different",
      "Draws a person with two to four body parts"
    ]
  },

  "60 months": {
    "Gross Motor": [
      "Stands on one foot for ten or more seconds",
      "Hops and may skip",
      "Can do a somersault",
      "Swings and climbs",
      "Catches a small ball using hands only"
    ],
    "Fine Motor": [
      "Copies a triangle and other shapes",
      "Draws a person with at least six body parts",
      "Prints some letters and numbers",
      "Uses fork and spoon well and may use knife",
      "Can dress and undress independently"
    ],
    "Language": [
      "Speaks very clearly",
      "Tells a simple story using full sentences",
      "Uses future tense",
      "Says name and address",
      "Counts ten or more objects",
      "Uses five to eight word sentences"
    ],
    "Social/Emotional": [
      "Wants to please friends",
      "Wants to be like friends",
      "More likely to agree with rules",
      "Likes to sing dance and act",
      "Aware of gender",
      "Can tell real from make-believe"
    ],
    "Cognitive": [
      "Counts ten or more objects",
      "Names at least four colors correctly",
      "Better understands time concepts",
      "Knows about everyday things (money food)",
      "Draws a person with at least six body parts",
      "Prints some letters or numbers"
    ]
  },

  "6 years": {
    "Gross Motor": [
      "Rides a bicycle without training wheels",
      "Skips and runs with good coordination",
      "Kicks and catches a ball reliably",
      "Jumps rope",
      "Balances on one foot for several seconds"
    ],
    "Fine Motor": [
      "Writes name and simple words legibly",
      "Colors within lines",
      "Cuts along straight and curved lines with scissors",
      "Ties shoelaces independently",
      "Draws a recognizable person with details"
    ],
    "Language": [
      "Uses 5- to 8-word sentences routinely",
      "Reads simple words and short sentences",
      "Tells connected stories about events",
      "Understands and follows three-step instructions",
      "Articulates clearly; speech understood by all"
    ],
    "Social/Emotional": [
      "Prefers same-sex friends but plays with both",
      "Rule-oriented; upset when rules are broken",
      "Enjoys cooperative play and group games",
      "Begins to understand others' perspectives",
      "May show competitive behavior",
      "Seeks adult approval; eager to please"
    ],
    "Cognitive": [
      "Counts reliably to 100; adds and subtracts single digits",
      "Distinguishes left from right on self",
      "Understands concept of time (days weeks months)",
      "Names days of the week in order",
      "Classifies objects by two attributes (color and shape)",
      "Reads simple books with help"
    ]
  },

  "7 years": {
    "Gross Motor": [
      "Rides a bicycle with control and speed",
      "Swims basic strokes with instruction",
      "Performs organized sports skills (kicking passing)",
      "Skips smoothly and gallops",
      "Broad jumps and hops on either foot"
    ],
    "Fine Motor": [
      "Writes letters and numbers with good legibility",
      "Draws detailed pictures with background",
      "Uses tools (ruler compass) with guidance",
      "Cuts complex shapes accurately",
      "Prints and begins to learn cursive"
    ],
    "Language": [
      "Reads independently at grade level",
      "Explains the reason for rules and events",
      "Vocabulary of 2,000+ words in use",
      "Tells jokes and riddles; understands puns",
      "Distinguishes fantasy from reality verbally"
    ],
    "Social/Emotional": [
      "Increasing importance of peer acceptance",
      "Aware of self in relation to peers",
      "May be critical of self or others",
      "Better emotional regulation than at 6",
      "Begins to keep secrets",
      "Enjoys team activities and group projects"
    ],
    "Cognitive": [
      "Reads chapter books independently",
      "Adds and subtracts two-digit numbers",
      "Understands concept of multiplication",
      "Remembers the order of daily activities",
      "Can focus on tasks for 20–30 minutes",
      "Understands conservation of number and mass"
    ]
  },

  "8 years": {
    "Gross Motor": [
      "Participates in organized team sports",
      "Demonstrates smooth and rhythmic movement",
      "Increased stamina and speed",
      "Performs complex physical tasks (gymnastics swimming)",
      "Coordinates movements for ball sports"
    ],
    "Fine Motor": [
      "Writes in cursive or print with ease",
      "Uses keyboard with increasing speed",
      "Constructs detailed models and crafts",
      "Draws in proportion with perspective",
      "Handles small tools (compass protractor) independently"
    ],
    "Language": [
      "Reads fluently with comprehension",
      "Writes simple paragraphs and stories",
      "Understands figurative language (metaphors similes)",
      "Engages in debate and argument",
      "Extensive vocabulary; enjoys word games"
    ],
    "Social/Emotional": [
      "Strong peer relationships; friendship very important",
      "Understands fairness and reciprocity",
      "Increases independence from parents",
      "More aware of social norms and fitting in",
      "Can experience peer pressure",
      "Develops sense of personal competence"
    ],
    "Cognitive": [
      "Multiplication and division of single digits",
      "Reads and writes well independently",
      "Can focus on single task for 45–60 minutes",
      "Understands cause and effect in social situations",
      "Begins basic scientific reasoning",
      "Uses internet and technology with guidance"
    ]
  },

  "9 years": {
    "Gross Motor": [
      "Highly coordinated in sports and physical activities",
      "Sustained participation in team or individual sports",
      "Increasing strength and endurance",
      "Performs complex gymnastic or athletic maneuvers",
      "Competes in races or organized games"
    ],
    "Fine Motor": [
      "Writes in legible cursive for extended periods",
      "Creates detailed artwork with perspective",
      "Proficient with tools requiring precision",
      "Types efficiently on keyboard",
      "Complex crafts (knitting sewing model-building)"
    ],
    "Language": [
      "Reads chapter books independently for pleasure",
      "Writes multi-paragraph essays and reports",
      "Understands and uses complex grammar",
      "Can summarize and explain what was read",
      "Participates in formal discussions and debates"
    ],
    "Social/Emotional": [
      "Best-friend relationships central",
      "Sensitive to criticism from peers",
      "Increasing desire for privacy",
      "Understands others' complex feelings",
      "May show early concern about body image",
      "Appreciates humor and sarcasm"
    ],
    "Cognitive": [
      "Multiplies and divides multi-digit numbers",
      "Understands fractions and decimals",
      "Uses logical reasoning to solve problems",
      "Plans multi-step projects",
      "Aware of abstract concepts (justice democracy)",
      "Can memorize facts systematically"
    ]
  },

  "10 years": {
    "Gross Motor": [
      "Skilled and competitive in preferred sports",
      "Strong endurance for prolonged physical activity",
      "Good gross motor skills approaching adult patterns",
      "Enjoys recreational and competitive athletics",
      "Participates in organized leagues or clubs"
    ],
    "Fine Motor": [
      "Near-adult level fine motor precision",
      "Plays musical instrument with practice",
      "Produces polished written and artistic work",
      "Efficient and comfortable with keyboard",
      "Complex craft work with minimal guidance"
    ],
    "Language": [
      "Reading at or above grade level",
      "Writes organized multi-paragraph compositions",
      "Uses sophisticated vocabulary in writing and speech",
      "Can write a coherent argument or persuasive essay",
      "Understands complex figurative language"
    ],
    "Social/Emotional": [
      "Peer opinions very important; social conformity increases",
      "Beginning awareness of romantic attraction possible",
      "Understands nuance in social situations",
      "Stronger sense of personal identity",
      "May question family values or rules",
      "Can delay gratification effectively"
    ],
    "Cognitive": [
      "Beginning of formal operational thinking (Piaget)",
      "Understands fractions percentages and ratios",
      "Thinks about hypothetical situations",
      "Can plan and prioritize independently",
      "Understands multiple perspectives simultaneously",
      "Increasing interest in logic puzzles and strategy"
    ]
  },

  "11 years": {
    "Gross Motor": [
      "Physical activity preferences clearly established",
      "May be entering puberty; growth spurt possible",
      "Excellent coordination in practiced skills",
      "Varies widely by individual based on puberty timing",
      "Participates in physical education and sports"
    ],
    "Fine Motor": [
      "Adult-level fine motor skills in practiced areas",
      "Skilled at digital technology use",
      "Sophisticated artwork and craftsmanship",
      "Writes fluidly and legibly for extended periods",
      "Performs complex manual tasks independently"
    ],
    "Language": [
      "Reading comprehension approaching adult level",
      "Writes research reports and persuasive essays",
      "Understands sarcasm irony and double meaning",
      "Expresses nuanced opinions in writing and speech",
      "Vocabulary approaching 50,000+ words receptively"
    ],
    "Social/Emotional": [
      "Peer relationships may become central to identity",
      "May experiment with social roles and identity",
      "Possible early signs of puberty-related mood variability",
      "Greater capacity for empathy and perspective-taking",
      "Interest in romantic relationships may emerge",
      "Begins to develop adult moral reasoning"
    ],
    "Cognitive": [
      "Abstract reasoning develops steadily",
      "Can think through complex hypothetical problems",
      "Understands scientific method and experiment design",
      "Increased metacognition (thinking about thinking)",
      "Can plan and self-regulate over longer time horizons",
      "Interested in fairness justice and ethics"
    ]
  }
};

var DOMAIN_CONFIG = {
  "Gross Motor":      { icon: "🏃", css: "domain-gross-motor" },
  "Fine Motor":       { icon: "✋", css: "domain-fine-motor" },
  "Language":         { icon: "🗣️", css: "domain-language" },
  "Social/Emotional": { icon: "🤝", css: "domain-social" },
  "Cognitive":        { icon: "🧠", css: "domain-cognitive" }
};

// Expose as window global for fallback usage
window.MILESTONES_DATA_STATIC = MILESTONES_DATA_STATIC;
console.log('✅ Static milestones data loaded:', Object.keys(MILESTONES_DATA_STATIC).length, 'age groups');
