/* =====================================================
   WORD POWER MADE EASY - MODERN CSS STYLESHEET
   ===================================================== */

/* CSS Custom Properties for Theme Management */
:root {
    /* Light Theme Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-accent: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-accent: #495057;
    --border-color: #dee2e6;
    --link-color: #007bff;
    --link-hover: #0056b3;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --radius: 8px;
    
    /* Typography Scale */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    
    /* Font Families */
    --font-serif: 'Georgia', 'Times New Roman', serif;
    --font-sans: 'system-ui', -apple-system, 'Segoe UI', 'Roboto', sans-serif;
    --font-mono: 'Consolas', 'Monaco', monospace;
    --font-amazon-ember: 'Amazon Ember', 'Helvetica Neue', 'Roboto', Arial, sans-serif;
    --font-roboto: 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    --font-open-sans: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
    --font-inter: 'Inter', 'Helvetica Neue', 'Roboto', Arial, sans-serif;
    --font-source-sans: 'Source Sans Pro', 'Helvetica Neue', Arial, sans-serif;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Line Heights */
    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.75;
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-accent: #404040;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --text-accent: #ced4da;
    --border-color: #495057;
    --link-color: #66b3ff;
    --link-hover: #4da3ff;
    --shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Import Google Fonts for better font availability */
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;0,700;1,400&family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;1,400&family=Inter:wght@300;400;500;600;700&family=Source+Sans+Pro:ital,wght@0,300;0,400;0,600;0,700;1,400&display=swap');

body {
    font-family: var(--font-serif);
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    max-width: 95%;
    margin: 0 auto;
    padding: var(--space-md);
}

/* Header Controls */
.header-controls {
    position: fixed;
    top: var(--space-md);
    right: var(--space-md);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    z-index: 1000;
    max-width: 300px;
}

.control-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: var(--font-size-sm);
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

.control-btn:hover {
    background: var(--bg-accent);
    transform: translateY(-1px);
}

.control-btn:focus {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

/* Typography */
h1 {
    font-size: var(--font-size-4xl);
    font-weight: bold;
    margin-bottom: var(--space-xl);
    text-align: center;
    line-height: var(--line-height-tight);
    color: var(--text-primary);
}

h2 {
    font-size: var(--font-size-2xl);
    font-weight: bold;
    margin: var(--space-2xl) 0 var(--space-lg) 0;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: var(--space-sm);
}

h3 {
    font-size: var(--font-size-xl);
    font-weight: bold;
    margin: var(--space-xl) 0 var(--space-md) 0;
    color: var(--text-accent);
}

p {
    margin-bottom: var(--space-md);
    line-height: var(--line-height-relaxed);
    text-align: justify;
    text-indent: var(--space-md);
}

/* Remove text-indent for first paragraph after headings */
h1 + p, h2 + p, h3 + p {
    text-indent: 0;
}

/* Lists */
ol, ul {
    margin: var(--space-md) 0;
    padding-left: var(--space-xl);
}

li {
    margin-bottom: var(--space-sm);
    line-height: var(--line-height-relaxed);
}

/* Special Text Formatting */
.s2, .s3, .s7 {
    font-style: italic;
}

.s16 {
    font-weight: bold;
}

.s4, .s5, .s6, .s10, .s11, .s12, .s13, .s14 {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* Replace image decorative lines with CSS borders */
img[src*="Image_"] {
    display: none;
}

/* Add decorative lines where images were */
p:has(img[src*="Image_"]) {
    border-bottom: 2px solid var(--border-color);
    margin: var(--space-xl) 0;
    padding: 0;
    height: 2px;
    text-indent: 0;
}

/* Alternatively, for broader support: */
.decorative-line {
    border-bottom: 2px solid var(--border-color);
    margin: var(--space-xl) 0;
    width: 100%;
    height: 2px;
}

/* Center-aligned text */
[style*="text-align: center"] {
    text-align: center !important;
    text-indent: 0 !important;
}

/* Right-aligned text */
[style*="text-align: right"] {
    text-align: right !important;
    text-indent: 0 !important;
}

/* Chapter numbers and special formatting */
h1[style*="text-align: center"] {
    background: var(--bg-secondary);
    padding: var(--space-lg);
    border-radius: var(--radius);
    margin: var(--space-2xl) 0;
}

/* Exercise sections and special content blocks */
.teaser-preview, .exercise-section {
    background: var(--bg-secondary);
    padding: var(--space-xl);
    border-radius: var(--radius);
    margin: var(--space-xl) 0;
    border-left: 4px solid var(--link-color);
}

/* Answer keys */
.answer-key {
    background: var(--bg-accent);
    padding: var(--space-md);
    border-radius: var(--radius);
    margin: var(--space-md) 0;
    border-left: 4px solid #28a745;
}

/* Pronunciation guides */
.pronunciation {
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    background: var(--bg-accent);
    padding: var(--space-xs) var(--space-sm);
    border-radius: 4px;
    display: inline-block;
    margin-left: var(--space-sm);
}

/* Session headers */
h1:contains("SESSION") {
    background: var(--bg-secondary);
    padding: var(--space-lg);
    border-radius: var(--radius);
    font-size: var(--font-size-3xl);
}

/* Etymology and special sections */
.etymology-section {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-accent));
    padding: var(--space-xl);
    margin: var(--space-xl) 0;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

/* Personality type cards */
.personality-type {
    background: var(--bg-secondary);
    margin: var(--space-lg) 0;
    padding: var(--space-lg);
    border-radius: var(--radius);
    border-left: 4px solid var(--link-color);
}

.personality-type h3 {
    margin-top: 0;
    color: var(--link-color);
}

/* Key sections */
p:contains("KEY:") {
    background: var(--bg-accent);
    padding: var(--space-md);
    border-radius: var(--radius);
    border-left: 4px solid #28a745;
    font-weight: bold;
    color: #28a745;
}

/* Underlined blanks for fill-in exercises */
u {
    text-decoration: none;
    border-bottom: 1px solid var(--text-primary);
    padding-bottom: 2px;
    display: inline-block;
    min-width: 60px;
}

/* Table-like spacing for numbered lists */
ol[id*="l"] {
    list-style: none;
    counter-reset: item;
}

ol[id*="l"] > li {
    counter-increment: item;
    display: flex;
    align-items: flex-start;
    margin-bottom: var(--space-md);
}

ol[id*="l"] > li::before {
    content: counter(item) ". ";
    font-weight: bold;
    margin-right: var(--space-sm);
    min-width: 2rem;
}

/* Special formatting for YES/NO sections */
p:contains("YES   NO") {
    font-family: var(--font-mono);
    color: var(--text-secondary);
    text-indent: 0;
    margin-left: var(--space-lg);
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: var(--space-sm);
    }
    
    .header-controls {
        position: static;
        justify-content: center;
        margin-bottom: var(--space-lg);
    }
    
    h1 {
        font-size: var(--font-size-3xl);
    }
    
    h2 {
        font-size: var(--font-size-xl);
    }
    
    ol[id*="l"] > li {
        flex-direction: column;
    }
    
    ol[id*="l"] > li::before {
        margin-bottom: var(--space-xs);
    }
}

/* Print Styles */
@media print {
    .header-controls {
        display: none;
    }
    
    body {
        max-width: none;
        padding: 0;
        font-size: 12pt;
    }
    
    h1 {
        font-size: 18pt;
    }
    
    h2 {
        font-size: 16pt;
    }
    
    h3 {
        font-size: 14pt;
    }
    
    .teaser-preview, .exercise-section, .personality-type {
        break-inside: avoid;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Focus improvements for accessibility */
*:focus {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

/* End of stylesheet */