/* Font Definitions */

@font-face {
    font-family: Junicode;
    src: url('../fonts/Junicode.woff2') format('woff2');
    font-weight: 300 700;
    font-stretch: 75% 125%;
    font-style: normal;
}

@font-face {
    font-family: Junicode;
    src: url('../fonts/Junicode-Italic.woff2') format('woff2');
    font-weight: 300 700;
    font-stretch: 75% 125%;
    font-style: italic;
}

/* Add these rules to your CSS to fix all button margins and set fixed width */
.scribal-profiles .btn {
    width: 160px; /* Fixed width for all buttons */
    flex-grow: 0;
    flex-shrink: 0;
    color: #000; /* Dark text for better visibility */
    font-weight: 500; /* Slightly bolder text */
    border-width: 2px; /* Thicker border */
    margin: 0; /* Remove all margins */
    margin-right: 8px; /* Add right margin only */
    margin-bottom: 8px; /* Add bottom margin for spacing between rows */
}

/* Remove Bootstrap's button group margins */
.btn-group > .btn:not(:first-child),
.btn-group > .btn-group:not(:first-child) {
    margin-left: 0;
}

/* Fix for the scribal buttons container */
#scribalButtons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px; /* Use gap instead of margins for more consistent spacing */
}

/* If you're using gap, you can remove the margins from buttons */
#scribalButtons .btn {
    margin: 0;
}

.transcription-container,
.translation-container,
.main-content,
.margin-content,
.margin-content-wrapper,
.notes-section,
.top-margin,
.bottom-margin,
.left-margin,
.right-margin {
    font-family: 'Junicode', 'Gentium Plus', 'Noto Sans Symbols', 'Symbola', serif;
    font-size: 1rem;
    line-height: 1.5;
}

/* Add specific styling for superscript without changing font */
sup {
    font-family: inherit;
    font-size: 0.75em;
    line-height: 0;
    position: relative;
    top: -0.5em;
}

.add.right-vertical sup,
.add.left-vertical sup {
    top: 0;
    right: -0.5em; /* Move to the right in vertical text */
    position: relative;
}

/* Ensure footnote references maintain the font */
.footnote-ref {
    text-decoration: none;
    color: inherit;
    position: relative;
    display: inline-block;
}

.footnote-ref:hover {
    text-decoration: underline;
}

.right-aligned-block {
    display: block;
    text-align: right;
    margin: 0;
    padding: 0;
}

/* Keep the existing right-aligned for inline elements */
.right-aligned {
    display: inline;
    text-align: right;
    float: right;
    clear: right;
}



/* Add this to your existing CSS */
.resizer {
    width: 8px;
    background-color: #e0e0e0;
    cursor: col-resize;
    transition: background-color 0.2s;
    z-index: 100;
}

.resizer:hover,
.resizer:active {
    background-color: #bdbdbd;
}

/* Modify the existing resizable-layout class to add a gap */
.resizable-layout {
    display: flex;
    height: calc(100vh - 120px);
    min-height: 600px;
    width: 100%;
    position: relative;
    gap: 0; /* Ensure no gap between panels and resizer */
}

.folio-navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.current-folio {
    margin: 0 1rem;
}


/* Base Typography */
.transcription-container,
.translation-container,
.main-content,
.margin-content {
    font-family: 'Junicode', 'Gentium Plus', 'Noto Sans Symbols', 'Symbola', serif;
    font-size: 1rem;
}

.top-centre, .bottom-centre {
    text-align: center;
}

.top-right, .bottom-right {
    text-align: right;
}

/* Fix for centre-aligned text with scribal highlighting */
.centre-aligned {
    display: block;
    text-align: center;
}

/* Ensure highlighted spans inside center-aligned elements maintain centering */
.centre-aligned [class*="scribe-highlight-"] {
    display: inline;
    text-align: center;
}

/* Layout Components */
.resizable-layout {
    display: flex;
    height: calc(100vh - 120px);
    min-height: 600px;
    width: 100%;
    position: relative;
}

.left-panel {
    flex: 0 0 35%;
    min-width: 200px;
    max-width: 70%;
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    overflow-y: auto;
    overflow-x: hidden;
}

.right-panel {
    flex: 1;
    min-width: 30%;
    background-color: white;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Handshift and Scribal Styles */
.handshift-start {
    display: inline;
    position: relative;
    width: 0;
    height: 0;
    padding: 0;
    margin: 0;
}

.scribal-profiles {
    padding: 1rem;
    border-top: 1px solid #dee2e6;
}

.tbc-bold {
    font-variation-settings: "wght" 700, "wdth" 100;
}

/* Active state styling */
.scribal-profiles .btn.active {
    color: #000 !important; /* Force black text when active */
    border-color: #666 !important; /* Darker border when active */
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2); /* Inner shadow when active */
}

/* Hover state */
.scribal-profiles .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Focus state */
.scribal-profiles .btn:focus {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.2);
}

/* Active and hover combined */
.scribal-profiles .btn.active:hover {
    transform: translateY(0);
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
}

/* Margin Styles */
.margin {
    padding: 1rem;
    min-height: 50px;
    position: relative;
}

.margin-content-wrapper {
    display: flex;
    position: relative;
    gap: 15px;
}

.left-margin, .right-margin {
    flex: 0 0 150px;
    position: relative;
    min-height: 200px;
}

/* Text Modifications */
.cancelled {
    text-decoration: line-through;
}

.ink-red {
    color: #CC0000;
}

.ink-blue {
    color: #4887DF;
}

/* Notes Section */
.notes-section {
    margin-top: 2em;
    padding-top: 1em;
    border-top: 1px solid #ccc;
}

.note {
    margin-bottom: 0.5em;
    font-size: 0.9em;
    font-family: 'Junicode', 'Gentium Plus', 'Noto Sans Symbols', 'Symbola', serif;
    line-height: 1.4;
}

/* Enhanced Highlight Animations */
@keyframes highlight-pulse {
    0%, 100% {
        background-color: rgba(255, 223, 0, 0.2);
        box-shadow: 0 0 0 2px rgba(255, 223, 0, 0.1);
    }
    50% {
        background-color: rgba(255, 223, 0, 0.5);
        box-shadow: 0 0 0 4px rgba(255, 223, 0, 0.3);
    }
}

@keyframes highlight-pulse-strong {
    0%, 100% {
        background-color: rgba(255, 223, 0, 0.3);
        box-shadow: 0 0 0 3px rgba(255, 223, 0, 0.2);
        transform: scale(1);
    }
    50% {
        background-color: rgba(255, 223, 0, 0.6);
        box-shadow: 0 0 0 6px rgba(255, 223, 0, 0.4);
        transform: scale(1.02);
    }
}

.highlight.footnote-ref {
    animation: highlight-pulse 0.3s ease-in-out 3; /* 0.3s × 3 = 0.9s total */
    padding: 0 4px;
    margin: 0 -4px;
    border-radius: 4px;
    display: inline-block;
}

.highlight.note {
    animation: highlight-pulse-strong 0.3s ease-in-out 3; /* 0.3s × 3 = 0.9s total */
    padding: 8px 12px;
    margin: -8px -12px;
    border-radius: 6px;
    display: block;
}

.note a {
    text-decoration: none;
    color: inherit;
}

.note a:hover {
    text-decoration: underline;
}

.smudge-line, .smudge-char, .erasure {
    color: rgba(0, 0, 0, 0.4);
    /* text-shadow: 0 0 3px rgba(0, 0, 0, 0.6); */
    filter: blur(0.5px);
}

/* Gaps in manuscript */
.gap-space {
    display: inline-block;
    background-color: rgba(200, 200, 200, 0.2);
    border: 1px dashed #999;
    text-align: center;
    color: #666;
    font-size: 0.8em;
    min-width: 1em;
    vertical-align: middle;

}

.gap-space-line {
    display: inline-block;
    border-bottom: 1px solid #999;
    height: 0.5em;
    vertical-align: baseline;
    margin: 0 2px;
}

.gap-hole {
    display: inline-block;
    background-color: rgba(255, 220, 220, 0.2);
    border: 1px solid #d99;
    border-radius: 3px;
    text-align: center;
    color: #900;
    font-size: 0.8em;
    min-width: 1em;
    vertical-align: middle;

}

/* Container styling */
.margin-content-wrapper {
    display: flex;
    position: relative;
    gap: 20px; /* Space between margins and main content */
}

.left-margin, .right-margin {
    flex: 0 0 150px;
    position: relative;
    min-height: 200px;
}

.main-content {
    flex: 1;
    position: relative;
    padding: 0 10px;
}

/* Vertical text styling for margin notes */
.add.right-vertical {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    margin: 1em 0;
    padding: 0.5em 0;
}

.add.left-vertical {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    margin: 1em 0;
    padding: 0.5em 0;
}


/* Hover effects for both types
.gap-space:hover,
.gap-hole:hover {
    background-color: rgba(200, 200, 200, 0.3);
} */

/* If precision is marked as low
.gap-space[data-precision="low"],
.gap-hole[data-precision="low"] {
    border-style: dotted;
} */

/* Table Styles */
.manuscript-table {
    border-collapse: collapse;
    margin: 1em 0;
    width: 100%;
}

/* Table highlighting styles */
.manuscript-table td {
    position: relative; /* For proper highlight containment */
}

.manuscript-table td [class^="scribe-highlight-"] {
    display: inline; /* Keep highlights inline within cells */
}

/* Prevent highlight overflow */
.manuscript-table td > * {
    position: relative;
    z-index: 1;
}

.manuscript-table td {
    border: 1px solid #ddd;
    padding: 8px;
    vertical-align: top;
}

.manuscript-table tr:nth-child(even) {
    background-color: #f8f9fa;
}

.manuscript-table tr:hover {
    background-color: #f5f5f5;
}

.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator {
    display: inline;
}
#message-container {
    margin-top: 1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .resizable-layout {
        flex-direction: column;
        height: auto;
    }

    .left-panel, .right-panel {
        flex: none;
        width: 100%;
        max-width: 100%;
        min-width: 100%;
    }

    .resizer {
        display: none;
    }
}

/* Margin note spacing and positioning */
.margin-content {
    position: relative;
    padding: 1rem;
}

/* Safari-specific vertical text fixes - replace existing Safari fixes with these */
.safari-browser .add.right-vertical,
.safari-browser .add.left-vertical {
    /* Fix for initial visibility */
    display: block !important;
    width: 160px !important;
    margin-left: -25px !important;
    padding-left: 10px !important;
    transform: translateX(-5px) !important;
    position: relative !important;
    z-index: 1 !important;

    /* Fix Safari vertical text rendering */
    -webkit-writing-mode: vertical-rl !important;
    writing-mode: vertical-rl !important;
    text-orientation: mixed !important;

    /* Prevent internal wrapping issues */
    word-break: keep-all !important;
    white-space: nowrap !important;
    line-height: 1.4 !important;

    /* Better overflow handling */
    overflow: visible !important;
    max-height: none !important;
}

/* Fix for the Safari containers */
.safari-browser .right-margin,
.safari-browser .left-margin {
    overflow: visible !important;
    position: relative !important;
    z-index: 1 !important;
    width: 150px !important;
}

/* Ensure the content wrapper can handle the overflow */
.safari-browser .margin-content-wrapper {
    overflow: visible !important;
}

/* Force Safari to render correctly */
.safari-browser .margin-content {
    position: relative !important;
    transform: translateZ(0) !important;
    -webkit-transform: translateZ(0) !important;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
}

/* Fix for Safari font rendering in vertical text */
.safari-browser .add.right-vertical,
.safari-browser .add.left-vertical {
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

.margin-content .add {
    display: block;
    margin: 1.5em 0;
    position: relative;
}

/* Right margin specific spacing */
.margin-content.right-centre .add.right {
    text-align: left;
    min-height: 300px;
}

/* Left margin specific spacing */
.margin-content.left-centre .add.left {
    text-align: left;
    min-height: 300px;
}

/* Vertical margins between consecutive notes */
.margin-content .add + .add {
    margin-top: 2em;
}

/* Ensure proper alignment with main text */
.margin-content-wrapper {
    align-items: flex-start;
}

/* Prevent margin notes from overlapping */
.margin-content .add {
    clear: both;
    position: relative;
}
/* Make scribal highlighting more precise */
.centre-aligned .scribe-highlight-sc001,
.centre-aligned .scribe-highlight-sc002,
.centre-aligned .scribe-highlight-sc003,
.centre-aligned .scribe-highlight-sc004,
.centre-aligned .scribe-highlight-sc005,
.centre-aligned [class*="scribe-highlight-"] {
    display: inline;
    width: auto;
    text-align: inherit;
}

/* Ensure spans inside centered content don't break the centering */
.centre-aligned span {
    display: inline;
    text-align: inherit;
}

/* Make all scribal highlighting spans work with text alignment */
[class*="scribe-highlight-"] {
    display: inline;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}
/* CSS to preserve alignment in highlighted text */
.centre-aligned, .top-centre, .bottom-centre {
    display: block;
    text-align: center !important;
}

/* Ensure highlights inside centered elements maintain centering */
.centre-aligned [class*="scribe-highlight-"],
.top-centre [class*="scribe-highlight-"],
.bottom-centre [class*="scribe-highlight-"] {
    text-align: inherit !important;
    display: inline !important;
}

/* Prevent highlight spans from breaking alignment */
[class*="scribe-highlight-"] {
    display: inline !important;
}
/* Improved CSS for maintaining text alignment in highlights */
.centre-aligned, .top-centre, .bottom-centre {
    display: block !important;
    text-align: center !important;
}

.right-aligned, .top-right, .bottom-right {
    display: block !important;
    text-align: right !important;
}

/* Ensure highlights maintain the parent's text alignment */
.text-center {
    text-align: center !important;
}

.text-right {
    text-align: right !important;
}

/* Ensure all scribal highlight spans preserve their parent's alignment */
[class*="scribe-highlight-"] {
    display: inline !important;
    text-align: inherit !important;
}

/* Special handling for spans in centered and right-aligned parents */
.centre-aligned [class*="scribe-highlight-"],
.top-centre [class*="scribe-highlight-"],
.bottom-centre [class*="scribe-highlight-"] {
    display: inline !important;
    text-align: center !important;
}

.right-aligned [class*="scribe-highlight-"],
.top-right [class*="scribe-highlight-"],
.bottom-right [class*="scribe-highlight-"] {
    display: inline !important;
    text-align: right !important;
}

/* For browser compatibility */
span.centre-aligned, span.top-centre, span.bottom-centre {
    width: 100%;
}

span.right-aligned, span.top-right, span.bottom-right {
    width: 100%;
}
/* Add this to your CSS */
/* Force text alignment preservation for highlighted elements */
.centre-aligned,
.top-centre,
.bottom-centre,
span.centre-aligned,
span.top-centre,
span.bottom-centre {
    display: block !important;
    text-align: center !important;
}

/* Ensure parent element alignment is preserved */
.centre-aligned *,
.top-centre *,
.bottom-centre * {
    text-align: inherit !important;
}

/* Make all highlight spans display properly */
[class*="scribe-highlight-"] {
    display: inline !important;
    background-color: inherit; /* Will be overridden by the dynamic styles */
}

/* Fix for centered/right alignment when elements are highlighted */
[class*="scribe-highlight-"].centre-aligned,
[class*="scribe-highlight-"].top-centre,
[class*="scribe-highlight-"].bottom-centre {
    display: block !important;
    text-align: center !important;
    width: 100% !important;
}

[class*="scribe-highlight-"].right-aligned,
[class*="scribe-highlight-"].top-right,
[class*="scribe-highlight-"].bottom-right {
    display: block !important;
    text-align: right !important;
    width: 100% !important;
}
/* Add these CSS rules to handle highlighting better */

/* Base highlight styling for scribal sections */
[class*="scribe-highlight-"] {
    display: inline;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* Wrapper spans should always be inline */
.scribe-wrapper {
    display: inline !important;
    text-align: inherit !important;
}

/* Special handling for aligned elements with highlights */
.centre-aligned[class*="scribe-highlight-"],
.top-centre[class*="scribe-highlight-"],
.bottom-centre[class*="scribe-highlight-"] {
    display: block !important;
    text-align: center !important;
}

.right-aligned[class*="scribe-highlight-"],
.top-right[class*="scribe-highlight-"],
.bottom-right[class*="scribe-highlight-"] {
    display: block !important;
    text-align: right !important;
}

/* Ensure the text inside aligned elements stays aligned */
.centre-aligned[class*="scribe-highlight-"] *,
.top-centre[class*="scribe-highlight-"] *,
.bottom-centre[class*="scribe-highlight-"] * {
    text-align: center !important;
}

.right-aligned[class*="scribe-highlight-"] *,
.top-right[class*="scribe-highlight-"] *,
.bottom-right[class*="scribe-highlight-"] * {
    text-align: right !important;
}

/* Handle inline highlights within special containers */
.centre-aligned .scribe-wrapper,
.top-centre .scribe-wrapper,
.bottom-centre .scribe-wrapper {
    text-align: center !important;
}

.right-aligned .scribe-wrapper,
.top-right .scribe-wrapper,
.bottom-right .scribe-wrapper {
    text-align: right !important;
}