<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');

// Curated daily verses aligned with TBW mission
$verses = [
    ["reference" => "Hebrews 10:7", "text" => "Then I said, 'Here I am—it is written about me in the scroll—I have come to do your will, my God.'"],
    ["reference" => "Jeremiah 29:11", "text" => "For I know the plans I have for you, declares the Lord, plans to prosper you and not to harm you, plans to give you hope and a future."],
    ["reference" => "1 John 5:4", "text" => "For everyone born of God overcomes the world. This is the victory that has overcome the world, even our faith."],
    ["reference" => "Psalm 119:105", "text" => "Your word is a lamp for my feet, a light on my path."],
    ["reference" => "James 1:21", "text" => "Therefore, get rid of all moral filth and the evil that is so prevalent and humbly accept the word planted in you, which can save you."],
    ["reference" => "Matthew 18:20", "text" => "For where two or three gather in my name, there am I with them."],
    ["reference" => "2 Corinthians 5:7", "text" => "For we live by faith, not by sight."],
    ["reference" => "Psalm 34:10", "text" => "The lions may grow weak and hungry, but those who seek the Lord lack no good thing."],
    ["reference" => "Romans 8:28", "text" => "And we know that in all things God works for the good of those who love him, who have been called according to his purpose."],
    ["reference" => "Philippians 4:13", "text" => "I can do all this through him who gives me strength."],
    ["reference" => "Isaiah 41:10", "text" => "So do not fear, for I am with you; do not be dismayed, for I am your God. I will strengthen you and help you."],
    ["reference" => "Proverbs 3:5-6", "text" => "Trust in the Lord with all your heart and lean not on your own understanding; in all your ways submit to him, and he will make your paths straight."],
    ["reference" => "Joshua 1:9", "text" => "Have I not commanded you? Be strong and courageous. Do not be afraid; do not be discouraged, for the Lord your God will be with you wherever you go."],
    ["reference" => "Romans 8:37", "text" => "No, in all these things we are more than conquerors through him who loved us."],
    ["reference" => "Ephesians 2:10", "text" => "For we are God's handiwork, created in Christ Jesus to do good works, which God prepared in advance for us to do."],
    ["reference" => "Psalm 37:4", "text" => "Take delight in the Lord, and he will give you the desires of your heart."],
    ["reference" => "Isaiah 43:2", "text" => "When you pass through the waters, I will be with you; and when you pass through the rivers, they will not sweep over you."],
    ["reference" => "John 10:10", "text" => "The thief comes only to steal and kill and destroy; I have come that they may have life, and have it to the full."],
    ["reference" => "Galatians 6:9", "text" => "Let us not become weary in doing good, for at the proper time we will reap a harvest if we do not give up."],
    ["reference" => "Deuteronomy 31:8", "text" => "The Lord himself goes before you and will be with you; he will never leave you nor forsake you. Do not be afraid; do not be discouraged."],
    ["reference" => "Colossians 3:17", "text" => "And whatever you do, whether in word or deed, do it all in the name of the Lord Jesus, giving thanks to God the Father through him."],
    ["reference" => "1 Corinthians 2:9", "text" => "However, as it is written: What no eye has seen, what no ear has heard, and what no human mind has conceived—the things God has prepared for those who love him."],
    ["reference" => "Habakkuk 2:2", "text" => "Write the vision and make it plain on tablets, that he may run who reads it."],
    ["reference" => "Psalm 23:1", "text" => "The Lord is my shepherd, I lack nothing."],
    ["reference" => "Matthew 6:33", "text" => "But seek first his kingdom and his righteousness, and all these things will be given to you as well."],
    ["reference" => "Mark 9:23", "text" => "Everything is possible for one who believes."],
    ["reference" => "Psalm 46:10", "text" => "He says, 'Be still, and know that I am God; I will be exalted among the nations, I will be exalted in the earth.'"],
    ["reference" => "Isaiah 40:31", "text" => "But those who hope in the Lord will renew their strength. They will soar on wings like eagles; they will run and not grow weary, they will walk and not be faint."],
    ["reference" => "2 Timothy 1:7", "text" => "For the Spirit God gave us does not make us timid, but gives us power, love and self-discipline."],
    ["reference" => "Philippians 4:7", "text" => "And the peace of God, which transcends all understanding, will guard your hearts and your minds in Christ Jesus."],
    ["reference" => "Revelation 12:11", "text" => "They triumphed over him by the blood of the Lamb and by the word of their testimony."]
];

// Deterministic daily verse based on day of year
$dayOfYear = (int)date('z');
$verse = $verses[$dayOfYear % count($verses)];
$verse['date'] = date('D, d M Y');
$verse['day'] = $dayOfYear;

echo json_encode($verse, JSON_UNESCAPED_UNICODE);
