/* Homebrewery PHP Edition Styles - D&D 5e Theme */

:root {
    /* PHB Colors */
    --HB_Color_Background: #EEE5CE; /* Light parchment */
    --HB_Color_Accent: #E0E5C1; /* Pastel green */
    --HB_Color_HeaderUnderline: #C0AD6A; /* Gold */
    --HB_Color_HorizontalRule: #9C2B1B; /* Maroon */
    --HB_Color_HeaderText: #58180D; /* Dark Maroon */
    --HB_Color_MonsterStatBackground: #F2E5B5; /* Light orange parchment */
    --HB_Color_CaptionText: #766649; /* Brown */
    --HB_Color_WatercolorStain: #BBAD82; /* Light brown */
    --HB_Color_Footnotes: #C9AD6A; /* Gold */

    /* Additional Colors */
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --accent-color: #e74c3c;
    --light-bg: #ecf0f1;
    --dark-text: #2c3e50;
    --border-color: #bdc3c7;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--HB_Color_Background);
    color: var(--dark-text);
    margin: 0;
    padding: 0;
}

.hero-section {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
}

.editor-container {
    border: 1px solid var(--border-color);
    border-radius: 5px;
    overflow: hidden;
}

.preview-pane {
    background: white;
}

/* D&D 5e PHB Theme Styling for Brew Content */
.brew-content {
    font-family: 'BookInsanityRemake', Georgia, serif;
    font-size: 0.34cm;
    max-width: 8.5in;
    margin: 0 auto;
    padding: 0.5in;
    background: var(--HB_Color_Background);
    background-image: url('/assets/parchmentBackground.jpg');
    background-size: cover;
    background-blend-mode: multiply;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    column-count: 2;
    column-fill: auto;
    column-gap: 0.9cm;
    column-width: 8cm;
}

.brew-content p {
    line-height: 1.25em;
    margin-top: 0;
    margin-bottom: 0.325cm;
}

.brew-content p + p {
    text-indent: 1em;
}

.brew-content ul, 
.brew-content ol {
    padding-left: 1.4em;
    margin-bottom: 0.8em;
    line-height: 1.25em;
}

/* D&D 5e Headers */
.brew-content h1,
.brew-content h2,
.brew-content h3,
.brew-content h4,
.brew-content h5 {
    font-family: 'MrEavesRemake', serif;
    color: var(--HB_Color_HeaderText);
    margin-top: 0;
    margin-bottom: 0;
}

.brew-content h1 {
    margin-bottom: 0.18cm;
    column-span: all;
    font-size: 0.89cm;
    line-height: 1em;
    text-align: center;
    -webkit-column-span: all;
    -moz-column-span: all;
}

.brew-content h1 + p::first-letter {
    float: left;
    padding-bottom: 2px;
    padding-left: 40px;
    margin-top: -0.3cm;
    margin-bottom: -20px;
    margin-left: -40px;
    font-family: 'SolberaImitationRemake', serif;
    font-size: 3.5cm;
    line-height: 1em;
    color: rgba(0, 0, 0, 0);
    background-image: linear-gradient(-45deg, #322814, #998250, #322814);
    -webkit-background-clip: text;
    background-clip: text;
}

.brew-content h2 {
    font-size: 0.75cm;
    line-height: 0.988em;
    margin-top: 0;
    margin-bottom: 0;
}

.brew-content h3 {
    font-size: 0.575cm;
    line-height: 0.995em;
    border-bottom: 2px solid var(--HB_Color_HeaderUnderline);
    margin-top: 0.155cm;
    margin-bottom: 0.1cm;
}

.brew-content h4 {
    font-size: 0.458cm;
    line-height: 0.971em;
    margin-top: 0.235cm;
    margin-bottom: 0.02cm;
}

.brew-content h5 {
    font-family: 'ScalySansSmallCapsRemake', sans-serif;
    font-size: 0.423cm;
    line-height: 0.951em;
    margin-top: 0.2cm;
    margin-bottom: 0.02cm;
}

/* D&D 5e Table Styling */
.brew-content table {
    font-family: 'ScalySansRemake', sans-serif;
    font-size: 0.318cm;
    line-height: 1.2em;
    width: 100%;
    margin-top: 0;
    margin-bottom: 0.325cm;
    border-collapse: collapse;
}

.brew-content table th {
    font-weight: 800;
    padding: 0px 1.5px;
    vertical-align: bottom;
}

.brew-content table td {
    padding: 0px 1.5px;
}

.brew-content table tbody tr:nth-child(odd) {
    background-color: var(--HB_Color_Accent);
}

/* D&D 5e Quote Styling */
.brew-content .quote {
    margin: 0.54cm 0;
    font-style: italic;
}

.brew-content .quote p {
    line-height: 0.54cm;
}

.brew-content .quote p:first-child::first-line {
    font-size: 0.38cm;
    font-style: normal;
    font-variant: small-caps;
}

.brew-content .attribution {
    display: block;
    font-style: normal;
    line-height: 0.54cm;
    text-align: right;
}

.brew-content .attribution::before {
    margin-right: 0.2em;
    content: '---';
}

/* Standard Markdown Elements Styling */
.brew-content blockquote {
    margin: 0.54cm 0;
    padding: 0.3cm 0.5cm;
    border-left: 3px solid var(--HB_Color_HorizontalRule);
    background-color: rgba(224, 229, 193, 0.3);
    font-style: italic;
}

.brew-content blockquote p {
    margin: 0.2cm 0;
}

.brew-content ul, 
.brew-content ol {
    margin: 0.325cm 0;
    padding-left: 1.2em;
}

.brew-content li {
    margin-bottom: 0.1cm;
}

.brew-content hr {
    border: none;
    height: 6px;
    background: url('/assets/horizontalRule.svg') repeat-x center;
    background-size: auto 6px;
    margin: 0.5cm 0;
}

.brew-content p {
    line-height: 1.25em;
    margin-top: 0;
    margin-bottom: 0.325cm;
}

.brew-content p + p {
    text-indent: 1em;
}

/* Column and Page Break Styles */
.columnSplit {
    border: none;
    margin: 0;
    padding: 0;
    height: 0;
    border-bottom: 2px dotted var(--HB_Color_HorizontalRule);
    margin-bottom: 0.4cm;
    margin-top: 0.4cm;
    -webkit-column-break-after: always;
    page-break-after: always;
    break-after: always;
}

.pageBreak {
    display: block;
    page-break-before: always;
    -webkit-column-break-before: always;
    break-before: always;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    height: 0;
}

/* Monster Stat Block Styling */
.brew-content .monster {
    margin: 0.54cm 0;
    padding: 0.4cm;
    background-image: url('/assets/parchmentBackgroundGrayscale.jpg');
    border: 2px solid #7A200D;
    border-image: url('/assets/monsterBorderFancy.png') 4 round;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    break-inside: avoid;
    position: relative;
}

.brew-content .monster-content {
    position: relative;
    z-index: 1;
}

.brew-content .monster > h3 {
    margin: -0.4cm -0.4cm 0.3cm -0.4cm;
    padding: 0.3cm;
    background: rgba(242, 229, 181, 0.9);
    border: none;
    border-bottom: 1px solid #7A200D;
    font-family: 'MrEavesRemake', serif;
    font-size: 0.75cm;
    line-height: 0.988em;
    color: var(--HB_Color_HeaderText);
    text-align: center;
}

.monster .meta {
    font-style: italic;
    margin-bottom: 0.3cm;
    text-align: center;
}

.monster .stats {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.2cm;
    margin-bottom: 0.3cm;
}

.monster .stat {
    text-align: center;
    border-right: 1px solid #7A200D;
    padding-right: 0.2cm;
}

.monster .stat:last-child {
    border-right: none;
}

.monster .top-stats {
    border-bottom: 1px solid #7A200D;
    padding-bottom: 0.2cm;
    margin-bottom: 0.3cm;
}

.monster .property {
    margin-bottom: 0.2cm;
}

.monster .property-line {
    margin: 0.1cm 0;
}

/* Spell Block Styling */
.brew-content .spell {
    margin: 0.54cm 0;
    padding: 0.3cm 0.4cm;
    border-left: 3px solid var(--HB_Color_HorizontalRule);
    background-color: rgba(224, 229, 193, 0.3);
    border: 1px solid var(--HB_Color_HorizontalRule);
    border-radius: 2px;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    break-inside: avoid;
}

.brew-content .spell-content {
    position: relative;
}

/* Item Block Styling */
.brew-content .item {
    margin: 0.54cm 0;
    padding: 0.3cm 0.4cm;
    border: 1px solid #B8860B;
    background-color: rgba(255, 215, 0, 0.1);
    border-image: url('/assets/descriptiveBorder.png') 4 round;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    break-inside: avoid;
}

.brew-content .item-content {
    position: relative;
}

/* Descriptive Block Styling */
.brew-content .descriptive {
    margin: 0.54cm 0;
    padding: 0.3cm 0.4cm;
    background-color: rgba(224, 229, 193, 0.2);
    border: 1px solid var(--HB_Color_Accent);
    border-image: url('/assets/descriptiveBorder.png') 4 round;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    break-inside: avoid;
}

.brew-content .descriptive-content {
    position: relative;
}

/* Note Block Styling */
.brew-content .note {
    margin: 0.54cm 0;
    padding: 0.3cm 0.4cm;
    background-color: rgba(242, 242, 178, 0.3);
    border: 1px solid #aaa;
    border-image: url('/assets/noteBorder.png') 4 round;
    font-style: italic;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    break-inside: avoid;
}

.brew-content .note-content {
    position: relative;
}

/* Class Table Styling */
.brew-content .classTable {
    position: relative;
    margin: 0.5cm 0;
    padding: 0.3cm;
    border: 1px solid var(--border-color);
    background-color: rgba(242, 229, 181, 0.3);
}

.brew-content .classTableDecoration {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    z-index: -1;
}

.brew-content .classTable-content {
    position: relative;
    z-index: 1;
}

.monster .meta {
    font-style: italic;
    margin-bottom: 0.3cm;
    text-align: center;
}

.monster .stats {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.2cm;
    margin-bottom: 0.3cm;
}

.monster .stat {
    text-align: center;
    border-right: 1px solid #7A200D;
    padding-right: 0.2cm;
}

.monster .stat:last-child {
    border-right: none;
}

.monster .top-stats {
    border-bottom: 1px solid #7A200D;
    padding-bottom: 0.2cm;
    margin-bottom: 0.3cm;
}

.monster .property {
    margin-bottom: 0.2cm;
}

.monster .property-line {
    margin: 0.1cm 0;
}

/* Spell Block Styling */
.brew-content .spell {
    margin: 0.54cm 0;
    padding: 0.3cm 0.4cm;
    border-left: 3px solid var(--HB_Color_HorizontalRule);
    background-color: rgba(224, 229, 193, 0.3);
    border: 1px solid var(--HB_Color_HorizontalRule);
    border-radius: 2px;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    break-inside: avoid;
}

/* Item Block Styling */
.brew-content .item {
    margin: 0.54cm 0;
    padding: 0.3cm 0.4cm;
    border: 1px solid #B8860B;
    background-color: rgba(255, 215, 0, 0.1);
    border-image: url('/assets/descriptiveBorder.png') 4 round;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    break-inside: avoid;
}

/* Descriptive Block Styling */
.brew-content .descriptive {
    margin: 0.54cm 0;
    padding: 0.3cm 0.4cm;
    background-color: rgba(224, 229, 193, 0.2);
    border: 1px solid var(--HB_Color_Accent);
    border-image: url('/assets/descriptiveBorder.png') 4 round;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    break-inside: avoid;
}

/* Note Block Styling */
.brew-content .note {
    margin: 0.54cm 0;
    padding: 0.3cm 0.4cm;
    background-color: rgba(242, 242, 178, 0.3);
    border: 1px solid #aaa;
    border-image: url('/assets/noteBorder.png') 4 round;
    font-style: italic;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    break-inside: avoid;
}

/* Spell Block Styling */
.brew-content .spell {
    margin: 0.54cm 0;
    padding: 0.3cm 0.4cm;
    border-left: 3px solid var(--HB_Color_HorizontalRule);
    background-color: rgba(224, 229, 193, 0.3);
    border: 1px solid var(--HB_Color_HorizontalRule);
    border-radius: 2px;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    break-inside: avoid;
}

/* Item Block Styling */
.brew-content .item {
    margin: 0.54cm 0;
    padding: 0.3cm 0.4cm;
    border: 1px solid #B8860B;
    background-color: rgba(255, 215, 0, 0.1);
    border-image: url('/assets/descriptiveBorder.png') 4 round;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    break-inside: avoid;
}

/* Descriptive Block Styling */
.brew-content .descriptive {
    margin: 0.54cm 0;
    padding: 0.3cm 0.4cm;
    background-color: rgba(224, 229, 193, 0.2);
    border: 1px solid var(--HB_Color_Accent);
    border-image: url('/assets/descriptiveBorder.png') 4 round;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    break-inside: avoid;
}

/* Note Block Styling */
.brew-content .note {
    margin: 0.54cm 0;
    padding: 0.3cm 0.4cm;
    background-color: rgba(242, 242, 178, 0.3);
    border: 1px solid #aaa;
    border-image: url('/assets/noteBorder.png') 4 round;
    font-style: italic;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    break-inside: avoid;
}

/* Class Table Styling */
.brew-content .classTable {
    margin: 0.5cm 0;
    padding: 0.3cm;
    border: 1px solid var(--border-color);
    background-color: rgba(242, 229, 181, 0.3);
}

/* Table of Contents Styling */
.brew-content .toc {
    margin: 0.5cm 0;
    padding: 0.3cm;
    border: 1px solid var(--border-color);
    background-color: rgba(224, 229, 193, 0.2);
}

/* Wide Block Styling */
.brew-content .wide {
    column-span: all;
    -webkit-column-span: all;
    margin: 0.5cm 0;
    padding: 0.3cm;
    border: 1px solid var(--border-color);
    background-color: rgba(242, 229, 181, 0.3);
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .brew-content {
        box-shadow: none;
        max-width: 100%;
        margin: 0;
        padding: 0;
        background: white !important;
        background-image: none !important;
    }
    
    .pageBreak {
        page-break-before: always;
        border: none;
        background: none;
        margin: 0;
        padding: 0;
    }
    
    .columnSplit {
        -webkit-column-break-after: always;
        page-break-after: always;
        break-after: always;
        border-bottom: 2px dotted var(--HB_Color_HorizontalRule) !important;
        margin-bottom: 0.4cm !important;
        margin-top: 0.4cm !important;
    }
    
    .watercolor-stain {
        display: none;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .brew-content {
        padding: 0.25in;
        column-count: 1;
        column-width: auto;
    }
    
    .editor-container {
        height: auto;
        min-height: 400px;
    }
    
    .editor-pane, .preview-pane {
        height: 400px;
    }
    
    /* Ensure column breaks work on mobile */
    .columnSplit {
        -webkit-column-break-after: always;
        page-break-after: always;
        break-after: always;
    }
    
    .pageBreak {
        page-break-before: always;
        break-before: always;
    }
}

/* Animation for loading */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--primary-color);
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Front Cover Styling */
.brew-content .frontCover {
    position: relative;
    height: 27.94cm; /* 11 inches */
    width: 21.59cm; /* 8.5 inches */
    margin: 0 -0.5in;
    background-color: #EEE5CE;
    background-image: url('/assets/parchmentBackground.jpg');
    background-size: cover;
    page-break-after: always;
    break-after: page;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.brew-content .coverPage {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.brew-content .coverPageBanner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    z-index: 0;
}

.brew-content .coverPageContent {
    position: relative;
    z-index: 1;
    padding: 2cm;
    width: 100%;
}

.brew-content .frontCover h1 {
    font-size: 1.5cm;
    margin-bottom: 0.5cm;
    color: #58180D;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.brew-content .frontCover h2 {
    font-size: 1cm;
    margin-bottom: 1cm;
    color: #766649;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

/* Inside Cover Styling */
.brew-content .insideCover {
    position: relative;
    height: 27.94cm; /* 11 inches */
    width: 21.59cm; /* 8.5 inches */
    margin: 0 -0.5in;
    background-color: #EEE5CE;
    background-image: url('/assets/parchmentBackground.jpg');
    background-size: cover;
    page-break-after: always;
    break-after: page;
    padding: 2cm;
}

.brew-content .insideCoverMask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    z-index: 0;
}

.brew-content .insideCoverContent {
    position: relative;
    z-index: 1;
}

/* Part Cover Styling */
.brew-content .partCover {
    position: relative;
    height: 27.94cm; /* 11 inches */
    width: 21.59cm; /* 8.5 inches */
    margin: 0 -0.5in;
    background-color: #EEE5CE;
    background-image: url('/assets/parchmentBackground.jpg');
    background-size: cover;
    page-break-after: always;
    break-after: page;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding-top: 3cm;
}

.brew-content .partCoverHeader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3cm;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    z-index: 0;
}

.brew-content .partCoverContent {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: 0 2cm;
}

.brew-content .partCover h1 {
    font-size: 1.2cm;
    margin-bottom: 0.3cm;
    color: #58180D;
}

.brew-content .partCover h2 {
    font-size: 0.8cm;
    margin-bottom: 0.5cm;
    color: #766649;
}

/* Back Cover Styling */
.brew-content .backCover {
    position: relative;
    height: 27.94cm; /* 11 inches */
    width: 21.59cm; /* 8.5 inches */
    margin: 0 -0.5in;
    background-color: #EEE5CE;
    background-image: url('/assets/parchmentBackground.jpg');
    background-size: cover;
    page-break-after: always;
    break-after: page;
    padding: 2cm;
}

.brew-content .backCoverContent {
    position: relative;
    width: 100%;
    height: 100%;
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

/* Table of Contents Styling */
.brew-content .toc {
    margin: 0.5cm 0;
    padding: 0.3cm;
    border: 1px solid #bdc3c7;
    background-color: rgba(224, 229, 193, 0.2);
    column-span: all;
    -webkit-column-span: all;
}

.brew-content .tocContent {
    column-count: 2;
    column-gap: 1cm;
}

/* Wide Block Styling */
.brew-content .wide {
    column-span: all;
    -webkit-column-span: all;
    margin: 0.5cm 0;
    padding: 0.3cm;
    border: 1px solid #bdc3c7;
    background-color: rgba(242, 229, 181, 0.3);
}

/* Theme-specific styles */
.theme-phb {
    background-image: url('/assets/parchmentBackground.jpg');
}

.theme-phb h1 {
    color: var(--HB_Color_HeaderText);
    border-bottom-color: var(--HB_Color_HeaderUnderline);
}

.theme-phb h2 {
    color: var(--HB_Color_HeaderText);
}

.theme-dmg {
    font-family: 'Palatino', serif;
    background-color: #f0e6d2;
}

.theme-dmg h1 {
    color: #800000;
    border-bottom-color: #800000;
}

.theme-xgte {
    font-family: 'Georgia', serif;
}

.theme-xgte h1 {
    color: #4a4a4a;
    border-bottom-color: #4a4a4a;
}