https://forms.gle/nAr2wthXzCgMdWFB9

https://docs.google.com/spreadsheets/d/1kDWOtnEyRxj4RNiLJJCE0WCvil2o4wx4HMsO24Dmt0g/edit?usp=drivesdk


Response sheet
https://docs.google.com/spreadsheets/d/1kDWOtnEyRxj4RNiLJJCE0WCvil2o4wx4HMsO24Dmt0g/edit?usp=drivesdk

Badges

Being in Bloom
https://drive.google.com/file/d/109qscgJSKo0M1FlRGsZzn81F5_0ge9BX/view?usp=drivesdk

https://imgur.com/a/FH4smYG

Enduring Bloom
https://drive.google.com/file/d/1QUBaM3AJfvhvfTS9qkDIxnIaCFY8AE4a/view?usp=drivesdk

https://imgur.com/a/O9jy9rP



Moonlight Reverie
https://drive.google.com/file/d/16vKYdUk8JnBcKEx27sH5TkynPsqLiwXN/view?usp=drivesdk

https://imgur.com/a/HxR4aNu

Vision Vine
https://drive.google.com/file/d/11T52NzspBhfu8IU_Ulw-ApG-fXKnIh_S/view?usp=drivesdk

https://imgur.com/a/9acVnRl


Stoic bloom
https://imgur.com/a/7rzV2ZV

Royal Bloom

https://imgur.com/a/AlFdGYN

Pragmatic bloomer
https://imgur.com/a/56VvvGz

Altruism
https://imgur.com/a/Hcjw1Gv

Wild spirit
https://imgur.com/a/JvdgeyY

Nihlist
https://imgur.com/a/wSgrdLl

Pragmatist
https://imgur.com/a/Z1qoKaZ

Fragrance seeker
https://imgur.com/a/gwzILYd

Wild bloom
https://imgur.com/a/PzuiRKG

Harmony
https://imgur.com/a/Q43hN1U


Fcos logo
https://imgur.com/a/4Yco5wg

Skepticism
https://imgur.com/a/MNIglMs

Order & Form
https://imgur.com/a/ukuPLxh

Orchid Mahjong
https://imgur.com/a/gPfSFbm

Paphiopedilum
https://imgur.com/a/G4wbbh6

Cattleya
https://imgur.com/a/YRzeJbA

Masdevalia
https://imgur.com/a/PrOG9F4

Catasetum
https://imgur.com/a/uEKPjqL

Egoism Self Bloom
https://imgur.com/a/92asMXl


The ultimate Orchid quiz philosophy, Banner
https://imgur.com/a/Qn7iQB5


Already Designed
	1.	Epicureanism → Being in Bloom 🌺 (Delight in sensory joy)
	2.	Stoicism → Enduring Bloom 🪷 (Strength through cycles)
	3.	Transcendentalism → Moonlight Reverie 🌙 (Spiritual harmony with nature)
	4.	Idealism → Vision Vine 🌿 (Chasing perfection and ideals)

⸻

To Be Designed (Proposals)

5. Confucianism → Harmony Orchid ⚖️
	•	Symbol: Orchid framed by yin-yang inspired curves.
	•	Palette: Balanced gold and jade green.
	•	Concept: Responsibility, respect, and order.

6. Egoism → Radiant Flame Orchid 🔥
	•	Symbol: A single orchid glowing like a torch.
	•	Palette: Deep red, gold highlights.
	•	Concept: Self-driven brilliance, the orchid as mirror of self.

7. Nihilism → Vanishing Bloom 🖤
	•	Symbol: Orchid petals dissolving into mist.
	•	Palette: Charcoal and silver.
	•	Concept: Beauty in impermanence, truth in transience.

8. Renaissance Humanism → Orchid Muse 🎨
	•	Symbol: Stylized orchid with painter’s palette.
	•	Palette: Rich burgundy, ivory, Renaissance gold.
	•	Concept: The orchid as art, form and symmetry celebrated.

9. Pragmatism → Grounded Root 🌱
	•	Symbol: Strong roots wrapping around a stone.
	•	Palette: Earth brown, moss green.
	•	Concept: Practical wisdom, adaptive growth.

10. Skepticism → Veil Orchid 🕵️
	•	Symbol: Orchid half in shadow, half in light.
	•	Palette: Cool blues and silver.
	•	Concept: Questioning, cautious pursuit of truth.

11. Traditionalism → Legacy Bloom 📜
	•	Symbol: Orchid resting on an old scroll or book.
	•	Palette: Aged parchment, muted greens.
	•	Concept: Honor, lineage, keeping knowledge alive.

12. Cynicism → Wild Sprout 🌵
	•	Symbol: Orchid bursting from cracked stone.
	•	Palette: Grays with a rebellious flash of magenta.
	•	Concept: Breaking convention, thriving outside the lines.

13. Aristotelian → Ordered Bloom 🔢
	•	Symbol: Orchid petals arranged in geometric pattern.
	•	Palette: Ivory, navy blue.
	•	Concept: Knowledge through order, classification, clarity.

14. Altruism → Gifted Orchid 🎁
	•	Symbol: Orchid offered in open hands.
	•	Palette: Soft lavender and warm gold.
	•	Concept: Sharing joy, orchids as gifts of spirit.


The Philosophy of Orchids: What’s Your Growing Style?
Is orchid growing just a hobby—or a reflection of your deepest values? Let’s find out.

For thousands of years, humans have asked:
• Why are we here?
• What is beauty?
• How do we create meaning?

Now, we ask:
Why do you grow orchids the way you do?
Maybe your orchid style mirrors ancient wisdom…

Platonist Grower? Always hunting the “perfect” orchid.
Stoic Grower? Patient, peaceful, and unfazed by setbacks.
Epicurean Grower? You just want joy, scent, and color!
Confucian Grower? Tradition, balance, and respect guide you.
Existential Grower? You experiment, learn, and take full responsibility.
Skeptic? You question every plant label and grow tip.

Across centuries, philosophers have searched for meaning. And yet, the way we grow orchids might reflect our deepest beliefs—about patience, beauty, truth, or joy. Are you a Stoic? A Romantic? A Skeptic? Take the quiz and discover your Orchid Philosophy.



[Quick Glance: Orchid Grower Archetypes]

Platonist – Chasing the perfect, rare orchid.
Stoic – Patient and peaceful, in sync with nature’s pace.
Epicurean – You grow for joy, color, and fragrance.
Confucian – You follow time-tested wisdom and tradition.
Existentialist – You create your own path and learn by doing.
Skeptic – You question everything (even this quiz).
Traditionalist – You trust the old ways.
Transcendentalist – Orchids are a spiritual journey.
Pragmatist – If it blooms, it works.











/****************************************************
 Orchid Philosophy Quiz Auto-Scorer v1 (clean ASCII)
 - Scores 10 questions (A-D) to philosophies.
 - Writes result, blurb, and badge (image) to the sheet.
 - Optional email to respondent.
****************************************************/

// ====== CONFIG ======
const RESPONSES_SHEET_NAME = 'Form Responses 1';
const SEND_EMAILS = true;  // set false to disable emailing
const EMAIL_SUBJECT = 'Your Orchid Philosophy Result';

// Badge artwork (you provided Imgur + Drive; we use Imgur for easy embedding)
const BADGES = {
  'Epicureanism': {
    name: 'Being in Bloom',
    imgur: 'https://imgur.com/a/FH4smYG',   // page
    image: 'https://i.imgur.com/6b5fQ4N.png' // direct image URL if you have it; replace placeholder
  },
  'Stoicism': {
    name: 'Enduring Bloom',
    imgur: 'https://imgur.com/a/O9jy9rP',
    image: 'https://i.imgur.com/6b5fQ4N.png' // replace with your direct image URL
  },
  'Transcendentalism': {
    name: 'Moonlight Reverie',
    imgur: 'https://imgur.com/a/HxR4aNu',
    image: 'https://i.imgur.com/6b5fQ4N.png'
  },
  'Idealism': {
    name: 'Vision Vine',
    imgur: 'https://imgur.com/a/9acVnRl',
    image: 'https://i.imgur.com/6b5fQ4N.png'
  }
};

// Friendly blurbs (positive, whimsical). You can tweak anytime.
const BLURBS = {
  'Epicureanism': 'Your orchids are a garden of joy. Each bloom is a reminder that life’s greatest pleasures are often the simplest: fragrance, color, the quiet moment of opening a new flower. You savor orchids with mindful delight.',
  'Stoicism': 'You let orchids follow their own rhythm. You embrace what comes: the withered leaf, the late spike, the sudden gift of blossoms. Peace in tending, not controlling.',
  'Confucianism': 'You cultivate harmony: light and shade, water and rest, discipline and care. Orchids reflect your respect for tradition, mentors, and community.',
  'Egoism': 'Your collection is a mirror of your taste and triumphs. You grow for the joy it brings you — and your orchids glow in that certainty.',
  'Nihilism': 'You see the beauty in impermanence. Blooms fade; that is their truth. You do not cling — and yet you marvel every time one returns.',
  'Renaissance Humanism': 'Your orchids are art. You admire symmetry, form, and grace — every flower a masterpiece, devotion worthy of beauty.',
  'Pragmatism': 'You test, adapt, and do what works. Your orchids bloom on practical wisdom and creative problem-solving.',
  'Transcendentalism': 'You sense the spirit in nature. Orchids are messengers of connection — roots in mystery, blossoms in wonder.',
  'Skepticism': 'You question, test, and refine. Your orchids thrive on curiosity as much as water and light.',
  'Traditionalism': 'Your orchids carry stories — divisions handed down, journals kept, lessons preserved. You honor the lineage of growers.',
  'Cynicism': 'You refuse to be boxed by rules. If it grows in a bottle, a log, or a teacup — you smile and let it bloom outside the lines.',
  'Idealism': 'You chase the perfect bloom — rare, exquisite, inspiring. Orchids give you a vision of perfection worth striving for.',
  'Aristotelian': 'You delight in names, order, and clarity. Each tag, a piece of a larger pattern. Wisdom begins with seeing what a thing is.'
};

// If a philosophy does not have badge art yet, use this default
const DEFAULT_BADGE = {
  name: 'Orchid Spirit',
  imgur: '',
  image: 'https://i.imgur.com/6b5fQ4N.png' // replace with a neutral default image
};

// ====== SCORING KEY ======
// Map Q# + choice letter to a philosophy label.
const KEY = {
  1: { A:'Cynicism', B:'Renaissance Humanism', C:'Nihilism', D:'Traditionalism' },
  2: { A:'Egoism', B:'Altruism', C:'Confucianism', D:'Nihilism' },
  3: { A:'Idealism', B:'Pragmatism', C:'Aristotelian', D:'Epicureanism' },
  4: { A:'Egoism', B:'Altruism', C:'Confucianism', D:'Nihilism' },
  5: { A:'Traditionalism', B:'Cynicism', C:'Skepticism', D:'Egoism' },
  6: { A:'Confucianism', B:'Pragmatism', C:'Stoicism', D:'Skepticism' },
  7: { A:'Renaissance Humanism', B:'Epicureanism', C:'Nihilism', D:'Transcendentalism' },
  8: { A:'Skepticism', B:'Altruism', C:'Egoism', D:'Stoicism' },
  9: { A:'Pragmatism', B:'Traditionalism', C:'Transcendentalism', D:'Stoicism' },
 10: { A:'Egoism', B:'Altruism', C:'Skepticism', D:'Confucianism' }
};

// Tie-breaker priority (left to right). You can change the order.
const TIE_PRIORITY = [
  'Epicureanism','Stoicism','Confucianism','Egoism','Nihilism',
  'Renaissance Humanism','Pragmatism','Transcendentalism','Skepticism',
  'Traditionalism','Cynicism','Idealism','Aristotelian','Altruism'
];

// ====== ENTRY POINTS ======

// Trigger for future submissions
function OnFormSubmit(e) {
  // e may be undefined when run manually; fall back to process last row
  const sh = getResponsesSheet_();
  const lastRow = sh.getLastRow();
  processRow_(lastRow);
}

// One-time backfill for all existing responses
function ProcessAllRowsOnce() {
  const sh = getResponsesSheet_();
  const last = sh.getLastRow();
  if (last < 2) return;
  ensureResultColumns_(sh);
  for (let r = 2; r <= last; r++) processRow_(r);
}

// ====== CORE ======

function processRow_(row) {
  const sh = getResponsesSheet_();
  ensureResultColumns_(sh);

  const header = sh.getRange(1,1,1,sh.getLastColumn()).getDisplayValues()[0];
  const values = sh.getRange(row,1,1,sh.getLastColumn()).getDisplayValues()[0];

  const qCols = findQuestionColumns_(header); // array of column indexes for Q1..Q10
  const picks = [];

  for (let i = 0; i < qCols.length; i++) {
    const qNum = i + 1;
    const ans = (values[qCols[i]] || '').trim();
    const letter = extractLetter_(ans); // 'A','B','C','D' or ''
    const phi = KEY[qNum] && letter ? KEY[qNum][letter] : '';
    if (phi) picks.push(phi);
    else picks.push('');
  }

  const tally = {};
  picks.forEach(p => { if (p) tally[p] = (tally[p] || 0) + 1; });

  const resultPhilosophy = chooseWinner_(tally);
  const blurb = BLURBS[resultPhilosophy] || 'You have a unique orchid spirit.';
  const badge = BADGES[resultPhilosophy] || DEFAULT_BADGE;

  // write outputs
  const cols = locateOutputColumns_(sh, header);
  sh.getRange(row, cols.colResult).setValue(resultPhilosophy);
  sh.getRange(row, cols.colScores).setValue(JSON.stringify(tally));

  const badgeName = badge.name || '';
  const badgeUrl = badge.imgur || '';
  const badgeImg = badge.image ? '=IMAGE("' + badge.image + '",1,120,120)' : '';

  sh.getRange(row, cols.colBlurb).setValue(blurb);
  sh.getRange(row, cols.colBadgeName).setValue(badgeName);
  sh.getRange(row, cols.colBadgeUrl).setValue(badgeUrl);
  sh.getRange(row, cols.colBadgeImg).setValue(badgeImg);

  // optional email
  if (SEND_EMAILS) {
    const emailCol = findEmailColumnIndex_(header);
    if (emailCol >= 0) {
      const to = (values[emailCol] || '').trim();
      if (to) {
        const body = buildEmailBody_(resultPhilosophy, blurb, badgeName, badgeUrl);
        try {
          MailApp.sendEmail({
            to: to,
            subject: EMAIL_SUBJECT,
            htmlBody: body
          });
          sh.getRange(row, cols.colEmailSent).setValue(new Date());
        } catch (err) {
          sh.getRange(row, cols.colEmailSent).setValue('Email error: ' + String(err));
        }
      }
    }
  }
}

// ====== HELPERS ======

function getResponsesSheet_(){
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const sh = ss.getSheetByName(RESPONSES_SHEET_NAME);
  if (!sh) throw new Error('Sheet not found: ' + RESPONSES_SHEET_NAME);
  return sh;
}

function ensureResultColumns_(sh){
  const header = sh.getRange(1,1,1,sh.getLastColumn()).getDisplayValues()[0];
  const need = [
    'Result Philosophy','Score Map (JSON)','Blurb',
    'Badge Name','Badge URL','Badge Image','Email Sent'
  ];
  // Add missing columns at end in order
  let added = 0;
  need.forEach(n => { if (header.indexOf(n) === -1) { sh.getRange(1, sh.getLastColumn()+1, 1, 1).setValue(n); added++; } });
  if (added) {
    // nothing else
  }
}

function locateOutputColumns_(sh, header){
  // ensure columns exist
  ensureResultColumns_(sh);
  const hdr = sh.getRange(1,1,1,sh.getLastColumn()).getDisplayValues()[0];

  const idx = (name) => hdr.indexOf(name) + 1; // 1-based
  return {
    colResult:    idx('Result Philosophy'),
    colScores:    idx('Score Map (JSON)'),
    colBlurb:     idx('Blurb'),
    colBadgeName: idx('Badge Name'),
    colBadgeUrl:  idx('Badge URL'),
    colBadgeImg:  idx('Badge Image'),
    colEmailSent: idx('Email Sent')
  };
}

function findQuestionColumns_(header){
  // pick the first 10 columns whose header starts with 1.,2.,...,10.
  const out = [];
  for (let q = 1; q <= 10; q++) {
    const re = new RegExp('^\\s*' + q + '\\.');
    const i = header.findIndex(h => re.test(String(h)));
    if (i >= 0) out.push(i);
  }
  return out;
}

function extractLetter_(answerText){
  // Try to capture leading choice letter A-D
  // e.g., "A. I choose..." or "A) ..." or just "A"
  const m = String(answerText || '').trim().match(/^[\s]*([ABCD])/i);
  return m ? m[1].toUpperCase() : '';
}

function chooseWinner_(tally){
  let best = '';
  let bestScore = -1;
  for (const k in tally){
    if (tally[k] > bestScore) { best = k; bestScore = tally[k]; }
  }
  // tie-break using priority list
  if (best === '') return 'Epicureanism';
  const ties = Object.keys(tally).filter(k => tally[k] === bestScore);
  if (ties.length <= 1) return best;
  for (let i = 0; i < TIE_PRIORITY.length; i++){
    if (ties.indexOf(TIE_PRIORITY[i]) >= 0) return TIE_PRIORITY[i];
  }
  return best;
}

function findEmailColumnIndex_(header){
  // find first column whose header contains "email"
  const i = header.findIndex(h => /email/i.test(String(h)));
  return i >= 0 ? i : -1;
}

function buildEmailBody_(phi, blurb, badgeName, badgeUrl){
  const badgeLine = badgeName ? ('<p><b>Your badge:</b> ' + badgeName + (badgeUrl ? (' — <a href="'+badgeUrl+'">view</a>') : '') + '</p>') : '';
  return (
    '<div style="font-family:Arial,Helvetica,sans-serif;line-height:1.5">' +
    '<h2 style="margin:0 0 8px 0">Your Orchid Philosophy: ' + phi + '</h2>' +
    '<p>' + blurb + '</p>' +
    badgeLine +
    '<p style="color:#888">This message was generated automatically from your quiz responses.</p>' +
    '</div>'
  );
}


Google app script 

/**** FCOS Quiz — Full Setup + Results Email + Friend Invitations ****************
 * One-paste install. Creates/updates:
 *   - Philosophies (16 rows with long-form content + BadgeLink)
 *   - Results (scaffold for Name, Email, Philosophy + referral columns)
 * Menu actions:
 *   - Build/Refresh Sheets
 *   - Preview Email (selected row)
 *   - Send Email (selected row)
 *   - Send All Pending
 *   - Send Invite (selected row)
 *   - Send All Invites Pending
 * Emails:
 *   - Result email: FCOS logo header, badge prominent, large readable text,
 *     haiku styled, 3 CTAs, nonprofit footer, P.S. invite a friend.
 *   - Invitation email: logo header, clear button to take quiz, optional personal note.
 ******************************************************************************/

//////////////////// CONFIG ////////////////////
const CFG = {
  SHEET_PHILOS: 'Philosophies',
  SHEET_RESULTS: 'Results',

  // Links:
  MEMBERSHIP_URL: 'https://fivecitiesorchidsociety.app.neoncrm.com/forms/12',
  NEWSLETTER_URL: 'https://fivecitiesorchidsociety.app.neoncrm.com/subscribe.jsp?subscription=6',
  HOMEPAGE_URL: 'https://www.fcos.org',

  // If you have a Google Form / quiz URL, put it here:
  QUIZ_URL: 'https://www.fcos.org', // replace later with your Google Form link

  // Images:
  LOGO_URL: 'https://i.imgur.com/WK10q2B.png', // swap for your direct PNG/JPG if you have it

  // Email identity:
  FROM_NAME: 'Five Cities Orchid Society',
  SUBJECT_PREFIX: 'Your Orchid Philosophy: ',
  INVITE_SUBJECT: 'You’re invited to take the Ultimate Orchid Philosophy Quiz!',
};

//////////////////// MENU ////////////////////
function onOpen() {
  SpreadsheetApp.getUi()
    .createMenu('FCOS Quiz')
    .addItem('Build/Refresh Sheets', 'buildAll')
    .addSeparator()
    .addItem('Preview Email (selected row)', 'previewSelectedEmail')
    .addItem('Send Email (selected row)', 'sendSelectedEmail')
    .addItem('Send All Pending', 'sendAllPending')
    .addSeparator()
    .addItem('Send Invite (selected row)', 'sendSelectedInvite')
    .addItem('Send All Invites Pending', 'sendAllInvitesPending')
    .addToUi();
}

//////////////////// BUILDERS ////////////////////
function buildAll() {
  const ss = SpreadsheetApp.getActive();
  const shP = ensureSheet(ss, CFG.SHEET_PHILOS);
  const shR = ensureSheet(ss, CFG.SHEET_RESULTS);

  buildPhilosophies(shP);
  buildResultsScaffold(shR);

  SpreadsheetApp.getActive().toast('Setup complete. Philosophies + Results are ready.', 'FCOS Quiz', 8);
}

function ensureSheet(ss, name) {
  let sh = ss.getSheetByName(name);
  if (!sh) sh = ss.insertSheet(name);
  return sh;
}

function clearAndSetHeader(sh, headers) {
  sh.clear();
  sh.getRange(1, 1, 1, headers.length).setValues([headers]);
  sh.setFrozenRows(1);
  for (let c = 1; c <= headers.length; c++) {
    sh.setColumnWidth(c, Math.min(600, 180 + headers[c-1].length * 7));
  }
}

function buildResultsScaffold(shR) {
  const headers = [
    'Timestamp',
    'Name',
    'Email',
    'Philosophy',              // must match "Title" in Philosophies
    'BadgeLink (auto)',
    'Email Sent At',
    'Last Error',
    // Referral fields:
    'Friend Name',
    'Friend Email',
    'Invite Message (optional)',
    'Invite Sent At',
    'Invite Error'
  ];
  const existing = shR.getRange(1,1,1,Math.max(1, shR.getLastColumn())).getValues()[0];
  const needReset = existing.join('').trim()==='';
  if (needReset) {
    clearAndSetHeader(shR, headers);
  } else {
    // Ensure missing headers are appended in order
    const have = new Set(existing);
    const add = headers.filter(h => !have.has(h));
    if (add.length) {
      shR.insertColumnsAfter(shR.getLastColumn() || 1, add.length);
      shR.getRange(1, existing.length+1, 1, add.length).setValues([add]);
    }
  }

  // Auto BadgeLink via VLOOKUP
  const headRow = shR.getRange(1,1,1,shR.getLastColumn()).getValues()[0];
  const colPhilos = headRow.indexOf('Philosophy')+1;
  const colBadge  = headRow.indexOf('BadgeLink (auto)')+1;
  const philosRange = `'${CFG.SHEET_PHILOS}'!A2:G`;
  if (colPhilos>0 && colBadge>0) {
    const f = `=IFERROR(VLOOKUP($${columnLetter(colPhilos)}2, ${philosRange}, 7, FALSE), "")`;
    shR.getRange(2, colBadge, Math.max(1, shR.getMaxRows()-1), 1).setFormula(f);
  }
}

function columnLetter(n) {
  let s = '';
  while (n > 0) { const m = (n - 1) % 26; s = String.fromCharCode(65 + m) + s; n = (n - m - 1) / 26; }
  return s;
}

function buildPhilosophies(sh) {
  const headers = ['Title','LifePhilosophy','OrchidReflection','Haiku','Practical','Science','BadgeLink'];
  clearAndSetHeader(sh, headers);
  const rows = PHILOSOPHY_ROWS();
  sh.getRange(2, 1, rows.length, headers.length).setValues(rows);
  sh.autoResizeColumns(1, headers.length);
}

//////////////////// DATA: 16 PHILOSOPHIES ////////////////////
function PHILOSOPHY_ROWS() {
  return [
    ['Stoic Bloom',
     'You accept life as it comes—steady, patient, and grounded. Stoicism values inner steadiness in the face of change; you find strength in cycles rather than in control.',
     'Orchids teach you to honor time. A bud that takes a year is not a delay—it is the lesson.',
     'Silent orchid waits,\nWinter frost upon its leaves,\nSpring reveals its truth.',
     'You do not force bloom. You repot when new roots emerge and allow rest when needed.',
     'Many Paphiopedilum and Cymbidium rely on cool nights and rest phases to trigger flowering—patience is adaptive.',
     'https://imgur.com/a/7rzV2ZV'],
    ['Self Bloom',
     'You believe joy begins with self-respect. Egoism here means choosing what truly delights you and allowing that light to shine.',
     'Your collection reflects your taste—rare, bold, personal. You grow for your own joy.',
     'Mirror of the self,\nBlooming for no eyes but mine,\nJoy in solitude.',
     'You bring home the plant that thrills you—even if it’s not “trendy.”',
     'Autogamy (self-pollination) occurs in some orchids—a reminder that self-sufficiency can be a valid strategy.',
     'https://imgur.com/a/92asMXl'],
    ['Altruism',
     'Your first instinct is to share. Beauty multiplies when given, and orchids are your living gifts.',
     'Divisions and keikis become bridges—friendships rooted in generosity.',
     'Hands give living gifts,\nRoots entwine across the earth,\nJoy grows when it’s shared.',
     'You divide thriving plants for new members and donate to auctions.',
     'Keikis (on Phalaenopsis/Dendrobium) are natural clones—biology built for sharing.',
     'https://imgur.com/a/Hcjw1Gv'],
    ['Pragmatic Bloomer',
     'You value what works. Pragmatism is your compass—test, observe, keep what helps the plant thrive.',
     'For you, orchids are experiments that bloom into methods.',
     'Moss, bark, glass, or clay,\nRoots decide what thrives in time,\nBloom proves what is true.',
     'You try semi-hydro, change light, adjust media—then standardize what blooms.',
     'Hybrids often tolerate varied conditions; adaptability wins in cultivation.',
     'https://imgur.com/a/56VvvGz'],
    ['Endless Night Bloom',
     'You accept impermanence. Nihilism, to you, means seeing beauty without clinging to it.',
     'Fallen petals are facts, not failures. You honor moments as they are.',
     'Petals drift away,\nSilent truth beneath the stem,\nNothing holds for long.',
     'You enjoy blooms fully and accept their passing without despair.',
     'Many Stanhopea/Sobralia flowers last a day—evolution trades duration for intensity.',
     'https://imgur.com/a/wSgrdLl'],
    ['Wild Spirit',
     'You prize authenticity over convention. You grow with instinct and courage.',
     'Orchids in your care sprawl, mount, and surprise—alive beyond rules.',
     'Roots spill from the pot,\nUnruly, untamed, alive,\nTruth grows without rules.',
     'You mount epiphytes on wood, try outdoor microclimates, and ignore purist debates.',
     'Wild orchids colonize cliffs, trees, roadsides—fitness over formality.',
     'https://imgur.com/a/JvdgeyY'],
    ['Fragrance Seeker',
     'You savor life through the senses. Epicurean by heart, you collect delight.',
     'Blooms are not just seen—they are experienced.',
     'Sweet scent fills the air,\nPetals glowing, fleeting joy,\nMoments made to keep.',
     'You seek Rhynchostylis, Brassavola, and perfumed Oncidiums.',
     'Fragrance evolved for pollinator attraction—your delight echoes ecology.',
     'https://imgur.com/a/gwzILYd'],
    ['Vision Vine',
     'You chase ideals—purity of form, rare color, perfect symmetry. Idealism guides your eye.',
     'Each plant is a step toward the vision you hold.',
     'Unreachable star,\nPetals whisper higher truths,\nDreams take root in green.',
     'You prize Paphiopedilum rothschildianum, classic Cattleyas, and line-bred perfection.',
     'Hybridizing pursues ideal traits; symmetry is a core judging criterion.',
     'https://imgur.com/a/9acVnRl'],
    ['Royal Bloom',
     'You honor tradition and lineage. Beauty for you is heritage made visible.',
     'You see orchids as living heirlooms—carried from grower to grower.',
     'Velvet petals curve,\nCrafted by a careful hand,\nLiving heritage.',
     'You value awarded clones and divisions with provenance.',
     'AOS judging codifies standards—tradition shaping modern beauty.',
     'https://imgur.com/a/AlFdGYN'],
    ['Moonlight Reverie',
     'Nature is sacred to you. You find meaning beyond the material, in quiet hours with living things.',
     'A night-fragrant bloom feels like a message from the world itself.',
     'Moonlight on soft blooms,\nWhispers rise from silent leaves,\nSpirit breathes in green.',
     'You place night-fragrant orchids where you rest or reflect.',
     'Brassavola nodosa emits scent at night—timed to moth pollinators.',
     'https://imgur.com/a/HxR4aNu'],
    ['Harmony',
     'You value respect, balance, and right relationships. Care is a form of gratitude.',
     'Your bench reflects order—a place for each plant’s needs.',
     'Guided by the past,\nHands respect the root and leaf,\nHarmony endures.',
     'You gift responsibly and encourage good stewardship.',
     'Balanced light/humidity/airflow are keystones of orchid health.',
     'https://imgur.com/a/Q43hN1U'],
    ['Questioning Bloom',
     'You seek truth through doubt. Skepticism protects you from easy answers.',
     'Labels, culture sheets, photos—you verify before you trust.',
     'Each leaf asks a why,\nRoots spiral into the truth,\nAnswers bloom with doubt.',
     'You research identity and keep notes until evidence repeats.',
     'Orchid taxonomy is dynamic; names change with new data.',
     'https://imgur.com/a/MNIglMs'],
    ['Order & Form',
     'You love clarity and classification. Understanding increases beauty.',
     'Patterns in petals and growth tell you how the plant “thinks.”',
     'Each leaf has its place,\nPatterns hide in nature’s code,\nTruth in order blooms.',
     'You organize by genus and track bloom cycles.',
     '~30,000 orchid species: order helps minds grasp diversity.',
     'https://imgur.com/a/ukuPLxh'],
    ['Being in Bloom',
     'You live in the present. Every blossom is a celebration.',
     'You let orchids remind you to notice what is already here.',
     'Sun on open bloom,\nMorning breathes a golden note,\nNow is everything.',
     'You keep showy hybrids where you’ll see them daily.',
     'Light-driven opening/closing rhythms make presence visible.',
     'https://imgur.com/a/FH4smYG'],
    ['Enduring Bloom',
     'Resilience is your north star. You treasure returns and reliable grace.',
     'You love plants that reward steady care with faithful bloom.',
     'Storms will come and pass,\nRoots remember how to hold,\nBloom returns in time.',
     'You keep long-lived workhorses (Oncidium, Phalaenopsis) thriving year to year.',
     'Stress–recovery cycles can enhance flowering; resilience pays.',
     'https://imgur.com/a/O9jy9rP'],
    ['Wild Bloom',
     'You celebrate what won’t be tamed. Beauty, for you, lives just outside control.',
     'Your orchids sprawl, root, and surprise—alive and authentic.',
     'Edge of ordered beds,\nGreen defies the gardener,\nLife writes its own map.',
     'You let epiphytes wander over mounts and stone.',
     'Colonization of rough habitats is common—fitness beats neatness.',
     'https://imgur.com/a/PzuiRKG']
  ];
}

//////////////////// EMAIL: RESULT ////////////////////
function buildEmailHtml(philoTitle, badgeUrl, life, reflect, haiku, practical, science, recipientName) {
  const safeName = recipientName || 'Friend';
  const logoHtml = CFG.LOGO_URL
    ? `<img src="${CFG.LOGO_URL}" alt="Five Cities Orchid Society Logo" style="max-width:180px;height:auto;margin:0 auto 10px auto;display:block;">`
    : '';

  return `
  <div style="font-family:Arial, Helvetica, sans-serif; color:#1a1a1a; line-height:1.6; font-size:18px;">
    <div style="text-align:center; padding:10px 0;">${logoHtml}</div>

    <h1 style="text-align:center; color:#2b6a30; font-size:28px; margin:8px 0;">Your Orchid Philosophy: ${escapeHtml(philoTitle)}</h1>

    <div style="text-align:center; margin:16px 0;">
      ${badgeUrl ? `<a href="${badgeUrl}" target="_blank" style="text-decoration:none;">
        <img src="${badgeUrl}" alt="${escapeHtml(philoTitle)} Badge" style="max-width:360px;width:100%;height:auto;border:0;">
      </a>` : ''}
    </div>

    <p>Hi ${escapeHtml(safeName)},</p>

    <p><strong>${escapeHtml(philoTitle)}</strong> reflects how you meet the world—and how you meet your orchids.</p>

    <h2 style="color:#2b6a30; font-size:22px; margin:14px 0 6px;">Your Life Philosophy</h2>
    <p>${escapeHtml(life)}</p>

    <h2 style="color:#2b6a30; font-size:22px; margin:14px 0 6px;">Orchid Reflection</h2>
    <p>${escapeHtml(reflect)}</p>

    <div style="text-align:center; margin:18px 0; font-family:'Brush Script MT', 'Segoe Script', 'Apple Chancery', cursive; font-size:22px; color:#3a3a3a;">
      ${escapeHtml(haiku).replace(/\n/g,'<br>')}
    </div>

    <h3 style="color:#2b6a30; font-size:20px; margin:14px 0 6px;">Practical Tip</h3>
    <p>${escapeHtml(practical)}</p>

    <h3 style="color:#2b6a30; font-size:20px; margin:14px 0 6px;">Botanical Note</h3>
    <p>${escapeHtml(science)}</p>

    <hr style="border:0;border-top:1px solid #d0d0d0; margin:22px 0;">

    <p style="font-size:18px;"><strong>Keep blooming with us!</strong></p>
    <p>
      🌿 <a href="${CFG.MEMBERSHIP_URL}" target="_blank">Join the Five Cities Orchid Society</a><br>
      📰 <a href="${CFG.NEWSLETTER_URL}" target="_blank">Sign up for our Free Monthly Newsletter</a><br>
      🏡 <a href="${CFG.HOMEPAGE_URL}" target="_blank">Visit our Website</a>
    </p>

    <p style="margin-top:12px;">
      <em>P.S. Loved this quiz? Invite a friend to discover their Orchid Philosophy:</em><br>
      <a href="${CFG.QUIZ_URL}" target="_blank" style="font-weight:bold;">Take the Ultimate Orchid Philosophy Quiz</a>
    </p>

    <hr style="border:0;border-top:1px solid #d0d0d0; margin:22px 0;">

    <p style="font-size:16px; color:#555;">
      <em>Established in 1990, the Five Cities Orchid Society is a 501(c)(3) nonprofit dedicated to promoting the love,
      knowledge, and conservation of orchids for growers of all levels.</em>
    </p>

    <p style="font-size:16px; margin-top:6px;"><strong>Five Cities Orchid Society</strong><br>
      <a href="${CFG.HOMEPAGE_URL}">${CFG.HOMEPAGE_URL}</a>
    </p>
  </div>`;
}

//////////////////// EMAIL: INVITATION ////////////////////
function buildInviteHtml(friendName, senderName, inviteMsg) {
  const name = friendName || 'Friend';
  const from = senderName || 'A fellow orchid lover';
  const msg = inviteMsg ? `<p style="background:#f7f7f7;padding:12px;border-left:4px solid #2b6a30;">
  ${escapeHtml(inviteMsg)}</p>` : '';

  const logoHtml = CFG.LOGO_URL
    ? `<img src="${CFG.LOGO_URL}" alt="Five Cities Orchid Society Logo" style="max-width:180px;height:auto;margin:0 auto 10px auto;display:block;">`
    : '';

  return `
  <div style="font-family:Arial, Helvetica, sans-serif; color:#1a1a1a; line-height:1.6; font-size:18px;">
    <div style="text-align:center; padding:10px 0;">${logoHtml}</div>

    <h1 style="text-align:center; color:#2b6a30; font-size:26px; margin:8px 0;">You’re invited to the Ultimate Orchid Philosophy Quiz</h1>

    <p>Hi ${escapeHtml(name)},</p>
    <p>${escapeHtml(from)} thought you’d enjoy discovering your personal <strong>Orchid Philosophy</strong>—a fun, reflective quiz that blends
    life philosophy, orchid love, and a beautiful badge you can share.</p>

    ${msg}

    <div style="text-align:center; margin:24px 0;">
      <a href="${CFG.QUIZ_URL}" target="_blank"
         style="background:#2b6a30;color:#fff;padding:12px 20px;border-radius:6px;
                text-decoration:none;font-size:18px;display:inline-block;">
        Take the Quiz
      </a>
    </div>

    <p style="margin-top:12px;">After you submit your answers, we’ll email your result with a custom badge,
    an orchid-themed haiku, and practical grower tips—beautifully formatted.</p>

    <hr style="border:0;border-top:1px solid #d0d0d0; margin:22px 0;">
    <p style="font-size:16px; color:#555;">
      <em>Established in 1990, the Five Cities Orchid Society is a 501(c)(3) nonprofit dedicated to promoting the love,
      knowledge, and conservation of orchids for growers of all levels.</em>
    </p>

    <p style="font-size:16px; margin-top:6px;"><strong>Five Cities Orchid Society</strong><br>
      <a href="${CFG.HOMEPAGE_URL}">${CFG.HOMEPAGE_URL}</a>
    </p>
  </div>`;
}

//////////////////// SEND / PREVIEW (RESULT EMAIL) ////////////////////
function previewSelectedEmail() {
  const ctx = readSelectedResultRow_();
  if (!ctx) { uiAlert('Select exactly one row in the Results sheet.'); return; }
  const html = buildEmailForContext_(ctx).html;
  const htmlOutput = HtmlService.createHtmlOutput(html).setWidth(720).setHeight(900);
  SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'Preview: FCOS Result Email');
}

function sendSelectedEmail() {
  const ctx = readSelectedResultRow_();
  if (!ctx) { uiAlert('Select exactly one row in the Results sheet.'); return; }
  const built = buildEmailForContext_(ctx);
  if (!built.ok) { uiAlert(built.msg); return; }
  GmailApp.sendEmail(ctx.email, CFG.SUBJECT_PREFIX + ctx.philosophy, stripHtml_(built.html), {name: CFG.FROM_NAME, htmlBody: built.html});
  markTimestamp_(ctx.range, 'Email Sent At');
  clearError_(ctx.range, 'Last Error');
  uiAlert('Email sent ✅');
}

function sendAllPending() {
  const shR = SpreadsheetApp.getActive().getSheetByName(CFG.SHEET_RESULTS);
  if (!shR) { uiAlert('Results sheet not found. Run "Build/Refresh Sheets" first.'); return; }
  const vals = shR.getDataRange().getValues();
  if (vals.length <= 1) { uiAlert('No data to send.'); return; }

  const head = vals[0];
  const cName  = head.indexOf('Name');
  const cEmail = head.indexOf('Email');
  const cPhilo = head.indexOf('Philosophy');
  const cSent  = head.indexOf('Email Sent At');
  const cErr   = head.indexOf('Last Error');

  let sent = 0, skipped = 0;
  for (let r = 1; r < vals.length; r++) {
    const row = vals[r];
    if (!row[cEmail] || !row[cPhilo]) { skipped++; continue; }
    if (row[cSent]) { continue; } // already sent
    const ctx = { rowIndex: r+1, name: row[cName] || 'Friend', email: row[cEmail], philosophy: row[cPhilo] };
    const built = buildEmailForContext_(ctx);
    if (!built.ok) {
      setErrorAt_(shR, r+1, 'Last Error', built.msg);
      continue;
    }
    GmailApp.sendEmail(ctx.email, CFG.SUBJECT_PREFIX + ctx.philosophy, stripHtml_(built.html), {name: CFG.FROM_NAME, htmlBody: built.html});
    setTimestampAt_(shR, r+1, 'Email Sent At', new Date());
    setErrorAt_(shR, r+1, 'Last Error', '');
    sent++;
    Utilities.sleep(200);
  }
  uiAlert(`Send complete.\nSent: ${sent}\nSkipped (missing email/philosophy): ${skipped}`);
}

function buildEmailForContext_(ctx) {
  const shP = SpreadsheetApp.getActive().getSheetByName(CFG.SHEET_PHILOS);
  if (!shP) return { ok:false, msg:'Philosophies sheet not found. Run Build/Refresh first.' };

  const vals = shP.getDataRange().getValues();
  const head = vals[0];
  const cTitle = head.indexOf('Title');
  const cLife  = head.indexOf('LifePhilosophy');
  const cRefl  = head.indexOf('OrchidReflection');
  const cHaiku = head.indexOf('Haiku');
  const cPrac  = head.indexOf('Practical');
  const cSci   = head.indexOf('Science');
  const cBadge = head.indexOf('BadgeLink');

  let found = null;
  for (let i=1;i<vals.length;i++){
    if (String(vals[i][cTitle]).trim().toLowerCase() === String(ctx.philosophy).trim().toLowerCase()){
      found = vals[i]; break;
    }
  }
  if (!found) return { ok:false, msg:'Philosophy not found in Philosophies sheet: ' + ctx.philosophy };

  const html = buildEmailHtml(
    found[cTitle], found[cBadge],
    found[cLife], found[cRefl], found[cHaiku], found[cPrac], found[cSci],
    ctx.name
  );
  return { ok:true, html };
}

//////////////////// INVITES (FRIEND REFERRAL) ////////////////////
function sendSelectedInvite() {
  const ctx = readSelectedResultRow_();
  if (!ctx) { uiAlert('Select exactly one row in the Results sheet.'); return; }

  const shR = ctx.range.getSheet();
  const head = shR.getRange(1,1,1,shR.getLastColumn()).getValues()[0];
  const row  = shR.getRange(ctx.rowIndex,1,1,shR.getLastColumn()).getValues()[0];

  const cFriendName = head.indexOf('Friend Name');
  const cFriendMail = head.indexOf('Friend Email');
  const cMsg        = head.indexOf('Invite Message (optional)');

  const friendName = row[cFriendName] || 'Friend';
  const friendEmail = row[cFriendMail];
  const note = row[cMsg] || '';

  if (!friendEmail) { uiAlert('Missing Friend Email on the selected row.'); return; }

  const html = buildInviteHtml(friendName, ctx.name, note);
  GmailApp.sendEmail(friendEmail, CFG.INVITE_SUBJECT, stripHtml_(html), {name: CFG.FROM_NAME, htmlBody: html});
  markTimestamp_(ctx.range, 'Invite Sent At');
  clearError_(ctx.range, 'Invite Error');
  uiAlert('Invitation sent ✅');
}

function sendAllInvitesPending() {
  const shR = SpreadsheetApp.getActive().getSheetByName(CFG.SHEET_RESULTS);
  if (!shR) { uiAlert('Results sheet not found.'); return; }
  const vals = shR.getDataRange().getValues();
  if (vals.length <= 1) { uiAlert('No rows.'); return; }

  const head = vals[0];
  const cName = head.indexOf('Name');
  const cFriendName = head.indexOf('Friend Name');
  const cFriendMail = head.indexOf('Friend Email');
  const cMsg = head.indexOf('Invite Message (optional)');
  const cInvSent = head.indexOf('Invite Sent At');
  const cInvErr = head.indexOf('Invite Error');

  let sent = 0, skipped = 0;
  for (let r=1; r<vals.length; r++) {
    const row = vals[r];
    if (!row[cFriendMail]) { skipped++; continue; }
    if (row[cInvSent]) { continue; }
    try {
      const friendName = row[cFriendName] || 'Friend';
      const senderName = row[cName] || 'A fellow orchid lover';
      const note = row[cMsg] || '';
      const html = buildInviteHtml(friendName, senderName, note);
      GmailApp.sendEmail(row[cFriendMail], CFG.INVITE_SUBJECT, stripHtml_(html), {name: CFG.FROM_NAME, htmlBody: html});
      shR.getRange(r+1, cInvSent+1).setValue(new Date());
      shR.getRange(r+1, cInvErr+1).setValue('');
      sent++;
      Utilities.sleep(200);
    } catch (e) {
      shR.getRange(r+1, cInvErr+1).setValue(String(e));
    }
  }
  uiAlert(`Invitations complete.\nSent: ${sent}\nSkipped (missing friend email): ${skipped}`);
}

//////////////////// UTIL ////////////////////
function escapeHtml(s){
  return String(s || '')
    .replace(/&/g,'&amp;').replace(/</g,'&lt;')
    .replace(/>/g,'&gt;').replace(/"/g,'&quot;');
}

function stripHtml_(html) {
  return html.replace(/<style[\s\S]*?<\/style>/gi,'')
             .replace(/<script[\s\S]*?<\/script>/gi,'')
             .replace(/<[^>]+>/g,'')
             .replace(/&nbsp;/g,' ')
             .replace(/&amp;/g,'&')
             .replace(/&lt;/g,'<')
             .replace(/&gt;/g,'>');
}

function uiAlert(msg){ SpreadsheetApp.getUi().alert(msg); }

function readSelectedResultRow_() {
  const shR = SpreadsheetApp.getActive().getSheetByName(CFG.SHEET_RESULTS);
  if (!shR) return null;
  const sel = shR.getActiveRange();
  if (!sel || sel.getNumRows() !== 1) return null;
  const r = sel.getRow();
  if (r === 1) return null; // header

  const head = shR.getRange(1,1,1,shR.getLastColumn()).getValues()[0];
  const row  = shR.getRange(r,1,1,shR.getLastColumn()).getValues()[0];
  return {
    range: shR.getRange(r,1,1,shR.getLastColumn()),
    rowIndex: r,
    name: row[ head.indexOf('Name') ],
    email: row[ head.indexOf('Email') ],
    philosophy: row[ head.indexOf('Philosophy') ]
  };
}

function markTimestamp_(range, colHeader) {
  const sheet = range.getSheet();
  const head = sheet.getRange(1,1,1,sheet.getLastColumn()).getValues()[0];
  const idx = head.indexOf(colHeader);
  if (idx >= 0) range.getCell(1, idx+1).setValue(new Date());
}

function clearError_(range, colHeader) {
  const sheet = range.getSheet();
  const head = sheet.getRange(1,1,1,sheet.getLastColumn()).getValues()[0];
  const idx = head.indexOf(colHeader);
  if (idx >= 0) range.getCell(1, idx+1).setValue('');
}

function setTimestampAt_(sh, rowIndex, colHeader, ts) {
  const head = sh.getRange(1,1,1,sh.getLastColumn()).getValues()[0];
  const idx = head.indexOf(colHeader);
  if (idx >= 0) sh.getRange(rowIndex, idx+1).setValue(ts);
}
function setErrorAt_(sh, rowIndex, colHeader, msg) {
  const head = sh.getRange(1,1,1,sh.getLastColumn()).getValues()[0];
  const idx = head.indexOf(colHeader);
  if (idx >= 0) sh.getRange(rowIndex, idx+1).setValue(msg);
}


Widget Code

<!-- ORCHID PHILOSOPHY FLIP-CARD WIDGET -->
<div id="orchid-philocards"></div>

<style>
  .phi-wrap{max-width:920px;margin:0 auto;font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial;}
  .phi-card{position:relative;width:100%;aspect-ratio:16/9;perspective:1200px;margin:18px 0;}
  .phi-face{position:absolute;inset:0;border-radius:16px;box-shadow:0 8px 24px rgba(0,0,0,.15);
            backface-visibility:hidden;display:flex;flex-direction:column;justify-content:center;
            align-items:center;padding:28px;text-align:center;transition:transform .6s;}
  .phi-front{background:#2f3a33;color:#eaf3ed} /* Stoic front default; will be themed per slide */
  .phi-back{background:#eaf3ed;color:#1f2a23;transform:rotateY(180deg)}
  .phi-title{font-weight:700;font-size:clamp(20px,3.6vw,32px);margin:0 0 8px}
  .phi-sub{opacity:.9;max-width:60ch}
  .phi-actions{position:absolute;inset:auto 16px 16px auto;display:flex;gap:10px}
  .phi-btn{cursor:pointer;border:none;border-radius:999px;padding:10px 14px;font-weight:600}
  .phi-next{background:#ffffff;color:#222}
  .phi-cta{background:#5c2d91;color:#fff;text-decoration:none}
  .phi-flipped .phi-front{transform:rotateY(180deg)}
  .phi-flipped .phi-back{transform:rotateY(360deg)}
  .phi-nav{display:flex;justify-content:space-between;align-items:center;margin-top:10px}
  .phi-arrow{cursor:pointer;border:none;background:transparent;font-size:22px;padding:8px}
  .phi-step{font-size:13px;opacity:.7}
  @media (prefers-reduced-motion: reduce){.phi-face{transition:none}}
</style>

<script>
(() => {
  // 1) Data (you can swap this for a JSON fetch later)
  const DATA = [
    {
      key:"Stoicism",
      theme:{front:"#2f3a33",frontText:"#eaf3ed",back:"#eaf3ed",backText:"#1f2a23"},
      historyTitle:"Stoicism",
      historyText:"Ancient philosophy of inner peace by accepting what cannot be controlled.",
      orchidTitle:"The Enduring Bloom",
      orchidText:"The Stoic grower tends orchids with patience; every bloom is a gift in its own time."
    },
    {
      key:"Epicureanism",
      theme:{front:"#b4557a",frontText:"#fff7fa",back:"#f4e1a6",backText:"#5b3a2c"},
      historyTitle:"Epicureanism",
      historyText:"Seek simple joys, friendship, and savor the present moment.",
      orchidTitle:"The Joyful Bloom",
      orchidText:"You delight in orchids for fragrance, color, and present joy."
    },
    {
      key:"Confucianism",
      theme:{front:"#196b5a",frontText:"#eafff9",back:"#e7d9a0",backText:"#2e2a1b"},
      historyTitle:"Confucianism",
      historyText:"Harmony, respect, and wisdom passed down across generations.",
      orchidTitle:"The Harmony Orchid",
      orchidText:"You grow with balance, tradition, and learned wisdom."
    },
    // ...add the rest of your philosophies here...
    // FINAL CTA CARD:
    {
      key:"CTA",
      cta:true,
      title:"Ready to discover yours?",
      sub:"Take the Ultimate Orchid Philosophy Quiz and get your badge + haiku.",
      button:"Take the Quiz",
      href:"YOUR_QUIZ_URL"
    }
  ];

  // 2) State
  let index = 0;
  const el = document.getElementById('orchid-philocards');
  el.className = 'phi-wrap';

  function render() {
    const item = DATA[index];
    el.innerHTML = ""; // clear

    if (item.cta) {
      const box = document.createElement('div');
      box.className = 'phi-card';
      const face = document.createElement('div');
      face.className = 'phi-face phi-back';
      face.style.background = '#efe7ff';
      face.style.color = '#1e1140';
      face.innerHTML = `
        <h2 class="phi-title">${item.title}</h2>
        <p class="phi-sub">${item.sub}</p>
        <div class="phi-actions" style="position:static;margin-top:18px;justify-content:center">
          <a class="phi-btn phi-cta" href="${item.href}" rel="noopener">Take the Quiz</a>
        </div>
      `;
      box.appendChild(face);
      el.appendChild(box);
    } else {
      const card = document.createElement('div');
      card.className = 'phi-card';

      const front = document.createElement('div');
      front.className = 'phi-face phi-front';
      front.style.background = item.theme.front;
      front.style.color = item.theme.frontText;
      front.innerHTML = `
        <h2 class="phi-title">${item.historyTitle}</h2>
        <p class="phi-sub">${item.historyText}</p>
        <div class="phi-actions">
          <button class="phi-btn phi-next" aria-label="Show orchid reflection">Next ⟶</button>
        </div>
      `;

      const back = document.createElement('div');
      back.className = 'phi-face phi-back';
      back.style.background = item.theme.back;
      back.style.color = item.theme.backText;
      back.innerHTML = `
        <h2 class="phi-title">${item.orchidTitle}</h2>
        <p class="phi-sub">${item.orchidText}</p>
        <div class="phi-actions">
          <button class="phi-btn phi-next" aria-label="Go to next philosophy">Next ⟶</button>
        </div>
      `;

      card.appendChild(front);
      card.appendChild(back);
      el.appendChild(card);

      // Flip on "Next" first, then advance on second "Next"
      front.querySelector('.phi-next').addEventListener('click', () => {
        card.classList.add('phi-flipped');
      });
      back.querySelector('.phi-next').addEventListener('click', () => {
        index = Math.min(index + 1, DATA.length - 1);
        render();
      });
    }

    // Bottom nav (prev/next + step)
    const nav = document.createElement('div');
    nav.className = 'phi-nav';
    nav.innerHTML = `
      <button class="phi-arrow" ${index===0 ? 'disabled':''} aria-label="Previous">⟵</button>
      <div class="phi-step">${Math.min(index+1, DATA.length)} / ${DATA.length}</div>
      <button class="phi-arrow" ${index===DATA.length-1 ? 'disabled':''} aria-label="Next">⟶</button>
    `;
    el.appendChild(nav);

    const [prevBtn,,nextBtn] = nav.querySelectorAll('.phi-arrow');
    prevBtn.addEventListener('click', () => { if(index>0){ index--; render(); }});
    nextBtn.addEventListener('click', () => { if(index<DATA.length-1){ index++; render(); }});
  }

  render();
})();
</script>


<iframe src="https://your-hosted-widget.example/phi-cards.html" width="100%" height="560" style="border:0;border-radius:12px;overflow:hidden;"></iframe>



<script>
(() => {
  const DATA = [
    {
      key:"Platonism",
      theme:{front:"#4b3a7a",frontText:"#f3ecff",back:"#efe9ff",backText:"#281b4a"},
      historyTitle:"Platonism",
      historyText:"Beyond the imperfect world lies an ideal realm of perfect forms.",
      orchidTitle:"The Perfect Bloom",
      orchidText:"Chasing flawless symmetry and rare cultivars closest to an 'ideal bloom.'"
    },
    {
      key:"Stoicism",
      theme:{front:"#2f3a33",frontText:"#eaf3ed",back:"#eaf3ed",backText:"#1f2a23"},
      historyTitle:"Stoicism",
      historyText:"Inner peace by accepting what cannot be controlled; virtue over outcome.",
      orchidTitle:"The Enduring Bloom",
      orchidText:"Tend with patience; a dropped bud is part of the rhythm. Every bloom arrives in its time."
    },
    {
      key:"Epicureanism",
      theme:{front:"#b4557a",frontText:"#fff7fa",back:"#f4e1a6",backText:"#5b3a2c"},
      historyTitle:"Epicureanism",
      historyText:"Seek simple joys, friendship, and savor the present moment.",
      orchidTitle:"The Joyful Bloom",
      orchidText:"Delight in orchids for fragrance, color, and present joy."
    },
    {
      key:"Confucianism",
      theme:{front:"#196b5a",frontText:"#eafff9",back:"#e7d9a0",backText:"#2e2a1b"},
      historyTitle:"Confucianism",
      historyText:"Harmony, respect, and wisdom passed down across generations.",
      orchidTitle:"The Harmony Orchid",
      orchidText:"Grow with balance, tradition, and learned wisdom; care is a shared culture."
    },
    {
      key:"Transcendentalism",
      theme:{front:"#1e2756",frontText:"#eef0ff",back:"#eef0ff",backText:"#151a39"},
      historyTitle:"Transcendentalism",
      historyText:"Truth in direct experience with nature and spirit; intuition beyond reason.",
      orchidTitle:"Moonlight Reverie",
      orchidText:"A mystical bond with roots and spikes; orchids as guides to wonder."
    },
    {
      key:"Skepticism",
      theme:{front:"#1e3342",frontText:"#e9f6ff",back:"#e9f6ff",backText:"#0f2230"},
      historyTitle:"Skepticism",
      historyText:"Question assumptions; inquiry and evidence as paths to truth.",
      orchidTitle:"Veil Orchid",
      orchidText:"Verify tags, test mediums and light; curiosity powers the bloom."
    },
    {
      key:"Nihilism",
      theme:{front:"#2b2b2b",frontText:"#eaeaea",back:"#efefef",backText:"#1d1d1d"},
      historyTitle:"Nihilism",
      historyText:"No inherent meaning or permanence; beauty fades.",
      orchidTitle:"Vanishing Bloom",
      orchidText:"Every bloom is precious because it vanishes; impermanence revealed."
    },
    {
      key:"Egoism",
      theme:{front:"#6e1423",frontText:"#ffe9ec",back:"#ffe3b8",backText:"#3e1a06"},
      historyTitle:"Egoism",
      historyText:"Self-interest as foundation; personal achievement first.",
      orchidTitle:"Radiant Flame Orchid",
      orchidText:"Your collection mirrors your taste and triumphs; blooms as extensions of self."
    },
    {
      key:"Cynicism",
      theme:{front:"#55565a",frontText:"#f2f2f2",back:"#f4e0f0",backText:"#362a35"},
      historyTitle:"Cynicism",
      historyText:"Reject pretense and convention; live simply and freely.",
      orchidTitle:"Wild Sprout",
      orchidText:"Let orchids thrive outside rules—on logs, in bottles, even teacups."
    },
    {
      key:"Renaissance Humanism",
      theme:{front:"#5b1f2a",frontText:"#fde9e9",back:"#f7e3a3",backText:"#3b2a10"},
      historyTitle:"Renaissance Humanism",
      historyText:"Celebrate art, beauty, and human dignity inspired by classical ideals.",
      orchidTitle:"Orchid Muse",
      orchidText:"Orchids as living art—symmetry, form, and color admired as masterpieces."
    },
    {
      key:"Aristotelianism",
      theme:{front:"#1c2947",frontText:"#eaf0ff",back:"#f3f5ff",backText:"#0f1a33"},
      historyTitle:"Aristotelianism",
      historyText:"Knowledge through observation, logic, and classification.",
      orchidTitle:"Ordered Bloom",
      orchidText:"Tags, names, and genus charts—clarity through order."
    },
    {
      key:"Traditionalism",
      theme:{front:"#6b624e",frontText:"#fff7e9",back:"#efe6d0",backText:"#2f2b21"},
      historyTitle:"Traditionalism",
      historyText:"Honor inherited wisdom and practices; preserve the lineage.",
      orchidTitle:"Legacy Bloom",
      orchidText:"Time-tested methods; divisions become living heirlooms."
    },
    {
      key:"Pragmatism",
      theme:{front:"#4b3d2a",frontText:"#efe7da",back:"#e4eddc",backText:"#22301f"},
      historyTitle:"Pragmatism",
      historyText:"Truth is what works in practice; results over rules.",
      orchidTitle:"Grounded Root",
      orchidText:"If it thrives, it stays—adaptive methods, function over form."
    },
    {
      key:"Altruism",
      theme:{front:"#5d3f7a",frontText:"#f5ebff",back:"#efe1ff",backText:"#2e1b49"},
      historyTitle:"Altruism",
      historyText:"Ethic of selflessness; joy in giving.",
      orchidTitle:"Gifted Orchid",
      orchidText:"Share divisions generously—joy multiplies when given away."
    },
    // FINAL CTA CARD (always last):
    {
      key:"CTA",
      cta:true,
      title:"Ready to discover yours?",
      sub:"Take the Ultimate Orchid Philosophy Quiz and get your badge + haiku.",
      button:"Take the Quiz",
      href:"YOUR_QUIZ_URL"
    }
  ];

  // ---- Keep the rest of the widget code exactly as in the earlier snippet ----
  // Assign to window for debugging if you like:
  window.__ORCHID_DATA__ = DATA;

  // Reuse the renderer from the earlier snippet…
  // (If you already pasted the full widget earlier, just keep that and only replace its DATA.)
})();
</script>

Replace the quiz link with the following 

{
  key: "CTA",
  cta: true,
  title: "Ready to discover yours?",
  sub: "Take the Ultimate Orchid Philosophy Quiz and get your badge + haiku.",
  button: "Take the Quiz",
  href: "https://forms.gle/nAr2wthXzCgMdWFB9"
}