@font-face {
    font-family: 'Jancient';
    src: url('./fonts/jancient.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

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

body {
    font-family: 'Jancient', serif;
    background-color: #ffffff; /* match lilybui.com background */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Toolbar Styles */
.toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    padding: 12px 20px;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.toolbar::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 30px;
    background: transparent;
}

.toolbar:hover,
.toolbar.show {
    transform: translateY(0);
}

/* Hide the toolbar initially, show on hover or when class is added */
.toolbar.visible {
    transform: translateY(0);
}

/* Create a larger hover zone at the top of the page */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 80px;
    z-index: 999;
    pointer-events: none;
}

.toolbar-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    max-width: 800px;
    margin: 0 auto;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-group label {
    color: #333333;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.toolbar-group select {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: #333333;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toolbar-group select:hover {
    background: #f7f7f7;
    border-color: rgba(0, 0, 0, 0.3);
}

.toolbar-group select:focus {
    outline: none;
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.4);
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: rgba(0, 0, 0, 0.12);
    margin: 0 8px;
}

.toolbar-btn {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: #333333;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 8px;
}

.toolbar-btn:last-child {
    margin-right: 0;
}

.toolbar-btn:hover:not(:disabled) {
    background: #f5f5f5;
    border-color: rgba(0, 0, 0, 0.3);
}

.toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.toolbar-btn.delete-btn {
    color: #c62828;
    border-color: rgba(198, 40, 40, 0.4);
    background: #ffffff;
}

.toolbar-btn.delete-btn:hover:not(:disabled) {
    background: rgba(198, 40, 40, 0.08);
    border-color: rgba(198, 40, 40, 0.6);
}

.container {
    width: 100%;
    max-width: 850px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotate(-0.15deg); /* Slight rotation like a scanned page */
}

.book-page {
    background-color: #ffffff; /* pure white like lilybui.com */
    background-image: none; /* remove textures */
    padding: 85px 65px 85px 75px; /* Uneven padding like a book */
    box-shadow: none;
    position: relative;
    min-height: 750px;
    width: 100%;
    max-width: 650px;
    margin: 0 auto;
    overflow: hidden;
    border: none; /* remove visible border */
    filter: none;
    display: flex;
    flex-direction: column;
}

/* Multiple layers for realistic effects */
.book-page::before { content: none; }

.book-page::after { content: none; }

.page-content {
    position: relative;
    z-index: 1;
    min-height: 580px;
    outline: none;
    flex-grow: 1;
}

/* Text element styles */
.text-element {
    font-family: 'Jancient', serif;
    color: #2a2622;
    outline: none;
    caret-color: transparent;
    white-space: pre-wrap;
    word-wrap: break-word;
    text-shadow: none;
    filter: none;
    opacity: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    margin-bottom: 16px;
    cursor: text;
}

.text-element:last-child {
    margin-bottom: 0;
}

/* Removed hover and selection styling for cleaner experience */

.text-element.title {
    font-size: 24px;
    line-height: 1.3;
    text-align: center;
    font-weight: 500;
    margin-bottom: 24px;
}

.text-element.paragraph {
    font-size: 17px;
    line-height: 1.7;
    text-align: justify;
}

/* Placeholder element */
.text-element.placeholder-element {
    font-style: italic;
    color: #8a8a8a;
    opacity: 0.7;
    text-align: center;
    cursor: default;
}

.text-element.placeholder-element::before {
    content: attr(data-placeholder);
}

/* Empty text element placeholder */
.text-element:empty::before {
    content: attr(data-placeholder);
    color: #8a8a8a;
    font-style: italic;
    opacity: 0.7;
    pointer-events: none;
}

.page-content:focus {
    outline: none;
}

.page-content::selection {
    background-color: rgba(200, 180, 140, 0.3);
}

.page-content::-moz-selection {
    background-color: rgba(200, 180, 140, 0.3);
}

/* Placeholder styling for empty contenteditable */
.page-content:empty::before {
    content: attr(data-placeholder);
    color: #8a8a8a;
    font-style: italic;
    opacity: 0.7;
}

/* Add a subtle warping effect */
@keyframes subtle-warp {
    0%, 100% { transform: perspective(1000px) rotateY(0.5deg); }
    50% { transform: perspective(1000px) rotateY(-0.5deg); }
}

.book-page { animation: none; }

/* Additional lighting layer */
.lighting-overlay { display: none; }

@media (max-width: 768px) {
    .book-page {
        padding: 65px 45px;
        min-height: 600px;
    }
    
    .page-content {
        font-size: 15.5px;
        min-height: 470px;
    }
    
    .toolbar-content {
        gap: 16px;
        padding: 0 10px;
        overflow-x: auto;
    }
    
    .toolbar-group {
        flex-shrink: 0;
        gap: 6px;
    }
    
    .toolbar-group label {
        font-size: 12px;
    }
    
    .toolbar-group select {
        padding: 5px 8px;
        font-size: 12px;
        min-width: 60px;
    }
}

/* Footer */
.footer {
    position: fixed;
    bottom: 16px;
    right: 16px;
    font-size: 12px;
    color: #999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    z-index: 2000;
}

.footer a {
    color: #ccc;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer a:hover {
    color: #fff;
}

/* Particle Effects */
.particle-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation: particle-float 2s ease-out forwards;
    box-shadow: 0 0 4px rgba(150, 150, 150, 0.2);
}

@keyframes particle-float {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0.5);
    }
    20% {
        opacity: 0.5;
        transform: translateY(-5px) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-30px) scale(0.3);
    }
}

.custom-caret {
    position: fixed;
    width: 2px;
    background: #8f877d;
    pointer-events: none;
    z-index: 10000;
    opacity: 0;
    border-radius: 1px;
}

.custom-caret.visible {
    opacity: 1;
}
