/* Enhanced Ebook CSS Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
    line-height: 1.8;
    color: #333;
    background-color: #f9f7f4;
    padding: 0;
    margin: 0;
    font-size: 18px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Main content wrapper */
body > header,
body > nav,
body > section,
body > h1,
body > h2,
body > h3,
body > p,
body > blockquote,
body > ul,
body > ol {
    max-width: 650px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
}

/* Header styling */
header#title-block-header {
    text-align: center;
    padding: 80px 20px;
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    margin-bottom: 40px;
}

header h1.title {
    font-size: 2.5em;
    margin-bottom: 20px;
    font-weight: normal;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p.subtitle {
    font-size: 1.5em;
    font-style: italic;
    margin-bottom: 30px;
    opacity: 0.9;
}

header p.author {
    font-size: 1.2em;
    text-transform: uppercase;
    letter-spacing: 3px;
    opacity: 0.8;
}

/* No drop caps for author paragraph */
p.author:first-letter {
    float: none;
    font-size: inherit;
    line-height: inherit;
    margin: 0;
    color: inherit;
    font-weight: inherit;
}

/* Navigation */
nav#TOC {
    background: #fff;
    padding: 30px;
    margin: 0 auto 40px;
    max-width: 650px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-radius: 8px;
}

nav#TOC ul {
    list-style: none;
    padding-left: 0;
}

nav#TOC ul ul {
    padding-left: 30px;
    margin-top: 10px;
}

nav#TOC a {
    text-decoration: none;
    color: #3498db;
    display: block;
    padding: 8px 0;
    transition: all 0.3s ease;
    border-bottom: 1px solid transparent;
}

nav#TOC a:hover {
    color: #2c3e50;
    padding-left: 10px;
    border-bottom: 1px solid #3498db;
}

/* Chapter headings */
h1 {
    font-size: 2.2em;
    margin: 80px auto 40px;
    text-align: center;
    color: #2c3e50;
    font-weight: normal;
    position: relative;
    padding-bottom: 20px;
}

h1:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 3px;
    background: #3498db;
}

h2 {
    font-size: 1.6em;
    margin: 60px auto 30px;
    color: #34495e;
    font-weight: normal;
}

h3 {
    font-size: 1.3em;
    margin: 40px auto 20px;
    color: #34495e;
    font-weight: normal;
}

/* Paragraphs */
p {
    margin: 0 0 1.5em 0;
    text-align: justify;
    hyphens: auto;
}

/* First paragraph after chapter heading */
h1 + p {
    text-indent: 0;
}

/* Style quote paragraphs after chapter headings */
h1 + p {
    text-align: center;
    margin: 2em auto 3em auto;
    color: #666;
    max-width: 650px;
    padding: 0 20px;
}

h1 + p em {
    font-size: 1.1em;
    line-height: 1.6;
    display: inline-block;
}

/* Drop cap for the first real paragraph (second p after h1) */
h1 + p + p {
    text-indent: 0;
}

h1 + p + p:first-letter {
    float: left;
    font-size: 4em;
    line-height: 0.8;
    margin: 0.1em 0.1em 0 0;
    color: #3498db;
    font-weight: bold;
}

/* No drop caps for h3 elements */
h3 {
    text-indent: 0;
}

h3:first-letter {
    float: none;
    font-size: inherit;
    line-height: inherit;
    margin: 0;
    color: inherit;
    font-weight: inherit;
}

/* Emphasis and strong */
em {
    font-style: italic;
}

strong {
    font-weight: bold;
    color: #2c3e50;
}

/* Blockquotes */
blockquote {
    margin: 2em 0;
    padding: 1.5em;
    background: #fff;
    border-left: 4px solid #3498db;
    font-style: italic;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

/* Scene breaks */
hr {
    margin: 60px auto;
    border: none;
    text-align: center;
    position: relative;
}

hr:after {
    content: "• • •";
    font-size: 1.5em;
    color: #bdc3c7;
    letter-spacing: 1em;
}

/* Links */
a {
    color: #3498db;
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: #2c3e50;
    text-decoration: underline;
}

/* Lists */
ul, ol {
    margin: 1.5em 0;
    padding-left: 2em;
}

li {
    margin-bottom: 0.5em;
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        font-size: 16px;
    }
    
    header#title-block-header {
        padding: 40px 20px;
    }
    
    header h1.title {
        font-size: 2em;
    }
    
    h1 {
        font-size: 1.8em;
        margin: 60px auto 30px;
    }
    
    h2 {
        font-size: 1.4em;
    }
    
    nav#TOC {
        padding: 20px;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
        color: black;
        font-size: 12pt;
    }
    
    header#title-block-header {
        background: none;
        color: black;
        page-break-after: always;
    }
    
    nav#TOC {
        page-break-after: always;
    }
    
    h1 {
        page-break-before: always;
        page-break-after: avoid;
    }
    
    p {
        orphans: 3;
        widows: 3;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }
    
    header#title-block-header {
        background: linear-gradient(135deg, #1a1a1a 0%, #2c3e50 100%);
    }
    
    nav#TOC {
        background: #2c2c2c;
        box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    }
    
    h1, h2, h3 {
        color: #ecf0f1;
    }
    
    blockquote {
        background: #2c2c2c;
        border-left-color: #3498db;
    }
    
    strong {
        color: #ecf0f1;
    }
}