<!-- SECTION:CUSTOM_INTRO -->

## 🎯 Overview

The **marked-extended-spoiler** extension adds interactive spoiler functionality to hide sensitive content that users can reveal on demand. With support for both inline and block spoilers, 7 pre-built themes, customizable reveal effects, and full accessibility features, it's perfect for hiding plot spoilers, quiz answers, sensitive information, game walkthroughs, or any content that should be optionally viewable.

### ✨ Key Features

- 🎭 **Two Spoiler Types**: Inline (`||text||`) and block (`::: spoiler`) formats
- 🎨 **7 Pre-built Themes**: default, dark, light, danger, info, warning, success
- 👆 **Click-to-Reveal**: Interactive spoilers with toggle functionality
- 🌊 **Blur Effects**: Smooth reveal animations with blur transitions
- 🎯 **Custom Titles**: Configurable overlay titles and subtitles
- ✨ **Particle Effects**: Optional decorative particle animations
- ♿ **Fully Accessible**: ARIA labels, keyboard navigation, focus management
- 📝 **Rich Content Support**: Full Markdown in block spoilers
- 🎬 **Smooth Animations**: Configurable transition effects
- 🔧 **Highly Customizable**: Custom templates and themes
- 📱 **Mobile-Friendly**: Touch-optimized interactions
- 🎨 **Dark Mode Ready**: Theme variants for different color schemes
- 🚫 **Reduced Motion**: Respects user accessibility preferences
- 🔐 **Safe Interactions**: Preserves interactive elements (checkboxes, links, buttons)

### 🎪 Live Demo

Experience all spoiler types and themes: [View Demo](https://fsegurai.github.io/marked-extensions)

---

<!-- SECTION:CUSTOM_TOC_USAGE -->

	- [Quick Start](#quick-start)
	- [Syntax & Usage](#syntax--usage)
	- [Spoiler Types](#spoiler-types)
	- [Themes](#themes)
	- [Configuration Options](#configuration-options)
	- [Use Cases](#use-cases)
	- [Spoiler Syntax](#spoiler-syntax)
	- [Interaction Types](#interaction-types)
	- [Advanced Examples](#advanced-examples)

<!-- SECTION:CUSTOM_BASIC_USAGE -->

## Quick Start

### Basic Concept

**Spoilers use `||spoiler content||` syntax for inline spoilers and block syntax for larger content with customizable titles and themes.**

<!-- SECTION:CUSTOM_USAGE_EXAMPLE -->

### Installation

Install the package using your preferred package manager:

```bash
# Using Bun (recommended)
bun add @fsegurai/marked-extended-spoiler

# Using npm
npm install @fsegurai/marked-extended-spoiler

# Using yarn
yarn add @fsegurai/marked-extended-spoiler

# Using pnpm
pnpm add @fsegurai/marked-extended-spoiler
```

### Basic Implementation

```javascript
import { marked } from 'marked';
import markedExtendedSpoiler from '@fsegurai/marked-extended-spoiler';

// Import styles (required for functionality)
import '@fsegurai/marked-extended-spoiler/styles/spoiler.css';
// Optional: Import theme for enhanced visuals
import '@fsegurai/marked-extended-spoiler/styles/spoiler-theme.css';

// Register the extension
marked.use(markedExtendedSpoiler({
  className: 'marked-extended-spoiler',
  prefixId: 'spoiler-'
}));

// Your markdown content with spoilers
const markdown = `
# Movie Discussion - The Sixth Sense

## Quick Review

The movie was phenomenal! ||Bruce Willis delivers an outstanding performance||.

## Plot Analysis

The story follows a child psychologist working with a young boy who can see dead people.

### Major Plot Twist (Warning: Spoilers Ahead!)

::::spoiler{title="🎬 Ending Spoiler" subtitle="Click to reveal major plot twist"}
The main character, Malcolm Crowe (Bruce Willis), was actually dead the entire time. 
He was killed in the opening scene and has been a ghost throughout the movie.

This revelation completely changes the meaning of:

- All his interactions with his wife
- Why only Cole can see and communicate with him
- The entire narrative perspective
- The emotional weight of the ending

**Key Evidence:**
1. His wife never directly speaks to him
2. People in restaurants ignore him
3. He's always wearing the same clothes
4. The temperature drops when he's present
::::spoilerend

## Acting Performances

The child actor ||Haley Joel Osment|| was nominated for an Academy Award for his performance.

### Famous Quote

The line ||"I see dead people"|| became one of cinema's most iconic quotes.

## Without Spoilers

If you haven't seen it yet, this movie is definitely worth watching. The twist ending is genuinely surprising!

::::spoiler{title="💡 Viewing Tip" theme="info" subtitle="Spoiler-free recommendation"}
Watch it twice! The first time for the story, and the second time to catch all the subtle clues you missed.

The director masterfully places hints throughout that only make sense after you know the twist.
::::spoilerend
`;

// Parse and render
const html = marked.parse(markdown);
document.getElementById('content').innerHTML = html;
```

### Syntax & Usage

#### Inline Spoilers

Use double pipes (`||`) for short inline spoilers:

```markdown
The killer was ||Professor Plum|| in the library with the candlestick.

In Star Wars, ||Darth Vader is Luke's father||.

The answer to question 5 is ||42||.
```

#### Block Spoilers

Use block syntax for longer content:

```markdown
::::spoiler
This is a simple block spoiler with default settings.
::::spoilerend

::::spoiler{title="Custom Title"}
Block spoiler with a custom title.
::::spoilerend

::::spoiler{title="Quiz Answer" subtitle="Tap to see the solution"}
Block spoiler with custom title and subtitle.
::::spoilerend

::::spoiler{title="⚠️ Content Warning" theme="danger"}
Block spoiler with custom theme (danger = red overlay).
::::spoilerend
```

#### Short Aliases

You can use shorter syntax:

```markdown
:spoiler
Content here
:spoilerend

:spr
Even shorter!
:sprend
```

#### Nested Markdown

Block spoilers support full Markdown:

```markdown
::::spoiler{title="Complete Solution"}
# Step-by-Step Guide

1. **First step**: Do this
   - Substep A
   - Substep B

2. **Second step**: Then do that

\`\`\`javascript
// Code example
console.log("Spoilers can contain code!");
\`\`\`

> Important note in a blockquote

[Learn more](https://example.com)
::::spoilerend
```

<!-- SECTION:CUSTOM_USAGE_NOTES -->
Spoilers support **nested Markdown content** and provide accessible interaction with proper ARIA labels. Content remains
hidden until user interaction, with customizable reveal methods and styling.

### Styling Your Spoilers

This extension provides styles as separate CSS/SCSS files that you import into your project.

> 💡 **See [Themes](#themes)** for information about using the 7 pre-built themes (default, dark, light, danger, info, warning, success)

#### Available Style Files

- **spoiler.css / spoiler.scss** - Minimal structural styles required for functionality
- **spoiler-theme.css / spoiler-theme.scss** - Optional visual theming with 7 pre-built themes (blur effects, colors, animations)

#### Importing Styles

**In Node.js projects (CSS/SCSS):**

```css
/* Minimal structural styles only */
@import '@fsegurai/marked-extended-spoiler/styles/spoiler.css';

/* Or with theme */
@import '@fsegurai/marked-extended-spoiler/styles/spoiler.css';
@import '@fsegurai/marked-extended-spoiler/styles/spoiler-theme.css';
```

**In JavaScript/TypeScript:**

```javascript
import '@fsegurai/marked-extended-spoiler/styles/spoiler.css';
import '@fsegurai/marked-extended-spoiler/styles/spoiler-theme.css';
```

**In HTML (via node_modules):**

```html
<link rel="stylesheet" href="node_modules/@fsegurai/marked-extended-spoiler/styles/spoiler.css">
<link rel="stylesheet" href="node_modules/@fsegurai/marked-extended-spoiler/styles/spoiler-theme.css">
```

**In Angular:**

```scss
// In your global styles.scss or styles.css
@import '@fsegurai/marked-extended-spoiler/styles/spoiler.css';
@import '@fsegurai/marked-extended-spoiler/styles/spoiler-theme.css';
```

#### Generated HTML Structure

**Inline Spoilers:**

```html
<span class="marked-extended-spoiler marked-extended-spoiler-inline"
      data-revealed="false"
      tabindex="0"
      role="button"
      aria-label="Spoiler: Click to reveal">
  <span class="marked-extended-spoiler-content">Hidden content</span>
</span>
```

**Block Spoilers:**

```html

<div class="marked-extended-spoiler marked-extended-spoiler-block"
     data-revealed="false"
     tabindex="0"
     role="button"
     aria-expanded="false">
    <div class="marked-extended-spoiler-overlay">
        <div class="marked-extended-spoiler-overlay-content">
            <span class="spoiler-title">Spoiler</span>
            <p class="marked-extended-spoiler-reveal-hint">Click to reveal</p>
        </div>
    </div>
    <div class="marked-extended-spoiler-content">
        <!-- Markdown content here -->
    </div>
    <div class="marked-extended-spoiler-particles"></div>
</div>
```

#### CSS Classes Reference

| Class                                            | Purpose                | Type   |
|--------------------------------------------------|------------------------|--------|
| `.marked-extended-spoiler`                       | Base spoiler wrapper   | Both   |
| `.marked-extended-spoiler-inline`                | Inline spoiler style   | Inline |
| `.marked-extended-spoiler-block`                 | Block spoiler style    | Block  |
| `.marked-extended-spoiler[data-revealed="true"]` | Revealed state         | Both   |
| `.marked-extended-spoiler-content`               | Content wrapper        | Both   |
| `.marked-extended-spoiler-overlay`               | Blur overlay           | Block  |
| `.marked-extended-spoiler-overlay-content`       | Overlay text           | Block  |
| `.spoiler-title`                                 | "Spoiler" label        | Block  |
| `.marked-extended-spoiler-reveal-hint`           | "Click to reveal" text | Block  |
| `.marked-extended-spoiler-particles`             | Particle effects       | Block  |

#### Customization with CSS Variables

The theme file uses CSS variables for easy customization:

```css
:root {
  --spoiler-animation-duration: 0.4s;
  --spoiler-padding: 16px;
  --spoiler-border-radius: 8px;
  --spoiler-transition-timing: cubic-bezier(0.4, 0, 0.2, 1);
  --spoiler-focus-color: #4a9eff;
}
```

#### Complete Styling Example

```css
/* Base Spoiler */
.marked-extended-spoiler {
    position: relative;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.marked-extended-spoiler:not([data-revealed="true"]) {
    cursor: pointer;
}

/* Inline Spoilers */
.marked-extended-spoiler-inline {
    display: inline;
    padding: 2px 4px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.1);
}

.marked-extended-spoiler-inline .marked-extended-spoiler-content {
    filter: blur(5px);
    user-select: none;
    transition: filter 0.3s ease;
}

.marked-extended-spoiler-inline[data-revealed="true"] .marked-extended-spoiler-content {
    filter: blur(0);
    user-select: text;
}

.marked-extended-spoiler-inline:hover:not([data-revealed="true"]) {
    background: rgba(0, 0, 0, 0.15);
}

/* Block Spoilers */
.marked-extended-spoiler-block {
    margin: 1.5rem 0;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.02);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.marked-extended-spoiler-block:hover:not([data-revealed="true"]),
.marked-extended-spoiler-block:focus:not([data-revealed="true"]) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Content (blurred initially) */
.marked-extended-spoiler-block .marked-extended-spoiler-content {
    padding: 1.5rem;
    filter: blur(16px) grayscale(0.4);
    transform: scale(0.99);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.marked-extended-spoiler-block[data-revealed="true"] .marked-extended-spoiler-content {
    filter: blur(0) grayscale(0);
    transform: scale(1);
    user-select: text;
}

/* Overlay */
.marked-extended-spoiler-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

.marked-extended-spoiler-block[data-revealed="true"] .marked-extended-spoiler-overlay,
.marked-extended-spoiler-block:hover .marked-extended-spoiler-overlay,
.marked-extended-spoiler-block:focus .marked-extended-spoiler-overlay {
    opacity: 0;
    pointer-events: none;
}

.marked-extended-spoiler-overlay-content {
    text-align: center;
    padding: 1rem;
}

.spoiler-title {
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 0.5rem;
    color: #333;
}

.marked-extended-spoiler-reveal-hint {
    font-size: 0.875rem;
    opacity: 0.7;
    margin: 0;
}

.marked-extended-spoiler-reveal-hint::before {
    content: "👆 ";
}

/* Particles (optional decorative effect) */
.marked-extended-spoiler-particles {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    transition: opacity 0.4s;
}

.marked-extended-spoiler-block[data-revealed="true"] .marked-extended-spoiler-particles {
    opacity: 0;
}

/* Particle elements (add via JS if desired) */
.marked-extended-spoiler-particles .particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(0, 102, 204, 0.5);
    border-radius: 50%;
    animation: float 3s infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) translateX(0);
        opacity: 0.6;
    }
    50% {
        transform: translateY(-20px) translateX(10px);
        opacity: 1;
    }
}
```

#### Dark Mode Support

```css
/* Light theme */
body.light .marked-extended-spoiler-block {
    background: rgba(0, 0, 0, 0.02);
}

body.light .marked-extended-spoiler-overlay {
    background: rgba(255, 255, 255, 0.95);
    color: #333;
}

body.light .marked-extended-spoiler-overlay::before {
    opacity: 0.5;
}

/* Dark theme */
body.dark .marked-extended-spoiler-block {
    background: rgba(0, 0, 0, 0.2);
}

body.dark .marked-extended-spoiler-overlay {
    background: rgba(30, 30, 30, 0.95);
    color: #e0e0e0;
}

body.dark .spoiler-title {
    color: #e0e0e0;
}

body.dark .marked-extended-spoiler-overlay::before {
    opacity: 0.3;
}
```

#### Accessibility Enhancements

```css
/* Focus styles for keyboard navigation */
.marked-extended-spoiler:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

.marked-extended-spoiler:focus-visible {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* Remove outline for mouse users */
.marked-extended-spoiler:focus:not(:focus-visible) {
    outline: none;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .marked-extended-spoiler,
    .marked-extended-spoiler-content,
    .marked-extended-spoiler-overlay,
    .marked-extended-spoiler-particles {
        animation: none !important;
        transition: opacity 0.2s ease !important;
    }

    .marked-extended-spoiler:hover,
    .marked-extended-spoiler:focus {
        transform: none;
    }

    .marked-extended-spoiler-particles .particle {
        animation: none !important;
    }
}
```

#### Theme Variants

For detailed information about all 7 pre-built themes and how to use them, see the [**Themes**](#themes) section.

The themes are now **fully functional** with automatic color application! Simply use the `theme` parameter:

```markdown
::::spoiler{title="Info" theme="info"}
This uses the blue info theme
::::spoilerend

::::spoiler{title="Danger" theme="danger"}
This uses the red danger theme
::::spoilerend
```

**CSS Class Reference** (for customization):

```css
/* Danger theme (red) */
.marked-extended-spoiler.spoiler-theme-danger .marked-extended-spoiler-overlay {
    background: rgba(220, 53, 69, 0.95);
    color: white;
}

/* Info theme (blue) */
.marked-extended-spoiler.spoiler-theme-info .marked-extended-spoiler-overlay {
    background: rgba(13, 110, 253, 0.95);
    color: white;
}

/* Warning theme (yellow) */
.marked-extended-spoiler.spoiler-theme-warning .marked-extended-spoiler-overlay {
    background: rgba(255, 193, 7, 0.95);
    color: #333;
}

/* Success theme (green) */
.marked-extended-spoiler.spoiler-theme-success .marked-extended-spoiler-overlay {
    background: rgba(25, 135, 84, 0.95);
    color: white;
}
```

#### Live Demo & Examples

Check the [demo](https://fsegurai.github.io/marked-extensions) to see all spoiler themes and effects in action.

<!-- SECTION:CUSTOM_SECTIONS -->

### Spoiler Syntax

#### Inline Spoilers

Use double pipes for inline spoiler content:

```markdown
The killer was ||Professor Plum|| in the library.
```

#### Block Spoilers

Use block syntax for longer spoiler content:

```markdown
::::spoiler
This is a block spoiler that can contain:

- Multiple paragraphs
- **Formatted text**
- Code blocks
- Images and links
  ::::spoilerend
```

You can also use these short aliases:

- Start: `:spr` or `:spoiler`
- End: `:sprend` or `:spoilerend`

#### Spoilers with Custom Titles

```markdown
::::spoiler{title="Ending Spoiler"}
The detailed explanation of how the story ends...
::::spoilerend

::::spoiler{title="Quiz Answer" type="click"}
The answer is 42.
::::spoilerend
```

### Interaction Types

The extension supports multiple reveal mechanisms:

- **Hover** (default): Content appears on mouse hover
- **Click**: Content toggles on click/tap
- **Focus**: Content appears when element receives focus (keyboard accessible)
- **Auto**: Automatically reveals after a specified delay

## Themes

The marked-extended-spoiler extension includes **7 pre-built themes** that automatically style the spoiler overlay with different colors and effects. Themes are now **fully functional** with both inline styles and CSS-based styling for maximum compatibility.

### Available Themes

| Theme       | Color      | Background Gradient                                       | Best For                                      |
|-------------|------------|-----------------------------------------------------------|-----------------------------------------------|
| **default** | Dark Gray  | `rgba(30, 30, 30, 0.95)` → `rgba(15, 15, 15, 0.98)`       | General spoilers, neutral content             |
| **dark**    | Very Dark  | `rgba(20, 20, 20, 0.95)` → `rgba(5, 5, 5, 0.99)`          | Dark mode preference, professional content    |
| **light**   | Light Gray | `rgba(245, 245, 245, 0.95)` → `rgba(230, 230, 230, 0.98)` | Light mode preference, accessibility          |
| **danger**  | Red        | `rgba(220, 53, 69, 0.95)` → `rgba(180, 40, 50, 0.98)`     | Warnings, dangerous content, critical info    |
| **info**    | Blue       | `rgba(13, 110, 253, 0.95)` → `rgba(10, 88, 202, 0.98)`    | Information, tips, helpful content            |
| **warning** | Amber/Gold | `rgba(255, 193, 7, 0.95)` → `rgba(255, 160, 0, 0.98)`     | Cautions, important notices                   |
| **success** | Green      | `rgba(25, 135, 84, 0.95)` → `rgba(20, 108, 67, 0.98)`     | Positive content, achievements, confirmations |

### Using Themes

Simply add the `theme` parameter to your spoiler block:

```markdown
::::spoiler{theme="info"}
This spoiler uses the info theme (blue)
::::spoilerend

::::spoiler{title="Warning!" theme="danger"}
This spoiler uses the danger theme (red)
::::spoilerend

::::spoiler{title="Success!" theme="success"}
This spoiler uses the success theme (green)
::::spoilerend
```

### Theme Examples

#### Info Theme (Blue)
```markdown
::::spoiler{title="💡 Helpful Tip" theme="info"}
This is useful information that you might want to hide initially.

**Key Points:**
- Point 1
- Point 2
- Point 3
::::spoilerend
```

#### Danger Theme (Red)
```markdown
::::spoiler{title="⚠️ Warning" theme="danger"}
This content contains important warnings or dangerous information that users should review carefully before proceeding.

**Important:** Read this before continuing!
::::spoilerend
```

#### Success Theme (Green)
```markdown
::::spoiler{title="✓ Success!" theme="success"}
Congratulations! You've completed the task successfully.

Your rewards:
- Badge earned
- Points: +100
- Achievement unlocked
::::spoilerend
```

#### Warning Theme (Gold)
```markdown
::::spoiler{title="⚡ Caution" theme="warning"}
Please be careful with this operation. There's no undo!
::::spoilerend
```

### Theme Styling Details

When you import the theme CSS file:

```javascript
import '@fsegurai/marked-extended-spoiler/styles/spoiler-theme.css';
```

The themes are applied through **two mechanisms** for maximum compatibility:

#### 1. Inline Styles (Rendered by JavaScript)
Each spoiler receives inline styles applied directly to the overlay element:
```html
<div class="marked-extended-spoiler-overlay" 
     style="background: linear-gradient(...); 
             color: #ffffff; 
             box-shadow: 0 4px 20px rgba(...);">
```

#### 2. CSS Theme Classes (Stylesheet)
Additionally, a theme-specific CSS class is added to the spoiler container:
```html
<div class="marked-extended-spoiler spoiler-theme-info">
```

This is matched by CSS rules in `spoiler-theme.css`:
```css
.marked-extended-spoiler.spoiler-theme-info .marked-extended-spoiler-overlay {
  background: linear-gradient(145deg, rgba(13, 110, 253, 0.95), rgba(10, 88, 202, 0.98)) !important;
  color: #ffffff !important;
}
```

### Customizing Themes

You can override theme colors by targeting the theme classes in your own CSS:

```css
/* Override the info theme color */
.marked-extended-spoiler.spoiler-theme-info .marked-extended-spoiler-overlay {
    background: linear-gradient(145deg, #0066cc, #004999) !important;
    color: #ffffff !important;
}

/* Or modify the shadow */
.marked-extended-spoiler.spoiler-theme-info .marked-extended-spoiler-overlay {
    box-shadow: 0 8px 30px rgba(0, 102, 204, 0.3) !important;
}
```

### CSS Variable Customization

Customize animation timing and spacing:

```css
:root {
  --spoiler-animation-duration: 0.4s;
  --spoiler-padding: 16px;
  --spoiler-border-radius: 8px;
  --spoiler-transition-timing: cubic-bezier(0.4, 0, 0.2, 1);
}
```

### Theme Not Applying? ✅ Fixed!

**Previous Issue:** Themes were defined but not visually applied to spoilers.

**Current Solution:** As of v17.0.0+, themes are now fully functional with:
- ✅ Inline style injection from the renderer
- ✅ CSS class-based styling as fallback
- ✅ Proper shadow effects for each theme
- ✅ Complete support for all 7 themes

**To ensure themes work correctly:**
1. Import the theme stylesheet: `import '@fsegurai/marked-extended-spoiler/styles/spoiler-theme.css'`
2. Specify a theme in your spoiler: `::::spoiler{theme="info"}`
3. The spoiler will automatically display with the selected theme colors!

### Configuration Options

The marked-extended-spoiler extension accepts the following configuration options:

#### Extension Options

- `className`: Base CSS class for spoiler containers. Defaults to 'marked-extended-spoiler'.
- `prefixId`: Prefix for spoiler element IDs. Defaults to 'spoiler-'.
- `template`: Custom HTML template for spoiler structure. Defaults to built-in template.
- `customizeToken`: Function to customize tokens before rendering. Defaults to null.

#### Styling

Styles are no longer injected automatically. Import the CSS/SCSS files you need:

```javascript
// In your main JavaScript/TypeScript file
import '@fsegurai/marked-extended-spoiler/styles/spoiler.css';
import '@fsegurai/marked-extended-spoiler/styles/spoiler-theme.css';
```

Or in your CSS/SCSS:

```css
@import '@fsegurai/marked-extended-spoiler/styles/spoiler.css';
@import '@fsegurai/marked-extended-spoiler/styles/spoiler-theme.css';
```

Spoiler syntax parameters:

- `title`: Custom title for the spoiler. Defaults to 'Spoiler'.
- `subtitle`: Custom subtitle text for the spoiler reveal hint. Defaults to 'Click to reveal'.
- `theme`: Visual theme name ('default', 'dark', 'light', 'danger', 'info', 'warning', 'success').

### Advanced Examples

#### Gaming Guide with Multiple Spoiler Types

```markdown
# Game Walkthrough Guide

## Level 1: The Forest

Start by collecting the ||magic sword|| near the waterfall.

### Boss Strategy

::::spoiler{title="Boss Weakness" type="click"}
The forest guardian is weak to fire attacks. Use your fire spell 3 times, then attack with your sword when it's stunned.

**Recommended items:**

- Fire resistance potion
- Health potions (at least 5)
- Magic restoration items

**Attack pattern:**

1. Guardian charges (dodge left)
2. Magic blast (use fire resistance)
3. Vulnerable window (3 seconds) - attack now!
   ::::spoilerend

## Level 2: The Cave System

Navigate to the ||second tunnel on the right|| to find the hidden treasure.

### Puzzle Solution

::::spoiler{title="Crystal Puzzle Answer" type="hover"}
Arrange the crystals in this order:

1. Blue (top-left)
2. Red (top-right)
3. Green (bottom-left)
4. Yellow (bottom-right)
5. Purple (center)

The sequence must be activated by touching them in numerical order.
::::spoilerend

### Secret Achievement

||||You can unlock the "Master Explorer" achievement by finding all 12 hidden gems in this level.||||
```

#### Educational Quiz

```markdown
# Physics Quiz

## Question 1

What is the speed of light in a vacuum?

::::spoiler{title="Answer" type="click"}
The speed of light in a vacuum is approximately **299,792,458 meters per second** (often rounded to 3 × 10⁸ m/s).

**Additional context:**

- This is a fundamental constant of nature
- Symbol: *c*
- It's the maximum speed at which all matter and information can travel
- Einstein's theory of relativity is built around this constant

**Formula**: E = mc²
where *m* is mass and *c* is the speed of light
::::spoilerend

## Question 2

Who developed the theory of general relativity?

Quick answer: ||Albert Einstein||

## Question 3

What happens to time as you approach the speed of light?

::::spoiler{title="Detailed Answer"}
According to special relativity, time dilation occurs as you approach the speed of light. Time appears to slow down
relative to a stationary observer.

**Time dilation formula:**
```

t' = t / √(1 - v²/c²)

```

Where:
- t' = dilated time
- t = proper time  
- v = velocity
- c = speed of light

**Practical example:**
If you traveled at 90% the speed of light, time would pass about 2.3 times slower for you compared to someone on Earth.
::::spoilerend
```

#### Sensitive Content Warning

```markdown
# Content with Warnings

## News Article Discussion

The recent events have been difficult to process.

::::spoiler{title="⚠️ Sensitive Content Warning" type="click"}
**Content Warning**: This section discusses topics related to violence and loss.

The incident resulted in multiple casualties and has deeply impacted the local community. Support services have been
established for those affected, and counseling resources are available.

**Resources:**

- Crisis hotline: 1-800-XXX-XXXX
- Local support center: [link]
- Online counseling services: [link]

If you or someone you know needs support, please don't hesitate to reach out to these resources.
::::spoilerend

## Community Response

The community has come together to ||organize fundraising efforts|| for the affected families.
```

#### Interactive Story

```markdown
# Choose Your Adventure: The Mysterious Package

You find a mysterious package on your doorstep. What do you do?

## Option A: Open it immediately

::::spoiler{title="Reveal Consequence A" type="hover"}
You eagerly tear open the package and find... a beautiful vintage music box! As you wind it up, it plays a haunting
melody that seems familiar.

Suddenly, you remember - this belonged to your grandmother, who passed away last year. A note inside reads: "For my
dearest grandchild, may this bring you as much joy as it brought me."

**Emotional impact**: You feel overwhelmed with love and nostalgia.
**Item gained**: Grandmother's Music Box
**Story continues**: [Go to Chapter 2A]
::::spoilerend

## Option B: Examine it carefully first

||||You notice the package has no return address, but there's a small symbol pressed into the wax seal - a crescent
moon. This triggers a memory of an old family legend about mystical gifts that appear when most needed.||||

## Option C: Call the authorities

::::spoiler{title="Reveal Consequence C" type="click"}  
You decide to play it safe and call the local police. Officer Martinez arrives within 20 minutes and carefully examines
the package.

"This is interesting," she says, pointing to the postmark. "This was sent from a town that hasn't existed for 30 years."

After a thorough inspection, she determines it's safe to open. Inside you find...

**Plot twist**: The story takes a supernatural turn!
**Trust gained**: +1 with Local Authorities  
**Story continues**: [Go to Chapter 2C]
::::spoilerend
```

#### Configuration Examples

```javascript
// Gaming/entertainment focused
marked.use(markedExtendedSpoiler({
    spoilerClass: 'game-spoiler',
    revealType: 'click',
    showTitle: true,
    blurEffect: true,
    customTitle: '🎮 Game Spoiler'
}));

// Educational/quiz focused  
marked.use(markedExtendedSpoiler({
    spoilerClass: 'quiz-answer',
    revealType: 'click',
    animationDuration: '0.5s',
    customTitle: '📚 Answer',
    blurEffect: false
}));

// Sensitive content warnings
marked.use(markedExtendedSpoiler({
    spoilerClass: 'content-warning',
    revealType: 'click',
    customTitle: '⚠️ Content Warning',
    showTitle: true,
    template: customWarningTemplate
}));

// Auto-reveal for timed content
marked.use(markedExtendedSpoiler({
    revealType: 'auto',
    revealDelay: 5000, // 5 seconds
    animationDuration: '1s',
    customTitle: '⏰ Timed Reveal'
}));
```

### Spoiler Types

The extension supports two main spoiler types:

#### 1. **Inline Spoilers** - Quick Reveals

Short, inline content hidden with double pipes.

```markdown
The password is ||Admin123||.

In chemistry, H₂O is ||water||.

The capital of France is ||Paris||.
```

**Best for:**
- ✅ Short answers
- ✅ Single words or phrases
- ✅ Quick reveals
- ✅ Inline text flow

**Features:**
- Minimal blur effect
- Inline display
- Hover or click reveal
- Preserves text flow

#### 2. **Block Spoilers** - Detailed Content

Multi-line content with overlay and reveal effects.

```markdown
::::spoiler{title="Detailed Explanation"}
This can contain:
- Multiple paragraphs
- Lists and formatting
- Code blocks
- Images and links
::::spoilerend
```

**Best for:**
- ✅ Long explanations
- ✅ Multiple paragraphs
- ✅ Formatted content
- ✅ Rich media

**Features:**
- Full overlay with title
- Blur + grayscale effect
- Click to reveal
- Particle effects
- Custom themes

### Available Themes (7 Total)

The extension includes 7 pre-built themes for different contexts:

| Theme       | Color        | Best For                          | Example Use Case              |
|-------------|--------------|-----------------------------------|-------------------------------|
| **default** | Dark Gray    | General spoilers                  | Movie plots, story reveals    |
| **dark**    | Near Black   | High contrast                     | Text-heavy content            |
| **light**   | Light Gray   | Bright backgrounds                | Light-themed sites            |
| **danger**  | Red          | Major spoilers, warnings          | Plot twists, sensitive content|
| **info**    | Blue         | Information reveals               | Tips, hints, explanations     |
| **warning** | Yellow       | Caution content                   | Partial spoilers, notes       |
| **success** | Green        | Positive reveals                  | Achievements, solutions       |

#### Theme Examples

```markdown
<!-- Default theme -->
::::spoiler{title="Spoiler"}
Standard spoiler overlay
::::spoilerend

<!-- Danger theme (red) -->
::::spoiler{title="Major Spoiler" theme="danger"}
Critical plot information
::::spoilerend

<!-- Info theme (blue) -->
::::spoiler{title="Additional Info" theme="info"}
Helpful supplementary information
::::spoilerend

<!-- Warning theme (yellow) -->
::::spoiler{title="Partial Spoiler" theme="warning"}
Minor plot detail
::::spoilerend

<!-- Success theme (green) -->
::::spoiler{title="Solution" theme="success"}
Complete answer or solution
::::spoilerend
```

### Best Practices

#### 1. **Use Appropriate Spoiler Types**

```markdown
<!-- Good: Inline for short content -->
The winner is ||Team Blue||.

<!-- Good: Block for long content -->
::::spoiler{title="Full Strategy"}
Detailed multi-paragraph explanation...
::::spoilerend

<!-- Avoid: Inline for long content -->
||This is a very long spoiler with multiple sentences that should really be a block spoiler instead but someone decided to make it inline anyway which makes it hard to read||

<!-- Avoid: Block for one word -->
::::spoiler
Blue
::::spoilerend
```

#### 2. **Choose Appropriate Themes**

```markdown
<!-- Good: Danger for major spoilers -->
::::spoiler{title="Ending Spoiler" theme="danger"}
Major plot twist revealed
::::spoilerend

<!-- Good: Info for helpful tips -->
::::spoiler{title="Pro Tip" theme="info"}
Useful gameplay advice
::::spoilerend

<!-- Avoid: Success for sad content -->
::::spoiler{title="Tragic Death" theme="success"}
Character dies... <!-- ❌ Wrong theme -->
::::spoilerend
```

#### 3. **Provide Clear Titles**

```markdown
<!-- Good: Descriptive titles -->
::::spoiler{title="Act 3 Spoiler"}
::::spoiler{title="Quiz Answer"}
::::spoiler{title="Achievement Guide"}

<!-- Avoid: Vague titles -->
::::spoiler{title="Click Here"}
::::spoiler{title="Info"}
::::spoiler{title="Spoiler"} <!-- Too generic -->
```

#### 4. **Use Subtitles for Context**

```markdown
<!-- Good: Helpful subtitle -->
::::spoiler{title="Boss Strategy" subtitle="Click to reveal winning tactics"}
::::spoilerend

<!-- Good: Warning in subtitle -->
::::spoiler{title="⚠️ Content Warning" subtitle="Contains discussion of sensitive topics"}
::::spoilerend
```

#### 5. **Consider User Experience**

```markdown
<!-- Good: Warn before major spoilers -->
**Warning: Major spoilers ahead!**

::::spoiler{title="Ending Reveal"}
The complete ending explained...
::::spoilerend

<!-- Avoid: Spoilers without context -->
::::spoiler
Random spoiler with no warning
::::spoilerend
```

### Use Cases

#### 1. **Movie/TV Show Discussion**

```markdown
# Breaking Bad Series Finale Discussion

## Initial Reactions

The finale was absolutely brilliant! ||Bryan Cranston's performance was Emmy-worthy||.

## Plot Resolution

::::spoiler{title="🎬 Ending Spoiler" theme="danger" subtitle="Major finale spoilers"}
Walter White dies at the end, but not before accomplishing his goals:

1. **Saving Jesse**: He frees Jesse from captivity
2. **Providing for family**: The money reaches his family through Gretchen and Elliott
3. **Taking down enemies**: Eliminates the neo-Nazi gang
4. **Final moment**: Dies in the meth lab, surrounded by his "work"

The ending is bittersweet - Walter achieves his goals but loses everything that mattered.

**Iconic final scenes:**
- The machine gun in the trunk
- "I did it for me. I liked it. I was good at it."
- Jesse's scream of freedom
- Walter's final breath in the lab
::::spoilerend

## Character Arcs

### Jesse Pinkman

Jesse's journey from ||small-time dealer to traumatized survivor|| represents the show's tragic core.

### Skyler White

::::spoiler{title="Skyler's Fate" theme="info"}
Skyler survives but is left to deal with the aftermath of Walt's actions. 
She cooperates with authorities and attempts to rebuild her life with her children.

The final scene between Walt and Skyler is one of the show's most powerful moments.
::::spoilerend

## Easter Eggs

Did you notice ||the Stevia packet in the ricin scene||? Brilliant callback!
```

#### 2. **Gaming Walkthrough**

```markdown
# The Legend of Zelda: Tears of the Kingdom - Walkthrough

## Main Quest: Regional Phenomena

### Rito Village - Wind Temple

**Recommended level**: 20+  
**Preparation needed**: ||Cold resistance gear or elixirs||

::::spoiler{title="🎮 Boss Strategy" theme="success" subtitle="Click for winning tactics"}
## Colgera Battle Strategy

**Phase 1: Weak Points**
- Target the three ice shields first
- Use bow and arrows while gliding
- Aim for the glowing cores

**Phase 2: Rapid Fire**
- Boss becomes more aggressive
- Use updrafts to gain height
- Multi-shot bows are highly effective

**Recommended Items:**
- 3-shot bow or better
- 50+ arrows
- Cold resistance food
- Healing items (x5)

**Pro Tip**: Save your stamina for critical moments. The battle is more about positioning than button mashing.
::::spoilerend

### Secret Shrine Locations

There's a hidden shrine ||behind the waterfall in Zora's Domain||.

::::spoiler{title="🗺️ All Shrine Locations" theme="info"}
## Hebra Region Hidden Shrines

1. **Tabantha Shrine**: ||Coordinates: -2503, -1831||
   - Behind the ice wall
   - Requires fire arrows

2. **Rito Shrine**: ||Coordinates: -3602, 1832||
   - Under the snow pile
   - Use hot spring nearby

3. **Summit Shrine**: ||Coordinates: -3242, 1703||
   - On mountain peak
   - Requires climbing gear

**Completion reward**: Ancient Armor Set
::::spoilerend

## Side Quest: The Great Fairy

To unlock the fairy fountain, you need to ||collect 1000 rupees and complete the musician's quest||.
```

#### 3. **Educational Quiz**

```markdown
# Computer Science Final Exam Study Guide

## Algorithms & Data Structures

### Question 1: Big O Notation

What is the time complexity of binary search?

::::spoiler{title="📚 Answer" theme="success" subtitle="Click to reveal solution"}
**Answer**: O(log n)

**Explanation**:
Binary search halves the search space with each iteration, leading to logarithmic time complexity.

**Example**:
- Array of 16 elements: Max 4 comparisons (16→8→4→2→1)
- Array of 1024 elements: Max 10 comparisons

**Why it's efficient**:
Each comparison eliminates half of the remaining possibilities, making it much faster than linear search O(n) for large datasets.

**Code Example**:
\`\`\`python
def binary_search(arr, target):
    left, right = 0, len(arr) - 1
    while left <= right:
        mid = (left + right) // 2
        if arr[mid] == target:
            return mid
        elif arr[mid] < target:
            left = mid + 1
        else:
            right = mid - 1
    return -1
\`\`\`
::::spoilerend

### Question 2: Sorting Algorithms

Which sorting algorithm is most efficient for nearly sorted data?

Quick answer: ||Insertion Sort||

::::spoiler{title="Detailed Explanation" theme="info"}
**Insertion Sort** performs best on nearly sorted data with O(n) time complexity in the best case.

**Why it works well**:
1. Very few elements need to be moved
2. Inner loop terminates early when element is in correct position
3. Minimal overhead compared to other algorithms

**Comparison**:
| Algorithm      | Best Case | Average | Worst Case |
|----------------|-----------|---------|------------|
| Insertion Sort | O(n)      | O(n²)   | O(n²)      |
| Quick Sort     | O(n log n)| O(n log n)| O(n²)    |
| Merge Sort     | O(n log n)| O(n log n)| O(n log n)|

For nearly sorted data, Insertion Sort often outperforms O(n log n) algorithms due to its simplicity and early termination.
::::spoilerend
```

#### 4. **Recipe with Hidden Tips**

```markdown
# Perfect Chocolate Chip Cookies

## Ingredients

- 2¼ cups flour
- 1 tsp baking soda
- 1 tsp salt
- 1 cup butter (softened)
- ¾ cup sugar
- ¾ cup brown sugar
- 2 eggs
- 2 tsp vanilla
- 2 cups chocolate chips

## Secret Ingredient

Add ||1 tsp of espresso powder|| to enhance the chocolate flavor without making it taste like coffee!

## Instructions

1. Preheat oven to 375°F
2. Mix dry ingredients
3. Cream butter and sugars
4. Add eggs and vanilla
5. Combine wet and dry
6. Fold in chocolate chips
7. Bake for 9-11 minutes

::::spoiler{title="🍪 Pro Baker Tips" theme="success" subtitle="Click for expert secrets"}
## Professional Secrets

**Temperature Tricks**:
- Use ||room temperature butter|| (not melted!)
- ||Chill dough for 30 minutes|| before baking
- Bake at ||375°F for 9 minutes exactly|| for chewy centers

**Texture Secrets**:
- Replace 2 tablespoons of flour with ||cornstarch|| for softer cookies
- Use a mix of ||regular and mini chocolate chips|| for better distribution
- ||Underbake slightly|| - cookies continue cooking on the pan

**Flavor Enhancements**:
- Add ||1 tsp vanilla extract + ½ tsp almond extract||
- Sprinkle with ||sea salt|| before baking
- Use ||dark brown sugar|| for deeper molasses flavor

**Perfect Shape**:
- Use a ||cookie scoop|| for uniform size
- ||Bang the pan|| halfway through baking to create those signature wrinkles
- Let cool on pan for ||2 minutes|| before transferring

**Storage**:
- Store with a ||slice of bread|| in the container to keep soft
- Freeze dough balls for ||fresh cookies anytime||
- Warm in microwave for ||10 seconds|| to revive day-old cookies
::::spoilerend

## Baker's Notes

The key to perfect cookies is ||not overmixing the dough|| after adding flour!
```

### Troubleshooting

#### Spoilers Not Revealing

**Problem**: Clicking spoilers doesn't reveal content.

**Solutions**:

1. **Import CSS files:**
```javascript
import '@fsegurai/marked-extended-spoiler/styles/spoiler.css';
```

2. **Check JavaScript errors:**
```javascript
// Ensure no conflicts with other scripts
console.log('Spoiler loaded');
```

3. **Verify syntax:**
```markdown
<!-- Correct -->
::::spoiler
Content
::::spoilerend

<!-- Wrong -->
::::spoiler
Content
::::spoiler  <!-- ❌ Should be spoilerend -->
```

#### Inline Spoilers Not Working

**Problem**: Inline spoilers (`||text||`) don't render.

**Solution**:
```markdown
<!-- Ensure no spaces inside pipes -->
||correct||     ✅
|| incorrect || ❌
```

#### Theme Not Applied

**Problem**: Custom theme doesn't show.

**Solutions**:

1. **Import theme CSS:**
```javascript
import '@fsegurai/marked-extended-spoiler/styles/spoiler-theme.css';
```

2. **Check theme name:**
```markdown
<!-- Valid themes -->
theme="danger"   ✅
theme="info"     ✅
theme="warning"  ✅

<!-- Invalid -->
theme="red"      ❌
```

#### Blur Effect Not Showing

**Problem**: Content not blurred.

**Solution**:
```css
/* Ensure CSS loaded and not overridden */
.marked-extended-spoiler-block .marked-extended-spoiler-content {
  filter: blur(16px) grayscale(0.4) !important;
}
```

### Framework Integration

#### React Integration

```tsx
// SpoilerContent.tsx
import { marked } from 'marked';
import markedExtendedSpoiler from '@fsegurai/marked-extended-spoiler';
import '@fsegurai/marked-extended-spoiler/styles/spoiler.css';
import '@fsegurai/marked-extended-spoiler/styles/spoiler-theme.css';
import { useEffect, useState } from 'react';

marked.use(markedExtendedSpoiler({
  className: 'marked-extended-spoiler',
  prefixId: 'spoiler-'
}));

interface Props {
  content: string;
}

export function SpoilerContent({ content }: Props) {
  const [html, setHtml] = useState('');
  
  useEffect(() => {
    const parsed = marked.parse(content);
    setHtml(parsed);
  }, [content]);
  
  return (
    <div 
      className="spoiler-container"
      dangerouslySetInnerHTML={{ __html: html }} 
    />
  );
}

// Usage:
// <SpoilerContent content={markdownWithSpoilers} />
```

#### Vue 3 Integration

```vue
<script setup lang="ts">
import { marked } from 'marked';
import markedExtendedSpoiler from '@fsegurai/marked-extended-spoiler';
import '@fsegurai/marked-extended-spoiler/styles/spoiler.css';
import '@fsegurai/marked-extended-spoiler/styles/spoiler-theme.css';
import { computed } from 'vue';

marked.use(markedExtendedSpoiler({
  className: 'marked-extended-spoiler'
}));

interface Props {
  content: string;
}

const props = defineProps<Props>();

const html = computed(() => {
  return marked.parse(props.content);
});
</script>

<template>
  <div class="markdown-content" v-html="html" />
</template>
```

#### Angular Integration

```typescript
// spoiler-content.component.ts
import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { marked } from 'marked';
import markedExtendedSpoiler from '@fsegurai/marked-extended-spoiler';

marked.use(markedExtendedSpoiler({
  className: 'marked-extended-spoiler'
}));

@Component({
  selector: 'app-spoiler-content',
  template: `<div [innerHTML]="parsedContent"></div>`,
  styleUrls: [
    '../node_modules/@fsegurai/marked-extended-spoiler/styles/spoiler.css',
    '../node_modules/@fsegurai/marked-extended-spoiler/styles/spoiler-theme.css'
  ]
})
export class SpoilerContentComponent implements OnChanges {
  @Input() content: string = '';
  parsedContent: SafeHtml = '';

  constructor(private sanitizer: DomSanitizer) {}

  ngOnChanges(changes: SimpleChanges): void {
    if (changes['content']) {
      const html = marked.parse(this.content);
      this.parsedContent = this.sanitizer.bypassSecurityTrustHtml(html);
    }
  }
}
```

### Performance Tips

1. **Limit spoiler count**: Keep under 50 spoilers per page for best performance
2. **Optimize particles**: Disable particle effects for mobile
3. **Use inline spoilers**: Lighter weight for simple reveals

```javascript
// Disable particles on mobile
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);

marked.use(markedExtendedSpoiler({
    // Add custom logic in template if needed
}));
```

### Contributing

Found a bug or have a feature request? Please open an issue on [GitHub](https://github.com/fsegurai/marked-extensions/issues).

### Related Resources

- [Marked.js Documentation](https://marked.js.org/)
- [Extension Demo](https://fsegurai.github.io/marked-extensions)
- [Source Code](https://github.com/fsegurai/marked-extensions)
- [npm Package](https://www.npmjs.com/package/@fsegurai/marked-extended-spoiler)
- [Spoiler Design Guide](https://github.com/fsegurai/marked-extensions/wiki/spoiler-guide)



