// quotes.jsx — guidance from Dipa Ma and other masters of the insight lineage.
// Short, attributed teachings used across the app (daily on Today, in summaries, etc.)

const MT_QUOTES = [
  // — Dipa Ma (1911–1989) — the householder master, heart of this app —
  { t: 'Practice now. Don\u2019t think you will do it later.', a: 'Dipa Ma', r: 'Householder master', themes: ['urgency', 'effort'] },
  { t: 'If you can be mindful for one moment, you can be mindful for two.', a: 'Dipa Ma', r: 'Householder master', themes: ['effort', 'presence'] },
  { t: 'Whatever you are doing, be aware of it.', a: 'Dipa Ma', r: 'Householder master', themes: ['presence', 'noting'] },
  { t: 'Patience is one of the most important virtues for developing mindfulness.', a: 'Dipa Ma', r: 'Householder master', themes: ['equanimity', 'effort'] },
  { t: 'The whole path is a path of letting go.', a: 'Dipa Ma', r: 'Householder master', themes: ['letting-go'] },
  { t: 'Suffering is wanting things to be other than they are.', a: 'Dipa Ma', r: 'Householder master', themes: ['equanimity', 'letting-go'] },
  { t: 'Free your mind. Don\u2019t fill it up.', a: 'Dipa Ma', r: 'Householder master', themes: ['letting-go', 'presence'] },
  { t: 'Each day, just sit. That is enough.', a: 'Dipa Ma', r: 'Householder master', themes: ['effort', 'urgency'] },
  { t: 'When you do anything, do it completely \u2014 as if it is the only thing you have to do.', a: 'Dipa Ma', r: 'Householder master', themes: ['presence'] },
  { t: 'Watching thoughts is like sitting by a river. You do not have to jump in.', a: 'after Dipa Ma', r: 'in the householder spirit', themes: ['noting', 'equanimity', 'presence'] },

  // — S. N. Goenka (1924–2013) — Vipassana, body-sweep —
  { t: 'The continuity of practice is the secret of success.', a: 'S. N. Goenka', r: 'Vipassana teacher', themes: ['effort', 'urgency'] },
  { t: 'Anicca \u2014 everything that arises passes away.', a: 'S. N. Goenka', r: 'Vipassana teacher', themes: ['impermanence'] },
  { t: 'Observe reality as it is, not as you would like it to be.', a: 'S. N. Goenka', r: 'Vipassana teacher', themes: ['equanimity', 'noting'] },
  { t: 'Work patiently and persistently \u2014 you are bound to be successful.', a: 'S. N. Goenka', r: 'Vipassana teacher', themes: ['effort'] },
  { t: 'Liberation can only be gained by practice, never by mere discussion.', a: 'S. N. Goenka', r: 'Vipassana teacher', themes: ['effort', 'urgency'] },
  { t: 'Be equanimous, and you will come out of all your misery.', a: 'S. N. Goenka', r: 'Vipassana teacher', themes: ['equanimity'] },
  { t: 'Every time you react, you tie a new knot. Every time you observe, one dissolves.', a: 'S. N. Goenka', r: 'Vipassana teacher', themes: ['equanimity', 'noting'] },
  { t: 'May all beings be happy. May all beings be peaceful. May all beings be liberated.', a: 'S. N. Goenka', r: 'Vipassana teacher', themes: ['lovingkindness'] },

  // — The Buddha — public-domain suttas & Dhammapada —
  { t: 'All conditioned things are impermanent. Strive on with diligence.', a: 'The Buddha', r: 'Final words', themes: ['urgency', 'impermanence', 'effort'] },
  { t: 'Before long this body will lie upon the earth, cast aside, like a useless log.', a: 'The Buddha', r: 'Dhammapada 41', themes: ['urgency', 'impermanence'] },
  { t: 'Be an island unto yourself; be a refuge unto yourself.', a: 'The Buddha', r: 'Maha-parinibbana Sutta', themes: ['refuge', 'effort'] },
  { t: 'As a mother protects her only child, so cultivate boundless love for all beings.', a: 'The Buddha', r: 'Metta Sutta', themes: ['lovingkindness'] },

  // — Ajahn Chah (1918–1992) — Thai forest —
  { t: 'If you let go a little, you will have a little peace. If you let go a lot, you will have a lot of peace. If you let go completely, you will have complete peace.', a: 'Ajahn Chah', r: 'Thai forest master', themes: ['letting-go', 'equanimity'] },
  { t: 'Do everything with a mind that lets go.', a: 'Ajahn Chah', r: 'Thai forest master', themes: ['letting-go'] },

  // — Anagarika Munindra (1915–2003) — Dipa Ma\u2019s teacher —
  { t: 'If you want to understand your mind, sit down and observe it.', a: 'Anagarika Munindra', r: 'Dipa Ma\u2019s teacher', themes: ['noting', 'presence'] },
  { t: 'Be simple and easy and natural.', a: 'Anagarika Munindra', r: 'Dipa Ma\u2019s teacher', themes: ['presence', 'equanimity'] },

  // — Mahasi Sayadaw (1904–1982) — noting practice —
  { t: 'Whatever arises, note it \u2014 and it will pass.', a: 'Mahasi Sayadaw', r: 'Noting practice', themes: ['noting', 'impermanence'] },
  { t: 'Note the rising, note the falling. The whole world is in that movement.', a: 'Mahasi Sayadaw', r: 'Noting practice', themes: ['noting', 'presence'] },

  // — Living teachers of the lineage —
  { t: 'Mindfulness knows what is happening, as it is happening.', a: 'Joseph Goldstein', r: 'Insight Meditation Society', themes: ['presence', 'noting'] },
  { t: 'It is the nature of the mind to wander. It is the practice to begin again.', a: 'Joseph Goldstein', r: 'Insight Meditation Society', themes: ['effort', 'presence'] },
  { t: 'Mindfulness isn\u2019t difficult. We just need to remember to do it.', a: 'Sharon Salzberg', r: 'Insight Meditation Society', themes: ['presence', 'effort'] },
  { t: 'You don\u2019t need to control your thoughts. You just need to stop letting them control you.', a: 'Sharon Salzberg', r: 'Insight Meditation Society', themes: ['equanimity', 'letting-go'] },
  { t: 'The present moment is the only moment available to us.', a: 'Thich Nhat Hanh', r: 'Plum Village', themes: ['presence'] },

  // — Thich Nhat Hanh — How to Relax (Mindfulness Essentials) —
  { t: 'Feelings come and go like clouds in a windy sky. Conscious breathing is my anchor.', a: 'Thich Nhat Hanh', r: 'How to Relax', themes: ['start', 'presence'] },
  { t: 'Breathing in, I calm my body. Breathing out, I smile.', a: 'Thich Nhat Hanh', r: 'How to Relax', themes: ['start', 'presence'] },
  { t: 'Relaxation is the foundation of meditation. Allow your body to rest.', a: 'Thich Nhat Hanh', r: 'How to Relax', themes: ['start'] },
  { t: 'Smile, breathe, and go slowly.', a: 'Thich Nhat Hanh', r: 'How to Relax', themes: ['stop', 'presence'] },

  // — Sayadaw U Tejaniya — Relax and Be Aware —
  { t: 'Awareness is enough. You don\u2019t have to make anything happen.', a: 'Sayadaw U Tejaniya', r: 'Relax and Be Aware', themes: ['start', 'noting'] },
  { t: 'Is the mind tense or relaxed? Check, again and again.', a: 'Sayadaw U Tejaniya', r: 'Relax and Be Aware', themes: ['start', 'equanimity'] },
  { t: 'The thinking is not the problem. Being unaware that you are thinking is the problem.', a: 'Sayadaw U Tejaniya', r: 'Relax and Be Aware', themes: ['noting', 'presence'] },
  { t: 'You don\u2019t need to look for the end. Just keep being aware, and let awareness grow.', a: 'Sayadaw U Tejaniya', r: 'Relax and Be Aware', themes: ['stop', 'effort'] },

  // — Sri Ramakrishna Paramahansa —
  { t: 'The mind is like a lamp\u2019s flame: keep it steady, and it lights the whole room.', a: 'Ramakrishna Paramahansa', r: 'On meditation', themes: ['start', 'presence'] },
  { t: 'As you meditate, dive deep within \u2014 the gems lie not on the surface, but in the depths.', a: 'Ramakrishna Paramahansa', r: 'On meditation', themes: ['start', 'effort'] },
  { t: 'When the flower blooms, the bees come uninvited. Become still, and grace finds you.', a: 'Ramakrishna Paramahansa', r: 'On meditation', themes: ['stop'] },

  // — Sant Tukaram (1608–1650) — Varkari bhakti, the Name of Vitthala —
  { t: 'I have become my own master \u2014 the Name of God dwells in my heart.', a: 'Sant Tukaram', r: 'Abhanga · bhakti', themes: ['bhakti', 'start'] },
  { t: 'Repeat the Name, and the Name will repeat itself in you.', a: 'Sant Tukaram', r: 'Abhanga · bhakti', themes: ['bhakti', 'chant'] },
  { t: 'Where the Name is sung, there the Lord stands beside you.', a: 'Sant Tukaram', r: 'Abhanga · bhakti', themes: ['bhakti', 'chant'] },
  { t: 'Let the ego dissolve \u2014 only then does the heart fill with God.', a: 'Sant Tukaram', r: 'Abhanga · bhakti', themes: ['bhakti', 'stop'] },

  // — Sant Dnyaneshwar (1275–1296) — Jnaneshwari, jnana + bhakti —
  { t: 'Within the body dwells the deity; seek the Lord in your own heart.', a: 'Sant Dnyaneshwar', r: 'Jnaneshwari', themes: ['bhakti', 'start'] },
  { t: 'As fragrance lives in the flower, so the Divine lives in every cell of you.', a: 'Sant Dnyaneshwar', r: 'Jnaneshwari', themes: ['bhakti', 'chant'] },
  { t: 'Still the senses, turn inward, and the inner light reveals itself.', a: 'Sant Dnyaneshwar', r: 'Jnaneshwari', themes: ['bhakti', 'presence'] },
  { t: 'Let me be the dust at the feet of the devotees \u2014 there is liberation.', a: 'Sant Dnyaneshwar', r: 'Pasaydan', themes: ['bhakti', 'stop'] },
];

function mtQuotesBy(theme) {
  const list = MT_QUOTES.filter(q => !theme || q.themes.includes(theme));
  return list.length ? list : MT_QUOTES;
}
// a fresh quote for a moment ('start' before sitting, 'stop' on completion)
function mtQuotePhase(phase) {
  const pool = MT_QUOTES.filter(q => q.themes.includes(phase));
  const src = pool.length ? pool : MT_QUOTES;
  return src[Math.floor(Math.random() * src.length)];
}

// ── the teachers — short bios for the Teachings library ──────────
const MT_TEACHERS = {
  'Dipa Ma': { years: '1911–1989', tradition: 'Theravāda · Calcutta', hue: '#7CF0DC', initials: 'DM',
    bio: 'A widowed mother who lost two children and her husband, then turned to practice in her grief — and became one of the great masters of the century. She is the heart of this app: proof that deep awakening is possible inside an ordinary householder’s life.' },
  'S. N. Goenka': { years: '1924–2013', tradition: 'Vipassanā · U Ba Khin lineage', hue: '#36E8D2', initials: 'G',
    bio: 'A Burmese-Indian businessman who brought Vipassanā to millions through ten-day courses. His method centers on sweeping attention through the body and meeting every sensation with equanimity.' },
  'The Buddha': { years: 'c. 5th c. BCE', tradition: 'The awakened one', hue: '#FFD27C', initials: 'B',
    bio: 'Siddhattha Gotama, whose direct investigation of the mind and body — and the end of suffering — became the root from which all of these lineages grew.' },
  'Ajahn Chah': { years: '1918–1992', tradition: 'Thai Forest tradition', hue: '#9CD6FF', initials: 'AC',
    bio: 'A Thai forest master famed for plain, piercing teachings on letting go, patience, and the middle way. His monasteries trained many of today’s Western teachers.' },
  'Anagarika Munindra': { years: '1915–2003', tradition: 'Dipa Ma’s teacher', hue: '#B49CFF', initials: 'AM',
    bio: 'A Bengali master of gentle precision who guided Dipa Ma and a generation of Western students. He insisted practice be simple, natural, and woven into daily life.' },
  'Mahasi Sayadaw': { years: '1904–1982', tradition: 'Noting practice · Burma', hue: '#7CC4FF', initials: 'MS',
    bio: 'A Burmese monk whose “noting” method — silently naming each experience as it arises — made moment-to-moment insight accessible to lay practitioners worldwide.' },
  'Joseph Goldstein': { years: 'b. 1944', tradition: 'Insight Meditation Society', hue: '#7CF0DC', initials: 'JG',
    bio: 'Co-founder of the Insight Meditation Society and one of the foremost Western teachers of insight (vipassanā), known for clarity and dry humor.' },
  'Sharon Salzberg': { years: 'b. 1952', tradition: 'Insight Meditation Society', hue: '#F2A6C2', initials: 'SS',
    bio: 'Co-founder of IMS who brought lovingkindness (mettā) practice into the mainstream, pairing sharp insight with warmth.' },
  'Thich Nhat Hanh': { years: '1926–2022', tradition: 'Zen · Plum Village', hue: '#9CE6C4', initials: 'TN',
    bio: 'A Vietnamese Zen master and peace activist who taught mindfulness in the smallest acts of daily life — washing dishes, walking, breathing.' },
  'Sayadaw U Tejaniya': { years: 'b. 1962', tradition: 'Burmese noting · relaxed awareness', hue: '#7CC4FF', initials: 'UT',
    bio: 'A Burmese master whose approach centres on relaxed, continuous awareness — watching the knowing mind itself, with no force. His books "Relax and Be Aware" and "When Awareness Becomes Natural" make effortless mindfulness accessible to anyone.' },
  'Ramakrishna Paramahansa': { years: '1836–1886', tradition: 'Bhakti · Vedanta · Bengal', hue: '#FFB87C', initials: 'RK',
    bio: 'A Bengali mystic and saint whose ecstatic devotion and simple parables pointed countless seekers toward the divine. He taught that steady, single-pointed concentration in meditation reveals what lies in the depths of the heart.' },
  'Sant Tukaram': { years: '1608–1650', tradition: 'Varkari bhakti · Maharashtra', hue: '#FFA8C4', initials: 'T',
    bio: 'A farmer-saint of the Varkari tradition whose abhangas (devotional songs) to Vitthala of Pandharpur are sung across Maharashtra to this day. He taught liberation through the constant repetition of the divine Name and the dissolving of ego in love.' },
  'Sant Dnyaneshwar': { years: '1275–1296', tradition: 'Varkari · Jnaneshwari', hue: '#C4A8FF', initials: 'D',
    bio: 'A child-saint who, by age sixteen, wrote the Jnaneshwari — a Marathi commentary on the Bhagavad Gita that wed the path of knowledge (jnana) to the path of devotion (bhakti). His Pasaydan is a universal prayer for the welfare of all beings.' },
};
const MT_TEACHER_ORDER = ['Dipa Ma', 'S. N. Goenka', 'The Buddha', 'Anagarika Munindra', 'Mahasi Sayadaw', 'Sayadaw U Tejaniya', 'Ajahn Chah', 'Joseph Goldstein', 'Sharon Salzberg', 'Thich Nhat Hanh', 'Ramakrishna Paramahansa', 'Sant Tukaram', 'Sant Dnyaneshwar'];
function mtQuotesFor(author) { return MT_QUOTES.filter(q => q.a === author); }
// deterministic daily pick (stable across a day, themed optional)
function mtQuoteOfDay(theme) {
  const list = mtQuotesBy(theme);
  const day = Math.floor(Date.now() / 864e5);
  return list[day % list.length];
}
function mtQuoteRandom(theme, notText) {
  const list = mtQuotesBy(theme).filter(q => q.t !== notText);
  return list[Math.floor(Math.random() * list.length)] || mtQuotesBy(theme)[0];
}

// Attributed quote block. Tap to draw another (when `shuffle`).
function QuoteBlock({ theme, quote, shuffle, align = 'center', size = 17, dim, onShuffle }) {
  const C = MT_COLORS;
  const [q, setQ] = React.useState(quote || mtQuoteOfDay(theme));
  React.useEffect(() => { if (quote) setQ(quote); }, [quote]);
  const draw = () => { const n = mtQuoteRandom(theme, q.t); setQ(n); onShuffle && onShuffle(n); };
  return (
    <div onClick={shuffle ? draw : undefined}
      style={{ textAlign: align, cursor: shuffle ? 'pointer' : 'default', maxWidth: 540, margin: align === 'center' ? '0 auto' : 0 }}>
      <div key={q.t} style={{ font: `italic 300 ${size}px/1.5 var(--serif)`, color: dim ? C.inkFaint : C.inkDim, textWrap: 'pretty', animation: 'mtCue 0.7s ease-out' }}>
        “{q.t}”
      </div>
      <div style={{ display: 'flex', alignItems: 'center', justifyContent: align === 'center' ? 'center' : 'flex-start', gap: 8, marginTop: 10 }}>
        <span style={{ width: 14, height: 1, background: C.tealLine }} />
        <span style={{ fontSize: 12.5, color: C.ink, fontWeight: 600, letterSpacing: 0.2 }}>{q.a}</span>
        <span style={{ fontSize: 11.5, color: C.inkFaint }}>{q.r}</span>
        {shuffle && <span style={{ marginLeft: 4, color: C.inkFaint, display: 'inline-flex' }}><MTIcon name="spark" size={13} color={C.inkFaint} /></span>}
      </div>
    </div>
  );
}


// ── practical principles per teacher (shown on the teacher page) ──
// Distilled from each teacher's documented core instructions.
const MT_TEACHER_PRINCIPLES = {
  'Dipa Ma': [
    'Stay with one meditation method.',
    'Practice every day.',
    'Any situation can be used for practice.',
    'Develop patience.',
    'Don\u2019t believe every story the mind tells.',
    'Cool anger and emotional reactivity.',
    'Have fun along the way.',
    'Live simply.',
    'Bless others.',
    'Let meditation become part of your whole life.',
  ],
  'S. N. Goenka': [
    'Keep s\u012bla — moral conduct is the soil the practice grows in.',
    'Sit every day, morning and evening, without fail.',
    'Observe sensation, not the story around it.',
    'Remain equanimous — neither craving the pleasant nor resisting the unpleasant.',
    'Remember anicca: whatever arises, passes.',
    'Do not mix techniques — give one method a full, honest chance.',
  ],
  'The Buddha': [
    'See for yourself — accept nothing on hearsay or authority alone.',
    'Whatever arises, passes — hold on to nothing.',
    'Guard the senses; watch the mind.',
    'Abandon what is unwholesome; cultivate what is wholesome.',
    'Be an island unto yourself — your own refuge.',
    'Practice with urgency — as if your hair were on fire.',
  ],
  'Anagarika Munindra': [
    'Keep the practice simple and natural.',
    'When you walk, walk. When you eat, eat.',
    'Investigate experience with the curiosity of a scientist.',
    'The whole of life is meditation.',
    'Practice so that you truly see — even the small purple flowers by the side of the road.',
  ],
  'Mahasi Sayadaw': [
    'Note everything, moment to moment.',
    'Anchor at the rising and falling of the abdomen.',
    'Label gently — \u201cthinking,\u201d \u201chearing,\u201d \u201cwandering.\u201d',
    'Slow down: precision matters more than speed.',
    'Alternate walking and sitting in equal measure.',
    'Carry the noting from waking until sleep.',
  ],
  'Sayadaw U Tejaniya': [
    'Relax — awareness, not effort, does the work.',
    'Check the attitude of the watching mind first.',
    'Don\u2019t try to create results; observe what is already here.',
    'Defilements are the object of study, not the enemy.',
    'Practice all day, lightly — momentum over intensity.',
  ],
  'Ajahn Chah': [
    'Let go a little, a little peace. Let go a lot, a lot of peace. Let go completely — complete peace and freedom.',
    'Let the mind become like a still forest pool — and watch what comes to drink.',
    'Everything teaches, discomfort most of all.',
    'Do not cling even to stillness.',
    'Patient endurance is the highest practice.',
    'Meet everything with: \u201cit is uncertain.\u201d',
  ],
  'Joseph Goldstein': [
    'Noticing you were lost in thought is the practice working.',
    'One breath at a time is enough.',
    'Make mindfulness continuous, not episodic.',
    'Investigate the nature of whatever is arising.',
    'Experience arises on its own — don\u2019t take it personally.',
  ],
  'Sharon Salzberg': [
    'Begin again — every distraction is a fresh start, not a failure.',
    'Lovingkindness is a strength, not a sentiment.',
    'Start with kindness toward yourself.',
    'Small daily sits beat heroic rare ones.',
    'How you meet failure is the practice.',
  ],
  'Thich Nhat Hanh': [
    'Breathe, and know that you are breathing.',
    'Walk as if you are kissing the Earth with your feet.',
    'Do one thing at a time, completely.',
    'Hold your suffering tenderly, like a mother holds a child.',
    'Nothing exists by itself alone — look deeply and see everything in each thing.',
    'The present moment is the only moment.',
  ],
  'Ramakrishna Paramahansa': [
    'Call on the Divine with the longing of a child for its mother.',
    'As many faiths, so many paths — all lead to the same God.',
    'Sincerity of heart outweighs technique.',
    'Keep holy company.',
    'The Name purifies the mind that repeats it.',
  ],
  'Sant Tukaram': [
    'Keep the Name on every breath — Vitthala, Vitthala.',
    'Devotion needs no ritual, only sincerity.',
    'Sing — let the abhanga be your prayer.',
    'Surrender the outcome: Vitthala, you handle this.',
    'The Lord stays close to the humble.',
  ],
  'Sant Dnyaneshwar': [
    'Turn attention inward — the divine is within.',
    'Knowledge and devotion are one path, not two.',
    'Serve every being as a form of God.',
    'Let the breath carry the Name.',
    'Stay even-minded in honor and insult alike.',
  ],
};

Object.assign(window, { MT_QUOTES, MT_TEACHERS, MT_TEACHER_ORDER, MT_TEACHER_PRINCIPLES, mtQuotesBy, mtQuotesFor, mtQuoteOfDay, mtQuoteRandom, mtQuotePhase, QuoteBlock });
